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
71 /* for backward compitability */
89 struct sigmatel_spec {
90 struct snd_kcontrol_new *mixers[4];
91 unsigned int num_mixers;
94 unsigned int surr_switch: 1;
95 unsigned int line_switch: 1;
96 unsigned int mic_switch: 1;
97 unsigned int alt_switch: 1;
98 unsigned int hp_detect: 1;
99 unsigned int gpio_mute: 1;
101 unsigned int gpio_mask, gpio_data;
104 struct hda_multi_out multiout;
105 hda_nid_t dac_nids[5];
109 unsigned int num_adcs;
111 unsigned int num_muxes;
112 hda_nid_t *dmic_nids;
113 unsigned int num_dmics;
115 hda_nid_t dig_in_nid;
119 unsigned int num_pins;
120 unsigned int *pin_configs;
121 unsigned int *bios_pin_configs;
123 /* codec specific stuff */
124 struct hda_verb *init;
125 struct snd_kcontrol_new *mixer;
128 struct hda_input_mux *dinput_mux;
129 unsigned int cur_dmux;
130 struct hda_input_mux *input_mux;
131 unsigned int cur_mux[3];
134 unsigned int io_switch[2];
136 struct hda_pcm pcm_rec[2]; /* PCM information */
138 /* dynamic controls and input_mux */
139 struct auto_pin_cfg autocfg;
140 unsigned int num_kctl_alloc, num_kctl_used;
141 struct snd_kcontrol_new *kctl_alloc;
142 struct hda_input_mux private_dimux;
143 struct hda_input_mux private_imux;
146 static hda_nid_t stac9200_adc_nids[1] = {
150 static hda_nid_t stac9200_mux_nids[1] = {
154 static hda_nid_t stac9200_dac_nids[1] = {
158 static hda_nid_t stac925x_adc_nids[1] = {
162 static hda_nid_t stac925x_mux_nids[1] = {
166 static hda_nid_t stac925x_dac_nids[1] = {
170 static hda_nid_t stac925x_dmic_nids[1] = {
174 static hda_nid_t stac922x_adc_nids[2] = {
178 static hda_nid_t stac922x_mux_nids[2] = {
182 static hda_nid_t stac927x_adc_nids[3] = {
186 static hda_nid_t stac927x_mux_nids[3] = {
190 static hda_nid_t stac9205_adc_nids[2] = {
194 static hda_nid_t stac9205_mux_nids[2] = {
198 static hda_nid_t stac9205_dmic_nids[2] = {
202 static hda_nid_t stac9200_pin_nids[8] = {
203 0x08, 0x09, 0x0d, 0x0e,
204 0x0f, 0x10, 0x11, 0x12,
207 static hda_nid_t stac925x_pin_nids[8] = {
208 0x07, 0x08, 0x0a, 0x0b,
209 0x0c, 0x0d, 0x10, 0x11,
212 static hda_nid_t stac922x_pin_nids[10] = {
213 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
214 0x0f, 0x10, 0x11, 0x15, 0x1b,
217 static hda_nid_t stac927x_pin_nids[14] = {
218 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
219 0x0f, 0x10, 0x11, 0x12, 0x13,
220 0x14, 0x21, 0x22, 0x23,
223 static hda_nid_t stac9205_pin_nids[12] = {
224 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
225 0x0f, 0x14, 0x16, 0x17, 0x18,
229 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
230 struct snd_ctl_elem_info *uinfo)
232 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
233 struct sigmatel_spec *spec = codec->spec;
234 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
237 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
238 struct snd_ctl_elem_value *ucontrol)
240 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
241 struct sigmatel_spec *spec = codec->spec;
243 ucontrol->value.enumerated.item[0] = spec->cur_dmux;
247 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
248 struct snd_ctl_elem_value *ucontrol)
250 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
251 struct sigmatel_spec *spec = codec->spec;
253 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
254 spec->dmux_nid, &spec->cur_dmux);
257 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
259 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
260 struct sigmatel_spec *spec = codec->spec;
261 return snd_hda_input_mux_info(spec->input_mux, uinfo);
264 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
266 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
267 struct sigmatel_spec *spec = codec->spec;
268 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
270 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
274 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
276 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
277 struct sigmatel_spec *spec = codec->spec;
278 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
280 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
281 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
284 static struct hda_verb stac9200_core_init[] = {
285 /* set dac0mux for dac converter */
286 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
290 static struct hda_verb stac925x_core_init[] = {
291 /* set dac0mux for dac converter */
292 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
296 static struct hda_verb stac922x_core_init[] = {
297 /* set master volume and direct control */
298 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
302 static struct hda_verb d965_core_init[] = {
303 /* set master volume and direct control */
304 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
305 /* unmute node 0x1b */
306 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
307 /* select node 0x03 as DAC */
308 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
312 static struct hda_verb stac927x_core_init[] = {
313 /* set master volume and direct control */
314 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
318 static struct hda_verb stac9205_core_init[] = {
319 /* set master volume and direct control */
320 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
324 static struct snd_kcontrol_new stac9200_mixer[] = {
325 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
326 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
328 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
329 .name = "Input Source",
331 .info = stac92xx_mux_enum_info,
332 .get = stac92xx_mux_enum_get,
333 .put = stac92xx_mux_enum_put,
335 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
336 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
337 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
341 static struct snd_kcontrol_new stac925x_mixer[] = {
343 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
344 .name = "Input Source",
346 .info = stac92xx_mux_enum_info,
347 .get = stac92xx_mux_enum_get,
348 .put = stac92xx_mux_enum_put,
350 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
351 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
352 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
356 /* This needs to be generated dynamically based on sequence */
357 static struct snd_kcontrol_new stac922x_mixer[] = {
359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
360 .name = "Input Source",
362 .info = stac92xx_mux_enum_info,
363 .get = stac92xx_mux_enum_get,
364 .put = stac92xx_mux_enum_put,
366 HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
367 HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
368 HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
372 /* This needs to be generated dynamically based on sequence */
373 static struct snd_kcontrol_new stac9227_mixer[] = {
375 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
376 .name = "Input Source",
378 .info = stac92xx_mux_enum_info,
379 .get = stac92xx_mux_enum_get,
380 .put = stac92xx_mux_enum_put,
382 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
383 HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
387 static struct snd_kcontrol_new stac927x_mixer[] = {
389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
390 .name = "Input Source",
392 .info = stac92xx_mux_enum_info,
393 .get = stac92xx_mux_enum_get,
394 .put = stac92xx_mux_enum_put,
396 HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
397 HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
398 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
402 static struct snd_kcontrol_new stac9205_mixer[] = {
404 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
405 .name = "Digital Input Source",
407 .info = stac92xx_dmux_enum_info,
408 .get = stac92xx_dmux_enum_get,
409 .put = stac92xx_dmux_enum_put,
412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
413 .name = "Input Source",
415 .info = stac92xx_mux_enum_info,
416 .get = stac92xx_mux_enum_get,
417 .put = stac92xx_mux_enum_put,
419 HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
420 HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
421 HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
425 static int stac92xx_build_controls(struct hda_codec *codec)
427 struct sigmatel_spec *spec = codec->spec;
431 err = snd_hda_add_new_ctls(codec, spec->mixer);
435 for (i = 0; i < spec->num_mixers; i++) {
436 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
441 if (spec->multiout.dig_out_nid) {
442 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
446 if (spec->dig_in_nid) {
447 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
454 static unsigned int ref9200_pin_configs[8] = {
455 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
456 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
459 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
460 [STAC_REF] = ref9200_pin_configs,
463 static const char *stac9200_models[STAC_9200_MODELS] = {
467 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
468 /* SigmaTel reference board */
469 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
470 "DFI LanParty", STAC_REF),
471 /* Dell laptops have BIOS problem */
472 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
473 "Dell Inspiron 630m", STAC_REF),
474 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
475 "Dell Latitude D620", STAC_REF),
476 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
477 "Dell Latitude 120L", STAC_REF),
478 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
479 "Dell Latitude D820", STAC_REF),
480 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
481 "Dell Inspiron E1705/9400", STAC_REF),
482 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
483 "Dell XPS M1710", STAC_REF),
484 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
485 "Dell Precision M90", STAC_REF),
486 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
487 "unknown Dell", STAC_REF),
488 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
489 "Dell Inspiron 640m", STAC_REF),
490 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
491 "Dell Inspiron 1501", STAC_REF),
494 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
499 static unsigned int ref925x_pin_configs[8] = {
500 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
501 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
504 static unsigned int stac925x_MA6_pin_configs[8] = {
505 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
506 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
509 static unsigned int stac925x_PA6_pin_configs[8] = {
510 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
511 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
514 static unsigned int stac925xM2_2_pin_configs[8] = {
515 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
516 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
519 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
520 [STAC_REF] = ref925x_pin_configs,
521 [STAC_M2_2] = stac925xM2_2_pin_configs,
522 [STAC_MA6] = stac925x_MA6_pin_configs,
523 [STAC_PA6] = stac925x_PA6_pin_configs,
526 static const char *stac925x_models[STAC_925x_MODELS] = {
528 [STAC_M2_2] = "m2-2",
533 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
534 /* SigmaTel reference board */
535 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
536 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
537 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
538 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
539 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
540 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
541 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
545 static unsigned int ref922x_pin_configs[10] = {
546 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
547 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
548 0x40000100, 0x40000100,
551 static unsigned int d945gtp3_pin_configs[10] = {
552 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
553 0x40000100, 0x40000100, 0x40000100, 0x40000100,
554 0x02a19120, 0x40000100,
557 static unsigned int d945gtp5_pin_configs[10] = {
558 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
559 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
560 0x02a19320, 0x40000100,
563 static unsigned int intel_mac_v1_pin_configs[10] = {
564 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
565 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
566 0x400000fc, 0x400000fb,
569 static unsigned int intel_mac_v2_pin_configs[10] = {
570 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
571 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
572 0x400000fc, 0x400000fb,
575 static unsigned int intel_mac_v3_pin_configs[10] = {
576 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
577 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
578 0x400000fc, 0x400000fb,
581 static unsigned int intel_mac_v4_pin_configs[10] = {
582 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
583 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
584 0x400000fc, 0x400000fb,
587 static unsigned int intel_mac_v5_pin_configs[10] = {
588 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
589 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
590 0x400000fc, 0x400000fb,
593 static unsigned int stac922x_dell_pin_configs[10] = {
594 0x0221121e, 0x408103ff, 0x02a1123e, 0x90100310,
595 0x408003f1, 0x0221122f, 0x03451340, 0x40c003f2,
596 0x50a003f3, 0x405003f4
599 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
600 [STAC_D945_REF] = ref922x_pin_configs,
601 [STAC_D945GTP3] = d945gtp3_pin_configs,
602 [STAC_D945GTP5] = d945gtp5_pin_configs,
603 [STAC_922X_DELL] = stac922x_dell_pin_configs,
604 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
605 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
606 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
607 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
608 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
609 /* for backward compitability */
610 [STAC_MACMINI] = intel_mac_v3_pin_configs,
611 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
612 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
613 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
614 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
615 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
618 static const char *stac922x_models[STAC_922X_MODELS] = {
619 [STAC_D945_REF] = "ref",
620 [STAC_D945GTP5] = "5stack",
621 [STAC_D945GTP3] = "3stack",
622 [STAC_922X_DELL] = "dell",
623 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
624 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
625 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
626 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
627 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
628 /* for backward compitability */
629 [STAC_MACMINI] = "macmini",
630 [STAC_MACBOOK] = "macbook",
631 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
632 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
633 [STAC_IMAC_INTEL] = "imac-intel",
634 [STAC_IMAC_INTEL_20] = "imac-intel-20",
637 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
638 /* SigmaTel reference board */
639 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
640 "DFI LanParty", STAC_D945_REF),
641 /* Intel 945G based systems */
642 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
643 "Intel D945G", STAC_D945GTP3),
644 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
645 "Intel D945G", STAC_D945GTP3),
646 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
647 "Intel D945G", STAC_D945GTP3),
648 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
649 "Intel D945G", STAC_D945GTP3),
650 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
651 "Intel D945G", STAC_D945GTP3),
652 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
653 "Intel D945G", STAC_D945GTP3),
654 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
655 "Intel D945G", STAC_D945GTP3),
656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
657 "Intel D945G", STAC_D945GTP3),
658 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
659 "Intel D945G", STAC_D945GTP3),
660 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
661 "Intel D945G", STAC_D945GTP3),
662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
663 "Intel D945G", STAC_D945GTP3),
664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
665 "Intel D945G", STAC_D945GTP3),
666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
667 "Intel D945G", STAC_D945GTP3),
668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
669 "Intel D945G", STAC_D945GTP3),
670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
671 "Intel D945G", STAC_D945GTP3),
672 /* Intel D945G 5-stack systems */
673 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
674 "Intel D945G", STAC_D945GTP5),
675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
676 "Intel D945G", STAC_D945GTP5),
677 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
678 "Intel D945G", STAC_D945GTP5),
679 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
680 "Intel D945G", STAC_D945GTP5),
681 /* Intel 945P based systems */
682 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
683 "Intel D945P", STAC_D945GTP3),
684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
685 "Intel D945P", STAC_D945GTP3),
686 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
687 "Intel D945P", STAC_D945GTP3),
688 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
689 "Intel D945P", STAC_D945GTP3),
690 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
691 "Intel D945P", STAC_D945GTP3),
692 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
693 "Intel D945P", STAC_D945GTP5),
695 /* Apple Mac Mini (early 2006) */
696 SND_PCI_QUIRK(0x8384, 0x7680,
697 "Mac Mini", STAC_INTEL_MAC_V3),
699 SND_PCI_QUIRK(0x1028, 0x01d7, "Dell XPS M1210", STAC_922X_DELL),
704 static unsigned int ref927x_pin_configs[14] = {
705 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
706 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
707 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
708 0x01c42190, 0x40000100,
711 static unsigned int d965_3st_pin_configs[14] = {
712 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
713 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
714 0x40000100, 0x40000100, 0x40000100, 0x40000100,
715 0x40000100, 0x40000100
718 static unsigned int d965_5st_pin_configs[14] = {
719 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
720 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
721 0x40000100, 0x40000100, 0x40000100, 0x01442070,
722 0x40000100, 0x40000100
725 static unsigned int dell_3st_pin_configs[14] = {
726 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
727 0x01111212, 0x01116211, 0x01813050, 0x01112214,
728 0x403003fa, 0x40000100, 0x40000100, 0x404003fb,
729 0x40c003fc, 0x40000100
732 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
733 [STAC_D965_REF] = ref927x_pin_configs,
734 [STAC_D965_3ST] = d965_3st_pin_configs,
735 [STAC_D965_5ST] = d965_5st_pin_configs,
736 [STAC_DELL_3ST] = dell_3st_pin_configs,
739 static const char *stac927x_models[STAC_927X_MODELS] = {
740 [STAC_D965_REF] = "ref",
741 [STAC_D965_3ST] = "3stack",
742 [STAC_D965_5ST] = "5stack",
743 [STAC_DELL_3ST] = "dell-3stack",
746 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
747 /* SigmaTel reference board */
748 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
749 "DFI LanParty", STAC_D965_REF),
750 /* Intel 946 based systems */
751 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
752 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
753 /* 965 based 3 stack systems */
754 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
755 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
756 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
757 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
758 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
759 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
760 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
761 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
762 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
763 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
764 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
766 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
767 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
768 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
769 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
770 /* Dell 3 stack systems */
771 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell E520", STAC_DELL_3ST),
772 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
773 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
774 /* 965 based 5 stack systems */
775 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
776 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
777 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
778 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
779 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
780 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
781 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
782 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
783 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
787 static unsigned int ref9205_pin_configs[12] = {
788 0x40000100, 0x40000100, 0x01016011, 0x01014010,
789 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
790 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
793 static unsigned int dell_m43_9205_pin_configs[12] = {
794 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
795 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
796 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
799 static unsigned int dell_m44_9205_pin_configs[12] = {
800 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
801 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
802 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
806 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
807 [STAC_9205_REF] = ref9205_pin_configs,
808 [STAC_9205_DELL_M43] = dell_m43_9205_pin_configs,
809 [STAC_9205_DELL_M44] = dell_m44_9205_pin_configs,
810 [STAC_9205_M43xx] = NULL,
813 static const char *stac9205_models[STAC_9205_MODELS] = {
814 [STAC_9205_REF] = "ref",
815 [STAC_9205_DELL_M43] = "dell-m43",
816 [STAC_9205_DELL_M44] = "dell-m44",
819 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
820 /* SigmaTel reference board */
821 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
822 "DFI LanParty", STAC_9205_REF),
823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
824 "Dell Precision", STAC_9205_M43xx),
825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
826 "Dell Precision", STAC_9205_DELL_M43),
827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
828 "Dell Precision", STAC_9205_DELL_M43),
829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
830 "Dell Precision", STAC_9205_DELL_M43),
831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
832 "Dell Precision", STAC_9205_DELL_M43),
833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
834 "Dell Precision", STAC_9205_DELL_M43),
835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
836 "Dell Inspiron", STAC_9205_DELL_M44),
837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
838 "Dell Inspiron", STAC_9205_DELL_M44),
839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
840 "Dell Inspiron", STAC_9205_DELL_M44),
841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
842 "Dell Inspiron", STAC_9205_DELL_M44),
843 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
844 "Dell Inspiron", STAC_9205_DELL_M44),
848 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
851 struct sigmatel_spec *spec = codec->spec;
853 if (! spec->bios_pin_configs) {
854 spec->bios_pin_configs = kcalloc(spec->num_pins,
855 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
856 if (! spec->bios_pin_configs)
860 for (i = 0; i < spec->num_pins; i++) {
861 hda_nid_t nid = spec->pin_nids[i];
862 unsigned int pin_cfg;
864 pin_cfg = snd_hda_codec_read(codec, nid, 0,
865 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
866 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
868 spec->bios_pin_configs[i] = pin_cfg;
874 static void stac92xx_set_config_reg(struct hda_codec *codec,
875 hda_nid_t pin_nid, unsigned int pin_config)
878 snd_hda_codec_write(codec, pin_nid, 0,
879 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
880 pin_config & 0x000000ff);
881 snd_hda_codec_write(codec, pin_nid, 0,
882 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
883 (pin_config & 0x0000ff00) >> 8);
884 snd_hda_codec_write(codec, pin_nid, 0,
885 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
886 (pin_config & 0x00ff0000) >> 16);
887 snd_hda_codec_write(codec, pin_nid, 0,
888 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
890 i = snd_hda_codec_read(codec, pin_nid, 0,
891 AC_VERB_GET_CONFIG_DEFAULT,
893 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
897 static void stac92xx_set_config_regs(struct hda_codec *codec)
900 struct sigmatel_spec *spec = codec->spec;
902 if (!spec->pin_configs)
905 for (i = 0; i < spec->num_pins; i++)
906 stac92xx_set_config_reg(codec, spec->pin_nids[i],
907 spec->pin_configs[i]);
910 static void stac92xx_enable_gpio_mask(struct hda_codec *codec)
912 struct sigmatel_spec *spec = codec->spec;
913 /* Configure GPIOx as output */
914 snd_hda_codec_write_cache(codec, codec->afg, 0,
915 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask);
916 /* Configure GPIOx as CMOS */
917 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000);
919 snd_hda_codec_write_cache(codec, codec->afg, 0,
920 AC_VERB_SET_GPIO_DATA, spec->gpio_data);
922 snd_hda_codec_write_cache(codec, codec->afg, 0,
923 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
927 * Analog playback callbacks
929 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
930 struct hda_codec *codec,
931 struct snd_pcm_substream *substream)
933 struct sigmatel_spec *spec = codec->spec;
934 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
937 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
938 struct hda_codec *codec,
939 unsigned int stream_tag,
941 struct snd_pcm_substream *substream)
943 struct sigmatel_spec *spec = codec->spec;
944 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
947 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
948 struct hda_codec *codec,
949 struct snd_pcm_substream *substream)
951 struct sigmatel_spec *spec = codec->spec;
952 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
956 * Digital playback callbacks
958 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
959 struct hda_codec *codec,
960 struct snd_pcm_substream *substream)
962 struct sigmatel_spec *spec = codec->spec;
963 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
966 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
967 struct hda_codec *codec,
968 struct snd_pcm_substream *substream)
970 struct sigmatel_spec *spec = codec->spec;
971 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
974 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
975 struct hda_codec *codec,
976 unsigned int stream_tag,
978 struct snd_pcm_substream *substream)
980 struct sigmatel_spec *spec = codec->spec;
981 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
982 stream_tag, format, substream);
987 * Analog capture callbacks
989 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
990 struct hda_codec *codec,
991 unsigned int stream_tag,
993 struct snd_pcm_substream *substream)
995 struct sigmatel_spec *spec = codec->spec;
997 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
998 stream_tag, 0, format);
1002 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1003 struct hda_codec *codec,
1004 struct snd_pcm_substream *substream)
1006 struct sigmatel_spec *spec = codec->spec;
1008 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1012 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1016 /* NID is set in stac92xx_build_pcms */
1018 .open = stac92xx_dig_playback_pcm_open,
1019 .close = stac92xx_dig_playback_pcm_close,
1020 .prepare = stac92xx_dig_playback_pcm_prepare
1024 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1028 /* NID is set in stac92xx_build_pcms */
1031 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1035 .nid = 0x02, /* NID to query formats and rates */
1037 .open = stac92xx_playback_pcm_open,
1038 .prepare = stac92xx_playback_pcm_prepare,
1039 .cleanup = stac92xx_playback_pcm_cleanup
1043 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1047 .nid = 0x06, /* NID to query formats and rates */
1049 .open = stac92xx_playback_pcm_open,
1050 .prepare = stac92xx_playback_pcm_prepare,
1051 .cleanup = stac92xx_playback_pcm_cleanup
1055 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1059 /* NID is set in stac92xx_build_pcms */
1061 .prepare = stac92xx_capture_pcm_prepare,
1062 .cleanup = stac92xx_capture_pcm_cleanup
1066 static int stac92xx_build_pcms(struct hda_codec *codec)
1068 struct sigmatel_spec *spec = codec->spec;
1069 struct hda_pcm *info = spec->pcm_rec;
1071 codec->num_pcms = 1;
1072 codec->pcm_info = info;
1074 info->name = "STAC92xx Analog";
1075 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
1076 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
1077 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1079 if (spec->alt_switch) {
1082 info->name = "STAC92xx Analog Alt";
1083 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1086 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1089 info->name = "STAC92xx Digital";
1090 if (spec->multiout.dig_out_nid) {
1091 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1092 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1094 if (spec->dig_in_nid) {
1095 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1096 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1103 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1105 unsigned int pincap = snd_hda_param_read(codec, nid,
1107 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1108 if (pincap & AC_PINCAP_VREF_100)
1109 return AC_PINCTL_VREF_100;
1110 if (pincap & AC_PINCAP_VREF_80)
1111 return AC_PINCTL_VREF_80;
1112 if (pincap & AC_PINCAP_VREF_50)
1113 return AC_PINCTL_VREF_50;
1114 if (pincap & AC_PINCAP_VREF_GRD)
1115 return AC_PINCTL_VREF_GRD;
1119 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1122 snd_hda_codec_write_cache(codec, nid, 0,
1123 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1126 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1128 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1130 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1131 struct sigmatel_spec *spec = codec->spec;
1132 int io_idx = kcontrol-> private_value & 0xff;
1134 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1138 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1140 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1141 struct sigmatel_spec *spec = codec->spec;
1142 hda_nid_t nid = kcontrol->private_value >> 8;
1143 int io_idx = kcontrol-> private_value & 0xff;
1144 unsigned short val = ucontrol->value.integer.value[0];
1146 spec->io_switch[io_idx] = val;
1149 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1151 unsigned int pinctl = AC_PINCTL_IN_EN;
1152 if (io_idx) /* set VREF for mic */
1153 pinctl |= stac92xx_get_vref(codec, nid);
1154 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1159 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
1160 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1163 .info = stac92xx_io_switch_info, \
1164 .get = stac92xx_io_switch_get, \
1165 .put = stac92xx_io_switch_put, \
1166 .private_value = xpval, \
1171 STAC_CTL_WIDGET_VOL,
1172 STAC_CTL_WIDGET_MUTE,
1173 STAC_CTL_WIDGET_IO_SWITCH,
1176 static struct snd_kcontrol_new stac92xx_control_templates[] = {
1177 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1178 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1179 STAC_CODEC_IO_SWITCH(NULL, 0),
1182 /* add dynamic controls */
1183 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1185 struct snd_kcontrol_new *knew;
1187 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1188 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1190 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1193 if (spec->kctl_alloc) {
1194 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1195 kfree(spec->kctl_alloc);
1197 spec->kctl_alloc = knew;
1198 spec->num_kctl_alloc = num;
1201 knew = &spec->kctl_alloc[spec->num_kctl_used];
1202 *knew = stac92xx_control_templates[type];
1203 knew->name = kstrdup(name, GFP_KERNEL);
1206 knew->private_value = val;
1207 spec->num_kctl_used++;
1211 /* flag inputs as additional dynamic lineouts */
1212 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1214 struct sigmatel_spec *spec = codec->spec;
1215 unsigned int wcaps, wtype;
1216 int i, num_dacs = 0;
1218 /* use the wcaps cache to count all DACs available for line-outs */
1219 for (i = 0; i < codec->num_nodes; i++) {
1220 wcaps = codec->wcaps[i];
1221 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1222 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1226 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1228 switch (cfg->line_outs) {
1230 /* add line-in as side */
1231 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1232 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
1233 spec->line_switch = 1;
1238 /* add line-in as clfe and mic as side */
1239 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1240 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
1241 spec->line_switch = 1;
1244 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1245 cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
1246 spec->mic_switch = 1;
1251 /* add line-in as surr and mic as clfe */
1252 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1253 cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
1254 spec->line_switch = 1;
1257 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1258 cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
1259 spec->mic_switch = 1;
1269 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1273 for (i = 0; i < spec->multiout.num_dacs; i++) {
1274 if (spec->multiout.dac_nids[i] == nid)
1282 * Fill in the dac_nids table from the parsed pin configuration
1283 * This function only works when every pin in line_out_pins[]
1284 * contains atleast one DAC in its connection list. Some 92xx
1285 * codecs are not connected directly to a DAC, such as the 9200
1286 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1288 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1289 struct auto_pin_cfg *cfg)
1291 struct sigmatel_spec *spec = codec->spec;
1292 int i, j, conn_len = 0;
1293 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1294 unsigned int wcaps, wtype;
1296 for (i = 0; i < cfg->line_outs; i++) {
1297 nid = cfg->line_out_pins[i];
1298 conn_len = snd_hda_get_connections(codec, nid, conn,
1299 HDA_MAX_CONNECTIONS);
1300 for (j = 0; j < conn_len; j++) {
1301 wcaps = snd_hda_param_read(codec, conn[j],
1302 AC_PAR_AUDIO_WIDGET_CAP);
1303 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1305 if (wtype != AC_WID_AUD_OUT ||
1306 (wcaps & AC_WCAP_DIGITAL))
1308 /* conn[j] is a DAC routed to this line-out */
1309 if (!is_in_dac_nids(spec, conn[j]))
1313 if (j == conn_len) {
1314 if (spec->multiout.num_dacs > 0) {
1315 /* we have already working output pins,
1316 * so let's drop the broken ones again
1318 cfg->line_outs = spec->multiout.num_dacs;
1321 /* error out, no available DAC found */
1323 "%s: No available DAC for pin 0x%x\n",
1328 spec->multiout.dac_nids[i] = conn[j];
1329 spec->multiout.num_dacs++;
1331 /* select this DAC in the pin's input mux */
1332 snd_hda_codec_write_cache(codec, nid, 0,
1333 AC_VERB_SET_CONNECT_SEL, j);
1338 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1339 spec->multiout.num_dacs,
1340 spec->multiout.dac_nids[0],
1341 spec->multiout.dac_nids[1],
1342 spec->multiout.dac_nids[2],
1343 spec->multiout.dac_nids[3],
1344 spec->multiout.dac_nids[4]);
1348 /* create volume control/switch for the given prefx type */
1349 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1354 sprintf(name, "%s Playback Volume", pfx);
1355 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1356 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1359 sprintf(name, "%s Playback Switch", pfx);
1360 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1361 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1367 /* add playback controls from the parsed DAC table */
1368 static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
1369 const struct auto_pin_cfg *cfg)
1371 static const char *chname[4] = {
1372 "Front", "Surround", NULL /*CLFE*/, "Side"
1377 for (i = 0; i < cfg->line_outs; i++) {
1378 if (!spec->multiout.dac_nids[i])
1381 nid = spec->multiout.dac_nids[i];
1385 err = create_controls(spec, "Center", nid, 1);
1388 err = create_controls(spec, "LFE", nid, 2);
1392 err = create_controls(spec, chname[i], nid, 3);
1398 if (spec->line_switch)
1399 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1402 if (spec->mic_switch)
1403 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1409 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1411 if (is_in_dac_nids(spec, nid))
1413 if (spec->multiout.hp_nid == nid)
1418 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1420 if (!spec->multiout.hp_nid)
1421 spec->multiout.hp_nid = nid;
1422 else if (spec->multiout.num_dacs > 4) {
1423 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1426 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1427 spec->multiout.num_dacs++;
1432 /* add playback controls for Speaker and HP outputs */
1433 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1434 struct auto_pin_cfg *cfg)
1436 struct sigmatel_spec *spec = codec->spec;
1438 int i, old_num_dacs, err;
1440 old_num_dacs = spec->multiout.num_dacs;
1441 for (i = 0; i < cfg->hp_outs; i++) {
1442 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1443 if (wid_caps & AC_WCAP_UNSOL_CAP)
1444 spec->hp_detect = 1;
1445 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1446 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1447 if (check_in_dac_nids(spec, nid))
1451 add_spec_dacs(spec, nid);
1453 for (i = 0; i < cfg->speaker_outs; i++) {
1454 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1455 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1456 if (check_in_dac_nids(spec, nid))
1460 add_spec_dacs(spec, nid);
1462 for (i = 0; i < cfg->line_outs; i++) {
1463 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
1464 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1465 if (check_in_dac_nids(spec, nid))
1469 add_spec_dacs(spec, nid);
1471 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1472 static const char *pfxs[] = {
1473 "Speaker", "External Speaker", "Speaker2",
1475 err = create_controls(spec, pfxs[i - old_num_dacs],
1476 spec->multiout.dac_nids[i], 3);
1480 if (spec->multiout.hp_nid) {
1482 if (old_num_dacs == spec->multiout.num_dacs)
1486 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
1494 /* labels for dmic mux inputs */
1495 static const char *stac92xx_dmic_labels[5] = {
1496 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
1497 "Digital Mic 3", "Digital Mic 4"
1500 /* create playback/capture controls for input pins on dmic capable codecs */
1501 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
1502 const struct auto_pin_cfg *cfg)
1504 struct sigmatel_spec *spec = codec->spec;
1505 struct hda_input_mux *dimux = &spec->private_dimux;
1506 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1509 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
1510 dimux->items[dimux->num_items].index = 0;
1513 for (i = 0; i < spec->num_dmics; i++) {
1516 unsigned int def_conf;
1518 def_conf = snd_hda_codec_read(codec,
1521 AC_VERB_GET_CONFIG_DEFAULT,
1523 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
1526 num_cons = snd_hda_get_connections(codec,
1529 HDA_MAX_NUM_INPUTS);
1530 for (j = 0; j < num_cons; j++)
1531 if (con_lst[j] == spec->dmic_nids[i]) {
1537 dimux->items[dimux->num_items].label =
1538 stac92xx_dmic_labels[dimux->num_items];
1539 dimux->items[dimux->num_items].index = index;
1546 /* create playback/capture controls for input pins */
1547 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
1549 struct sigmatel_spec *spec = codec->spec;
1550 struct hda_input_mux *imux = &spec->private_imux;
1551 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
1554 for (i = 0; i < AUTO_PIN_LAST; i++) {
1557 if (!cfg->input_pins[i])
1560 for (j = 0; j < spec->num_muxes; j++) {
1562 num_cons = snd_hda_get_connections(codec,
1565 HDA_MAX_NUM_INPUTS);
1566 for (k = 0; k < num_cons; k++)
1567 if (con_lst[k] == cfg->input_pins[i]) {
1574 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
1575 imux->items[imux->num_items].index = index;
1579 if (imux->num_items) {
1581 * Set the current input for the muxes.
1582 * The STAC9221 has two input muxes with identical source
1583 * NID lists. Hopefully this won't get confused.
1585 for (i = 0; i < spec->num_muxes; i++) {
1586 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
1587 AC_VERB_SET_CONNECT_SEL,
1588 imux->items[0].index);
1595 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
1597 struct sigmatel_spec *spec = codec->spec;
1600 for (i = 0; i < spec->autocfg.line_outs; i++) {
1601 hda_nid_t nid = spec->autocfg.line_out_pins[i];
1602 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1606 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
1608 struct sigmatel_spec *spec = codec->spec;
1611 for (i = 0; i < spec->autocfg.hp_outs; i++) {
1613 pin = spec->autocfg.hp_pins[i];
1614 if (pin) /* connect to front */
1615 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
1617 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
1619 pin = spec->autocfg.speaker_pins[i];
1620 if (pin) /* connect to front */
1621 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
1625 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
1627 struct sigmatel_spec *spec = codec->spec;
1630 if ((err = snd_hda_parse_pin_def_config(codec,
1632 spec->dmic_nids)) < 0)
1634 if (! spec->autocfg.line_outs)
1635 return 0; /* can't find valid pin config */
1637 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
1639 if (spec->multiout.num_dacs == 0)
1640 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
1643 if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
1644 (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
1645 (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1648 if (spec->num_dmics > 0)
1649 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
1650 &spec->autocfg)) < 0)
1653 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
1654 if (spec->multiout.max_channels > 2)
1655 spec->surr_switch = 1;
1657 if (spec->autocfg.dig_out_pin)
1658 spec->multiout.dig_out_nid = dig_out;
1659 if (spec->autocfg.dig_in_pin)
1660 spec->dig_in_nid = dig_in;
1662 if (spec->kctl_alloc)
1663 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1665 spec->input_mux = &spec->private_imux;
1666 spec->dinput_mux = &spec->private_dimux;
1671 /* add playback controls for HP output */
1672 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
1673 struct auto_pin_cfg *cfg)
1675 struct sigmatel_spec *spec = codec->spec;
1676 hda_nid_t pin = cfg->hp_pins[0];
1677 unsigned int wid_caps;
1682 wid_caps = get_wcaps(codec, pin);
1683 if (wid_caps & AC_WCAP_UNSOL_CAP)
1684 spec->hp_detect = 1;
1689 /* add playback controls for LFE output */
1690 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
1691 struct auto_pin_cfg *cfg)
1693 struct sigmatel_spec *spec = codec->spec;
1695 hda_nid_t lfe_pin = 0x0;
1699 * search speaker outs and line outs for a mono speaker pin
1700 * with an amp. If one is found, add LFE controls
1703 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
1704 hda_nid_t pin = spec->autocfg.speaker_pins[i];
1705 unsigned long wcaps = get_wcaps(codec, pin);
1706 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1707 if (wcaps == AC_WCAP_OUT_AMP)
1708 /* found a mono speaker with an amp, must be lfe */
1712 /* if speaker_outs is 0, then speakers may be in line_outs */
1713 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
1714 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
1715 hda_nid_t pin = spec->autocfg.line_out_pins[i];
1717 cfg = snd_hda_codec_read(codec, pin, 0,
1718 AC_VERB_GET_CONFIG_DEFAULT,
1720 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
1721 unsigned long wcaps = get_wcaps(codec, pin);
1722 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
1723 if (wcaps == AC_WCAP_OUT_AMP)
1724 /* found a mono speaker with an amp,
1732 err = create_controls(spec, "LFE", lfe_pin, 1);
1740 static int stac9200_parse_auto_config(struct hda_codec *codec)
1742 struct sigmatel_spec *spec = codec->spec;
1745 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
1748 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
1751 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
1754 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
1757 if (spec->autocfg.dig_out_pin)
1758 spec->multiout.dig_out_nid = 0x05;
1759 if (spec->autocfg.dig_in_pin)
1760 spec->dig_in_nid = 0x04;
1762 if (spec->kctl_alloc)
1763 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
1765 spec->input_mux = &spec->private_imux;
1766 spec->dinput_mux = &spec->private_dimux;
1772 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
1773 * funky external mute control using GPIO pins.
1776 static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
1778 unsigned int gpiostate, gpiomask, gpiodir;
1780 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
1781 AC_VERB_GET_GPIO_DATA, 0);
1784 gpiostate |= (1 << pin);
1786 gpiostate &= ~(1 << pin);
1788 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
1789 AC_VERB_GET_GPIO_MASK, 0);
1790 gpiomask |= (1 << pin);
1792 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
1793 AC_VERB_GET_GPIO_DIRECTION, 0);
1794 gpiodir |= (1 << pin);
1796 /* AppleHDA seems to do this -- WTF is this verb?? */
1797 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
1799 snd_hda_codec_write(codec, codec->afg, 0,
1800 AC_VERB_SET_GPIO_MASK, gpiomask);
1801 snd_hda_codec_write(codec, codec->afg, 0,
1802 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
1806 snd_hda_codec_write(codec, codec->afg, 0,
1807 AC_VERB_SET_GPIO_DATA, gpiostate);
1810 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
1813 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
1814 snd_hda_codec_write(codec, nid, 0,
1815 AC_VERB_SET_UNSOLICITED_ENABLE,
1816 (AC_USRSP_EN | event));
1819 static int stac92xx_init(struct hda_codec *codec)
1821 struct sigmatel_spec *spec = codec->spec;
1822 struct auto_pin_cfg *cfg = &spec->autocfg;
1825 snd_hda_sequence_write(codec, spec->init);
1828 if (spec->hp_detect) {
1829 /* Enable unsolicited responses on the HP widget */
1830 for (i = 0; i < cfg->hp_outs; i++)
1831 enable_pin_detect(codec, cfg->hp_pins[i],
1833 /* force to enable the first line-out; the others are set up
1836 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
1838 stac92xx_auto_init_hp_out(codec);
1839 /* fake event to set up pins */
1840 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1842 stac92xx_auto_init_multi_out(codec);
1843 stac92xx_auto_init_hp_out(codec);
1845 for (i = 0; i < AUTO_PIN_LAST; i++) {
1846 hda_nid_t nid = cfg->input_pins[i];
1848 unsigned int pinctl = AC_PINCTL_IN_EN;
1849 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
1850 pinctl |= stac92xx_get_vref(codec, nid);
1851 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1854 if (spec->num_dmics > 0)
1855 for (i = 0; i < spec->num_dmics; i++)
1856 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
1859 if (cfg->dig_out_pin)
1860 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
1862 if (cfg->dig_in_pin)
1863 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
1866 if (spec->gpio_mute) {
1867 stac922x_gpio_mute(codec, 0, 0);
1868 stac922x_gpio_mute(codec, 1, 0);
1874 static void stac92xx_free(struct hda_codec *codec)
1876 struct sigmatel_spec *spec = codec->spec;
1882 if (spec->kctl_alloc) {
1883 for (i = 0; i < spec->num_kctl_used; i++)
1884 kfree(spec->kctl_alloc[i].name);
1885 kfree(spec->kctl_alloc);
1888 if (spec->bios_pin_configs)
1889 kfree(spec->bios_pin_configs);
1894 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
1897 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1898 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1900 if (pin_ctl & AC_PINCTL_IN_EN) {
1902 * we need to check the current set-up direction of
1903 * shared input pins since they can be switched via
1904 * "xxx as Output" mixer switch
1906 struct sigmatel_spec *spec = codec->spec;
1907 struct auto_pin_cfg *cfg = &spec->autocfg;
1908 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
1909 spec->line_switch) ||
1910 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
1915 /* if setting pin direction bits, clear the current
1916 direction bits first */
1917 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
1918 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
1920 snd_hda_codec_write_cache(codec, nid, 0,
1921 AC_VERB_SET_PIN_WIDGET_CONTROL,
1925 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
1928 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
1929 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
1930 snd_hda_codec_write_cache(codec, nid, 0,
1931 AC_VERB_SET_PIN_WIDGET_CONTROL,
1935 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
1939 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
1945 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
1947 struct sigmatel_spec *spec = codec->spec;
1948 struct auto_pin_cfg *cfg = &spec->autocfg;
1952 for (i = 0; i < cfg->hp_outs; i++) {
1953 presence = get_pin_presence(codec, cfg->hp_pins[i]);
1959 /* disable lineouts, enable hp */
1960 for (i = 0; i < cfg->line_outs; i++)
1961 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
1963 for (i = 0; i < cfg->speaker_outs; i++)
1964 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
1967 /* enable lineouts, disable hp */
1968 for (i = 0; i < cfg->line_outs; i++)
1969 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
1971 for (i = 0; i < cfg->speaker_outs; i++)
1972 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
1977 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
1979 switch (res >> 26) {
1981 stac92xx_hp_detect(codec, res);
1986 #ifdef SND_HDA_NEEDS_RESUME
1987 static int stac92xx_resume(struct hda_codec *codec)
1989 stac92xx_set_config_regs(codec);
1990 stac92xx_init(codec);
1991 snd_hda_codec_resume_amp(codec);
1992 snd_hda_codec_resume_cache(codec);
1997 static struct hda_codec_ops stac92xx_patch_ops = {
1998 .build_controls = stac92xx_build_controls,
1999 .build_pcms = stac92xx_build_pcms,
2000 .init = stac92xx_init,
2001 .free = stac92xx_free,
2002 .unsol_event = stac92xx_unsol_event,
2003 #ifdef SND_HDA_NEEDS_RESUME
2004 .resume = stac92xx_resume,
2008 static int patch_stac9200(struct hda_codec *codec)
2010 struct sigmatel_spec *spec;
2013 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2018 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
2019 spec->pin_nids = stac9200_pin_nids;
2020 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
2023 if (spec->board_config < 0) {
2024 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
2025 err = stac92xx_save_bios_config_regs(codec);
2027 stac92xx_free(codec);
2030 spec->pin_configs = spec->bios_pin_configs;
2032 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
2033 stac92xx_set_config_regs(codec);
2036 spec->multiout.max_channels = 2;
2037 spec->multiout.num_dacs = 1;
2038 spec->multiout.dac_nids = stac9200_dac_nids;
2039 spec->adc_nids = stac9200_adc_nids;
2040 spec->mux_nids = stac9200_mux_nids;
2041 spec->num_muxes = 1;
2042 spec->num_dmics = 0;
2044 spec->init = stac9200_core_init;
2045 spec->mixer = stac9200_mixer;
2047 err = stac9200_parse_auto_config(codec);
2049 stac92xx_free(codec);
2053 codec->patch_ops = stac92xx_patch_ops;
2058 static int patch_stac925x(struct hda_codec *codec)
2060 struct sigmatel_spec *spec;
2063 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2068 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
2069 spec->pin_nids = stac925x_pin_nids;
2070 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
2074 if (spec->board_config < 0) {
2075 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2076 "using BIOS defaults\n");
2077 err = stac92xx_save_bios_config_regs(codec);
2079 stac92xx_free(codec);
2082 spec->pin_configs = spec->bios_pin_configs;
2083 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
2084 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
2085 stac92xx_set_config_regs(codec);
2088 spec->multiout.max_channels = 2;
2089 spec->multiout.num_dacs = 1;
2090 spec->multiout.dac_nids = stac925x_dac_nids;
2091 spec->adc_nids = stac925x_adc_nids;
2092 spec->mux_nids = stac925x_mux_nids;
2093 spec->num_muxes = 1;
2094 switch (codec->vendor_id) {
2095 case 0x83847632: /* STAC9202 */
2096 case 0x83847633: /* STAC9202D */
2097 case 0x83847636: /* STAC9251 */
2098 case 0x83847637: /* STAC9251D */
2099 spec->num_dmics = 1;
2100 spec->dmic_nids = stac925x_dmic_nids;
2103 spec->num_dmics = 0;
2107 spec->init = stac925x_core_init;
2108 spec->mixer = stac925x_mixer;
2110 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
2112 if (spec->board_config < 0) {
2113 printk(KERN_WARNING "hda_codec: No auto-config is "
2114 "available, default to model=ref\n");
2115 spec->board_config = STAC_925x_REF;
2121 stac92xx_free(codec);
2125 codec->patch_ops = stac92xx_patch_ops;
2130 static int patch_stac922x(struct hda_codec *codec)
2132 struct sigmatel_spec *spec;
2135 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2140 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
2141 spec->pin_nids = stac922x_pin_nids;
2142 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2145 if (spec->board_config == STAC_INTEL_MAC_V3) {
2146 spec->gpio_mute = 1;
2147 /* Intel Macs have all same PCI SSID, so we need to check
2148 * codec SSID to distinguish the exact models
2150 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
2151 switch (codec->subsystem_id) {
2154 spec->board_config = STAC_INTEL_MAC_V1;
2158 spec->board_config = STAC_INTEL_MAC_V2;
2166 spec->board_config = STAC_INTEL_MAC_V3;
2170 spec->board_config = STAC_INTEL_MAC_V4;
2174 spec->board_config = STAC_INTEL_MAC_V5;
2180 if (spec->board_config < 0) {
2181 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2182 "using BIOS defaults\n");
2183 err = stac92xx_save_bios_config_regs(codec);
2185 stac92xx_free(codec);
2188 spec->pin_configs = spec->bios_pin_configs;
2189 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
2190 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2191 stac92xx_set_config_regs(codec);
2194 spec->adc_nids = stac922x_adc_nids;
2195 spec->mux_nids = stac922x_mux_nids;
2196 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
2197 spec->num_dmics = 0;
2199 spec->init = stac922x_core_init;
2200 spec->mixer = stac922x_mixer;
2202 spec->multiout.dac_nids = spec->dac_nids;
2204 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
2206 if (spec->board_config < 0) {
2207 printk(KERN_WARNING "hda_codec: No auto-config is "
2208 "available, default to model=ref\n");
2209 spec->board_config = STAC_D945_REF;
2215 stac92xx_free(codec);
2219 codec->patch_ops = stac92xx_patch_ops;
2221 /* Fix Mux capture level; max to 2 */
2222 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2223 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2224 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2225 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2226 (0 << AC_AMPCAP_MUTE_SHIFT));
2231 static int patch_stac927x(struct hda_codec *codec)
2233 struct sigmatel_spec *spec;
2236 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2241 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
2242 spec->pin_nids = stac927x_pin_nids;
2243 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2247 if (spec->board_config < 0) {
2248 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
2249 err = stac92xx_save_bios_config_regs(codec);
2251 stac92xx_free(codec);
2254 spec->pin_configs = spec->bios_pin_configs;
2255 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
2256 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2257 stac92xx_set_config_regs(codec);
2260 switch (spec->board_config) {
2262 spec->adc_nids = stac927x_adc_nids;
2263 spec->mux_nids = stac927x_mux_nids;
2264 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2265 spec->num_dmics = 0;
2266 spec->init = d965_core_init;
2267 spec->mixer = stac9227_mixer;
2270 spec->adc_nids = stac927x_adc_nids;
2271 spec->mux_nids = stac927x_mux_nids;
2272 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2273 spec->num_dmics = 0;
2274 spec->init = d965_core_init;
2275 spec->mixer = stac9227_mixer;
2278 spec->adc_nids = stac927x_adc_nids;
2279 spec->mux_nids = stac927x_mux_nids;
2280 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2281 spec->num_dmics = 0;
2282 spec->init = stac927x_core_init;
2283 spec->mixer = stac927x_mixer;
2286 spec->multiout.dac_nids = spec->dac_nids;
2287 /* GPIO0 High = Enable EAPD */
2288 spec->gpio_mask = spec->gpio_data = 0x00000001;
2289 stac92xx_enable_gpio_mask(codec);
2291 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
2293 if (spec->board_config < 0) {
2294 printk(KERN_WARNING "hda_codec: No auto-config is "
2295 "available, default to model=ref\n");
2296 spec->board_config = STAC_D965_REF;
2302 stac92xx_free(codec);
2306 codec->patch_ops = stac92xx_patch_ops;
2311 static int patch_stac9205(struct hda_codec *codec)
2313 struct sigmatel_spec *spec;
2316 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2321 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
2322 spec->pin_nids = stac9205_pin_nids;
2323 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2327 if (spec->board_config < 0) {
2328 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2329 err = stac92xx_save_bios_config_regs(codec);
2331 stac92xx_free(codec);
2334 spec->pin_configs = spec->bios_pin_configs;
2336 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
2337 stac92xx_set_config_regs(codec);
2340 spec->adc_nids = stac9205_adc_nids;
2341 spec->mux_nids = stac9205_mux_nids;
2342 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
2343 spec->dmic_nids = stac9205_dmic_nids;
2344 spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
2345 spec->dmux_nid = 0x1d;
2347 spec->init = stac9205_core_init;
2348 spec->mixer = stac9205_mixer;
2350 spec->multiout.dac_nids = spec->dac_nids;
2352 switch (spec->board_config){
2353 case STAC_9205_M43xx:
2354 case STAC_9205_DELL_M43:
2355 /* Enable SPDIF in/out */
2356 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
2357 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
2359 spec->gpio_mask = 0x00000007; /* GPIO0-2 */
2360 /* GPIO0 High = EAPD, GPIO1 Low = DRM,
2361 * GPIO2 High = Headphone Mute
2363 spec->gpio_data = 0x00000005;
2366 /* GPIO0 High = EAPD */
2367 spec->gpio_mask = spec->gpio_data = 0x00000001;
2371 stac92xx_enable_gpio_mask(codec);
2372 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
2374 if (spec->board_config < 0) {
2375 printk(KERN_WARNING "hda_codec: No auto-config is "
2376 "available, default to model=ref\n");
2377 spec->board_config = STAC_9205_REF;
2383 stac92xx_free(codec);
2387 codec->patch_ops = stac92xx_patch_ops;
2396 /* static config for Sony VAIO FE550G and Sony VAIO AR */
2397 static hda_nid_t vaio_dacs[] = { 0x2 };
2398 #define VAIO_HP_DAC 0x5
2399 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
2400 static hda_nid_t vaio_mux_nids[] = { 0x15 };
2402 static struct hda_input_mux vaio_mux = {
2405 /* { "HP", 0x0 }, */
2406 { "Mic Jack", 0x1 },
2407 { "Internal Mic", 0x2 },
2412 static struct hda_verb vaio_init[] = {
2413 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2414 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
2415 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2416 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2417 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2419 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2420 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2421 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2422 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2428 static struct hda_verb vaio_ar_init[] = {
2429 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
2430 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
2431 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
2432 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
2433 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
2434 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
2435 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
2436 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
2437 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
2438 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
2439 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
2440 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
2441 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
2445 /* bind volumes of both NID 0x02 and 0x05 */
2446 static struct hda_bind_ctls vaio_bind_master_vol = {
2447 .ops = &snd_hda_bind_vol,
2449 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2450 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2455 /* bind volumes of both NID 0x02 and 0x05 */
2456 static struct hda_bind_ctls vaio_bind_master_sw = {
2457 .ops = &snd_hda_bind_sw,
2459 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
2460 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
2465 static struct snd_kcontrol_new vaio_mixer[] = {
2466 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2467 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2468 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2469 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2470 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2473 .name = "Capture Source",
2475 .info = stac92xx_mux_enum_info,
2476 .get = stac92xx_mux_enum_get,
2477 .put = stac92xx_mux_enum_put,
2482 static struct snd_kcontrol_new vaio_ar_mixer[] = {
2483 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
2484 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
2485 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
2486 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
2487 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
2488 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
2489 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
2491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2492 .name = "Capture Source",
2494 .info = stac92xx_mux_enum_info,
2495 .get = stac92xx_mux_enum_get,
2496 .put = stac92xx_mux_enum_put,
2501 static struct hda_codec_ops stac9872_patch_ops = {
2502 .build_controls = stac92xx_build_controls,
2503 .build_pcms = stac92xx_build_pcms,
2504 .init = stac92xx_init,
2505 .free = stac92xx_free,
2506 #ifdef SND_HDA_NEEDS_RESUME
2507 .resume = stac92xx_resume,
2511 static int stac9872_vaio_init(struct hda_codec *codec)
2515 err = stac92xx_init(codec);
2518 if (codec->patch_ops.unsol_event)
2519 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2523 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
2525 if (get_pin_presence(codec, 0x0a)) {
2526 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
2527 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
2529 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
2530 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
2534 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
2536 switch (res >> 26) {
2538 stac9872_vaio_hp_detect(codec, res);
2543 static struct hda_codec_ops stac9872_vaio_patch_ops = {
2544 .build_controls = stac92xx_build_controls,
2545 .build_pcms = stac92xx_build_pcms,
2546 .init = stac9872_vaio_init,
2547 .free = stac92xx_free,
2548 .unsol_event = stac9872_vaio_unsol_event,
2550 .resume = stac92xx_resume,
2554 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
2556 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
2558 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
2560 /* AR Series. id=0x83847664 and subsys=104D1300 */
2565 static const char *stac9872_models[STAC_9872_MODELS] = {
2566 [CXD9872RD_VAIO] = "vaio",
2567 [CXD9872AKD_VAIO] = "vaio-ar",
2570 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
2571 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
2572 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
2573 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
2574 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
2578 static int patch_stac9872(struct hda_codec *codec)
2580 struct sigmatel_spec *spec;
2583 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
2586 if (board_config < 0)
2587 /* unknown config, let generic-parser do its job... */
2588 return snd_hda_parse_generic_codec(codec);
2590 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2595 switch (board_config) {
2596 case CXD9872RD_VAIO:
2597 case STAC9872AK_VAIO:
2598 case STAC9872K_VAIO:
2599 spec->mixer = vaio_mixer;
2600 spec->init = vaio_init;
2601 spec->multiout.max_channels = 2;
2602 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2603 spec->multiout.dac_nids = vaio_dacs;
2604 spec->multiout.hp_nid = VAIO_HP_DAC;
2605 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2606 spec->adc_nids = vaio_adcs;
2607 spec->input_mux = &vaio_mux;
2608 spec->mux_nids = vaio_mux_nids;
2609 codec->patch_ops = stac9872_vaio_patch_ops;
2612 case CXD9872AKD_VAIO:
2613 spec->mixer = vaio_ar_mixer;
2614 spec->init = vaio_ar_init;
2615 spec->multiout.max_channels = 2;
2616 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
2617 spec->multiout.dac_nids = vaio_dacs;
2618 spec->multiout.hp_nid = VAIO_HP_DAC;
2619 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
2620 spec->adc_nids = vaio_adcs;
2621 spec->input_mux = &vaio_mux;
2622 spec->mux_nids = vaio_mux_nids;
2623 codec->patch_ops = stac9872_patch_ops;
2634 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
2635 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
2636 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
2637 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
2638 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
2639 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
2640 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
2641 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
2642 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
2643 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
2644 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
2645 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
2646 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
2647 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
2648 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
2649 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
2650 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
2651 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
2652 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
2653 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
2654 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
2655 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
2656 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
2657 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
2658 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
2659 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
2660 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
2661 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
2662 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
2663 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
2664 /* The following does not take into account .id=0x83847661 when subsys =
2665 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
2666 * currently not fully supported.
2668 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
2669 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
2670 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
2671 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
2672 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
2673 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
2674 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
2675 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
2676 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
2677 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
2678 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },