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 <sound/driver.h>
28 #include <linux/init.h>
29 #include <linux/delay.h>
30 #include <linux/slab.h>
31 #include <linux/pci.h>
32 #include <sound/core.h>
33 #include <sound/asoundef.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
37 #define NUM_CONTROL_ALLOC 32
38 #define STAC_HP_EVENT 0x37
81 /* for backward compatibility */
103 struct sigmatel_spec {
104 struct snd_kcontrol_new *mixers[4];
105 unsigned int num_mixers;
108 unsigned int surr_switch: 1;
109 unsigned int line_switch: 1;
110 unsigned int mic_switch: 1;
111 unsigned int alt_switch: 1;
112 unsigned int hp_detect: 1;
113 unsigned int gpio_mute: 1;
115 unsigned int gpio_mask, gpio_data;
118 struct hda_multi_out multiout;
119 hda_nid_t dac_nids[5];
123 unsigned int num_adcs;
125 unsigned int num_muxes;
126 hda_nid_t *dmic_nids;
127 unsigned int num_dmics;
129 hda_nid_t dig_in_nid;
133 unsigned int num_pins;
134 unsigned int *pin_configs;
135 unsigned int *bios_pin_configs;
137 /* codec specific stuff */
138 struct hda_verb *init;
139 struct snd_kcontrol_new *mixer;
142 struct hda_input_mux *dinput_mux;
143 unsigned int cur_dmux;
144 struct hda_input_mux *input_mux;
145 unsigned int cur_mux[3];
148 unsigned int io_switch[2];
149 unsigned int clfe_swap;
150 unsigned int aloopback;
152 struct hda_pcm pcm_rec[2]; /* PCM information */
154 /* dynamic controls and input_mux */
155 struct auto_pin_cfg autocfg;
156 unsigned int num_kctl_alloc, num_kctl_used;
157 struct snd_kcontrol_new *kctl_alloc;
158 struct hda_input_mux private_dimux;
159 struct hda_input_mux private_imux;
162 static hda_nid_t stac9200_adc_nids[1] = {
166 static hda_nid_t stac9200_mux_nids[1] = {
170 static hda_nid_t stac9200_dac_nids[1] = {
174 static hda_nid_t stac925x_adc_nids[1] = {
178 static hda_nid_t stac925x_mux_nids[1] = {
182 static hda_nid_t stac925x_dac_nids[1] = {
186 #define STAC925X_NUM_DMICS 1
187 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
191 static hda_nid_t stac922x_adc_nids[2] = {
195 static hda_nid_t stac922x_mux_nids[2] = {
199 static hda_nid_t stac927x_adc_nids[3] = {
203 static hda_nid_t stac927x_mux_nids[3] = {
207 static hda_nid_t stac9205_adc_nids[2] = {
211 static hda_nid_t stac9205_mux_nids[2] = {
215 #define STAC9205_NUM_DMICS 2
216 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
220 static hda_nid_t stac9200_pin_nids[8] = {
221 0x08, 0x09, 0x0d, 0x0e,
222 0x0f, 0x10, 0x11, 0x12,
225 static hda_nid_t stac925x_pin_nids[8] = {
226 0x07, 0x08, 0x0a, 0x0b,
227 0x0c, 0x0d, 0x10, 0x11,
230 static hda_nid_t stac922x_pin_nids[10] = {
231 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
232 0x0f, 0x10, 0x11, 0x15, 0x1b,
235 static hda_nid_t stac927x_pin_nids[14] = {
236 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
237 0x0f, 0x10, 0x11, 0x12, 0x13,
238 0x14, 0x21, 0x22, 0x23,
241 static hda_nid_t stac9205_pin_nids[12] = {
242 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
243 0x0f, 0x14, 0x16, 0x17, 0x18,
247 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
248 struct snd_ctl_elem_info *uinfo)
250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
251 struct sigmatel_spec *spec = codec->spec;
252 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
255 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
256 struct snd_ctl_elem_value *ucontrol)
258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
259 struct sigmatel_spec *spec = codec->spec;
261 ucontrol->value.enumerated.item[0] = spec->cur_dmux;
265 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
266 struct snd_ctl_elem_value *ucontrol)
268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
269 struct sigmatel_spec *spec = codec->spec;
271 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
272 spec->dmux_nid, &spec->cur_dmux);
275 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
278 struct sigmatel_spec *spec = codec->spec;
279 return snd_hda_input_mux_info(spec->input_mux, uinfo);
282 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
284 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
285 struct sigmatel_spec *spec = codec->spec;
286 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
288 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
292 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
294 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
295 struct sigmatel_spec *spec = codec->spec;
296 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
298 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
299 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
302 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
304 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
305 struct snd_ctl_elem_value *ucontrol)
307 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
308 struct sigmatel_spec *spec = codec->spec;
310 ucontrol->value.integer.value[0] = spec->aloopback;
314 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
315 struct snd_ctl_elem_value *ucontrol)
317 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
318 struct sigmatel_spec *spec = codec->spec;
319 unsigned int dac_mode;
321 if (spec->aloopback == ucontrol->value.integer.value[0])
324 spec->aloopback = ucontrol->value.integer.value[0];
327 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
328 kcontrol->private_value & 0xFFFF, 0x0);
330 if (spec->aloopback) {
331 snd_hda_power_up(codec);
334 snd_hda_power_down(codec);
338 snd_hda_codec_write_cache(codec, codec->afg, 0,
339 kcontrol->private_value >> 16, dac_mode);
344 static struct hda_verb stac9200_core_init[] = {
345 /* set dac0mux for dac converter */
346 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
350 static struct hda_verb stac9200_eapd_init[] = {
351 /* set dac0mux for dac converter */
352 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
353 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
357 static struct hda_verb stac925x_core_init[] = {
358 /* set dac0mux for dac converter */
359 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
363 static struct hda_verb stac922x_core_init[] = {
364 /* set master volume and direct control */
365 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
369 static struct hda_verb d965_core_init[] = {
370 /* set master volume and direct control */
371 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
372 /* unmute node 0x1b */
373 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
374 /* select node 0x03 as DAC */
375 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
379 static struct hda_verb stac927x_core_init[] = {
380 /* set master volume and direct control */
381 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
385 static struct hda_verb stac9205_core_init[] = {
386 /* set master volume and direct control */
387 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
391 #define STAC_INPUT_SOURCE(cnt) \
393 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
394 .name = "Input Source", \
396 .info = stac92xx_mux_enum_info, \
397 .get = stac92xx_mux_enum_get, \
398 .put = stac92xx_mux_enum_put, \
401 #define STAC_ANALOG_LOOPBACK(verb_read,verb_write) \
403 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
404 .name = "Analog Loopback", \
406 .info = stac92xx_aloopback_info, \
407 .get = stac92xx_aloopback_get, \
408 .put = stac92xx_aloopback_put, \
409 .private_value = verb_read | (verb_write << 16), \
412 static struct snd_kcontrol_new stac9200_mixer[] = {
413 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
414 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
415 STAC_INPUT_SOURCE(1),
416 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
417 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
418 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
422 static struct snd_kcontrol_new stac925x_mixer[] = {
423 STAC_INPUT_SOURCE(1),
424 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
425 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
426 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
430 static struct snd_kcontrol_new stac9205_mixer[] = {
432 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
433 .name = "Digital Input Source",
435 .info = stac92xx_dmux_enum_info,
436 .get = stac92xx_dmux_enum_get,
437 .put = stac92xx_dmux_enum_put,
439 STAC_INPUT_SOURCE(2),
440 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0),
442 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
443 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
444 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
446 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
447 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
448 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
453 /* This needs to be generated dynamically based on sequence */
454 static struct snd_kcontrol_new stac922x_mixer[] = {
455 STAC_INPUT_SOURCE(2),
456 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
457 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
458 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
460 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
461 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
462 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
467 static struct snd_kcontrol_new stac927x_mixer[] = {
468 STAC_INPUT_SOURCE(3),
469 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB),
471 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
472 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
473 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
475 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
476 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
477 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
479 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
480 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
481 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
485 static int stac92xx_build_controls(struct hda_codec *codec)
487 struct sigmatel_spec *spec = codec->spec;
491 err = snd_hda_add_new_ctls(codec, spec->mixer);
495 for (i = 0; i < spec->num_mixers; i++) {
496 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
501 if (spec->multiout.dig_out_nid) {
502 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
506 if (spec->dig_in_nid) {
507 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
514 static unsigned int ref9200_pin_configs[8] = {
515 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
516 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
520 STAC 9200 pin configs for
525 static unsigned int dell9200_d21_pin_configs[8] = {
526 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
527 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
531 STAC 9200 pin configs for
535 static unsigned int dell9200_d22_pin_configs[8] = {
536 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
537 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
541 STAC 9200 pin configs for
542 102801C4 (Dell Dimension E310)
549 static unsigned int dell9200_d23_pin_configs[8] = {
550 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
551 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
556 STAC 9200-32 pin configs for
557 102801B5 (Dell Inspiron 630m)
558 102801D8 (Dell Inspiron 640m)
560 static unsigned int dell9200_m21_pin_configs[8] = {
561 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
562 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
566 STAC 9200-32 pin configs for
567 102801C2 (Dell Latitude D620)
569 102801CC (Dell Latitude D820)
573 static unsigned int dell9200_m22_pin_configs[8] = {
574 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
575 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
579 STAC 9200-32 pin configs for
580 102801CE (Dell XPS M1710)
581 102801CF (Dell Precision M90)
583 static unsigned int dell9200_m23_pin_configs[8] = {
584 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
585 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
589 STAC 9200-32 pin configs for
592 102801CB (Dell Latitude 120L)
595 static unsigned int dell9200_m24_pin_configs[8] = {
596 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
597 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
601 STAC 9200-32 pin configs for
602 102801BD (Dell Inspiron E1505n)
606 static unsigned int dell9200_m25_pin_configs[8] = {
607 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
608 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
612 STAC 9200-32 pin configs for
613 102801F5 (Dell Inspiron 1501)
616 static unsigned int dell9200_m26_pin_configs[8] = {
617 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
618 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
623 102801CD (Dell Inspiron E1705/9400)
625 static unsigned int dell9200_m27_pin_configs[8] = {
626 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
627 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
631 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
632 [STAC_REF] = ref9200_pin_configs,
633 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
634 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
635 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
636 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
637 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
638 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
639 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
640 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
641 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
642 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
645 static const char *stac9200_models[STAC_9200_MODELS] = {
647 [STAC_9200_DELL_D21] = "dell-d21",
648 [STAC_9200_DELL_D22] = "dell-d22",
649 [STAC_9200_DELL_D23] = "dell-d23",
650 [STAC_9200_DELL_M21] = "dell-m21",
651 [STAC_9200_DELL_M22] = "dell-m22",
652 [STAC_9200_DELL_M23] = "dell-m23",
653 [STAC_9200_DELL_M24] = "dell-m24",
654 [STAC_9200_DELL_M25] = "dell-m25",
655 [STAC_9200_DELL_M26] = "dell-m26",
656 [STAC_9200_DELL_M27] = "dell-m27",
657 [STAC_9200_GATEWAY] = "gateway",
660 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
661 /* SigmaTel reference board */
662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
663 "DFI LanParty", STAC_REF),
664 /* Dell laptops have BIOS problem */
665 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
666 "unknown Dell", STAC_9200_DELL_D21),
667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
668 "Dell Inspiron 630m", STAC_9200_DELL_M21),
669 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
670 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
672 "unknown Dell", STAC_9200_DELL_D22),
673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
674 "unknown Dell", STAC_9200_DELL_D22),
675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
676 "Dell Latitude D620", STAC_9200_DELL_M22),
677 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
678 "unknown Dell", STAC_9200_DELL_D23),
679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
680 "unknown Dell", STAC_9200_DELL_D23),
681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
682 "unknown Dell", STAC_9200_DELL_M22),
683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
684 "unknown Dell", STAC_9200_DELL_M24),
685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
686 "unknown Dell", STAC_9200_DELL_M24),
687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
688 "Dell Latitude 120L", STAC_9200_DELL_M24),
689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
690 "Dell Latitude D820", STAC_9200_DELL_M22),
691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
692 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
694 "Dell XPS M1710", STAC_9200_DELL_M23),
695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
696 "Dell Precision M90", STAC_9200_DELL_M23),
697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
698 "unknown Dell", STAC_9200_DELL_M22),
699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
700 "unknown Dell", STAC_9200_DELL_M22),
701 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
702 "unknown Dell", STAC_9200_DELL_M22),
703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
704 "Dell Inspiron 640m", STAC_9200_DELL_M21),
705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
706 "unknown Dell", STAC_9200_DELL_D23),
707 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
708 "unknown Dell", STAC_9200_DELL_D23),
709 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
710 "unknown Dell", STAC_9200_DELL_D21),
711 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
712 "unknown Dell", STAC_9200_DELL_D23),
713 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
714 "unknown Dell", STAC_9200_DELL_D21),
715 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
716 "unknown Dell", STAC_9200_DELL_M25),
717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
718 "unknown Dell", STAC_9200_DELL_M25),
719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
720 "Dell Inspiron 1501", STAC_9200_DELL_M26),
721 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
722 "unknown Dell", STAC_9200_DELL_M26),
724 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
725 /* Gateway machines needs EAPD to be set on resume */
726 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
727 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
729 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
734 static unsigned int ref925x_pin_configs[8] = {
735 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
736 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
739 static unsigned int stac925x_MA6_pin_configs[8] = {
740 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
741 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
744 static unsigned int stac925x_PA6_pin_configs[8] = {
745 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
746 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
749 static unsigned int stac925xM2_2_pin_configs[8] = {
750 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
751 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
754 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
755 [STAC_REF] = ref925x_pin_configs,
756 [STAC_M2_2] = stac925xM2_2_pin_configs,
757 [STAC_MA6] = stac925x_MA6_pin_configs,
758 [STAC_PA6] = stac925x_PA6_pin_configs,
761 static const char *stac925x_models[STAC_925x_MODELS] = {
763 [STAC_M2_2] = "m2-2",
768 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
769 /* SigmaTel reference board */
770 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
771 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
772 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
773 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
774 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
775 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
776 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
780 static unsigned int ref922x_pin_configs[10] = {
781 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
782 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
783 0x40000100, 0x40000100,
787 STAC 922X pin configs for
794 static unsigned int dell_922x_d81_pin_configs[10] = {
795 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
796 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
797 0x01813122, 0x400001f2,
801 STAC 922X pin configs for
805 static unsigned int dell_922x_d82_pin_configs[10] = {
806 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
807 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
808 0x01813122, 0x400001f1,
812 STAC 922X pin configs for
815 static unsigned int dell_922x_m81_pin_configs[10] = {
816 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
817 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
818 0x40C003f1, 0x405003f0,
822 STAC 9221 A1 pin configs for
823 102801D7 (Dell XPS M1210)
825 static unsigned int dell_922x_m82_pin_configs[10] = {
826 0x0221121f, 0x408103ff, 0x02111212, 0x90100310,
827 0x408003f1, 0x02111211, 0x03451340, 0x40c003f2,
828 0x508003f3, 0x405003f4,
831 static unsigned int d945gtp3_pin_configs[10] = {
832 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
833 0x40000100, 0x40000100, 0x40000100, 0x40000100,
834 0x02a19120, 0x40000100,
837 static unsigned int d945gtp5_pin_configs[10] = {
838 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
839 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
840 0x02a19320, 0x40000100,
843 static unsigned int intel_mac_v1_pin_configs[10] = {
844 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
845 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
846 0x400000fc, 0x400000fb,
849 static unsigned int intel_mac_v2_pin_configs[10] = {
850 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
851 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
852 0x400000fc, 0x400000fb,
855 static unsigned int intel_mac_v3_pin_configs[10] = {
856 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
857 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
858 0x400000fc, 0x400000fb,
861 static unsigned int intel_mac_v4_pin_configs[10] = {
862 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
863 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
864 0x400000fc, 0x400000fb,
867 static unsigned int intel_mac_v5_pin_configs[10] = {
868 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
869 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
870 0x400000fc, 0x400000fb,
874 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
875 [STAC_D945_REF] = ref922x_pin_configs,
876 [STAC_D945GTP3] = d945gtp3_pin_configs,
877 [STAC_D945GTP5] = d945gtp5_pin_configs,
878 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
879 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
880 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
881 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
882 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
883 /* for backward compatibility */
884 [STAC_MACMINI] = intel_mac_v3_pin_configs,
885 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
886 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
887 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
888 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
889 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
890 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
891 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
892 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
893 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
896 static const char *stac922x_models[STAC_922X_MODELS] = {
897 [STAC_D945_REF] = "ref",
898 [STAC_D945GTP5] = "5stack",
899 [STAC_D945GTP3] = "3stack",
900 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
901 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
902 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
903 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
904 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
905 /* for backward compatibility */
906 [STAC_MACMINI] = "macmini",
907 [STAC_MACBOOK] = "macbook",
908 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
909 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
910 [STAC_IMAC_INTEL] = "imac-intel",
911 [STAC_IMAC_INTEL_20] = "imac-intel-20",
912 [STAC_922X_DELL_D81] = "dell-d81",
913 [STAC_922X_DELL_D82] = "dell-d82",
914 [STAC_922X_DELL_M81] = "dell-m81",
915 [STAC_922X_DELL_M82] = "dell-m82",
918 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
919 /* SigmaTel reference board */
920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
921 "DFI LanParty", STAC_D945_REF),
922 /* Intel 945G based systems */
923 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
924 "Intel D945G", STAC_D945GTP3),
925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
926 "Intel D945G", STAC_D945GTP3),
927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
928 "Intel D945G", STAC_D945GTP3),
929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
930 "Intel D945G", STAC_D945GTP3),
931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
932 "Intel D945G", STAC_D945GTP3),
933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
934 "Intel D945G", STAC_D945GTP3),
935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
936 "Intel D945G", STAC_D945GTP3),
937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
938 "Intel D945G", STAC_D945GTP3),
939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
940 "Intel D945G", STAC_D945GTP3),
941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
942 "Intel D945G", STAC_D945GTP3),
943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
944 "Intel D945G", STAC_D945GTP3),
945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
946 "Intel D945G", STAC_D945GTP3),
947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
948 "Intel D945G", STAC_D945GTP3),
949 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
950 "Intel D945G", STAC_D945GTP3),
951 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
952 "Intel D945G", STAC_D945GTP3),
953 /* Intel D945G 5-stack systems */
954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
955 "Intel D945G", STAC_D945GTP5),
956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
957 "Intel D945G", STAC_D945GTP5),
958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
959 "Intel D945G", STAC_D945GTP5),
960 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
961 "Intel D945G", STAC_D945GTP5),
962 /* Intel 945P based systems */
963 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
964 "Intel D945P", STAC_D945GTP3),
965 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
966 "Intel D945P", STAC_D945GTP3),
967 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
968 "Intel D945P", STAC_D945GTP3),
969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
970 "Intel D945P", STAC_D945GTP3),
971 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
972 "Intel D945P", STAC_D945GTP3),
973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
974 "Intel D945P", STAC_D945GTP5),
976 /* Apple Mac Mini (early 2006) */
977 SND_PCI_QUIRK(0x8384, 0x7680,
978 "Mac Mini", STAC_INTEL_MAC_V3),
980 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
981 "unknown Dell", STAC_922X_DELL_D81),
982 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
983 "unknown Dell", STAC_922X_DELL_D81),
984 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
985 "unknown Dell", STAC_922X_DELL_D81),
986 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
987 "unknown Dell", STAC_922X_DELL_D82),
988 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
989 "unknown Dell", STAC_922X_DELL_M81),
990 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
991 "unknown Dell", STAC_922X_DELL_D82),
992 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
993 "unknown Dell", STAC_922X_DELL_D81),
994 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
995 "unknown Dell", STAC_922X_DELL_D81),
996 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
997 "Dell XPS M1210", STAC_922X_DELL_M82),
1001 static unsigned int ref927x_pin_configs[14] = {
1002 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1003 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1004 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1005 0x01c42190, 0x40000100,
1008 static unsigned int d965_3st_pin_configs[14] = {
1009 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1010 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1011 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1012 0x40000100, 0x40000100
1015 static unsigned int d965_5st_pin_configs[14] = {
1016 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1017 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1018 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1019 0x40000100, 0x40000100
1022 static unsigned int dell_3st_pin_configs[14] = {
1023 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1024 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1025 0x403003fa, 0x40000100, 0x40000100, 0x404003fb,
1026 0x40c003fc, 0x40000100
1029 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1030 [STAC_D965_REF] = ref927x_pin_configs,
1031 [STAC_D965_3ST] = d965_3st_pin_configs,
1032 [STAC_D965_5ST] = d965_5st_pin_configs,
1033 [STAC_DELL_3ST] = dell_3st_pin_configs,
1036 static const char *stac927x_models[STAC_927X_MODELS] = {
1037 [STAC_D965_REF] = "ref",
1038 [STAC_D965_3ST] = "3stack",
1039 [STAC_D965_5ST] = "5stack",
1040 [STAC_DELL_3ST] = "dell-3stack",
1043 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1044 /* SigmaTel reference board */
1045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1046 "DFI LanParty", STAC_D965_REF),
1047 /* Intel 946 based systems */
1048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1050 /* 965 based 3 stack systems */
1051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1055 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_D965_3ST),
1068 /* Dell 3 stack systems */
1069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1070 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1072 /* 965 based 5 stack systems */
1073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_D965_5ST),
1074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1076 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1078 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1080 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1082 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1086 static unsigned int ref9205_pin_configs[12] = {
1087 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1088 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
1089 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1093 STAC 9205 pin configs for
1101 static unsigned int dell_9205_m42_pin_configs[12] = {
1102 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1103 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1104 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1108 STAC 9205 pin configs for
1112 102801FF (Dell Precision M4300)
1117 static unsigned int dell_9205_m43_pin_configs[12] = {
1118 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1119 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1120 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1123 static unsigned int dell_9205_m44_pin_configs[12] = {
1124 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1125 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1126 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1129 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1130 [STAC_9205_REF] = ref9205_pin_configs,
1131 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1132 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1133 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1136 static const char *stac9205_models[STAC_9205_MODELS] = {
1137 [STAC_9205_REF] = "ref",
1138 [STAC_9205_DELL_M42] = "dell-m42",
1139 [STAC_9205_DELL_M43] = "dell-m43",
1140 [STAC_9205_DELL_M44] = "dell-m44",
1143 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1144 /* SigmaTel reference board */
1145 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1146 "DFI LanParty", STAC_9205_REF),
1147 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1148 "unknown Dell", STAC_9205_DELL_M42),
1149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1150 "unknown Dell", STAC_9205_DELL_M42),
1151 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1152 "Dell Precision", STAC_9205_DELL_M43),
1153 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1154 "Dell Precision", STAC_9205_DELL_M43),
1155 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1156 "Dell Precision", STAC_9205_DELL_M43),
1157 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1158 "Dell Precision", STAC_9205_DELL_M43),
1159 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1160 "Dell Precision", STAC_9205_DELL_M43),
1161 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1162 "unknown Dell", STAC_9205_DELL_M42),
1163 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1164 "unknown Dell", STAC_9205_DELL_M42),
1165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1166 "Dell Precision", STAC_9205_DELL_M43),
1167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1168 "Dell Precision M4300", STAC_9205_DELL_M43),
1169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1170 "Dell Precision", STAC_9205_DELL_M43),
1171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1172 "Dell Inspiron", STAC_9205_DELL_M44),
1173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1174 "Dell Inspiron", STAC_9205_DELL_M44),
1175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1176 "Dell Inspiron", STAC_9205_DELL_M44),
1177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1178 "Dell Inspiron", STAC_9205_DELL_M44),
1179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1180 "unknown Dell", STAC_9205_DELL_M42),
1181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1182 "Dell Inspiron", STAC_9205_DELL_M44),
1186 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1189 struct sigmatel_spec *spec = codec->spec;
1191 if (! spec->bios_pin_configs) {
1192 spec->bios_pin_configs = kcalloc(spec->num_pins,
1193 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1194 if (! spec->bios_pin_configs)
1198 for (i = 0; i < spec->num_pins; i++) {
1199 hda_nid_t nid = spec->pin_nids[i];
1200 unsigned int pin_cfg;
1202 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1203 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1204 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1206 spec->bios_pin_configs[i] = pin_cfg;
1212 static void stac92xx_set_config_reg(struct hda_codec *codec,
1213 hda_nid_t pin_nid, unsigned int pin_config)
1216 snd_hda_codec_write(codec, pin_nid, 0,
1217 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1218 pin_config & 0x000000ff);
1219 snd_hda_codec_write(codec, pin_nid, 0,
1220 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1221 (pin_config & 0x0000ff00) >> 8);
1222 snd_hda_codec_write(codec, pin_nid, 0,
1223 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1224 (pin_config & 0x00ff0000) >> 16);
1225 snd_hda_codec_write(codec, pin_nid, 0,
1226 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1228 i = snd_hda_codec_read(codec, pin_nid, 0,
1229 AC_VERB_GET_CONFIG_DEFAULT,
1231 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1235 static void stac92xx_set_config_regs(struct hda_codec *codec)
1238 struct sigmatel_spec *spec = codec->spec;
1240 if (!spec->pin_configs)
1243 for (i = 0; i < spec->num_pins; i++)
1244 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1245 spec->pin_configs[i]);
1248 static void stac92xx_enable_gpio_mask(struct hda_codec *codec)
1250 struct sigmatel_spec *spec = codec->spec;
1251 /* Configure GPIOx as output */
1252 snd_hda_codec_write_cache(codec, codec->afg, 0,
1253 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask);
1254 /* Configure GPIOx as CMOS */
1255 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000);
1257 snd_hda_codec_write_cache(codec, codec->afg, 0,
1258 AC_VERB_SET_GPIO_DATA, spec->gpio_data);
1260 snd_hda_codec_write_cache(codec, codec->afg, 0,
1261 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
1265 * Analog playback callbacks
1267 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1268 struct hda_codec *codec,
1269 struct snd_pcm_substream *substream)
1271 struct sigmatel_spec *spec = codec->spec;
1272 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1275 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1276 struct hda_codec *codec,
1277 unsigned int stream_tag,
1278 unsigned int format,
1279 struct snd_pcm_substream *substream)
1281 struct sigmatel_spec *spec = codec->spec;
1282 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1285 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1286 struct hda_codec *codec,
1287 struct snd_pcm_substream *substream)
1289 struct sigmatel_spec *spec = codec->spec;
1290 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1294 * Digital playback callbacks
1296 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1297 struct hda_codec *codec,
1298 struct snd_pcm_substream *substream)
1300 struct sigmatel_spec *spec = codec->spec;
1301 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1304 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1305 struct hda_codec *codec,
1306 struct snd_pcm_substream *substream)
1308 struct sigmatel_spec *spec = codec->spec;
1309 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1312 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1313 struct hda_codec *codec,
1314 unsigned int stream_tag,
1315 unsigned int format,
1316 struct snd_pcm_substream *substream)
1318 struct sigmatel_spec *spec = codec->spec;
1319 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1320 stream_tag, format, substream);
1325 * Analog capture callbacks
1327 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1328 struct hda_codec *codec,
1329 unsigned int stream_tag,
1330 unsigned int format,
1331 struct snd_pcm_substream *substream)
1333 struct sigmatel_spec *spec = codec->spec;
1335 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1336 stream_tag, 0, format);
1340 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1341 struct hda_codec *codec,
1342 struct snd_pcm_substream *substream)
1344 struct sigmatel_spec *spec = codec->spec;
1346 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1350 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1354 /* NID is set in stac92xx_build_pcms */
1356 .open = stac92xx_dig_playback_pcm_open,
1357 .close = stac92xx_dig_playback_pcm_close,
1358 .prepare = stac92xx_dig_playback_pcm_prepare
1362 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1366 /* NID is set in stac92xx_build_pcms */
1369 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1373 .nid = 0x02, /* NID to query formats and rates */
1375 .open = stac92xx_playback_pcm_open,
1376 .prepare = stac92xx_playback_pcm_prepare,
1377 .cleanup = stac92xx_playback_pcm_cleanup
1381 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1385 .nid = 0x06, /* NID to query formats and rates */
1387 .open = stac92xx_playback_pcm_open,
1388 .prepare = stac92xx_playback_pcm_prepare,
1389 .cleanup = stac92xx_playback_pcm_cleanup
1393 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1396 /* NID + .substreams is set in stac92xx_build_pcms */
1398 .prepare = stac92xx_capture_pcm_prepare,
1399 .cleanup = stac92xx_capture_pcm_cleanup
1403 static int stac92xx_build_pcms(struct hda_codec *codec)
1405 struct sigmatel_spec *spec = codec->spec;
1406 struct hda_pcm *info = spec->pcm_rec;
1408 codec->num_pcms = 1;
1409 codec->pcm_info = info;
1411 info->name = "STAC92xx Analog";
1412 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
1413 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
1414 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1415 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
1417 if (spec->alt_switch) {
1420 info->name = "STAC92xx Analog Alt";
1421 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1424 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1427 info->name = "STAC92xx Digital";
1428 if (spec->multiout.dig_out_nid) {
1429 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1430 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1432 if (spec->dig_in_nid) {
1433 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1434 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1441 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1443 unsigned int pincap = snd_hda_param_read(codec, nid,
1445 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1446 if (pincap & AC_PINCAP_VREF_100)
1447 return AC_PINCTL_VREF_100;
1448 if (pincap & AC_PINCAP_VREF_80)
1449 return AC_PINCTL_VREF_80;
1450 if (pincap & AC_PINCAP_VREF_50)
1451 return AC_PINCTL_VREF_50;
1452 if (pincap & AC_PINCAP_VREF_GRD)
1453 return AC_PINCTL_VREF_GRD;
1457 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1460 snd_hda_codec_write_cache(codec, nid, 0,
1461 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1464 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1466 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1468 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1469 struct sigmatel_spec *spec = codec->spec;
1470 int io_idx = kcontrol-> private_value & 0xff;
1472 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1476 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1479 struct sigmatel_spec *spec = codec->spec;
1480 hda_nid_t nid = kcontrol->private_value >> 8;
1481 int io_idx = kcontrol-> private_value & 0xff;
1482 unsigned short val = ucontrol->value.integer.value[0];
1484 spec->io_switch[io_idx] = val;
1487 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1489 unsigned int pinctl = AC_PINCTL_IN_EN;
1490 if (io_idx) /* set VREF for mic */
1491 pinctl |= stac92xx_get_vref(codec, nid);
1492 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1497 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
1499 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
1500 struct snd_ctl_elem_value *ucontrol)
1502 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1503 struct sigmatel_spec *spec = codec->spec;
1505 ucontrol->value.integer.value[0] = spec->clfe_swap;
1509 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
1510 struct snd_ctl_elem_value *ucontrol)
1512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1513 struct sigmatel_spec *spec = codec->spec;
1514 hda_nid_t nid = kcontrol->private_value & 0xff;
1516 if (spec->clfe_swap == ucontrol->value.integer.value[0])
1519 spec->clfe_swap = ucontrol->value.integer.value[0];
1521 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1522 spec->clfe_swap ? 0x4 : 0x0);
1527 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
1528 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1531 .info = stac92xx_io_switch_info, \
1532 .get = stac92xx_io_switch_get, \
1533 .put = stac92xx_io_switch_put, \
1534 .private_value = xpval, \
1537 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
1538 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1541 .info = stac92xx_clfe_switch_info, \
1542 .get = stac92xx_clfe_switch_get, \
1543 .put = stac92xx_clfe_switch_put, \
1544 .private_value = xpval, \
1548 STAC_CTL_WIDGET_VOL,
1549 STAC_CTL_WIDGET_MUTE,
1550 STAC_CTL_WIDGET_IO_SWITCH,
1551 STAC_CTL_WIDGET_CLFE_SWITCH
1554 static struct snd_kcontrol_new stac92xx_control_templates[] = {
1555 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1556 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1557 STAC_CODEC_IO_SWITCH(NULL, 0),
1558 STAC_CODEC_CLFE_SWITCH(NULL, 0),
1561 /* add dynamic controls */
1562 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1564 struct snd_kcontrol_new *knew;
1566 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1567 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1569 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1572 if (spec->kctl_alloc) {
1573 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1574 kfree(spec->kctl_alloc);
1576 spec->kctl_alloc = knew;
1577 spec->num_kctl_alloc = num;
1580 knew = &spec->kctl_alloc[spec->num_kctl_used];
1581 *knew = stac92xx_control_templates[type];
1582 knew->name = kstrdup(name, GFP_KERNEL);
1585 knew->private_value = val;
1586 spec->num_kctl_used++;
1590 /* flag inputs as additional dynamic lineouts */
1591 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1593 struct sigmatel_spec *spec = codec->spec;
1594 unsigned int wcaps, wtype;
1595 int i, num_dacs = 0;
1597 /* use the wcaps cache to count all DACs available for line-outs */
1598 for (i = 0; i < codec->num_nodes; i++) {
1599 wcaps = codec->wcaps[i];
1600 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1601 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1605 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1607 switch (cfg->line_outs) {
1609 /* add line-in as side */
1610 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1611 cfg->line_out_pins[cfg->line_outs] =
1612 cfg->input_pins[AUTO_PIN_LINE];
1613 spec->line_switch = 1;
1618 /* add line-in as clfe and mic as side */
1619 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1620 cfg->line_out_pins[cfg->line_outs] =
1621 cfg->input_pins[AUTO_PIN_LINE];
1622 spec->line_switch = 1;
1625 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1626 cfg->line_out_pins[cfg->line_outs] =
1627 cfg->input_pins[AUTO_PIN_MIC];
1628 spec->mic_switch = 1;
1633 /* add line-in as surr and mic as clfe */
1634 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1635 cfg->line_out_pins[cfg->line_outs] =
1636 cfg->input_pins[AUTO_PIN_LINE];
1637 spec->line_switch = 1;
1640 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1641 cfg->line_out_pins[cfg->line_outs] =
1642 cfg->input_pins[AUTO_PIN_MIC];
1643 spec->mic_switch = 1;
1653 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1657 for (i = 0; i < spec->multiout.num_dacs; i++) {
1658 if (spec->multiout.dac_nids[i] == nid)
1666 * Fill in the dac_nids table from the parsed pin configuration
1667 * This function only works when every pin in line_out_pins[]
1668 * contains atleast one DAC in its connection list. Some 92xx
1669 * codecs are not connected directly to a DAC, such as the 9200
1670 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1672 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1673 struct auto_pin_cfg *cfg)
1675 struct sigmatel_spec *spec = codec->spec;
1676 int i, j, conn_len = 0;
1677 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1678 unsigned int wcaps, wtype;
1680 for (i = 0; i < cfg->line_outs; i++) {
1681 nid = cfg->line_out_pins[i];
1682 conn_len = snd_hda_get_connections(codec, nid, conn,
1683 HDA_MAX_CONNECTIONS);
1684 for (j = 0; j < conn_len; j++) {
1685 wcaps = snd_hda_param_read(codec, conn[j],
1686 AC_PAR_AUDIO_WIDGET_CAP);
1687 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1689 if (wtype != AC_WID_AUD_OUT ||
1690 (wcaps & AC_WCAP_DIGITAL))
1692 /* conn[j] is a DAC routed to this line-out */
1693 if (!is_in_dac_nids(spec, conn[j]))
1697 if (j == conn_len) {
1698 if (spec->multiout.num_dacs > 0) {
1699 /* we have already working output pins,
1700 * so let's drop the broken ones again
1702 cfg->line_outs = spec->multiout.num_dacs;
1705 /* error out, no available DAC found */
1707 "%s: No available DAC for pin 0x%x\n",
1712 spec->multiout.dac_nids[i] = conn[j];
1713 spec->multiout.num_dacs++;
1715 /* select this DAC in the pin's input mux */
1716 snd_hda_codec_write_cache(codec, nid, 0,
1717 AC_VERB_SET_CONNECT_SEL, j);
1722 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1723 spec->multiout.num_dacs,
1724 spec->multiout.dac_nids[0],
1725 spec->multiout.dac_nids[1],
1726 spec->multiout.dac_nids[2],
1727 spec->multiout.dac_nids[3],
1728 spec->multiout.dac_nids[4]);
1732 /* create volume control/switch for the given prefx type */
1733 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1738 sprintf(name, "%s Playback Volume", pfx);
1739 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1740 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1743 sprintf(name, "%s Playback Switch", pfx);
1744 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1745 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1751 /* add playback controls from the parsed DAC table */
1752 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
1753 const struct auto_pin_cfg *cfg)
1755 static const char *chname[4] = {
1756 "Front", "Surround", NULL /*CLFE*/, "Side"
1761 struct sigmatel_spec *spec = codec->spec;
1762 unsigned int wid_caps;
1765 for (i = 0; i < cfg->line_outs; i++) {
1766 if (!spec->multiout.dac_nids[i])
1769 nid = spec->multiout.dac_nids[i];
1773 err = create_controls(spec, "Center", nid, 1);
1776 err = create_controls(spec, "LFE", nid, 2);
1780 wid_caps = get_wcaps(codec, nid);
1782 if (wid_caps & AC_WCAP_LR_SWAP) {
1783 err = stac92xx_add_control(spec,
1784 STAC_CTL_WIDGET_CLFE_SWITCH,
1785 "Swap Center/LFE Playback Switch", nid);
1792 err = create_controls(spec, chname[i], nid, 3);
1798 if (spec->line_switch)
1799 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1802 if (spec->mic_switch)
1803 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1809 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1811 if (is_in_dac_nids(spec, nid))
1813 if (spec->multiout.hp_nid == nid)
1818 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1820 if (!spec->multiout.hp_nid)
1821 spec->multiout.hp_nid = nid;
1822 else if (spec->multiout.num_dacs > 4) {
1823 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1826 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1827 spec->multiout.num_dacs++;
1832 /* add playback controls for Speaker and HP outputs */
1833 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1834 struct auto_pin_cfg *cfg)
1836 struct sigmatel_spec *spec = codec->spec;
1838 int i, old_num_dacs, err;
1840 old_num_dacs = spec->multiout.num_dacs;
1841 for (i = 0; i < cfg->hp_outs; i++) {
1842 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1843 if (wid_caps & AC_WCAP_UNSOL_CAP)
1844 spec->hp_detect = 1;
1845 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1846 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1847 if (check_in_dac_nids(spec, nid))
1851 add_spec_dacs(spec, nid);
1853 for (i = 0; i < cfg->speaker_outs; i++) {
1854 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1855 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1856 if (check_in_dac_nids(spec, nid))
1860 add_spec_dacs(spec, nid);
1862 for (i = 0; i < cfg->line_outs; i++) {
1863 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
1864 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1865 if (check_in_dac_nids(spec, nid))
1869 add_spec_dacs(spec, nid);
1871 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1872 static const char *pfxs[] = {
1873 "Speaker", "External Speaker", "Speaker2",
1875 err = create_controls(spec, pfxs[i - old_num_dacs],
1876 spec->multiout.dac_nids[i], 3);
1880 if (spec->multiout.hp_nid) {
1882 if (old_num_dacs == spec->multiout.num_dacs)
1886 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
1894 /* labels for dmic mux inputs */
1895 static const char *stac92xx_dmic_labels[5] = {
1896 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1897 "Digital Mic 3", "Digital Mic 4"
1900 /* create playback/capture controls for input pins on dmic capable codecs */
1901 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1902 const struct auto_pin_cfg *cfg)
1904 struct sigmatel_spec *spec = codec->spec;
1905 struct hda_input_mux *dimux = &spec->private_dimux;
1906 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1909 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1910 dimux->items[dimux->num_items].index = 0;
1913 for (i = 0; i < spec->num_dmics; i++) {
1916 unsigned int def_conf;
1918 def_conf = snd_hda_codec_read(codec,
1921 AC_VERB_GET_CONFIG_DEFAULT,
1923 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1926 num_cons = snd_hda_get_connections(codec,
1929 HDA_MAX_NUM_INPUTS);
1930 for (j = 0; j < num_cons; j++)
1931 if (con_lst[j] == spec->dmic_nids[i]) {
1937 dimux->items[dimux->num_items].label =
1938 stac92xx_dmic_labels[dimux->num_items];
1939 dimux->items[dimux->num_items].index = index;
1946 /* create playback/capture controls for input pins */
1947 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1949 struct sigmatel_spec *spec = codec->spec;
1950 struct hda_input_mux *imux = &spec->private_imux;
1951 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1954 for (i = 0; i < AUTO_PIN_LAST; i++) {
1957 if (!cfg->input_pins[i])
1960 for (j = 0; j < spec->num_muxes; j++) {
1962 num_cons = snd_hda_get_connections(codec,
1965 HDA_MAX_NUM_INPUTS);
1966 for (k = 0; k < num_cons; k++)
1967 if (con_lst[k] == cfg->input_pins[i]) {
1974 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1975 imux->items[imux->num_items].index = index;
1979 if (imux->num_items) {
1981 * Set the current input for the muxes.
1982 * The STAC9221 has two input muxes with identical source
1983 * NID lists. Hopefully this won't get confused.
1985 for (i = 0; i < spec->num_muxes; i++) {
1986 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
1987 AC_VERB_SET_CONNECT_SEL,
1988 imux->items[0].index);
1995 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1997 struct sigmatel_spec *spec = codec->spec;
2000 for (i = 0; i < spec->autocfg.line_outs; i++) {
2001 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2002 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2006 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2008 struct sigmatel_spec *spec = codec->spec;
2011 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2013 pin = spec->autocfg.hp_pins[i];
2014 if (pin) /* connect to front */
2015 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2017 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2019 pin = spec->autocfg.speaker_pins[i];
2020 if (pin) /* connect to front */
2021 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2025 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2027 struct sigmatel_spec *spec = codec->spec;
2030 if ((err = snd_hda_parse_pin_def_config(codec,
2032 spec->dmic_nids)) < 0)
2034 if (! spec->autocfg.line_outs)
2035 return 0; /* can't find valid pin config */
2037 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2039 if (spec->multiout.num_dacs == 0)
2040 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2043 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2048 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2053 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2058 if (spec->num_dmics > 0)
2059 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2060 &spec->autocfg)) < 0)
2063 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2064 if (spec->multiout.max_channels > 2)
2065 spec->surr_switch = 1;
2067 if (spec->autocfg.dig_out_pin)
2068 spec->multiout.dig_out_nid = dig_out;
2069 if (spec->autocfg.dig_in_pin)
2070 spec->dig_in_nid = dig_in;
2072 if (spec->kctl_alloc)
2073 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2075 spec->input_mux = &spec->private_imux;
2076 spec->dinput_mux = &spec->private_dimux;
2081 /* add playback controls for HP output */
2082 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2083 struct auto_pin_cfg *cfg)
2085 struct sigmatel_spec *spec = codec->spec;
2086 hda_nid_t pin = cfg->hp_pins[0];
2087 unsigned int wid_caps;
2092 wid_caps = get_wcaps(codec, pin);
2093 if (wid_caps & AC_WCAP_UNSOL_CAP)
2094 spec->hp_detect = 1;
2099 /* add playback controls for LFE output */
2100 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2101 struct auto_pin_cfg *cfg)
2103 struct sigmatel_spec *spec = codec->spec;
2105 hda_nid_t lfe_pin = 0x0;
2109 * search speaker outs and line outs for a mono speaker pin
2110 * with an amp. If one is found, add LFE controls
2113 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2114 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2115 unsigned long wcaps = get_wcaps(codec, pin);
2116 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2117 if (wcaps == AC_WCAP_OUT_AMP)
2118 /* found a mono speaker with an amp, must be lfe */
2122 /* if speaker_outs is 0, then speakers may be in line_outs */
2123 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2124 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2125 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2127 cfg = snd_hda_codec_read(codec, pin, 0,
2128 AC_VERB_GET_CONFIG_DEFAULT,
2130 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
2131 unsigned long wcaps = get_wcaps(codec, pin);
2132 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2133 if (wcaps == AC_WCAP_OUT_AMP)
2134 /* found a mono speaker with an amp,
2142 err = create_controls(spec, "LFE", lfe_pin, 1);
2150 static int stac9200_parse_auto_config(struct hda_codec *codec)
2152 struct sigmatel_spec *spec = codec->spec;
2155 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2158 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2161 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2164 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2167 if (spec->autocfg.dig_out_pin)
2168 spec->multiout.dig_out_nid = 0x05;
2169 if (spec->autocfg.dig_in_pin)
2170 spec->dig_in_nid = 0x04;
2172 if (spec->kctl_alloc)
2173 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2175 spec->input_mux = &spec->private_imux;
2176 spec->dinput_mux = &spec->private_dimux;
2182 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2183 * funky external mute control using GPIO pins.
2186 static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
2188 unsigned int gpiostate, gpiomask, gpiodir;
2190 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
2191 AC_VERB_GET_GPIO_DATA, 0);
2194 gpiostate |= (1 << pin);
2196 gpiostate &= ~(1 << pin);
2198 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
2199 AC_VERB_GET_GPIO_MASK, 0);
2200 gpiomask |= (1 << pin);
2202 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
2203 AC_VERB_GET_GPIO_DIRECTION, 0);
2204 gpiodir |= (1 << pin);
2206 /* AppleHDA seems to do this -- WTF is this verb?? */
2207 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
2209 snd_hda_codec_write(codec, codec->afg, 0,
2210 AC_VERB_SET_GPIO_MASK, gpiomask);
2211 snd_hda_codec_write(codec, codec->afg, 0,
2212 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
2216 snd_hda_codec_write(codec, codec->afg, 0,
2217 AC_VERB_SET_GPIO_DATA, gpiostate);
2220 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2223 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
2224 snd_hda_codec_write_cache(codec, nid, 0,
2225 AC_VERB_SET_UNSOLICITED_ENABLE,
2226 (AC_USRSP_EN | event));
2229 static int stac92xx_init(struct hda_codec *codec)
2231 struct sigmatel_spec *spec = codec->spec;
2232 struct auto_pin_cfg *cfg = &spec->autocfg;
2235 snd_hda_sequence_write(codec, spec->init);
2238 if (spec->hp_detect) {
2239 /* Enable unsolicited responses on the HP widget */
2240 for (i = 0; i < cfg->hp_outs; i++)
2241 enable_pin_detect(codec, cfg->hp_pins[i],
2243 /* force to enable the first line-out; the others are set up
2246 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
2248 stac92xx_auto_init_hp_out(codec);
2249 /* fake event to set up pins */
2250 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2252 stac92xx_auto_init_multi_out(codec);
2253 stac92xx_auto_init_hp_out(codec);
2255 for (i = 0; i < AUTO_PIN_LAST; i++) {
2256 hda_nid_t nid = cfg->input_pins[i];
2258 unsigned int pinctl = AC_PINCTL_IN_EN;
2259 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
2260 pinctl |= stac92xx_get_vref(codec, nid);
2261 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2264 if (spec->num_dmics > 0)
2265 for (i = 0; i < spec->num_dmics; i++)
2266 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
2269 if (cfg->dig_out_pin)
2270 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
2272 if (cfg->dig_in_pin)
2273 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
2276 if (spec->gpio_mute) {
2277 stac922x_gpio_mute(codec, 0, 0);
2278 stac922x_gpio_mute(codec, 1, 0);
2284 static void stac92xx_free(struct hda_codec *codec)
2286 struct sigmatel_spec *spec = codec->spec;
2292 if (spec->kctl_alloc) {
2293 for (i = 0; i < spec->num_kctl_used; i++)
2294 kfree(spec->kctl_alloc[i].name);
2295 kfree(spec->kctl_alloc);
2298 if (spec->bios_pin_configs)
2299 kfree(spec->bios_pin_configs);
2304 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
2307 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2308 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2310 if (pin_ctl & AC_PINCTL_IN_EN) {
2312 * we need to check the current set-up direction of
2313 * shared input pins since they can be switched via
2314 * "xxx as Output" mixer switch
2316 struct sigmatel_spec *spec = codec->spec;
2317 struct auto_pin_cfg *cfg = &spec->autocfg;
2318 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
2319 spec->line_switch) ||
2320 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
2325 /* if setting pin direction bits, clear the current
2326 direction bits first */
2327 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
2328 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
2330 snd_hda_codec_write_cache(codec, nid, 0,
2331 AC_VERB_SET_PIN_WIDGET_CONTROL,
2335 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
2338 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2339 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2340 snd_hda_codec_write_cache(codec, nid, 0,
2341 AC_VERB_SET_PIN_WIDGET_CONTROL,
2345 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
2349 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
2355 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
2357 struct sigmatel_spec *spec = codec->spec;
2358 struct auto_pin_cfg *cfg = &spec->autocfg;
2362 for (i = 0; i < cfg->hp_outs; i++) {
2363 presence = get_pin_presence(codec, cfg->hp_pins[i]);
2369 /* disable lineouts, enable hp */
2370 for (i = 0; i < cfg->line_outs; i++)
2371 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
2373 for (i = 0; i < cfg->speaker_outs; i++)
2374 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2377 /* enable lineouts, disable hp */
2378 for (i = 0; i < cfg->line_outs; i++)
2379 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
2381 for (i = 0; i < cfg->speaker_outs; i++)
2382 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2387 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
2389 switch (res >> 26) {
2391 stac92xx_hp_detect(codec, res);
2396 #ifdef SND_HDA_NEEDS_RESUME
2397 static int stac92xx_resume(struct hda_codec *codec)
2399 struct sigmatel_spec *spec = codec->spec;
2401 stac92xx_set_config_regs(codec);
2402 snd_hda_sequence_write(codec, spec->init);
2403 if (spec->gpio_mute) {
2404 stac922x_gpio_mute(codec, 0, 0);
2405 stac922x_gpio_mute(codec, 1, 0);
2407 snd_hda_codec_resume_amp(codec);
2408 snd_hda_codec_resume_cache(codec);
2409 /* invoke unsolicited event to reset the HP state */
2410 if (spec->hp_detect)
2411 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2416 static struct hda_codec_ops stac92xx_patch_ops = {
2417 .build_controls = stac92xx_build_controls,
2418 .build_pcms = stac92xx_build_pcms,
2419 .init = stac92xx_init,
2420 .free = stac92xx_free,
2421 .unsol_event = stac92xx_unsol_event,
2422 #ifdef SND_HDA_NEEDS_RESUME
2423 .resume = stac92xx_resume,
2427 static int patch_stac9200(struct hda_codec *codec)
2429 struct sigmatel_spec *spec;
2432 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2437 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
2438 spec->pin_nids = stac9200_pin_nids;
2439 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
2442 if (spec->board_config < 0) {
2443 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
2444 err = stac92xx_save_bios_config_regs(codec);
2446 stac92xx_free(codec);
2449 spec->pin_configs = spec->bios_pin_configs;
2451 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
2452 stac92xx_set_config_regs(codec);
2455 spec->multiout.max_channels = 2;
2456 spec->multiout.num_dacs = 1;
2457 spec->multiout.dac_nids = stac9200_dac_nids;
2458 spec->adc_nids = stac9200_adc_nids;
2459 spec->mux_nids = stac9200_mux_nids;
2460 spec->num_muxes = 1;
2461 spec->num_dmics = 0;
2464 if (spec->board_config == STAC_9200_GATEWAY)
2465 spec->init = stac9200_eapd_init;
2467 spec->init = stac9200_core_init;
2468 spec->mixer = stac9200_mixer;
2470 err = stac9200_parse_auto_config(codec);
2472 stac92xx_free(codec);
2476 codec->patch_ops = stac92xx_patch_ops;
2481 static int patch_stac925x(struct hda_codec *codec)
2483 struct sigmatel_spec *spec;
2486 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2491 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
2492 spec->pin_nids = stac925x_pin_nids;
2493 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
2497 if (spec->board_config < 0) {
2498 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2499 "using BIOS defaults\n");
2500 err = stac92xx_save_bios_config_regs(codec);
2502 stac92xx_free(codec);
2505 spec->pin_configs = spec->bios_pin_configs;
2506 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
2507 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
2508 stac92xx_set_config_regs(codec);
2511 spec->multiout.max_channels = 2;
2512 spec->multiout.num_dacs = 1;
2513 spec->multiout.dac_nids = stac925x_dac_nids;
2514 spec->adc_nids = stac925x_adc_nids;
2515 spec->mux_nids = stac925x_mux_nids;
2516 spec->num_muxes = 1;
2518 switch (codec->vendor_id) {
2519 case 0x83847632: /* STAC9202 */
2520 case 0x83847633: /* STAC9202D */
2521 case 0x83847636: /* STAC9251 */
2522 case 0x83847637: /* STAC9251D */
2523 spec->num_dmics = STAC925X_NUM_DMICS;
2524 spec->dmic_nids = stac925x_dmic_nids;
2527 spec->num_dmics = 0;
2531 spec->init = stac925x_core_init;
2532 spec->mixer = stac925x_mixer;
2534 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
2536 if (spec->board_config < 0) {
2537 printk(KERN_WARNING "hda_codec: No auto-config is "
2538 "available, default to model=ref\n");
2539 spec->board_config = STAC_925x_REF;
2545 stac92xx_free(codec);
2549 codec->patch_ops = stac92xx_patch_ops;
2554 static int patch_stac922x(struct hda_codec *codec)
2556 struct sigmatel_spec *spec;
2559 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2564 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
2565 spec->pin_nids = stac922x_pin_nids;
2566 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2569 if (spec->board_config == STAC_INTEL_MAC_V3) {
2570 spec->gpio_mute = 1;
2571 /* Intel Macs have all same PCI SSID, so we need to check
2572 * codec SSID to distinguish the exact models
2574 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
2575 switch (codec->subsystem_id) {
2578 spec->board_config = STAC_INTEL_MAC_V1;
2582 spec->board_config = STAC_INTEL_MAC_V2;
2590 spec->board_config = STAC_INTEL_MAC_V3;
2594 spec->board_config = STAC_INTEL_MAC_V4;
2598 spec->board_config = STAC_INTEL_MAC_V5;
2604 if (spec->board_config < 0) {
2605 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2606 "using BIOS defaults\n");
2607 err = stac92xx_save_bios_config_regs(codec);
2609 stac92xx_free(codec);
2612 spec->pin_configs = spec->bios_pin_configs;
2613 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
2614 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2615 stac92xx_set_config_regs(codec);
2618 spec->adc_nids = stac922x_adc_nids;
2619 spec->mux_nids = stac922x_mux_nids;
2620 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
2621 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
2622 spec->num_dmics = 0;
2624 spec->init = stac922x_core_init;
2625 spec->mixer = stac922x_mixer;
2627 spec->multiout.dac_nids = spec->dac_nids;
2629 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
2631 if (spec->board_config < 0) {
2632 printk(KERN_WARNING "hda_codec: No auto-config is "
2633 "available, default to model=ref\n");
2634 spec->board_config = STAC_D945_REF;
2640 stac92xx_free(codec);
2644 codec->patch_ops = stac92xx_patch_ops;
2646 /* Fix Mux capture level; max to 2 */
2647 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2648 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2649 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2650 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2651 (0 << AC_AMPCAP_MUTE_SHIFT));
2656 static int patch_stac927x(struct hda_codec *codec)
2658 struct sigmatel_spec *spec;
2661 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2666 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
2667 spec->pin_nids = stac927x_pin_nids;
2668 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2672 if (spec->board_config < 0) {
2673 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
2674 err = stac92xx_save_bios_config_regs(codec);
2676 stac92xx_free(codec);
2679 spec->pin_configs = spec->bios_pin_configs;
2680 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
2681 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2682 stac92xx_set_config_regs(codec);
2685 switch (spec->board_config) {
2687 spec->adc_nids = stac927x_adc_nids;
2688 spec->mux_nids = stac927x_mux_nids;
2689 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2690 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2691 spec->num_dmics = 0;
2692 spec->init = d965_core_init;
2693 spec->mixer = stac927x_mixer;
2696 spec->adc_nids = stac927x_adc_nids;
2697 spec->mux_nids = stac927x_mux_nids;
2698 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2699 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2700 spec->num_dmics = 0;
2701 spec->init = d965_core_init;
2702 spec->mixer = stac927x_mixer;
2705 spec->adc_nids = stac927x_adc_nids;
2706 spec->mux_nids = stac927x_mux_nids;
2707 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2708 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2709 spec->num_dmics = 0;
2710 spec->init = stac927x_core_init;
2711 spec->mixer = stac927x_mixer;
2714 spec->multiout.dac_nids = spec->dac_nids;
2715 /* GPIO0 High = Enable EAPD */
2716 spec->gpio_mask = spec->gpio_data = 0x00000001;
2717 stac92xx_enable_gpio_mask(codec);
2719 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
2721 if (spec->board_config < 0) {
2722 printk(KERN_WARNING "hda_codec: No auto-config is "
2723 "available, default to model=ref\n");
2724 spec->board_config = STAC_D965_REF;
2730 stac92xx_free(codec);
2734 codec->patch_ops = stac92xx_patch_ops;
2739 static int patch_stac9205(struct hda_codec *codec)
2741 struct sigmatel_spec *spec;
2744 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2749 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
2750 spec->pin_nids = stac9205_pin_nids;
2751 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2755 if (spec->board_config < 0) {
2756 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2757 err = stac92xx_save_bios_config_regs(codec);
2759 stac92xx_free(codec);
2762 spec->pin_configs = spec->bios_pin_configs;
2764 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
2765 stac92xx_set_config_regs(codec);
2768 spec->adc_nids = stac9205_adc_nids;
2769 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
2770 spec->mux_nids = stac9205_mux_nids;
2771 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2772 spec->dmic_nids = stac9205_dmic_nids;
2773 spec->num_dmics = STAC9205_NUM_DMICS;
2774 spec->dmux_nid = 0x1d;
2776 spec->init = stac9205_core_init;
2777 spec->mixer = stac9205_mixer;
2779 spec->multiout.dac_nids = spec->dac_nids;
2781 switch (spec->board_config){
2782 case STAC_9205_DELL_M43:
2783 /* Enable SPDIF in/out */
2784 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
2785 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
2787 spec->gpio_mask = 0x00000007; /* GPIO0-2 */
2788 /* GPIO0 High = EAPD, GPIO1 Low = DRM,
2789 * GPIO2 High = Headphone Mute
2791 spec->gpio_data = 0x00000005;
2794 /* GPIO0 High = EAPD */
2795 spec->gpio_mask = spec->gpio_data = 0x00000001;
2799 stac92xx_enable_gpio_mask(codec);
2800 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
2802 if (spec->board_config < 0) {
2803 printk(KERN_WARNING "hda_codec: No auto-config is "
2804 "available, default to model=ref\n");
2805 spec->board_config = STAC_9205_REF;
2811 stac92xx_free(codec);
2815 codec->patch_ops = stac92xx_patch_ops;
2824 /* static config for Sony VAIO FE550G and Sony VAIO AR */
2825 static hda_nid_t vaio_dacs[] = { 0x2 };
2826 #define VAIO_HP_DAC 0x5
2827 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
2828 static hda_nid_t vaio_mux_nids[] = { 0x15 };
2830 static struct hda_input_mux vaio_mux = {
2833 /* { "HP", 0x0 }, */
2834 { "Mic Jack", 0x1 },
2835 { "Internal Mic", 0x2 },
2840 static struct hda_verb vaio_init[] = {
2841 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2842 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
2843 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2844 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2845 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2846 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2847 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2848 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2849 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2850 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2852 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2856 static struct hda_verb vaio_ar_init[] = {
2857 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2858 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2859 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2860 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2861 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2862 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2863 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2864 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2865 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2866 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2867 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2868 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2869 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2873 /* bind volumes of both NID 0x02 and 0x05 */
2874 static struct hda_bind_ctls vaio_bind_master_vol = {
2875 .ops = &snd_hda_bind_vol,
2877 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2878 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2883 /* bind volumes of both NID 0x02 and 0x05 */
2884 static struct hda_bind_ctls vaio_bind_master_sw = {
2885 .ops = &snd_hda_bind_sw,
2887 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2888 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2893 static struct snd_kcontrol_new vaio_mixer[] = {
2894 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2895 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2896 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2897 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2898 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2901 .name = "Capture Source",
2903 .info = stac92xx_mux_enum_info,
2904 .get = stac92xx_mux_enum_get,
2905 .put = stac92xx_mux_enum_put,
2910 static struct snd_kcontrol_new vaio_ar_mixer[] = {
2911 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2912 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2913 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2914 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2915 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2916 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2917 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2919 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2920 .name = "Capture Source",
2922 .info = stac92xx_mux_enum_info,
2923 .get = stac92xx_mux_enum_get,
2924 .put = stac92xx_mux_enum_put,
2929 static struct hda_codec_ops stac9872_patch_ops = {
2930 .build_controls = stac92xx_build_controls,
2931 .build_pcms = stac92xx_build_pcms,
2932 .init = stac92xx_init,
2933 .free = stac92xx_free,
2934 #ifdef SND_HDA_NEEDS_RESUME
2935 .resume = stac92xx_resume,
2939 static int stac9872_vaio_init(struct hda_codec *codec)
2943 err = stac92xx_init(codec);
2946 if (codec->patch_ops.unsol_event)
2947 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2951 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
2953 if (get_pin_presence(codec, 0x0a)) {
2954 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
2955 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
2957 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
2958 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
2962 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
2964 switch (res >> 26) {
2966 stac9872_vaio_hp_detect(codec, res);
2971 static struct hda_codec_ops stac9872_vaio_patch_ops = {
2972 .build_controls = stac92xx_build_controls,
2973 .build_pcms = stac92xx_build_pcms,
2974 .init = stac9872_vaio_init,
2975 .free = stac92xx_free,
2976 .unsol_event = stac9872_vaio_unsol_event,
2978 .resume = stac92xx_resume,
2982 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2984 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2986 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2988 /* AR Series. id=0x83847664 and subsys=104D1300 */
2993 static const char *stac9872_models[STAC_9872_MODELS] = {
2994 [CXD9872RD_VAIO] = "vaio",
2995 [CXD9872AKD_VAIO] = "vaio-ar",
2998 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2999 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
3000 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
3001 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
3002 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
3006 static int patch_stac9872(struct hda_codec *codec)
3008 struct sigmatel_spec *spec;
3011 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
3014 if (board_config < 0)
3015 /* unknown config, let generic-parser do its job... */
3016 return snd_hda_parse_generic_codec(codec);
3018 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3023 switch (board_config) {
3024 case CXD9872RD_VAIO:
3025 case STAC9872AK_VAIO:
3026 case STAC9872K_VAIO:
3027 spec->mixer = vaio_mixer;
3028 spec->init = vaio_init;
3029 spec->multiout.max_channels = 2;
3030 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
3031 spec->multiout.dac_nids = vaio_dacs;
3032 spec->multiout.hp_nid = VAIO_HP_DAC;
3033 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3034 spec->adc_nids = vaio_adcs;
3035 spec->input_mux = &vaio_mux;
3036 spec->mux_nids = vaio_mux_nids;
3037 codec->patch_ops = stac9872_vaio_patch_ops;
3040 case CXD9872AKD_VAIO:
3041 spec->mixer = vaio_ar_mixer;
3042 spec->init = vaio_ar_init;
3043 spec->multiout.max_channels = 2;
3044 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
3045 spec->multiout.dac_nids = vaio_dacs;
3046 spec->multiout.hp_nid = VAIO_HP_DAC;
3047 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3048 spec->adc_nids = vaio_adcs;
3049 spec->input_mux = &vaio_mux;
3050 spec->mux_nids = vaio_mux_nids;
3051 codec->patch_ops = stac9872_patch_ops;
3062 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
3063 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
3064 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
3065 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
3066 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
3067 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
3068 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
3069 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
3070 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
3071 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
3072 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
3073 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
3074 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
3075 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
3076 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
3077 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
3078 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
3079 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
3080 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
3081 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
3082 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
3083 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
3084 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
3085 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
3086 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
3087 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
3088 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
3089 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
3090 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
3091 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
3092 /* The following does not take into account .id=0x83847661 when subsys =
3093 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
3094 * currently not fully supported.
3096 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
3097 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
3098 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
3099 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
3100 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
3101 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
3102 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
3103 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
3104 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
3105 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
3106 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },