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 int stac92xx_volknob_info(struct snd_kcontrol *kcontrol,
378 struct snd_ctl_elem_info *uinfo)
380 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
382 uinfo->value.integer.min = 0;
383 uinfo->value.integer.max = 127;
387 static int stac92xx_volknob_get(struct snd_kcontrol *kcontrol,
388 struct snd_ctl_elem_value *ucontrol)
390 ucontrol->value.integer.value[0] = kcontrol->private_value & 0xff;
394 static int stac92xx_volknob_put(struct snd_kcontrol *kcontrol,
395 struct snd_ctl_elem_value *ucontrol)
397 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
398 unsigned int oval = kcontrol->private_value & 0xff;
401 val = ucontrol->value.integer.value[0] & 0xff;
405 kcontrol->private_value &= ~0xff;
406 kcontrol->private_value |= val;
408 snd_hda_codec_write_cache(codec, kcontrol->private_value >> 16, 0,
409 AC_VERB_SET_VOLUME_KNOB_CONTROL, val | 0x80);
413 static struct hda_verb stac9200_core_init[] = {
414 /* set dac0mux for dac converter */
415 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
419 static struct hda_verb stac9200_eapd_init[] = {
420 /* set dac0mux for dac converter */
421 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
422 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
426 static struct hda_verb stac92hd71bxx_core_init[] = {
427 /* set master volume and direct control */
428 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
429 /* connect headphone jack to dac1 */
430 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
431 /* connect ports 0d and 0f to audio mixer */
432 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
433 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
434 /* unmute dac0 input in audio mixer */
435 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
436 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
437 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
438 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
439 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
440 /* unmute mono out node */
441 { 0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
445 static struct hda_verb stac925x_core_init[] = {
446 /* set dac0mux for dac converter */
447 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
451 static struct hda_verb stac922x_core_init[] = {
452 /* set master volume and direct control */
453 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
457 static struct hda_verb d965_core_init[] = {
458 /* set master volume and direct control */
459 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
460 /* unmute node 0x1b */
461 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
462 /* select node 0x03 as DAC */
463 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
467 static struct hda_verb stac927x_core_init[] = {
468 /* set master volume and direct control */
469 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
473 static struct hda_verb stac9205_core_init[] = {
474 /* set master volume and direct control */
475 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
479 #define STAC_DIGITAL_INPUT_SOURCE(cnt) \
481 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
482 .name = "Digital Input Source", \
484 .info = stac92xx_dmux_enum_info, \
485 .get = stac92xx_dmux_enum_get, \
486 .put = stac92xx_dmux_enum_put,\
489 #define STAC_INPUT_SOURCE(cnt) \
491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
492 .name = "Input Source", \
494 .info = stac92xx_mux_enum_info, \
495 .get = stac92xx_mux_enum_get, \
496 .put = stac92xx_mux_enum_put, \
499 #define STAC_ANALOG_LOOPBACK(verb_read,verb_write) \
501 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
502 .name = "Analog Loopback", \
504 .info = stac92xx_aloopback_info, \
505 .get = stac92xx_aloopback_get, \
506 .put = stac92xx_aloopback_put, \
507 .private_value = verb_read | (verb_write << 16), \
510 #define STAC_VOLKNOB(knob_nid) \
512 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
513 .name = "Master Playback Volume", \
515 .info = stac92xx_volknob_info, \
516 .get = stac92xx_volknob_get, \
517 .put = stac92xx_volknob_put, \
518 .private_value = 127 | (knob_nid << 16), \
521 static struct snd_kcontrol_new stac9200_mixer[] = {
522 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
523 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
524 STAC_INPUT_SOURCE(1),
525 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
526 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
527 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
531 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
532 STAC_DIGITAL_INPUT_SOURCE(1),
533 STAC_INPUT_SOURCE(2),
536 /* hardware gain controls */
537 HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x0, 0x18, 0x0, HDA_OUTPUT),
538 HDA_CODEC_VOLUME_IDX("Digital Mic Volume", 0x1, 0x19, 0x0, HDA_OUTPUT),
540 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
541 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
542 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
544 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
545 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
546 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
548 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
549 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
553 static struct snd_kcontrol_new stac925x_mixer[] = {
554 STAC_INPUT_SOURCE(1),
555 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
556 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
557 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
561 static struct snd_kcontrol_new stac9205_mixer[] = {
562 STAC_DIGITAL_INPUT_SOURCE(1),
563 STAC_INPUT_SOURCE(2),
564 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0),
566 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
567 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
568 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
570 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
571 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
572 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
577 /* This needs to be generated dynamically based on sequence */
578 static struct snd_kcontrol_new stac922x_mixer[] = {
579 STAC_INPUT_SOURCE(2),
580 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
581 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
582 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
584 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
585 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
586 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
591 static struct snd_kcontrol_new stac927x_mixer[] = {
592 STAC_DIGITAL_INPUT_SOURCE(1),
593 STAC_INPUT_SOURCE(3),
594 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB),
596 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
597 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
598 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
600 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
601 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
602 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
604 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
605 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
606 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
610 static int stac92xx_build_controls(struct hda_codec *codec)
612 struct sigmatel_spec *spec = codec->spec;
616 err = snd_hda_add_new_ctls(codec, spec->mixer);
620 for (i = 0; i < spec->num_mixers; i++) {
621 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
626 if (spec->multiout.dig_out_nid) {
627 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
631 if (spec->dig_in_nid) {
632 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
639 static unsigned int ref9200_pin_configs[8] = {
640 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
641 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
645 STAC 9200 pin configs for
650 static unsigned int dell9200_d21_pin_configs[8] = {
651 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
652 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
656 STAC 9200 pin configs for
660 static unsigned int dell9200_d22_pin_configs[8] = {
661 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
662 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
666 STAC 9200 pin configs for
667 102801C4 (Dell Dimension E310)
674 static unsigned int dell9200_d23_pin_configs[8] = {
675 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
676 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
681 STAC 9200-32 pin configs for
682 102801B5 (Dell Inspiron 630m)
683 102801D8 (Dell Inspiron 640m)
685 static unsigned int dell9200_m21_pin_configs[8] = {
686 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
687 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
691 STAC 9200-32 pin configs for
692 102801C2 (Dell Latitude D620)
694 102801CC (Dell Latitude D820)
698 static unsigned int dell9200_m22_pin_configs[8] = {
699 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
700 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
704 STAC 9200-32 pin configs for
705 102801CE (Dell XPS M1710)
706 102801CF (Dell Precision M90)
708 static unsigned int dell9200_m23_pin_configs[8] = {
709 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
710 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
714 STAC 9200-32 pin configs for
717 102801CB (Dell Latitude 120L)
720 static unsigned int dell9200_m24_pin_configs[8] = {
721 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
722 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
726 STAC 9200-32 pin configs for
727 102801BD (Dell Inspiron E1505n)
731 static unsigned int dell9200_m25_pin_configs[8] = {
732 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
733 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
737 STAC 9200-32 pin configs for
738 102801F5 (Dell Inspiron 1501)
741 static unsigned int dell9200_m26_pin_configs[8] = {
742 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
743 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
748 102801CD (Dell Inspiron E1705/9400)
750 static unsigned int dell9200_m27_pin_configs[8] = {
751 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
752 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
756 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
757 [STAC_REF] = ref9200_pin_configs,
758 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
759 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
760 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
761 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
762 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
763 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
764 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
765 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
766 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
767 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
770 static const char *stac9200_models[STAC_9200_MODELS] = {
772 [STAC_9200_DELL_D21] = "dell-d21",
773 [STAC_9200_DELL_D22] = "dell-d22",
774 [STAC_9200_DELL_D23] = "dell-d23",
775 [STAC_9200_DELL_M21] = "dell-m21",
776 [STAC_9200_DELL_M22] = "dell-m22",
777 [STAC_9200_DELL_M23] = "dell-m23",
778 [STAC_9200_DELL_M24] = "dell-m24",
779 [STAC_9200_DELL_M25] = "dell-m25",
780 [STAC_9200_DELL_M26] = "dell-m26",
781 [STAC_9200_DELL_M27] = "dell-m27",
782 [STAC_9200_GATEWAY] = "gateway",
785 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
786 /* SigmaTel reference board */
787 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
788 "DFI LanParty", STAC_REF),
789 /* Dell laptops have BIOS problem */
790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
791 "unknown Dell", STAC_9200_DELL_D21),
792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
793 "Dell Inspiron 630m", STAC_9200_DELL_M21),
794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
795 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
797 "unknown Dell", STAC_9200_DELL_D22),
798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
799 "unknown Dell", STAC_9200_DELL_D22),
800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
801 "Dell Latitude D620", STAC_9200_DELL_M22),
802 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
803 "unknown Dell", STAC_9200_DELL_D23),
804 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
805 "unknown Dell", STAC_9200_DELL_D23),
806 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
807 "unknown Dell", STAC_9200_DELL_M22),
808 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
809 "unknown Dell", STAC_9200_DELL_M24),
810 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
811 "unknown Dell", STAC_9200_DELL_M24),
812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
813 "Dell Latitude 120L", STAC_9200_DELL_M24),
814 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
815 "Dell Latitude D820", STAC_9200_DELL_M22),
816 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
817 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
818 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
819 "Dell XPS M1710", STAC_9200_DELL_M23),
820 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
821 "Dell Precision M90", STAC_9200_DELL_M23),
822 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
823 "unknown Dell", STAC_9200_DELL_M22),
824 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
825 "unknown Dell", STAC_9200_DELL_M22),
826 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
827 "unknown Dell", STAC_9200_DELL_M22),
828 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
829 "Dell Inspiron 640m", STAC_9200_DELL_M21),
830 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
831 "unknown Dell", STAC_9200_DELL_D23),
832 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
833 "unknown Dell", STAC_9200_DELL_D23),
834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
835 "unknown Dell", STAC_9200_DELL_D21),
836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
837 "unknown Dell", STAC_9200_DELL_D23),
838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
839 "unknown Dell", STAC_9200_DELL_D21),
840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
841 "unknown Dell", STAC_9200_DELL_M25),
842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
843 "unknown Dell", STAC_9200_DELL_M25),
844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
845 "Dell Inspiron 1501", STAC_9200_DELL_M26),
846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
847 "unknown Dell", STAC_9200_DELL_M26),
849 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
850 /* Gateway machines needs EAPD to be set on resume */
851 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
852 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
854 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
859 static unsigned int ref925x_pin_configs[8] = {
860 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
861 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
864 static unsigned int stac925x_MA6_pin_configs[8] = {
865 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
866 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
869 static unsigned int stac925x_PA6_pin_configs[8] = {
870 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
871 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
874 static unsigned int stac925xM2_2_pin_configs[8] = {
875 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
876 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
879 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
880 [STAC_REF] = ref925x_pin_configs,
881 [STAC_M2_2] = stac925xM2_2_pin_configs,
882 [STAC_MA6] = stac925x_MA6_pin_configs,
883 [STAC_PA6] = stac925x_PA6_pin_configs,
886 static const char *stac925x_models[STAC_925x_MODELS] = {
888 [STAC_M2_2] = "m2-2",
893 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
894 /* SigmaTel reference board */
895 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
896 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
897 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
898 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
899 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
900 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
901 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
905 static unsigned int ref92hd71bxx_pin_configs[10] = {
906 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
907 0x0181302e, 0x01114010, 0x01a19020, 0x90a000f0,
908 0x90a000f0, 0x01452050,
911 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
912 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
915 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
916 [STAC_92HD71BXX_REF] = "ref",
919 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
920 /* SigmaTel reference board */
921 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
922 "DFI LanParty", STAC_92HD71BXX_REF),
926 static unsigned int ref922x_pin_configs[10] = {
927 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
928 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
929 0x40000100, 0x40000100,
933 STAC 922X pin configs for
940 static unsigned int dell_922x_d81_pin_configs[10] = {
941 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
942 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
943 0x01813122, 0x400001f2,
947 STAC 922X pin configs for
951 static unsigned int dell_922x_d82_pin_configs[10] = {
952 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
953 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
954 0x01813122, 0x400001f1,
958 STAC 922X pin configs for
961 static unsigned int dell_922x_m81_pin_configs[10] = {
962 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
963 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
964 0x40C003f1, 0x405003f0,
968 STAC 9221 A1 pin configs for
969 102801D7 (Dell XPS M1210)
971 static unsigned int dell_922x_m82_pin_configs[10] = {
972 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
973 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
974 0x508003f3, 0x405003f4,
977 static unsigned int d945gtp3_pin_configs[10] = {
978 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
979 0x40000100, 0x40000100, 0x40000100, 0x40000100,
980 0x02a19120, 0x40000100,
983 static unsigned int d945gtp5_pin_configs[10] = {
984 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
985 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
986 0x02a19320, 0x40000100,
989 static unsigned int intel_mac_v1_pin_configs[10] = {
990 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
991 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
992 0x400000fc, 0x400000fb,
995 static unsigned int intel_mac_v2_pin_configs[10] = {
996 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
997 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
998 0x400000fc, 0x400000fb,
1001 static unsigned int intel_mac_v3_pin_configs[10] = {
1002 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1003 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1004 0x400000fc, 0x400000fb,
1007 static unsigned int intel_mac_v4_pin_configs[10] = {
1008 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1009 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1010 0x400000fc, 0x400000fb,
1013 static unsigned int intel_mac_v5_pin_configs[10] = {
1014 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1015 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1016 0x400000fc, 0x400000fb,
1020 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1021 [STAC_D945_REF] = ref922x_pin_configs,
1022 [STAC_D945GTP3] = d945gtp3_pin_configs,
1023 [STAC_D945GTP5] = d945gtp5_pin_configs,
1024 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1025 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1026 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1027 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1028 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1029 /* for backward compatibility */
1030 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1031 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1032 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1033 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1034 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1035 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1036 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1037 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1038 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1039 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1042 static const char *stac922x_models[STAC_922X_MODELS] = {
1043 [STAC_D945_REF] = "ref",
1044 [STAC_D945GTP5] = "5stack",
1045 [STAC_D945GTP3] = "3stack",
1046 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1047 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1048 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1049 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1050 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1051 /* for backward compatibility */
1052 [STAC_MACMINI] = "macmini",
1053 [STAC_MACBOOK] = "macbook",
1054 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1055 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1056 [STAC_IMAC_INTEL] = "imac-intel",
1057 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1058 [STAC_922X_DELL_D81] = "dell-d81",
1059 [STAC_922X_DELL_D82] = "dell-d82",
1060 [STAC_922X_DELL_M81] = "dell-m81",
1061 [STAC_922X_DELL_M82] = "dell-m82",
1064 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1065 /* SigmaTel reference board */
1066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1067 "DFI LanParty", STAC_D945_REF),
1068 /* Intel 945G based systems */
1069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1070 "Intel D945G", STAC_D945GTP3),
1071 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1072 "Intel D945G", STAC_D945GTP3),
1073 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1074 "Intel D945G", STAC_D945GTP3),
1075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1076 "Intel D945G", STAC_D945GTP3),
1077 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1078 "Intel D945G", STAC_D945GTP3),
1079 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1080 "Intel D945G", STAC_D945GTP3),
1081 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1082 "Intel D945G", STAC_D945GTP3),
1083 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1084 "Intel D945G", STAC_D945GTP3),
1085 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1086 "Intel D945G", STAC_D945GTP3),
1087 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1088 "Intel D945G", STAC_D945GTP3),
1089 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1090 "Intel D945G", STAC_D945GTP3),
1091 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1092 "Intel D945G", STAC_D945GTP3),
1093 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1094 "Intel D945G", STAC_D945GTP3),
1095 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1096 "Intel D945G", STAC_D945GTP3),
1097 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1098 "Intel D945G", STAC_D945GTP3),
1099 /* Intel D945G 5-stack systems */
1100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1101 "Intel D945G", STAC_D945GTP5),
1102 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1103 "Intel D945G", STAC_D945GTP5),
1104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1105 "Intel D945G", STAC_D945GTP5),
1106 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1107 "Intel D945G", STAC_D945GTP5),
1108 /* Intel 945P based systems */
1109 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1110 "Intel D945P", STAC_D945GTP3),
1111 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1112 "Intel D945P", STAC_D945GTP3),
1113 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1114 "Intel D945P", STAC_D945GTP3),
1115 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1116 "Intel D945P", STAC_D945GTP3),
1117 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1118 "Intel D945P", STAC_D945GTP3),
1119 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1120 "Intel D945P", STAC_D945GTP5),
1122 /* Apple Mac Mini (early 2006) */
1123 SND_PCI_QUIRK(0x8384, 0x7680,
1124 "Mac Mini", STAC_INTEL_MAC_V3),
1126 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1127 "unknown Dell", STAC_922X_DELL_D81),
1128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1129 "unknown Dell", STAC_922X_DELL_D81),
1130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1131 "unknown Dell", STAC_922X_DELL_D81),
1132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1133 "unknown Dell", STAC_922X_DELL_D82),
1134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1135 "unknown Dell", STAC_922X_DELL_M81),
1136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1137 "unknown Dell", STAC_922X_DELL_D82),
1138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1139 "unknown Dell", STAC_922X_DELL_D81),
1140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1141 "unknown Dell", STAC_922X_DELL_D81),
1142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1143 "Dell XPS M1210", STAC_922X_DELL_M82),
1147 static unsigned int ref927x_pin_configs[14] = {
1148 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1149 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1150 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1151 0x01c42190, 0x40000100,
1154 static unsigned int d965_3st_pin_configs[14] = {
1155 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1156 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1157 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1158 0x40000100, 0x40000100
1161 static unsigned int d965_5st_pin_configs[14] = {
1162 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1163 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1164 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1165 0x40000100, 0x40000100
1168 static unsigned int dell_3st_pin_configs[14] = {
1169 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1170 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1171 0x403003fa, 0x40000100, 0x40000100, 0x404003fb,
1172 0x40c003fc, 0x40000100
1175 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1176 [STAC_D965_REF] = ref927x_pin_configs,
1177 [STAC_D965_3ST] = d965_3st_pin_configs,
1178 [STAC_D965_5ST] = d965_5st_pin_configs,
1179 [STAC_DELL_3ST] = dell_3st_pin_configs,
1182 static const char *stac927x_models[STAC_927X_MODELS] = {
1183 [STAC_D965_REF] = "ref",
1184 [STAC_D965_3ST] = "3stack",
1185 [STAC_D965_5ST] = "5stack",
1186 [STAC_DELL_3ST] = "dell-3stack",
1189 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1190 /* SigmaTel reference board */
1191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1192 "DFI LanParty", STAC_D965_REF),
1193 /* Intel 946 based systems */
1194 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1195 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1196 /* 965 based 3 stack systems */
1197 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1198 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1199 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1200 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1201 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1202 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1203 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1204 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1205 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1206 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1207 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1208 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1209 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1210 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1211 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1212 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1213 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_D965_3ST),
1214 /* Dell 3 stack systems */
1215 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1217 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1218 /* 965 based 5 stack systems */
1219 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_D965_5ST),
1220 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1221 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1222 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1223 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1224 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1225 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1226 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1227 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1228 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1232 static unsigned int ref9205_pin_configs[12] = {
1233 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1234 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
1235 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1239 STAC 9205 pin configs for
1247 static unsigned int dell_9205_m42_pin_configs[12] = {
1248 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1249 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1250 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1254 STAC 9205 pin configs for
1258 102801FF (Dell Precision M4300)
1263 static unsigned int dell_9205_m43_pin_configs[12] = {
1264 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1265 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1266 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1269 static unsigned int dell_9205_m44_pin_configs[12] = {
1270 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1271 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1272 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1275 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1276 [STAC_9205_REF] = ref9205_pin_configs,
1277 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1278 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1279 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1282 static const char *stac9205_models[STAC_9205_MODELS] = {
1283 [STAC_9205_REF] = "ref",
1284 [STAC_9205_DELL_M42] = "dell-m42",
1285 [STAC_9205_DELL_M43] = "dell-m43",
1286 [STAC_9205_DELL_M44] = "dell-m44",
1289 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1290 /* SigmaTel reference board */
1291 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1292 "DFI LanParty", STAC_9205_REF),
1293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1294 "unknown Dell", STAC_9205_DELL_M42),
1295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1296 "unknown Dell", STAC_9205_DELL_M42),
1297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1298 "Dell Precision", STAC_9205_DELL_M43),
1299 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1300 "Dell Precision", STAC_9205_DELL_M43),
1301 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1302 "Dell Precision", STAC_9205_DELL_M43),
1303 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1304 "Dell Precision", STAC_9205_DELL_M43),
1305 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1306 "Dell Precision", STAC_9205_DELL_M43),
1307 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1308 "unknown Dell", STAC_9205_DELL_M42),
1309 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1310 "unknown Dell", STAC_9205_DELL_M42),
1311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1312 "Dell Precision", STAC_9205_DELL_M43),
1313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1314 "Dell Precision M4300", STAC_9205_DELL_M43),
1315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1316 "Dell Precision", STAC_9205_DELL_M43),
1317 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1318 "Dell Inspiron", STAC_9205_DELL_M44),
1319 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1320 "Dell Inspiron", STAC_9205_DELL_M44),
1321 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1322 "Dell Inspiron", STAC_9205_DELL_M44),
1323 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1324 "Dell Inspiron", STAC_9205_DELL_M44),
1325 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1326 "unknown Dell", STAC_9205_DELL_M42),
1327 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1328 "Dell Inspiron", STAC_9205_DELL_M44),
1332 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1335 struct sigmatel_spec *spec = codec->spec;
1337 if (! spec->bios_pin_configs) {
1338 spec->bios_pin_configs = kcalloc(spec->num_pins,
1339 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1340 if (! spec->bios_pin_configs)
1344 for (i = 0; i < spec->num_pins; i++) {
1345 hda_nid_t nid = spec->pin_nids[i];
1346 unsigned int pin_cfg;
1348 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1349 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1350 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1352 spec->bios_pin_configs[i] = pin_cfg;
1358 static void stac92xx_set_config_reg(struct hda_codec *codec,
1359 hda_nid_t pin_nid, unsigned int pin_config)
1362 snd_hda_codec_write(codec, pin_nid, 0,
1363 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1364 pin_config & 0x000000ff);
1365 snd_hda_codec_write(codec, pin_nid, 0,
1366 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1367 (pin_config & 0x0000ff00) >> 8);
1368 snd_hda_codec_write(codec, pin_nid, 0,
1369 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1370 (pin_config & 0x00ff0000) >> 16);
1371 snd_hda_codec_write(codec, pin_nid, 0,
1372 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1374 i = snd_hda_codec_read(codec, pin_nid, 0,
1375 AC_VERB_GET_CONFIG_DEFAULT,
1377 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1381 static void stac92xx_set_config_regs(struct hda_codec *codec)
1384 struct sigmatel_spec *spec = codec->spec;
1386 if (!spec->pin_configs)
1389 for (i = 0; i < spec->num_pins; i++)
1390 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1391 spec->pin_configs[i]);
1394 static void stac92xx_enable_gpio_mask(struct hda_codec *codec)
1396 struct sigmatel_spec *spec = codec->spec;
1397 /* Configure GPIOx as output */
1398 snd_hda_codec_write_cache(codec, codec->afg, 0,
1399 AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask);
1400 /* Configure GPIOx as CMOS */
1401 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000);
1403 snd_hda_codec_write_cache(codec, codec->afg, 0,
1404 AC_VERB_SET_GPIO_DATA, spec->gpio_data);
1406 snd_hda_codec_write_cache(codec, codec->afg, 0,
1407 AC_VERB_SET_GPIO_MASK, spec->gpio_mask);
1411 * Analog playback callbacks
1413 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1414 struct hda_codec *codec,
1415 struct snd_pcm_substream *substream)
1417 struct sigmatel_spec *spec = codec->spec;
1418 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
1421 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1422 struct hda_codec *codec,
1423 unsigned int stream_tag,
1424 unsigned int format,
1425 struct snd_pcm_substream *substream)
1427 struct sigmatel_spec *spec = codec->spec;
1428 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1431 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1432 struct hda_codec *codec,
1433 struct snd_pcm_substream *substream)
1435 struct sigmatel_spec *spec = codec->spec;
1436 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1440 * Digital playback callbacks
1442 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1443 struct hda_codec *codec,
1444 struct snd_pcm_substream *substream)
1446 struct sigmatel_spec *spec = codec->spec;
1447 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1450 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1451 struct hda_codec *codec,
1452 struct snd_pcm_substream *substream)
1454 struct sigmatel_spec *spec = codec->spec;
1455 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1458 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1459 struct hda_codec *codec,
1460 unsigned int stream_tag,
1461 unsigned int format,
1462 struct snd_pcm_substream *substream)
1464 struct sigmatel_spec *spec = codec->spec;
1465 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1466 stream_tag, format, substream);
1471 * Analog capture callbacks
1473 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1474 struct hda_codec *codec,
1475 unsigned int stream_tag,
1476 unsigned int format,
1477 struct snd_pcm_substream *substream)
1479 struct sigmatel_spec *spec = codec->spec;
1481 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1482 stream_tag, 0, format);
1486 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1487 struct hda_codec *codec,
1488 struct snd_pcm_substream *substream)
1490 struct sigmatel_spec *spec = codec->spec;
1492 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1496 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1500 /* NID is set in stac92xx_build_pcms */
1502 .open = stac92xx_dig_playback_pcm_open,
1503 .close = stac92xx_dig_playback_pcm_close,
1504 .prepare = stac92xx_dig_playback_pcm_prepare
1508 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1512 /* NID is set in stac92xx_build_pcms */
1515 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1519 .nid = 0x02, /* NID to query formats and rates */
1521 .open = stac92xx_playback_pcm_open,
1522 .prepare = stac92xx_playback_pcm_prepare,
1523 .cleanup = stac92xx_playback_pcm_cleanup
1527 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1531 .nid = 0x06, /* NID to query formats and rates */
1533 .open = stac92xx_playback_pcm_open,
1534 .prepare = stac92xx_playback_pcm_prepare,
1535 .cleanup = stac92xx_playback_pcm_cleanup
1539 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1542 /* NID + .substreams is set in stac92xx_build_pcms */
1544 .prepare = stac92xx_capture_pcm_prepare,
1545 .cleanup = stac92xx_capture_pcm_cleanup
1549 static int stac92xx_build_pcms(struct hda_codec *codec)
1551 struct sigmatel_spec *spec = codec->spec;
1552 struct hda_pcm *info = spec->pcm_rec;
1554 codec->num_pcms = 1;
1555 codec->pcm_info = info;
1557 info->name = "STAC92xx Analog";
1558 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
1559 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
1560 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1561 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
1563 if (spec->alt_switch) {
1566 info->name = "STAC92xx Analog Alt";
1567 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1570 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1573 info->name = "STAC92xx Digital";
1574 if (spec->multiout.dig_out_nid) {
1575 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1576 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1578 if (spec->dig_in_nid) {
1579 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1580 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1587 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1589 unsigned int pincap = snd_hda_param_read(codec, nid,
1591 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1592 if (pincap & AC_PINCAP_VREF_100)
1593 return AC_PINCTL_VREF_100;
1594 if (pincap & AC_PINCAP_VREF_80)
1595 return AC_PINCTL_VREF_80;
1596 if (pincap & AC_PINCAP_VREF_50)
1597 return AC_PINCTL_VREF_50;
1598 if (pincap & AC_PINCAP_VREF_GRD)
1599 return AC_PINCTL_VREF_GRD;
1603 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1606 snd_hda_codec_write_cache(codec, nid, 0,
1607 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1610 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1612 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1614 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1615 struct sigmatel_spec *spec = codec->spec;
1616 int io_idx = kcontrol-> private_value & 0xff;
1618 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1622 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1625 struct sigmatel_spec *spec = codec->spec;
1626 hda_nid_t nid = kcontrol->private_value >> 8;
1627 int io_idx = kcontrol-> private_value & 0xff;
1628 unsigned short val = !!ucontrol->value.integer.value[0];
1630 spec->io_switch[io_idx] = val;
1633 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1635 unsigned int pinctl = AC_PINCTL_IN_EN;
1636 if (io_idx) /* set VREF for mic */
1637 pinctl |= stac92xx_get_vref(codec, nid);
1638 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1641 /* check the auto-mute again: we need to mute/unmute the speaker
1642 * appropriately according to the pin direction
1644 if (spec->hp_detect)
1645 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1650 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
1652 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
1653 struct snd_ctl_elem_value *ucontrol)
1655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1656 struct sigmatel_spec *spec = codec->spec;
1658 ucontrol->value.integer.value[0] = spec->clfe_swap;
1662 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
1663 struct snd_ctl_elem_value *ucontrol)
1665 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1666 struct sigmatel_spec *spec = codec->spec;
1667 hda_nid_t nid = kcontrol->private_value & 0xff;
1668 unsigned int val = !!ucontrol->value.integer.value[0];
1670 if (spec->clfe_swap == val)
1673 spec->clfe_swap = val;
1675 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1676 spec->clfe_swap ? 0x4 : 0x0);
1681 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
1682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1685 .info = stac92xx_io_switch_info, \
1686 .get = stac92xx_io_switch_get, \
1687 .put = stac92xx_io_switch_put, \
1688 .private_value = xpval, \
1691 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
1692 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1695 .info = stac92xx_clfe_switch_info, \
1696 .get = stac92xx_clfe_switch_get, \
1697 .put = stac92xx_clfe_switch_put, \
1698 .private_value = xpval, \
1702 STAC_CTL_WIDGET_VOL,
1703 STAC_CTL_WIDGET_MUTE,
1704 STAC_CTL_WIDGET_IO_SWITCH,
1705 STAC_CTL_WIDGET_CLFE_SWITCH
1708 static struct snd_kcontrol_new stac92xx_control_templates[] = {
1709 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
1710 HDA_CODEC_MUTE(NULL, 0, 0, 0),
1711 STAC_CODEC_IO_SWITCH(NULL, 0),
1712 STAC_CODEC_CLFE_SWITCH(NULL, 0),
1715 /* add dynamic controls */
1716 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
1718 struct snd_kcontrol_new *knew;
1720 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
1721 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
1723 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
1726 if (spec->kctl_alloc) {
1727 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
1728 kfree(spec->kctl_alloc);
1730 spec->kctl_alloc = knew;
1731 spec->num_kctl_alloc = num;
1734 knew = &spec->kctl_alloc[spec->num_kctl_used];
1735 *knew = stac92xx_control_templates[type];
1736 knew->name = kstrdup(name, GFP_KERNEL);
1739 knew->private_value = val;
1740 spec->num_kctl_used++;
1744 /* flag inputs as additional dynamic lineouts */
1745 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
1747 struct sigmatel_spec *spec = codec->spec;
1748 unsigned int wcaps, wtype;
1749 int i, num_dacs = 0;
1751 /* use the wcaps cache to count all DACs available for line-outs */
1752 for (i = 0; i < codec->num_nodes; i++) {
1753 wcaps = codec->wcaps[i];
1754 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1755 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
1759 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
1761 switch (cfg->line_outs) {
1763 /* add line-in as side */
1764 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
1765 cfg->line_out_pins[cfg->line_outs] =
1766 cfg->input_pins[AUTO_PIN_LINE];
1767 spec->line_switch = 1;
1772 /* add line-in as clfe and mic as side */
1773 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
1774 cfg->line_out_pins[cfg->line_outs] =
1775 cfg->input_pins[AUTO_PIN_LINE];
1776 spec->line_switch = 1;
1779 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
1780 cfg->line_out_pins[cfg->line_outs] =
1781 cfg->input_pins[AUTO_PIN_MIC];
1782 spec->mic_switch = 1;
1787 /* add line-in as surr and mic as clfe */
1788 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
1789 cfg->line_out_pins[cfg->line_outs] =
1790 cfg->input_pins[AUTO_PIN_LINE];
1791 spec->line_switch = 1;
1794 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
1795 cfg->line_out_pins[cfg->line_outs] =
1796 cfg->input_pins[AUTO_PIN_MIC];
1797 spec->mic_switch = 1;
1807 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1811 for (i = 0; i < spec->multiout.num_dacs; i++) {
1812 if (spec->multiout.dac_nids[i] == nid)
1820 * Fill in the dac_nids table from the parsed pin configuration
1821 * This function only works when every pin in line_out_pins[]
1822 * contains atleast one DAC in its connection list. Some 92xx
1823 * codecs are not connected directly to a DAC, such as the 9200
1824 * and 9202/925x. For those, dac_nids[] must be hard-coded.
1826 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
1827 struct auto_pin_cfg *cfg)
1829 struct sigmatel_spec *spec = codec->spec;
1830 int i, j, conn_len = 0;
1831 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
1832 unsigned int wcaps, wtype;
1834 for (i = 0; i < cfg->line_outs; i++) {
1835 nid = cfg->line_out_pins[i];
1836 conn_len = snd_hda_get_connections(codec, nid, conn,
1837 HDA_MAX_CONNECTIONS);
1838 for (j = 0; j < conn_len; j++) {
1839 wcaps = snd_hda_param_read(codec, conn[j],
1840 AC_PAR_AUDIO_WIDGET_CAP);
1841 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
1843 if (wtype != AC_WID_AUD_OUT ||
1844 (wcaps & AC_WCAP_DIGITAL))
1846 /* conn[j] is a DAC routed to this line-out */
1847 if (!is_in_dac_nids(spec, conn[j]))
1851 if (j == conn_len) {
1852 if (spec->multiout.num_dacs > 0) {
1853 /* we have already working output pins,
1854 * so let's drop the broken ones again
1856 cfg->line_outs = spec->multiout.num_dacs;
1859 /* error out, no available DAC found */
1861 "%s: No available DAC for pin 0x%x\n",
1866 spec->multiout.dac_nids[i] = conn[j];
1867 spec->multiout.num_dacs++;
1869 /* select this DAC in the pin's input mux */
1870 snd_hda_codec_write_cache(codec, nid, 0,
1871 AC_VERB_SET_CONNECT_SEL, j);
1876 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
1877 spec->multiout.num_dacs,
1878 spec->multiout.dac_nids[0],
1879 spec->multiout.dac_nids[1],
1880 spec->multiout.dac_nids[2],
1881 spec->multiout.dac_nids[3],
1882 spec->multiout.dac_nids[4]);
1886 /* create volume control/switch for the given prefx type */
1887 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
1892 sprintf(name, "%s Playback Volume", pfx);
1893 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
1894 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1897 sprintf(name, "%s Playback Switch", pfx);
1898 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
1899 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
1905 /* add playback controls from the parsed DAC table */
1906 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
1907 const struct auto_pin_cfg *cfg)
1909 static const char *chname[4] = {
1910 "Front", "Surround", NULL /*CLFE*/, "Side"
1915 struct sigmatel_spec *spec = codec->spec;
1916 unsigned int wid_caps;
1919 for (i = 0; i < cfg->line_outs; i++) {
1920 if (!spec->multiout.dac_nids[i])
1923 nid = spec->multiout.dac_nids[i];
1927 err = create_controls(spec, "Center", nid, 1);
1930 err = create_controls(spec, "LFE", nid, 2);
1934 wid_caps = get_wcaps(codec, nid);
1936 if (wid_caps & AC_WCAP_LR_SWAP) {
1937 err = stac92xx_add_control(spec,
1938 STAC_CTL_WIDGET_CLFE_SWITCH,
1939 "Swap Center/LFE Playback Switch", nid);
1946 err = create_controls(spec, chname[i], nid, 3);
1952 if (spec->line_switch)
1953 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
1956 if (spec->mic_switch)
1957 if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
1963 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
1965 if (is_in_dac_nids(spec, nid))
1967 if (spec->multiout.hp_nid == nid)
1972 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
1974 if (!spec->multiout.hp_nid)
1975 spec->multiout.hp_nid = nid;
1976 else if (spec->multiout.num_dacs > 4) {
1977 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
1980 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
1981 spec->multiout.num_dacs++;
1986 /* add playback controls for Speaker and HP outputs */
1987 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
1988 struct auto_pin_cfg *cfg)
1990 struct sigmatel_spec *spec = codec->spec;
1992 int i, old_num_dacs, err;
1994 old_num_dacs = spec->multiout.num_dacs;
1995 for (i = 0; i < cfg->hp_outs; i++) {
1996 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
1997 if (wid_caps & AC_WCAP_UNSOL_CAP)
1998 spec->hp_detect = 1;
1999 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2000 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2001 if (check_in_dac_nids(spec, nid))
2005 add_spec_dacs(spec, nid);
2007 for (i = 0; i < cfg->speaker_outs; i++) {
2008 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2009 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2010 if (check_in_dac_nids(spec, nid))
2014 add_spec_dacs(spec, nid);
2016 for (i = 0; i < cfg->line_outs; i++) {
2017 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2018 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2019 if (check_in_dac_nids(spec, nid))
2023 add_spec_dacs(spec, nid);
2025 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2026 static const char *pfxs[] = {
2027 "Speaker", "External Speaker", "Speaker2",
2029 err = create_controls(spec, pfxs[i - old_num_dacs],
2030 spec->multiout.dac_nids[i], 3);
2034 if (spec->multiout.hp_nid) {
2036 if (old_num_dacs == spec->multiout.num_dacs)
2040 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
2048 /* labels for dmic mux inputs */
2049 static const char *stac92xx_dmic_labels[5] = {
2050 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2051 "Digital Mic 3", "Digital Mic 4"
2054 /* create playback/capture controls for input pins on dmic capable codecs */
2055 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2056 const struct auto_pin_cfg *cfg)
2058 struct sigmatel_spec *spec = codec->spec;
2059 struct hda_input_mux *dimux = &spec->private_dimux;
2060 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2063 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2064 dimux->items[dimux->num_items].index = 0;
2067 for (i = 0; i < spec->num_dmics; i++) {
2070 unsigned int def_conf;
2072 def_conf = snd_hda_codec_read(codec,
2075 AC_VERB_GET_CONFIG_DEFAULT,
2077 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2080 num_cons = snd_hda_get_connections(codec,
2083 HDA_MAX_NUM_INPUTS);
2084 for (j = 0; j < num_cons; j++)
2085 if (con_lst[j] == spec->dmic_nids[i]) {
2091 dimux->items[dimux->num_items].label =
2092 stac92xx_dmic_labels[dimux->num_items];
2093 dimux->items[dimux->num_items].index = index;
2100 /* create playback/capture controls for input pins */
2101 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2103 struct sigmatel_spec *spec = codec->spec;
2104 struct hda_input_mux *imux = &spec->private_imux;
2105 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2108 for (i = 0; i < AUTO_PIN_LAST; i++) {
2111 if (!cfg->input_pins[i])
2114 for (j = 0; j < spec->num_muxes; j++) {
2116 num_cons = snd_hda_get_connections(codec,
2119 HDA_MAX_NUM_INPUTS);
2120 for (k = 0; k < num_cons; k++)
2121 if (con_lst[k] == cfg->input_pins[i]) {
2128 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2129 imux->items[imux->num_items].index = index;
2133 if (imux->num_items) {
2135 * Set the current input for the muxes.
2136 * The STAC9221 has two input muxes with identical source
2137 * NID lists. Hopefully this won't get confused.
2139 for (i = 0; i < spec->num_muxes; i++) {
2140 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2141 AC_VERB_SET_CONNECT_SEL,
2142 imux->items[0].index);
2149 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2151 struct sigmatel_spec *spec = codec->spec;
2154 for (i = 0; i < spec->autocfg.line_outs; i++) {
2155 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2156 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2160 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2162 struct sigmatel_spec *spec = codec->spec;
2165 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2167 pin = spec->autocfg.hp_pins[i];
2168 if (pin) /* connect to front */
2169 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2171 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2173 pin = spec->autocfg.speaker_pins[i];
2174 if (pin) /* connect to front */
2175 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2179 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2181 struct sigmatel_spec *spec = codec->spec;
2183 int hp_speaker_swap = 0;
2185 if ((err = snd_hda_parse_pin_def_config(codec,
2187 spec->dmic_nids)) < 0)
2189 if (! spec->autocfg.line_outs)
2190 return 0; /* can't find valid pin config */
2192 /* If we have no real line-out pin and multiple hp-outs, HPs should
2193 * be set up as multi-channel outputs.
2195 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2196 spec->autocfg.hp_outs > 1) {
2197 /* Copy hp_outs to line_outs, backup line_outs in
2198 * speaker_outs so that the following routines can handle
2199 * HP pins as primary outputs.
2201 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2202 sizeof(spec->autocfg.line_out_pins));
2203 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2204 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2205 sizeof(spec->autocfg.hp_pins));
2206 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2207 hp_speaker_swap = 1;
2210 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2212 if (spec->multiout.num_dacs == 0)
2213 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2216 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2221 if (hp_speaker_swap == 1) {
2222 /* Restore the hp_outs and line_outs */
2223 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2224 sizeof(spec->autocfg.line_out_pins));
2225 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2226 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2227 sizeof(spec->autocfg.speaker_pins));
2228 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2229 memset(spec->autocfg.speaker_pins, 0,
2230 sizeof(spec->autocfg.speaker_pins));
2231 spec->autocfg.speaker_outs = 0;
2234 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2239 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2244 if (spec->num_dmics > 0)
2245 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2246 &spec->autocfg)) < 0)
2249 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2250 if (spec->multiout.max_channels > 2)
2251 spec->surr_switch = 1;
2253 if (spec->autocfg.dig_out_pin)
2254 spec->multiout.dig_out_nid = dig_out;
2255 if (spec->autocfg.dig_in_pin)
2256 spec->dig_in_nid = dig_in;
2258 if (spec->kctl_alloc)
2259 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2261 spec->input_mux = &spec->private_imux;
2262 spec->dinput_mux = &spec->private_dimux;
2267 /* add playback controls for HP output */
2268 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2269 struct auto_pin_cfg *cfg)
2271 struct sigmatel_spec *spec = codec->spec;
2272 hda_nid_t pin = cfg->hp_pins[0];
2273 unsigned int wid_caps;
2278 wid_caps = get_wcaps(codec, pin);
2279 if (wid_caps & AC_WCAP_UNSOL_CAP)
2280 spec->hp_detect = 1;
2285 /* add playback controls for LFE output */
2286 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2287 struct auto_pin_cfg *cfg)
2289 struct sigmatel_spec *spec = codec->spec;
2291 hda_nid_t lfe_pin = 0x0;
2295 * search speaker outs and line outs for a mono speaker pin
2296 * with an amp. If one is found, add LFE controls
2299 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2300 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2301 unsigned long wcaps = get_wcaps(codec, pin);
2302 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2303 if (wcaps == AC_WCAP_OUT_AMP)
2304 /* found a mono speaker with an amp, must be lfe */
2308 /* if speaker_outs is 0, then speakers may be in line_outs */
2309 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2310 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2311 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2313 cfg = snd_hda_codec_read(codec, pin, 0,
2314 AC_VERB_GET_CONFIG_DEFAULT,
2316 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
2317 unsigned long wcaps = get_wcaps(codec, pin);
2318 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2319 if (wcaps == AC_WCAP_OUT_AMP)
2320 /* found a mono speaker with an amp,
2328 err = create_controls(spec, "LFE", lfe_pin, 1);
2336 static int stac9200_parse_auto_config(struct hda_codec *codec)
2338 struct sigmatel_spec *spec = codec->spec;
2341 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2344 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2347 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2350 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2353 if (spec->autocfg.dig_out_pin)
2354 spec->multiout.dig_out_nid = 0x05;
2355 if (spec->autocfg.dig_in_pin)
2356 spec->dig_in_nid = 0x04;
2358 if (spec->kctl_alloc)
2359 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2361 spec->input_mux = &spec->private_imux;
2362 spec->dinput_mux = &spec->private_dimux;
2368 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2369 * funky external mute control using GPIO pins.
2372 static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
2374 unsigned int gpiostate, gpiomask, gpiodir;
2376 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
2377 AC_VERB_GET_GPIO_DATA, 0);
2380 gpiostate |= (1 << pin);
2382 gpiostate &= ~(1 << pin);
2384 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
2385 AC_VERB_GET_GPIO_MASK, 0);
2386 gpiomask |= (1 << pin);
2388 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
2389 AC_VERB_GET_GPIO_DIRECTION, 0);
2390 gpiodir |= (1 << pin);
2392 /* AppleHDA seems to do this -- WTF is this verb?? */
2393 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
2395 snd_hda_codec_write(codec, codec->afg, 0,
2396 AC_VERB_SET_GPIO_MASK, gpiomask);
2397 snd_hda_codec_write(codec, codec->afg, 0,
2398 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
2402 snd_hda_codec_write(codec, codec->afg, 0,
2403 AC_VERB_SET_GPIO_DATA, gpiostate);
2406 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2409 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
2410 snd_hda_codec_write_cache(codec, nid, 0,
2411 AC_VERB_SET_UNSOLICITED_ENABLE,
2412 (AC_USRSP_EN | event));
2415 static int stac92xx_init(struct hda_codec *codec)
2417 struct sigmatel_spec *spec = codec->spec;
2418 struct auto_pin_cfg *cfg = &spec->autocfg;
2421 snd_hda_sequence_write(codec, spec->init);
2424 if (spec->hp_detect) {
2425 /* Enable unsolicited responses on the HP widget */
2426 for (i = 0; i < cfg->hp_outs; i++)
2427 enable_pin_detect(codec, cfg->hp_pins[i],
2429 /* force to enable the first line-out; the others are set up
2432 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
2434 stac92xx_auto_init_hp_out(codec);
2435 /* fake event to set up pins */
2436 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2438 stac92xx_auto_init_multi_out(codec);
2439 stac92xx_auto_init_hp_out(codec);
2441 for (i = 0; i < AUTO_PIN_LAST; i++) {
2442 hda_nid_t nid = cfg->input_pins[i];
2444 unsigned int pinctl = AC_PINCTL_IN_EN;
2445 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
2446 pinctl |= stac92xx_get_vref(codec, nid);
2447 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2450 if (spec->num_dmics > 0)
2451 for (i = 0; i < spec->num_dmics; i++)
2452 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
2455 if (cfg->dig_out_pin)
2456 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
2458 if (cfg->dig_in_pin)
2459 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
2462 if (spec->gpio_mute) {
2463 stac922x_gpio_mute(codec, 0, 0);
2464 stac922x_gpio_mute(codec, 1, 0);
2470 static void stac92xx_free(struct hda_codec *codec)
2472 struct sigmatel_spec *spec = codec->spec;
2478 if (spec->kctl_alloc) {
2479 for (i = 0; i < spec->num_kctl_used; i++)
2480 kfree(spec->kctl_alloc[i].name);
2481 kfree(spec->kctl_alloc);
2484 if (spec->bios_pin_configs)
2485 kfree(spec->bios_pin_configs);
2490 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
2493 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2494 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2496 if (pin_ctl & AC_PINCTL_IN_EN) {
2498 * we need to check the current set-up direction of
2499 * shared input pins since they can be switched via
2500 * "xxx as Output" mixer switch
2502 struct sigmatel_spec *spec = codec->spec;
2503 struct auto_pin_cfg *cfg = &spec->autocfg;
2504 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
2505 spec->line_switch) ||
2506 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
2511 /* if setting pin direction bits, clear the current
2512 direction bits first */
2513 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
2514 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
2516 snd_hda_codec_write_cache(codec, nid, 0,
2517 AC_VERB_SET_PIN_WIDGET_CONTROL,
2521 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
2524 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2525 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2526 snd_hda_codec_write_cache(codec, nid, 0,
2527 AC_VERB_SET_PIN_WIDGET_CONTROL,
2531 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
2535 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
2537 unsigned int pinctl;
2538 pinctl = snd_hda_codec_read(codec, nid, 0,
2539 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2540 if (pinctl & AC_PINCTL_IN_EN)
2541 return 0; /* mic- or line-input */
2543 return 1; /* HP-output */
2548 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
2550 struct sigmatel_spec *spec = codec->spec;
2551 struct auto_pin_cfg *cfg = &spec->autocfg;
2555 for (i = 0; i < cfg->hp_outs; i++) {
2556 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
2562 /* disable lineouts, enable hp */
2563 for (i = 0; i < cfg->line_outs; i++)
2564 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
2566 for (i = 0; i < cfg->speaker_outs; i++)
2567 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
2570 /* enable lineouts, disable hp */
2571 for (i = 0; i < cfg->line_outs; i++)
2572 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
2574 for (i = 0; i < cfg->speaker_outs; i++)
2575 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
2580 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
2582 switch (res >> 26) {
2584 stac92xx_hp_detect(codec, res);
2589 #ifdef SND_HDA_NEEDS_RESUME
2590 static int stac92xx_resume(struct hda_codec *codec)
2592 struct sigmatel_spec *spec = codec->spec;
2594 stac92xx_set_config_regs(codec);
2595 snd_hda_sequence_write(codec, spec->init);
2596 if (spec->gpio_mute) {
2597 stac922x_gpio_mute(codec, 0, 0);
2598 stac922x_gpio_mute(codec, 1, 0);
2600 snd_hda_codec_resume_amp(codec);
2601 snd_hda_codec_resume_cache(codec);
2602 /* invoke unsolicited event to reset the HP state */
2603 if (spec->hp_detect)
2604 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2609 static struct hda_codec_ops stac92xx_patch_ops = {
2610 .build_controls = stac92xx_build_controls,
2611 .build_pcms = stac92xx_build_pcms,
2612 .init = stac92xx_init,
2613 .free = stac92xx_free,
2614 .unsol_event = stac92xx_unsol_event,
2615 #ifdef SND_HDA_NEEDS_RESUME
2616 .resume = stac92xx_resume,
2620 static int patch_stac9200(struct hda_codec *codec)
2622 struct sigmatel_spec *spec;
2625 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2630 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
2631 spec->pin_nids = stac9200_pin_nids;
2632 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
2635 if (spec->board_config < 0) {
2636 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
2637 err = stac92xx_save_bios_config_regs(codec);
2639 stac92xx_free(codec);
2642 spec->pin_configs = spec->bios_pin_configs;
2644 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
2645 stac92xx_set_config_regs(codec);
2648 spec->multiout.max_channels = 2;
2649 spec->multiout.num_dacs = 1;
2650 spec->multiout.dac_nids = stac9200_dac_nids;
2651 spec->adc_nids = stac9200_adc_nids;
2652 spec->mux_nids = stac9200_mux_nids;
2653 spec->num_muxes = 1;
2654 spec->num_dmics = 0;
2657 if (spec->board_config == STAC_9200_GATEWAY)
2658 spec->init = stac9200_eapd_init;
2660 spec->init = stac9200_core_init;
2661 spec->mixer = stac9200_mixer;
2663 err = stac9200_parse_auto_config(codec);
2665 stac92xx_free(codec);
2669 codec->patch_ops = stac92xx_patch_ops;
2674 static int patch_stac925x(struct hda_codec *codec)
2676 struct sigmatel_spec *spec;
2679 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2684 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
2685 spec->pin_nids = stac925x_pin_nids;
2686 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
2690 if (spec->board_config < 0) {
2691 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
2692 "using BIOS defaults\n");
2693 err = stac92xx_save_bios_config_regs(codec);
2695 stac92xx_free(codec);
2698 spec->pin_configs = spec->bios_pin_configs;
2699 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
2700 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
2701 stac92xx_set_config_regs(codec);
2704 spec->multiout.max_channels = 2;
2705 spec->multiout.num_dacs = 1;
2706 spec->multiout.dac_nids = stac925x_dac_nids;
2707 spec->adc_nids = stac925x_adc_nids;
2708 spec->mux_nids = stac925x_mux_nids;
2709 spec->num_muxes = 1;
2711 switch (codec->vendor_id) {
2712 case 0x83847632: /* STAC9202 */
2713 case 0x83847633: /* STAC9202D */
2714 case 0x83847636: /* STAC9251 */
2715 case 0x83847637: /* STAC9251D */
2716 spec->num_dmics = STAC925X_NUM_DMICS;
2717 spec->dmic_nids = stac925x_dmic_nids;
2720 spec->num_dmics = 0;
2724 spec->init = stac925x_core_init;
2725 spec->mixer = stac925x_mixer;
2727 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
2729 if (spec->board_config < 0) {
2730 printk(KERN_WARNING "hda_codec: No auto-config is "
2731 "available, default to model=ref\n");
2732 spec->board_config = STAC_925x_REF;
2738 stac92xx_free(codec);
2742 codec->patch_ops = stac92xx_patch_ops;
2747 static int patch_stac92hd71bxx(struct hda_codec *codec)
2749 struct sigmatel_spec *spec;
2752 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2757 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
2758 spec->pin_nids = stac92hd71bxx_pin_nids;
2759 spec->board_config = snd_hda_check_board_config(codec,
2760 STAC_92HD71BXX_MODELS,
2761 stac92hd71bxx_models,
2762 stac92hd71bxx_cfg_tbl);
2764 if (spec->board_config < 0) {
2765 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
2766 " STAC92HD71BXX, using BIOS defaults\n");
2767 err = stac92xx_save_bios_config_regs(codec);
2769 stac92xx_free(codec);
2772 spec->pin_configs = spec->bios_pin_configs;
2774 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
2775 stac92xx_set_config_regs(codec);
2778 spec->gpio_mask = spec->gpio_data = 0x00000001; /* GPIO0 High = EAPD */
2779 stac92xx_enable_gpio_mask(codec);
2781 spec->init = stac92hd71bxx_core_init;
2782 spec->mixer = stac92hd71bxx_mixer;
2784 spec->mux_nids = stac92hd71bxx_mux_nids;
2785 spec->adc_nids = stac92hd71bxx_adc_nids;
2786 spec->dmic_nids = stac92hd71bxx_dmic_nids;
2787 spec->dmux_nid = 0x1c;
2789 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
2790 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
2791 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
2793 spec->multiout.num_dacs = 2;
2794 spec->multiout.hp_nid = 0x11;
2795 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
2797 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
2799 if (spec->board_config < 0) {
2800 printk(KERN_WARNING "hda_codec: No auto-config is "
2801 "available, default to model=ref\n");
2802 spec->board_config = STAC_92HD71BXX_REF;
2809 stac92xx_free(codec);
2813 codec->patch_ops = stac92xx_patch_ops;
2818 static int patch_stac922x(struct hda_codec *codec)
2820 struct sigmatel_spec *spec;
2823 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2828 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
2829 spec->pin_nids = stac922x_pin_nids;
2830 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
2833 if (spec->board_config == STAC_INTEL_MAC_V3) {
2834 spec->gpio_mute = 1;
2835 /* Intel Macs have all same PCI SSID, so we need to check
2836 * codec SSID to distinguish the exact models
2838 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
2839 switch (codec->subsystem_id) {
2842 spec->board_config = STAC_INTEL_MAC_V1;
2846 spec->board_config = STAC_INTEL_MAC_V2;
2854 spec->board_config = STAC_INTEL_MAC_V3;
2858 spec->board_config = STAC_INTEL_MAC_V4;
2862 spec->board_config = STAC_INTEL_MAC_V5;
2868 if (spec->board_config < 0) {
2869 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
2870 "using BIOS defaults\n");
2871 err = stac92xx_save_bios_config_regs(codec);
2873 stac92xx_free(codec);
2876 spec->pin_configs = spec->bios_pin_configs;
2877 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
2878 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
2879 stac92xx_set_config_regs(codec);
2882 spec->adc_nids = stac922x_adc_nids;
2883 spec->mux_nids = stac922x_mux_nids;
2884 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
2885 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
2886 spec->num_dmics = 0;
2888 spec->init = stac922x_core_init;
2889 spec->mixer = stac922x_mixer;
2891 spec->multiout.dac_nids = spec->dac_nids;
2893 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
2895 if (spec->board_config < 0) {
2896 printk(KERN_WARNING "hda_codec: No auto-config is "
2897 "available, default to model=ref\n");
2898 spec->board_config = STAC_D945_REF;
2904 stac92xx_free(codec);
2908 codec->patch_ops = stac92xx_patch_ops;
2910 /* Fix Mux capture level; max to 2 */
2911 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
2912 (0 << AC_AMPCAP_OFFSET_SHIFT) |
2913 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
2914 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
2915 (0 << AC_AMPCAP_MUTE_SHIFT));
2920 static int patch_stac927x(struct hda_codec *codec)
2922 struct sigmatel_spec *spec;
2925 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2930 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
2931 spec->pin_nids = stac927x_pin_nids;
2932 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
2936 if (spec->board_config < 0) {
2937 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
2938 err = stac92xx_save_bios_config_regs(codec);
2940 stac92xx_free(codec);
2943 spec->pin_configs = spec->bios_pin_configs;
2944 } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
2945 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
2946 stac92xx_set_config_regs(codec);
2949 switch (spec->board_config) {
2951 spec->adc_nids = stac927x_adc_nids;
2952 spec->mux_nids = stac927x_mux_nids;
2953 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2954 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2955 spec->init = d965_core_init;
2956 spec->mixer = stac927x_mixer;
2959 spec->adc_nids = stac927x_adc_nids;
2960 spec->mux_nids = stac927x_mux_nids;
2961 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2962 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2963 spec->init = d965_core_init;
2964 spec->mixer = stac927x_mixer;
2967 spec->adc_nids = stac927x_adc_nids;
2968 spec->mux_nids = stac927x_mux_nids;
2969 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
2970 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
2971 spec->init = stac927x_core_init;
2972 spec->mixer = stac927x_mixer;
2975 switch (codec->subsystem_id) {
2976 case 0x10280242: /* STAC 9228 */
2980 spec->dmic_nids = stac927x_dmic_nids;
2981 spec->num_dmics = STAC927X_NUM_DMICS;
2982 spec->dmux_nid = 0x1b;
2985 stac92xx_set_config_reg(codec, 0x13, 0x90a60040);
2987 /* GPIO2 High = Enable EAPD */
2988 spec->gpio_mask = spec->gpio_data = 0x00000004;
2991 spec->num_dmics = 0;
2993 /* GPIO0 High = Enable EAPD */
2994 spec->gpio_mask = spec->gpio_data = 0x00000001;
2997 spec->multiout.dac_nids = spec->dac_nids;
2998 stac92xx_enable_gpio_mask(codec);
3000 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3002 if (spec->board_config < 0) {
3003 printk(KERN_WARNING "hda_codec: No auto-config is "
3004 "available, default to model=ref\n");
3005 spec->board_config = STAC_D965_REF;
3011 stac92xx_free(codec);
3015 codec->patch_ops = stac92xx_patch_ops;
3020 static int patch_stac9205(struct hda_codec *codec)
3022 struct sigmatel_spec *spec;
3025 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3030 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
3031 spec->pin_nids = stac9205_pin_nids;
3032 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
3036 if (spec->board_config < 0) {
3037 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
3038 err = stac92xx_save_bios_config_regs(codec);
3040 stac92xx_free(codec);
3043 spec->pin_configs = spec->bios_pin_configs;
3045 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
3046 stac92xx_set_config_regs(codec);
3049 spec->adc_nids = stac9205_adc_nids;
3050 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
3051 spec->mux_nids = stac9205_mux_nids;
3052 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
3053 spec->dmic_nids = stac9205_dmic_nids;
3054 spec->num_dmics = STAC9205_NUM_DMICS;
3055 spec->dmux_nid = 0x1d;
3057 spec->init = stac9205_core_init;
3058 spec->mixer = stac9205_mixer;
3060 spec->multiout.dac_nids = spec->dac_nids;
3062 switch (spec->board_config){
3063 case STAC_9205_DELL_M43:
3064 /* Enable SPDIF in/out */
3065 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3066 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
3068 spec->gpio_mask = 0x00000007; /* GPIO0-2 */
3069 /* GPIO0 High = EAPD, GPIO1 Low = DRM,
3070 * GPIO2 High = Headphone Mute
3072 spec->gpio_data = 0x00000005;
3075 /* GPIO0 High = EAPD */
3076 spec->gpio_mask = spec->gpio_data = 0x00000001;
3080 stac92xx_enable_gpio_mask(codec);
3081 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
3083 if (spec->board_config < 0) {
3084 printk(KERN_WARNING "hda_codec: No auto-config is "
3085 "available, default to model=ref\n");
3086 spec->board_config = STAC_9205_REF;
3092 stac92xx_free(codec);
3096 codec->patch_ops = stac92xx_patch_ops;
3105 /* static config for Sony VAIO FE550G and Sony VAIO AR */
3106 static hda_nid_t vaio_dacs[] = { 0x2 };
3107 #define VAIO_HP_DAC 0x5
3108 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
3109 static hda_nid_t vaio_mux_nids[] = { 0x15 };
3111 static struct hda_input_mux vaio_mux = {
3114 /* { "HP", 0x0 }, */
3115 { "Mic Jack", 0x1 },
3116 { "Internal Mic", 0x2 },
3121 static struct hda_verb vaio_init[] = {
3122 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3123 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
3124 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3125 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3126 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3127 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3128 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3129 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3130 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3131 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3137 static struct hda_verb vaio_ar_init[] = {
3138 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3139 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3140 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3141 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3142 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
3143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3144 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3145 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3146 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3147 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
3148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3149 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3150 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3154 /* bind volumes of both NID 0x02 and 0x05 */
3155 static struct hda_bind_ctls vaio_bind_master_vol = {
3156 .ops = &snd_hda_bind_vol,
3158 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
3159 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
3164 /* bind volumes of both NID 0x02 and 0x05 */
3165 static struct hda_bind_ctls vaio_bind_master_sw = {
3166 .ops = &snd_hda_bind_sw,
3168 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
3169 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
3174 static struct snd_kcontrol_new vaio_mixer[] = {
3175 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
3176 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
3177 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
3178 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
3179 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
3181 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3182 .name = "Capture Source",
3184 .info = stac92xx_mux_enum_info,
3185 .get = stac92xx_mux_enum_get,
3186 .put = stac92xx_mux_enum_put,
3191 static struct snd_kcontrol_new vaio_ar_mixer[] = {
3192 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
3193 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
3194 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
3195 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
3196 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
3197 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
3198 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
3200 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3201 .name = "Capture Source",
3203 .info = stac92xx_mux_enum_info,
3204 .get = stac92xx_mux_enum_get,
3205 .put = stac92xx_mux_enum_put,
3210 static struct hda_codec_ops stac9872_patch_ops = {
3211 .build_controls = stac92xx_build_controls,
3212 .build_pcms = stac92xx_build_pcms,
3213 .init = stac92xx_init,
3214 .free = stac92xx_free,
3215 #ifdef SND_HDA_NEEDS_RESUME
3216 .resume = stac92xx_resume,
3220 static int stac9872_vaio_init(struct hda_codec *codec)
3224 err = stac92xx_init(codec);
3227 if (codec->patch_ops.unsol_event)
3228 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3232 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
3234 if (get_hp_pin_presence(codec, 0x0a)) {
3235 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
3236 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
3238 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
3239 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
3243 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
3245 switch (res >> 26) {
3247 stac9872_vaio_hp_detect(codec, res);
3252 static struct hda_codec_ops stac9872_vaio_patch_ops = {
3253 .build_controls = stac92xx_build_controls,
3254 .build_pcms = stac92xx_build_pcms,
3255 .init = stac9872_vaio_init,
3256 .free = stac92xx_free,
3257 .unsol_event = stac9872_vaio_unsol_event,
3259 .resume = stac92xx_resume,
3263 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
3265 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
3267 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
3269 /* AR Series. id=0x83847664 and subsys=104D1300 */
3274 static const char *stac9872_models[STAC_9872_MODELS] = {
3275 [CXD9872RD_VAIO] = "vaio",
3276 [CXD9872AKD_VAIO] = "vaio-ar",
3279 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
3280 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
3281 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
3282 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
3283 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
3287 static int patch_stac9872(struct hda_codec *codec)
3289 struct sigmatel_spec *spec;
3292 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
3295 if (board_config < 0)
3296 /* unknown config, let generic-parser do its job... */
3297 return snd_hda_parse_generic_codec(codec);
3299 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3304 switch (board_config) {
3305 case CXD9872RD_VAIO:
3306 case STAC9872AK_VAIO:
3307 case STAC9872K_VAIO:
3308 spec->mixer = vaio_mixer;
3309 spec->init = vaio_init;
3310 spec->multiout.max_channels = 2;
3311 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
3312 spec->multiout.dac_nids = vaio_dacs;
3313 spec->multiout.hp_nid = VAIO_HP_DAC;
3314 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3315 spec->adc_nids = vaio_adcs;
3316 spec->input_mux = &vaio_mux;
3317 spec->mux_nids = vaio_mux_nids;
3318 codec->patch_ops = stac9872_vaio_patch_ops;
3321 case CXD9872AKD_VAIO:
3322 spec->mixer = vaio_ar_mixer;
3323 spec->init = vaio_ar_init;
3324 spec->multiout.max_channels = 2;
3325 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
3326 spec->multiout.dac_nids = vaio_dacs;
3327 spec->multiout.hp_nid = VAIO_HP_DAC;
3328 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
3329 spec->adc_nids = vaio_adcs;
3330 spec->input_mux = &vaio_mux;
3331 spec->mux_nids = vaio_mux_nids;
3332 codec->patch_ops = stac9872_patch_ops;
3343 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
3344 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
3345 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
3346 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
3347 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
3348 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
3349 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
3350 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
3351 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
3352 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
3353 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
3354 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
3355 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
3356 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
3357 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
3358 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
3359 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
3360 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
3361 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
3362 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
3363 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
3364 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
3365 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
3366 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
3367 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
3368 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
3369 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
3370 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
3371 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
3372 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
3373 /* The following does not take into account .id=0x83847661 when subsys =
3374 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
3375 * currently not fully supported.
3377 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
3378 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
3379 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
3380 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
3381 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
3382 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
3383 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
3384 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
3385 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
3386 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
3387 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
3388 { .id = 0x111d76b0, .name = "92HD71BXX", .patch = patch_stac92hd71bxx },