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];
150 struct hda_pcm pcm_rec[2]; /* PCM information */
152 /* dynamic controls and input_mux */
153 struct auto_pin_cfg autocfg;
154 unsigned int num_kctl_alloc, num_kctl_used;
155 struct snd_kcontrol_new *kctl_alloc;
156 struct hda_input_mux private_dimux;
157 struct hda_input_mux private_imux;
160 static hda_nid_t stac9200_adc_nids[1] = {
164 static hda_nid_t stac9200_mux_nids[1] = {
168 static hda_nid_t stac9200_dac_nids[1] = {
172 static hda_nid_t stac925x_adc_nids[1] = {
176 static hda_nid_t stac925x_mux_nids[1] = {
180 static hda_nid_t stac925x_dac_nids[1] = {
184 static hda_nid_t stac925x_dmic_nids[1] = {
188 static hda_nid_t stac922x_adc_nids[2] = {
192 static hda_nid_t stac922x_mux_nids[2] = {
196 static hda_nid_t stac927x_adc_nids[3] = {
200 static hda_nid_t stac927x_mux_nids[3] = {
204 static hda_nid_t stac9205_adc_nids[2] = {
208 static hda_nid_t stac9205_mux_nids[2] = {
212 static hda_nid_t stac9205_dmic_nids[2] = {
216 static hda_nid_t stac9200_pin_nids[8] = {
217 0x08, 0x09, 0x0d, 0x0e,
218 0x0f, 0x10, 0x11, 0x12,
221 static hda_nid_t stac925x_pin_nids[8] = {
222 0x07, 0x08, 0x0a, 0x0b,
223 0x0c, 0x0d, 0x10, 0x11,
226 static hda_nid_t stac922x_pin_nids[10] = {
227 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
228 0x0f, 0x10, 0x11, 0x15, 0x1b,
231 static hda_nid_t stac927x_pin_nids[14] = {
232 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
233 0x0f, 0x10, 0x11, 0x12, 0x13,
234 0x14, 0x21, 0x22, 0x23,
237 static hda_nid_t stac9205_pin_nids[12] = {
238 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
239 0x0f, 0x14, 0x16, 0x17, 0x18,
243 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
244 struct snd_ctl_elem_info *uinfo)
246 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
247 struct sigmatel_spec *spec = codec->spec;
248 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
251 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
252 struct snd_ctl_elem_value *ucontrol)
254 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
255 struct sigmatel_spec *spec = codec->spec;
257 ucontrol->value.enumerated.item[0] = spec->cur_dmux;
261 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
262 struct snd_ctl_elem_value *ucontrol)
264 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
265 struct sigmatel_spec *spec = codec->spec;
267 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
268 spec->dmux_nid, &spec->cur_dmux);
271 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
273 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
274 struct sigmatel_spec *spec = codec->spec;
275 return snd_hda_input_mux_info(spec->input_mux, uinfo);
278 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
280 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
281 struct sigmatel_spec *spec = codec->spec;
282 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
284 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
288 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
290 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
291 struct sigmatel_spec *spec = codec->spec;
292 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
294 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
295 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
298 static struct hda_verb stac9200_core_init[] = {
299 /* set dac0mux for dac converter */
300 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
304 static struct hda_verb stac925x_core_init[] = {
305 /* set dac0mux for dac converter */
306 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
310 static struct hda_verb stac922x_core_init[] = {
311 /* set master volume and direct control */
312 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
316 static struct hda_verb d965_core_init[] = {
317 /* set master volume and direct control */
318 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
319 /* unmute node 0x1b */
320 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
321 /* select node 0x03 as DAC */
322 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
326 static struct hda_verb stac927x_core_init[] = {
327 /* set master volume and direct control */
328 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
332 static struct hda_verb stac9205_core_init[] = {
333 /* set master volume and direct control */
334 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
338 #define STAC_INPUT_SOURCE \
340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
341 .name = "Input Source", \
343 .info = stac92xx_mux_enum_info, \
344 .get = stac92xx_mux_enum_get, \
345 .put = stac92xx_mux_enum_put, \
349 static struct snd_kcontrol_new stac9200_mixer[] = {
350 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
351 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
353 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
354 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
355 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
359 static struct snd_kcontrol_new stac925x_mixer[] = {
361 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
362 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
363 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
367 /* This needs to be generated dynamically based on sequence */
368 static struct snd_kcontrol_new stac922x_mixer[] = {
370 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
371 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
372 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
376 /* This needs to be generated dynamically based on sequence */
377 static struct snd_kcontrol_new stac9227_mixer[] = {
379 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
380 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
384 static struct snd_kcontrol_new stac927x_mixer[] = {
386 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
387 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
388 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
392 static struct snd_kcontrol_new stac9205_mixer[] = {
394 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
395 .name = "Digital Input Source",
397 .info = stac92xx_dmux_enum_info,
398 .get = stac92xx_dmux_enum_get,
399 .put = stac92xx_dmux_enum_put,
402 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
403 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
404 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
408 static int stac92xx_build_controls(struct hda_codec *codec)
410 struct sigmatel_spec *spec = codec->spec;
414 err = snd_hda_add_new_ctls(codec, spec->mixer);
418 for (i = 0; i < spec->num_mixers; i++) {
419 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
424 if (spec->multiout.dig_out_nid) {
425 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
429 if (spec->dig_in_nid) {
430 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
437 static unsigned int ref9200_pin_configs[8] = {
438 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
439 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
443 STAC 9200 pin configs for
448 static unsigned int dell9200_d21_pin_configs[8] = {
449 0x400001f0, 0x400001f1, 0x01a19021, 0x90100140,
450 0x01813122, 0x02214030, 0x01014010, 0x02a19020,
454 STAC 9200 pin configs for
458 static unsigned int dell9200_d22_pin_configs[8] = {
459 0x400001f0, 0x400001f1, 0x02a19021, 0x90100140,
460 0x400001f2, 0x0221401f, 0x01014010, 0x01813020,
464 STAC 9200 pin configs for
465 102801C4 (Dell Dimension E310)
472 static unsigned int dell9200_d23_pin_configs[8] = {
473 0x400001f0, 0x400001f1, 0x01a19021, 0x90100140,
474 0x400001f2, 0x0221401f, 0x01014010, 0x01813020,
479 STAC 9200-32 pin configs for
480 102801B5 (Dell Inspiron 630m)
481 102801D8 (Dell Inspiron 640m)
483 static unsigned int dell9200_m21_pin_configs[8] = {
484 0x40c003fa, 0x03441340, 0x03a11020, 0x401003fc,
485 0x403003fd, 0x0321121f, 0x0321121f, 0x408003fb,
489 STAC 9200-32 pin configs for
490 102801C2 (Dell Latitude D620)
492 102801CC (Dell Latitude D820)
496 static unsigned int dell9200_m22_pin_configs[8] = {
497 0x40c003fa, 0x0144131f, 0x03A11020, 0x401003fb,
498 0x40f000fc, 0x0321121f, 0x90170310, 0x90a70321,
502 STAC 9200-32 pin configs for
503 102801CE (Dell XPS M1710)
504 102801CF (Dell Precision M90)
506 static unsigned int dell9200_m23_pin_configs[8] = {
507 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
508 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
512 STAC 9200-32 pin configs for
515 102801CB (Dell Latitude 120L)
518 static unsigned int dell9200_m24_pin_configs[8] = {
519 0x40c003fa, 0x404003fb, 0x03a11020, 0x401003fd,
520 0x403003fe, 0x0321121f, 0x90170310, 0x408003fc,
524 STAC 9200-32 pin configs for
525 102801BD (Dell Inspiron E1505n)
529 static unsigned int dell9200_m25_pin_configs[8] = {
530 0x40c003fa, 0x01441340, 0x04a11020, 0x401003fc,
531 0x403003fd, 0x0421121f, 0x90170310, 0x408003fb,
535 STAC 9200-32 pin configs for
536 102801F5 (Dell Inspiron 1501)
539 static unsigned int dell9200_m26_pin_configs[8] = {
540 0x40c003fa, 0x404003fb, 0x04a11020, 0x401003fd,
541 0x403003fe, 0x0421121f, 0x90170310, 0x408003fc,
546 102801CD (Dell Inspiron E1705/9400)
548 static unsigned int dell9200_m27_pin_configs[8] = {
549 0x40c003fa, 0x01441340, 0x04a11020, 0x90170310,
550 0x40f003fc, 0x0421121f, 0x90170310, 0x408003fb,
554 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
555 [STAC_REF] = ref9200_pin_configs,
556 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
557 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
558 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
559 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
560 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
561 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
562 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
563 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
564 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
565 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
568 static const char *stac9200_models[STAC_9200_MODELS] = {
570 [STAC_9200_DELL_D21] = "dell-d21",
571 [STAC_9200_DELL_D22] = "dell-d22",
572 [STAC_9200_DELL_D23] = "dell-d23",
573 [STAC_9200_DELL_M21] = "dell-m21",
574 [STAC_9200_DELL_M22] = "dell-m22",
575 [STAC_9200_DELL_M23] = "dell-m23",
576 [STAC_9200_DELL_M24] = "dell-m24",
577 [STAC_9200_DELL_M25] = "dell-m25",
578 [STAC_9200_DELL_M26] = "dell-m26",
579 [STAC_9200_DELL_M27] = "dell-m27",
582 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
583 /* SigmaTel reference board */
584 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
585 "DFI LanParty", STAC_REF),
586 /* Dell laptops have BIOS problem */
587 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
588 "unknown Dell", STAC_9200_DELL_D21),
589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
590 "Dell Inspiron 630m", STAC_9200_DELL_M21),
591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
592 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
594 "unknown Dell", STAC_9200_DELL_D22),
595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
596 "unknown Dell", STAC_9200_DELL_D22),
597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
598 "Dell Latitude D620", STAC_9200_DELL_M22),
599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
600 "unknown Dell", STAC_9200_DELL_D23),
601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
602 "unknown Dell", STAC_9200_DELL_D23),
603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
604 "unknown Dell", STAC_9200_DELL_M22),
605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
606 "unknown Dell", STAC_9200_DELL_M24),
607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
608 "unknown Dell", STAC_9200_DELL_M24),
609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
610 "Dell Latitude 120L", STAC_9200_DELL_M24),
611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
612 "Dell Latitude D820", STAC_9200_DELL_M22),
613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
614 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
615 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
616 "Dell XPS M1710", STAC_9200_DELL_M23),
617 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
618 "Dell Precision M90", STAC_9200_DELL_M23),
619 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
620 "unknown Dell", STAC_9200_DELL_M22),
621 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
622 "unknown Dell", STAC_9200_DELL_M22),
623 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
624 "unknown Dell", STAC_9200_DELL_M22),
625 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
626 "Dell Inspiron 640m", STAC_9200_DELL_M21),
627 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
628 "unknown Dell", STAC_9200_DELL_D23),
629 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
630 "unknown Dell", STAC_9200_DELL_D23),
631 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
632 "unknown Dell", STAC_9200_DELL_D21),
633 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
634 "unknown Dell", STAC_9200_DELL_D23),
635 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
636 "unknown Dell", STAC_9200_DELL_D21),
637 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
638 "unknown Dell", STAC_9200_DELL_M25),
639 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
640 "unknown Dell", STAC_9200_DELL_M25),
641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
642 "Dell Inspiron 1501", STAC_9200_DELL_M26),
643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
644 "unknown Dell", STAC_9200_DELL_M26),
646 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
651 static unsigned int ref925x_pin_configs[8] = {
652 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
653 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
656 static unsigned int stac925x_MA6_pin_configs[8] = {
657 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
658 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
661 static unsigned int stac925x_PA6_pin_configs[8] = {
662 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
663 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
666 static unsigned int stac925xM2_2_pin_configs[8] = {
667 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
668 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
671 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
672 [STAC_REF] = ref925x_pin_configs,
673 [STAC_M2_2] = stac925xM2_2_pin_configs,
674 [STAC_MA6] = stac925x_MA6_pin_configs,
675 [STAC_PA6] = stac925x_PA6_pin_configs,
678 static const char *stac925x_models[STAC_925x_MODELS] = {
680 [STAC_M2_2] = "m2-2",
685 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
686 /* SigmaTel reference board */
687 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
688 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
689 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
690 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
691 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
692 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
693 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
697 static unsigned int ref922x_pin_configs[10] = {
698 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
699 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
700 0x40000100, 0x40000100,
704 STAC 922X pin configs for
711 static unsigned int dell_922x_d81_pin_configs[10] = {
712 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
713 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
714 0x01813122, 0x400001f2,
718 STAC 922X pin configs for
722 static unsigned int dell_922x_d82_pin_configs[10] = {
723 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
724 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
725 0x01813122, 0x400001f1,
729 STAC 922X pin configs for
732 static unsigned int dell_922x_m81_pin_configs[10] = {
733 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
734 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
735 0x40C003f1, 0x405003f0,
739 STAC 9221 A1 pin configs for
740 102801D7 (Dell XPS M1210)
742 static unsigned int dell_922x_m82_pin_configs[10] = {
743 0x0221121f, 0x408103ff, 0x02111212, 0x90100310,
744 0x408003f1, 0x02111211, 0x03451340, 0x40c003f2,
745 0x508003f3, 0x405003f4,
748 static unsigned int d945gtp3_pin_configs[10] = {
749 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
750 0x40000100, 0x40000100, 0x40000100, 0x40000100,
751 0x02a19120, 0x40000100,
754 static unsigned int d945gtp5_pin_configs[10] = {
755 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
756 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
757 0x02a19320, 0x40000100,
760 static unsigned int intel_mac_v1_pin_configs[10] = {
761 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
762 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
763 0x400000fc, 0x400000fb,
766 static unsigned int intel_mac_v2_pin_configs[10] = {
767 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
768 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
769 0x400000fc, 0x400000fb,
772 static unsigned int intel_mac_v3_pin_configs[10] = {
773 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
774 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
775 0x400000fc, 0x400000fb,
778 static unsigned int intel_mac_v4_pin_configs[10] = {
779 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
780 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
781 0x400000fc, 0x400000fb,
784 static unsigned int intel_mac_v5_pin_configs[10] = {
785 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
786 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
787 0x400000fc, 0x400000fb,
791 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
792 [STAC_D945_REF] = ref922x_pin_configs,
793 [STAC_D945GTP3] = d945gtp3_pin_configs,
794 [STAC_D945GTP5] = d945gtp5_pin_configs,
795 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
796 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
797 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
798 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
799 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
800 /* for backward compatibility */
801 [STAC_MACMINI] = intel_mac_v3_pin_configs,
802 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
803 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
804 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
805 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
806 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
807 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
808 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
809 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
810 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
813 static const char *stac922x_models[STAC_922X_MODELS] = {
814 [STAC_D945_REF] = "ref",
815 [STAC_D945GTP5] = "5stack",
816 [STAC_D945GTP3] = "3stack",
817 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
818 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
819 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
820 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
821 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
822 /* for backward compatibility */
823 [STAC_MACMINI] = "macmini",
824 [STAC_MACBOOK] = "macbook",
825 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
826 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
827 [STAC_IMAC_INTEL] = "imac-intel",
828 [STAC_IMAC_INTEL_20] = "imac-intel-20",
829 [STAC_922X_DELL_D81] = "dell-d81",
830 [STAC_922X_DELL_D82] = "dell-d82",
831 [STAC_922X_DELL_M81] = "dell-m81",
832 [STAC_922X_DELL_M82] = "dell-m82",
835 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
836 /* SigmaTel reference board */
837 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
838 "DFI LanParty", STAC_D945_REF),
839 /* Intel 945G based systems */
840 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
841 "Intel D945G", STAC_D945GTP3),
842 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
843 "Intel D945G", STAC_D945GTP3),
844 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
845 "Intel D945G", STAC_D945GTP3),
846 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
847 "Intel D945G", STAC_D945GTP3),
848 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
849 "Intel D945G", STAC_D945GTP3),
850 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
851 "Intel D945G", STAC_D945GTP3),
852 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
853 "Intel D945G", STAC_D945GTP3),
854 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
855 "Intel D945G", STAC_D945GTP3),
856 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
857 "Intel D945G", STAC_D945GTP3),
858 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
859 "Intel D945G", STAC_D945GTP3),
860 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
861 "Intel D945G", STAC_D945GTP3),
862 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
863 "Intel D945G", STAC_D945GTP3),
864 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
865 "Intel D945G", STAC_D945GTP3),
866 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
867 "Intel D945G", STAC_D945GTP3),
868 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
869 "Intel D945G", STAC_D945GTP3),
870 /* Intel D945G 5-stack systems */
871 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
872 "Intel D945G", STAC_D945GTP5),
873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
874 "Intel D945G", STAC_D945GTP5),
875 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
876 "Intel D945G", STAC_D945GTP5),
877 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
878 "Intel D945G", STAC_D945GTP5),
879 /* Intel 945P based systems */
880 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
881 "Intel D945P", STAC_D945GTP3),
882 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
883 "Intel D945P", STAC_D945GTP3),
884 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
885 "Intel D945P", STAC_D945GTP3),
886 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
887 "Intel D945P", STAC_D945GTP3),
888 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
889 "Intel D945P", STAC_D945GTP3),
890 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
891 "Intel D945P", STAC_D945GTP5),
893 /* Apple Mac Mini (early 2006) */
894 SND_PCI_QUIRK(0x8384, 0x7680,
895 "Mac Mini", STAC_INTEL_MAC_V3),
897 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
898 "unknown Dell", STAC_922X_DELL_D81),
899 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
900 "unknown Dell", STAC_922X_DELL_D81),
901 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
902 "unknown Dell", STAC_922X_DELL_D81),
903 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
904 "unknown Dell", STAC_922X_DELL_D82),
905 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
906 "unknown Dell", STAC_922X_DELL_M81),
907 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
908 "unknown Dell", STAC_922X_DELL_D82),
909 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
910 "unknown Dell", STAC_922X_DELL_D81),
911 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
912 "unknown Dell", STAC_922X_DELL_D81),
913 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
914 "Dell XPS M1210", STAC_922X_DELL_M82),
918 static unsigned int ref927x_pin_configs[14] = {
919 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
920 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
921 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
922 0x01c42190, 0x40000100,
925 static unsigned int d965_3st_pin_configs[14] = {
926 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
927 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
928 0x40000100, 0x40000100, 0x40000100, 0x40000100,
929 0x40000100, 0x40000100
932 static unsigned int d965_5st_pin_configs[14] = {
933 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
934 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
935 0x40000100, 0x40000100, 0x40000100, 0x01442070,
936 0x40000100, 0x40000100
939 static unsigned int dell_3st_pin_configs[14] = {
940 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
941 0x01111212, 0x01116211, 0x01813050, 0x01112214,
942 0x403003fa, 0x40000100, 0x40000100, 0x404003fb,
943 0x40c003fc, 0x40000100
946 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
947 [STAC_D965_REF] = ref927x_pin_configs,
948 [STAC_D965_3ST] = d965_3st_pin_configs,
949 [STAC_D965_5ST] = d965_5st_pin_configs,
950 [STAC_DELL_3ST] = dell_3st_pin_configs,
953 static const char *stac927x_models[STAC_927X_MODELS] = {
954 [STAC_D965_REF] = "ref",
955 [STAC_D965_3ST] = "3stack",
956 [STAC_D965_5ST] = "5stack",
957 [STAC_DELL_3ST] = "dell-3stack",
960 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
961 /* SigmaTel reference board */
962 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
963 "DFI LanParty", STAC_D965_REF),
964 /* Intel 946 based systems */
965 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
966 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
967 /* 965 based 3 stack systems */
968 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
970 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
971 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
972 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
974 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
976 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
977 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
979 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
981 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
982 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
984 /* Dell 3 stack systems */
985 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
986 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
987 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
988 /* 965 based 5 stack systems */
989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
991 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
993 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
995 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1001 static unsigned int ref9205_pin_configs[12] = {
1002 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1003 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
1004 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1008 STAC 9205 pin configs for
1016 static unsigned int dell_9205_m42_pin_configs[12] = {
1017 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1018 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1019 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1023 STAC 9205 pin configs for
1027 102801FF (Dell Precision M4300)
1032 static unsigned int dell_9205_m43_pin_configs[12] = {
1033 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1034 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1035 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1038 static unsigned int dell_9205_m44_pin_configs[12] = {
1039 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1040 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1041 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1044 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1045 [STAC_9205_REF] = ref9205_pin_configs,
1046 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1047 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1048 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1049 [STAC_9205_M43xx] = NULL,
1052 static const char *stac9205_models[STAC_9205_MODELS] = {
1053 [STAC_9205_REF] = "ref",
1054 [STAC_9205_DELL_M42] = "dell-m42",
1055 [STAC_9205_DELL_M43] = "dell-m43",
1056 [STAC_9205_DELL_M44] = "dell-m44",
1059 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1060 /* SigmaTel reference board */
1061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1062 "DFI LanParty", STAC_9205_REF),
1063 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1064 "unknown Dell", STAC_9205_DELL_M42),
1065 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1066 "unknown Dell", STAC_9205_DELL_M42),
1067 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1068 "Dell Precision", STAC_9205_M43xx),
1069 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1070 "Dell Precision", STAC_9205_DELL_M43),
1071 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1072 "Dell Precision", STAC_9205_DELL_M43),
1073 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1074 "unknown Dell", STAC_9205_DELL_M42),
1075 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1076 "unknown Dell", STAC_9205_DELL_M42),
1077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1078 "Dell Precision", STAC_9205_DELL_M43),
1079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1080 "Dell Precision M4300", STAC_9205_DELL_M43),
1081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1082 "Dell Precision", STAC_9205_DELL_M43),
1083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1084 "Dell Inspiron", STAC_9205_DELL_M44),
1085 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1086 "Dell Inspiron", STAC_9205_DELL_M44),
1087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1088 "Dell Inspiron", STAC_9205_DELL_M44),
1089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1090 "Dell Inspiron", STAC_9205_DELL_M44),
1091 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1092 "unknown Dell", STAC_9205_DELL_M42),
1093 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1094 "Dell Inspiron", STAC_9205_DELL_M44),
1098 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1101 struct sigmatel_spec *spec = codec->spec;
1103 if (! spec->bios_pin_configs) {
1104 spec->bios_pin_configs = kcalloc(spec->num_pins,
1105 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1106 if (! spec->bios_pin_configs)
1110 for (i = 0; i < spec->num_pins; i++) {
1111 hda_nid_t nid = spec->pin_nids[i];
1112 unsigned int pin_cfg;
1114 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1115 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1116 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1118 spec->bios_pin_configs[i] = pin_cfg;
1124 static void stac92xx_set_config_reg(struct hda_codec *codec,
1125 hda_nid_t pin_nid, unsigned int pin_config)
1128 snd_hda_codec_write(codec, pin_nid, 0,
1129 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1130 pin_config & 0x000000ff);
1131 snd_hda_codec_write(codec, pin_nid, 0,
1132 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1133 (pin_config & 0x0000ff00) >> 8);
1134 snd_hda_codec_write(codec, pin_nid, 0,
1135 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1136 (pin_config & 0x00ff0000) >> 16);
1137 snd_hda_codec_write(codec, pin_nid, 0,
1138 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1140 i = snd_hda_codec_read(codec, pin_nid, 0,
1141 AC_VERB_GET_CONFIG_DEFAULT,
1143 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1147 static void stac92xx_set_config_regs(struct hda_codec *codec)
1150 struct sigmatel_spec *spec = codec->spec;
1152 if (!spec->pin_configs)
1155 for (i = 0; i < spec->num_pins; i++)
1156 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1157 spec->pin_configs[i]);
1160 static void stac92xx_enable_gpio_mask(struct hda_codec *codec)
1162 struct sigmatel_spec *spec = codec->spec;
1163 /* Configure GPIOx as output */
1164 snd_hda_codec_write_cache(codec, codec->afg, 0,
1165 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask);
1166 /* Configure GPIOx as CMOS */
1167 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000);
1169 snd_hda_codec_write_cache(codec, codec->afg, 0,
1170 AC_VERB_SET_GPIO_DATA, spec->gpio_data);
1172 snd_hda_codec_write_cache(codec, codec->afg, 0,
1173 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
1177 * Analog playback callbacks
1179 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1180 struct hda_codec *codec,
1181 struct snd_pcm_substream *substream)
1183 struct sigmatel_spec *spec = codec->spec;
1184 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1187 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1188 struct hda_codec *codec,
1189 unsigned int stream_tag,
1190 unsigned int format,
1191 struct snd_pcm_substream *substream)
1193 struct sigmatel_spec *spec = codec->spec;
1194 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1197 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1198 struct hda_codec *codec,
1199 struct snd_pcm_substream *substream)
1201 struct sigmatel_spec *spec = codec->spec;
1202 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1206 * Digital playback callbacks
1208 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1209 struct hda_codec *codec,
1210 struct snd_pcm_substream *substream)
1212 struct sigmatel_spec *spec = codec->spec;
1213 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1216 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1217 struct hda_codec *codec,
1218 struct snd_pcm_substream *substream)
1220 struct sigmatel_spec *spec = codec->spec;
1221 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1224 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1225 struct hda_codec *codec,
1226 unsigned int stream_tag,
1227 unsigned int format,
1228 struct snd_pcm_substream *substream)
1230 struct sigmatel_spec *spec = codec->spec;
1231 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1232 stream_tag, format, substream);
1237 * Analog capture callbacks
1239 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1240 struct hda_codec *codec,
1241 unsigned int stream_tag,
1242 unsigned int format,
1243 struct snd_pcm_substream *substream)
1245 struct sigmatel_spec *spec = codec->spec;
1247 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1248 stream_tag, 0, format);
1252 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1253 struct hda_codec *codec,
1254 struct snd_pcm_substream *substream)
1256 struct sigmatel_spec *spec = codec->spec;
1258 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1262 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1266 /* NID is set in stac92xx_build_pcms */
1268 .open = stac92xx_dig_playback_pcm_open,
1269 .close = stac92xx_dig_playback_pcm_close,
1270 .prepare = stac92xx_dig_playback_pcm_prepare
1274 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1278 /* NID is set in stac92xx_build_pcms */
1281 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1285 .nid = 0x02, /* NID to query formats and rates */
1287 .open = stac92xx_playback_pcm_open,
1288 .prepare = stac92xx_playback_pcm_prepare,
1289 .cleanup = stac92xx_playback_pcm_cleanup
1293 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1297 .nid = 0x06, /* NID to query formats and rates */
1299 .open = stac92xx_playback_pcm_open,
1300 .prepare = stac92xx_playback_pcm_prepare,
1301 .cleanup = stac92xx_playback_pcm_cleanup
1305 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1309 /* NID is set in stac92xx_build_pcms */
1311 .prepare = stac92xx_capture_pcm_prepare,
1312 .cleanup = stac92xx_capture_pcm_cleanup
1316 static int stac92xx_build_pcms(struct hda_codec *codec)
1318 struct sigmatel_spec *spec = codec->spec;
1319 struct hda_pcm *info = spec->pcm_rec;
1321 codec->num_pcms = 1;
1322 codec->pcm_info = info;
1324 info->name = "STAC92xx Analog";
1325 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
1326 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
1327 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1329 if (spec->alt_switch) {
1332 info->name = "STAC92xx Analog Alt";
1333 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1336 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1339 info->name = "STAC92xx Digital";
1340 if (spec->multiout.dig_out_nid) {
1341 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1342 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1344 if (spec->dig_in_nid) {
1345 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1346 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1353 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1355 unsigned int pincap = snd_hda_param_read(codec, nid,
1357 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1358 if (pincap & AC_PINCAP_VREF_100)
1359 return AC_PINCTL_VREF_100;
1360 if (pincap & AC_PINCAP_VREF_80)
1361 return AC_PINCTL_VREF_80;
1362 if (pincap & AC_PINCAP_VREF_50)
1363 return AC_PINCTL_VREF_50;
1364 if (pincap & AC_PINCAP_VREF_GRD)
1365 return AC_PINCTL_VREF_GRD;
1369 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1372 snd_hda_codec_write_cache(codec, nid, 0,
1373 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1376 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1378 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1380 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1381 struct sigmatel_spec *spec = codec->spec;
1382 int io_idx = kcontrol-> private_value & 0xff;
1384 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1388 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1390 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1391 struct sigmatel_spec *spec = codec->spec;
1392 hda_nid_t nid = kcontrol->private_value >> 8;
1393 int io_idx = kcontrol-> private_value & 0xff;
1394 unsigned short val = ucontrol->value.integer.value[0];
1396 spec->io_switch[io_idx] = val;
1399 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1401 unsigned int pinctl = AC_PINCTL_IN_EN;
1402 if (io_idx) /* set VREF for mic */
1403 pinctl |= stac92xx_get_vref(codec, nid);
1404 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1409 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
1410 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1413 .info = stac92xx_io_switch_info, \
1414 .get = stac92xx_io_switch_get, \
1415 .put = stac92xx_io_switch_put, \
1416 .private_value = xpval, \
1421 STAC_CTL_WIDGET_VOL,
1422 STAC_CTL_WIDGET_MUTE,
1423 STAC_CTL_WIDGET_IO_SWITCH,
1426 static struct snd_kcontrol_new stac92xx_control_templates[] = {
1427 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1428 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1429 STAC_CODEC_IO_SWITCH(NULL, 0),
1432 /* add dynamic controls */
1433 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1435 struct snd_kcontrol_new *knew;
1437 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1438 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1440 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1443 if (spec->kctl_alloc) {
1444 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1445 kfree(spec->kctl_alloc);
1447 spec->kctl_alloc = knew;
1448 spec->num_kctl_alloc = num;
1451 knew = &spec->kctl_alloc[spec->num_kctl_used];
1452 *knew = stac92xx_control_templates[type];
1453 knew->name = kstrdup(name, GFP_KERNEL);
1456 knew->private_value = val;
1457 spec->num_kctl_used++;
1461 /* flag inputs as additional dynamic lineouts */
1462 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1464 struct sigmatel_spec *spec = codec->spec;
1465 unsigned int wcaps, wtype;
1466 int i, num_dacs = 0;
1468 /* use the wcaps cache to count all DACs available for line-outs */
1469 for (i = 0; i < codec->num_nodes; i++) {
1470 wcaps = codec->wcaps[i];
1471 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1472 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1476 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1478 switch (cfg->line_outs) {
1480 /* add line-in as side */
1481 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1482 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1483 spec->line_switch = 1;
1488 /* add line-in as clfe and mic as side */
1489 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1490 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1491 spec->line_switch = 1;
1494 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1495 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1496 spec->mic_switch = 1;
1501 /* add line-in as surr and mic as clfe */
1502 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1503 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1504 spec->line_switch = 1;
1507 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1508 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1509 spec->mic_switch = 1;
1519 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1523 for (i = 0; i < spec->multiout.num_dacs; i++) {
1524 if (spec->multiout.dac_nids[i] == nid)
1532 * Fill in the dac_nids table from the parsed pin configuration
1533 * This function only works when every pin in line_out_pins[]
1534 * contains atleast one DAC in its connection list. Some 92xx
1535 * codecs are not connected directly to a DAC, such as the 9200
1536 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1538 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1539 struct auto_pin_cfg *cfg)
1541 struct sigmatel_spec *spec = codec->spec;
1542 int i, j, conn_len = 0;
1543 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1544 unsigned int wcaps, wtype;
1546 for (i = 0; i < cfg->line_outs; i++) {
1547 nid = cfg->line_out_pins[i];
1548 conn_len = snd_hda_get_connections(codec, nid, conn,
1549 HDA_MAX_CONNECTIONS);
1550 for (j = 0; j < conn_len; j++) {
1551 wcaps = snd_hda_param_read(codec, conn[j],
1552 AC_PAR_AUDIO_WIDGET_CAP);
1553 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1555 if (wtype != AC_WID_AUD_OUT ||
1556 (wcaps & AC_WCAP_DIGITAL))
1558 /* conn[j] is a DAC routed to this line-out */
1559 if (!is_in_dac_nids(spec, conn[j]))
1563 if (j == conn_len) {
1564 if (spec->multiout.num_dacs > 0) {
1565 /* we have already working output pins,
1566 * so let's drop the broken ones again
1568 cfg->line_outs = spec->multiout.num_dacs;
1571 /* error out, no available DAC found */
1573 "%s: No available DAC for pin 0x%x\n",
1578 spec->multiout.dac_nids[i] = conn[j];
1579 spec->multiout.num_dacs++;
1581 /* select this DAC in the pin's input mux */
1582 snd_hda_codec_write_cache(codec, nid, 0,
1583 AC_VERB_SET_CONNECT_SEL, j);
1588 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1589 spec->multiout.num_dacs,
1590 spec->multiout.dac_nids[0],
1591 spec->multiout.dac_nids[1],
1592 spec->multiout.dac_nids[2],
1593 spec->multiout.dac_nids[3],
1594 spec->multiout.dac_nids[4]);
1598 /* create volume control/switch for the given prefx type */
1599 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1604 sprintf(name, "%s Playback Volume", pfx);
1605 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1606 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1609 sprintf(name, "%s Playback Switch", pfx);
1610 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1611 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1617 /* add playback controls from the parsed DAC table */
1618 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1619 const struct auto_pin_cfg *cfg)
1621 static const char *chname[4] = {
1622 "Front", "Surround", NULL /*CLFE*/, "Side"
1627 for (i = 0; i < cfg->line_outs; i++) {
1628 if (!spec->multiout.dac_nids[i])
1631 nid = spec->multiout.dac_nids[i];
1635 err = create_controls(spec, "Center", nid, 1);
1638 err = create_controls(spec, "LFE", nid, 2);
1642 err = create_controls(spec, chname[i], nid, 3);
1648 if (spec->line_switch)
1649 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1652 if (spec->mic_switch)
1653 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1659 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1661 if (is_in_dac_nids(spec, nid))
1663 if (spec->multiout.hp_nid == nid)
1668 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1670 if (!spec->multiout.hp_nid)
1671 spec->multiout.hp_nid = nid;
1672 else if (spec->multiout.num_dacs > 4) {
1673 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1676 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1677 spec->multiout.num_dacs++;
1682 /* add playback controls for Speaker and HP outputs */
1683 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1684 struct auto_pin_cfg *cfg)
1686 struct sigmatel_spec *spec = codec->spec;
1688 int i, old_num_dacs, err;
1690 old_num_dacs = spec->multiout.num_dacs;
1691 for (i = 0; i < cfg->hp_outs; i++) {
1692 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1693 if (wid_caps & AC_WCAP_UNSOL_CAP)
1694 spec->hp_detect = 1;
1695 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1696 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1697 if (check_in_dac_nids(spec, nid))
1701 add_spec_dacs(spec, nid);
1703 for (i = 0; i < cfg->speaker_outs; i++) {
1704 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1705 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1706 if (check_in_dac_nids(spec, nid))
1710 add_spec_dacs(spec, nid);
1712 for (i = 0; i < cfg->line_outs; i++) {
1713 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
1714 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1715 if (check_in_dac_nids(spec, nid))
1719 add_spec_dacs(spec, nid);
1721 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1722 static const char *pfxs[] = {
1723 "Speaker", "External Speaker", "Speaker2",
1725 err = create_controls(spec, pfxs[i - old_num_dacs],
1726 spec->multiout.dac_nids[i], 3);
1730 if (spec->multiout.hp_nid) {
1732 if (old_num_dacs == spec->multiout.num_dacs)
1736 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
1744 /* labels for dmic mux inputs */
1745 static const char *stac92xx_dmic_labels[5] = {
1746 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1747 "Digital Mic 3", "Digital Mic 4"
1750 /* create playback/capture controls for input pins on dmic capable codecs */
1751 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1752 const struct auto_pin_cfg *cfg)
1754 struct sigmatel_spec *spec = codec->spec;
1755 struct hda_input_mux *dimux = &spec->private_dimux;
1756 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1759 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1760 dimux->items[dimux->num_items].index = 0;
1763 for (i = 0; i < spec->num_dmics; i++) {
1766 unsigned int def_conf;
1768 def_conf = snd_hda_codec_read(codec,
1771 AC_VERB_GET_CONFIG_DEFAULT,
1773 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1776 num_cons = snd_hda_get_connections(codec,
1779 HDA_MAX_NUM_INPUTS);
1780 for (j = 0; j < num_cons; j++)
1781 if (con_lst[j] == spec->dmic_nids[i]) {
1787 dimux->items[dimux->num_items].label =
1788 stac92xx_dmic_labels[dimux->num_items];
1789 dimux->items[dimux->num_items].index = index;
1796 /* create playback/capture controls for input pins */
1797 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1799 struct sigmatel_spec *spec = codec->spec;
1800 struct hda_input_mux *imux = &spec->private_imux;
1801 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1804 for (i = 0; i < AUTO_PIN_LAST; i++) {
1807 if (!cfg->input_pins[i])
1810 for (j = 0; j < spec->num_muxes; j++) {
1812 num_cons = snd_hda_get_connections(codec,
1815 HDA_MAX_NUM_INPUTS);
1816 for (k = 0; k < num_cons; k++)
1817 if (con_lst[k] == cfg->input_pins[i]) {
1824 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1825 imux->items[imux->num_items].index = index;
1829 if (imux->num_items) {
1831 * Set the current input for the muxes.
1832 * The STAC9221 has two input muxes with identical source
1833 * NID lists. Hopefully this won't get confused.
1835 for (i = 0; i < spec->num_muxes; i++) {
1836 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
1837 AC_VERB_SET_CONNECT_SEL,
1838 imux->items[0].index);
1845 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1847 struct sigmatel_spec *spec = codec->spec;
1850 for (i = 0; i < spec->autocfg.line_outs; i++) {
1851 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1852 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1856 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
1858 struct sigmatel_spec *spec = codec->spec;
1861 for (i = 0; i < spec->autocfg.hp_outs; i++) {
1863 pin = spec->autocfg.hp_pins[i];
1864 if (pin) /* connect to front */
1865 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1867 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
1869 pin = spec->autocfg.speaker_pins[i];
1870 if (pin) /* connect to front */
1871 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
1875 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
1877 struct sigmatel_spec *spec = codec->spec;
1880 if ((err = snd_hda_parse_pin_def_config(codec,
1882 spec->dmic_nids)) < 0)
1884 if (! spec->autocfg.line_outs)
1885 return 0; /* can't find valid pin config */
1887 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
1889 if (spec->multiout.num_dacs == 0)
1890 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
1893 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1894 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
1895 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1898 if (spec->num_dmics > 0)
1899 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
1900 &spec->autocfg)) < 0)
1903 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1904 if (spec->multiout.max_channels > 2)
1905 spec->surr_switch = 1;
1907 if (spec->autocfg.dig_out_pin)
1908 spec->multiout.dig_out_nid = dig_out;
1909 if (spec->autocfg.dig_in_pin)
1910 spec->dig_in_nid = dig_in;
1912 if (spec->kctl_alloc)
1913 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1915 spec->input_mux = &spec->private_imux;
1916 spec->dinput_mux = &spec->private_dimux;
1921 /* add playback controls for HP output */
1922 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
1923 struct auto_pin_cfg *cfg)
1925 struct sigmatel_spec *spec = codec->spec;
1926 hda_nid_t pin = cfg->hp_pins[0];
1927 unsigned int wid_caps;
1932 wid_caps = get_wcaps(codec, pin);
1933 if (wid_caps & AC_WCAP_UNSOL_CAP)
1934 spec->hp_detect = 1;
1939 /* add playback controls for LFE output */
1940 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
1941 struct auto_pin_cfg *cfg)
1943 struct sigmatel_spec *spec = codec->spec;
1945 hda_nid_t lfe_pin = 0x0;
1949 * search speaker outs and line outs for a mono speaker pin
1950 * with an amp. If one is found, add LFE controls
1953 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
1954 hda_nid_t pin = spec->autocfg.speaker_pins[i];
1955 unsigned long wcaps = get_wcaps(codec, pin);
1956 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1957 if (wcaps == AC_WCAP_OUT_AMP)
1958 /* found a mono speaker with an amp, must be lfe */
1962 /* if speaker_outs is 0, then speakers may be in line_outs */
1963 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
1964 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
1965 hda_nid_t pin = spec->autocfg.line_out_pins[i];
1967 cfg = snd_hda_codec_read(codec, pin, 0,
1968 AC_VERB_GET_CONFIG_DEFAULT,
1970 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
1971 unsigned long wcaps = get_wcaps(codec, pin);
1972 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1973 if (wcaps == AC_WCAP_OUT_AMP)
1974 /* found a mono speaker with an amp,
1982 err = create_controls(spec, "LFE", lfe_pin, 1);
1990 static int stac9200_parse_auto_config(struct hda_codec *codec)
1992 struct sigmatel_spec *spec = codec->spec;
1995 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
1998 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2001 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2004 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2007 if (spec->autocfg.dig_out_pin)
2008 spec->multiout.dig_out_nid = 0x05;
2009 if (spec->autocfg.dig_in_pin)
2010 spec->dig_in_nid = 0x04;
2012 if (spec->kctl_alloc)
2013 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2015 spec->input_mux = &spec->private_imux;
2016 spec->dinput_mux = &spec->private_dimux;
2022 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2023 * funky external mute control using GPIO pins.
2026 static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
2028 unsigned int gpiostate, gpiomask, gpiodir;
2030 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
2031 AC_VERB_GET_GPIO_DATA, 0);
2034 gpiostate |= (1 << pin);
2036 gpiostate &= ~(1 << pin);
2038 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
2039 AC_VERB_GET_GPIO_MASK, 0);
2040 gpiomask |= (1 << pin);
2042 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
2043 AC_VERB_GET_GPIO_DIRECTION, 0);
2044 gpiodir |= (1 << pin);
2046 /* AppleHDA seems to do this -- WTF is this verb?? */
2047 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
2049 snd_hda_codec_write(codec, codec->afg, 0,
2050 AC_VERB_SET_GPIO_MASK, gpiomask);
2051 snd_hda_codec_write(codec, codec->afg, 0,
2052 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
2056 snd_hda_codec_write(codec, codec->afg, 0,
2057 AC_VERB_SET_GPIO_DATA, gpiostate);
2060 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2063 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
2064 snd_hda_codec_write(codec, nid, 0,
2065 AC_VERB_SET_UNSOLICITED_ENABLE,
2066 (AC_USRSP_EN | event));
2069 static int stac92xx_init(struct hda_codec *codec)
2071 struct sigmatel_spec *spec = codec->spec;
2072 struct auto_pin_cfg *cfg = &spec->autocfg;
2075 snd_hda_sequence_write(codec, spec->init);
2078 if (spec->hp_detect) {
2079 /* Enable unsolicited responses on the HP widget */
2080 for (i = 0; i < cfg->hp_outs; i++)
2081 enable_pin_detect(codec, cfg->hp_pins[i],
2083 /* force to enable the first line-out; the others are set up
2086 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
2088 stac92xx_auto_init_hp_out(codec);
2089 /* fake event to set up pins */
2090 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2092 stac92xx_auto_init_multi_out(codec);
2093 stac92xx_auto_init_hp_out(codec);
2095 for (i = 0; i < AUTO_PIN_LAST; i++) {
2096 hda_nid_t nid = cfg->input_pins[i];
2098 unsigned int pinctl = AC_PINCTL_IN_EN;
2099 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
2100 pinctl |= stac92xx_get_vref(codec, nid);
2101 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2104 if (spec->num_dmics > 0)
2105 for (i = 0; i < spec->num_dmics; i++)
2106 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
2109 if (cfg->dig_out_pin)
2110 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
2112 if (cfg->dig_in_pin)
2113 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
2116 if (spec->gpio_mute) {
2117 stac922x_gpio_mute(codec, 0, 0);
2118 stac922x_gpio_mute(codec, 1, 0);
2124 static void stac92xx_free(struct hda_codec *codec)
2126 struct sigmatel_spec *spec = codec->spec;
2132 if (spec->kctl_alloc) {
2133 for (i = 0; i < spec->num_kctl_used; i++)
2134 kfree(spec->kctl_alloc[i].name);
2135 kfree(spec->kctl_alloc);
2138 if (spec->bios_pin_configs)
2139 kfree(spec->bios_pin_configs);
2144 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
2147 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2148 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2150 if (pin_ctl & AC_PINCTL_IN_EN) {
2152 * we need to check the current set-up direction of
2153 * shared input pins since they can be switched via
2154 * "xxx as Output" mixer switch
2156 struct sigmatel_spec *spec = codec->spec;
2157 struct auto_pin_cfg *cfg = &spec->autocfg;
2158 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
2159 spec->line_switch) ||
2160 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
2165 /* if setting pin direction bits, clear the current
2166 direction bits first */
2167 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
2168 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
2170 snd_hda_codec_write_cache(codec, nid, 0,
2171 AC_VERB_SET_PIN_WIDGET_CONTROL,
2175 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
2178 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2179 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2180 snd_hda_codec_write_cache(codec, nid, 0,
2181 AC_VERB_SET_PIN_WIDGET_CONTROL,
2185 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
2189 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
2195 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
2197 struct sigmatel_spec *spec = codec->spec;
2198 struct auto_pin_cfg *cfg = &spec->autocfg;
2202 for (i = 0; i < cfg->hp_outs; i++) {
2203 presence = get_pin_presence(codec, cfg->hp_pins[i]);
2209 /* disable lineouts, enable hp */
2210 for (i = 0; i < cfg->line_outs; i++)
2211 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
2213 for (i = 0; i < cfg->speaker_outs; i++)
2214 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2217 /* enable lineouts, disable hp */
2218 for (i = 0; i < cfg->line_outs; i++)
2219 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
2221 for (i = 0; i < cfg->speaker_outs; i++)
2222 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2227 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
2229 switch (res >> 26) {
2231 stac92xx_hp_detect(codec, res);
2236 #ifdef SND_HDA_NEEDS_RESUME
2237 static int stac92xx_resume(struct hda_codec *codec)
2239 stac92xx_set_config_regs(codec);
2240 stac92xx_init(codec);
2241 snd_hda_codec_resume_amp(codec);
2242 snd_hda_codec_resume_cache(codec);
2247 static struct hda_codec_ops stac92xx_patch_ops = {
2248 .build_controls = stac92xx_build_controls,
2249 .build_pcms = stac92xx_build_pcms,
2250 .init = stac92xx_init,
2251 .free = stac92xx_free,
2252 .unsol_event = stac92xx_unsol_event,
2253 #ifdef SND_HDA_NEEDS_RESUME
2254 .resume = stac92xx_resume,
2258 static int patch_stac9200(struct hda_codec *codec)
2260 struct sigmatel_spec *spec;
2263 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2268 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
2269 spec->pin_nids = stac9200_pin_nids;
2270 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
2273 if (spec->board_config < 0) {
2274 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
2275 err = stac92xx_save_bios_config_regs(codec);
2277 stac92xx_free(codec);
2280 spec->pin_configs = spec->bios_pin_configs;
2282 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
2283 stac92xx_set_config_regs(codec);
2286 spec->multiout.max_channels = 2;
2287 spec->multiout.num_dacs = 1;
2288 spec->multiout.dac_nids = stac9200_dac_nids;
2289 spec->adc_nids = stac9200_adc_nids;
2290 spec->mux_nids = stac9200_mux_nids;
2291 spec->num_muxes = 1;
2292 spec->num_dmics = 0;
2294 spec->init = stac9200_core_init;
2295 spec->mixer = stac9200_mixer;
2297 err = stac9200_parse_auto_config(codec);
2299 stac92xx_free(codec);
2303 codec->patch_ops = stac92xx_patch_ops;
2308 static int patch_stac925x(struct hda_codec *codec)
2310 struct sigmatel_spec *spec;
2313 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2318 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
2319 spec->pin_nids = stac925x_pin_nids;
2320 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
2324 if (spec->board_config < 0) {
2325 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2326 "using BIOS defaults\n");
2327 err = stac92xx_save_bios_config_regs(codec);
2329 stac92xx_free(codec);
2332 spec->pin_configs = spec->bios_pin_configs;
2333 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
2334 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
2335 stac92xx_set_config_regs(codec);
2338 spec->multiout.max_channels = 2;
2339 spec->multiout.num_dacs = 1;
2340 spec->multiout.dac_nids = stac925x_dac_nids;
2341 spec->adc_nids = stac925x_adc_nids;
2342 spec->mux_nids = stac925x_mux_nids;
2343 spec->num_muxes = 1;
2344 switch (codec->vendor_id) {
2345 case 0x83847632: /* STAC9202 */
2346 case 0x83847633: /* STAC9202D */
2347 case 0x83847636: /* STAC9251 */
2348 case 0x83847637: /* STAC9251D */
2349 spec->num_dmics = 1;
2350 spec->dmic_nids = stac925x_dmic_nids;
2353 spec->num_dmics = 0;
2357 spec->init = stac925x_core_init;
2358 spec->mixer = stac925x_mixer;
2360 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
2362 if (spec->board_config < 0) {
2363 printk(KERN_WARNING "hda_codec: No auto-config is "
2364 "available, default to model=ref\n");
2365 spec->board_config = STAC_925x_REF;
2371 stac92xx_free(codec);
2375 codec->patch_ops = stac92xx_patch_ops;
2380 static int patch_stac922x(struct hda_codec *codec)
2382 struct sigmatel_spec *spec;
2385 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2390 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
2391 spec->pin_nids = stac922x_pin_nids;
2392 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2395 if (spec->board_config == STAC_INTEL_MAC_V3) {
2396 spec->gpio_mute = 1;
2397 /* Intel Macs have all same PCI SSID, so we need to check
2398 * codec SSID to distinguish the exact models
2400 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
2401 switch (codec->subsystem_id) {
2404 spec->board_config = STAC_INTEL_MAC_V1;
2408 spec->board_config = STAC_INTEL_MAC_V2;
2416 spec->board_config = STAC_INTEL_MAC_V3;
2420 spec->board_config = STAC_INTEL_MAC_V4;
2424 spec->board_config = STAC_INTEL_MAC_V5;
2430 if (spec->board_config < 0) {
2431 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2432 "using BIOS defaults\n");
2433 err = stac92xx_save_bios_config_regs(codec);
2435 stac92xx_free(codec);
2438 spec->pin_configs = spec->bios_pin_configs;
2439 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
2440 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2441 stac92xx_set_config_regs(codec);
2444 spec->adc_nids = stac922x_adc_nids;
2445 spec->mux_nids = stac922x_mux_nids;
2446 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
2447 spec->num_dmics = 0;
2449 spec->init = stac922x_core_init;
2450 spec->mixer = stac922x_mixer;
2452 spec->multiout.dac_nids = spec->dac_nids;
2454 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
2456 if (spec->board_config < 0) {
2457 printk(KERN_WARNING "hda_codec: No auto-config is "
2458 "available, default to model=ref\n");
2459 spec->board_config = STAC_D945_REF;
2465 stac92xx_free(codec);
2469 codec->patch_ops = stac92xx_patch_ops;
2471 /* Fix Mux capture level; max to 2 */
2472 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2473 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2474 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2475 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2476 (0 << AC_AMPCAP_MUTE_SHIFT));
2481 static int patch_stac927x(struct hda_codec *codec)
2483 struct sigmatel_spec *spec;
2486 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2491 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
2492 spec->pin_nids = stac927x_pin_nids;
2493 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2497 if (spec->board_config < 0) {
2498 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
2499 err = stac92xx_save_bios_config_regs(codec);
2501 stac92xx_free(codec);
2504 spec->pin_configs = spec->bios_pin_configs;
2505 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
2506 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2507 stac92xx_set_config_regs(codec);
2510 switch (spec->board_config) {
2512 spec->adc_nids = stac927x_adc_nids;
2513 spec->mux_nids = stac927x_mux_nids;
2514 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2515 spec->num_dmics = 0;
2516 spec->init = d965_core_init;
2517 spec->mixer = stac9227_mixer;
2520 spec->adc_nids = stac927x_adc_nids;
2521 spec->mux_nids = stac927x_mux_nids;
2522 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2523 spec->num_dmics = 0;
2524 spec->init = d965_core_init;
2525 spec->mixer = stac9227_mixer;
2528 spec->adc_nids = stac927x_adc_nids;
2529 spec->mux_nids = stac927x_mux_nids;
2530 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2531 spec->num_dmics = 0;
2532 spec->init = stac927x_core_init;
2533 spec->mixer = stac927x_mixer;
2536 spec->multiout.dac_nids = spec->dac_nids;
2537 /* GPIO0 High = Enable EAPD */
2538 spec->gpio_mask = spec->gpio_data = 0x00000001;
2539 stac92xx_enable_gpio_mask(codec);
2541 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
2543 if (spec->board_config < 0) {
2544 printk(KERN_WARNING "hda_codec: No auto-config is "
2545 "available, default to model=ref\n");
2546 spec->board_config = STAC_D965_REF;
2552 stac92xx_free(codec);
2556 codec->patch_ops = stac92xx_patch_ops;
2561 static int patch_stac9205(struct hda_codec *codec)
2563 struct sigmatel_spec *spec;
2566 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2571 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
2572 spec->pin_nids = stac9205_pin_nids;
2573 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2577 if (spec->board_config < 0) {
2578 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2579 err = stac92xx_save_bios_config_regs(codec);
2581 stac92xx_free(codec);
2584 spec->pin_configs = spec->bios_pin_configs;
2586 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
2587 stac92xx_set_config_regs(codec);
2590 spec->adc_nids = stac9205_adc_nids;
2591 spec->mux_nids = stac9205_mux_nids;
2592 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2593 spec->dmic_nids = stac9205_dmic_nids;
2594 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
2595 spec->dmux_nid = 0x1d;
2597 spec->init = stac9205_core_init;
2598 spec->mixer = stac9205_mixer;
2600 spec->multiout.dac_nids = spec->dac_nids;
2602 switch (spec->board_config){
2603 case STAC_9205_M43xx:
2604 case STAC_9205_DELL_M43:
2605 /* Enable SPDIF in/out */
2606 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
2607 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
2609 spec->gpio_mask = 0x00000007; /* GPIO0-2 */
2610 /* GPIO0 High = EAPD, GPIO1 Low = DRM,
2611 * GPIO2 High = Headphone Mute
2613 spec->gpio_data = 0x00000005;
2616 /* GPIO0 High = EAPD */
2617 spec->gpio_mask = spec->gpio_data = 0x00000001;
2621 stac92xx_enable_gpio_mask(codec);
2622 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
2624 if (spec->board_config < 0) {
2625 printk(KERN_WARNING "hda_codec: No auto-config is "
2626 "available, default to model=ref\n");
2627 spec->board_config = STAC_9205_REF;
2633 stac92xx_free(codec);
2637 codec->patch_ops = stac92xx_patch_ops;
2646 /* static config for Sony VAIO FE550G and Sony VAIO AR */
2647 static hda_nid_t vaio_dacs[] = { 0x2 };
2648 #define VAIO_HP_DAC 0x5
2649 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
2650 static hda_nid_t vaio_mux_nids[] = { 0x15 };
2652 static struct hda_input_mux vaio_mux = {
2655 /* { "HP", 0x0 }, */
2656 { "Mic Jack", 0x1 },
2657 { "Internal Mic", 0x2 },
2662 static struct hda_verb vaio_init[] = {
2663 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2664 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
2665 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2666 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2667 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2668 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2669 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2670 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2671 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2672 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2678 static struct hda_verb vaio_ar_init[] = {
2679 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2680 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2681 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2682 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2683 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2684 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2686 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2687 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2688 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2689 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2690 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2691 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2695 /* bind volumes of both NID 0x02 and 0x05 */
2696 static struct hda_bind_ctls vaio_bind_master_vol = {
2697 .ops = &snd_hda_bind_vol,
2699 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2700 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2705 /* bind volumes of both NID 0x02 and 0x05 */
2706 static struct hda_bind_ctls vaio_bind_master_sw = {
2707 .ops = &snd_hda_bind_sw,
2709 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2710 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2715 static struct snd_kcontrol_new vaio_mixer[] = {
2716 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2717 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2718 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2719 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2720 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2722 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2723 .name = "Capture Source",
2725 .info = stac92xx_mux_enum_info,
2726 .get = stac92xx_mux_enum_get,
2727 .put = stac92xx_mux_enum_put,
2732 static struct snd_kcontrol_new vaio_ar_mixer[] = {
2733 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2734 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2735 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2736 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2737 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2738 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2739 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2742 .name = "Capture Source",
2744 .info = stac92xx_mux_enum_info,
2745 .get = stac92xx_mux_enum_get,
2746 .put = stac92xx_mux_enum_put,
2751 static struct hda_codec_ops stac9872_patch_ops = {
2752 .build_controls = stac92xx_build_controls,
2753 .build_pcms = stac92xx_build_pcms,
2754 .init = stac92xx_init,
2755 .free = stac92xx_free,
2756 #ifdef SND_HDA_NEEDS_RESUME
2757 .resume = stac92xx_resume,
2761 static int stac9872_vaio_init(struct hda_codec *codec)
2765 err = stac92xx_init(codec);
2768 if (codec->patch_ops.unsol_event)
2769 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2773 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
2775 if (get_pin_presence(codec, 0x0a)) {
2776 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
2777 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
2779 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
2780 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
2784 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
2786 switch (res >> 26) {
2788 stac9872_vaio_hp_detect(codec, res);
2793 static struct hda_codec_ops stac9872_vaio_patch_ops = {
2794 .build_controls = stac92xx_build_controls,
2795 .build_pcms = stac92xx_build_pcms,
2796 .init = stac9872_vaio_init,
2797 .free = stac92xx_free,
2798 .unsol_event = stac9872_vaio_unsol_event,
2800 .resume = stac92xx_resume,
2804 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2806 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2808 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2810 /* AR Series. id=0x83847664 and subsys=104D1300 */
2815 static const char *stac9872_models[STAC_9872_MODELS] = {
2816 [CXD9872RD_VAIO] = "vaio",
2817 [CXD9872AKD_VAIO] = "vaio-ar",
2820 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2821 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2822 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2823 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
2824 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
2828 static int patch_stac9872(struct hda_codec *codec)
2830 struct sigmatel_spec *spec;
2833 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
2836 if (board_config < 0)
2837 /* unknown config, let generic-parser do its job... */
2838 return snd_hda_parse_generic_codec(codec);
2840 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2845 switch (board_config) {
2846 case CXD9872RD_VAIO:
2847 case STAC9872AK_VAIO:
2848 case STAC9872K_VAIO:
2849 spec->mixer = vaio_mixer;
2850 spec->init = vaio_init;
2851 spec->multiout.max_channels = 2;
2852 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2853 spec->multiout.dac_nids = vaio_dacs;
2854 spec->multiout.hp_nid = VAIO_HP_DAC;
2855 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2856 spec->adc_nids = vaio_adcs;
2857 spec->input_mux = &vaio_mux;
2858 spec->mux_nids = vaio_mux_nids;
2859 codec->patch_ops = stac9872_vaio_patch_ops;
2862 case CXD9872AKD_VAIO:
2863 spec->mixer = vaio_ar_mixer;
2864 spec->init = vaio_ar_init;
2865 spec->multiout.max_channels = 2;
2866 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2867 spec->multiout.dac_nids = vaio_dacs;
2868 spec->multiout.hp_nid = VAIO_HP_DAC;
2869 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2870 spec->adc_nids = vaio_adcs;
2871 spec->input_mux = &vaio_mux;
2872 spec->mux_nids = vaio_mux_nids;
2873 codec->patch_ops = stac9872_patch_ops;
2884 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
2885 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
2886 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
2887 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
2888 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
2889 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
2890 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
2891 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
2892 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
2893 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
2894 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
2895 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
2896 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
2897 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
2898 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
2899 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
2900 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
2901 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
2902 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
2903 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
2904 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
2905 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
2906 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
2907 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
2908 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
2909 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
2910 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
2911 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
2912 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
2913 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
2914 /* The following does not take into account .id=0x83847661 when subsys =
2915 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2916 * currently not fully supported.
2918 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
2919 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
2920 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
2921 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
2922 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
2923 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
2924 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
2925 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
2926 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
2927 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
2928 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },