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 "hda_codec.h"
34 #include "hda_local.h"
35 #include "hda_patch.h"
38 #define NUM_CONTROL_ALLOC 32
39 #define STAC_PWR_EVENT 0x20
40 #define STAC_HP_EVENT 0x30
41 #define STAC_VREF_EVENT 0x40
106 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
107 * is given, one of the above models will be
108 * chosen according to the subsystem id. */
109 /* for backward compatibility */
133 struct sigmatel_spec {
134 struct snd_kcontrol_new *mixers[4];
135 unsigned int num_mixers;
138 unsigned int surr_switch: 1;
139 unsigned int line_switch: 1;
140 unsigned int mic_switch: 1;
141 unsigned int alt_switch: 1;
142 unsigned int hp_detect: 1;
143 unsigned int spdif_mute: 1;
146 unsigned int eapd_mask;
147 unsigned int gpio_mask;
148 unsigned int gpio_dir;
149 unsigned int gpio_data;
150 unsigned int gpio_mute;
153 unsigned int stream_delay;
155 /* analog loopback */
156 unsigned char aloopback_mask;
157 unsigned char aloopback_shift;
159 /* power management */
160 unsigned int num_pwrs;
161 unsigned int *pwr_mapping;
166 struct hda_input_mux *mono_mux;
167 struct hda_input_mux *amp_mux;
168 unsigned int cur_mmux;
169 struct hda_multi_out multiout;
170 hda_nid_t dac_nids[5];
174 unsigned int num_adcs;
176 unsigned int num_muxes;
177 hda_nid_t *dmic_nids;
178 unsigned int num_dmics;
179 hda_nid_t *dmux_nids;
180 unsigned int num_dmuxes;
181 hda_nid_t *smux_nids;
182 unsigned int num_smuxes;
183 const char **spdif_labels;
185 hda_nid_t dig_in_nid;
187 hda_nid_t anabeep_nid;
188 hda_nid_t digbeep_nid;
192 unsigned int num_pins;
193 unsigned int *pin_configs;
194 unsigned int *bios_pin_configs;
196 /* codec specific stuff */
197 struct hda_verb *init;
198 struct snd_kcontrol_new *mixer;
201 struct hda_input_mux *dinput_mux;
202 unsigned int cur_dmux[2];
203 struct hda_input_mux *input_mux;
204 unsigned int cur_mux[3];
205 struct hda_input_mux *sinput_mux;
206 unsigned int cur_smux[2];
207 unsigned int cur_amux;
209 unsigned int num_amps;
210 unsigned int powerdown_adcs;
213 unsigned int io_switch[2];
214 unsigned int clfe_swap;
215 unsigned int hp_switch; /* NID of HP as line-out */
216 unsigned int aloopback;
218 struct hda_pcm pcm_rec[2]; /* PCM information */
220 /* dynamic controls and input_mux */
221 struct auto_pin_cfg autocfg;
222 unsigned int num_kctl_alloc, num_kctl_used;
223 struct snd_kcontrol_new *kctl_alloc;
224 struct hda_input_mux private_dimux;
225 struct hda_input_mux private_imux;
226 struct hda_input_mux private_smux;
227 struct hda_input_mux private_amp_mux;
228 struct hda_input_mux private_mono_mux;
231 static hda_nid_t stac9200_adc_nids[1] = {
235 static hda_nid_t stac9200_mux_nids[1] = {
239 static hda_nid_t stac9200_dac_nids[1] = {
243 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
244 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
248 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
252 static hda_nid_t stac92hd73xx_adc_nids[2] = {
256 #define DELL_M6_AMP 2
257 static hda_nid_t stac92hd73xx_amp_nids[3] = {
261 #define STAC92HD73XX_NUM_DMICS 2
262 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
266 #define STAC92HD73_DAC_COUNT 5
267 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
268 0x15, 0x16, 0x17, 0x18, 0x19,
271 static hda_nid_t stac92hd73xx_mux_nids[4] = {
272 0x28, 0x29, 0x2a, 0x2b,
275 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
279 static hda_nid_t stac92hd73xx_smux_nids[2] = {
283 #define STAC92HD83XXX_NUM_DMICS 2
284 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
288 #define STAC92HD81_DAC_COUNT 2
289 #define STAC92HD83_DAC_COUNT 3
290 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
294 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
298 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
302 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
306 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
310 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
311 0x03, 0x0c, 0x10, 0x40,
314 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
318 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
322 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
326 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
330 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
334 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
338 #define STAC92HD71BXX_NUM_DMICS 2
339 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
343 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
347 static hda_nid_t stac925x_adc_nids[1] = {
351 static hda_nid_t stac925x_mux_nids[1] = {
355 static hda_nid_t stac925x_dac_nids[1] = {
359 #define STAC925X_NUM_DMICS 1
360 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
364 static hda_nid_t stac925x_dmux_nids[1] = {
368 static hda_nid_t stac922x_adc_nids[2] = {
372 static hda_nid_t stac922x_mux_nids[2] = {
376 static hda_nid_t stac927x_adc_nids[3] = {
380 static hda_nid_t stac927x_mux_nids[3] = {
384 static hda_nid_t stac927x_smux_nids[1] = {
388 static hda_nid_t stac927x_dac_nids[6] = {
389 0x02, 0x03, 0x04, 0x05, 0x06, 0
392 static hda_nid_t stac927x_dmux_nids[1] = {
396 #define STAC927X_NUM_DMICS 2
397 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
401 static const char *stac927x_spdif_labels[5] = {
402 "Digital Playback", "ADAT", "Analog Mux 1",
403 "Analog Mux 2", "Analog Mux 3"
406 static hda_nid_t stac9205_adc_nids[2] = {
410 static hda_nid_t stac9205_mux_nids[2] = {
414 static hda_nid_t stac9205_dmux_nids[1] = {
418 static hda_nid_t stac9205_smux_nids[1] = {
422 #define STAC9205_NUM_DMICS 2
423 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
427 static hda_nid_t stac9200_pin_nids[8] = {
428 0x08, 0x09, 0x0d, 0x0e,
429 0x0f, 0x10, 0x11, 0x12,
432 static hda_nid_t stac925x_pin_nids[8] = {
433 0x07, 0x08, 0x0a, 0x0b,
434 0x0c, 0x0d, 0x10, 0x11,
437 static hda_nid_t stac922x_pin_nids[10] = {
438 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
439 0x0f, 0x10, 0x11, 0x15, 0x1b,
442 static hda_nid_t stac92hd73xx_pin_nids[13] = {
443 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
444 0x0f, 0x10, 0x11, 0x12, 0x13,
448 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
449 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
450 0x0f, 0x10, 0x11, 0x12, 0x13,
451 0x1d, 0x1e, 0x1f, 0x20
453 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
454 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
455 0x0f, 0x14, 0x18, 0x19, 0x1e,
459 static hda_nid_t stac927x_pin_nids[14] = {
460 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
461 0x0f, 0x10, 0x11, 0x12, 0x13,
462 0x14, 0x21, 0x22, 0x23,
465 static hda_nid_t stac9205_pin_nids[12] = {
466 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
467 0x0f, 0x14, 0x16, 0x17, 0x18,
471 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
473 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
474 struct snd_ctl_elem_value *ucontrol)
476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
477 struct sigmatel_spec *spec = codec->spec;
478 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
480 kcontrol->private_value ^= get_amp_nid(kcontrol);
481 kcontrol->private_value |= nid;
483 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
486 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
487 struct snd_ctl_elem_value *ucontrol)
489 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
490 struct sigmatel_spec *spec = codec->spec;
491 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
493 kcontrol->private_value ^= get_amp_nid(kcontrol);
494 kcontrol->private_value |= nid;
496 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
499 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
500 struct snd_ctl_elem_info *uinfo)
502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
503 struct sigmatel_spec *spec = codec->spec;
504 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
507 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
508 struct snd_ctl_elem_value *ucontrol)
510 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
511 struct sigmatel_spec *spec = codec->spec;
512 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
514 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
518 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
519 struct snd_ctl_elem_value *ucontrol)
521 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
522 struct sigmatel_spec *spec = codec->spec;
523 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
525 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
526 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
529 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
530 struct snd_ctl_elem_info *uinfo)
532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
533 struct sigmatel_spec *spec = codec->spec;
534 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
537 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
538 struct snd_ctl_elem_value *ucontrol)
540 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
541 struct sigmatel_spec *spec = codec->spec;
542 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
544 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
548 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
549 struct snd_ctl_elem_value *ucontrol)
551 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
552 struct sigmatel_spec *spec = codec->spec;
553 struct hda_input_mux *smux = &spec->private_smux;
554 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
558 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
559 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
563 if (spec->spdif_mute) {
565 nid = spec->multiout.dig_out_nid;
567 nid = codec->slave_dig_outs[smux_idx - 1];
568 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
571 val = AMP_OUT_UNMUTE;
572 /* un/mute SPDIF out */
573 snd_hda_codec_write_cache(codec, nid, 0,
574 AC_VERB_SET_AMP_GAIN_MUTE, val);
579 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
581 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
582 struct sigmatel_spec *spec = codec->spec;
583 return snd_hda_input_mux_info(spec->input_mux, uinfo);
586 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
589 struct sigmatel_spec *spec = codec->spec;
590 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
592 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
596 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
602 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
603 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
606 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
607 struct snd_ctl_elem_info *uinfo)
609 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
610 struct sigmatel_spec *spec = codec->spec;
611 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
614 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 struct sigmatel_spec *spec = codec->spec;
620 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
624 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_value *ucontrol)
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
630 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
631 spec->mono_nid, &spec->cur_mmux);
634 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_info *uinfo)
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 struct sigmatel_spec *spec = codec->spec;
639 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
642 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
648 ucontrol->value.enumerated.item[0] = spec->cur_amux;
652 static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
653 struct snd_ctl_elem_value *ucontrol)
655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
656 struct sigmatel_spec *spec = codec->spec;
657 struct snd_kcontrol *ctl =
658 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
662 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
663 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
665 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
669 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
671 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
672 struct snd_ctl_elem_value *ucontrol)
674 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
675 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
676 struct sigmatel_spec *spec = codec->spec;
678 ucontrol->value.integer.value[0] = !!(spec->aloopback &
679 (spec->aloopback_mask << idx));
683 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
684 struct snd_ctl_elem_value *ucontrol)
686 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
687 struct sigmatel_spec *spec = codec->spec;
688 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
689 unsigned int dac_mode;
690 unsigned int val, idx_val;
692 idx_val = spec->aloopback_mask << idx;
693 if (ucontrol->value.integer.value[0])
694 val = spec->aloopback | idx_val;
696 val = spec->aloopback & ~idx_val;
697 if (spec->aloopback == val)
700 spec->aloopback = val;
702 /* Only return the bits defined by the shift value of the
703 * first two bytes of the mask
705 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
706 kcontrol->private_value & 0xFFFF, 0x0);
707 dac_mode >>= spec->aloopback_shift;
709 if (spec->aloopback & idx_val) {
710 snd_hda_power_up(codec);
713 snd_hda_power_down(codec);
714 dac_mode &= ~idx_val;
717 snd_hda_codec_write_cache(codec, codec->afg, 0,
718 kcontrol->private_value >> 16, dac_mode);
723 static struct hda_verb stac9200_core_init[] = {
724 /* set dac0mux for dac converter */
725 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
729 static struct hda_verb stac9200_eapd_init[] = {
730 /* set dac0mux for dac converter */
731 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
732 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
736 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
737 /* set master volume and direct control */
738 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
739 /* setup audio connections */
740 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
741 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
742 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
743 /* setup adcs to point to mixer */
744 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
745 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
746 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
747 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
748 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
749 /* setup import muxs */
750 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
751 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
752 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
753 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
757 static struct hda_verb dell_eq_core_init[] = {
758 /* set master volume to max value without distortion
759 * and direct control */
760 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
761 /* setup audio connections */
762 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
763 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
764 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
765 /* setup adcs to point to mixer */
766 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
767 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
768 /* setup import muxs */
769 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
770 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
771 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
772 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
776 static struct hda_verb dell_m6_core_init[] = {
777 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
778 /* setup audio connections */
779 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
780 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
781 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
782 /* setup adcs to point to mixer */
783 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
784 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
785 /* setup import muxs */
786 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
787 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
788 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
793 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
794 /* set master volume and direct control */
795 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
796 /* setup audio connections */
797 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
798 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
799 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
800 /* connect hp ports to dac3 */
801 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
802 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
803 /* setup adcs to point to mixer */
804 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
805 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
806 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
807 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
808 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
809 /* setup import muxs */
810 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
811 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
812 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
817 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
818 /* set master volume and direct control */
819 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
820 /* setup audio connections */
821 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
822 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
823 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
824 /* dac3 is connected to import3 mux */
825 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
826 /* connect hp ports to dac4 */
827 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
828 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
829 /* setup adcs to point to mixer */
830 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
831 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
832 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
833 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
834 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
835 /* setup import muxs */
836 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
837 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
838 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
839 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
843 static struct hda_verb stac92hd83xxx_core_init[] = {
844 /* start of config #1 */
845 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
847 /* start of config #2 */
848 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
849 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
850 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
852 /* power state controls amps */
853 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
856 static struct hda_verb stac92hd71bxx_core_init[] = {
857 /* set master volume and direct control */
858 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
859 /* connect headphone jack to dac1 */
860 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
861 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
862 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
863 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
864 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
867 #define HD_DISABLE_PORTF 2
868 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
869 /* start of config #1 */
871 /* connect port 0f to audio mixer */
872 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
873 /* unmute right and left channels for node 0x0f */
874 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
875 /* start of config #2 */
877 /* set master volume and direct control */
878 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
879 /* connect headphone jack to dac1 */
880 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
881 /* unmute right and left channels for nodes 0x0a, 0xd */
882 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
883 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
887 static struct hda_verb stac925x_core_init[] = {
888 /* set dac0mux for dac converter */
889 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
893 static struct hda_verb stac922x_core_init[] = {
894 /* set master volume and direct control */
895 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
899 static struct hda_verb d965_core_init[] = {
900 /* set master volume and direct control */
901 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
902 /* unmute node 0x1b */
903 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
904 /* select node 0x03 as DAC */
905 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
909 static struct hda_verb stac927x_core_init[] = {
910 /* set master volume and direct control */
911 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
912 /* enable analog pc beep path */
913 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
917 static struct hda_verb stac9205_core_init[] = {
918 /* set master volume and direct control */
919 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
920 /* enable analog pc beep path */
921 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
925 #define STAC_MONO_MUX \
927 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
928 .name = "Mono Mux", \
930 .info = stac92xx_mono_mux_enum_info, \
931 .get = stac92xx_mono_mux_enum_get, \
932 .put = stac92xx_mono_mux_enum_put, \
935 #define STAC_AMP_MUX \
937 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
938 .name = "Amp Selector Capture Switch", \
940 .info = stac92xx_amp_mux_enum_info, \
941 .get = stac92xx_amp_mux_enum_get, \
942 .put = stac92xx_amp_mux_enum_put, \
945 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
947 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
950 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
951 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
952 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
953 .info = stac92xx_amp_volume_info, \
954 .get = stac92xx_amp_volume_get, \
955 .put = stac92xx_amp_volume_put, \
956 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
957 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
960 #define STAC_INPUT_SOURCE(cnt) \
962 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
963 .name = "Input Source", \
965 .info = stac92xx_mux_enum_info, \
966 .get = stac92xx_mux_enum_get, \
967 .put = stac92xx_mux_enum_put, \
970 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
972 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
973 .name = "Analog Loopback", \
975 .info = stac92xx_aloopback_info, \
976 .get = stac92xx_aloopback_get, \
977 .put = stac92xx_aloopback_put, \
978 .private_value = verb_read | (verb_write << 16), \
981 static struct snd_kcontrol_new stac9200_mixer[] = {
982 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
983 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
984 STAC_INPUT_SOURCE(1),
985 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
986 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
990 #define DELL_M6_MIXER 6
991 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
992 /* start of config #1 */
993 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
994 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
996 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
997 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
999 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1000 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1002 /* start of config #2 */
1003 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1004 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1006 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1007 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1009 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1011 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1012 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1014 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1015 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1020 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1021 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1023 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1024 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1026 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1027 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1029 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1030 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1032 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1033 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1035 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1036 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1038 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1039 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1041 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1042 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1046 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1047 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1049 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1050 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1052 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1053 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1055 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1056 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1058 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1059 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1061 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1062 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1064 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1065 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1067 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1068 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1073 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1074 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1075 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1077 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1078 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1080 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1081 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1083 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1084 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1086 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1087 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1089 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1090 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1093 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1094 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1099 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1100 STAC_INPUT_SOURCE(2),
1101 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1103 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1104 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1106 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1107 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1108 /* analog pc-beep replaced with digital beep support */
1110 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1111 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1114 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1115 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1117 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1118 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1120 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1121 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1123 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1124 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1128 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1129 STAC_INPUT_SOURCE(2),
1130 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1132 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1135 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1136 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1140 static struct snd_kcontrol_new stac925x_mixer[] = {
1141 STAC_INPUT_SOURCE(1),
1142 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1143 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1147 static struct snd_kcontrol_new stac9205_mixer[] = {
1148 STAC_INPUT_SOURCE(2),
1149 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1151 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1152 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1155 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1159 /* This needs to be generated dynamically based on sequence */
1160 static struct snd_kcontrol_new stac922x_mixer[] = {
1161 STAC_INPUT_SOURCE(2),
1162 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1163 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1165 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1166 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1171 static struct snd_kcontrol_new stac927x_mixer[] = {
1172 STAC_INPUT_SOURCE(3),
1173 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1178 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1179 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1181 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1182 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1186 static struct snd_kcontrol_new stac_dmux_mixer = {
1187 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1188 .name = "Digital Input Source",
1189 /* count set later */
1190 .info = stac92xx_dmux_enum_info,
1191 .get = stac92xx_dmux_enum_get,
1192 .put = stac92xx_dmux_enum_put,
1195 static struct snd_kcontrol_new stac_smux_mixer = {
1196 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1197 .name = "IEC958 Playback Source",
1198 /* count set later */
1199 .info = stac92xx_smux_enum_info,
1200 .get = stac92xx_smux_enum_get,
1201 .put = stac92xx_smux_enum_put,
1204 static const char *slave_vols[] = {
1205 "Front Playback Volume",
1206 "Surround Playback Volume",
1207 "Center Playback Volume",
1208 "LFE Playback Volume",
1209 "Side Playback Volume",
1210 "Headphone Playback Volume",
1211 "Headphone Playback Volume",
1212 "Speaker Playback Volume",
1213 "External Speaker Playback Volume",
1214 "Speaker2 Playback Volume",
1218 static const char *slave_sws[] = {
1219 "Front Playback Switch",
1220 "Surround Playback Switch",
1221 "Center Playback Switch",
1222 "LFE Playback Switch",
1223 "Side Playback Switch",
1224 "Headphone Playback Switch",
1225 "Headphone Playback Switch",
1226 "Speaker Playback Switch",
1227 "External Speaker Playback Switch",
1228 "Speaker2 Playback Switch",
1229 "IEC958 Playback Switch",
1233 static int stac92xx_build_controls(struct hda_codec *codec)
1235 struct sigmatel_spec *spec = codec->spec;
1239 err = snd_hda_add_new_ctls(codec, spec->mixer);
1243 for (i = 0; i < spec->num_mixers; i++) {
1244 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1248 if (spec->num_dmuxes > 0) {
1249 stac_dmux_mixer.count = spec->num_dmuxes;
1250 err = snd_ctl_add(codec->bus->card,
1251 snd_ctl_new1(&stac_dmux_mixer, codec));
1255 if (spec->num_smuxes > 0) {
1256 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1257 struct hda_input_mux *smux = &spec->private_smux;
1258 /* check for mute support on SPDIF out */
1259 if (wcaps & AC_WCAP_OUT_AMP) {
1260 smux->items[smux->num_items].label = "Off";
1261 smux->items[smux->num_items].index = 0;
1263 spec->spdif_mute = 1;
1265 stac_smux_mixer.count = spec->num_smuxes;
1266 err = snd_ctl_add(codec->bus->card,
1267 snd_ctl_new1(&stac_smux_mixer, codec));
1272 if (spec->multiout.dig_out_nid) {
1273 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1276 err = snd_hda_create_spdif_share_sw(codec,
1280 spec->multiout.share_spdif = 1;
1282 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1283 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1288 /* if we have no master control, let's create it */
1289 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1290 unsigned int vmaster_tlv[4];
1291 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1292 HDA_OUTPUT, vmaster_tlv);
1293 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1294 vmaster_tlv, slave_vols);
1298 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1299 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1308 static unsigned int ref9200_pin_configs[8] = {
1309 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1310 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1314 STAC 9200 pin configs for
1319 static unsigned int dell9200_d21_pin_configs[8] = {
1320 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1321 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1325 STAC 9200 pin configs for
1329 static unsigned int dell9200_d22_pin_configs[8] = {
1330 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1331 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1335 STAC 9200 pin configs for
1336 102801C4 (Dell Dimension E310)
1343 static unsigned int dell9200_d23_pin_configs[8] = {
1344 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1345 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1350 STAC 9200-32 pin configs for
1351 102801B5 (Dell Inspiron 630m)
1352 102801D8 (Dell Inspiron 640m)
1354 static unsigned int dell9200_m21_pin_configs[8] = {
1355 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1356 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1360 STAC 9200-32 pin configs for
1361 102801C2 (Dell Latitude D620)
1363 102801CC (Dell Latitude D820)
1367 static unsigned int dell9200_m22_pin_configs[8] = {
1368 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1369 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1373 STAC 9200-32 pin configs for
1374 102801CE (Dell XPS M1710)
1375 102801CF (Dell Precision M90)
1377 static unsigned int dell9200_m23_pin_configs[8] = {
1378 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1379 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1383 STAC 9200-32 pin configs for
1386 102801CB (Dell Latitude 120L)
1389 static unsigned int dell9200_m24_pin_configs[8] = {
1390 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1391 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1395 STAC 9200-32 pin configs for
1396 102801BD (Dell Inspiron E1505n)
1400 static unsigned int dell9200_m25_pin_configs[8] = {
1401 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1402 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1406 STAC 9200-32 pin configs for
1407 102801F5 (Dell Inspiron 1501)
1410 static unsigned int dell9200_m26_pin_configs[8] = {
1411 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1412 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1417 102801CD (Dell Inspiron E1705/9400)
1419 static unsigned int dell9200_m27_pin_configs[8] = {
1420 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1421 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1424 static unsigned int oqo9200_pin_configs[8] = {
1425 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1426 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1430 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1431 [STAC_REF] = ref9200_pin_configs,
1432 [STAC_9200_OQO] = oqo9200_pin_configs,
1433 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1434 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1435 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1436 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1437 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1438 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1439 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1440 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1441 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1442 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1443 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1446 static const char *stac9200_models[STAC_9200_MODELS] = {
1448 [STAC_9200_OQO] = "oqo",
1449 [STAC_9200_DELL_D21] = "dell-d21",
1450 [STAC_9200_DELL_D22] = "dell-d22",
1451 [STAC_9200_DELL_D23] = "dell-d23",
1452 [STAC_9200_DELL_M21] = "dell-m21",
1453 [STAC_9200_DELL_M22] = "dell-m22",
1454 [STAC_9200_DELL_M23] = "dell-m23",
1455 [STAC_9200_DELL_M24] = "dell-m24",
1456 [STAC_9200_DELL_M25] = "dell-m25",
1457 [STAC_9200_DELL_M26] = "dell-m26",
1458 [STAC_9200_DELL_M27] = "dell-m27",
1459 [STAC_9200_GATEWAY] = "gateway",
1460 [STAC_9200_PANASONIC] = "panasonic",
1463 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1464 /* SigmaTel reference board */
1465 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1466 "DFI LanParty", STAC_REF),
1467 /* Dell laptops have BIOS problem */
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1469 "unknown Dell", STAC_9200_DELL_D21),
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1471 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1473 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1475 "unknown Dell", STAC_9200_DELL_D22),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1477 "unknown Dell", STAC_9200_DELL_D22),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1479 "Dell Latitude D620", STAC_9200_DELL_M22),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1481 "unknown Dell", STAC_9200_DELL_D23),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1483 "unknown Dell", STAC_9200_DELL_D23),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1485 "unknown Dell", STAC_9200_DELL_M22),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1487 "unknown Dell", STAC_9200_DELL_M24),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1489 "unknown Dell", STAC_9200_DELL_M24),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1491 "Dell Latitude 120L", STAC_9200_DELL_M24),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1493 "Dell Latitude D820", STAC_9200_DELL_M22),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1495 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1497 "Dell XPS M1710", STAC_9200_DELL_M23),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1499 "Dell Precision M90", STAC_9200_DELL_M23),
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1501 "unknown Dell", STAC_9200_DELL_M22),
1502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1503 "unknown Dell", STAC_9200_DELL_M22),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1505 "unknown Dell", STAC_9200_DELL_M22),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1507 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1509 "unknown Dell", STAC_9200_DELL_D23),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1511 "unknown Dell", STAC_9200_DELL_D23),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1513 "unknown Dell", STAC_9200_DELL_D21),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1515 "unknown Dell", STAC_9200_DELL_D23),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1517 "unknown Dell", STAC_9200_DELL_D21),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1519 "unknown Dell", STAC_9200_DELL_M25),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1521 "unknown Dell", STAC_9200_DELL_M25),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1523 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1524 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1525 "unknown Dell", STAC_9200_DELL_M26),
1527 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1528 /* Gateway machines needs EAPD to be set on resume */
1529 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1530 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1532 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1535 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1539 static unsigned int ref925x_pin_configs[8] = {
1540 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1541 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1544 static unsigned int stac925x_MA6_pin_configs[8] = {
1545 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1546 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1549 static unsigned int stac925x_PA6_pin_configs[8] = {
1550 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1551 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1554 static unsigned int stac925xM2_2_pin_configs[8] = {
1555 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1556 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1559 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1560 [STAC_REF] = ref925x_pin_configs,
1561 [STAC_M2_2] = stac925xM2_2_pin_configs,
1562 [STAC_MA6] = stac925x_MA6_pin_configs,
1563 [STAC_PA6] = stac925x_PA6_pin_configs,
1566 static const char *stac925x_models[STAC_925x_MODELS] = {
1568 [STAC_M2_2] = "m2-2",
1573 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1574 /* SigmaTel reference board */
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1576 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1577 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1578 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1579 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1580 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1581 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1585 static unsigned int ref92hd73xx_pin_configs[13] = {
1586 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1587 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1588 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1592 static unsigned int dell_m6_pin_configs[13] = {
1593 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1594 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1595 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1599 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1600 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1601 [STAC_DELL_M6] = dell_m6_pin_configs,
1602 [STAC_DELL_EQ] = dell_m6_pin_configs,
1605 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1606 [STAC_92HD73XX_REF] = "ref",
1607 [STAC_DELL_M6] = "dell-m6",
1608 [STAC_DELL_EQ] = "dell-eq",
1611 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1612 /* SigmaTel reference board */
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1614 "DFI LanParty", STAC_92HD73XX_REF),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1616 "unknown Dell", STAC_DELL_M6),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1618 "unknown Dell", STAC_DELL_M6),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1620 "unknown Dell", STAC_DELL_M6),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1622 "unknown Dell", STAC_DELL_M6),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1624 "unknown Dell", STAC_DELL_M6),
1625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1626 "unknown Dell", STAC_DELL_M6),
1627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1628 "unknown Dell", STAC_DELL_M6),
1632 static unsigned int ref92hd83xxx_pin_configs[14] = {
1633 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1634 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1635 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1636 0x01451160, 0x98560170,
1639 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1640 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1643 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1644 [STAC_92HD83XXX_REF] = "ref",
1647 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1648 /* SigmaTel reference board */
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1650 "DFI LanParty", STAC_92HD71BXX_REF),
1653 static unsigned int ref92hd71bxx_pin_configs[11] = {
1654 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1655 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1656 0x90a000f0, 0x01452050, 0x01452050,
1659 static unsigned int dell_m4_1_pin_configs[11] = {
1660 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1661 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1662 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1665 static unsigned int dell_m4_2_pin_configs[11] = {
1666 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1667 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1668 0x40f000f0, 0x044413b0, 0x044413b0,
1671 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1672 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1673 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1674 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1675 [STAC_HP_M4] = NULL,
1678 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1679 [STAC_92HD71BXX_REF] = "ref",
1680 [STAC_DELL_M4_1] = "dell-m4-1",
1681 [STAC_DELL_M4_2] = "dell-m4-2",
1682 [STAC_HP_M4] = "hp-m4",
1685 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1686 /* SigmaTel reference board */
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1688 "DFI LanParty", STAC_92HD71BXX_REF),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1690 "unknown HP", STAC_HP_M4),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1692 "unknown Dell", STAC_DELL_M4_1),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1694 "unknown Dell", STAC_DELL_M4_1),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1696 "unknown Dell", STAC_DELL_M4_1),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1698 "unknown Dell", STAC_DELL_M4_1),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1700 "unknown Dell", STAC_DELL_M4_1),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1702 "unknown Dell", STAC_DELL_M4_1),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1704 "unknown Dell", STAC_DELL_M4_1),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1706 "unknown Dell", STAC_DELL_M4_2),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1708 "unknown Dell", STAC_DELL_M4_2),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1710 "unknown Dell", STAC_DELL_M4_2),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1712 "unknown Dell", STAC_DELL_M4_2),
1716 static unsigned int ref922x_pin_configs[10] = {
1717 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1718 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1719 0x40000100, 0x40000100,
1723 STAC 922X pin configs for
1730 static unsigned int dell_922x_d81_pin_configs[10] = {
1731 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1732 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1733 0x01813122, 0x400001f2,
1737 STAC 922X pin configs for
1741 static unsigned int dell_922x_d82_pin_configs[10] = {
1742 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1743 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1744 0x01813122, 0x400001f1,
1748 STAC 922X pin configs for
1751 static unsigned int dell_922x_m81_pin_configs[10] = {
1752 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1753 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1754 0x40C003f1, 0x405003f0,
1758 STAC 9221 A1 pin configs for
1759 102801D7 (Dell XPS M1210)
1761 static unsigned int dell_922x_m82_pin_configs[10] = {
1762 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1763 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1764 0x508003f3, 0x405003f4,
1767 static unsigned int d945gtp3_pin_configs[10] = {
1768 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1769 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1770 0x02a19120, 0x40000100,
1773 static unsigned int d945gtp5_pin_configs[10] = {
1774 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1775 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1776 0x02a19320, 0x40000100,
1779 static unsigned int intel_mac_v1_pin_configs[10] = {
1780 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1781 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1782 0x400000fc, 0x400000fb,
1785 static unsigned int intel_mac_v2_pin_configs[10] = {
1786 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1787 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1788 0x400000fc, 0x400000fb,
1791 static unsigned int intel_mac_v3_pin_configs[10] = {
1792 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1793 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1794 0x400000fc, 0x400000fb,
1797 static unsigned int intel_mac_v4_pin_configs[10] = {
1798 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1799 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1800 0x400000fc, 0x400000fb,
1803 static unsigned int intel_mac_v5_pin_configs[10] = {
1804 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1805 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1806 0x400000fc, 0x400000fb,
1809 static unsigned int ecs202_pin_configs[10] = {
1810 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1811 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1812 0x9037012e, 0x40e000f2,
1815 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1816 [STAC_D945_REF] = ref922x_pin_configs,
1817 [STAC_D945GTP3] = d945gtp3_pin_configs,
1818 [STAC_D945GTP5] = d945gtp5_pin_configs,
1819 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1820 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1821 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1822 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1823 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1824 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1825 /* for backward compatibility */
1826 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1827 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1828 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1829 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1830 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1831 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1832 [STAC_ECS_202] = ecs202_pin_configs,
1833 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1834 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1835 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1836 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1839 static const char *stac922x_models[STAC_922X_MODELS] = {
1840 [STAC_D945_REF] = "ref",
1841 [STAC_D945GTP5] = "5stack",
1842 [STAC_D945GTP3] = "3stack",
1843 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1844 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1845 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1846 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1847 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1848 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1849 /* for backward compatibility */
1850 [STAC_MACMINI] = "macmini",
1851 [STAC_MACBOOK] = "macbook",
1852 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1853 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1854 [STAC_IMAC_INTEL] = "imac-intel",
1855 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1856 [STAC_ECS_202] = "ecs202",
1857 [STAC_922X_DELL_D81] = "dell-d81",
1858 [STAC_922X_DELL_D82] = "dell-d82",
1859 [STAC_922X_DELL_M81] = "dell-m81",
1860 [STAC_922X_DELL_M82] = "dell-m82",
1863 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1864 /* SigmaTel reference board */
1865 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1866 "DFI LanParty", STAC_D945_REF),
1867 /* Intel 945G based systems */
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1869 "Intel D945G", STAC_D945GTP3),
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1871 "Intel D945G", STAC_D945GTP3),
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1873 "Intel D945G", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1875 "Intel D945G", STAC_D945GTP3),
1876 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1877 "Intel D945G", STAC_D945GTP3),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1879 "Intel D945G", STAC_D945GTP3),
1880 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1881 "Intel D945G", STAC_D945GTP3),
1882 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1883 "Intel D945G", STAC_D945GTP3),
1884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1885 "Intel D945G", STAC_D945GTP3),
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1887 "Intel D945G", STAC_D945GTP3),
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1893 "Intel D945G", STAC_D945GTP3),
1894 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1895 "Intel D945G", STAC_D945GTP3),
1896 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1897 "Intel D945G", STAC_D945GTP3),
1898 /* Intel D945G 5-stack systems */
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1900 "Intel D945G", STAC_D945GTP5),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1902 "Intel D945G", STAC_D945GTP5),
1903 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1904 "Intel D945G", STAC_D945GTP5),
1905 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1906 "Intel D945G", STAC_D945GTP5),
1907 /* Intel 945P based systems */
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1909 "Intel D945P", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1911 "Intel D945P", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1913 "Intel D945P", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1915 "Intel D945P", STAC_D945GTP3),
1916 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1917 "Intel D945P", STAC_D945GTP3),
1918 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1919 "Intel D945P", STAC_D945GTP5),
1921 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1922 SND_PCI_QUIRK(0x8384, 0x7680,
1923 "Mac", STAC_INTEL_MAC_AUTO),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1926 "unknown Dell", STAC_922X_DELL_D81),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1928 "unknown Dell", STAC_922X_DELL_D81),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1930 "unknown Dell", STAC_922X_DELL_D81),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1932 "unknown Dell", STAC_922X_DELL_D82),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1934 "unknown Dell", STAC_922X_DELL_M81),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1936 "unknown Dell", STAC_922X_DELL_D82),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1938 "unknown Dell", STAC_922X_DELL_D81),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1940 "unknown Dell", STAC_922X_DELL_D81),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1942 "Dell XPS M1210", STAC_922X_DELL_M82),
1943 /* ECS/PC Chips boards */
1944 SND_PCI_QUIRK(0x1019, 0x2144,
1945 "ECS/PC chips", STAC_ECS_202),
1946 SND_PCI_QUIRK(0x1019, 0x2608,
1947 "ECS/PC chips", STAC_ECS_202),
1948 SND_PCI_QUIRK(0x1019, 0x2633,
1949 "ECS/PC chips P17G/1333", STAC_ECS_202),
1950 SND_PCI_QUIRK(0x1019, 0x2811,
1951 "ECS/PC chips", STAC_ECS_202),
1952 SND_PCI_QUIRK(0x1019, 0x2812,
1953 "ECS/PC chips", STAC_ECS_202),
1954 SND_PCI_QUIRK(0x1019, 0x2813,
1955 "ECS/PC chips", STAC_ECS_202),
1956 SND_PCI_QUIRK(0x1019, 0x2814,
1957 "ECS/PC chips", STAC_ECS_202),
1958 SND_PCI_QUIRK(0x1019, 0x2815,
1959 "ECS/PC chips", STAC_ECS_202),
1960 SND_PCI_QUIRK(0x1019, 0x2816,
1961 "ECS/PC chips", STAC_ECS_202),
1962 SND_PCI_QUIRK(0x1019, 0x2817,
1963 "ECS/PC chips", STAC_ECS_202),
1964 SND_PCI_QUIRK(0x1019, 0x2818,
1965 "ECS/PC chips", STAC_ECS_202),
1966 SND_PCI_QUIRK(0x1019, 0x2819,
1967 "ECS/PC chips", STAC_ECS_202),
1968 SND_PCI_QUIRK(0x1019, 0x2820,
1969 "ECS/PC chips", STAC_ECS_202),
1973 static unsigned int ref927x_pin_configs[14] = {
1974 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1975 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1976 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1977 0x01c42190, 0x40000100,
1980 static unsigned int d965_3st_pin_configs[14] = {
1981 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1982 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1983 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1984 0x40000100, 0x40000100
1987 static unsigned int d965_5st_pin_configs[14] = {
1988 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1989 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1990 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1991 0x40000100, 0x40000100
1994 static unsigned int dell_3st_pin_configs[14] = {
1995 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1996 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1997 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1998 0x40c003fc, 0x40000100
2001 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2002 [STAC_D965_REF] = ref927x_pin_configs,
2003 [STAC_D965_3ST] = d965_3st_pin_configs,
2004 [STAC_D965_5ST] = d965_5st_pin_configs,
2005 [STAC_DELL_3ST] = dell_3st_pin_configs,
2006 [STAC_DELL_BIOS] = NULL,
2009 static const char *stac927x_models[STAC_927X_MODELS] = {
2010 [STAC_D965_REF] = "ref",
2011 [STAC_D965_3ST] = "3stack",
2012 [STAC_D965_5ST] = "5stack",
2013 [STAC_DELL_3ST] = "dell-3stack",
2014 [STAC_DELL_BIOS] = "dell-bios",
2017 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2018 /* SigmaTel reference board */
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2020 "DFI LanParty", STAC_D965_REF),
2021 /* Intel 946 based systems */
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2024 /* 965 based 3 stack systems */
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2041 /* Dell 3 stack systems */
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2046 /* Dell 3 stack systems with verb table in BIOS */
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2055 /* 965 based 5 stack systems */
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2068 static unsigned int ref9205_pin_configs[12] = {
2069 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2070 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2071 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2075 STAC 9205 pin configs for
2082 10280228 (Dell Vostro 1500)
2084 static unsigned int dell_9205_m42_pin_configs[12] = {
2085 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2086 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2087 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2091 STAC 9205 pin configs for
2095 102801FF (Dell Precision M4300)
2100 static unsigned int dell_9205_m43_pin_configs[12] = {
2101 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2102 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2103 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2106 static unsigned int dell_9205_m44_pin_configs[12] = {
2107 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2108 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2109 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2112 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2113 [STAC_9205_REF] = ref9205_pin_configs,
2114 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2115 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2116 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2119 static const char *stac9205_models[STAC_9205_MODELS] = {
2120 [STAC_9205_REF] = "ref",
2121 [STAC_9205_DELL_M42] = "dell-m42",
2122 [STAC_9205_DELL_M43] = "dell-m43",
2123 [STAC_9205_DELL_M44] = "dell-m44",
2126 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2127 /* SigmaTel reference board */
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2129 "DFI LanParty", STAC_9205_REF),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2131 "unknown Dell", STAC_9205_DELL_M42),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2133 "unknown Dell", STAC_9205_DELL_M42),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2135 "Dell Precision", STAC_9205_DELL_M43),
2136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2137 "Dell Precision", STAC_9205_DELL_M43),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2139 "Dell Precision", STAC_9205_DELL_M43),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2141 "unknown Dell", STAC_9205_DELL_M42),
2142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2143 "unknown Dell", STAC_9205_DELL_M42),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2145 "Dell Precision", STAC_9205_DELL_M43),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2147 "Dell Precision M4300", STAC_9205_DELL_M43),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2149 "unknown Dell", STAC_9205_DELL_M42),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2151 "Dell Precision", STAC_9205_DELL_M43),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2153 "Dell Precision", STAC_9205_DELL_M43),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2155 "Dell Precision", STAC_9205_DELL_M43),
2156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2157 "Dell Inspiron", STAC_9205_DELL_M44),
2158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2159 "Dell Vostro 1500", STAC_9205_DELL_M42),
2163 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2166 struct sigmatel_spec *spec = codec->spec;
2168 if (! spec->bios_pin_configs) {
2169 spec->bios_pin_configs = kcalloc(spec->num_pins,
2170 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2171 if (! spec->bios_pin_configs)
2175 for (i = 0; i < spec->num_pins; i++) {
2176 hda_nid_t nid = spec->pin_nids[i];
2177 unsigned int pin_cfg;
2179 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2180 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2181 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2183 spec->bios_pin_configs[i] = pin_cfg;
2189 static void stac92xx_set_config_reg(struct hda_codec *codec,
2190 hda_nid_t pin_nid, unsigned int pin_config)
2193 snd_hda_codec_write(codec, pin_nid, 0,
2194 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2195 pin_config & 0x000000ff);
2196 snd_hda_codec_write(codec, pin_nid, 0,
2197 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2198 (pin_config & 0x0000ff00) >> 8);
2199 snd_hda_codec_write(codec, pin_nid, 0,
2200 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2201 (pin_config & 0x00ff0000) >> 16);
2202 snd_hda_codec_write(codec, pin_nid, 0,
2203 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2205 i = snd_hda_codec_read(codec, pin_nid, 0,
2206 AC_VERB_GET_CONFIG_DEFAULT,
2208 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2212 static void stac92xx_set_config_regs(struct hda_codec *codec)
2215 struct sigmatel_spec *spec = codec->spec;
2217 if (!spec->pin_configs)
2220 for (i = 0; i < spec->num_pins; i++)
2221 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2222 spec->pin_configs[i]);
2226 * Analog playback callbacks
2228 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2229 struct hda_codec *codec,
2230 struct snd_pcm_substream *substream)
2232 struct sigmatel_spec *spec = codec->spec;
2233 if (spec->stream_delay)
2234 msleep(spec->stream_delay);
2235 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2239 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2240 struct hda_codec *codec,
2241 unsigned int stream_tag,
2242 unsigned int format,
2243 struct snd_pcm_substream *substream)
2245 struct sigmatel_spec *spec = codec->spec;
2246 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2249 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2250 struct hda_codec *codec,
2251 struct snd_pcm_substream *substream)
2253 struct sigmatel_spec *spec = codec->spec;
2254 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2258 * Digital playback callbacks
2260 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2261 struct hda_codec *codec,
2262 struct snd_pcm_substream *substream)
2264 struct sigmatel_spec *spec = codec->spec;
2265 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2268 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2269 struct hda_codec *codec,
2270 struct snd_pcm_substream *substream)
2272 struct sigmatel_spec *spec = codec->spec;
2273 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2276 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2277 struct hda_codec *codec,
2278 unsigned int stream_tag,
2279 unsigned int format,
2280 struct snd_pcm_substream *substream)
2282 struct sigmatel_spec *spec = codec->spec;
2283 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2284 stream_tag, format, substream);
2289 * Analog capture callbacks
2291 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2292 struct hda_codec *codec,
2293 unsigned int stream_tag,
2294 unsigned int format,
2295 struct snd_pcm_substream *substream)
2297 struct sigmatel_spec *spec = codec->spec;
2298 hda_nid_t nid = spec->adc_nids[substream->number];
2300 if (spec->powerdown_adcs) {
2302 snd_hda_codec_write_cache(codec, nid, 0,
2303 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2305 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2309 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2310 struct hda_codec *codec,
2311 struct snd_pcm_substream *substream)
2313 struct sigmatel_spec *spec = codec->spec;
2314 hda_nid_t nid = spec->adc_nids[substream->number];
2316 snd_hda_codec_cleanup_stream(codec, nid);
2317 if (spec->powerdown_adcs)
2318 snd_hda_codec_write_cache(codec, nid, 0,
2319 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2323 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2327 /* NID is set in stac92xx_build_pcms */
2329 .open = stac92xx_dig_playback_pcm_open,
2330 .close = stac92xx_dig_playback_pcm_close,
2331 .prepare = stac92xx_dig_playback_pcm_prepare
2335 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2339 /* NID is set in stac92xx_build_pcms */
2342 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2346 .nid = 0x02, /* NID to query formats and rates */
2348 .open = stac92xx_playback_pcm_open,
2349 .prepare = stac92xx_playback_pcm_prepare,
2350 .cleanup = stac92xx_playback_pcm_cleanup
2354 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2358 .nid = 0x06, /* NID to query formats and rates */
2360 .open = stac92xx_playback_pcm_open,
2361 .prepare = stac92xx_playback_pcm_prepare,
2362 .cleanup = stac92xx_playback_pcm_cleanup
2366 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2369 /* NID + .substreams is set in stac92xx_build_pcms */
2371 .prepare = stac92xx_capture_pcm_prepare,
2372 .cleanup = stac92xx_capture_pcm_cleanup
2376 static int stac92xx_build_pcms(struct hda_codec *codec)
2378 struct sigmatel_spec *spec = codec->spec;
2379 struct hda_pcm *info = spec->pcm_rec;
2381 codec->num_pcms = 1;
2382 codec->pcm_info = info;
2384 info->name = "STAC92xx Analog";
2385 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2386 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2387 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2388 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2390 if (spec->alt_switch) {
2393 info->name = "STAC92xx Analog Alt";
2394 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2397 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2400 info->name = "STAC92xx Digital";
2401 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2402 if (spec->multiout.dig_out_nid) {
2403 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2404 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2406 if (spec->dig_in_nid) {
2407 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2408 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2415 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2417 unsigned int pincap = snd_hda_param_read(codec, nid,
2419 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2420 if (pincap & AC_PINCAP_VREF_100)
2421 return AC_PINCTL_VREF_100;
2422 if (pincap & AC_PINCAP_VREF_80)
2423 return AC_PINCTL_VREF_80;
2424 if (pincap & AC_PINCAP_VREF_50)
2425 return AC_PINCTL_VREF_50;
2426 if (pincap & AC_PINCAP_VREF_GRD)
2427 return AC_PINCTL_VREF_GRD;
2431 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2434 snd_hda_codec_write_cache(codec, nid, 0,
2435 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2438 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2440 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2441 struct snd_ctl_elem_value *ucontrol)
2443 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2444 struct sigmatel_spec *spec = codec->spec;
2446 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2450 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2451 struct snd_ctl_elem_value *ucontrol)
2453 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2454 struct sigmatel_spec *spec = codec->spec;
2455 int nid = kcontrol->private_value;
2457 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2459 /* check to be sure that the ports are upto date with
2462 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2467 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2469 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2472 struct sigmatel_spec *spec = codec->spec;
2473 int io_idx = kcontrol-> private_value & 0xff;
2475 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2479 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2481 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2482 struct sigmatel_spec *spec = codec->spec;
2483 hda_nid_t nid = kcontrol->private_value >> 8;
2484 int io_idx = kcontrol-> private_value & 0xff;
2485 unsigned short val = !!ucontrol->value.integer.value[0];
2487 spec->io_switch[io_idx] = val;
2490 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2492 unsigned int pinctl = AC_PINCTL_IN_EN;
2493 if (io_idx) /* set VREF for mic */
2494 pinctl |= stac92xx_get_vref(codec, nid);
2495 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2498 /* check the auto-mute again: we need to mute/unmute the speaker
2499 * appropriately according to the pin direction
2501 if (spec->hp_detect)
2502 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2507 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2509 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2510 struct snd_ctl_elem_value *ucontrol)
2512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2513 struct sigmatel_spec *spec = codec->spec;
2515 ucontrol->value.integer.value[0] = spec->clfe_swap;
2519 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2520 struct snd_ctl_elem_value *ucontrol)
2522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2523 struct sigmatel_spec *spec = codec->spec;
2524 hda_nid_t nid = kcontrol->private_value & 0xff;
2525 unsigned int val = !!ucontrol->value.integer.value[0];
2527 if (spec->clfe_swap == val)
2530 spec->clfe_swap = val;
2532 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2533 spec->clfe_swap ? 0x4 : 0x0);
2538 #define STAC_CODEC_HP_SWITCH(xname) \
2539 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2542 .info = stac92xx_hp_switch_info, \
2543 .get = stac92xx_hp_switch_get, \
2544 .put = stac92xx_hp_switch_put, \
2547 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2548 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2551 .info = stac92xx_io_switch_info, \
2552 .get = stac92xx_io_switch_get, \
2553 .put = stac92xx_io_switch_put, \
2554 .private_value = xpval, \
2557 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2558 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2561 .info = stac92xx_clfe_switch_info, \
2562 .get = stac92xx_clfe_switch_get, \
2563 .put = stac92xx_clfe_switch_put, \
2564 .private_value = xpval, \
2568 STAC_CTL_WIDGET_VOL,
2569 STAC_CTL_WIDGET_MUTE,
2570 STAC_CTL_WIDGET_MONO_MUX,
2571 STAC_CTL_WIDGET_AMP_MUX,
2572 STAC_CTL_WIDGET_AMP_VOL,
2573 STAC_CTL_WIDGET_HP_SWITCH,
2574 STAC_CTL_WIDGET_IO_SWITCH,
2575 STAC_CTL_WIDGET_CLFE_SWITCH
2578 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2579 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2580 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2583 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2584 STAC_CODEC_HP_SWITCH(NULL),
2585 STAC_CODEC_IO_SWITCH(NULL, 0),
2586 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2589 /* add dynamic controls */
2590 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2591 struct snd_kcontrol_new *ktemp,
2592 int idx, const char *name,
2595 struct snd_kcontrol_new *knew;
2597 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2598 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2600 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2603 if (spec->kctl_alloc) {
2604 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2605 kfree(spec->kctl_alloc);
2607 spec->kctl_alloc = knew;
2608 spec->num_kctl_alloc = num;
2611 knew = &spec->kctl_alloc[spec->num_kctl_used];
2614 knew->name = kstrdup(name, GFP_KERNEL);
2617 knew->private_value = val;
2618 spec->num_kctl_used++;
2622 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2623 int type, int idx, const char *name,
2626 return stac92xx_add_control_temp(spec,
2627 &stac92xx_control_templates[type],
2632 /* add dynamic controls */
2633 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2634 const char *name, unsigned long val)
2636 return stac92xx_add_control_idx(spec, type, 0, name, val);
2639 /* flag inputs as additional dynamic lineouts */
2640 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2642 struct sigmatel_spec *spec = codec->spec;
2643 unsigned int wcaps, wtype;
2644 int i, num_dacs = 0;
2646 /* use the wcaps cache to count all DACs available for line-outs */
2647 for (i = 0; i < codec->num_nodes; i++) {
2648 wcaps = codec->wcaps[i];
2649 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2651 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2655 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2657 switch (cfg->line_outs) {
2659 /* add line-in as side */
2660 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2661 cfg->line_out_pins[cfg->line_outs] =
2662 cfg->input_pins[AUTO_PIN_LINE];
2663 spec->line_switch = 1;
2668 /* add line-in as clfe and mic as side */
2669 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2670 cfg->line_out_pins[cfg->line_outs] =
2671 cfg->input_pins[AUTO_PIN_LINE];
2672 spec->line_switch = 1;
2675 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2676 cfg->line_out_pins[cfg->line_outs] =
2677 cfg->input_pins[AUTO_PIN_MIC];
2678 spec->mic_switch = 1;
2683 /* add line-in as surr and mic as clfe */
2684 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2685 cfg->line_out_pins[cfg->line_outs] =
2686 cfg->input_pins[AUTO_PIN_LINE];
2687 spec->line_switch = 1;
2690 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2691 cfg->line_out_pins[cfg->line_outs] =
2692 cfg->input_pins[AUTO_PIN_MIC];
2693 spec->mic_switch = 1;
2703 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2707 for (i = 0; i < spec->multiout.num_dacs; i++) {
2708 if (spec->multiout.dac_nids[i] == nid)
2716 * Fill in the dac_nids table from the parsed pin configuration
2717 * This function only works when every pin in line_out_pins[]
2718 * contains atleast one DAC in its connection list. Some 92xx
2719 * codecs are not connected directly to a DAC, such as the 9200
2720 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2722 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2723 struct auto_pin_cfg *cfg)
2725 struct sigmatel_spec *spec = codec->spec;
2726 int i, j, conn_len = 0;
2727 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2728 unsigned int wcaps, wtype;
2730 for (i = 0; i < cfg->line_outs; i++) {
2731 nid = cfg->line_out_pins[i];
2732 conn_len = snd_hda_get_connections(codec, nid, conn,
2733 HDA_MAX_CONNECTIONS);
2734 for (j = 0; j < conn_len; j++) {
2735 wcaps = snd_hda_param_read(codec, conn[j],
2736 AC_PAR_AUDIO_WIDGET_CAP);
2737 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2738 if (wtype != AC_WID_AUD_OUT ||
2739 (wcaps & AC_WCAP_DIGITAL))
2741 /* conn[j] is a DAC routed to this line-out */
2742 if (!is_in_dac_nids(spec, conn[j]))
2746 if (j == conn_len) {
2747 if (spec->multiout.num_dacs > 0) {
2748 /* we have already working output pins,
2749 * so let's drop the broken ones again
2751 cfg->line_outs = spec->multiout.num_dacs;
2754 /* error out, no available DAC found */
2756 "%s: No available DAC for pin 0x%x\n",
2761 spec->multiout.dac_nids[i] = conn[j];
2762 spec->multiout.num_dacs++;
2764 /* select this DAC in the pin's input mux */
2765 snd_hda_codec_write_cache(codec, nid, 0,
2766 AC_VERB_SET_CONNECT_SEL, j);
2771 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2772 spec->multiout.num_dacs,
2773 spec->multiout.dac_nids[0],
2774 spec->multiout.dac_nids[1],
2775 spec->multiout.dac_nids[2],
2776 spec->multiout.dac_nids[3],
2777 spec->multiout.dac_nids[4]);
2781 /* create volume control/switch for the given prefx type */
2782 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2787 sprintf(name, "%s Playback Volume", pfx);
2788 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2789 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2792 sprintf(name, "%s Playback Switch", pfx);
2793 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2794 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2800 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2802 if (!spec->multiout.hp_nid)
2803 spec->multiout.hp_nid = nid;
2804 else if (spec->multiout.num_dacs > 4) {
2805 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2808 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2809 spec->multiout.num_dacs++;
2814 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2816 if (is_in_dac_nids(spec, nid))
2818 if (spec->multiout.hp_nid == nid)
2823 /* add playback controls from the parsed DAC table */
2824 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2825 const struct auto_pin_cfg *cfg)
2827 static const char *chname[4] = {
2828 "Front", "Surround", NULL /*CLFE*/, "Side"
2833 struct sigmatel_spec *spec = codec->spec;
2834 unsigned int wid_caps, pincap;
2837 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2838 if (!spec->multiout.dac_nids[i])
2841 nid = spec->multiout.dac_nids[i];
2845 err = create_controls(spec, "Center", nid, 1);
2848 err = create_controls(spec, "LFE", nid, 2);
2852 wid_caps = get_wcaps(codec, nid);
2854 if (wid_caps & AC_WCAP_LR_SWAP) {
2855 err = stac92xx_add_control(spec,
2856 STAC_CTL_WIDGET_CLFE_SWITCH,
2857 "Swap Center/LFE Playback Switch", nid);
2864 err = create_controls(spec, chname[i], nid, 3);
2870 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2871 cfg->hp_outs && !spec->multiout.hp_nid)
2872 spec->multiout.hp_nid = nid;
2874 if (cfg->hp_outs > 1) {
2875 err = stac92xx_add_control(spec,
2876 STAC_CTL_WIDGET_HP_SWITCH,
2877 "Headphone as Line Out Switch",
2878 cfg->hp_pins[cfg->hp_outs - 1]);
2883 if (spec->line_switch) {
2884 nid = cfg->input_pins[AUTO_PIN_LINE];
2885 pincap = snd_hda_param_read(codec, nid,
2887 if (pincap & AC_PINCAP_OUT) {
2888 err = stac92xx_add_control(spec,
2889 STAC_CTL_WIDGET_IO_SWITCH,
2890 "Line In as Output Switch", nid << 8);
2896 if (spec->mic_switch) {
2897 unsigned int def_conf;
2898 unsigned int mic_pin = AUTO_PIN_MIC;
2900 nid = cfg->input_pins[mic_pin];
2901 def_conf = snd_hda_codec_read(codec, nid, 0,
2902 AC_VERB_GET_CONFIG_DEFAULT, 0);
2903 /* some laptops have an internal analog microphone
2904 * which can't be used as a output */
2905 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2906 pincap = snd_hda_param_read(codec, nid,
2908 if (pincap & AC_PINCAP_OUT) {
2909 err = stac92xx_add_control(spec,
2910 STAC_CTL_WIDGET_IO_SWITCH,
2911 "Mic as Output Switch", (nid << 8) | 1);
2912 nid = snd_hda_codec_read(codec, nid, 0,
2913 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2914 if (!check_in_dac_nids(spec, nid))
2915 add_spec_dacs(spec, nid);
2919 } else if (mic_pin == AUTO_PIN_MIC) {
2920 mic_pin = AUTO_PIN_FRONT_MIC;
2928 /* add playback controls for Speaker and HP outputs */
2929 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2930 struct auto_pin_cfg *cfg)
2932 struct sigmatel_spec *spec = codec->spec;
2934 int i, old_num_dacs, err;
2936 old_num_dacs = spec->multiout.num_dacs;
2937 for (i = 0; i < cfg->hp_outs; i++) {
2938 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2939 if (wid_caps & AC_WCAP_UNSOL_CAP)
2940 spec->hp_detect = 1;
2941 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2942 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2943 if (check_in_dac_nids(spec, nid))
2947 add_spec_dacs(spec, nid);
2949 for (i = 0; i < cfg->speaker_outs; i++) {
2950 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2951 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2952 if (check_in_dac_nids(spec, nid))
2956 add_spec_dacs(spec, nid);
2958 for (i = 0; i < cfg->line_outs; i++) {
2959 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2960 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2961 if (check_in_dac_nids(spec, nid))
2965 add_spec_dacs(spec, nid);
2967 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2968 static const char *pfxs[] = {
2969 "Speaker", "External Speaker", "Speaker2",
2971 err = create_controls(spec, pfxs[i - old_num_dacs],
2972 spec->multiout.dac_nids[i], 3);
2976 if (spec->multiout.hp_nid) {
2977 err = create_controls(spec, "Headphone",
2978 spec->multiout.hp_nid, 3);
2986 /* labels for mono mux outputs */
2987 static const char *stac92xx_mono_labels[4] = {
2988 "DAC0", "DAC1", "Mixer", "DAC2"
2991 /* create mono mux for mono out on capable codecs */
2992 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2994 struct sigmatel_spec *spec = codec->spec;
2995 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2997 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2999 num_cons = snd_hda_get_connections(codec,
3002 HDA_MAX_NUM_INPUTS);
3003 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3006 for (i = 0; i < num_cons; i++) {
3007 mono_mux->items[mono_mux->num_items].label =
3008 stac92xx_mono_labels[i];
3009 mono_mux->items[mono_mux->num_items].index = i;
3010 mono_mux->num_items++;
3013 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3014 "Mono Mux", spec->mono_nid);
3017 /* labels for amp mux outputs */
3018 static const char *stac92xx_amp_labels[3] = {
3019 "Front Microphone", "Microphone", "Line In",
3022 /* create amp out controls mux on capable codecs */
3023 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3025 struct sigmatel_spec *spec = codec->spec;
3026 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3029 for (i = 0; i < spec->num_amps; i++) {
3030 amp_mux->items[amp_mux->num_items].label =
3031 stac92xx_amp_labels[i];
3032 amp_mux->items[amp_mux->num_items].index = i;
3033 amp_mux->num_items++;
3036 if (spec->num_amps > 1) {
3037 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3038 "Amp Selector Capture Switch", 0);
3042 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3043 "Amp Capture Volume",
3044 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3048 /* create PC beep volume controls */
3049 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3052 struct sigmatel_spec *spec = codec->spec;
3053 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3056 /* check for mute support for the the amp */
3057 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3058 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3059 "PC Beep Playback Switch",
3060 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3065 /* check to see if there is volume support for the amp */
3066 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3067 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3068 "PC Beep Playback Volume",
3069 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3076 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3077 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3079 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3080 struct snd_ctl_elem_value *ucontrol)
3082 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3083 ucontrol->value.integer.value[0] = codec->beep->enabled;
3087 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3088 struct snd_ctl_elem_value *ucontrol)
3090 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3091 int enabled = !!ucontrol->value.integer.value[0];
3092 if (codec->beep->enabled != enabled) {
3093 codec->beep->enabled = enabled;
3099 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3100 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3101 .info = stac92xx_dig_beep_switch_info,
3102 .get = stac92xx_dig_beep_switch_get,
3103 .put = stac92xx_dig_beep_switch_put,
3106 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3108 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3109 0, "PC Beep Playback Switch", 0);
3113 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3115 struct sigmatel_spec *spec = codec->spec;
3116 int wcaps, nid, i, err = 0;
3118 for (i = 0; i < spec->num_muxes; i++) {
3119 nid = spec->mux_nids[i];
3120 wcaps = get_wcaps(codec, nid);
3122 if (wcaps & AC_WCAP_OUT_AMP) {
3123 err = stac92xx_add_control_idx(spec,
3124 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3125 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3133 static const char *stac92xx_spdif_labels[3] = {
3134 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3137 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3139 struct sigmatel_spec *spec = codec->spec;
3140 struct hda_input_mux *spdif_mux = &spec->private_smux;
3141 const char **labels = spec->spdif_labels;
3143 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3145 num_cons = snd_hda_get_connections(codec,
3148 HDA_MAX_NUM_INPUTS);
3153 labels = stac92xx_spdif_labels;
3155 for (i = 0; i < num_cons; i++) {
3156 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3157 spdif_mux->items[spdif_mux->num_items].index = i;
3158 spdif_mux->num_items++;
3164 /* labels for dmic mux inputs */
3165 static const char *stac92xx_dmic_labels[5] = {
3166 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3167 "Digital Mic 3", "Digital Mic 4"
3170 /* create playback/capture controls for input pins on dmic capable codecs */
3171 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3172 const struct auto_pin_cfg *cfg)
3174 struct sigmatel_spec *spec = codec->spec;
3175 struct hda_input_mux *dimux = &spec->private_dimux;
3176 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3180 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3181 dimux->items[dimux->num_items].index = 0;
3184 for (i = 0; i < spec->num_dmics; i++) {
3189 unsigned int def_conf;
3191 def_conf = snd_hda_codec_read(codec,
3194 AC_VERB_GET_CONFIG_DEFAULT,
3196 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3199 nid = spec->dmic_nids[i];
3200 num_cons = snd_hda_get_connections(codec,
3203 HDA_MAX_NUM_INPUTS);
3204 for (j = 0; j < num_cons; j++)
3205 if (con_lst[j] == nid) {
3211 wcaps = get_wcaps(codec, nid) &
3212 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3215 sprintf(name, "%s Capture Volume",
3216 stac92xx_dmic_labels[dimux->num_items]);
3218 err = stac92xx_add_control(spec,
3219 STAC_CTL_WIDGET_VOL,
3221 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3222 (wcaps & AC_WCAP_OUT_AMP) ?
3223 HDA_OUTPUT : HDA_INPUT));
3228 dimux->items[dimux->num_items].label =
3229 stac92xx_dmic_labels[dimux->num_items];
3230 dimux->items[dimux->num_items].index = index;
3237 /* create playback/capture controls for input pins */
3238 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3240 struct sigmatel_spec *spec = codec->spec;
3241 struct hda_input_mux *imux = &spec->private_imux;
3242 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3245 for (i = 0; i < AUTO_PIN_LAST; i++) {
3248 if (!cfg->input_pins[i])
3251 for (j = 0; j < spec->num_muxes; j++) {
3253 num_cons = snd_hda_get_connections(codec,
3256 HDA_MAX_NUM_INPUTS);
3257 for (k = 0; k < num_cons; k++)
3258 if (con_lst[k] == cfg->input_pins[i]) {
3265 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3266 imux->items[imux->num_items].index = index;
3270 if (imux->num_items) {
3272 * Set the current input for the muxes.
3273 * The STAC9221 has two input muxes with identical source
3274 * NID lists. Hopefully this won't get confused.
3276 for (i = 0; i < spec->num_muxes; i++) {
3277 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3278 AC_VERB_SET_CONNECT_SEL,
3279 imux->items[0].index);
3286 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3288 struct sigmatel_spec *spec = codec->spec;
3291 for (i = 0; i < spec->autocfg.line_outs; i++) {
3292 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3293 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3297 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3299 struct sigmatel_spec *spec = codec->spec;
3302 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3304 pin = spec->autocfg.hp_pins[i];
3305 if (pin) /* connect to front */
3306 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3308 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3310 pin = spec->autocfg.speaker_pins[i];
3311 if (pin) /* connect to front */
3312 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3316 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3318 struct sigmatel_spec *spec = codec->spec;
3320 int hp_speaker_swap = 0;
3322 if ((err = snd_hda_parse_pin_def_config(codec,
3324 spec->dmic_nids)) < 0)
3326 if (! spec->autocfg.line_outs)
3327 return 0; /* can't find valid pin config */
3329 /* If we have no real line-out pin and multiple hp-outs, HPs should
3330 * be set up as multi-channel outputs.
3332 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3333 spec->autocfg.hp_outs > 1) {
3334 /* Copy hp_outs to line_outs, backup line_outs in
3335 * speaker_outs so that the following routines can handle
3336 * HP pins as primary outputs.
3338 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3339 sizeof(spec->autocfg.line_out_pins));
3340 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3341 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3342 sizeof(spec->autocfg.hp_pins));
3343 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3344 hp_speaker_swap = 1;
3346 if (spec->autocfg.mono_out_pin) {
3347 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3348 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3349 u32 caps = query_amp_caps(codec,
3350 spec->autocfg.mono_out_pin, dir);
3351 hda_nid_t conn_list[1];
3353 /* get the mixer node and then the mono mux if it exists */
3354 if (snd_hda_get_connections(codec,
3355 spec->autocfg.mono_out_pin, conn_list, 1) &&
3356 snd_hda_get_connections(codec, conn_list[0],
3359 int wcaps = get_wcaps(codec, conn_list[0]);
3360 int wid_type = (wcaps & AC_WCAP_TYPE)
3361 >> AC_WCAP_TYPE_SHIFT;
3362 /* LR swap check, some stac925x have a mux that
3363 * changes the DACs output path instead of the
3366 if (wid_type == AC_WID_AUD_SEL &&
3367 !(wcaps & AC_WCAP_LR_SWAP))
3368 spec->mono_nid = conn_list[0];
3371 hda_nid_t nid = spec->autocfg.mono_out_pin;
3373 /* most mono outs have a least a mute/unmute switch */
3374 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3375 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3376 "Mono Playback Switch",
3377 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3380 /* check for volume support for the amp */
3381 if ((caps & AC_AMPCAP_NUM_STEPS)
3382 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3383 err = stac92xx_add_control(spec,
3384 STAC_CTL_WIDGET_VOL,
3385 "Mono Playback Volume",
3386 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3392 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3396 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3398 if (spec->multiout.num_dacs == 0)
3399 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3402 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3407 /* setup analog beep controls */
3408 if (spec->anabeep_nid > 0) {
3409 err = stac92xx_auto_create_beep_ctls(codec,
3415 /* setup digital beep controls and input device */
3416 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3417 if (spec->digbeep_nid > 0) {
3418 hda_nid_t nid = spec->digbeep_nid;
3421 err = stac92xx_auto_create_beep_ctls(codec, nid);
3424 err = snd_hda_attach_beep_device(codec, nid);
3427 /* if no beep switch is available, make its own one */
3428 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3430 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3431 err = stac92xx_beep_switch_ctl(codec);
3438 if (hp_speaker_swap == 1) {
3439 /* Restore the hp_outs and line_outs */
3440 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3441 sizeof(spec->autocfg.line_out_pins));
3442 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3443 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3444 sizeof(spec->autocfg.speaker_pins));
3445 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3446 memset(spec->autocfg.speaker_pins, 0,
3447 sizeof(spec->autocfg.speaker_pins));
3448 spec->autocfg.speaker_outs = 0;
3451 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3456 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3461 if (spec->mono_nid > 0) {
3462 err = stac92xx_auto_create_mono_output_ctls(codec);
3466 if (spec->num_amps > 0) {
3467 err = stac92xx_auto_create_amp_output_ctls(codec);
3471 if (spec->num_dmics > 0 && !spec->dinput_mux)
3472 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3473 &spec->autocfg)) < 0)
3475 if (spec->num_muxes > 0) {
3476 err = stac92xx_auto_create_mux_input_ctls(codec);
3480 if (spec->num_smuxes > 0) {
3481 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3486 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3487 if (spec->multiout.max_channels > 2)
3488 spec->surr_switch = 1;
3490 if (spec->autocfg.dig_out_pin)
3491 spec->multiout.dig_out_nid = dig_out;
3492 if (dig_in && spec->autocfg.dig_in_pin)
3493 spec->dig_in_nid = dig_in;
3495 if (spec->kctl_alloc)
3496 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3498 spec->input_mux = &spec->private_imux;
3499 spec->dinput_mux = &spec->private_dimux;
3500 spec->sinput_mux = &spec->private_smux;
3501 spec->mono_mux = &spec->private_mono_mux;
3502 spec->amp_mux = &spec->private_amp_mux;
3506 /* add playback controls for HP output */
3507 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3508 struct auto_pin_cfg *cfg)
3510 struct sigmatel_spec *spec = codec->spec;
3511 hda_nid_t pin = cfg->hp_pins[0];
3512 unsigned int wid_caps;
3517 wid_caps = get_wcaps(codec, pin);
3518 if (wid_caps & AC_WCAP_UNSOL_CAP)
3519 spec->hp_detect = 1;
3524 /* add playback controls for LFE output */
3525 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3526 struct auto_pin_cfg *cfg)
3528 struct sigmatel_spec *spec = codec->spec;
3530 hda_nid_t lfe_pin = 0x0;
3534 * search speaker outs and line outs for a mono speaker pin
3535 * with an amp. If one is found, add LFE controls
3538 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3539 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3540 unsigned int wcaps = get_wcaps(codec, pin);
3541 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3542 if (wcaps == AC_WCAP_OUT_AMP)
3543 /* found a mono speaker with an amp, must be lfe */
3547 /* if speaker_outs is 0, then speakers may be in line_outs */
3548 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3549 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3550 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3551 unsigned int defcfg;
3552 defcfg = snd_hda_codec_read(codec, pin, 0,
3553 AC_VERB_GET_CONFIG_DEFAULT,
3555 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3556 unsigned int wcaps = get_wcaps(codec, pin);
3557 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3558 if (wcaps == AC_WCAP_OUT_AMP)
3559 /* found a mono speaker with an amp,
3567 err = create_controls(spec, "LFE", lfe_pin, 1);
3575 static int stac9200_parse_auto_config(struct hda_codec *codec)
3577 struct sigmatel_spec *spec = codec->spec;
3580 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3583 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3586 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3589 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3592 if (spec->num_muxes > 0) {
3593 err = stac92xx_auto_create_mux_input_ctls(codec);
3598 if (spec->autocfg.dig_out_pin)
3599 spec->multiout.dig_out_nid = 0x05;
3600 if (spec->autocfg.dig_in_pin)
3601 spec->dig_in_nid = 0x04;
3603 if (spec->kctl_alloc)
3604 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3606 spec->input_mux = &spec->private_imux;
3607 spec->dinput_mux = &spec->private_dimux;
3613 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3614 * funky external mute control using GPIO pins.
3617 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3618 unsigned int dir_mask, unsigned int data)
3620 unsigned int gpiostate, gpiomask, gpiodir;
3622 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3623 AC_VERB_GET_GPIO_DATA, 0);
3624 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3626 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3627 AC_VERB_GET_GPIO_MASK, 0);
3630 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3631 AC_VERB_GET_GPIO_DIRECTION, 0);
3632 gpiodir |= dir_mask;
3634 /* Configure GPIOx as CMOS */
3635 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3637 snd_hda_codec_write(codec, codec->afg, 0,
3638 AC_VERB_SET_GPIO_MASK, gpiomask);
3639 snd_hda_codec_read(codec, codec->afg, 0,
3640 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3644 snd_hda_codec_read(codec, codec->afg, 0,
3645 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3648 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3651 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3652 snd_hda_codec_write_cache(codec, nid, 0,
3653 AC_VERB_SET_UNSOLICITED_ENABLE,
3654 (AC_USRSP_EN | event));
3657 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3660 for (i = 0; i < cfg->hp_outs; i++)
3661 if (cfg->hp_pins[i] == nid)
3662 return 1; /* nid is a HP-Out */
3664 return 0; /* nid is not a HP-Out */
3667 static void stac92xx_power_down(struct hda_codec *codec)
3669 struct sigmatel_spec *spec = codec->spec;
3671 /* power down inactive DACs */
3673 for (dac = spec->dac_list; *dac; dac++)
3674 if (!is_in_dac_nids(spec, *dac) &&
3675 spec->multiout.hp_nid != *dac)
3676 snd_hda_codec_write_cache(codec, *dac, 0,
3677 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3680 static int stac92xx_init(struct hda_codec *codec)
3682 struct sigmatel_spec *spec = codec->spec;
3683 struct auto_pin_cfg *cfg = &spec->autocfg;
3686 snd_hda_sequence_write(codec, spec->init);
3688 /* power down adcs initially */
3689 if (spec->powerdown_adcs)
3690 for (i = 0; i < spec->num_adcs; i++)
3691 snd_hda_codec_write_cache(codec,
3692 spec->adc_nids[i], 0,
3693 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3695 if (spec->hp_detect) {
3696 /* Enable unsolicited responses on the HP widget */
3697 for (i = 0; i < cfg->hp_outs; i++)
3698 enable_pin_detect(codec, cfg->hp_pins[i],
3700 /* force to enable the first line-out; the others are set up
3703 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3705 stac92xx_auto_init_hp_out(codec);
3706 /* fake event to set up pins */
3707 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3709 stac92xx_auto_init_multi_out(codec);
3710 stac92xx_auto_init_hp_out(codec);
3712 for (i = 0; i < AUTO_PIN_LAST; i++) {
3713 hda_nid_t nid = cfg->input_pins[i];
3715 unsigned int pinctl;
3716 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
3717 /* for mic pins, force to initialize */
3718 pinctl = stac92xx_get_vref(codec, nid);
3720 pinctl = snd_hda_codec_read(codec, nid, 0,
3721 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3722 /* if PINCTL already set then skip */
3723 if (pinctl & AC_PINCTL_IN_EN)
3726 pinctl |= AC_PINCTL_IN_EN;
3727 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3730 for (i = 0; i < spec->num_dmics; i++)
3731 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3733 for (i = 0; i < spec->num_pwrs; i++) {
3734 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3735 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3736 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3737 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3738 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3739 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3740 def_conf = get_defcfg_connect(def_conf);
3741 /* outputs are only ports capable of power management
3742 * any attempts on powering down a input port cause the
3743 * referenced VREF to act quirky.
3745 if (pinctl & AC_PINCTL_IN_EN)
3747 /* skip any ports that don't have jacks since presence
3748 * detection is useless */
3749 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3751 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3752 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3755 stac92xx_power_down(codec);
3756 if (cfg->dig_out_pin)
3757 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3759 if (cfg->dig_in_pin)
3760 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3763 stac_gpio_set(codec, spec->gpio_mask,
3764 spec->gpio_dir, spec->gpio_data);
3769 static void stac92xx_free(struct hda_codec *codec)
3771 struct sigmatel_spec *spec = codec->spec;
3777 if (spec->kctl_alloc) {
3778 for (i = 0; i < spec->num_kctl_used; i++)
3779 kfree(spec->kctl_alloc[i].name);
3780 kfree(spec->kctl_alloc);
3783 if (spec->bios_pin_configs)
3784 kfree(spec->bios_pin_configs);
3787 snd_hda_detach_beep_device(codec);
3790 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3793 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3794 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3796 if (pin_ctl & AC_PINCTL_IN_EN) {
3798 * we need to check the current set-up direction of
3799 * shared input pins since they can be switched via
3800 * "xxx as Output" mixer switch
3802 struct sigmatel_spec *spec = codec->spec;
3803 struct auto_pin_cfg *cfg = &spec->autocfg;
3804 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3805 spec->line_switch) ||
3806 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3811 /* if setting pin direction bits, clear the current
3812 direction bits first */
3813 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3814 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3816 snd_hda_codec_write_cache(codec, nid, 0,
3817 AC_VERB_SET_PIN_WIDGET_CONTROL,
3821 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3824 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3825 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3826 snd_hda_codec_write_cache(codec, nid, 0,
3827 AC_VERB_SET_PIN_WIDGET_CONTROL,
3831 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3835 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3837 unsigned int pinctl;
3838 pinctl = snd_hda_codec_read(codec, nid, 0,
3839 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3840 if (pinctl & AC_PINCTL_IN_EN)
3841 return 0; /* mic- or line-input */
3843 return 1; /* HP-output */
3848 /* return non-zero if the hp-pin of the given array index isn't
3849 * a jack-detection target
3851 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
3853 struct auto_pin_cfg *cfg = &spec->autocfg;
3855 /* ignore sensing of shared line and mic jacks */
3856 if (spec->line_switch &&
3857 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE])
3859 if (spec->mic_switch &&
3860 cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC])
3862 /* ignore if the pin is set as line-out */
3863 if (cfg->hp_pins[i] == spec->hp_switch)
3868 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3870 struct sigmatel_spec *spec = codec->spec;
3871 struct auto_pin_cfg *cfg = &spec->autocfg;
3875 if (spec->gpio_mute)
3876 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3877 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3879 for (i = 0; i < cfg->hp_outs; i++) {
3882 if (no_hp_sensing(spec, i))
3884 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3888 /* disable lineouts */
3889 if (spec->hp_switch)
3890 stac92xx_reset_pinctl(codec, spec->hp_switch,
3892 for (i = 0; i < cfg->line_outs; i++)
3893 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3895 for (i = 0; i < cfg->speaker_outs; i++)
3896 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3898 if (spec->eapd_mask)
3899 stac_gpio_set(codec, spec->gpio_mask,
3900 spec->gpio_dir, spec->gpio_data &
3903 /* enable lineouts */
3904 if (spec->hp_switch)
3905 stac92xx_set_pinctl(codec, spec->hp_switch,
3907 for (i = 0; i < cfg->line_outs; i++)
3908 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3910 for (i = 0; i < cfg->speaker_outs; i++)
3911 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3913 if (spec->eapd_mask)
3914 stac_gpio_set(codec, spec->gpio_mask,
3915 spec->gpio_dir, spec->gpio_data |
3918 /* toggle hp outs */
3919 for (i = 0; i < cfg->hp_outs; i++) {
3920 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
3921 if (no_hp_sensing(spec, i))
3924 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
3926 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
3930 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3932 struct sigmatel_spec *spec = codec->spec;
3933 hda_nid_t nid = spec->pwr_nids[idx];
3935 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3937 presence = get_hp_pin_presence(codec, nid);
3939 /* several codecs have two power down bits */
3940 if (spec->pwr_mapping)
3941 idx = spec->pwr_mapping[idx];
3950 /* power down unused output ports */
3951 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3954 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3956 struct sigmatel_spec *spec = codec->spec;
3957 int idx = res >> 26 & 0x0f;
3959 switch ((res >> 26) & 0x70) {
3961 stac92xx_hp_detect(codec, res);
3963 case STAC_PWR_EVENT:
3964 if (spec->num_pwrs > 0)
3965 stac92xx_pin_sense(codec, idx);
3967 case STAC_VREF_EVENT: {
3968 int data = snd_hda_codec_read(codec, codec->afg, 0,
3969 AC_VERB_GET_GPIO_DATA, 0);
3970 /* toggle VREF state based on GPIOx status */
3971 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
3972 !!(data & (1 << idx)));
3978 #ifdef SND_HDA_NEEDS_RESUME
3979 static int stac92xx_resume(struct hda_codec *codec)
3981 struct sigmatel_spec *spec = codec->spec;
3983 stac92xx_set_config_regs(codec);
3984 snd_hda_sequence_write(codec, spec->init);
3985 stac_gpio_set(codec, spec->gpio_mask,
3986 spec->gpio_dir, spec->gpio_data);
3987 snd_hda_codec_resume_amp(codec);
3988 snd_hda_codec_resume_cache(codec);
3989 /* power down inactive DACs */
3991 stac92xx_power_down(codec);
3992 /* invoke unsolicited event to reset the HP state */
3993 if (spec->hp_detect)
3994 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3999 static struct hda_codec_ops stac92xx_patch_ops = {
4000 .build_controls = stac92xx_build_controls,
4001 .build_pcms = stac92xx_build_pcms,
4002 .init = stac92xx_init,
4003 .free = stac92xx_free,
4004 .unsol_event = stac92xx_unsol_event,
4005 #ifdef SND_HDA_NEEDS_RESUME
4006 .resume = stac92xx_resume,
4010 static int patch_stac9200(struct hda_codec *codec)
4012 struct sigmatel_spec *spec;
4015 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4020 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4021 spec->pin_nids = stac9200_pin_nids;
4022 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4025 if (spec->board_config < 0) {
4026 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
4027 err = stac92xx_save_bios_config_regs(codec);
4029 stac92xx_free(codec);
4032 spec->pin_configs = spec->bios_pin_configs;
4034 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
4035 stac92xx_set_config_regs(codec);
4038 spec->multiout.max_channels = 2;
4039 spec->multiout.num_dacs = 1;
4040 spec->multiout.dac_nids = stac9200_dac_nids;
4041 spec->adc_nids = stac9200_adc_nids;
4042 spec->mux_nids = stac9200_mux_nids;
4043 spec->num_muxes = 1;
4044 spec->num_dmics = 0;
4048 if (spec->board_config == STAC_9200_GATEWAY ||
4049 spec->board_config == STAC_9200_OQO)
4050 spec->init = stac9200_eapd_init;
4052 spec->init = stac9200_core_init;
4053 spec->mixer = stac9200_mixer;
4055 if (spec->board_config == STAC_9200_PANASONIC) {
4056 spec->gpio_mask = spec->gpio_dir = 0x09;
4057 spec->gpio_data = 0x00;
4060 err = stac9200_parse_auto_config(codec);
4062 stac92xx_free(codec);
4066 codec->patch_ops = stac92xx_patch_ops;
4071 static int patch_stac925x(struct hda_codec *codec)
4073 struct sigmatel_spec *spec;
4076 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4081 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4082 spec->pin_nids = stac925x_pin_nids;
4083 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
4087 if (spec->board_config < 0) {
4088 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
4089 "using BIOS defaults\n");
4090 err = stac92xx_save_bios_config_regs(codec);
4092 stac92xx_free(codec);
4095 spec->pin_configs = spec->bios_pin_configs;
4096 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
4097 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
4098 stac92xx_set_config_regs(codec);
4101 spec->multiout.max_channels = 2;
4102 spec->multiout.num_dacs = 1;
4103 spec->multiout.dac_nids = stac925x_dac_nids;
4104 spec->adc_nids = stac925x_adc_nids;
4105 spec->mux_nids = stac925x_mux_nids;
4106 spec->num_muxes = 1;
4109 switch (codec->vendor_id) {
4110 case 0x83847632: /* STAC9202 */
4111 case 0x83847633: /* STAC9202D */
4112 case 0x83847636: /* STAC9251 */
4113 case 0x83847637: /* STAC9251D */
4114 spec->num_dmics = STAC925X_NUM_DMICS;
4115 spec->dmic_nids = stac925x_dmic_nids;
4116 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4117 spec->dmux_nids = stac925x_dmux_nids;
4120 spec->num_dmics = 0;
4124 spec->init = stac925x_core_init;
4125 spec->mixer = stac925x_mixer;
4127 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4129 if (spec->board_config < 0) {
4130 printk(KERN_WARNING "hda_codec: No auto-config is "
4131 "available, default to model=ref\n");
4132 spec->board_config = STAC_925x_REF;
4138 stac92xx_free(codec);
4142 codec->patch_ops = stac92xx_patch_ops;
4147 static struct hda_input_mux stac92hd73xx_dmux = {
4150 { "Analog Inputs", 0x0b },
4151 { "Digital Mic 1", 0x09 },
4152 { "Digital Mic 2", 0x0a },
4157 static int patch_stac92hd73xx(struct hda_codec *codec)
4159 struct sigmatel_spec *spec;
4160 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4163 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4168 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4169 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4170 spec->pin_nids = stac92hd73xx_pin_nids;
4171 spec->board_config = snd_hda_check_board_config(codec,
4172 STAC_92HD73XX_MODELS,
4173 stac92hd73xx_models,
4174 stac92hd73xx_cfg_tbl);
4176 if (spec->board_config < 0) {
4177 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4178 " STAC92HD73XX, using BIOS defaults\n");
4179 err = stac92xx_save_bios_config_regs(codec);
4181 stac92xx_free(codec);
4184 spec->pin_configs = spec->bios_pin_configs;
4186 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4187 stac92xx_set_config_regs(codec);
4190 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4191 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4193 if (spec->multiout.num_dacs < 0) {
4194 printk(KERN_WARNING "hda_codec: Could not determine "
4195 "number of channels defaulting to DAC count\n");
4196 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4199 switch (spec->multiout.num_dacs) {
4200 case 0x3: /* 6 Channel */
4201 spec->mixer = stac92hd73xx_6ch_mixer;
4202 spec->init = stac92hd73xx_6ch_core_init;
4204 case 0x4: /* 8 Channel */
4205 spec->mixer = stac92hd73xx_8ch_mixer;
4206 spec->init = stac92hd73xx_8ch_core_init;
4208 case 0x5: /* 10 Channel */
4209 spec->mixer = stac92hd73xx_10ch_mixer;
4210 spec->init = stac92hd73xx_10ch_core_init;
4213 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4214 spec->aloopback_mask = 0x01;
4215 spec->aloopback_shift = 8;
4217 spec->digbeep_nid = 0x1c;
4218 spec->mux_nids = stac92hd73xx_mux_nids;
4219 spec->adc_nids = stac92hd73xx_adc_nids;
4220 spec->dmic_nids = stac92hd73xx_dmic_nids;
4221 spec->dmux_nids = stac92hd73xx_dmux_nids;
4222 spec->smux_nids = stac92hd73xx_smux_nids;
4223 spec->amp_nids = stac92hd73xx_amp_nids;
4224 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4226 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4227 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4228 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4229 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4230 sizeof(stac92hd73xx_dmux));
4232 switch (spec->board_config) {
4234 spec->init = dell_eq_core_init;
4237 spec->num_smuxes = 0;
4238 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4239 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4243 spec->init = dell_m6_core_init;
4244 switch (codec->subsystem_id) {
4245 case 0x1028025e: /* Analog Mics */
4247 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4248 spec->num_dmics = 0;
4249 spec->private_dimux.num_items = 1;
4251 case 0x10280271: /* Digital Mics */
4255 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4256 spec->num_dmics = 1;
4257 spec->private_dimux.num_items = 2;
4259 case 0x10280256: /* Both */
4261 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4262 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4263 spec->num_dmics = 1;
4264 spec->private_dimux.num_items = 2;
4269 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4270 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4272 if (spec->board_config > STAC_92HD73XX_REF) {
4273 /* GPIO0 High = Enable EAPD */
4274 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4275 spec->gpio_data = 0x01;
4277 spec->dinput_mux = &spec->private_dimux;
4279 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4280 spec->pwr_nids = stac92hd73xx_pwr_nids;
4282 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4285 if (spec->board_config < 0) {
4286 printk(KERN_WARNING "hda_codec: No auto-config is "
4287 "available, default to model=ref\n");
4288 spec->board_config = STAC_92HD73XX_REF;
4295 stac92xx_free(codec);
4299 codec->patch_ops = stac92xx_patch_ops;
4304 static struct hda_input_mux stac92hd83xxx_dmux = {
4307 { "Analog Inputs", 0x03 },
4308 { "Digital Mic 1", 0x04 },
4309 { "Digital Mic 2", 0x05 },
4313 static int patch_stac92hd83xxx(struct hda_codec *codec)
4315 struct sigmatel_spec *spec;
4318 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4323 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4324 spec->mono_nid = 0x19;
4325 spec->digbeep_nid = 0x21;
4326 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4327 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4328 spec->adc_nids = stac92hd83xxx_adc_nids;
4329 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4330 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4331 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4332 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4334 spec->init = stac92hd83xxx_core_init;
4335 switch (codec->vendor_id) {
4337 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4341 spec->init++; /* switch to config #2 */
4342 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4345 spec->mixer = stac92hd83xxx_mixer;
4346 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4347 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4348 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4349 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4350 spec->dinput_mux = &stac92hd83xxx_dmux;
4351 spec->pin_nids = stac92hd83xxx_pin_nids;
4352 spec->board_config = snd_hda_check_board_config(codec,
4353 STAC_92HD83XXX_MODELS,
4354 stac92hd83xxx_models,
4355 stac92hd83xxx_cfg_tbl);
4357 if (spec->board_config < 0) {
4358 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4359 " STAC92HD83XXX, using BIOS defaults\n");
4360 err = stac92xx_save_bios_config_regs(codec);
4362 stac92xx_free(codec);
4365 spec->pin_configs = spec->bios_pin_configs;
4367 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4368 stac92xx_set_config_regs(codec);
4371 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4373 if (spec->board_config < 0) {
4374 printk(KERN_WARNING "hda_codec: No auto-config is "
4375 "available, default to model=ref\n");
4376 spec->board_config = STAC_92HD83XXX_REF;
4383 stac92xx_free(codec);
4387 codec->patch_ops = stac92xx_patch_ops;
4392 #ifdef SND_HDA_NEEDS_RESUME
4393 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4395 struct sigmatel_spec *spec = codec->spec;
4397 snd_hda_codec_write_cache(codec, codec->afg, 0,
4398 AC_VERB_SET_POWER_STATE, pwr);
4401 for (i = 0; i < spec->num_adcs; i++) {
4402 snd_hda_codec_write_cache(codec,
4403 spec->adc_nids[i], 0,
4404 AC_VERB_SET_POWER_STATE, pwr);
4408 static int stac92hd71xx_resume(struct hda_codec *codec)
4410 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4411 return stac92xx_resume(codec);
4414 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4416 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4422 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4423 .build_controls = stac92xx_build_controls,
4424 .build_pcms = stac92xx_build_pcms,
4425 .init = stac92xx_init,
4426 .free = stac92xx_free,
4427 .unsol_event = stac92xx_unsol_event,
4428 #ifdef SND_HDA_NEEDS_RESUME
4429 .resume = stac92hd71xx_resume,
4430 .suspend = stac92hd71xx_suspend,
4434 static struct hda_input_mux stac92hd71bxx_dmux = {
4437 { "Analog Inputs", 0x00 },
4439 { "Digital Mic 1", 0x02 },
4440 { "Digital Mic 2", 0x03 },
4444 static int patch_stac92hd71bxx(struct hda_codec *codec)
4446 struct sigmatel_spec *spec;
4449 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4454 codec->patch_ops = stac92xx_patch_ops;
4455 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4456 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4457 spec->pin_nids = stac92hd71bxx_pin_nids;
4458 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux,
4459 sizeof(stac92hd71bxx_dmux));
4460 spec->board_config = snd_hda_check_board_config(codec,
4461 STAC_92HD71BXX_MODELS,
4462 stac92hd71bxx_models,
4463 stac92hd71bxx_cfg_tbl);
4465 if (spec->board_config < 0) {
4466 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4467 " STAC92HD71BXX, using BIOS defaults\n");
4468 err = stac92xx_save_bios_config_regs(codec);
4470 stac92xx_free(codec);
4473 spec->pin_configs = spec->bios_pin_configs;
4475 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4476 stac92xx_set_config_regs(codec);
4479 switch (codec->vendor_id) {
4480 case 0x111d76b6: /* 4 Port without Analog Mixer */
4482 case 0x111d76b4: /* 6 Port without Analog Mixer */
4484 spec->mixer = stac92hd71bxx_mixer;
4485 spec->init = stac92hd71bxx_core_init;
4486 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4488 case 0x111d7608: /* 5 Port with Analog Mixer */
4489 switch (codec->subsystem_id) {
4491 /* Enable VREF power saving on GPIO1 detect */
4492 snd_hda_codec_write(codec, codec->afg, 0,
4493 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
4494 snd_hda_codec_write_cache(codec, codec->afg, 0,
4495 AC_VERB_SET_UNSOLICITED_ENABLE,
4496 (AC_USRSP_EN | STAC_VREF_EVENT | 0x01));
4497 spec->gpio_mask |= 0x02;
4500 if ((codec->revision_id & 0xf) == 0 ||
4501 (codec->revision_id & 0xf) == 1) {
4502 #ifdef SND_HDA_NEEDS_RESUME
4503 codec->patch_ops = stac92hd71bxx_patch_ops;
4505 spec->stream_delay = 40; /* 40 milliseconds */
4508 /* no output amps */
4510 spec->mixer = stac92hd71bxx_analog_mixer;
4511 spec->dinput_mux = &spec->private_dimux;
4514 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4515 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4517 case 0x111d7603: /* 6 Port with Analog Mixer */
4518 if ((codec->revision_id & 0xf) == 1) {
4519 #ifdef SND_HDA_NEEDS_RESUME
4520 codec->patch_ops = stac92hd71bxx_patch_ops;
4522 spec->stream_delay = 40; /* 40 milliseconds */
4525 /* no output amps */
4529 spec->dinput_mux = &spec->private_dimux;
4530 spec->mixer = stac92hd71bxx_analog_mixer;
4531 spec->init = stac92hd71bxx_analog_core_init;
4532 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4535 spec->aloopback_mask = 0x50;
4536 spec->aloopback_shift = 0;
4538 if (spec->board_config > STAC_92HD71BXX_REF) {
4540 spec->gpio_mask = 0x01;
4541 spec->gpio_dir = 0x01;
4542 spec->gpio_data = 0x01;
4545 spec->powerdown_adcs = 1;
4546 spec->digbeep_nid = 0x26;
4547 spec->mux_nids = stac92hd71bxx_mux_nids;
4548 spec->adc_nids = stac92hd71bxx_adc_nids;
4549 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4550 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4551 spec->smux_nids = stac92hd71bxx_smux_nids;
4552 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4554 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4555 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4557 switch (spec->board_config) {
4559 spec->num_dmics = 0;
4560 spec->num_smuxes = 0;
4561 spec->num_dmuxes = 0;
4563 /* enable internal microphone */
4564 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4565 stac92xx_auto_set_pinctl(codec, 0x0e,
4566 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4569 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4570 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4571 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4574 spec->multiout.num_dacs = 1;
4575 spec->multiout.hp_nid = 0x11;
4576 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4577 if (spec->dinput_mux)
4578 spec->private_dimux.num_items +=
4580 (ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1);
4582 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4584 if (spec->board_config < 0) {
4585 printk(KERN_WARNING "hda_codec: No auto-config is "
4586 "available, default to model=ref\n");
4587 spec->board_config = STAC_92HD71BXX_REF;
4594 stac92xx_free(codec);
4601 static int patch_stac922x(struct hda_codec *codec)
4603 struct sigmatel_spec *spec;
4606 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4611 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4612 spec->pin_nids = stac922x_pin_nids;
4613 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4616 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4617 spec->gpio_mask = spec->gpio_dir = 0x03;
4618 spec->gpio_data = 0x03;
4619 /* Intel Macs have all same PCI SSID, so we need to check
4620 * codec SSID to distinguish the exact models
4622 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4623 switch (codec->subsystem_id) {
4626 spec->board_config = STAC_INTEL_MAC_V1;
4630 spec->board_config = STAC_INTEL_MAC_V2;
4638 spec->board_config = STAC_INTEL_MAC_V3;
4642 spec->board_config = STAC_INTEL_MAC_V4;
4646 spec->board_config = STAC_INTEL_MAC_V5;
4649 spec->board_config = STAC_INTEL_MAC_V3;
4655 if (spec->board_config < 0) {
4656 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4657 "using BIOS defaults\n");
4658 err = stac92xx_save_bios_config_regs(codec);
4660 stac92xx_free(codec);
4663 spec->pin_configs = spec->bios_pin_configs;
4664 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4665 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4666 stac92xx_set_config_regs(codec);
4669 spec->adc_nids = stac922x_adc_nids;
4670 spec->mux_nids = stac922x_mux_nids;
4671 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4672 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4673 spec->num_dmics = 0;
4676 spec->init = stac922x_core_init;
4677 spec->mixer = stac922x_mixer;
4679 spec->multiout.dac_nids = spec->dac_nids;
4681 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4683 if (spec->board_config < 0) {
4684 printk(KERN_WARNING "hda_codec: No auto-config is "
4685 "available, default to model=ref\n");
4686 spec->board_config = STAC_D945_REF;
4692 stac92xx_free(codec);
4696 codec->patch_ops = stac92xx_patch_ops;
4698 /* Fix Mux capture level; max to 2 */
4699 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4700 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4701 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4702 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4703 (0 << AC_AMPCAP_MUTE_SHIFT));
4708 static int patch_stac927x(struct hda_codec *codec)
4710 struct sigmatel_spec *spec;
4713 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4718 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4719 spec->pin_nids = stac927x_pin_nids;
4720 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4724 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4725 if (spec->board_config < 0)
4726 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4727 "STAC927x, using BIOS defaults\n");
4728 err = stac92xx_save_bios_config_regs(codec);
4730 stac92xx_free(codec);
4733 spec->pin_configs = spec->bios_pin_configs;
4735 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4736 stac92xx_set_config_regs(codec);
4739 spec->digbeep_nid = 0x23;
4740 spec->adc_nids = stac927x_adc_nids;
4741 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4742 spec->mux_nids = stac927x_mux_nids;
4743 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4744 spec->smux_nids = stac927x_smux_nids;
4745 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4746 spec->spdif_labels = stac927x_spdif_labels;
4747 spec->dac_list = stac927x_dac_nids;
4748 spec->multiout.dac_nids = spec->dac_nids;
4750 switch (spec->board_config) {
4753 /* GPIO0 High = Enable EAPD */
4754 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4755 spec->gpio_data = 0x01;
4756 spec->num_dmics = 0;
4758 spec->init = d965_core_init;
4759 spec->mixer = stac927x_mixer;
4761 case STAC_DELL_BIOS:
4762 switch (codec->subsystem_id) {
4765 /* correct the device field to SPDIF out */
4766 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4769 /* configure the analog microphone on some laptops */
4770 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4771 /* correct the front output jack as a hp out */
4772 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4773 /* correct the front input jack as a mic */
4774 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4777 /* GPIO2 High = Enable EAPD */
4778 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4779 spec->gpio_data = 0x04;
4780 spec->dmic_nids = stac927x_dmic_nids;
4781 spec->num_dmics = STAC927X_NUM_DMICS;
4783 spec->init = d965_core_init;
4784 spec->mixer = stac927x_mixer;
4785 spec->dmux_nids = stac927x_dmux_nids;
4786 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4789 if (spec->board_config > STAC_D965_REF) {
4790 /* GPIO0 High = Enable EAPD */
4791 spec->eapd_mask = spec->gpio_mask = 0x01;
4792 spec->gpio_dir = spec->gpio_data = 0x01;
4794 spec->num_dmics = 0;
4796 spec->init = stac927x_core_init;
4797 spec->mixer = stac927x_mixer;
4801 spec->aloopback_mask = 0x40;
4802 spec->aloopback_shift = 0;
4804 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4806 if (spec->board_config < 0) {
4807 printk(KERN_WARNING "hda_codec: No auto-config is "
4808 "available, default to model=ref\n");
4809 spec->board_config = STAC_D965_REF;
4815 stac92xx_free(codec);
4819 codec->patch_ops = stac92xx_patch_ops;
4823 * The STAC927x seem to require fairly long delays for certain
4824 * command sequences. With too short delays (even if the answer
4825 * is set to RIRB properly), it results in the silence output
4826 * on some hardwares like Dell.
4828 * The below flag enables the longer delay (see get_response
4831 codec->bus->needs_damn_long_delay = 1;
4836 static int patch_stac9205(struct hda_codec *codec)
4838 struct sigmatel_spec *spec;
4841 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4846 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4847 spec->pin_nids = stac9205_pin_nids;
4848 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4852 if (spec->board_config < 0) {
4853 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4854 err = stac92xx_save_bios_config_regs(codec);
4856 stac92xx_free(codec);
4859 spec->pin_configs = spec->bios_pin_configs;
4861 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4862 stac92xx_set_config_regs(codec);
4865 spec->digbeep_nid = 0x23;
4866 spec->adc_nids = stac9205_adc_nids;
4867 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4868 spec->mux_nids = stac9205_mux_nids;
4869 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4870 spec->smux_nids = stac9205_smux_nids;
4871 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4872 spec->dmic_nids = stac9205_dmic_nids;
4873 spec->num_dmics = STAC9205_NUM_DMICS;
4874 spec->dmux_nids = stac9205_dmux_nids;
4875 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4878 spec->init = stac9205_core_init;
4879 spec->mixer = stac9205_mixer;
4881 spec->aloopback_mask = 0x40;
4882 spec->aloopback_shift = 0;
4883 spec->multiout.dac_nids = spec->dac_nids;
4885 switch (spec->board_config){
4886 case STAC_9205_DELL_M43:
4887 /* Enable SPDIF in/out */
4888 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4889 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4891 /* Enable unsol response for GPIO4/Dock HP connection */
4892 snd_hda_codec_write(codec, codec->afg, 0,
4893 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4894 snd_hda_codec_write_cache(codec, codec->afg, 0,
4895 AC_VERB_SET_UNSOLICITED_ENABLE,
4896 (AC_USRSP_EN | STAC_HP_EVENT));
4898 spec->gpio_dir = 0x0b;
4899 spec->eapd_mask = 0x01;
4900 spec->gpio_mask = 0x1b;
4901 spec->gpio_mute = 0x10;
4902 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4905 spec->gpio_data = 0x01;
4908 /* SPDIF-In enabled */
4911 /* GPIO0 High = EAPD */
4912 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4913 spec->gpio_data = 0x01;
4917 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4919 if (spec->board_config < 0) {
4920 printk(KERN_WARNING "hda_codec: No auto-config is "
4921 "available, default to model=ref\n");
4922 spec->board_config = STAC_9205_REF;
4928 stac92xx_free(codec);
4932 codec->patch_ops = stac92xx_patch_ops;
4941 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4942 static hda_nid_t vaio_dacs[] = { 0x2 };
4943 #define VAIO_HP_DAC 0x5
4944 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4945 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4947 static struct hda_input_mux vaio_mux = {
4950 /* { "HP", 0x0 }, */
4951 { "Mic Jack", 0x1 },
4952 { "Internal Mic", 0x2 },
4957 static struct hda_verb vaio_init[] = {
4958 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4959 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
4960 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4961 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4962 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4963 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4964 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4965 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4966 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4967 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4969 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4973 static struct hda_verb vaio_ar_init[] = {
4974 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4975 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4976 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4977 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4978 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4979 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4981 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4982 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4983 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4984 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4985 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4986 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4990 /* bind volumes of both NID 0x02 and 0x05 */
4991 static struct hda_bind_ctls vaio_bind_master_vol = {
4992 .ops = &snd_hda_bind_vol,
4994 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4995 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5000 /* bind volumes of both NID 0x02 and 0x05 */
5001 static struct hda_bind_ctls vaio_bind_master_sw = {
5002 .ops = &snd_hda_bind_sw,
5004 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
5005 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
5010 static struct snd_kcontrol_new vaio_mixer[] = {
5011 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5012 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5013 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5014 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5015 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5018 .name = "Capture Source",
5020 .info = stac92xx_mux_enum_info,
5021 .get = stac92xx_mux_enum_get,
5022 .put = stac92xx_mux_enum_put,
5027 static struct snd_kcontrol_new vaio_ar_mixer[] = {
5028 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
5029 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
5030 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
5031 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5032 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5033 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
5034 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
5036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5037 .name = "Capture Source",
5039 .info = stac92xx_mux_enum_info,
5040 .get = stac92xx_mux_enum_get,
5041 .put = stac92xx_mux_enum_put,
5046 static struct hda_codec_ops stac9872_patch_ops = {
5047 .build_controls = stac92xx_build_controls,
5048 .build_pcms = stac92xx_build_pcms,
5049 .init = stac92xx_init,
5050 .free = stac92xx_free,
5051 #ifdef SND_HDA_NEEDS_RESUME
5052 .resume = stac92xx_resume,
5056 static int stac9872_vaio_init(struct hda_codec *codec)
5060 err = stac92xx_init(codec);
5063 if (codec->patch_ops.unsol_event)
5064 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
5068 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
5070 if (get_hp_pin_presence(codec, 0x0a)) {
5071 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5072 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5074 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
5075 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
5079 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
5081 switch (res >> 26) {
5083 stac9872_vaio_hp_detect(codec, res);
5088 static struct hda_codec_ops stac9872_vaio_patch_ops = {
5089 .build_controls = stac92xx_build_controls,
5090 .build_pcms = stac92xx_build_pcms,
5091 .init = stac9872_vaio_init,
5092 .free = stac92xx_free,
5093 .unsol_event = stac9872_vaio_unsol_event,
5095 .resume = stac92xx_resume,
5099 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
5101 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
5103 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
5105 /* AR Series. id=0x83847664 and subsys=104D1300 */
5110 static const char *stac9872_models[STAC_9872_MODELS] = {
5111 [CXD9872RD_VAIO] = "vaio",
5112 [CXD9872AKD_VAIO] = "vaio-ar",
5115 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5116 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
5117 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
5118 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
5119 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
5123 static int patch_stac9872(struct hda_codec *codec)
5125 struct sigmatel_spec *spec;
5128 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5131 if (board_config < 0)
5132 /* unknown config, let generic-parser do its job... */
5133 return snd_hda_parse_generic_codec(codec);
5135 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5140 switch (board_config) {
5141 case CXD9872RD_VAIO:
5142 case STAC9872AK_VAIO:
5143 case STAC9872K_VAIO:
5144 spec->mixer = vaio_mixer;
5145 spec->init = vaio_init;
5146 spec->multiout.max_channels = 2;
5147 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5148 spec->multiout.dac_nids = vaio_dacs;
5149 spec->multiout.hp_nid = VAIO_HP_DAC;
5150 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5151 spec->adc_nids = vaio_adcs;
5153 spec->input_mux = &vaio_mux;
5154 spec->mux_nids = vaio_mux_nids;
5155 codec->patch_ops = stac9872_vaio_patch_ops;
5158 case CXD9872AKD_VAIO:
5159 spec->mixer = vaio_ar_mixer;
5160 spec->init = vaio_ar_init;
5161 spec->multiout.max_channels = 2;
5162 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5163 spec->multiout.dac_nids = vaio_dacs;
5164 spec->multiout.hp_nid = VAIO_HP_DAC;
5165 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5167 spec->adc_nids = vaio_adcs;
5168 spec->input_mux = &vaio_mux;
5169 spec->mux_nids = vaio_mux_nids;
5170 codec->patch_ops = stac9872_patch_ops;
5181 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5182 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5183 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5184 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5185 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5186 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5187 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5188 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5189 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5190 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5191 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5192 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5193 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5194 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5195 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5196 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5197 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5198 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5199 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5200 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5201 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5202 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5203 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5204 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5205 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5206 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5207 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5208 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5209 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5210 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5211 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5212 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5213 /* The following does not take into account .id=0x83847661 when subsys =
5214 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5215 * currently not fully supported.
5217 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5218 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5219 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5220 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5221 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5222 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5223 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5224 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5225 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5226 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5227 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5228 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5229 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5230 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5231 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5232 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5233 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5234 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5235 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5236 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5237 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5238 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5239 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5240 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5241 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5242 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },