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
86 /* for backward compatibility */
108 struct sigmatel_spec {
109 struct snd_kcontrol_new *mixers[4];
110 unsigned int num_mixers;
113 unsigned int surr_switch: 1;
114 unsigned int line_switch: 1;
115 unsigned int mic_switch: 1;
116 unsigned int alt_switch: 1;
117 unsigned int hp_detect: 1;
118 unsigned int gpio_mute: 1;
120 unsigned int gpio_mask, gpio_data;
123 struct hda_multi_out multiout;
124 hda_nid_t dac_nids[5];
128 unsigned int num_adcs;
130 unsigned int num_muxes;
131 hda_nid_t *dmic_nids;
132 unsigned int num_dmics;
134 hda_nid_t dig_in_nid;
138 unsigned int num_pins;
139 unsigned int *pin_configs;
140 unsigned int *bios_pin_configs;
142 /* codec specific stuff */
143 struct hda_verb *init;
144 struct snd_kcontrol_new *mixer;
147 struct hda_input_mux *dinput_mux;
148 unsigned int cur_dmux;
149 struct hda_input_mux *input_mux;
150 unsigned int cur_mux[3];
153 unsigned int io_switch[2];
154 unsigned int clfe_swap;
155 unsigned int aloopback;
157 struct hda_pcm pcm_rec[2]; /* PCM information */
159 /* dynamic controls and input_mux */
160 struct auto_pin_cfg autocfg;
161 unsigned int num_kctl_alloc, num_kctl_used;
162 struct snd_kcontrol_new *kctl_alloc;
163 struct hda_input_mux private_dimux;
164 struct hda_input_mux private_imux;
167 static hda_nid_t stac9200_adc_nids[1] = {
171 static hda_nid_t stac9200_mux_nids[1] = {
175 static hda_nid_t stac9200_dac_nids[1] = {
179 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
183 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
187 static hda_nid_t stac92hd71bxx_dac_nids[2] = {
191 #define STAC92HD71BXX_NUM_DMICS 2
192 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
196 static hda_nid_t stac925x_adc_nids[1] = {
200 static hda_nid_t stac925x_mux_nids[1] = {
204 static hda_nid_t stac925x_dac_nids[1] = {
208 #define STAC925X_NUM_DMICS 1
209 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
213 static hda_nid_t stac922x_adc_nids[2] = {
217 static hda_nid_t stac922x_mux_nids[2] = {
221 static hda_nid_t stac927x_adc_nids[3] = {
225 static hda_nid_t stac927x_mux_nids[3] = {
229 #define STAC927X_NUM_DMICS 2
230 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
234 static hda_nid_t stac9205_adc_nids[2] = {
238 static hda_nid_t stac9205_mux_nids[2] = {
242 #define STAC9205_NUM_DMICS 2
243 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
247 static hda_nid_t stac9200_pin_nids[8] = {
248 0x08, 0x09, 0x0d, 0x0e,
249 0x0f, 0x10, 0x11, 0x12,
252 static hda_nid_t stac925x_pin_nids[8] = {
253 0x07, 0x08, 0x0a, 0x0b,
254 0x0c, 0x0d, 0x10, 0x11,
257 static hda_nid_t stac922x_pin_nids[10] = {
258 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
259 0x0f, 0x10, 0x11, 0x15, 0x1b,
262 static hda_nid_t stac92hd71bxx_pin_nids[10] = {
263 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
264 0x0f, 0x14, 0x18, 0x19, 0x1e,
267 static hda_nid_t stac927x_pin_nids[14] = {
268 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
269 0x0f, 0x10, 0x11, 0x12, 0x13,
270 0x14, 0x21, 0x22, 0x23,
273 static hda_nid_t stac9205_pin_nids[12] = {
274 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
275 0x0f, 0x14, 0x16, 0x17, 0x18,
279 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
280 struct snd_ctl_elem_info *uinfo)
282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
283 struct sigmatel_spec *spec = codec->spec;
284 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
287 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
288 struct snd_ctl_elem_value *ucontrol)
290 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
291 struct sigmatel_spec *spec = codec->spec;
293 ucontrol->value.enumerated.item[0] = spec->cur_dmux;
297 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
298 struct snd_ctl_elem_value *ucontrol)
300 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
301 struct sigmatel_spec *spec = codec->spec;
303 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
304 spec->dmux_nid, &spec->cur_dmux);
307 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
309 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
310 struct sigmatel_spec *spec = codec->spec;
311 return snd_hda_input_mux_info(spec->input_mux, uinfo);
314 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
316 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
317 struct sigmatel_spec *spec = codec->spec;
318 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
320 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
324 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
326 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
327 struct sigmatel_spec *spec = codec->spec;
328 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
330 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
331 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
334 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
336 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
337 struct snd_ctl_elem_value *ucontrol)
339 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
340 struct sigmatel_spec *spec = codec->spec;
342 ucontrol->value.integer.value[0] = spec->aloopback;
346 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
347 struct snd_ctl_elem_value *ucontrol)
349 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
350 struct sigmatel_spec *spec = codec->spec;
351 unsigned int dac_mode;
354 val = !!ucontrol->value.integer.value[0];
355 if (spec->aloopback == val)
358 spec->aloopback = val;
360 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
361 kcontrol->private_value & 0xFFFF, 0x0);
363 if (spec->aloopback) {
364 snd_hda_power_up(codec);
367 snd_hda_power_down(codec);
371 snd_hda_codec_write_cache(codec, codec->afg, 0,
372 kcontrol->private_value >> 16, dac_mode);
377 static struct hda_verb stac9200_core_init[] = {
378 /* set dac0mux for dac converter */
379 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
383 static struct hda_verb stac9200_eapd_init[] = {
384 /* set dac0mux for dac converter */
385 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
386 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
390 static struct hda_verb stac92hd71bxx_core_init[] = {
391 /* set master volume and direct control */
392 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
393 /* connect headphone jack to dac1 */
394 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
395 /* connect ports 0d and 0f to audio mixer */
396 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
397 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
398 /* unmute dac0 input in audio mixer */
399 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
400 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
401 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
402 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
403 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
404 /* unmute mono out node */
405 { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
409 static struct hda_verb stac925x_core_init[] = {
410 /* set dac0mux for dac converter */
411 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
415 static struct hda_verb stac922x_core_init[] = {
416 /* set master volume and direct control */
417 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
421 static struct hda_verb d965_core_init[] = {
422 /* set master volume and direct control */
423 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
424 /* unmute node 0x1b */
425 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
426 /* select node 0x03 as DAC */
427 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
431 static struct hda_verb stac927x_core_init[] = {
432 /* set master volume and direct control */
433 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
437 static struct hda_verb stac9205_core_init[] = {
438 /* set master volume and direct control */
439 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
443 #define STAC_DIGITAL_INPUT_SOURCE(cnt) \
445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
446 .name = "Digital Input Source", \
448 .info = stac92xx_dmux_enum_info, \
449 .get = stac92xx_dmux_enum_get, \
450 .put = stac92xx_dmux_enum_put,\
453 #define STAC_INPUT_SOURCE(cnt) \
455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
456 .name = "Input Source", \
458 .info = stac92xx_mux_enum_info, \
459 .get = stac92xx_mux_enum_get, \
460 .put = stac92xx_mux_enum_put, \
463 #define STAC_ANALOG_LOOPBACK(verb_read,verb_write) \
465 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
466 .name = "Analog Loopback", \
468 .info = stac92xx_aloopback_info, \
469 .get = stac92xx_aloopback_get, \
470 .put = stac92xx_aloopback_put, \
471 .private_value = verb_read | (verb_write << 16), \
474 static struct snd_kcontrol_new stac9200_mixer[] = {
475 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
476 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
477 STAC_INPUT_SOURCE(1),
478 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
479 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
480 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
484 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
485 STAC_DIGITAL_INPUT_SOURCE(1),
486 STAC_INPUT_SOURCE(2),
488 /* hardware gain controls */
489 HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x18, 0x0, HDA_OUTPUT),
490 HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x19, 0x0, HDA_OUTPUT),
492 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
493 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
494 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
496 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
497 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
498 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
500 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
501 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
505 static struct snd_kcontrol_new stac925x_mixer[] = {
506 STAC_INPUT_SOURCE(1),
507 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
508 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
509 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
513 static struct snd_kcontrol_new stac9205_mixer[] = {
514 STAC_DIGITAL_INPUT_SOURCE(1),
515 STAC_INPUT_SOURCE(2),
516 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0),
518 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
519 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
520 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
522 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
523 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
524 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
529 /* This needs to be generated dynamically based on sequence */
530 static struct snd_kcontrol_new stac922x_mixer[] = {
531 STAC_INPUT_SOURCE(2),
532 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
533 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
534 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
536 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
537 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
538 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
543 static struct snd_kcontrol_new stac927x_mixer[] = {
544 STAC_DIGITAL_INPUT_SOURCE(1),
545 STAC_INPUT_SOURCE(3),
546 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB),
548 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
549 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
550 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
552 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
553 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
554 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
556 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
557 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
558 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
562 static int stac92xx_build_controls(struct hda_codec *codec)
564 struct sigmatel_spec *spec = codec->spec;
568 err = snd_hda_add_new_ctls(codec, spec->mixer);
572 for (i = 0; i < spec->num_mixers; i++) {
573 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
578 if (spec->multiout.dig_out_nid) {
579 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
583 if (spec->dig_in_nid) {
584 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
591 static unsigned int ref9200_pin_configs[8] = {
592 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
593 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
597 STAC 9200 pin configs for
602 static unsigned int dell9200_d21_pin_configs[8] = {
603 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
604 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
608 STAC 9200 pin configs for
612 static unsigned int dell9200_d22_pin_configs[8] = {
613 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
614 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
618 STAC 9200 pin configs for
619 102801C4 (Dell Dimension E310)
626 static unsigned int dell9200_d23_pin_configs[8] = {
627 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
628 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
633 STAC 9200-32 pin configs for
634 102801B5 (Dell Inspiron 630m)
635 102801D8 (Dell Inspiron 640m)
637 static unsigned int dell9200_m21_pin_configs[8] = {
638 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
639 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
643 STAC 9200-32 pin configs for
644 102801C2 (Dell Latitude D620)
646 102801CC (Dell Latitude D820)
650 static unsigned int dell9200_m22_pin_configs[8] = {
651 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
652 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
656 STAC 9200-32 pin configs for
657 102801CE (Dell XPS M1710)
658 102801CF (Dell Precision M90)
660 static unsigned int dell9200_m23_pin_configs[8] = {
661 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
662 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
666 STAC 9200-32 pin configs for
669 102801CB (Dell Latitude 120L)
672 static unsigned int dell9200_m24_pin_configs[8] = {
673 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
674 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
678 STAC 9200-32 pin configs for
679 102801BD (Dell Inspiron E1505n)
683 static unsigned int dell9200_m25_pin_configs[8] = {
684 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
685 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
689 STAC 9200-32 pin configs for
690 102801F5 (Dell Inspiron 1501)
693 static unsigned int dell9200_m26_pin_configs[8] = {
694 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
695 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
700 102801CD (Dell Inspiron E1705/9400)
702 static unsigned int dell9200_m27_pin_configs[8] = {
703 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
704 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
708 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
709 [STAC_REF] = ref9200_pin_configs,
710 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
711 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
712 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
713 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
714 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
715 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
716 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
717 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
718 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
719 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
722 static const char *stac9200_models[STAC_9200_MODELS] = {
724 [STAC_9200_DELL_D21] = "dell-d21",
725 [STAC_9200_DELL_D22] = "dell-d22",
726 [STAC_9200_DELL_D23] = "dell-d23",
727 [STAC_9200_DELL_M21] = "dell-m21",
728 [STAC_9200_DELL_M22] = "dell-m22",
729 [STAC_9200_DELL_M23] = "dell-m23",
730 [STAC_9200_DELL_M24] = "dell-m24",
731 [STAC_9200_DELL_M25] = "dell-m25",
732 [STAC_9200_DELL_M26] = "dell-m26",
733 [STAC_9200_DELL_M27] = "dell-m27",
734 [STAC_9200_GATEWAY] = "gateway",
737 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
738 /* SigmaTel reference board */
739 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
740 "DFI LanParty", STAC_REF),
741 /* Dell laptops have BIOS problem */
742 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
743 "unknown Dell", STAC_9200_DELL_D21),
744 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
745 "Dell Inspiron 630m", STAC_9200_DELL_M21),
746 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
747 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
748 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
749 "unknown Dell", STAC_9200_DELL_D22),
750 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
751 "unknown Dell", STAC_9200_DELL_D22),
752 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
753 "Dell Latitude D620", STAC_9200_DELL_M22),
754 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
755 "unknown Dell", STAC_9200_DELL_D23),
756 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
757 "unknown Dell", STAC_9200_DELL_D23),
758 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
759 "unknown Dell", STAC_9200_DELL_M22),
760 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
761 "unknown Dell", STAC_9200_DELL_M24),
762 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
763 "unknown Dell", STAC_9200_DELL_M24),
764 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
765 "Dell Latitude 120L", STAC_9200_DELL_M24),
766 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
767 "Dell Latitude D820", STAC_9200_DELL_M22),
768 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
769 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
770 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
771 "Dell XPS M1710", STAC_9200_DELL_M23),
772 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
773 "Dell Precision M90", STAC_9200_DELL_M23),
774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
775 "unknown Dell", STAC_9200_DELL_M22),
776 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
777 "unknown Dell", STAC_9200_DELL_M22),
778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
779 "unknown Dell", STAC_9200_DELL_M22),
780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
781 "Dell Inspiron 640m", STAC_9200_DELL_M21),
782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
783 "unknown Dell", STAC_9200_DELL_D23),
784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
785 "unknown Dell", STAC_9200_DELL_D23),
786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
787 "unknown Dell", STAC_9200_DELL_D21),
788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
789 "unknown Dell", STAC_9200_DELL_D23),
790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
791 "unknown Dell", STAC_9200_DELL_D21),
792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
793 "unknown Dell", STAC_9200_DELL_M25),
794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
795 "unknown Dell", STAC_9200_DELL_M25),
796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
797 "Dell Inspiron 1501", STAC_9200_DELL_M26),
798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
799 "unknown Dell", STAC_9200_DELL_M26),
801 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
802 /* Gateway machines needs EAPD to be set on resume */
803 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
804 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
806 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
811 static unsigned int ref925x_pin_configs[8] = {
812 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
813 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
816 static unsigned int stac925x_MA6_pin_configs[8] = {
817 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
818 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
821 static unsigned int stac925x_PA6_pin_configs[8] = {
822 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
823 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
826 static unsigned int stac925xM2_2_pin_configs[8] = {
827 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
828 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
831 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
832 [STAC_REF] = ref925x_pin_configs,
833 [STAC_M2_2] = stac925xM2_2_pin_configs,
834 [STAC_MA6] = stac925x_MA6_pin_configs,
835 [STAC_PA6] = stac925x_PA6_pin_configs,
838 static const char *stac925x_models[STAC_925x_MODELS] = {
840 [STAC_M2_2] = "m2-2",
845 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
846 /* SigmaTel reference board */
847 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
848 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
849 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
850 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
851 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
852 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
853 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
857 static unsigned int ref92hd71bxx_pin_configs[10] = {
858 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
859 0x0181302e, 0x01114010, 0x01a19020, 0x90a000f0,
860 0x90a000f0, 0x01452050,
863 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
864 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
867 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
868 [STAC_92HD71BXX_REF] = "ref",
871 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
872 /* SigmaTel reference board */
873 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
874 "DFI LanParty", STAC_92HD71BXX_REF),
878 static unsigned int ref922x_pin_configs[10] = {
879 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
880 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
881 0x40000100, 0x40000100,
885 STAC 922X pin configs for
892 static unsigned int dell_922x_d81_pin_configs[10] = {
893 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
894 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
895 0x01813122, 0x400001f2,
899 STAC 922X pin configs for
903 static unsigned int dell_922x_d82_pin_configs[10] = {
904 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
905 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
906 0x01813122, 0x400001f1,
910 STAC 922X pin configs for
913 static unsigned int dell_922x_m81_pin_configs[10] = {
914 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
915 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
916 0x40C003f1, 0x405003f0,
920 STAC 9221 A1 pin configs for
921 102801D7 (Dell XPS M1210)
923 static unsigned int dell_922x_m82_pin_configs[10] = {
924 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
925 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
926 0x508003f3, 0x405003f4,
929 static unsigned int d945gtp3_pin_configs[10] = {
930 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
931 0x40000100, 0x40000100, 0x40000100, 0x40000100,
932 0x02a19120, 0x40000100,
935 static unsigned int d945gtp5_pin_configs[10] = {
936 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
937 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
938 0x02a19320, 0x40000100,
941 static unsigned int intel_mac_v1_pin_configs[10] = {
942 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
943 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
944 0x400000fc, 0x400000fb,
947 static unsigned int intel_mac_v2_pin_configs[10] = {
948 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
949 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
950 0x400000fc, 0x400000fb,
953 static unsigned int intel_mac_v3_pin_configs[10] = {
954 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
955 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
956 0x400000fc, 0x400000fb,
959 static unsigned int intel_mac_v4_pin_configs[10] = {
960 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
961 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
962 0x400000fc, 0x400000fb,
965 static unsigned int intel_mac_v5_pin_configs[10] = {
966 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
967 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
968 0x400000fc, 0x400000fb,
972 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
973 [STAC_D945_REF] = ref922x_pin_configs,
974 [STAC_D945GTP3] = d945gtp3_pin_configs,
975 [STAC_D945GTP5] = d945gtp5_pin_configs,
976 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
977 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
978 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
979 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
980 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
981 /* for backward compatibility */
982 [STAC_MACMINI] = intel_mac_v3_pin_configs,
983 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
984 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
985 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
986 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
987 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
988 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
989 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
990 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
991 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
994 static const char *stac922x_models[STAC_922X_MODELS] = {
995 [STAC_D945_REF] = "ref",
996 [STAC_D945GTP5] = "5stack",
997 [STAC_D945GTP3] = "3stack",
998 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
999 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1000 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1001 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1002 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1003 /* for backward compatibility */
1004 [STAC_MACMINI] = "macmini",
1005 [STAC_MACBOOK] = "macbook",
1006 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1007 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1008 [STAC_IMAC_INTEL] = "imac-intel",
1009 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1010 [STAC_922X_DELL_D81] = "dell-d81",
1011 [STAC_922X_DELL_D82] = "dell-d82",
1012 [STAC_922X_DELL_M81] = "dell-m81",
1013 [STAC_922X_DELL_M82] = "dell-m82",
1016 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1017 /* SigmaTel reference board */
1018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1019 "DFI LanParty", STAC_D945_REF),
1020 /* Intel 945G based systems */
1021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1022 "Intel D945G", STAC_D945GTP3),
1023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1024 "Intel D945G", STAC_D945GTP3),
1025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1026 "Intel D945G", STAC_D945GTP3),
1027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1028 "Intel D945G", STAC_D945GTP3),
1029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1030 "Intel D945G", STAC_D945GTP3),
1031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1032 "Intel D945G", STAC_D945GTP3),
1033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1034 "Intel D945G", STAC_D945GTP3),
1035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1036 "Intel D945G", STAC_D945GTP3),
1037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1038 "Intel D945G", STAC_D945GTP3),
1039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1040 "Intel D945G", STAC_D945GTP3),
1041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1042 "Intel D945G", STAC_D945GTP3),
1043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1044 "Intel D945G", STAC_D945GTP3),
1045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1046 "Intel D945G", STAC_D945GTP3),
1047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1048 "Intel D945G", STAC_D945GTP3),
1049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1050 "Intel D945G", STAC_D945GTP3),
1051 /* Intel D945G 5-stack systems */
1052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1053 "Intel D945G", STAC_D945GTP5),
1054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1055 "Intel D945G", STAC_D945GTP5),
1056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1057 "Intel D945G", STAC_D945GTP5),
1058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1059 "Intel D945G", STAC_D945GTP5),
1060 /* Intel 945P based systems */
1061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1062 "Intel D945P", STAC_D945GTP3),
1063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1064 "Intel D945P", STAC_D945GTP3),
1065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1066 "Intel D945P", STAC_D945GTP3),
1067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1068 "Intel D945P", STAC_D945GTP3),
1069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1070 "Intel D945P", STAC_D945GTP3),
1071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1072 "Intel D945P", STAC_D945GTP5),
1074 /* Apple Mac Mini (early 2006) */
1075 SND_PCI_QUIRK(0x8384, 0x7680,
1076 "Mac Mini", STAC_INTEL_MAC_V3),
1078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1079 "unknown Dell", STAC_922X_DELL_D81),
1080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1081 "unknown Dell", STAC_922X_DELL_D81),
1082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1083 "unknown Dell", STAC_922X_DELL_D81),
1084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1085 "unknown Dell", STAC_922X_DELL_D82),
1086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1087 "unknown Dell", STAC_922X_DELL_M81),
1088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1089 "unknown Dell", STAC_922X_DELL_D82),
1090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1091 "unknown Dell", STAC_922X_DELL_D81),
1092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1093 "unknown Dell", STAC_922X_DELL_D81),
1094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1095 "Dell XPS M1210", STAC_922X_DELL_M82),
1099 static unsigned int ref927x_pin_configs[14] = {
1100 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1101 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1102 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1103 0x01c42190, 0x40000100,
1106 static unsigned int d965_3st_pin_configs[14] = {
1107 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1108 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1109 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1110 0x40000100, 0x40000100
1113 static unsigned int d965_5st_pin_configs[14] = {
1114 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1115 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1116 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1117 0x40000100, 0x40000100
1120 static unsigned int dell_3st_pin_configs[14] = {
1121 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1122 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1123 0x403003fa, 0x40000100, 0x40000100, 0x404003fb,
1124 0x40c003fc, 0x40000100
1127 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1128 [STAC_D965_REF] = ref927x_pin_configs,
1129 [STAC_D965_3ST] = d965_3st_pin_configs,
1130 [STAC_D965_5ST] = d965_5st_pin_configs,
1131 [STAC_DELL_3ST] = dell_3st_pin_configs,
1134 static const char *stac927x_models[STAC_927X_MODELS] = {
1135 [STAC_D965_REF] = "ref",
1136 [STAC_D965_3ST] = "3stack",
1137 [STAC_D965_5ST] = "5stack",
1138 [STAC_DELL_3ST] = "dell-3stack",
1141 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1142 /* SigmaTel reference board */
1143 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1144 "DFI LanParty", STAC_D965_REF),
1145 /* Intel 946 based systems */
1146 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1147 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1148 /* 965 based 3 stack systems */
1149 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1150 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1151 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1152 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1153 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1154 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1155 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1156 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1157 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1158 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1159 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1164 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_D965_3ST),
1166 /* Dell 3 stack systems */
1167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1170 /* 965 based 5 stack systems */
1171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_D965_5ST),
1172 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1173 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1174 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1175 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1176 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1177 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1178 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1179 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1180 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1184 static unsigned int ref9205_pin_configs[12] = {
1185 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1186 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
1187 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1191 STAC 9205 pin configs for
1199 static unsigned int dell_9205_m42_pin_configs[12] = {
1200 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1201 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1202 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1206 STAC 9205 pin configs for
1210 102801FF (Dell Precision M4300)
1215 static unsigned int dell_9205_m43_pin_configs[12] = {
1216 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1217 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1218 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1221 static unsigned int dell_9205_m44_pin_configs[12] = {
1222 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1223 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1224 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1227 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1228 [STAC_9205_REF] = ref9205_pin_configs,
1229 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1230 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1231 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1234 static const char *stac9205_models[STAC_9205_MODELS] = {
1235 [STAC_9205_REF] = "ref",
1236 [STAC_9205_DELL_M42] = "dell-m42",
1237 [STAC_9205_DELL_M43] = "dell-m43",
1238 [STAC_9205_DELL_M44] = "dell-m44",
1241 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1242 /* SigmaTel reference board */
1243 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1244 "DFI LanParty", STAC_9205_REF),
1245 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1246 "unknown Dell", STAC_9205_DELL_M42),
1247 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1248 "unknown Dell", STAC_9205_DELL_M42),
1249 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1250 "Dell Precision", STAC_9205_DELL_M43),
1251 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1252 "Dell Precision", STAC_9205_DELL_M43),
1253 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1254 "Dell Precision", STAC_9205_DELL_M43),
1255 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1256 "Dell Precision", STAC_9205_DELL_M43),
1257 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1258 "Dell Precision", STAC_9205_DELL_M43),
1259 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1260 "unknown Dell", STAC_9205_DELL_M42),
1261 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1262 "unknown Dell", STAC_9205_DELL_M42),
1263 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1264 "Dell Precision", STAC_9205_DELL_M43),
1265 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1266 "Dell Precision M4300", STAC_9205_DELL_M43),
1267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1268 "Dell Precision", STAC_9205_DELL_M43),
1269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1270 "Dell Inspiron", STAC_9205_DELL_M44),
1271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1272 "Dell Inspiron", STAC_9205_DELL_M44),
1273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1274 "Dell Inspiron", STAC_9205_DELL_M44),
1275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1276 "Dell Inspiron", STAC_9205_DELL_M44),
1277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1278 "unknown Dell", STAC_9205_DELL_M42),
1279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1280 "Dell Inspiron", STAC_9205_DELL_M44),
1284 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1287 struct sigmatel_spec *spec = codec->spec;
1289 if (! spec->bios_pin_configs) {
1290 spec->bios_pin_configs = kcalloc(spec->num_pins,
1291 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1292 if (! spec->bios_pin_configs)
1296 for (i = 0; i < spec->num_pins; i++) {
1297 hda_nid_t nid = spec->pin_nids[i];
1298 unsigned int pin_cfg;
1300 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1301 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1302 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1304 spec->bios_pin_configs[i] = pin_cfg;
1310 static void stac92xx_set_config_reg(struct hda_codec *codec,
1311 hda_nid_t pin_nid, unsigned int pin_config)
1314 snd_hda_codec_write(codec, pin_nid, 0,
1315 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1316 pin_config & 0x000000ff);
1317 snd_hda_codec_write(codec, pin_nid, 0,
1318 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1319 (pin_config & 0x0000ff00) >> 8);
1320 snd_hda_codec_write(codec, pin_nid, 0,
1321 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1322 (pin_config & 0x00ff0000) >> 16);
1323 snd_hda_codec_write(codec, pin_nid, 0,
1324 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1326 i = snd_hda_codec_read(codec, pin_nid, 0,
1327 AC_VERB_GET_CONFIG_DEFAULT,
1329 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1333 static void stac92xx_set_config_regs(struct hda_codec *codec)
1336 struct sigmatel_spec *spec = codec->spec;
1338 if (!spec->pin_configs)
1341 for (i = 0; i < spec->num_pins; i++)
1342 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1343 spec->pin_configs[i]);
1346 static void stac92xx_enable_gpio_mask(struct hda_codec *codec)
1348 struct sigmatel_spec *spec = codec->spec;
1349 /* Configure GPIOx as output */
1350 snd_hda_codec_write_cache(codec, codec->afg, 0,
1351 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask);
1352 /* Configure GPIOx as CMOS */
1353 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000);
1355 snd_hda_codec_write_cache(codec, codec->afg, 0,
1356 AC_VERB_SET_GPIO_DATA, spec->gpio_data);
1358 snd_hda_codec_write_cache(codec, codec->afg, 0,
1359 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
1363 * Analog playback callbacks
1365 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1366 struct hda_codec *codec,
1367 struct snd_pcm_substream *substream)
1369 struct sigmatel_spec *spec = codec->spec;
1370 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1373 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1374 struct hda_codec *codec,
1375 unsigned int stream_tag,
1376 unsigned int format,
1377 struct snd_pcm_substream *substream)
1379 struct sigmatel_spec *spec = codec->spec;
1380 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1383 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1384 struct hda_codec *codec,
1385 struct snd_pcm_substream *substream)
1387 struct sigmatel_spec *spec = codec->spec;
1388 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1392 * Digital playback callbacks
1394 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1395 struct hda_codec *codec,
1396 struct snd_pcm_substream *substream)
1398 struct sigmatel_spec *spec = codec->spec;
1399 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1402 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1403 struct hda_codec *codec,
1404 struct snd_pcm_substream *substream)
1406 struct sigmatel_spec *spec = codec->spec;
1407 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1410 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1411 struct hda_codec *codec,
1412 unsigned int stream_tag,
1413 unsigned int format,
1414 struct snd_pcm_substream *substream)
1416 struct sigmatel_spec *spec = codec->spec;
1417 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1418 stream_tag, format, substream);
1423 * Analog capture callbacks
1425 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1426 struct hda_codec *codec,
1427 unsigned int stream_tag,
1428 unsigned int format,
1429 struct snd_pcm_substream *substream)
1431 struct sigmatel_spec *spec = codec->spec;
1433 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1434 stream_tag, 0, format);
1438 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1439 struct hda_codec *codec,
1440 struct snd_pcm_substream *substream)
1442 struct sigmatel_spec *spec = codec->spec;
1444 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1448 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1452 /* NID is set in stac92xx_build_pcms */
1454 .open = stac92xx_dig_playback_pcm_open,
1455 .close = stac92xx_dig_playback_pcm_close,
1456 .prepare = stac92xx_dig_playback_pcm_prepare
1460 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1464 /* NID is set in stac92xx_build_pcms */
1467 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1471 .nid = 0x02, /* NID to query formats and rates */
1473 .open = stac92xx_playback_pcm_open,
1474 .prepare = stac92xx_playback_pcm_prepare,
1475 .cleanup = stac92xx_playback_pcm_cleanup
1479 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1483 .nid = 0x06, /* NID to query formats and rates */
1485 .open = stac92xx_playback_pcm_open,
1486 .prepare = stac92xx_playback_pcm_prepare,
1487 .cleanup = stac92xx_playback_pcm_cleanup
1491 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1494 /* NID + .substreams is set in stac92xx_build_pcms */
1496 .prepare = stac92xx_capture_pcm_prepare,
1497 .cleanup = stac92xx_capture_pcm_cleanup
1501 static int stac92xx_build_pcms(struct hda_codec *codec)
1503 struct sigmatel_spec *spec = codec->spec;
1504 struct hda_pcm *info = spec->pcm_rec;
1506 codec->num_pcms = 1;
1507 codec->pcm_info = info;
1509 info->name = "STAC92xx Analog";
1510 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
1511 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
1512 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1513 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
1515 if (spec->alt_switch) {
1518 info->name = "STAC92xx Analog Alt";
1519 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1522 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1525 info->name = "STAC92xx Digital";
1526 if (spec->multiout.dig_out_nid) {
1527 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1528 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1530 if (spec->dig_in_nid) {
1531 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1532 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1539 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1541 unsigned int pincap = snd_hda_param_read(codec, nid,
1543 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1544 if (pincap & AC_PINCAP_VREF_100)
1545 return AC_PINCTL_VREF_100;
1546 if (pincap & AC_PINCAP_VREF_80)
1547 return AC_PINCTL_VREF_80;
1548 if (pincap & AC_PINCAP_VREF_50)
1549 return AC_PINCTL_VREF_50;
1550 if (pincap & AC_PINCAP_VREF_GRD)
1551 return AC_PINCTL_VREF_GRD;
1555 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1558 snd_hda_codec_write_cache(codec, nid, 0,
1559 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1562 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1564 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1566 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1567 struct sigmatel_spec *spec = codec->spec;
1568 int io_idx = kcontrol-> private_value & 0xff;
1570 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1574 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1576 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1577 struct sigmatel_spec *spec = codec->spec;
1578 hda_nid_t nid = kcontrol->private_value >> 8;
1579 int io_idx = kcontrol-> private_value & 0xff;
1580 unsigned short val = !!ucontrol->value.integer.value[0];
1582 spec->io_switch[io_idx] = val;
1585 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1587 unsigned int pinctl = AC_PINCTL_IN_EN;
1588 if (io_idx) /* set VREF for mic */
1589 pinctl |= stac92xx_get_vref(codec, nid);
1590 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1593 /* check the auto-mute again: we need to mute/unmute the speaker
1594 * appropriately according to the pin direction
1596 if (spec->hp_detect)
1597 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1602 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
1604 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
1605 struct snd_ctl_elem_value *ucontrol)
1607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1608 struct sigmatel_spec *spec = codec->spec;
1610 ucontrol->value.integer.value[0] = spec->clfe_swap;
1614 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
1615 struct snd_ctl_elem_value *ucontrol)
1617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1618 struct sigmatel_spec *spec = codec->spec;
1619 hda_nid_t nid = kcontrol->private_value & 0xff;
1620 unsigned int val = !!ucontrol->value.integer.value[0];
1622 if (spec->clfe_swap == val)
1625 spec->clfe_swap = val;
1627 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1628 spec->clfe_swap ? 0x4 : 0x0);
1633 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
1634 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1637 .info = stac92xx_io_switch_info, \
1638 .get = stac92xx_io_switch_get, \
1639 .put = stac92xx_io_switch_put, \
1640 .private_value = xpval, \
1643 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
1644 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1647 .info = stac92xx_clfe_switch_info, \
1648 .get = stac92xx_clfe_switch_get, \
1649 .put = stac92xx_clfe_switch_put, \
1650 .private_value = xpval, \
1654 STAC_CTL_WIDGET_VOL,
1655 STAC_CTL_WIDGET_MUTE,
1656 STAC_CTL_WIDGET_IO_SWITCH,
1657 STAC_CTL_WIDGET_CLFE_SWITCH
1660 static struct snd_kcontrol_new stac92xx_control_templates[] = {
1661 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1662 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1663 STAC_CODEC_IO_SWITCH(NULL, 0),
1664 STAC_CODEC_CLFE_SWITCH(NULL, 0),
1667 /* add dynamic controls */
1668 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1670 struct snd_kcontrol_new *knew;
1672 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1673 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1675 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1678 if (spec->kctl_alloc) {
1679 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1680 kfree(spec->kctl_alloc);
1682 spec->kctl_alloc = knew;
1683 spec->num_kctl_alloc = num;
1686 knew = &spec->kctl_alloc[spec->num_kctl_used];
1687 *knew = stac92xx_control_templates[type];
1688 knew->name = kstrdup(name, GFP_KERNEL);
1691 knew->private_value = val;
1692 spec->num_kctl_used++;
1696 /* flag inputs as additional dynamic lineouts */
1697 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1699 struct sigmatel_spec *spec = codec->spec;
1700 unsigned int wcaps, wtype;
1701 int i, num_dacs = 0;
1703 /* use the wcaps cache to count all DACs available for line-outs */
1704 for (i = 0; i < codec->num_nodes; i++) {
1705 wcaps = codec->wcaps[i];
1706 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1707 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1711 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1713 switch (cfg->line_outs) {
1715 /* add line-in as side */
1716 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1717 cfg->line_out_pins[cfg->line_outs] =
1718 cfg->input_pins[AUTO_PIN_LINE];
1719 spec->line_switch = 1;
1724 /* add line-in as clfe and mic as side */
1725 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1726 cfg->line_out_pins[cfg->line_outs] =
1727 cfg->input_pins[AUTO_PIN_LINE];
1728 spec->line_switch = 1;
1731 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1732 cfg->line_out_pins[cfg->line_outs] =
1733 cfg->input_pins[AUTO_PIN_MIC];
1734 spec->mic_switch = 1;
1739 /* add line-in as surr and mic as clfe */
1740 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1741 cfg->line_out_pins[cfg->line_outs] =
1742 cfg->input_pins[AUTO_PIN_LINE];
1743 spec->line_switch = 1;
1746 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1747 cfg->line_out_pins[cfg->line_outs] =
1748 cfg->input_pins[AUTO_PIN_MIC];
1749 spec->mic_switch = 1;
1759 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1763 for (i = 0; i < spec->multiout.num_dacs; i++) {
1764 if (spec->multiout.dac_nids[i] == nid)
1772 * Fill in the dac_nids table from the parsed pin configuration
1773 * This function only works when every pin in line_out_pins[]
1774 * contains atleast one DAC in its connection list. Some 92xx
1775 * codecs are not connected directly to a DAC, such as the 9200
1776 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1778 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1779 struct auto_pin_cfg *cfg)
1781 struct sigmatel_spec *spec = codec->spec;
1782 int i, j, conn_len = 0;
1783 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1784 unsigned int wcaps, wtype;
1786 for (i = 0; i < cfg->line_outs; i++) {
1787 nid = cfg->line_out_pins[i];
1788 conn_len = snd_hda_get_connections(codec, nid, conn,
1789 HDA_MAX_CONNECTIONS);
1790 for (j = 0; j < conn_len; j++) {
1791 wcaps = snd_hda_param_read(codec, conn[j],
1792 AC_PAR_AUDIO_WIDGET_CAP);
1793 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1795 if (wtype != AC_WID_AUD_OUT ||
1796 (wcaps & AC_WCAP_DIGITAL))
1798 /* conn[j] is a DAC routed to this line-out */
1799 if (!is_in_dac_nids(spec, conn[j]))
1803 if (j == conn_len) {
1804 if (spec->multiout.num_dacs > 0) {
1805 /* we have already working output pins,
1806 * so let's drop the broken ones again
1808 cfg->line_outs = spec->multiout.num_dacs;
1811 /* error out, no available DAC found */
1813 "%s: No available DAC for pin 0x%x\n",
1818 spec->multiout.dac_nids[i] = conn[j];
1819 spec->multiout.num_dacs++;
1821 /* select this DAC in the pin's input mux */
1822 snd_hda_codec_write_cache(codec, nid, 0,
1823 AC_VERB_SET_CONNECT_SEL, j);
1828 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1829 spec->multiout.num_dacs,
1830 spec->multiout.dac_nids[0],
1831 spec->multiout.dac_nids[1],
1832 spec->multiout.dac_nids[2],
1833 spec->multiout.dac_nids[3],
1834 spec->multiout.dac_nids[4]);
1838 /* create volume control/switch for the given prefx type */
1839 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1844 sprintf(name, "%s Playback Volume", pfx);
1845 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1846 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1849 sprintf(name, "%s Playback Switch", pfx);
1850 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1851 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1857 /* add playback controls from the parsed DAC table */
1858 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
1859 const struct auto_pin_cfg *cfg)
1861 static const char *chname[4] = {
1862 "Front", "Surround", NULL /*CLFE*/, "Side"
1867 struct sigmatel_spec *spec = codec->spec;
1868 unsigned int wid_caps;
1871 for (i = 0; i < cfg->line_outs; i++) {
1872 if (!spec->multiout.dac_nids[i])
1875 nid = spec->multiout.dac_nids[i];
1879 err = create_controls(spec, "Center", nid, 1);
1882 err = create_controls(spec, "LFE", nid, 2);
1886 wid_caps = get_wcaps(codec, nid);
1888 if (wid_caps & AC_WCAP_LR_SWAP) {
1889 err = stac92xx_add_control(spec,
1890 STAC_CTL_WIDGET_CLFE_SWITCH,
1891 "Swap Center/LFE Playback Switch", nid);
1898 err = create_controls(spec, chname[i], nid, 3);
1904 if (spec->line_switch)
1905 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1908 if (spec->mic_switch)
1909 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1915 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1917 if (is_in_dac_nids(spec, nid))
1919 if (spec->multiout.hp_nid == nid)
1924 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1926 if (!spec->multiout.hp_nid)
1927 spec->multiout.hp_nid = nid;
1928 else if (spec->multiout.num_dacs > 4) {
1929 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1932 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1933 spec->multiout.num_dacs++;
1938 /* add playback controls for Speaker and HP outputs */
1939 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1940 struct auto_pin_cfg *cfg)
1942 struct sigmatel_spec *spec = codec->spec;
1944 int i, old_num_dacs, err;
1946 old_num_dacs = spec->multiout.num_dacs;
1947 for (i = 0; i < cfg->hp_outs; i++) {
1948 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1949 if (wid_caps & AC_WCAP_UNSOL_CAP)
1950 spec->hp_detect = 1;
1951 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
1952 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1953 if (check_in_dac_nids(spec, nid))
1957 add_spec_dacs(spec, nid);
1959 for (i = 0; i < cfg->speaker_outs; i++) {
1960 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
1961 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1962 if (check_in_dac_nids(spec, nid))
1966 add_spec_dacs(spec, nid);
1968 for (i = 0; i < cfg->line_outs; i++) {
1969 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
1970 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
1971 if (check_in_dac_nids(spec, nid))
1975 add_spec_dacs(spec, nid);
1977 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
1978 static const char *pfxs[] = {
1979 "Speaker", "External Speaker", "Speaker2",
1981 err = create_controls(spec, pfxs[i - old_num_dacs],
1982 spec->multiout.dac_nids[i], 3);
1986 if (spec->multiout.hp_nid) {
1988 if (old_num_dacs == spec->multiout.num_dacs)
1992 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
2000 /* labels for dmic mux inputs */
2001 static const char *stac92xx_dmic_labels[5] = {
2002 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2003 "Digital Mic 3", "Digital Mic 4"
2006 /* create playback/capture controls for input pins on dmic capable codecs */
2007 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2008 const struct auto_pin_cfg *cfg)
2010 struct sigmatel_spec *spec = codec->spec;
2011 struct hda_input_mux *dimux = &spec->private_dimux;
2012 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2015 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2016 dimux->items[dimux->num_items].index = 0;
2019 for (i = 0; i < spec->num_dmics; i++) {
2022 unsigned int def_conf;
2024 def_conf = snd_hda_codec_read(codec,
2027 AC_VERB_GET_CONFIG_DEFAULT,
2029 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2032 num_cons = snd_hda_get_connections(codec,
2035 HDA_MAX_NUM_INPUTS);
2036 for (j = 0; j < num_cons; j++)
2037 if (con_lst[j] == spec->dmic_nids[i]) {
2043 dimux->items[dimux->num_items].label =
2044 stac92xx_dmic_labels[dimux->num_items];
2045 dimux->items[dimux->num_items].index = index;
2052 /* create playback/capture controls for input pins */
2053 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2055 struct sigmatel_spec *spec = codec->spec;
2056 struct hda_input_mux *imux = &spec->private_imux;
2057 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2060 for (i = 0; i < AUTO_PIN_LAST; i++) {
2063 if (!cfg->input_pins[i])
2066 for (j = 0; j < spec->num_muxes; j++) {
2068 num_cons = snd_hda_get_connections(codec,
2071 HDA_MAX_NUM_INPUTS);
2072 for (k = 0; k < num_cons; k++)
2073 if (con_lst[k] == cfg->input_pins[i]) {
2080 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2081 imux->items[imux->num_items].index = index;
2085 if (imux->num_items) {
2087 * Set the current input for the muxes.
2088 * The STAC9221 has two input muxes with identical source
2089 * NID lists. Hopefully this won't get confused.
2091 for (i = 0; i < spec->num_muxes; i++) {
2092 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2093 AC_VERB_SET_CONNECT_SEL,
2094 imux->items[0].index);
2101 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2103 struct sigmatel_spec *spec = codec->spec;
2106 for (i = 0; i < spec->autocfg.line_outs; i++) {
2107 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2108 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2112 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2114 struct sigmatel_spec *spec = codec->spec;
2117 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2119 pin = spec->autocfg.hp_pins[i];
2120 if (pin) /* connect to front */
2121 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2123 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2125 pin = spec->autocfg.speaker_pins[i];
2126 if (pin) /* connect to front */
2127 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2131 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2133 struct sigmatel_spec *spec = codec->spec;
2135 int hp_speaker_swap = 0;
2137 if ((err = snd_hda_parse_pin_def_config(codec,
2139 spec->dmic_nids)) < 0)
2141 if (! spec->autocfg.line_outs)
2142 return 0; /* can't find valid pin config */
2144 /* If we have no real line-out pin and multiple hp-outs, HPs should
2145 * be set up as multi-channel outputs.
2147 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2148 spec->autocfg.hp_outs > 1) {
2149 /* Copy hp_outs to line_outs, backup line_outs in
2150 * speaker_outs so that the following routines can handle
2151 * HP pins as primary outputs.
2153 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2154 sizeof(spec->autocfg.line_out_pins));
2155 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2156 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2157 sizeof(spec->autocfg.hp_pins));
2158 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2159 hp_speaker_swap = 1;
2162 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2164 if (spec->multiout.num_dacs == 0)
2165 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2168 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2173 if (hp_speaker_swap == 1) {
2174 /* Restore the hp_outs and line_outs */
2175 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2176 sizeof(spec->autocfg.line_out_pins));
2177 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2178 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2179 sizeof(spec->autocfg.speaker_pins));
2180 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2181 memset(spec->autocfg.speaker_pins, 0,
2182 sizeof(spec->autocfg.speaker_pins));
2183 spec->autocfg.speaker_outs = 0;
2186 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2191 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2196 if (spec->num_dmics > 0)
2197 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2198 &spec->autocfg)) < 0)
2201 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2202 if (spec->multiout.max_channels > 2)
2203 spec->surr_switch = 1;
2205 if (spec->autocfg.dig_out_pin)
2206 spec->multiout.dig_out_nid = dig_out;
2207 if (spec->autocfg.dig_in_pin)
2208 spec->dig_in_nid = dig_in;
2210 if (spec->kctl_alloc)
2211 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2213 spec->input_mux = &spec->private_imux;
2214 spec->dinput_mux = &spec->private_dimux;
2219 /* add playback controls for HP output */
2220 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2221 struct auto_pin_cfg *cfg)
2223 struct sigmatel_spec *spec = codec->spec;
2224 hda_nid_t pin = cfg->hp_pins[0];
2225 unsigned int wid_caps;
2230 wid_caps = get_wcaps(codec, pin);
2231 if (wid_caps & AC_WCAP_UNSOL_CAP)
2232 spec->hp_detect = 1;
2237 /* add playback controls for LFE output */
2238 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2239 struct auto_pin_cfg *cfg)
2241 struct sigmatel_spec *spec = codec->spec;
2243 hda_nid_t lfe_pin = 0x0;
2247 * search speaker outs and line outs for a mono speaker pin
2248 * with an amp. If one is found, add LFE controls
2251 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2252 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2253 unsigned long wcaps = get_wcaps(codec, pin);
2254 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2255 if (wcaps == AC_WCAP_OUT_AMP)
2256 /* found a mono speaker with an amp, must be lfe */
2260 /* if speaker_outs is 0, then speakers may be in line_outs */
2261 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2262 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2263 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2265 cfg = snd_hda_codec_read(codec, pin, 0,
2266 AC_VERB_GET_CONFIG_DEFAULT,
2268 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
2269 unsigned long wcaps = get_wcaps(codec, pin);
2270 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2271 if (wcaps == AC_WCAP_OUT_AMP)
2272 /* found a mono speaker with an amp,
2280 err = create_controls(spec, "LFE", lfe_pin, 1);
2288 static int stac9200_parse_auto_config(struct hda_codec *codec)
2290 struct sigmatel_spec *spec = codec->spec;
2293 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2296 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2299 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2302 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2305 if (spec->autocfg.dig_out_pin)
2306 spec->multiout.dig_out_nid = 0x05;
2307 if (spec->autocfg.dig_in_pin)
2308 spec->dig_in_nid = 0x04;
2310 if (spec->kctl_alloc)
2311 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2313 spec->input_mux = &spec->private_imux;
2314 spec->dinput_mux = &spec->private_dimux;
2320 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2321 * funky external mute control using GPIO pins.
2324 static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
2326 unsigned int gpiostate, gpiomask, gpiodir;
2328 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
2329 AC_VERB_GET_GPIO_DATA, 0);
2332 gpiostate |= (1 << pin);
2334 gpiostate &= ~(1 << pin);
2336 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
2337 AC_VERB_GET_GPIO_MASK, 0);
2338 gpiomask |= (1 << pin);
2340 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
2341 AC_VERB_GET_GPIO_DIRECTION, 0);
2342 gpiodir |= (1 << pin);
2344 /* AppleHDA seems to do this -- WTF is this verb?? */
2345 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
2347 snd_hda_codec_write(codec, codec->afg, 0,
2348 AC_VERB_SET_GPIO_MASK, gpiomask);
2349 snd_hda_codec_write(codec, codec->afg, 0,
2350 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
2354 snd_hda_codec_write(codec, codec->afg, 0,
2355 AC_VERB_SET_GPIO_DATA, gpiostate);
2358 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2361 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
2362 snd_hda_codec_write_cache(codec, nid, 0,
2363 AC_VERB_SET_UNSOLICITED_ENABLE,
2364 (AC_USRSP_EN | event));
2367 static int stac92xx_init(struct hda_codec *codec)
2369 struct sigmatel_spec *spec = codec->spec;
2370 struct auto_pin_cfg *cfg = &spec->autocfg;
2373 snd_hda_sequence_write(codec, spec->init);
2376 if (spec->hp_detect) {
2377 /* Enable unsolicited responses on the HP widget */
2378 for (i = 0; i < cfg->hp_outs; i++)
2379 enable_pin_detect(codec, cfg->hp_pins[i],
2381 /* force to enable the first line-out; the others are set up
2384 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
2386 stac92xx_auto_init_hp_out(codec);
2387 /* fake event to set up pins */
2388 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2390 stac92xx_auto_init_multi_out(codec);
2391 stac92xx_auto_init_hp_out(codec);
2393 for (i = 0; i < AUTO_PIN_LAST; i++) {
2394 hda_nid_t nid = cfg->input_pins[i];
2396 unsigned int pinctl = AC_PINCTL_IN_EN;
2397 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
2398 pinctl |= stac92xx_get_vref(codec, nid);
2399 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2402 if (spec->num_dmics > 0)
2403 for (i = 0; i < spec->num_dmics; i++)
2404 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
2407 if (cfg->dig_out_pin)
2408 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
2410 if (cfg->dig_in_pin)
2411 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
2414 if (spec->gpio_mute) {
2415 stac922x_gpio_mute(codec, 0, 0);
2416 stac922x_gpio_mute(codec, 1, 0);
2422 static void stac92xx_free(struct hda_codec *codec)
2424 struct sigmatel_spec *spec = codec->spec;
2430 if (spec->kctl_alloc) {
2431 for (i = 0; i < spec->num_kctl_used; i++)
2432 kfree(spec->kctl_alloc[i].name);
2433 kfree(spec->kctl_alloc);
2436 if (spec->bios_pin_configs)
2437 kfree(spec->bios_pin_configs);
2442 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
2445 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2446 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2448 if (pin_ctl & AC_PINCTL_IN_EN) {
2450 * we need to check the current set-up direction of
2451 * shared input pins since they can be switched via
2452 * "xxx as Output" mixer switch
2454 struct sigmatel_spec *spec = codec->spec;
2455 struct auto_pin_cfg *cfg = &spec->autocfg;
2456 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
2457 spec->line_switch) ||
2458 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
2463 /* if setting pin direction bits, clear the current
2464 direction bits first */
2465 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
2466 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
2468 snd_hda_codec_write_cache(codec, nid, 0,
2469 AC_VERB_SET_PIN_WIDGET_CONTROL,
2473 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
2476 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2477 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2478 snd_hda_codec_write_cache(codec, nid, 0,
2479 AC_VERB_SET_PIN_WIDGET_CONTROL,
2483 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
2487 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
2489 unsigned int pinctl;
2490 pinctl = snd_hda_codec_read(codec, nid, 0,
2491 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2492 if (pinctl & AC_PINCTL_IN_EN)
2493 return 0; /* mic- or line-input */
2495 return 1; /* HP-output */
2500 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
2502 struct sigmatel_spec *spec = codec->spec;
2503 struct auto_pin_cfg *cfg = &spec->autocfg;
2507 for (i = 0; i < cfg->hp_outs; i++) {
2508 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
2514 /* disable lineouts, enable hp */
2515 for (i = 0; i < cfg->line_outs; i++)
2516 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
2518 for (i = 0; i < cfg->speaker_outs; i++)
2519 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2522 /* enable lineouts, disable hp */
2523 for (i = 0; i < cfg->line_outs; i++)
2524 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
2526 for (i = 0; i < cfg->speaker_outs; i++)
2527 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2532 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
2534 switch (res >> 26) {
2536 stac92xx_hp_detect(codec, res);
2541 #ifdef SND_HDA_NEEDS_RESUME
2542 static int stac92xx_resume(struct hda_codec *codec)
2544 struct sigmatel_spec *spec = codec->spec;
2546 stac92xx_set_config_regs(codec);
2547 snd_hda_sequence_write(codec, spec->init);
2548 if (spec->gpio_mute) {
2549 stac922x_gpio_mute(codec, 0, 0);
2550 stac922x_gpio_mute(codec, 1, 0);
2552 snd_hda_codec_resume_amp(codec);
2553 snd_hda_codec_resume_cache(codec);
2554 /* invoke unsolicited event to reset the HP state */
2555 if (spec->hp_detect)
2556 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2561 static struct hda_codec_ops stac92xx_patch_ops = {
2562 .build_controls = stac92xx_build_controls,
2563 .build_pcms = stac92xx_build_pcms,
2564 .init = stac92xx_init,
2565 .free = stac92xx_free,
2566 .unsol_event = stac92xx_unsol_event,
2567 #ifdef SND_HDA_NEEDS_RESUME
2568 .resume = stac92xx_resume,
2572 static int patch_stac9200(struct hda_codec *codec)
2574 struct sigmatel_spec *spec;
2577 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2582 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
2583 spec->pin_nids = stac9200_pin_nids;
2584 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
2587 if (spec->board_config < 0) {
2588 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
2589 err = stac92xx_save_bios_config_regs(codec);
2591 stac92xx_free(codec);
2594 spec->pin_configs = spec->bios_pin_configs;
2596 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
2597 stac92xx_set_config_regs(codec);
2600 spec->multiout.max_channels = 2;
2601 spec->multiout.num_dacs = 1;
2602 spec->multiout.dac_nids = stac9200_dac_nids;
2603 spec->adc_nids = stac9200_adc_nids;
2604 spec->mux_nids = stac9200_mux_nids;
2605 spec->num_muxes = 1;
2606 spec->num_dmics = 0;
2609 if (spec->board_config == STAC_9200_GATEWAY)
2610 spec->init = stac9200_eapd_init;
2612 spec->init = stac9200_core_init;
2613 spec->mixer = stac9200_mixer;
2615 err = stac9200_parse_auto_config(codec);
2617 stac92xx_free(codec);
2621 codec->patch_ops = stac92xx_patch_ops;
2626 static int patch_stac925x(struct hda_codec *codec)
2628 struct sigmatel_spec *spec;
2631 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2636 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
2637 spec->pin_nids = stac925x_pin_nids;
2638 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
2642 if (spec->board_config < 0) {
2643 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2644 "using BIOS defaults\n");
2645 err = stac92xx_save_bios_config_regs(codec);
2647 stac92xx_free(codec);
2650 spec->pin_configs = spec->bios_pin_configs;
2651 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
2652 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
2653 stac92xx_set_config_regs(codec);
2656 spec->multiout.max_channels = 2;
2657 spec->multiout.num_dacs = 1;
2658 spec->multiout.dac_nids = stac925x_dac_nids;
2659 spec->adc_nids = stac925x_adc_nids;
2660 spec->mux_nids = stac925x_mux_nids;
2661 spec->num_muxes = 1;
2663 switch (codec->vendor_id) {
2664 case 0x83847632: /* STAC9202 */
2665 case 0x83847633: /* STAC9202D */
2666 case 0x83847636: /* STAC9251 */
2667 case 0x83847637: /* STAC9251D */
2668 spec->num_dmics = STAC925X_NUM_DMICS;
2669 spec->dmic_nids = stac925x_dmic_nids;
2672 spec->num_dmics = 0;
2676 spec->init = stac925x_core_init;
2677 spec->mixer = stac925x_mixer;
2679 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
2681 if (spec->board_config < 0) {
2682 printk(KERN_WARNING "hda_codec: No auto-config is "
2683 "available, default to model=ref\n");
2684 spec->board_config = STAC_925x_REF;
2690 stac92xx_free(codec);
2694 codec->patch_ops = stac92xx_patch_ops;
2699 static int patch_stac92hd71bxx(struct hda_codec *codec)
2701 struct sigmatel_spec *spec;
2704 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2709 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
2710 spec->pin_nids = stac92hd71bxx_pin_nids;
2711 spec->board_config = snd_hda_check_board_config(codec,
2712 STAC_92HD71BXX_MODELS,
2713 stac92hd71bxx_models,
2714 stac92hd71bxx_cfg_tbl);
2716 if (spec->board_config < 0) {
2717 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
2718 " STAC92HD71BXX, using BIOS defaults\n");
2719 err = stac92xx_save_bios_config_regs(codec);
2721 stac92xx_free(codec);
2724 spec->pin_configs = spec->bios_pin_configs;
2726 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
2727 stac92xx_set_config_regs(codec);
2730 spec->gpio_mask = spec->gpio_data = 0x00000001; /* GPIO0 High = EAPD */
2731 stac92xx_enable_gpio_mask(codec);
2733 spec->init = stac92hd71bxx_core_init;
2734 spec->mixer = stac92hd71bxx_mixer;
2736 spec->mux_nids = stac92hd71bxx_mux_nids;
2737 spec->adc_nids = stac92hd71bxx_adc_nids;
2738 spec->dmic_nids = stac92hd71bxx_dmic_nids;
2739 spec->dmux_nid = 0x1c;
2741 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
2742 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
2743 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
2745 spec->multiout.num_dacs = 2;
2746 spec->multiout.hp_nid = 0x11;
2747 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
2749 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
2751 if (spec->board_config < 0) {
2752 printk(KERN_WARNING "hda_codec: No auto-config is "
2753 "available, default to model=ref\n");
2754 spec->board_config = STAC_92HD71BXX_REF;
2761 stac92xx_free(codec);
2765 codec->patch_ops = stac92xx_patch_ops;
2770 static int patch_stac922x(struct hda_codec *codec)
2772 struct sigmatel_spec *spec;
2775 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2780 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
2781 spec->pin_nids = stac922x_pin_nids;
2782 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2785 if (spec->board_config == STAC_INTEL_MAC_V3) {
2786 spec->gpio_mute = 1;
2787 /* Intel Macs have all same PCI SSID, so we need to check
2788 * codec SSID to distinguish the exact models
2790 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
2791 switch (codec->subsystem_id) {
2794 spec->board_config = STAC_INTEL_MAC_V1;
2798 spec->board_config = STAC_INTEL_MAC_V2;
2806 spec->board_config = STAC_INTEL_MAC_V3;
2810 spec->board_config = STAC_INTEL_MAC_V4;
2814 spec->board_config = STAC_INTEL_MAC_V5;
2820 if (spec->board_config < 0) {
2821 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2822 "using BIOS defaults\n");
2823 err = stac92xx_save_bios_config_regs(codec);
2825 stac92xx_free(codec);
2828 spec->pin_configs = spec->bios_pin_configs;
2829 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
2830 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2831 stac92xx_set_config_regs(codec);
2834 spec->adc_nids = stac922x_adc_nids;
2835 spec->mux_nids = stac922x_mux_nids;
2836 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
2837 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
2838 spec->num_dmics = 0;
2840 spec->init = stac922x_core_init;
2841 spec->mixer = stac922x_mixer;
2843 spec->multiout.dac_nids = spec->dac_nids;
2845 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
2847 if (spec->board_config < 0) {
2848 printk(KERN_WARNING "hda_codec: No auto-config is "
2849 "available, default to model=ref\n");
2850 spec->board_config = STAC_D945_REF;
2856 stac92xx_free(codec);
2860 codec->patch_ops = stac92xx_patch_ops;
2862 /* Fix Mux capture level; max to 2 */
2863 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2864 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2865 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2866 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2867 (0 << AC_AMPCAP_MUTE_SHIFT));
2872 static int patch_stac927x(struct hda_codec *codec)
2874 struct sigmatel_spec *spec;
2877 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2882 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
2883 spec->pin_nids = stac927x_pin_nids;
2884 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2888 if (spec->board_config < 0) {
2889 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
2890 err = stac92xx_save_bios_config_regs(codec);
2892 stac92xx_free(codec);
2895 spec->pin_configs = spec->bios_pin_configs;
2896 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
2897 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2898 stac92xx_set_config_regs(codec);
2901 switch (spec->board_config) {
2903 spec->adc_nids = stac927x_adc_nids;
2904 spec->mux_nids = stac927x_mux_nids;
2905 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2906 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2907 spec->init = d965_core_init;
2908 spec->mixer = stac927x_mixer;
2911 spec->adc_nids = stac927x_adc_nids;
2912 spec->mux_nids = stac927x_mux_nids;
2913 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2914 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2915 spec->init = d965_core_init;
2916 spec->mixer = stac927x_mixer;
2919 spec->adc_nids = stac927x_adc_nids;
2920 spec->mux_nids = stac927x_mux_nids;
2921 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2922 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2923 spec->init = stac927x_core_init;
2924 spec->mixer = stac927x_mixer;
2927 switch (codec->subsystem_id) {
2928 case 0x10280242: /* STAC 9228 */
2932 spec->dmic_nids = stac927x_dmic_nids;
2933 spec->num_dmics = STAC927X_NUM_DMICS;
2934 spec->dmux_nid = 0x1b;
2937 stac92xx_set_config_reg(codec, 0x13, 0x90a60040);
2939 /* GPIO2 High = Enable EAPD */
2940 spec->gpio_mask = spec->gpio_data = 0x00000004;
2943 spec->num_dmics = 0;
2945 /* GPIO0 High = Enable EAPD */
2946 spec->gpio_mask = spec->gpio_data = 0x00000001;
2949 spec->multiout.dac_nids = spec->dac_nids;
2950 stac92xx_enable_gpio_mask(codec);
2952 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
2954 if (spec->board_config < 0) {
2955 printk(KERN_WARNING "hda_codec: No auto-config is "
2956 "available, default to model=ref\n");
2957 spec->board_config = STAC_D965_REF;
2963 stac92xx_free(codec);
2967 codec->patch_ops = stac92xx_patch_ops;
2972 static int patch_stac9205(struct hda_codec *codec)
2974 struct sigmatel_spec *spec;
2977 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2982 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
2983 spec->pin_nids = stac9205_pin_nids;
2984 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
2988 if (spec->board_config < 0) {
2989 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
2990 err = stac92xx_save_bios_config_regs(codec);
2992 stac92xx_free(codec);
2995 spec->pin_configs = spec->bios_pin_configs;
2997 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
2998 stac92xx_set_config_regs(codec);
3001 spec->adc_nids = stac9205_adc_nids;
3002 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
3003 spec->mux_nids = stac9205_mux_nids;
3004 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
3005 spec->dmic_nids = stac9205_dmic_nids;
3006 spec->num_dmics = STAC9205_NUM_DMICS;
3007 spec->dmux_nid = 0x1d;
3009 spec->init = stac9205_core_init;
3010 spec->mixer = stac9205_mixer;
3012 spec->multiout.dac_nids = spec->dac_nids;
3014 switch (spec->board_config){
3015 case STAC_9205_DELL_M43:
3016 /* Enable SPDIF in/out */
3017 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3018 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
3020 spec->gpio_mask = 0x00000007; /* GPIO0-2 */
3021 /* GPIO0 High = EAPD, GPIO1 Low = DRM,
3022 * GPIO2 High = Headphone Mute
3024 spec->gpio_data = 0x00000005;
3027 /* GPIO0 High = EAPD */
3028 spec->gpio_mask = spec->gpio_data = 0x00000001;
3032 stac92xx_enable_gpio_mask(codec);
3033 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
3035 if (spec->board_config < 0) {
3036 printk(KERN_WARNING "hda_codec: No auto-config is "
3037 "available, default to model=ref\n");
3038 spec->board_config = STAC_9205_REF;
3044 stac92xx_free(codec);
3048 codec->patch_ops = stac92xx_patch_ops;
3057 /* static config for Sony VAIO FE550G and Sony VAIO AR */
3058 static hda_nid_t vaio_dacs[] = { 0x2 };
3059 #define VAIO_HP_DAC 0x5
3060 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
3061 static hda_nid_t vaio_mux_nids[] = { 0x15 };
3063 static struct hda_input_mux vaio_mux = {
3066 /* { "HP", 0x0 }, */
3067 { "Mic Jack", 0x1 },
3068 { "Internal Mic", 0x2 },
3073 static struct hda_verb vaio_init[] = {
3074 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3075 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
3076 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3077 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3078 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3079 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3080 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3081 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3082 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3083 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3085 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3089 static struct hda_verb vaio_ar_init[] = {
3090 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3091 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3092 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3093 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3094 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
3095 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3096 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3097 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3098 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3099 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
3100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3101 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3106 /* bind volumes of both NID 0x02 and 0x05 */
3107 static struct hda_bind_ctls vaio_bind_master_vol = {
3108 .ops = &snd_hda_bind_vol,
3110 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
3111 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
3116 /* bind volumes of both NID 0x02 and 0x05 */
3117 static struct hda_bind_ctls vaio_bind_master_sw = {
3118 .ops = &snd_hda_bind_sw,
3120 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
3121 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
3126 static struct snd_kcontrol_new vaio_mixer[] = {
3127 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
3128 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
3129 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
3130 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
3131 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
3133 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3134 .name = "Capture Source",
3136 .info = stac92xx_mux_enum_info,
3137 .get = stac92xx_mux_enum_get,
3138 .put = stac92xx_mux_enum_put,
3143 static struct snd_kcontrol_new vaio_ar_mixer[] = {
3144 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
3145 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
3146 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
3147 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
3148 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
3149 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
3150 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
3152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3153 .name = "Capture Source",
3155 .info = stac92xx_mux_enum_info,
3156 .get = stac92xx_mux_enum_get,
3157 .put = stac92xx_mux_enum_put,
3162 static struct hda_codec_ops stac9872_patch_ops = {
3163 .build_controls = stac92xx_build_controls,
3164 .build_pcms = stac92xx_build_pcms,
3165 .init = stac92xx_init,
3166 .free = stac92xx_free,
3167 #ifdef SND_HDA_NEEDS_RESUME
3168 .resume = stac92xx_resume,
3172 static int stac9872_vaio_init(struct hda_codec *codec)
3176 err = stac92xx_init(codec);
3179 if (codec->patch_ops.unsol_event)
3180 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3184 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
3186 if (get_hp_pin_presence(codec, 0x0a)) {
3187 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
3188 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
3190 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
3191 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
3195 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
3197 switch (res >> 26) {
3199 stac9872_vaio_hp_detect(codec, res);
3204 static struct hda_codec_ops stac9872_vaio_patch_ops = {
3205 .build_controls = stac92xx_build_controls,
3206 .build_pcms = stac92xx_build_pcms,
3207 .init = stac9872_vaio_init,
3208 .free = stac92xx_free,
3209 .unsol_event = stac9872_vaio_unsol_event,
3211 .resume = stac92xx_resume,
3215 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
3217 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
3219 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
3221 /* AR Series. id=0x83847664 and subsys=104D1300 */
3226 static const char *stac9872_models[STAC_9872_MODELS] = {
3227 [CXD9872RD_VAIO] = "vaio",
3228 [CXD9872AKD_VAIO] = "vaio-ar",
3231 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
3232 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
3233 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
3234 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
3235 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
3239 static int patch_stac9872(struct hda_codec *codec)
3241 struct sigmatel_spec *spec;
3244 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
3247 if (board_config < 0)
3248 /* unknown config, let generic-parser do its job... */
3249 return snd_hda_parse_generic_codec(codec);
3251 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3256 switch (board_config) {
3257 case CXD9872RD_VAIO:
3258 case STAC9872AK_VAIO:
3259 case STAC9872K_VAIO:
3260 spec->mixer = vaio_mixer;
3261 spec->init = vaio_init;
3262 spec->multiout.max_channels = 2;
3263 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
3264 spec->multiout.dac_nids = vaio_dacs;
3265 spec->multiout.hp_nid = VAIO_HP_DAC;
3266 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3267 spec->adc_nids = vaio_adcs;
3268 spec->input_mux = &vaio_mux;
3269 spec->mux_nids = vaio_mux_nids;
3270 codec->patch_ops = stac9872_vaio_patch_ops;
3273 case CXD9872AKD_VAIO:
3274 spec->mixer = vaio_ar_mixer;
3275 spec->init = vaio_ar_init;
3276 spec->multiout.max_channels = 2;
3277 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
3278 spec->multiout.dac_nids = vaio_dacs;
3279 spec->multiout.hp_nid = VAIO_HP_DAC;
3280 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3281 spec->adc_nids = vaio_adcs;
3282 spec->input_mux = &vaio_mux;
3283 spec->mux_nids = vaio_mux_nids;
3284 codec->patch_ops = stac9872_patch_ops;
3295 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
3296 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
3297 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
3298 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
3299 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
3300 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
3301 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
3302 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
3303 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
3304 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
3305 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
3306 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
3307 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
3308 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
3309 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
3310 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
3311 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
3312 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
3313 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
3314 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
3315 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
3316 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
3317 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
3318 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
3319 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
3320 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
3321 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
3322 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
3323 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
3324 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
3325 /* The following does not take into account .id=0x83847661 when subsys =
3326 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
3327 * currently not fully supported.
3329 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
3330 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
3331 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
3332 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
3333 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
3334 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
3335 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
3336 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
3337 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
3338 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
3339 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
3340 { .id = 0x111d76b0, .name = "92HD71BXX", .patch = patch_stac92hd71bxx },