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
104 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
105 * is given, one of the above models will be
106 * chosen according to the subsystem id. */
107 /* for backward compatibility */
131 struct sigmatel_spec {
132 struct snd_kcontrol_new *mixers[4];
133 unsigned int num_mixers;
136 unsigned int surr_switch: 1;
137 unsigned int line_switch: 1;
138 unsigned int mic_switch: 1;
139 unsigned int alt_switch: 1;
140 unsigned int hp_detect: 1;
141 unsigned int spdif_mute: 1;
144 unsigned int eapd_mask;
145 unsigned int gpio_mask;
146 unsigned int gpio_dir;
147 unsigned int gpio_data;
148 unsigned int gpio_mute;
151 unsigned int stream_delay;
153 /* analog loopback */
154 unsigned char aloopback_mask;
155 unsigned char aloopback_shift;
157 /* power management */
158 unsigned int num_pwrs;
159 unsigned int *pwr_mapping;
164 struct hda_input_mux *mono_mux;
165 struct hda_input_mux *amp_mux;
166 unsigned int cur_mmux;
167 struct hda_multi_out multiout;
168 hda_nid_t dac_nids[5];
172 unsigned int num_adcs;
174 unsigned int num_muxes;
175 hda_nid_t *dmic_nids;
176 unsigned int num_dmics;
177 hda_nid_t *dmux_nids;
178 unsigned int num_dmuxes;
179 hda_nid_t *smux_nids;
180 unsigned int num_smuxes;
181 const char **spdif_labels;
183 hda_nid_t dig_in_nid;
185 hda_nid_t anabeep_nid;
186 hda_nid_t digbeep_nid;
190 unsigned int num_pins;
191 unsigned int *pin_configs;
192 unsigned int *bios_pin_configs;
194 /* codec specific stuff */
195 struct hda_verb *init;
196 struct snd_kcontrol_new *mixer;
199 struct hda_input_mux *dinput_mux;
200 unsigned int cur_dmux[2];
201 struct hda_input_mux *input_mux;
202 unsigned int cur_mux[3];
203 struct hda_input_mux *sinput_mux;
204 unsigned int cur_smux[2];
205 unsigned int cur_amux;
207 unsigned int num_amps;
208 unsigned int powerdown_adcs;
211 unsigned int io_switch[2];
212 unsigned int clfe_swap;
213 unsigned int hp_switch;
214 unsigned int aloopback;
216 struct hda_pcm pcm_rec[2]; /* PCM information */
218 /* dynamic controls and input_mux */
219 struct auto_pin_cfg autocfg;
220 unsigned int num_kctl_alloc, num_kctl_used;
221 struct snd_kcontrol_new *kctl_alloc;
222 struct hda_input_mux private_dimux;
223 struct hda_input_mux private_imux;
224 struct hda_input_mux private_smux;
225 struct hda_input_mux private_amp_mux;
226 struct hda_input_mux private_mono_mux;
229 static hda_nid_t stac9200_adc_nids[1] = {
233 static hda_nid_t stac9200_mux_nids[1] = {
237 static hda_nid_t stac9200_dac_nids[1] = {
241 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
242 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
246 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
250 static hda_nid_t stac92hd73xx_adc_nids[2] = {
254 #define DELL_M6_AMP 2
255 static hda_nid_t stac92hd73xx_amp_nids[3] = {
259 #define STAC92HD73XX_NUM_DMICS 2
260 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
264 #define STAC92HD73_DAC_COUNT 5
265 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
266 0x15, 0x16, 0x17, 0x18, 0x19,
269 static hda_nid_t stac92hd73xx_mux_nids[4] = {
270 0x28, 0x29, 0x2a, 0x2b,
273 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
277 static hda_nid_t stac92hd73xx_smux_nids[2] = {
281 #define STAC92HD83XXX_NUM_DMICS 2
282 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
286 #define STAC92HD81_DAC_COUNT 2
287 #define STAC92HD83_DAC_COUNT 3
288 static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = {
292 static hda_nid_t stac92hd83xxx_dmux_nids[2] = {
296 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
300 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
304 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
308 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
309 0x03, 0x0c, 0x10, 0x40,
312 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
316 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
320 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
324 static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
328 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
332 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
336 #define STAC92HD71BXX_NUM_DMICS 2
337 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
341 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
345 static hda_nid_t stac925x_adc_nids[1] = {
349 static hda_nid_t stac925x_mux_nids[1] = {
353 static hda_nid_t stac925x_dac_nids[1] = {
357 #define STAC925X_NUM_DMICS 1
358 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
362 static hda_nid_t stac925x_dmux_nids[1] = {
366 static hda_nid_t stac922x_adc_nids[2] = {
370 static hda_nid_t stac922x_mux_nids[2] = {
374 static hda_nid_t stac927x_adc_nids[3] = {
378 static hda_nid_t stac927x_mux_nids[3] = {
382 static hda_nid_t stac927x_smux_nids[1] = {
386 static hda_nid_t stac927x_dac_nids[6] = {
387 0x02, 0x03, 0x04, 0x05, 0x06, 0
390 static hda_nid_t stac927x_dmux_nids[1] = {
394 #define STAC927X_NUM_DMICS 2
395 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
399 static const char *stac927x_spdif_labels[5] = {
400 "Digital Playback", "ADAT", "Analog Mux 1",
401 "Analog Mux 2", "Analog Mux 3"
404 static hda_nid_t stac9205_adc_nids[2] = {
408 static hda_nid_t stac9205_mux_nids[2] = {
412 static hda_nid_t stac9205_dmux_nids[1] = {
416 static hda_nid_t stac9205_smux_nids[1] = {
420 #define STAC9205_NUM_DMICS 2
421 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
425 static hda_nid_t stac9200_pin_nids[8] = {
426 0x08, 0x09, 0x0d, 0x0e,
427 0x0f, 0x10, 0x11, 0x12,
430 static hda_nid_t stac925x_pin_nids[8] = {
431 0x07, 0x08, 0x0a, 0x0b,
432 0x0c, 0x0d, 0x10, 0x11,
435 static hda_nid_t stac922x_pin_nids[10] = {
436 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
437 0x0f, 0x10, 0x11, 0x15, 0x1b,
440 static hda_nid_t stac92hd73xx_pin_nids[13] = {
441 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
442 0x0f, 0x10, 0x11, 0x12, 0x13,
446 static hda_nid_t stac92hd83xxx_pin_nids[14] = {
447 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
448 0x0f, 0x10, 0x11, 0x12, 0x13,
449 0x1d, 0x1e, 0x1f, 0x20
451 static hda_nid_t stac92hd71bxx_pin_nids[11] = {
452 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
453 0x0f, 0x14, 0x18, 0x19, 0x1e,
457 static hda_nid_t stac927x_pin_nids[14] = {
458 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
459 0x0f, 0x10, 0x11, 0x12, 0x13,
460 0x14, 0x21, 0x22, 0x23,
463 static hda_nid_t stac9205_pin_nids[12] = {
464 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
465 0x0f, 0x14, 0x16, 0x17, 0x18,
469 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
471 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_value *ucontrol)
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct sigmatel_spec *spec = codec->spec;
476 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
478 kcontrol->private_value ^= get_amp_nid(kcontrol);
479 kcontrol->private_value |= nid;
481 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
484 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
485 struct snd_ctl_elem_value *ucontrol)
487 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
488 struct sigmatel_spec *spec = codec->spec;
489 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
491 kcontrol->private_value ^= get_amp_nid(kcontrol);
492 kcontrol->private_value |= nid;
494 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
497 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
498 struct snd_ctl_elem_info *uinfo)
500 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
501 struct sigmatel_spec *spec = codec->spec;
502 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
505 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
506 struct snd_ctl_elem_value *ucontrol)
508 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
509 struct sigmatel_spec *spec = codec->spec;
510 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
512 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
516 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_value *ucontrol)
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct sigmatel_spec *spec = codec->spec;
521 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
523 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
524 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
527 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
528 struct snd_ctl_elem_info *uinfo)
530 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
531 struct sigmatel_spec *spec = codec->spec;
532 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
535 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct sigmatel_spec *spec = codec->spec;
540 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
542 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
546 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct sigmatel_spec *spec = codec->spec;
551 struct hda_input_mux *smux = &spec->private_smux;
552 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
556 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
557 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
561 if (spec->spdif_mute) {
563 nid = spec->multiout.dig_out_nid;
565 nid = codec->slave_dig_outs[smux_idx - 1];
566 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
569 nid = spec->multiout.dig_out_nid;
571 nid = codec->slave_dig_outs[smux_idx - 1];
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 /* set master volume to max value without distortion
778 * and direct control */
779 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
780 /* setup audio connections */
781 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
782 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
783 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
784 /* setup adcs to point to mixer */
785 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
786 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
787 /* setup import muxs */
788 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
789 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
790 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
791 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
795 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
796 /* set master volume and direct control */
797 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
798 /* setup audio connections */
799 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
800 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
801 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
802 /* connect hp ports to dac3 */
803 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
804 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
805 /* setup adcs to point to mixer */
806 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
807 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
808 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
809 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
810 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
811 /* setup import muxs */
812 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
813 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
814 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
815 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
819 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
820 /* set master volume and direct control */
821 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
822 /* setup audio connections */
823 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
824 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
825 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
826 /* dac3 is connected to import3 mux */
827 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
828 /* connect hp ports to dac4 */
829 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
830 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
831 /* setup adcs to point to mixer */
832 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
833 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
834 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
835 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
836 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 /* setup import muxs */
838 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
839 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
840 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
845 static struct hda_verb stac92hd83xxx_core_init[] = {
846 /* start of config #1 */
847 { 0xe, AC_VERB_SET_CONNECT_SEL, 0x3},
849 /* start of config #2 */
850 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x0},
851 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x0},
852 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x1},
854 /* power state controls amps */
855 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
858 static struct hda_verb stac92hd71bxx_core_init[] = {
859 /* set master volume and direct control */
860 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
861 /* connect headphone jack to dac1 */
862 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
863 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
864 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
865 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
866 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
867 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 #define HD_DISABLE_PORTF 3
871 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
872 /* start of config #1 */
874 /* connect port 0f to audio mixer */
875 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
876 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
877 /* unmute right and left channels for node 0x0f */
878 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
879 /* start of config #2 */
881 /* set master volume and direct control */
882 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
883 /* connect headphone jack to dac1 */
884 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
885 /* connect port 0d to audio mixer */
886 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
887 /* unmute dac0 input in audio mixer */
888 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
889 /* unmute right and left channels for nodes 0x0a, 0xd */
890 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
891 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
895 static struct hda_verb stac925x_core_init[] = {
896 /* set dac0mux for dac converter */
897 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
901 static struct hda_verb stac922x_core_init[] = {
902 /* set master volume and direct control */
903 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
907 static struct hda_verb d965_core_init[] = {
908 /* set master volume and direct control */
909 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
910 /* unmute node 0x1b */
911 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
912 /* select node 0x03 as DAC */
913 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
917 static struct hda_verb stac927x_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 static struct hda_verb stac9205_core_init[] = {
926 /* set master volume and direct control */
927 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
928 /* enable analog pc beep path */
929 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
933 #define STAC_MONO_MUX \
935 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
936 .name = "Mono Mux", \
938 .info = stac92xx_mono_mux_enum_info, \
939 .get = stac92xx_mono_mux_enum_get, \
940 .put = stac92xx_mono_mux_enum_put, \
943 #define STAC_AMP_MUX \
945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
946 .name = "Amp Selector Capture Switch", \
948 .info = stac92xx_amp_mux_enum_info, \
949 .get = stac92xx_amp_mux_enum_get, \
950 .put = stac92xx_amp_mux_enum_put, \
953 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
955 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
959 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
960 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
961 .info = stac92xx_amp_volume_info, \
962 .get = stac92xx_amp_volume_get, \
963 .put = stac92xx_amp_volume_put, \
964 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
965 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
968 #define STAC_INPUT_SOURCE(cnt) \
970 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
971 .name = "Input Source", \
973 .info = stac92xx_mux_enum_info, \
974 .get = stac92xx_mux_enum_get, \
975 .put = stac92xx_mux_enum_put, \
978 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Analog Loopback", \
983 .info = stac92xx_aloopback_info, \
984 .get = stac92xx_aloopback_get, \
985 .put = stac92xx_aloopback_put, \
986 .private_value = verb_read | (verb_write << 16), \
989 static struct snd_kcontrol_new stac9200_mixer[] = {
990 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
992 STAC_INPUT_SOURCE(1),
993 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
994 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
998 #define DELL_M6_MIXER 6
999 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1000 /* start of config #1 */
1001 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1002 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1004 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1005 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1007 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1008 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1010 /* start of config #2 */
1011 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1012 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1014 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1015 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1019 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1020 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1022 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1023 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1028 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1029 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1031 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1032 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1034 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1035 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1037 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1038 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1040 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1041 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1043 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1044 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1046 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1047 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1049 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1050 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1054 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1055 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1057 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1058 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1060 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1061 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1063 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1064 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1066 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1069 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1070 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1072 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1073 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1075 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1076 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1081 static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1082 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1083 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1085 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1086 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1088 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT),
1089 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT),
1091 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT),
1092 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT),
1094 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT),
1095 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT),
1097 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT),
1098 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT),
1101 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT),
1102 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT),
1107 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1108 STAC_INPUT_SOURCE(2),
1110 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1111 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1113 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1114 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1115 /* analog pc-beep replaced with digital beep support */
1117 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1118 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1121 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
1122 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
1126 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1127 STAC_INPUT_SOURCE(2),
1128 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
1130 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1131 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1133 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1134 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1138 static struct snd_kcontrol_new stac925x_mixer[] = {
1139 STAC_INPUT_SOURCE(1),
1140 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1141 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1145 static struct snd_kcontrol_new stac9205_mixer[] = {
1146 STAC_INPUT_SOURCE(2),
1147 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1157 /* This needs to be generated dynamically based on sequence */
1158 static struct snd_kcontrol_new stac922x_mixer[] = {
1159 STAC_INPUT_SOURCE(2),
1160 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1161 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1163 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1164 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1169 static struct snd_kcontrol_new stac927x_mixer[] = {
1170 STAC_INPUT_SOURCE(3),
1171 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1179 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1180 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1184 static struct snd_kcontrol_new stac_dmux_mixer = {
1185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1186 .name = "Digital Input Source",
1187 /* count set later */
1188 .info = stac92xx_dmux_enum_info,
1189 .get = stac92xx_dmux_enum_get,
1190 .put = stac92xx_dmux_enum_put,
1193 static struct snd_kcontrol_new stac_smux_mixer = {
1194 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1195 .name = "IEC958 Playback Source",
1196 /* count set later */
1197 .info = stac92xx_smux_enum_info,
1198 .get = stac92xx_smux_enum_get,
1199 .put = stac92xx_smux_enum_put,
1202 static const char *slave_vols[] = {
1203 "Front Playback Volume",
1204 "Surround Playback Volume",
1205 "Center Playback Volume",
1206 "LFE Playback Volume",
1207 "Side Playback Volume",
1208 "Headphone Playback Volume",
1209 "Headphone Playback Volume",
1210 "Speaker Playback Volume",
1211 "External Speaker Playback Volume",
1212 "Speaker2 Playback Volume",
1216 static const char *slave_sws[] = {
1217 "Front Playback Switch",
1218 "Surround Playback Switch",
1219 "Center Playback Switch",
1220 "LFE Playback Switch",
1221 "Side Playback Switch",
1222 "Headphone Playback Switch",
1223 "Headphone Playback Switch",
1224 "Speaker Playback Switch",
1225 "External Speaker Playback Switch",
1226 "Speaker2 Playback Switch",
1227 "IEC958 Playback Switch",
1231 static int stac92xx_build_controls(struct hda_codec *codec)
1233 struct sigmatel_spec *spec = codec->spec;
1237 err = snd_hda_add_new_ctls(codec, spec->mixer);
1241 for (i = 0; i < spec->num_mixers; i++) {
1242 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1246 if (spec->num_dmuxes > 0) {
1247 stac_dmux_mixer.count = spec->num_dmuxes;
1248 err = snd_ctl_add(codec->bus->card,
1249 snd_ctl_new1(&stac_dmux_mixer, codec));
1253 if (spec->num_smuxes > 0) {
1254 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1255 struct hda_input_mux *smux = &spec->private_smux;
1256 /* check for mute support on SPDIF out */
1257 if (wcaps & AC_WCAP_OUT_AMP) {
1258 smux->items[smux->num_items].label = "Off";
1259 smux->items[smux->num_items].index = 0;
1261 spec->spdif_mute = 1;
1263 stac_smux_mixer.count = spec->num_smuxes;
1264 err = snd_ctl_add(codec->bus->card,
1265 snd_ctl_new1(&stac_smux_mixer, codec));
1270 if (spec->multiout.dig_out_nid) {
1271 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1274 err = snd_hda_create_spdif_share_sw(codec,
1278 spec->multiout.share_spdif = 1;
1280 if (spec->dig_in_nid && (!spec->gpio_dir & 0x01)) {
1281 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1286 /* if we have no master control, let's create it */
1287 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1288 unsigned int vmaster_tlv[4];
1289 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1290 HDA_OUTPUT, vmaster_tlv);
1291 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1292 vmaster_tlv, slave_vols);
1296 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1297 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1306 static unsigned int ref9200_pin_configs[8] = {
1307 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1308 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1312 STAC 9200 pin configs for
1317 static unsigned int dell9200_d21_pin_configs[8] = {
1318 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1319 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1323 STAC 9200 pin configs for
1327 static unsigned int dell9200_d22_pin_configs[8] = {
1328 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1329 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1333 STAC 9200 pin configs for
1334 102801C4 (Dell Dimension E310)
1341 static unsigned int dell9200_d23_pin_configs[8] = {
1342 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1343 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1348 STAC 9200-32 pin configs for
1349 102801B5 (Dell Inspiron 630m)
1350 102801D8 (Dell Inspiron 640m)
1352 static unsigned int dell9200_m21_pin_configs[8] = {
1353 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1354 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1358 STAC 9200-32 pin configs for
1359 102801C2 (Dell Latitude D620)
1361 102801CC (Dell Latitude D820)
1365 static unsigned int dell9200_m22_pin_configs[8] = {
1366 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1367 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1371 STAC 9200-32 pin configs for
1372 102801CE (Dell XPS M1710)
1373 102801CF (Dell Precision M90)
1375 static unsigned int dell9200_m23_pin_configs[8] = {
1376 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1377 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1381 STAC 9200-32 pin configs for
1384 102801CB (Dell Latitude 120L)
1387 static unsigned int dell9200_m24_pin_configs[8] = {
1388 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1389 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1393 STAC 9200-32 pin configs for
1394 102801BD (Dell Inspiron E1505n)
1398 static unsigned int dell9200_m25_pin_configs[8] = {
1399 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1400 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1404 STAC 9200-32 pin configs for
1405 102801F5 (Dell Inspiron 1501)
1408 static unsigned int dell9200_m26_pin_configs[8] = {
1409 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1410 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1415 102801CD (Dell Inspiron E1705/9400)
1417 static unsigned int dell9200_m27_pin_configs[8] = {
1418 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1419 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1422 static unsigned int oqo9200_pin_configs[8] = {
1423 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1424 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1428 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1429 [STAC_REF] = ref9200_pin_configs,
1430 [STAC_9200_OQO] = oqo9200_pin_configs,
1431 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1432 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1433 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1434 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1435 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1436 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1437 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1438 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1439 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1440 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1441 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1444 static const char *stac9200_models[STAC_9200_MODELS] = {
1446 [STAC_9200_OQO] = "oqo",
1447 [STAC_9200_DELL_D21] = "dell-d21",
1448 [STAC_9200_DELL_D22] = "dell-d22",
1449 [STAC_9200_DELL_D23] = "dell-d23",
1450 [STAC_9200_DELL_M21] = "dell-m21",
1451 [STAC_9200_DELL_M22] = "dell-m22",
1452 [STAC_9200_DELL_M23] = "dell-m23",
1453 [STAC_9200_DELL_M24] = "dell-m24",
1454 [STAC_9200_DELL_M25] = "dell-m25",
1455 [STAC_9200_DELL_M26] = "dell-m26",
1456 [STAC_9200_DELL_M27] = "dell-m27",
1457 [STAC_9200_GATEWAY] = "gateway",
1458 [STAC_9200_PANASONIC] = "panasonic",
1461 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1462 /* SigmaTel reference board */
1463 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1464 "DFI LanParty", STAC_REF),
1465 /* Dell laptops have BIOS problem */
1466 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1467 "unknown Dell", STAC_9200_DELL_D21),
1468 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1469 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1470 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1471 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1473 "unknown Dell", STAC_9200_DELL_D22),
1474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1475 "unknown Dell", STAC_9200_DELL_D22),
1476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1477 "Dell Latitude D620", STAC_9200_DELL_M22),
1478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1479 "unknown Dell", STAC_9200_DELL_D23),
1480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1481 "unknown Dell", STAC_9200_DELL_D23),
1482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1483 "unknown Dell", STAC_9200_DELL_M22),
1484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1485 "unknown Dell", STAC_9200_DELL_M24),
1486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1487 "unknown Dell", STAC_9200_DELL_M24),
1488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1489 "Dell Latitude 120L", STAC_9200_DELL_M24),
1490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1491 "Dell Latitude D820", STAC_9200_DELL_M22),
1492 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1493 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1494 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1495 "Dell XPS M1710", STAC_9200_DELL_M23),
1496 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1497 "Dell Precision M90", STAC_9200_DELL_M23),
1498 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1499 "unknown Dell", STAC_9200_DELL_M22),
1500 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1501 "unknown Dell", STAC_9200_DELL_M22),
1502 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1503 "unknown Dell", STAC_9200_DELL_M22),
1504 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1505 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1506 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1507 "unknown Dell", STAC_9200_DELL_D23),
1508 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1509 "unknown Dell", STAC_9200_DELL_D23),
1510 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1511 "unknown Dell", STAC_9200_DELL_D21),
1512 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1513 "unknown Dell", STAC_9200_DELL_D23),
1514 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1515 "unknown Dell", STAC_9200_DELL_D21),
1516 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1517 "unknown Dell", STAC_9200_DELL_M25),
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1519 "unknown Dell", STAC_9200_DELL_M25),
1520 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1521 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1522 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1523 "unknown Dell", STAC_9200_DELL_M26),
1525 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1526 /* Gateway machines needs EAPD to be set on resume */
1527 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1528 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1530 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1533 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1537 static unsigned int ref925x_pin_configs[8] = {
1538 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1539 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1542 static unsigned int stac925x_MA6_pin_configs[8] = {
1543 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1544 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1547 static unsigned int stac925x_PA6_pin_configs[8] = {
1548 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1549 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1552 static unsigned int stac925xM2_2_pin_configs[8] = {
1553 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1554 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1557 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1558 [STAC_REF] = ref925x_pin_configs,
1559 [STAC_M2_2] = stac925xM2_2_pin_configs,
1560 [STAC_MA6] = stac925x_MA6_pin_configs,
1561 [STAC_PA6] = stac925x_PA6_pin_configs,
1564 static const char *stac925x_models[STAC_925x_MODELS] = {
1566 [STAC_M2_2] = "m2-2",
1571 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1572 /* SigmaTel reference board */
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1574 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1575 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1576 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1577 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1578 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1579 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1583 static unsigned int ref92hd73xx_pin_configs[13] = {
1584 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1585 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1586 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1590 static unsigned int dell_m6_pin_configs[13] = {
1591 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1592 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1593 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1597 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1598 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1599 [STAC_DELL_M6] = dell_m6_pin_configs,
1602 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1603 [STAC_92HD73XX_REF] = "ref",
1604 [STAC_DELL_M6] = "dell-m6",
1607 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1608 /* SigmaTel reference board */
1609 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1610 "DFI LanParty", STAC_92HD73XX_REF),
1611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1612 "unknown Dell", STAC_DELL_M6),
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1614 "unknown Dell", STAC_DELL_M6),
1615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1616 "unknown Dell", STAC_DELL_M6),
1617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1618 "unknown Dell", STAC_DELL_M6),
1619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1620 "unknown Dell", STAC_DELL_M6),
1621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1622 "unknown Dell", STAC_DELL_M6),
1623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1624 "unknown Dell", STAC_DELL_M6),
1628 static unsigned int ref92hd83xxx_pin_configs[14] = {
1629 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1630 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1631 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x40f000f0,
1632 0x01451160, 0x98560170,
1635 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1636 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1639 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1640 [STAC_92HD83XXX_REF] = "ref",
1643 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1644 /* SigmaTel reference board */
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1646 "DFI LanParty", STAC_92HD71BXX_REF),
1649 static unsigned int ref92hd71bxx_pin_configs[11] = {
1650 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1651 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1652 0x90a000f0, 0x01452050, 0x01452050,
1655 static unsigned int dell_m4_1_pin_configs[11] = {
1656 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1657 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1658 0x40f000f0, 0x4f0000f0, 0x4f0000f0,
1661 static unsigned int dell_m4_2_pin_configs[11] = {
1662 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1663 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1664 0x40f000f0, 0x044413b0, 0x044413b0,
1667 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1668 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1669 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1670 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1671 [STAC_HP_M4] = NULL,
1674 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1675 [STAC_92HD71BXX_REF] = "ref",
1676 [STAC_DELL_M4_1] = "dell-m4-1",
1677 [STAC_DELL_M4_2] = "dell-m4-2",
1678 [STAC_HP_M4] = "hp-m4",
1681 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1682 /* SigmaTel reference board */
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1684 "DFI LanParty", STAC_92HD71BXX_REF),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1686 "unknown HP", STAC_HP_M4),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1688 "unknown Dell", STAC_DELL_M4_1),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1690 "unknown Dell", STAC_DELL_M4_1),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1692 "unknown Dell", STAC_DELL_M4_1),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1694 "unknown Dell", STAC_DELL_M4_1),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1696 "unknown Dell", STAC_DELL_M4_1),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1698 "unknown Dell", STAC_DELL_M4_1),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1700 "unknown Dell", STAC_DELL_M4_1),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1702 "unknown Dell", STAC_DELL_M4_2),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1704 "unknown Dell", STAC_DELL_M4_2),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1706 "unknown Dell", STAC_DELL_M4_2),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1708 "unknown Dell", STAC_DELL_M4_2),
1712 static unsigned int ref922x_pin_configs[10] = {
1713 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1714 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1715 0x40000100, 0x40000100,
1719 STAC 922X pin configs for
1726 static unsigned int dell_922x_d81_pin_configs[10] = {
1727 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1728 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1729 0x01813122, 0x400001f2,
1733 STAC 922X pin configs for
1737 static unsigned int dell_922x_d82_pin_configs[10] = {
1738 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1739 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1740 0x01813122, 0x400001f1,
1744 STAC 922X pin configs for
1747 static unsigned int dell_922x_m81_pin_configs[10] = {
1748 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1749 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1750 0x40C003f1, 0x405003f0,
1754 STAC 9221 A1 pin configs for
1755 102801D7 (Dell XPS M1210)
1757 static unsigned int dell_922x_m82_pin_configs[10] = {
1758 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1759 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1760 0x508003f3, 0x405003f4,
1763 static unsigned int d945gtp3_pin_configs[10] = {
1764 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1765 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1766 0x02a19120, 0x40000100,
1769 static unsigned int d945gtp5_pin_configs[10] = {
1770 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1771 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1772 0x02a19320, 0x40000100,
1775 static unsigned int intel_mac_v1_pin_configs[10] = {
1776 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1777 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1778 0x400000fc, 0x400000fb,
1781 static unsigned int intel_mac_v2_pin_configs[10] = {
1782 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1783 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1784 0x400000fc, 0x400000fb,
1787 static unsigned int intel_mac_v3_pin_configs[10] = {
1788 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1789 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1790 0x400000fc, 0x400000fb,
1793 static unsigned int intel_mac_v4_pin_configs[10] = {
1794 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1795 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1796 0x400000fc, 0x400000fb,
1799 static unsigned int intel_mac_v5_pin_configs[10] = {
1800 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1801 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1802 0x400000fc, 0x400000fb,
1805 static unsigned int ecs202_pin_configs[10] = {
1806 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1807 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1808 0x9037012e, 0x40e000f2,
1811 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1812 [STAC_D945_REF] = ref922x_pin_configs,
1813 [STAC_D945GTP3] = d945gtp3_pin_configs,
1814 [STAC_D945GTP5] = d945gtp5_pin_configs,
1815 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1816 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1817 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1818 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1819 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1820 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1821 /* for backward compatibility */
1822 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1823 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1824 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1825 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1826 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1827 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1828 [STAC_ECS_202] = ecs202_pin_configs,
1829 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1830 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1831 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1832 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1835 static const char *stac922x_models[STAC_922X_MODELS] = {
1836 [STAC_D945_REF] = "ref",
1837 [STAC_D945GTP5] = "5stack",
1838 [STAC_D945GTP3] = "3stack",
1839 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1840 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1841 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1842 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1843 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1844 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1845 /* for backward compatibility */
1846 [STAC_MACMINI] = "macmini",
1847 [STAC_MACBOOK] = "macbook",
1848 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1849 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1850 [STAC_IMAC_INTEL] = "imac-intel",
1851 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1852 [STAC_ECS_202] = "ecs202",
1853 [STAC_922X_DELL_D81] = "dell-d81",
1854 [STAC_922X_DELL_D82] = "dell-d82",
1855 [STAC_922X_DELL_M81] = "dell-m81",
1856 [STAC_922X_DELL_M82] = "dell-m82",
1859 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1860 /* SigmaTel reference board */
1861 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1862 "DFI LanParty", STAC_D945_REF),
1863 /* Intel 945G based systems */
1864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1865 "Intel D945G", STAC_D945GTP3),
1866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1867 "Intel D945G", STAC_D945GTP3),
1868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1869 "Intel D945G", STAC_D945GTP3),
1870 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1871 "Intel D945G", STAC_D945GTP3),
1872 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1873 "Intel D945G", STAC_D945GTP3),
1874 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1875 "Intel D945G", STAC_D945GTP3),
1876 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1877 "Intel D945G", STAC_D945GTP3),
1878 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1879 "Intel D945G", STAC_D945GTP3),
1880 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1881 "Intel D945G", STAC_D945GTP3),
1882 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1883 "Intel D945G", STAC_D945GTP3),
1884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1885 "Intel D945G", STAC_D945GTP3),
1886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1887 "Intel D945G", STAC_D945GTP3),
1888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1889 "Intel D945G", STAC_D945GTP3),
1890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1891 "Intel D945G", STAC_D945GTP3),
1892 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1893 "Intel D945G", STAC_D945GTP3),
1894 /* Intel D945G 5-stack systems */
1895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1896 "Intel D945G", STAC_D945GTP5),
1897 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1898 "Intel D945G", STAC_D945GTP5),
1899 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1900 "Intel D945G", STAC_D945GTP5),
1901 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1902 "Intel D945G", STAC_D945GTP5),
1903 /* Intel 945P based systems */
1904 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1905 "Intel D945P", STAC_D945GTP3),
1906 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1907 "Intel D945P", STAC_D945GTP3),
1908 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1909 "Intel D945P", STAC_D945GTP3),
1910 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1911 "Intel D945P", STAC_D945GTP3),
1912 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1913 "Intel D945P", STAC_D945GTP3),
1914 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1915 "Intel D945P", STAC_D945GTP5),
1917 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1918 SND_PCI_QUIRK(0x8384, 0x7680,
1919 "Mac", STAC_INTEL_MAC_AUTO),
1921 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1922 "unknown Dell", STAC_922X_DELL_D81),
1923 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1924 "unknown Dell", STAC_922X_DELL_D81),
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1926 "unknown Dell", STAC_922X_DELL_D81),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1928 "unknown Dell", STAC_922X_DELL_D82),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1930 "unknown Dell", STAC_922X_DELL_M81),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1932 "unknown Dell", STAC_922X_DELL_D82),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1934 "unknown Dell", STAC_922X_DELL_D81),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1936 "unknown Dell", STAC_922X_DELL_D81),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1938 "Dell XPS M1210", STAC_922X_DELL_M82),
1939 /* ECS/PC Chips boards */
1940 SND_PCI_QUIRK(0x1019, 0x2144,
1941 "ECS/PC chips", STAC_ECS_202),
1942 SND_PCI_QUIRK(0x1019, 0x2608,
1943 "ECS/PC chips", STAC_ECS_202),
1944 SND_PCI_QUIRK(0x1019, 0x2633,
1945 "ECS/PC chips P17G/1333", STAC_ECS_202),
1946 SND_PCI_QUIRK(0x1019, 0x2811,
1947 "ECS/PC chips", STAC_ECS_202),
1948 SND_PCI_QUIRK(0x1019, 0x2812,
1949 "ECS/PC chips", STAC_ECS_202),
1950 SND_PCI_QUIRK(0x1019, 0x2813,
1951 "ECS/PC chips", STAC_ECS_202),
1952 SND_PCI_QUIRK(0x1019, 0x2814,
1953 "ECS/PC chips", STAC_ECS_202),
1954 SND_PCI_QUIRK(0x1019, 0x2815,
1955 "ECS/PC chips", STAC_ECS_202),
1956 SND_PCI_QUIRK(0x1019, 0x2816,
1957 "ECS/PC chips", STAC_ECS_202),
1958 SND_PCI_QUIRK(0x1019, 0x2817,
1959 "ECS/PC chips", STAC_ECS_202),
1960 SND_PCI_QUIRK(0x1019, 0x2818,
1961 "ECS/PC chips", STAC_ECS_202),
1962 SND_PCI_QUIRK(0x1019, 0x2819,
1963 "ECS/PC chips", STAC_ECS_202),
1964 SND_PCI_QUIRK(0x1019, 0x2820,
1965 "ECS/PC chips", STAC_ECS_202),
1969 static unsigned int ref927x_pin_configs[14] = {
1970 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1971 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1972 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1973 0x01c42190, 0x40000100,
1976 static unsigned int d965_3st_pin_configs[14] = {
1977 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1978 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1979 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1980 0x40000100, 0x40000100
1983 static unsigned int d965_5st_pin_configs[14] = {
1984 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1985 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1986 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1987 0x40000100, 0x40000100
1990 static unsigned int dell_3st_pin_configs[14] = {
1991 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1992 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1993 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1994 0x40c003fc, 0x40000100
1997 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1998 [STAC_D965_REF] = ref927x_pin_configs,
1999 [STAC_D965_3ST] = d965_3st_pin_configs,
2000 [STAC_D965_5ST] = d965_5st_pin_configs,
2001 [STAC_DELL_3ST] = dell_3st_pin_configs,
2002 [STAC_DELL_BIOS] = NULL,
2005 static const char *stac927x_models[STAC_927X_MODELS] = {
2006 [STAC_D965_REF] = "ref",
2007 [STAC_D965_3ST] = "3stack",
2008 [STAC_D965_5ST] = "5stack",
2009 [STAC_DELL_3ST] = "dell-3stack",
2010 [STAC_DELL_BIOS] = "dell-bios",
2013 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2014 /* SigmaTel reference board */
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2016 "DFI LanParty", STAC_D965_REF),
2017 /* Intel 946 based systems */
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2020 /* 965 based 3 stack systems */
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
2037 /* Dell 3 stack systems */
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2042 /* Dell 3 stack systems with verb table in BIOS */
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2046 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2051 /* 965 based 5 stack systems */
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
2055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
2064 static unsigned int ref9205_pin_configs[12] = {
2065 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2066 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2067 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2071 STAC 9205 pin configs for
2078 10280228 (Dell Vostro 1500)
2080 static unsigned int dell_9205_m42_pin_configs[12] = {
2081 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2082 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2083 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2087 STAC 9205 pin configs for
2091 102801FF (Dell Precision M4300)
2096 static unsigned int dell_9205_m43_pin_configs[12] = {
2097 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2098 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2099 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2102 static unsigned int dell_9205_m44_pin_configs[12] = {
2103 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2104 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2105 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2108 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2109 [STAC_9205_REF] = ref9205_pin_configs,
2110 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2111 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2112 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2115 static const char *stac9205_models[STAC_9205_MODELS] = {
2116 [STAC_9205_REF] = "ref",
2117 [STAC_9205_DELL_M42] = "dell-m42",
2118 [STAC_9205_DELL_M43] = "dell-m43",
2119 [STAC_9205_DELL_M44] = "dell-m44",
2122 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2123 /* SigmaTel reference board */
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2125 "DFI LanParty", STAC_9205_REF),
2126 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2127 "unknown Dell", STAC_9205_DELL_M42),
2128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2129 "unknown Dell", STAC_9205_DELL_M42),
2130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2131 "Dell Precision", STAC_9205_DELL_M43),
2132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2133 "Dell Precision", STAC_9205_DELL_M43),
2134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2135 "Dell Precision", STAC_9205_DELL_M43),
2136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2137 "unknown Dell", STAC_9205_DELL_M42),
2138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2139 "unknown Dell", STAC_9205_DELL_M42),
2140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2141 "Dell Precision", STAC_9205_DELL_M43),
2142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2143 "Dell Precision M4300", STAC_9205_DELL_M43),
2144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2145 "unknown Dell", STAC_9205_DELL_M42),
2146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2147 "Dell Precision", STAC_9205_DELL_M43),
2148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2149 "Dell Precision", STAC_9205_DELL_M43),
2150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2151 "Dell Precision", STAC_9205_DELL_M43),
2152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2153 "Dell Inspiron", STAC_9205_DELL_M44),
2154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2155 "Dell Vostro 1500", STAC_9205_DELL_M42),
2159 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
2162 struct sigmatel_spec *spec = codec->spec;
2164 if (! spec->bios_pin_configs) {
2165 spec->bios_pin_configs = kcalloc(spec->num_pins,
2166 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
2167 if (! spec->bios_pin_configs)
2171 for (i = 0; i < spec->num_pins; i++) {
2172 hda_nid_t nid = spec->pin_nids[i];
2173 unsigned int pin_cfg;
2175 pin_cfg = snd_hda_codec_read(codec, nid, 0,
2176 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
2177 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
2179 spec->bios_pin_configs[i] = pin_cfg;
2185 static void stac92xx_set_config_reg(struct hda_codec *codec,
2186 hda_nid_t pin_nid, unsigned int pin_config)
2189 snd_hda_codec_write(codec, pin_nid, 0,
2190 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
2191 pin_config & 0x000000ff);
2192 snd_hda_codec_write(codec, pin_nid, 0,
2193 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
2194 (pin_config & 0x0000ff00) >> 8);
2195 snd_hda_codec_write(codec, pin_nid, 0,
2196 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
2197 (pin_config & 0x00ff0000) >> 16);
2198 snd_hda_codec_write(codec, pin_nid, 0,
2199 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
2201 i = snd_hda_codec_read(codec, pin_nid, 0,
2202 AC_VERB_GET_CONFIG_DEFAULT,
2204 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
2208 static void stac92xx_set_config_regs(struct hda_codec *codec)
2211 struct sigmatel_spec *spec = codec->spec;
2213 if (!spec->pin_configs)
2216 for (i = 0; i < spec->num_pins; i++)
2217 stac92xx_set_config_reg(codec, spec->pin_nids[i],
2218 spec->pin_configs[i]);
2222 * Analog playback callbacks
2224 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2225 struct hda_codec *codec,
2226 struct snd_pcm_substream *substream)
2228 struct sigmatel_spec *spec = codec->spec;
2229 if (spec->stream_delay)
2230 msleep(spec->stream_delay);
2231 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2235 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2236 struct hda_codec *codec,
2237 unsigned int stream_tag,
2238 unsigned int format,
2239 struct snd_pcm_substream *substream)
2241 struct sigmatel_spec *spec = codec->spec;
2242 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2245 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2246 struct hda_codec *codec,
2247 struct snd_pcm_substream *substream)
2249 struct sigmatel_spec *spec = codec->spec;
2250 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2254 * Digital playback callbacks
2256 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2257 struct hda_codec *codec,
2258 struct snd_pcm_substream *substream)
2260 struct sigmatel_spec *spec = codec->spec;
2261 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2264 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2265 struct hda_codec *codec,
2266 struct snd_pcm_substream *substream)
2268 struct sigmatel_spec *spec = codec->spec;
2269 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2272 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2273 struct hda_codec *codec,
2274 unsigned int stream_tag,
2275 unsigned int format,
2276 struct snd_pcm_substream *substream)
2278 struct sigmatel_spec *spec = codec->spec;
2279 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2280 stream_tag, format, substream);
2285 * Analog capture callbacks
2287 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2288 struct hda_codec *codec,
2289 unsigned int stream_tag,
2290 unsigned int format,
2291 struct snd_pcm_substream *substream)
2293 struct sigmatel_spec *spec = codec->spec;
2294 hda_nid_t nid = spec->adc_nids[substream->number];
2296 if (spec->powerdown_adcs) {
2298 snd_hda_codec_write_cache(codec, nid, 0,
2299 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2301 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2305 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2306 struct hda_codec *codec,
2307 struct snd_pcm_substream *substream)
2309 struct sigmatel_spec *spec = codec->spec;
2310 hda_nid_t nid = spec->adc_nids[substream->number];
2312 snd_hda_codec_cleanup_stream(codec, nid);
2313 if (spec->powerdown_adcs)
2314 snd_hda_codec_write_cache(codec, nid, 0,
2315 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2319 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2323 /* NID is set in stac92xx_build_pcms */
2325 .open = stac92xx_dig_playback_pcm_open,
2326 .close = stac92xx_dig_playback_pcm_close,
2327 .prepare = stac92xx_dig_playback_pcm_prepare
2331 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2335 /* NID is set in stac92xx_build_pcms */
2338 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2342 .nid = 0x02, /* NID to query formats and rates */
2344 .open = stac92xx_playback_pcm_open,
2345 .prepare = stac92xx_playback_pcm_prepare,
2346 .cleanup = stac92xx_playback_pcm_cleanup
2350 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2354 .nid = 0x06, /* NID to query formats and rates */
2356 .open = stac92xx_playback_pcm_open,
2357 .prepare = stac92xx_playback_pcm_prepare,
2358 .cleanup = stac92xx_playback_pcm_cleanup
2362 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2365 /* NID + .substreams is set in stac92xx_build_pcms */
2367 .prepare = stac92xx_capture_pcm_prepare,
2368 .cleanup = stac92xx_capture_pcm_cleanup
2372 static int stac92xx_build_pcms(struct hda_codec *codec)
2374 struct sigmatel_spec *spec = codec->spec;
2375 struct hda_pcm *info = spec->pcm_rec;
2377 codec->num_pcms = 1;
2378 codec->pcm_info = info;
2380 info->name = "STAC92xx Analog";
2381 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2382 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2383 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2384 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2386 if (spec->alt_switch) {
2389 info->name = "STAC92xx Analog Alt";
2390 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2393 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2396 info->name = "STAC92xx Digital";
2397 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2398 if (spec->multiout.dig_out_nid) {
2399 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2400 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2402 if (spec->dig_in_nid) {
2403 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2404 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2411 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2413 unsigned int pincap = snd_hda_param_read(codec, nid,
2415 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2416 if (pincap & AC_PINCAP_VREF_100)
2417 return AC_PINCTL_VREF_100;
2418 if (pincap & AC_PINCAP_VREF_80)
2419 return AC_PINCTL_VREF_80;
2420 if (pincap & AC_PINCAP_VREF_50)
2421 return AC_PINCTL_VREF_50;
2422 if (pincap & AC_PINCAP_VREF_GRD)
2423 return AC_PINCTL_VREF_GRD;
2427 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2430 snd_hda_codec_write_cache(codec, nid, 0,
2431 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2434 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2436 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2437 struct snd_ctl_elem_value *ucontrol)
2439 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2440 struct sigmatel_spec *spec = codec->spec;
2442 ucontrol->value.integer.value[0] = spec->hp_switch;
2446 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2447 struct snd_ctl_elem_value *ucontrol)
2449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2450 struct sigmatel_spec *spec = codec->spec;
2452 spec->hp_switch = ucontrol->value.integer.value[0];
2454 /* check to be sure that the ports are upto date with
2457 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2462 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2464 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2466 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2467 struct sigmatel_spec *spec = codec->spec;
2468 int io_idx = kcontrol-> private_value & 0xff;
2470 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2474 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2476 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2477 struct sigmatel_spec *spec = codec->spec;
2478 hda_nid_t nid = kcontrol->private_value >> 8;
2479 int io_idx = kcontrol-> private_value & 0xff;
2480 unsigned short val = !!ucontrol->value.integer.value[0];
2482 spec->io_switch[io_idx] = val;
2485 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2487 unsigned int pinctl = AC_PINCTL_IN_EN;
2488 if (io_idx) /* set VREF for mic */
2489 pinctl |= stac92xx_get_vref(codec, nid);
2490 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2493 /* check the auto-mute again: we need to mute/unmute the speaker
2494 * appropriately according to the pin direction
2496 if (spec->hp_detect)
2497 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2502 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2504 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2505 struct snd_ctl_elem_value *ucontrol)
2507 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2508 struct sigmatel_spec *spec = codec->spec;
2510 ucontrol->value.integer.value[0] = spec->clfe_swap;
2514 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2515 struct snd_ctl_elem_value *ucontrol)
2517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2518 struct sigmatel_spec *spec = codec->spec;
2519 hda_nid_t nid = kcontrol->private_value & 0xff;
2520 unsigned int val = !!ucontrol->value.integer.value[0];
2522 if (spec->clfe_swap == val)
2525 spec->clfe_swap = val;
2527 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2528 spec->clfe_swap ? 0x4 : 0x0);
2533 #define STAC_CODEC_HP_SWITCH(xname) \
2534 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2537 .info = stac92xx_hp_switch_info, \
2538 .get = stac92xx_hp_switch_get, \
2539 .put = stac92xx_hp_switch_put, \
2542 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2543 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2546 .info = stac92xx_io_switch_info, \
2547 .get = stac92xx_io_switch_get, \
2548 .put = stac92xx_io_switch_put, \
2549 .private_value = xpval, \
2552 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2553 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2556 .info = stac92xx_clfe_switch_info, \
2557 .get = stac92xx_clfe_switch_get, \
2558 .put = stac92xx_clfe_switch_put, \
2559 .private_value = xpval, \
2563 STAC_CTL_WIDGET_VOL,
2564 STAC_CTL_WIDGET_MUTE,
2565 STAC_CTL_WIDGET_MONO_MUX,
2566 STAC_CTL_WIDGET_AMP_MUX,
2567 STAC_CTL_WIDGET_AMP_VOL,
2568 STAC_CTL_WIDGET_HP_SWITCH,
2569 STAC_CTL_WIDGET_IO_SWITCH,
2570 STAC_CTL_WIDGET_CLFE_SWITCH
2573 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2574 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2575 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2578 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2579 STAC_CODEC_HP_SWITCH(NULL),
2580 STAC_CODEC_IO_SWITCH(NULL, 0),
2581 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2584 /* add dynamic controls */
2585 static int stac92xx_add_control_idx(struct sigmatel_spec *spec, int type,
2586 int idx, const char *name, unsigned long val)
2588 struct snd_kcontrol_new *knew;
2590 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2591 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2593 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2596 if (spec->kctl_alloc) {
2597 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2598 kfree(spec->kctl_alloc);
2600 spec->kctl_alloc = knew;
2601 spec->num_kctl_alloc = num;
2604 knew = &spec->kctl_alloc[spec->num_kctl_used];
2605 *knew = stac92xx_control_templates[type];
2607 knew->name = kstrdup(name, GFP_KERNEL);
2610 knew->private_value = val;
2611 spec->num_kctl_used++;
2616 /* add dynamic controls */
2617 static int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2618 const char *name, unsigned long val)
2620 return stac92xx_add_control_idx(spec, type, 0, name, val);
2623 /* flag inputs as additional dynamic lineouts */
2624 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2626 struct sigmatel_spec *spec = codec->spec;
2627 unsigned int wcaps, wtype;
2628 int i, num_dacs = 0;
2630 /* use the wcaps cache to count all DACs available for line-outs */
2631 for (i = 0; i < codec->num_nodes; i++) {
2632 wcaps = codec->wcaps[i];
2633 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2635 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2639 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2641 switch (cfg->line_outs) {
2643 /* add line-in as side */
2644 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2645 cfg->line_out_pins[cfg->line_outs] =
2646 cfg->input_pins[AUTO_PIN_LINE];
2647 spec->line_switch = 1;
2652 /* add line-in as clfe and mic as side */
2653 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2654 cfg->line_out_pins[cfg->line_outs] =
2655 cfg->input_pins[AUTO_PIN_LINE];
2656 spec->line_switch = 1;
2659 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2660 cfg->line_out_pins[cfg->line_outs] =
2661 cfg->input_pins[AUTO_PIN_MIC];
2662 spec->mic_switch = 1;
2667 /* add line-in as surr and mic as clfe */
2668 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2669 cfg->line_out_pins[cfg->line_outs] =
2670 cfg->input_pins[AUTO_PIN_LINE];
2671 spec->line_switch = 1;
2674 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2675 cfg->line_out_pins[cfg->line_outs] =
2676 cfg->input_pins[AUTO_PIN_MIC];
2677 spec->mic_switch = 1;
2687 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2691 for (i = 0; i < spec->multiout.num_dacs; i++) {
2692 if (spec->multiout.dac_nids[i] == nid)
2700 * Fill in the dac_nids table from the parsed pin configuration
2701 * This function only works when every pin in line_out_pins[]
2702 * contains atleast one DAC in its connection list. Some 92xx
2703 * codecs are not connected directly to a DAC, such as the 9200
2704 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2706 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2707 struct auto_pin_cfg *cfg)
2709 struct sigmatel_spec *spec = codec->spec;
2710 int i, j, conn_len = 0;
2711 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2712 unsigned int wcaps, wtype;
2714 for (i = 0; i < cfg->line_outs; i++) {
2715 nid = cfg->line_out_pins[i];
2716 conn_len = snd_hda_get_connections(codec, nid, conn,
2717 HDA_MAX_CONNECTIONS);
2718 for (j = 0; j < conn_len; j++) {
2719 wcaps = snd_hda_param_read(codec, conn[j],
2720 AC_PAR_AUDIO_WIDGET_CAP);
2721 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2722 if (wtype != AC_WID_AUD_OUT ||
2723 (wcaps & AC_WCAP_DIGITAL))
2725 /* conn[j] is a DAC routed to this line-out */
2726 if (!is_in_dac_nids(spec, conn[j]))
2730 if (j == conn_len) {
2731 if (spec->multiout.num_dacs > 0) {
2732 /* we have already working output pins,
2733 * so let's drop the broken ones again
2735 cfg->line_outs = spec->multiout.num_dacs;
2738 /* error out, no available DAC found */
2740 "%s: No available DAC for pin 0x%x\n",
2745 spec->multiout.dac_nids[i] = conn[j];
2746 spec->multiout.num_dacs++;
2748 /* select this DAC in the pin's input mux */
2749 snd_hda_codec_write_cache(codec, nid, 0,
2750 AC_VERB_SET_CONNECT_SEL, j);
2755 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2756 spec->multiout.num_dacs,
2757 spec->multiout.dac_nids[0],
2758 spec->multiout.dac_nids[1],
2759 spec->multiout.dac_nids[2],
2760 spec->multiout.dac_nids[3],
2761 spec->multiout.dac_nids[4]);
2765 /* create volume control/switch for the given prefx type */
2766 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2771 sprintf(name, "%s Playback Volume", pfx);
2772 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2773 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2776 sprintf(name, "%s Playback Switch", pfx);
2777 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2778 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2784 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2786 if (!spec->multiout.hp_nid)
2787 spec->multiout.hp_nid = nid;
2788 else if (spec->multiout.num_dacs > 4) {
2789 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2792 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2793 spec->multiout.num_dacs++;
2798 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2800 if (is_in_dac_nids(spec, nid))
2802 if (spec->multiout.hp_nid == nid)
2807 /* add playback controls from the parsed DAC table */
2808 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2809 const struct auto_pin_cfg *cfg)
2811 static const char *chname[4] = {
2812 "Front", "Surround", NULL /*CLFE*/, "Side"
2817 struct sigmatel_spec *spec = codec->spec;
2818 unsigned int wid_caps, pincap;
2821 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2822 if (!spec->multiout.dac_nids[i])
2825 nid = spec->multiout.dac_nids[i];
2829 err = create_controls(spec, "Center", nid, 1);
2832 err = create_controls(spec, "LFE", nid, 2);
2836 wid_caps = get_wcaps(codec, nid);
2838 if (wid_caps & AC_WCAP_LR_SWAP) {
2839 err = stac92xx_add_control(spec,
2840 STAC_CTL_WIDGET_CLFE_SWITCH,
2841 "Swap Center/LFE Playback Switch", nid);
2848 err = create_controls(spec, chname[i], nid, 3);
2854 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2855 cfg->hp_outs && !spec->multiout.hp_nid)
2856 spec->multiout.hp_nid = nid;
2858 if (cfg->hp_outs > 1) {
2859 err = stac92xx_add_control(spec,
2860 STAC_CTL_WIDGET_HP_SWITCH,
2861 "Headphone as Line Out Switch", 0);
2866 if (spec->line_switch) {
2867 nid = cfg->input_pins[AUTO_PIN_LINE];
2868 pincap = snd_hda_param_read(codec, nid,
2870 if (pincap & AC_PINCAP_OUT) {
2871 err = stac92xx_add_control(spec,
2872 STAC_CTL_WIDGET_IO_SWITCH,
2873 "Line In as Output Switch", nid << 8);
2879 if (spec->mic_switch) {
2880 unsigned int def_conf;
2881 unsigned int mic_pin = AUTO_PIN_MIC;
2883 nid = cfg->input_pins[mic_pin];
2884 def_conf = snd_hda_codec_read(codec, nid, 0,
2885 AC_VERB_GET_CONFIG_DEFAULT, 0);
2886 /* some laptops have an internal analog microphone
2887 * which can't be used as a output */
2888 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2889 pincap = snd_hda_param_read(codec, nid,
2891 if (pincap & AC_PINCAP_OUT) {
2892 err = stac92xx_add_control(spec,
2893 STAC_CTL_WIDGET_IO_SWITCH,
2894 "Mic as Output Switch", (nid << 8) | 1);
2895 nid = snd_hda_codec_read(codec, nid, 0,
2896 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2897 if (!check_in_dac_nids(spec, nid))
2898 add_spec_dacs(spec, nid);
2902 } else if (mic_pin == AUTO_PIN_MIC) {
2903 mic_pin = AUTO_PIN_FRONT_MIC;
2911 /* add playback controls for Speaker and HP outputs */
2912 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2913 struct auto_pin_cfg *cfg)
2915 struct sigmatel_spec *spec = codec->spec;
2917 int i, old_num_dacs, err;
2919 old_num_dacs = spec->multiout.num_dacs;
2920 for (i = 0; i < cfg->hp_outs; i++) {
2921 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2922 if (wid_caps & AC_WCAP_UNSOL_CAP)
2923 spec->hp_detect = 1;
2924 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2925 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2926 if (check_in_dac_nids(spec, nid))
2930 add_spec_dacs(spec, nid);
2932 for (i = 0; i < cfg->speaker_outs; i++) {
2933 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2934 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2935 if (check_in_dac_nids(spec, nid))
2939 add_spec_dacs(spec, nid);
2941 for (i = 0; i < cfg->line_outs; i++) {
2942 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2943 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2944 if (check_in_dac_nids(spec, nid))
2948 add_spec_dacs(spec, nid);
2950 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2951 static const char *pfxs[] = {
2952 "Speaker", "External Speaker", "Speaker2",
2954 err = create_controls(spec, pfxs[i - old_num_dacs],
2955 spec->multiout.dac_nids[i], 3);
2959 if (spec->multiout.hp_nid) {
2960 err = create_controls(spec, "Headphone",
2961 spec->multiout.hp_nid, 3);
2969 /* labels for mono mux outputs */
2970 static const char *stac92xx_mono_labels[4] = {
2971 "DAC0", "DAC1", "Mixer", "DAC2"
2974 /* create mono mux for mono out on capable codecs */
2975 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2977 struct sigmatel_spec *spec = codec->spec;
2978 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2980 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2982 num_cons = snd_hda_get_connections(codec,
2985 HDA_MAX_NUM_INPUTS);
2986 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2989 for (i = 0; i < num_cons; i++) {
2990 mono_mux->items[mono_mux->num_items].label =
2991 stac92xx_mono_labels[i];
2992 mono_mux->items[mono_mux->num_items].index = i;
2993 mono_mux->num_items++;
2996 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2997 "Mono Mux", spec->mono_nid);
3000 /* labels for amp mux outputs */
3001 static const char *stac92xx_amp_labels[3] = {
3002 "Front Microphone", "Microphone", "Line In"
3005 /* create amp out controls mux on capable codecs */
3006 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3008 struct sigmatel_spec *spec = codec->spec;
3009 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3012 for (i = 0; i < spec->num_amps; i++) {
3013 amp_mux->items[amp_mux->num_items].label =
3014 stac92xx_amp_labels[i];
3015 amp_mux->items[amp_mux->num_items].index = i;
3016 amp_mux->num_items++;
3019 if (spec->num_amps > 1) {
3020 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3021 "Amp Selector Capture Switch", 0);
3025 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3026 "Amp Capture Volume",
3027 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3031 /* create PC beep volume controls */
3032 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3035 struct sigmatel_spec *spec = codec->spec;
3036 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3039 /* check for mute support for the the amp */
3040 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3041 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3042 "PC Beep Playback Switch",
3043 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3048 /* check to see if there is volume support for the amp */
3049 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3050 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3051 "PC Beep Playback Volume",
3052 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3059 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3061 struct sigmatel_spec *spec = codec->spec;
3062 int wcaps, nid, i, err = 0;
3064 for (i = 0; i < spec->num_muxes; i++) {
3065 nid = spec->mux_nids[i];
3066 wcaps = get_wcaps(codec, nid);
3068 if (wcaps & AC_WCAP_OUT_AMP) {
3069 err = stac92xx_add_control_idx(spec,
3070 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume",
3071 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3079 static const char *stac92xx_spdif_labels[3] = {
3080 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3083 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3085 struct sigmatel_spec *spec = codec->spec;
3086 struct hda_input_mux *spdif_mux = &spec->private_smux;
3087 const char **labels = spec->spdif_labels;
3089 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3091 num_cons = snd_hda_get_connections(codec,
3094 HDA_MAX_NUM_INPUTS);
3099 labels = stac92xx_spdif_labels;
3101 for (i = 0; i < num_cons; i++) {
3102 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3103 spdif_mux->items[spdif_mux->num_items].index = i;
3104 spdif_mux->num_items++;
3110 /* labels for dmic mux inputs */
3111 static const char *stac92xx_dmic_labels[5] = {
3112 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3113 "Digital Mic 3", "Digital Mic 4"
3116 /* create playback/capture controls for input pins on dmic capable codecs */
3117 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3118 const struct auto_pin_cfg *cfg)
3120 struct sigmatel_spec *spec = codec->spec;
3121 struct hda_input_mux *dimux = &spec->private_dimux;
3122 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3126 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3127 dimux->items[dimux->num_items].index = 0;
3130 for (i = 0; i < spec->num_dmics; i++) {
3135 unsigned int def_conf;
3137 def_conf = snd_hda_codec_read(codec,
3140 AC_VERB_GET_CONFIG_DEFAULT,
3142 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3145 nid = spec->dmic_nids[i];
3146 num_cons = snd_hda_get_connections(codec,
3149 HDA_MAX_NUM_INPUTS);
3150 for (j = 0; j < num_cons; j++)
3151 if (con_lst[j] == nid) {
3157 wcaps = get_wcaps(codec, nid) &
3158 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3161 sprintf(name, "%s Capture Volume",
3162 stac92xx_dmic_labels[dimux->num_items]);
3164 err = stac92xx_add_control(spec,
3165 STAC_CTL_WIDGET_VOL,
3167 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3168 (wcaps & AC_WCAP_OUT_AMP) ?
3169 HDA_OUTPUT : HDA_INPUT));
3174 dimux->items[dimux->num_items].label =
3175 stac92xx_dmic_labels[dimux->num_items];
3176 dimux->items[dimux->num_items].index = index;
3183 /* create playback/capture controls for input pins */
3184 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3186 struct sigmatel_spec *spec = codec->spec;
3187 struct hda_input_mux *imux = &spec->private_imux;
3188 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3191 for (i = 0; i < AUTO_PIN_LAST; i++) {
3194 if (!cfg->input_pins[i])
3197 for (j = 0; j < spec->num_muxes; j++) {
3199 num_cons = snd_hda_get_connections(codec,
3202 HDA_MAX_NUM_INPUTS);
3203 for (k = 0; k < num_cons; k++)
3204 if (con_lst[k] == cfg->input_pins[i]) {
3211 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3212 imux->items[imux->num_items].index = index;
3216 if (imux->num_items) {
3218 * Set the current input for the muxes.
3219 * The STAC9221 has two input muxes with identical source
3220 * NID lists. Hopefully this won't get confused.
3222 for (i = 0; i < spec->num_muxes; i++) {
3223 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3224 AC_VERB_SET_CONNECT_SEL,
3225 imux->items[0].index);
3232 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3234 struct sigmatel_spec *spec = codec->spec;
3237 for (i = 0; i < spec->autocfg.line_outs; i++) {
3238 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3239 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3243 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3245 struct sigmatel_spec *spec = codec->spec;
3248 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3250 pin = spec->autocfg.hp_pins[i];
3251 if (pin) /* connect to front */
3252 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3254 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3256 pin = spec->autocfg.speaker_pins[i];
3257 if (pin) /* connect to front */
3258 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3262 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3264 struct sigmatel_spec *spec = codec->spec;
3266 int hp_speaker_swap = 0;
3268 if ((err = snd_hda_parse_pin_def_config(codec,
3270 spec->dmic_nids)) < 0)
3272 if (! spec->autocfg.line_outs)
3273 return 0; /* can't find valid pin config */
3275 /* If we have no real line-out pin and multiple hp-outs, HPs should
3276 * be set up as multi-channel outputs.
3278 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3279 spec->autocfg.hp_outs > 1) {
3280 /* Copy hp_outs to line_outs, backup line_outs in
3281 * speaker_outs so that the following routines can handle
3282 * HP pins as primary outputs.
3284 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3285 sizeof(spec->autocfg.line_out_pins));
3286 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3287 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3288 sizeof(spec->autocfg.hp_pins));
3289 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3290 hp_speaker_swap = 1;
3292 if (spec->autocfg.mono_out_pin) {
3293 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3294 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3295 u32 caps = query_amp_caps(codec,
3296 spec->autocfg.mono_out_pin, dir);
3297 hda_nid_t conn_list[1];
3299 /* get the mixer node and then the mono mux if it exists */
3300 if (snd_hda_get_connections(codec,
3301 spec->autocfg.mono_out_pin, conn_list, 1) &&
3302 snd_hda_get_connections(codec, conn_list[0],
3305 int wcaps = get_wcaps(codec, conn_list[0]);
3306 int wid_type = (wcaps & AC_WCAP_TYPE)
3307 >> AC_WCAP_TYPE_SHIFT;
3308 /* LR swap check, some stac925x have a mux that
3309 * changes the DACs output path instead of the
3312 if (wid_type == AC_WID_AUD_SEL &&
3313 !(wcaps & AC_WCAP_LR_SWAP))
3314 spec->mono_nid = conn_list[0];
3317 hda_nid_t nid = spec->autocfg.mono_out_pin;
3319 /* most mono outs have a least a mute/unmute switch */
3320 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3321 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3322 "Mono Playback Switch",
3323 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3326 /* check for volume support for the amp */
3327 if ((caps & AC_AMPCAP_NUM_STEPS)
3328 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3329 err = stac92xx_add_control(spec,
3330 STAC_CTL_WIDGET_VOL,
3331 "Mono Playback Volume",
3332 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3338 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3342 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
3344 if (spec->multiout.num_dacs == 0)
3345 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
3348 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
3353 /* setup analog beep controls */
3354 if (spec->anabeep_nid > 0) {
3355 err = stac92xx_auto_create_beep_ctls(codec,
3361 /* setup digital beep controls and input device */
3362 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3363 if (spec->digbeep_nid > 0) {
3364 hda_nid_t nid = spec->digbeep_nid;
3366 err = stac92xx_auto_create_beep_ctls(codec, nid);
3369 err = snd_hda_attach_beep_device(codec, nid);
3375 if (hp_speaker_swap == 1) {
3376 /* Restore the hp_outs and line_outs */
3377 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3378 sizeof(spec->autocfg.line_out_pins));
3379 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3380 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
3381 sizeof(spec->autocfg.speaker_pins));
3382 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
3383 memset(spec->autocfg.speaker_pins, 0,
3384 sizeof(spec->autocfg.speaker_pins));
3385 spec->autocfg.speaker_outs = 0;
3388 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3393 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3398 if (spec->mono_nid > 0) {
3399 err = stac92xx_auto_create_mono_output_ctls(codec);
3403 if (spec->num_amps > 0) {
3404 err = stac92xx_auto_create_amp_output_ctls(codec);
3408 if (spec->num_dmics > 0 && !spec->dinput_mux)
3409 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3410 &spec->autocfg)) < 0)
3412 if (spec->num_muxes > 0) {
3413 err = stac92xx_auto_create_mux_input_ctls(codec);
3417 if (spec->num_smuxes > 0) {
3418 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3423 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3424 if (spec->multiout.max_channels > 2)
3425 spec->surr_switch = 1;
3427 if (spec->autocfg.dig_out_pin)
3428 spec->multiout.dig_out_nid = dig_out;
3429 if (dig_in && spec->autocfg.dig_in_pin)
3430 spec->dig_in_nid = dig_in;
3432 if (spec->kctl_alloc)
3433 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3435 spec->input_mux = &spec->private_imux;
3436 spec->dinput_mux = &spec->private_dimux;
3437 spec->sinput_mux = &spec->private_smux;
3438 spec->mono_mux = &spec->private_mono_mux;
3439 spec->amp_mux = &spec->private_amp_mux;
3443 /* add playback controls for HP output */
3444 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3445 struct auto_pin_cfg *cfg)
3447 struct sigmatel_spec *spec = codec->spec;
3448 hda_nid_t pin = cfg->hp_pins[0];
3449 unsigned int wid_caps;
3454 wid_caps = get_wcaps(codec, pin);
3455 if (wid_caps & AC_WCAP_UNSOL_CAP)
3456 spec->hp_detect = 1;
3461 /* add playback controls for LFE output */
3462 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3463 struct auto_pin_cfg *cfg)
3465 struct sigmatel_spec *spec = codec->spec;
3467 hda_nid_t lfe_pin = 0x0;
3471 * search speaker outs and line outs for a mono speaker pin
3472 * with an amp. If one is found, add LFE controls
3475 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3476 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3477 unsigned int wcaps = get_wcaps(codec, pin);
3478 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3479 if (wcaps == AC_WCAP_OUT_AMP)
3480 /* found a mono speaker with an amp, must be lfe */
3484 /* if speaker_outs is 0, then speakers may be in line_outs */
3485 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3486 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3487 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3488 unsigned int defcfg;
3489 defcfg = snd_hda_codec_read(codec, pin, 0,
3490 AC_VERB_GET_CONFIG_DEFAULT,
3492 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3493 unsigned int wcaps = get_wcaps(codec, pin);
3494 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3495 if (wcaps == AC_WCAP_OUT_AMP)
3496 /* found a mono speaker with an amp,
3504 err = create_controls(spec, "LFE", lfe_pin, 1);
3512 static int stac9200_parse_auto_config(struct hda_codec *codec)
3514 struct sigmatel_spec *spec = codec->spec;
3517 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3520 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3523 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3526 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3529 if (spec->autocfg.dig_out_pin)
3530 spec->multiout.dig_out_nid = 0x05;
3531 if (spec->autocfg.dig_in_pin)
3532 spec->dig_in_nid = 0x04;
3534 if (spec->kctl_alloc)
3535 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3537 spec->input_mux = &spec->private_imux;
3538 spec->dinput_mux = &spec->private_dimux;
3544 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3545 * funky external mute control using GPIO pins.
3548 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3549 unsigned int dir_mask, unsigned int data)
3551 unsigned int gpiostate, gpiomask, gpiodir;
3553 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3554 AC_VERB_GET_GPIO_DATA, 0);
3555 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3557 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3558 AC_VERB_GET_GPIO_MASK, 0);
3561 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3562 AC_VERB_GET_GPIO_DIRECTION, 0);
3563 gpiodir |= dir_mask;
3565 /* Configure GPIOx as CMOS */
3566 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3568 snd_hda_codec_write(codec, codec->afg, 0,
3569 AC_VERB_SET_GPIO_MASK, gpiomask);
3570 snd_hda_codec_read(codec, codec->afg, 0,
3571 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3575 snd_hda_codec_read(codec, codec->afg, 0,
3576 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3579 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3582 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3583 snd_hda_codec_write_cache(codec, nid, 0,
3584 AC_VERB_SET_UNSOLICITED_ENABLE,
3585 (AC_USRSP_EN | event));
3588 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3591 for (i = 0; i < cfg->hp_outs; i++)
3592 if (cfg->hp_pins[i] == nid)
3593 return 1; /* nid is a HP-Out */
3595 return 0; /* nid is not a HP-Out */
3598 static void stac92xx_power_down(struct hda_codec *codec)
3600 struct sigmatel_spec *spec = codec->spec;
3602 /* power down inactive DACs */
3604 for (dac = spec->dac_list; *dac; dac++)
3605 if (!is_in_dac_nids(spec, *dac) &&
3606 spec->multiout.hp_nid != *dac)
3607 snd_hda_codec_write_cache(codec, *dac, 0,
3608 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3611 static int stac92xx_init(struct hda_codec *codec)
3613 struct sigmatel_spec *spec = codec->spec;
3614 struct auto_pin_cfg *cfg = &spec->autocfg;
3617 snd_hda_sequence_write(codec, spec->init);
3619 /* power down adcs initially */
3620 if (spec->powerdown_adcs)
3621 for (i = 0; i < spec->num_adcs; i++)
3622 snd_hda_codec_write_cache(codec,
3623 spec->adc_nids[i], 0,
3624 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3626 if (spec->hp_detect) {
3627 /* Enable unsolicited responses on the HP widget */
3628 for (i = 0; i < cfg->hp_outs; i++)
3629 enable_pin_detect(codec, cfg->hp_pins[i],
3631 /* force to enable the first line-out; the others are set up
3634 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3636 stac92xx_auto_init_hp_out(codec);
3637 /* fake event to set up pins */
3638 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3640 stac92xx_auto_init_multi_out(codec);
3641 stac92xx_auto_init_hp_out(codec);
3643 for (i = 0; i < AUTO_PIN_LAST; i++) {
3644 hda_nid_t nid = cfg->input_pins[i];
3646 unsigned int pinctl = snd_hda_codec_read(codec, nid,
3647 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3648 /* if PINCTL already set then skip */
3649 if (pinctl & AC_PINCAP_IN)
3651 pinctl = AC_PINCTL_IN_EN;
3652 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3653 pinctl |= stac92xx_get_vref(codec, nid);
3654 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3657 for (i = 0; i < spec->num_dmics; i++)
3658 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3660 for (i = 0; i < spec->num_pwrs; i++) {
3661 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3662 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3663 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3664 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3665 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3666 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3667 def_conf = get_defcfg_connect(def_conf);
3668 /* outputs are only ports capable of power management
3669 * any attempts on powering down a input port cause the
3670 * referenced VREF to act quirky.
3672 if (pinctl & AC_PINCTL_IN_EN)
3674 /* skip any ports that don't have jacks since presence
3675 * detection is useless */
3676 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3678 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3679 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3682 stac92xx_power_down(codec);
3683 if (cfg->dig_out_pin)
3684 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3686 if (cfg->dig_in_pin)
3687 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3690 stac_gpio_set(codec, spec->gpio_mask,
3691 spec->gpio_dir, spec->gpio_data);
3696 static void stac92xx_free(struct hda_codec *codec)
3698 struct sigmatel_spec *spec = codec->spec;
3704 if (spec->kctl_alloc) {
3705 for (i = 0; i < spec->num_kctl_used; i++)
3706 kfree(spec->kctl_alloc[i].name);
3707 kfree(spec->kctl_alloc);
3710 if (spec->bios_pin_configs)
3711 kfree(spec->bios_pin_configs);
3714 snd_hda_detach_beep_device(codec);
3717 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3720 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3721 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3723 if (pin_ctl & AC_PINCTL_IN_EN) {
3725 * we need to check the current set-up direction of
3726 * shared input pins since they can be switched via
3727 * "xxx as Output" mixer switch
3729 struct sigmatel_spec *spec = codec->spec;
3730 struct auto_pin_cfg *cfg = &spec->autocfg;
3731 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3732 spec->line_switch) ||
3733 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3738 /* if setting pin direction bits, clear the current
3739 direction bits first */
3740 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3741 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3743 snd_hda_codec_write_cache(codec, nid, 0,
3744 AC_VERB_SET_PIN_WIDGET_CONTROL,
3748 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3751 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3752 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3753 snd_hda_codec_write_cache(codec, nid, 0,
3754 AC_VERB_SET_PIN_WIDGET_CONTROL,
3758 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3762 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3764 unsigned int pinctl;
3765 pinctl = snd_hda_codec_read(codec, nid, 0,
3766 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3767 if (pinctl & AC_PINCTL_IN_EN)
3768 return 0; /* mic- or line-input */
3770 return 1; /* HP-output */
3775 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3777 struct sigmatel_spec *spec = codec->spec;
3778 struct auto_pin_cfg *cfg = &spec->autocfg;
3779 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3783 if (spec->gpio_mute)
3784 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3785 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3787 for (i = 0; i < cfg->hp_outs; i++) {
3790 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3792 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3796 /* disable lineouts, enable hp */
3797 if (spec->hp_switch)
3798 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3799 for (i = 0; i < cfg->line_outs; i++)
3800 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3802 for (i = 0; i < cfg->speaker_outs; i++)
3803 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3805 if (spec->eapd_mask)
3806 stac_gpio_set(codec, spec->gpio_mask,
3807 spec->gpio_dir, spec->gpio_data &
3810 /* enable lineouts, disable hp */
3811 if (spec->hp_switch)
3812 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3813 for (i = 0; i < cfg->line_outs; i++)
3814 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3816 for (i = 0; i < cfg->speaker_outs; i++)
3817 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3819 if (spec->eapd_mask)
3820 stac_gpio_set(codec, spec->gpio_mask,
3821 spec->gpio_dir, spec->gpio_data |
3824 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3825 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3828 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3830 struct sigmatel_spec *spec = codec->spec;
3831 hda_nid_t nid = spec->pwr_nids[idx];
3833 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3835 presence = get_hp_pin_presence(codec, nid);
3837 /* several codecs have two power down bits */
3838 if (spec->pwr_mapping)
3839 idx = spec->pwr_mapping[idx];
3848 /* power down unused output ports */
3849 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3852 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3854 struct sigmatel_spec *spec = codec->spec;
3855 int idx = res >> 26 & 0x0f;
3857 switch ((res >> 26) & 0x30) {
3859 stac92xx_hp_detect(codec, res);
3861 case STAC_PWR_EVENT:
3862 if (spec->num_pwrs > 0)
3863 stac92xx_pin_sense(codec, idx);
3867 #ifdef SND_HDA_NEEDS_RESUME
3868 static int stac92xx_resume(struct hda_codec *codec)
3870 struct sigmatel_spec *spec = codec->spec;
3872 stac92xx_set_config_regs(codec);
3873 snd_hda_sequence_write(codec, spec->init);
3874 stac_gpio_set(codec, spec->gpio_mask,
3875 spec->gpio_dir, spec->gpio_data);
3876 snd_hda_codec_resume_amp(codec);
3877 snd_hda_codec_resume_cache(codec);
3878 /* power down inactive DACs */
3880 stac92xx_power_down(codec);
3881 /* invoke unsolicited event to reset the HP state */
3882 if (spec->hp_detect)
3883 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3888 static struct hda_codec_ops stac92xx_patch_ops = {
3889 .build_controls = stac92xx_build_controls,
3890 .build_pcms = stac92xx_build_pcms,
3891 .init = stac92xx_init,
3892 .free = stac92xx_free,
3893 .unsol_event = stac92xx_unsol_event,
3894 #ifdef SND_HDA_NEEDS_RESUME
3895 .resume = stac92xx_resume,
3899 static int patch_stac9200(struct hda_codec *codec)
3901 struct sigmatel_spec *spec;
3904 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3909 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3910 spec->pin_nids = stac9200_pin_nids;
3911 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3914 if (spec->board_config < 0) {
3915 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3916 err = stac92xx_save_bios_config_regs(codec);
3918 stac92xx_free(codec);
3921 spec->pin_configs = spec->bios_pin_configs;
3923 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3924 stac92xx_set_config_regs(codec);
3927 spec->multiout.max_channels = 2;
3928 spec->multiout.num_dacs = 1;
3929 spec->multiout.dac_nids = stac9200_dac_nids;
3930 spec->adc_nids = stac9200_adc_nids;
3931 spec->mux_nids = stac9200_mux_nids;
3932 spec->num_muxes = 1;
3933 spec->num_dmics = 0;
3937 if (spec->board_config == STAC_9200_GATEWAY ||
3938 spec->board_config == STAC_9200_OQO)
3939 spec->init = stac9200_eapd_init;
3941 spec->init = stac9200_core_init;
3942 spec->mixer = stac9200_mixer;
3944 if (spec->board_config == STAC_9200_PANASONIC) {
3945 spec->gpio_mask = spec->gpio_dir = 0x09;
3946 spec->gpio_data = 0x00;
3949 err = stac9200_parse_auto_config(codec);
3951 stac92xx_free(codec);
3955 codec->patch_ops = stac92xx_patch_ops;
3960 static int patch_stac925x(struct hda_codec *codec)
3962 struct sigmatel_spec *spec;
3965 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3970 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3971 spec->pin_nids = stac925x_pin_nids;
3972 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3976 if (spec->board_config < 0) {
3977 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3978 "using BIOS defaults\n");
3979 err = stac92xx_save_bios_config_regs(codec);
3981 stac92xx_free(codec);
3984 spec->pin_configs = spec->bios_pin_configs;
3985 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3986 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3987 stac92xx_set_config_regs(codec);
3990 spec->multiout.max_channels = 2;
3991 spec->multiout.num_dacs = 1;
3992 spec->multiout.dac_nids = stac925x_dac_nids;
3993 spec->adc_nids = stac925x_adc_nids;
3994 spec->mux_nids = stac925x_mux_nids;
3995 spec->num_muxes = 1;
3998 switch (codec->vendor_id) {
3999 case 0x83847632: /* STAC9202 */
4000 case 0x83847633: /* STAC9202D */
4001 case 0x83847636: /* STAC9251 */
4002 case 0x83847637: /* STAC9251D */
4003 spec->num_dmics = STAC925X_NUM_DMICS;
4004 spec->dmic_nids = stac925x_dmic_nids;
4005 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4006 spec->dmux_nids = stac925x_dmux_nids;
4009 spec->num_dmics = 0;
4013 spec->init = stac925x_core_init;
4014 spec->mixer = stac925x_mixer;
4016 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4018 if (spec->board_config < 0) {
4019 printk(KERN_WARNING "hda_codec: No auto-config is "
4020 "available, default to model=ref\n");
4021 spec->board_config = STAC_925x_REF;
4027 stac92xx_free(codec);
4031 codec->patch_ops = stac92xx_patch_ops;
4036 static struct hda_input_mux stac92hd73xx_dmux = {
4039 { "Analog Inputs", 0x0b },
4040 { "Digital Mic 1", 0x09 },
4041 { "Digital Mic 2", 0x0a },
4046 static int patch_stac92hd73xx(struct hda_codec *codec)
4048 struct sigmatel_spec *spec;
4049 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
4052 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4057 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
4058 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
4059 spec->pin_nids = stac92hd73xx_pin_nids;
4060 spec->board_config = snd_hda_check_board_config(codec,
4061 STAC_92HD73XX_MODELS,
4062 stac92hd73xx_models,
4063 stac92hd73xx_cfg_tbl);
4065 if (spec->board_config < 0) {
4066 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4067 " STAC92HD73XX, using BIOS defaults\n");
4068 err = stac92xx_save_bios_config_regs(codec);
4070 stac92xx_free(codec);
4073 spec->pin_configs = spec->bios_pin_configs;
4075 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
4076 stac92xx_set_config_regs(codec);
4079 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
4080 conn, STAC92HD73_DAC_COUNT + 2) - 1;
4082 if (spec->multiout.num_dacs < 0) {
4083 printk(KERN_WARNING "hda_codec: Could not determine "
4084 "number of channels defaulting to DAC count\n");
4085 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
4088 switch (spec->multiout.num_dacs) {
4089 case 0x3: /* 6 Channel */
4090 spec->mixer = stac92hd73xx_6ch_mixer;
4091 spec->init = stac92hd73xx_6ch_core_init;
4093 case 0x4: /* 8 Channel */
4094 spec->mixer = stac92hd73xx_8ch_mixer;
4095 spec->init = stac92hd73xx_8ch_core_init;
4097 case 0x5: /* 10 Channel */
4098 spec->mixer = stac92hd73xx_10ch_mixer;
4099 spec->init = stac92hd73xx_10ch_core_init;
4102 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
4103 spec->aloopback_mask = 0x01;
4104 spec->aloopback_shift = 8;
4106 spec->digbeep_nid = 0x1c;
4107 spec->mux_nids = stac92hd73xx_mux_nids;
4108 spec->adc_nids = stac92hd73xx_adc_nids;
4109 spec->dmic_nids = stac92hd73xx_dmic_nids;
4110 spec->dmux_nids = stac92hd73xx_dmux_nids;
4111 spec->smux_nids = stac92hd73xx_smux_nids;
4112 spec->amp_nids = stac92hd73xx_amp_nids;
4113 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4115 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4116 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4117 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4118 memcpy(&spec->private_dimux, &stac92hd73xx_dmux,
4119 sizeof(stac92hd73xx_dmux));
4121 switch (spec->board_config) {
4123 spec->init = dell_eq_core_init;
4124 spec->num_smuxes = 0;
4125 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4126 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4128 switch (codec->subsystem_id) {
4129 case 0x1028025e: /* Analog Mics */
4131 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4132 spec->num_dmics = 0;
4133 spec->private_dimux.num_items = 1;
4135 case 0x10280271: /* Digital Mics */
4137 spec->init = dell_m6_core_init;
4141 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4142 spec->num_dmics = 1;
4143 spec->private_dimux.num_items = 2;
4145 case 0x10280256: /* Both */
4147 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
4148 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
4149 spec->num_dmics = 1;
4150 spec->private_dimux.num_items = 2;
4155 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
4156 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
4158 if (spec->board_config > STAC_92HD73XX_REF) {
4159 /* GPIO0 High = Enable EAPD */
4160 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4161 spec->gpio_data = 0x01;
4163 spec->dinput_mux = &spec->private_dimux;
4165 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
4166 spec->pwr_nids = stac92hd73xx_pwr_nids;
4168 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
4171 if (spec->board_config < 0) {
4172 printk(KERN_WARNING "hda_codec: No auto-config is "
4173 "available, default to model=ref\n");
4174 spec->board_config = STAC_92HD73XX_REF;
4181 stac92xx_free(codec);
4185 codec->patch_ops = stac92xx_patch_ops;
4190 static struct hda_input_mux stac92hd83xxx_dmux = {
4193 { "Analog Inputs", 0x03 },
4194 { "Digital Mic 1", 0x04 },
4195 { "Digital Mic 2", 0x05 },
4199 static int patch_stac92hd83xxx(struct hda_codec *codec)
4201 struct sigmatel_spec *spec;
4204 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4209 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
4210 spec->mono_nid = 0x19;
4211 spec->digbeep_nid = 0x21;
4212 spec->dmic_nids = stac92hd83xxx_dmic_nids;
4213 spec->dmux_nids = stac92hd83xxx_dmux_nids;
4214 spec->adc_nids = stac92hd83xxx_adc_nids;
4215 spec->pwr_nids = stac92hd83xxx_pwr_nids;
4216 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
4217 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
4218 spec->multiout.dac_nids = stac92hd83xxx_dac_nids;
4220 spec->init = stac92hd83xxx_core_init;
4221 switch (codec->vendor_id) {
4223 spec->multiout.num_dacs = STAC92HD81_DAC_COUNT;
4227 spec->init++; /* switch to config #2 */
4228 spec->multiout.num_dacs = STAC92HD83_DAC_COUNT;
4231 spec->mixer = stac92hd83xxx_mixer;
4232 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
4233 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
4234 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
4235 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
4236 spec->dinput_mux = &stac92hd83xxx_dmux;
4237 spec->pin_nids = stac92hd83xxx_pin_nids;
4238 spec->board_config = snd_hda_check_board_config(codec,
4239 STAC_92HD83XXX_MODELS,
4240 stac92hd83xxx_models,
4241 stac92hd83xxx_cfg_tbl);
4243 if (spec->board_config < 0) {
4244 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4245 " STAC92HD83XXX, using BIOS defaults\n");
4246 err = stac92xx_save_bios_config_regs(codec);
4248 stac92xx_free(codec);
4251 spec->pin_configs = spec->bios_pin_configs;
4253 spec->pin_configs = stac92hd83xxx_brd_tbl[spec->board_config];
4254 stac92xx_set_config_regs(codec);
4257 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
4259 if (spec->board_config < 0) {
4260 printk(KERN_WARNING "hda_codec: No auto-config is "
4261 "available, default to model=ref\n");
4262 spec->board_config = STAC_92HD83XXX_REF;
4269 stac92xx_free(codec);
4273 codec->patch_ops = stac92xx_patch_ops;
4278 #ifdef SND_HDA_NEEDS_RESUME
4279 static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr)
4281 struct sigmatel_spec *spec = codec->spec;
4283 snd_hda_codec_write_cache(codec, codec->afg, 0,
4284 AC_VERB_SET_POWER_STATE, pwr);
4287 for (i = 0; i < spec->num_adcs; i++) {
4288 snd_hda_codec_write_cache(codec,
4289 spec->adc_nids[i], 0,
4290 AC_VERB_SET_POWER_STATE, pwr);
4294 static int stac92hd71xx_resume(struct hda_codec *codec)
4296 stac92hd71xx_set_power_state(codec, AC_PWRST_D0);
4297 return stac92xx_resume(codec);
4300 static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state)
4302 stac92hd71xx_set_power_state(codec, AC_PWRST_D3);
4308 static struct hda_codec_ops stac92hd71bxx_patch_ops = {
4309 .build_controls = stac92xx_build_controls,
4310 .build_pcms = stac92xx_build_pcms,
4311 .init = stac92xx_init,
4312 .free = stac92xx_free,
4313 .unsol_event = stac92xx_unsol_event,
4314 #ifdef SND_HDA_NEEDS_RESUME
4315 .resume = stac92hd71xx_resume,
4316 .suspend = stac92hd71xx_suspend,
4320 static int patch_stac92hd71bxx(struct hda_codec *codec)
4322 struct sigmatel_spec *spec;
4325 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4330 codec->patch_ops = stac92xx_patch_ops;
4331 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
4332 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
4333 spec->pin_nids = stac92hd71bxx_pin_nids;
4334 spec->board_config = snd_hda_check_board_config(codec,
4335 STAC_92HD71BXX_MODELS,
4336 stac92hd71bxx_models,
4337 stac92hd71bxx_cfg_tbl);
4339 if (spec->board_config < 0) {
4340 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4341 " STAC92HD71BXX, using BIOS defaults\n");
4342 err = stac92xx_save_bios_config_regs(codec);
4344 stac92xx_free(codec);
4347 spec->pin_configs = spec->bios_pin_configs;
4349 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
4350 stac92xx_set_config_regs(codec);
4353 switch (codec->vendor_id) {
4354 case 0x111d76b6: /* 4 Port without Analog Mixer */
4356 case 0x111d76b4: /* 6 Port without Analog Mixer */
4358 spec->mixer = stac92hd71bxx_mixer;
4359 spec->init = stac92hd71bxx_core_init;
4360 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4362 case 0x111d7608: /* 5 Port with Analog Mixer */
4363 if ((codec->revision_id & 0xf) == 0 ||
4364 (codec->revision_id & 0xf) == 1) {
4365 #ifdef SND_HDA_NEEDS_RESUME
4366 codec->patch_ops = stac92hd71bxx_patch_ops;
4368 spec->stream_delay = 40; /* 40 milliseconds */
4371 /* no output amps */
4373 spec->mixer = stac92hd71bxx_analog_mixer;
4376 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
4377 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
4379 case 0x111d7603: /* 6 Port with Analog Mixer */
4380 if ((codec->revision_id & 0xf) == 1) {
4381 #ifdef SND_HDA_NEEDS_RESUME
4382 codec->patch_ops = stac92hd71bxx_patch_ops;
4384 spec->stream_delay = 40; /* 40 milliseconds */
4387 /* no output amps */
4391 spec->mixer = stac92hd71bxx_analog_mixer;
4392 spec->init = stac92hd71bxx_analog_core_init;
4393 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
4396 spec->aloopback_mask = 0x20;
4397 spec->aloopback_shift = 0;
4399 if (spec->board_config > STAC_92HD71BXX_REF) {
4401 spec->gpio_mask = 0x01;
4402 spec->gpio_dir = 0x01;
4403 spec->gpio_data = 0x01;
4406 spec->powerdown_adcs = 1;
4407 spec->digbeep_nid = 0x26;
4408 spec->mux_nids = stac92hd71bxx_mux_nids;
4409 spec->adc_nids = stac92hd71bxx_adc_nids;
4410 spec->dmic_nids = stac92hd71bxx_dmic_nids;
4411 spec->dmux_nids = stac92hd71bxx_dmux_nids;
4412 spec->smux_nids = stac92hd71bxx_smux_nids;
4413 spec->pwr_nids = stac92hd71bxx_pwr_nids;
4415 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
4416 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
4418 switch (spec->board_config) {
4420 spec->num_dmics = 0;
4421 spec->num_smuxes = 0;
4422 spec->num_dmuxes = 0;
4424 /* enable internal microphone */
4425 stac92xx_set_config_reg(codec, 0x0e, 0x01813040);
4426 stac92xx_auto_set_pinctl(codec, 0x0e,
4427 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
4430 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
4431 spec->num_smuxes = ARRAY_SIZE(stac92hd71bxx_smux_nids);
4432 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
4435 spec->multiout.num_dacs = 1;
4436 spec->multiout.hp_nid = 0x11;
4437 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
4439 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
4441 if (spec->board_config < 0) {
4442 printk(KERN_WARNING "hda_codec: No auto-config is "
4443 "available, default to model=ref\n");
4444 spec->board_config = STAC_92HD71BXX_REF;
4451 stac92xx_free(codec);
4458 static int patch_stac922x(struct hda_codec *codec)
4460 struct sigmatel_spec *spec;
4463 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4468 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
4469 spec->pin_nids = stac922x_pin_nids;
4470 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
4473 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
4474 spec->gpio_mask = spec->gpio_dir = 0x03;
4475 spec->gpio_data = 0x03;
4476 /* Intel Macs have all same PCI SSID, so we need to check
4477 * codec SSID to distinguish the exact models
4479 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
4480 switch (codec->subsystem_id) {
4483 spec->board_config = STAC_INTEL_MAC_V1;
4487 spec->board_config = STAC_INTEL_MAC_V2;
4495 spec->board_config = STAC_INTEL_MAC_V3;
4499 spec->board_config = STAC_INTEL_MAC_V4;
4503 spec->board_config = STAC_INTEL_MAC_V5;
4506 spec->board_config = STAC_INTEL_MAC_V3;
4512 if (spec->board_config < 0) {
4513 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
4514 "using BIOS defaults\n");
4515 err = stac92xx_save_bios_config_regs(codec);
4517 stac92xx_free(codec);
4520 spec->pin_configs = spec->bios_pin_configs;
4521 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
4522 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
4523 stac92xx_set_config_regs(codec);
4526 spec->adc_nids = stac922x_adc_nids;
4527 spec->mux_nids = stac922x_mux_nids;
4528 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
4529 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
4530 spec->num_dmics = 0;
4533 spec->init = stac922x_core_init;
4534 spec->mixer = stac922x_mixer;
4536 spec->multiout.dac_nids = spec->dac_nids;
4538 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
4540 if (spec->board_config < 0) {
4541 printk(KERN_WARNING "hda_codec: No auto-config is "
4542 "available, default to model=ref\n");
4543 spec->board_config = STAC_D945_REF;
4549 stac92xx_free(codec);
4553 codec->patch_ops = stac92xx_patch_ops;
4555 /* Fix Mux capture level; max to 2 */
4556 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
4557 (0 << AC_AMPCAP_OFFSET_SHIFT) |
4558 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
4559 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
4560 (0 << AC_AMPCAP_MUTE_SHIFT));
4565 static int patch_stac927x(struct hda_codec *codec)
4567 struct sigmatel_spec *spec;
4570 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4575 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
4576 spec->pin_nids = stac927x_pin_nids;
4577 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
4581 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
4582 if (spec->board_config < 0)
4583 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
4584 "STAC927x, using BIOS defaults\n");
4585 err = stac92xx_save_bios_config_regs(codec);
4587 stac92xx_free(codec);
4590 spec->pin_configs = spec->bios_pin_configs;
4592 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
4593 stac92xx_set_config_regs(codec);
4596 spec->digbeep_nid = 0x23;
4597 spec->adc_nids = stac927x_adc_nids;
4598 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
4599 spec->mux_nids = stac927x_mux_nids;
4600 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
4601 spec->smux_nids = stac927x_smux_nids;
4602 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
4603 spec->spdif_labels = stac927x_spdif_labels;
4604 spec->dac_list = stac927x_dac_nids;
4605 spec->multiout.dac_nids = spec->dac_nids;
4607 switch (spec->board_config) {
4610 /* GPIO0 High = Enable EAPD */
4611 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
4612 spec->gpio_data = 0x01;
4613 spec->num_dmics = 0;
4615 spec->init = d965_core_init;
4616 spec->mixer = stac927x_mixer;
4618 case STAC_DELL_BIOS:
4619 switch (codec->subsystem_id) {
4622 /* correct the device field to SPDIF out */
4623 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
4626 /* configure the analog microphone on some laptops */
4627 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
4628 /* correct the front output jack as a hp out */
4629 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
4630 /* correct the front input jack as a mic */
4631 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
4634 /* GPIO2 High = Enable EAPD */
4635 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
4636 spec->gpio_data = 0x04;
4637 spec->dmic_nids = stac927x_dmic_nids;
4638 spec->num_dmics = STAC927X_NUM_DMICS;
4640 spec->init = d965_core_init;
4641 spec->mixer = stac927x_mixer;
4642 spec->dmux_nids = stac927x_dmux_nids;
4643 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
4646 if (spec->board_config > STAC_D965_REF) {
4647 /* GPIO0 High = Enable EAPD */
4648 spec->eapd_mask = spec->gpio_mask = 0x01;
4649 spec->gpio_dir = spec->gpio_data = 0x01;
4651 spec->num_dmics = 0;
4653 spec->init = stac927x_core_init;
4654 spec->mixer = stac927x_mixer;
4658 spec->aloopback_mask = 0x40;
4659 spec->aloopback_shift = 0;
4661 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
4663 if (spec->board_config < 0) {
4664 printk(KERN_WARNING "hda_codec: No auto-config is "
4665 "available, default to model=ref\n");
4666 spec->board_config = STAC_D965_REF;
4672 stac92xx_free(codec);
4676 codec->patch_ops = stac92xx_patch_ops;
4680 * The STAC927x seem to require fairly long delays for certain
4681 * command sequences. With too short delays (even if the answer
4682 * is set to RIRB properly), it results in the silence output
4683 * on some hardwares like Dell.
4685 * The below flag enables the longer delay (see get_response
4688 codec->bus->needs_damn_long_delay = 1;
4693 static int patch_stac9205(struct hda_codec *codec)
4695 struct sigmatel_spec *spec;
4698 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4703 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4704 spec->pin_nids = stac9205_pin_nids;
4705 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4709 if (spec->board_config < 0) {
4710 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4711 err = stac92xx_save_bios_config_regs(codec);
4713 stac92xx_free(codec);
4716 spec->pin_configs = spec->bios_pin_configs;
4718 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4719 stac92xx_set_config_regs(codec);
4722 spec->digbeep_nid = 0x23;
4723 spec->adc_nids = stac9205_adc_nids;
4724 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4725 spec->mux_nids = stac9205_mux_nids;
4726 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4727 spec->smux_nids = stac9205_smux_nids;
4728 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
4729 spec->dmic_nids = stac9205_dmic_nids;
4730 spec->num_dmics = STAC9205_NUM_DMICS;
4731 spec->dmux_nids = stac9205_dmux_nids;
4732 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4735 spec->init = stac9205_core_init;
4736 spec->mixer = stac9205_mixer;
4738 spec->aloopback_mask = 0x40;
4739 spec->aloopback_shift = 0;
4740 spec->multiout.dac_nids = spec->dac_nids;
4742 switch (spec->board_config){
4743 case STAC_9205_DELL_M43:
4744 /* Enable SPDIF in/out */
4745 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4746 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4748 /* Enable unsol response for GPIO4/Dock HP connection */
4749 snd_hda_codec_write(codec, codec->afg, 0,
4750 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4751 snd_hda_codec_write_cache(codec, codec->afg, 0,
4752 AC_VERB_SET_UNSOLICITED_ENABLE,
4753 (AC_USRSP_EN | STAC_HP_EVENT));
4755 spec->gpio_dir = 0x0b;
4756 spec->eapd_mask = 0x01;
4757 spec->gpio_mask = 0x1b;
4758 spec->gpio_mute = 0x10;
4759 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4762 spec->gpio_data = 0x01;
4765 /* SPDIF-In enabled */
4768 /* GPIO0 High = EAPD */
4769 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4770 spec->gpio_data = 0x01;
4774 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4776 if (spec->board_config < 0) {
4777 printk(KERN_WARNING "hda_codec: No auto-config is "
4778 "available, default to model=ref\n");
4779 spec->board_config = STAC_9205_REF;
4785 stac92xx_free(codec);
4789 codec->patch_ops = stac92xx_patch_ops;
4798 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4799 static hda_nid_t vaio_dacs[] = { 0x2 };
4800 #define VAIO_HP_DAC 0x5
4801 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4802 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4804 static struct hda_input_mux vaio_mux = {
4807 /* { "HP", 0x0 }, */
4808 { "Mic Jack", 0x1 },
4809 { "Internal Mic", 0x2 },
4814 static struct hda_verb vaio_init[] = {
4815 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4816 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
4817 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4818 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4819 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4821 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4822 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4823 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4824 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4825 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4830 static struct hda_verb vaio_ar_init[] = {
4831 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4832 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4833 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4834 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4835 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4836 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4837 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4838 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4839 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4840 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4841 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4842 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4843 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4847 /* bind volumes of both NID 0x02 and 0x05 */
4848 static struct hda_bind_ctls vaio_bind_master_vol = {
4849 .ops = &snd_hda_bind_vol,
4851 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4852 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4857 /* bind volumes of both NID 0x02 and 0x05 */
4858 static struct hda_bind_ctls vaio_bind_master_sw = {
4859 .ops = &snd_hda_bind_sw,
4861 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4862 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4867 static struct snd_kcontrol_new vaio_mixer[] = {
4868 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4869 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4870 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4871 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4872 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4874 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4875 .name = "Capture Source",
4877 .info = stac92xx_mux_enum_info,
4878 .get = stac92xx_mux_enum_get,
4879 .put = stac92xx_mux_enum_put,
4884 static struct snd_kcontrol_new vaio_ar_mixer[] = {
4885 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4886 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4887 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4888 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4889 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4890 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4891 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4893 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4894 .name = "Capture Source",
4896 .info = stac92xx_mux_enum_info,
4897 .get = stac92xx_mux_enum_get,
4898 .put = stac92xx_mux_enum_put,
4903 static struct hda_codec_ops stac9872_patch_ops = {
4904 .build_controls = stac92xx_build_controls,
4905 .build_pcms = stac92xx_build_pcms,
4906 .init = stac92xx_init,
4907 .free = stac92xx_free,
4908 #ifdef SND_HDA_NEEDS_RESUME
4909 .resume = stac92xx_resume,
4913 static int stac9872_vaio_init(struct hda_codec *codec)
4917 err = stac92xx_init(codec);
4920 if (codec->patch_ops.unsol_event)
4921 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4925 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4927 if (get_hp_pin_presence(codec, 0x0a)) {
4928 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4929 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4931 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4932 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4936 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4938 switch (res >> 26) {
4940 stac9872_vaio_hp_detect(codec, res);
4945 static struct hda_codec_ops stac9872_vaio_patch_ops = {
4946 .build_controls = stac92xx_build_controls,
4947 .build_pcms = stac92xx_build_pcms,
4948 .init = stac9872_vaio_init,
4949 .free = stac92xx_free,
4950 .unsol_event = stac9872_vaio_unsol_event,
4952 .resume = stac92xx_resume,
4956 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4958 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4960 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4962 /* AR Series. id=0x83847664 and subsys=104D1300 */
4967 static const char *stac9872_models[STAC_9872_MODELS] = {
4968 [CXD9872RD_VAIO] = "vaio",
4969 [CXD9872AKD_VAIO] = "vaio-ar",
4972 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4973 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4974 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4975 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
4976 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
4980 static int patch_stac9872(struct hda_codec *codec)
4982 struct sigmatel_spec *spec;
4985 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4988 if (board_config < 0)
4989 /* unknown config, let generic-parser do its job... */
4990 return snd_hda_parse_generic_codec(codec);
4992 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4997 switch (board_config) {
4998 case CXD9872RD_VAIO:
4999 case STAC9872AK_VAIO:
5000 case STAC9872K_VAIO:
5001 spec->mixer = vaio_mixer;
5002 spec->init = vaio_init;
5003 spec->multiout.max_channels = 2;
5004 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5005 spec->multiout.dac_nids = vaio_dacs;
5006 spec->multiout.hp_nid = VAIO_HP_DAC;
5007 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5008 spec->adc_nids = vaio_adcs;
5010 spec->input_mux = &vaio_mux;
5011 spec->mux_nids = vaio_mux_nids;
5012 codec->patch_ops = stac9872_vaio_patch_ops;
5015 case CXD9872AKD_VAIO:
5016 spec->mixer = vaio_ar_mixer;
5017 spec->init = vaio_ar_init;
5018 spec->multiout.max_channels = 2;
5019 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
5020 spec->multiout.dac_nids = vaio_dacs;
5021 spec->multiout.hp_nid = VAIO_HP_DAC;
5022 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
5024 spec->adc_nids = vaio_adcs;
5025 spec->input_mux = &vaio_mux;
5026 spec->mux_nids = vaio_mux_nids;
5027 codec->patch_ops = stac9872_patch_ops;
5038 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5039 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5040 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5041 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5042 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5043 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5044 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5045 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5046 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5047 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5048 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5049 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5050 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5051 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5052 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5053 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5054 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5055 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5056 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5057 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5058 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5059 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5060 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5061 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5062 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5063 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5064 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5065 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5066 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5067 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5068 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
5069 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
5070 /* The following does not take into account .id=0x83847661 when subsys =
5071 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
5072 * currently not fully supported.
5074 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
5075 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
5076 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
5077 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
5078 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
5079 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
5080 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
5081 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
5082 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
5083 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
5084 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
5085 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
5086 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
5087 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
5088 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
5089 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
5090 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
5091 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
5092 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5093 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
5094 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5095 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
5096 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5097 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
5098 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
5099 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },