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 <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include "hda_codec.h"
34 #include "hda_local.h"
36 #define NUM_CONTROL_ALLOC 32
37 #define STAC_PWR_EVENT 0x20
38 #define STAC_HP_EVENT 0x30
92 /* for backward compatibility */
115 struct sigmatel_spec {
116 struct snd_kcontrol_new *mixers[4];
117 unsigned int num_mixers;
120 unsigned int surr_switch: 1;
121 unsigned int line_switch: 1;
122 unsigned int mic_switch: 1;
123 unsigned int alt_switch: 1;
124 unsigned int hp_detect: 1;
127 unsigned int gpio_mask;
128 unsigned int gpio_dir;
129 unsigned int gpio_data;
130 unsigned int gpio_mute;
132 /* analog loopback */
133 unsigned char aloopback_mask;
134 unsigned char aloopback_shift;
136 /* power management */
137 unsigned int num_pwrs;
142 struct hda_input_mux *mono_mux;
143 unsigned int cur_mmux;
144 struct hda_multi_out multiout;
145 hda_nid_t dac_nids[5];
149 unsigned int num_adcs;
151 unsigned int num_muxes;
152 hda_nid_t *dmic_nids;
153 unsigned int num_dmics;
154 hda_nid_t *dmux_nids;
155 unsigned int num_dmuxes;
156 hda_nid_t dig_in_nid;
161 unsigned int num_pins;
162 unsigned int *pin_configs;
163 unsigned int *bios_pin_configs;
165 /* codec specific stuff */
166 struct hda_verb *init;
167 struct snd_kcontrol_new *mixer;
170 struct hda_input_mux *dinput_mux;
171 unsigned int cur_dmux[2];
172 struct hda_input_mux *input_mux;
173 unsigned int cur_mux[3];
176 unsigned int io_switch[2];
177 unsigned int clfe_swap;
178 unsigned int aloopback;
180 struct hda_pcm pcm_rec[2]; /* PCM information */
182 /* dynamic controls and input_mux */
183 struct auto_pin_cfg autocfg;
184 unsigned int num_kctl_alloc, num_kctl_used;
185 struct snd_kcontrol_new *kctl_alloc;
186 struct hda_input_mux private_dimux;
187 struct hda_input_mux private_imux;
188 struct hda_input_mux private_mono_mux;
191 static hda_nid_t stac9200_adc_nids[1] = {
195 static hda_nid_t stac9200_mux_nids[1] = {
199 static hda_nid_t stac9200_dac_nids[1] = {
203 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
204 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
208 static hda_nid_t stac92hd73xx_adc_nids[2] = {
212 #define STAC92HD73XX_NUM_DMICS 2
213 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
217 #define STAC92HD73_DAC_COUNT 5
218 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
219 0x15, 0x16, 0x17, 0x18, 0x19,
222 static hda_nid_t stac92hd73xx_mux_nids[4] = {
223 0x28, 0x29, 0x2a, 0x2b,
226 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
230 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
234 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
238 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
242 static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
246 static hda_nid_t stac92hd71bxx_dac_nids[2] = {
250 #define STAC92HD71BXX_NUM_DMICS 2
251 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
255 static hda_nid_t stac925x_adc_nids[1] = {
259 static hda_nid_t stac925x_mux_nids[1] = {
263 static hda_nid_t stac925x_dac_nids[1] = {
267 #define STAC925X_NUM_DMICS 1
268 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
272 static hda_nid_t stac925x_dmux_nids[1] = {
276 static hda_nid_t stac922x_adc_nids[2] = {
280 static hda_nid_t stac922x_mux_nids[2] = {
284 static hda_nid_t stac927x_adc_nids[3] = {
288 static hda_nid_t stac927x_mux_nids[3] = {
292 static hda_nid_t stac927x_dac_nids[6] = {
293 0x02, 0x03, 0x04, 0x05, 0x06, 0
296 static hda_nid_t stac927x_dmux_nids[1] = {
300 #define STAC927X_NUM_DMICS 2
301 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
305 static hda_nid_t stac9205_adc_nids[2] = {
309 static hda_nid_t stac9205_mux_nids[2] = {
313 static hda_nid_t stac9205_dmux_nids[1] = {
317 #define STAC9205_NUM_DMICS 2
318 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
322 static hda_nid_t stac9200_pin_nids[8] = {
323 0x08, 0x09, 0x0d, 0x0e,
324 0x0f, 0x10, 0x11, 0x12,
327 static hda_nid_t stac925x_pin_nids[8] = {
328 0x07, 0x08, 0x0a, 0x0b,
329 0x0c, 0x0d, 0x10, 0x11,
332 static hda_nid_t stac922x_pin_nids[10] = {
333 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
334 0x0f, 0x10, 0x11, 0x15, 0x1b,
337 static hda_nid_t stac92hd73xx_pin_nids[12] = {
338 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
339 0x0f, 0x10, 0x11, 0x12, 0x13,
343 static hda_nid_t stac92hd71bxx_pin_nids[10] = {
344 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
345 0x0f, 0x14, 0x18, 0x19, 0x1e,
348 static hda_nid_t stac927x_pin_nids[14] = {
349 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
350 0x0f, 0x10, 0x11, 0x12, 0x13,
351 0x14, 0x21, 0x22, 0x23,
354 static hda_nid_t stac9205_pin_nids[12] = {
355 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
356 0x0f, 0x14, 0x16, 0x17, 0x18,
360 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
361 struct snd_ctl_elem_info *uinfo)
363 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
364 struct sigmatel_spec *spec = codec->spec;
365 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
368 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
369 struct snd_ctl_elem_value *ucontrol)
371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
372 struct sigmatel_spec *spec = codec->spec;
373 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
375 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
379 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
380 struct snd_ctl_elem_value *ucontrol)
382 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
383 struct sigmatel_spec *spec = codec->spec;
384 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
386 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
387 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
390 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
392 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
393 struct sigmatel_spec *spec = codec->spec;
394 return snd_hda_input_mux_info(spec->input_mux, uinfo);
397 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
400 struct sigmatel_spec *spec = codec->spec;
401 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
403 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
407 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
410 struct sigmatel_spec *spec = codec->spec;
411 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
413 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
414 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
417 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
418 struct snd_ctl_elem_info *uinfo)
420 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
421 struct sigmatel_spec *spec = codec->spec;
422 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
425 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_value *ucontrol)
428 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
429 struct sigmatel_spec *spec = codec->spec;
431 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
435 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
436 struct snd_ctl_elem_value *ucontrol)
438 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
439 struct sigmatel_spec *spec = codec->spec;
441 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
442 spec->mono_nid, &spec->cur_mmux);
445 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
447 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_value *ucontrol)
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
452 struct sigmatel_spec *spec = codec->spec;
454 ucontrol->value.integer.value[0] = !!(spec->aloopback &
455 (spec->aloopback_mask << idx));
459 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct sigmatel_spec *spec = codec->spec;
464 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
465 unsigned int dac_mode;
466 unsigned int val, idx_val;
468 idx_val = spec->aloopback_mask << idx;
469 if (ucontrol->value.integer.value[0])
470 val = spec->aloopback | idx_val;
472 val = spec->aloopback & ~idx_val;
473 if (spec->aloopback == val)
476 spec->aloopback = val;
478 /* Only return the bits defined by the shift value of the
479 * first two bytes of the mask
481 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
482 kcontrol->private_value & 0xFFFF, 0x0);
483 dac_mode >>= spec->aloopback_shift;
485 if (spec->aloopback & idx_val) {
486 snd_hda_power_up(codec);
489 snd_hda_power_down(codec);
490 dac_mode &= ~idx_val;
493 snd_hda_codec_write_cache(codec, codec->afg, 0,
494 kcontrol->private_value >> 16, dac_mode);
499 static struct hda_verb stac9200_core_init[] = {
500 /* set dac0mux for dac converter */
501 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
505 static struct hda_verb stac9200_eapd_init[] = {
506 /* set dac0mux for dac converter */
507 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
508 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
512 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
513 /* set master volume and direct control */
514 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
515 /* setup audio connections */
516 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
517 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
518 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
519 /* setup adcs to point to mixer */
520 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
521 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
522 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
523 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
524 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
525 /* setup import muxs */
526 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
527 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
528 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
529 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
533 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
534 /* set master volume and direct control */
535 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
536 /* setup audio connections */
537 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
538 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
539 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
540 /* connect hp ports to dac3 */
541 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
542 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
543 /* setup adcs to point to mixer */
544 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
545 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
546 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
547 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
548 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
549 /* setup import muxs */
550 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
551 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
552 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
553 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
557 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
558 /* set master volume and direct control */
559 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
560 /* setup audio connections */
561 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
562 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
563 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
564 /* dac3 is connected to import3 mux */
565 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
566 /* connect hp ports to dac4 */
567 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
568 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
569 /* setup adcs to point to mixer */
570 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
571 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
572 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
573 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
574 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
575 /* setup import muxs */
576 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
577 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
578 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
579 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
583 static struct hda_verb stac92hd71bxx_core_init[] = {
584 /* set master volume and direct control */
585 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
586 /* connect headphone jack to dac1 */
587 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
588 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
589 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
590 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
591 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
592 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
595 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
596 /* set master volume and direct control */
597 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
598 /* connect headphone jack to dac1 */
599 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
600 /* connect ports 0d and 0f to audio mixer */
601 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
602 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
603 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
604 /* unmute dac0 input in audio mixer */
605 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
606 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
607 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
608 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
609 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
613 static struct hda_verb stac925x_core_init[] = {
614 /* set dac0mux for dac converter */
615 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
619 static struct hda_verb stac922x_core_init[] = {
620 /* set master volume and direct control */
621 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
625 static struct hda_verb d965_core_init[] = {
626 /* set master volume and direct control */
627 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
628 /* unmute node 0x1b */
629 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
630 /* select node 0x03 as DAC */
631 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
635 static struct hda_verb stac927x_core_init[] = {
636 /* set master volume and direct control */
637 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
641 static struct hda_verb stac9205_core_init[] = {
642 /* set master volume and direct control */
643 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
647 #define STAC_MONO_MUX \
649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
650 .name = "Mono Mux", \
652 .info = stac92xx_mono_mux_enum_info, \
653 .get = stac92xx_mono_mux_enum_get, \
654 .put = stac92xx_mono_mux_enum_put, \
657 #define STAC_INPUT_SOURCE(cnt) \
659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
660 .name = "Input Source", \
662 .info = stac92xx_mux_enum_info, \
663 .get = stac92xx_mux_enum_get, \
664 .put = stac92xx_mux_enum_put, \
667 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
669 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
670 .name = "Analog Loopback", \
672 .info = stac92xx_aloopback_info, \
673 .get = stac92xx_aloopback_get, \
674 .put = stac92xx_aloopback_put, \
675 .private_value = verb_read | (verb_write << 16), \
678 static struct snd_kcontrol_new stac9200_mixer[] = {
679 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
680 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
681 STAC_INPUT_SOURCE(1),
682 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
683 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
684 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
688 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
689 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
691 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
692 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
694 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
695 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
697 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
698 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
700 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
701 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
703 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
704 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
706 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
707 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
709 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
710 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
714 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
715 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
717 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
718 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
720 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
721 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
723 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
724 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
726 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
727 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
729 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
730 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
732 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
733 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
735 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
736 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
740 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
741 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
743 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
744 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
746 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
747 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
749 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
750 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
752 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
753 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
755 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
756 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
758 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
759 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
761 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
762 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
766 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
767 STAC_INPUT_SOURCE(2),
769 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
770 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
771 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
773 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
774 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
775 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
777 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
778 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
782 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
783 STAC_INPUT_SOURCE(2),
784 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
786 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
787 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
788 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
790 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
791 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
792 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
796 static struct snd_kcontrol_new stac925x_mixer[] = {
797 STAC_INPUT_SOURCE(1),
798 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
799 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
800 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
804 static struct snd_kcontrol_new stac9205_mixer[] = {
805 STAC_INPUT_SOURCE(2),
806 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
808 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
809 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
810 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
812 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
813 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
814 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
819 /* This needs to be generated dynamically based on sequence */
820 static struct snd_kcontrol_new stac922x_mixer[] = {
821 STAC_INPUT_SOURCE(2),
822 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
823 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
824 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
826 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
827 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
828 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
833 static struct snd_kcontrol_new stac927x_mixer[] = {
834 STAC_INPUT_SOURCE(3),
835 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
837 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
838 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
839 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
841 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
842 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
843 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
845 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
846 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
847 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
851 static struct snd_kcontrol_new stac_dmux_mixer = {
852 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
853 .name = "Digital Input Source",
854 /* count set later */
855 .info = stac92xx_dmux_enum_info,
856 .get = stac92xx_dmux_enum_get,
857 .put = stac92xx_dmux_enum_put,
860 static const char *slave_vols[] = {
861 "Front Playback Volume",
862 "Surround Playback Volume",
863 "Center Playback Volume",
864 "LFE Playback Volume",
865 "Side Playback Volume",
866 "Headphone Playback Volume",
867 "Headphone Playback Volume",
868 "Speaker Playback Volume",
869 "External Speaker Playback Volume",
870 "Speaker2 Playback Volume",
874 static const char *slave_sws[] = {
875 "Front Playback Switch",
876 "Surround Playback Switch",
877 "Center Playback Switch",
878 "LFE Playback Switch",
879 "Side Playback Switch",
880 "Headphone Playback Switch",
881 "Headphone Playback Switch",
882 "Speaker Playback Switch",
883 "External Speaker Playback Switch",
884 "Speaker2 Playback Switch",
885 "IEC958 Playback Switch",
889 static int stac92xx_build_controls(struct hda_codec *codec)
891 struct sigmatel_spec *spec = codec->spec;
895 err = snd_hda_add_new_ctls(codec, spec->mixer);
899 for (i = 0; i < spec->num_mixers; i++) {
900 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
904 if (spec->num_dmuxes > 0) {
905 stac_dmux_mixer.count = spec->num_dmuxes;
906 err = snd_ctl_add(codec->bus->card,
907 snd_ctl_new1(&stac_dmux_mixer, codec));
912 if (spec->multiout.dig_out_nid) {
913 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
916 err = snd_hda_create_spdif_share_sw(codec,
920 spec->multiout.share_spdif = 1;
922 if (spec->dig_in_nid) {
923 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
928 /* if we have no master control, let's create it */
929 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
930 unsigned int vmaster_tlv[4];
931 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
932 HDA_OUTPUT, vmaster_tlv);
933 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
934 vmaster_tlv, slave_vols);
938 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
939 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
948 static unsigned int ref9200_pin_configs[8] = {
949 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
950 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
954 STAC 9200 pin configs for
959 static unsigned int dell9200_d21_pin_configs[8] = {
960 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
961 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
965 STAC 9200 pin configs for
969 static unsigned int dell9200_d22_pin_configs[8] = {
970 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
971 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
975 STAC 9200 pin configs for
976 102801C4 (Dell Dimension E310)
983 static unsigned int dell9200_d23_pin_configs[8] = {
984 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
985 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
990 STAC 9200-32 pin configs for
991 102801B5 (Dell Inspiron 630m)
992 102801D8 (Dell Inspiron 640m)
994 static unsigned int dell9200_m21_pin_configs[8] = {
995 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
996 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1000 STAC 9200-32 pin configs for
1001 102801C2 (Dell Latitude D620)
1003 102801CC (Dell Latitude D820)
1007 static unsigned int dell9200_m22_pin_configs[8] = {
1008 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1009 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1013 STAC 9200-32 pin configs for
1014 102801CE (Dell XPS M1710)
1015 102801CF (Dell Precision M90)
1017 static unsigned int dell9200_m23_pin_configs[8] = {
1018 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1019 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1023 STAC 9200-32 pin configs for
1026 102801CB (Dell Latitude 120L)
1029 static unsigned int dell9200_m24_pin_configs[8] = {
1030 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1031 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1035 STAC 9200-32 pin configs for
1036 102801BD (Dell Inspiron E1505n)
1040 static unsigned int dell9200_m25_pin_configs[8] = {
1041 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1042 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1046 STAC 9200-32 pin configs for
1047 102801F5 (Dell Inspiron 1501)
1050 static unsigned int dell9200_m26_pin_configs[8] = {
1051 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1052 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1057 102801CD (Dell Inspiron E1705/9400)
1059 static unsigned int dell9200_m27_pin_configs[8] = {
1060 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1061 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1064 static unsigned int oqo9200_pin_configs[8] = {
1065 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1066 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1070 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1071 [STAC_REF] = ref9200_pin_configs,
1072 [STAC_9200_OQO] = oqo9200_pin_configs,
1073 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1074 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1075 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1076 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1077 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1078 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1079 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1080 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1081 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1082 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1085 static const char *stac9200_models[STAC_9200_MODELS] = {
1087 [STAC_9200_OQO] = "oqo",
1088 [STAC_9200_DELL_D21] = "dell-d21",
1089 [STAC_9200_DELL_D22] = "dell-d22",
1090 [STAC_9200_DELL_D23] = "dell-d23",
1091 [STAC_9200_DELL_M21] = "dell-m21",
1092 [STAC_9200_DELL_M22] = "dell-m22",
1093 [STAC_9200_DELL_M23] = "dell-m23",
1094 [STAC_9200_DELL_M24] = "dell-m24",
1095 [STAC_9200_DELL_M25] = "dell-m25",
1096 [STAC_9200_DELL_M26] = "dell-m26",
1097 [STAC_9200_DELL_M27] = "dell-m27",
1098 [STAC_9200_GATEWAY] = "gateway",
1101 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1102 /* SigmaTel reference board */
1103 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1104 "DFI LanParty", STAC_REF),
1105 /* Dell laptops have BIOS problem */
1106 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1107 "unknown Dell", STAC_9200_DELL_D21),
1108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1109 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1111 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1113 "unknown Dell", STAC_9200_DELL_D22),
1114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1115 "unknown Dell", STAC_9200_DELL_D22),
1116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1117 "Dell Latitude D620", STAC_9200_DELL_M22),
1118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1119 "unknown Dell", STAC_9200_DELL_D23),
1120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1121 "unknown Dell", STAC_9200_DELL_D23),
1122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1123 "unknown Dell", STAC_9200_DELL_M22),
1124 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1125 "unknown Dell", STAC_9200_DELL_M24),
1126 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1127 "unknown Dell", STAC_9200_DELL_M24),
1128 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1129 "Dell Latitude 120L", STAC_9200_DELL_M24),
1130 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1131 "Dell Latitude D820", STAC_9200_DELL_M22),
1132 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1133 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1134 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1135 "Dell XPS M1710", STAC_9200_DELL_M23),
1136 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1137 "Dell Precision M90", STAC_9200_DELL_M23),
1138 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1139 "unknown Dell", STAC_9200_DELL_M22),
1140 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1141 "unknown Dell", STAC_9200_DELL_M22),
1142 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1143 "unknown Dell", STAC_9200_DELL_M22),
1144 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1145 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1146 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1147 "unknown Dell", STAC_9200_DELL_D23),
1148 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1149 "unknown Dell", STAC_9200_DELL_D23),
1150 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1151 "unknown Dell", STAC_9200_DELL_D21),
1152 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1153 "unknown Dell", STAC_9200_DELL_D23),
1154 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1155 "unknown Dell", STAC_9200_DELL_D21),
1156 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1157 "unknown Dell", STAC_9200_DELL_M25),
1158 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1159 "unknown Dell", STAC_9200_DELL_M25),
1160 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1161 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1162 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1163 "unknown Dell", STAC_9200_DELL_M26),
1165 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
1166 /* Gateway machines needs EAPD to be set on resume */
1167 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1168 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1170 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1173 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1177 static unsigned int ref925x_pin_configs[8] = {
1178 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1179 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1182 static unsigned int stac925x_MA6_pin_configs[8] = {
1183 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1184 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1187 static unsigned int stac925x_PA6_pin_configs[8] = {
1188 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1189 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1192 static unsigned int stac925xM2_2_pin_configs[8] = {
1193 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1194 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1197 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1198 [STAC_REF] = ref925x_pin_configs,
1199 [STAC_M2_2] = stac925xM2_2_pin_configs,
1200 [STAC_MA6] = stac925x_MA6_pin_configs,
1201 [STAC_PA6] = stac925x_PA6_pin_configs,
1204 static const char *stac925x_models[STAC_925x_MODELS] = {
1206 [STAC_M2_2] = "m2-2",
1211 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1212 /* SigmaTel reference board */
1213 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1214 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1215 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1216 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1217 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1218 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1219 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1223 static unsigned int ref92hd73xx_pin_configs[12] = {
1224 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1225 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1226 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1229 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1230 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1233 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1234 [STAC_92HD73XX_REF] = "ref",
1237 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1238 /* SigmaTel reference board */
1239 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1240 "DFI LanParty", STAC_92HD73XX_REF),
1244 static unsigned int ref92hd71bxx_pin_configs[10] = {
1245 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1246 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1247 0x90a000f0, 0x01452050,
1250 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1251 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1254 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1255 [STAC_92HD71BXX_REF] = "ref",
1258 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1259 /* SigmaTel reference board */
1260 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1261 "DFI LanParty", STAC_92HD71BXX_REF),
1265 static unsigned int ref922x_pin_configs[10] = {
1266 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1267 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1268 0x40000100, 0x40000100,
1272 STAC 922X pin configs for
1279 static unsigned int dell_922x_d81_pin_configs[10] = {
1280 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1281 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1282 0x01813122, 0x400001f2,
1286 STAC 922X pin configs for
1290 static unsigned int dell_922x_d82_pin_configs[10] = {
1291 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1292 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1293 0x01813122, 0x400001f1,
1297 STAC 922X pin configs for
1300 static unsigned int dell_922x_m81_pin_configs[10] = {
1301 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1302 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1303 0x40C003f1, 0x405003f0,
1307 STAC 9221 A1 pin configs for
1308 102801D7 (Dell XPS M1210)
1310 static unsigned int dell_922x_m82_pin_configs[10] = {
1311 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1312 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1313 0x508003f3, 0x405003f4,
1316 static unsigned int d945gtp3_pin_configs[10] = {
1317 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1318 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1319 0x02a19120, 0x40000100,
1322 static unsigned int d945gtp5_pin_configs[10] = {
1323 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1324 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1325 0x02a19320, 0x40000100,
1328 static unsigned int intel_mac_v1_pin_configs[10] = {
1329 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1330 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1331 0x400000fc, 0x400000fb,
1334 static unsigned int intel_mac_v2_pin_configs[10] = {
1335 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1336 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1337 0x400000fc, 0x400000fb,
1340 static unsigned int intel_mac_v3_pin_configs[10] = {
1341 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1342 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1343 0x400000fc, 0x400000fb,
1346 static unsigned int intel_mac_v4_pin_configs[10] = {
1347 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1348 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1349 0x400000fc, 0x400000fb,
1352 static unsigned int intel_mac_v5_pin_configs[10] = {
1353 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1354 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1355 0x400000fc, 0x400000fb,
1359 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1360 [STAC_D945_REF] = ref922x_pin_configs,
1361 [STAC_D945GTP3] = d945gtp3_pin_configs,
1362 [STAC_D945GTP5] = d945gtp5_pin_configs,
1363 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1364 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1365 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1366 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1367 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1368 /* for backward compatibility */
1369 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1370 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1371 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1372 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1373 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1374 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1375 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1376 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1377 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1378 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1381 static const char *stac922x_models[STAC_922X_MODELS] = {
1382 [STAC_D945_REF] = "ref",
1383 [STAC_D945GTP5] = "5stack",
1384 [STAC_D945GTP3] = "3stack",
1385 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1386 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1387 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1388 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1389 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1390 /* for backward compatibility */
1391 [STAC_MACMINI] = "macmini",
1392 [STAC_MACBOOK] = "macbook",
1393 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1394 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1395 [STAC_IMAC_INTEL] = "imac-intel",
1396 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1397 [STAC_922X_DELL_D81] = "dell-d81",
1398 [STAC_922X_DELL_D82] = "dell-d82",
1399 [STAC_922X_DELL_M81] = "dell-m81",
1400 [STAC_922X_DELL_M82] = "dell-m82",
1403 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1404 /* SigmaTel reference board */
1405 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1406 "DFI LanParty", STAC_D945_REF),
1407 /* Intel 945G based systems */
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1409 "Intel D945G", STAC_D945GTP3),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1411 "Intel D945G", STAC_D945GTP3),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1413 "Intel D945G", STAC_D945GTP3),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1415 "Intel D945G", STAC_D945GTP3),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1417 "Intel D945G", STAC_D945GTP3),
1418 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1419 "Intel D945G", STAC_D945GTP3),
1420 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1421 "Intel D945G", STAC_D945GTP3),
1422 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1423 "Intel D945G", STAC_D945GTP3),
1424 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1425 "Intel D945G", STAC_D945GTP3),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1427 "Intel D945G", STAC_D945GTP3),
1428 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1429 "Intel D945G", STAC_D945GTP3),
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1431 "Intel D945G", STAC_D945GTP3),
1432 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1433 "Intel D945G", STAC_D945GTP3),
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1435 "Intel D945G", STAC_D945GTP3),
1436 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1437 "Intel D945G", STAC_D945GTP3),
1438 /* Intel D945G 5-stack systems */
1439 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1440 "Intel D945G", STAC_D945GTP5),
1441 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1442 "Intel D945G", STAC_D945GTP5),
1443 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1444 "Intel D945G", STAC_D945GTP5),
1445 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1446 "Intel D945G", STAC_D945GTP5),
1447 /* Intel 945P based systems */
1448 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1449 "Intel D945P", STAC_D945GTP3),
1450 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1451 "Intel D945P", STAC_D945GTP3),
1452 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1453 "Intel D945P", STAC_D945GTP3),
1454 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1455 "Intel D945P", STAC_D945GTP3),
1456 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1457 "Intel D945P", STAC_D945GTP3),
1458 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1459 "Intel D945P", STAC_D945GTP5),
1461 /* Apple Mac Mini (early 2006) */
1462 SND_PCI_QUIRK(0x8384, 0x7680,
1463 "Mac Mini", STAC_INTEL_MAC_V3),
1465 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1466 "unknown Dell", STAC_922X_DELL_D81),
1467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1468 "unknown Dell", STAC_922X_DELL_D81),
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1470 "unknown Dell", STAC_922X_DELL_D81),
1471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1472 "unknown Dell", STAC_922X_DELL_D82),
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1474 "unknown Dell", STAC_922X_DELL_M81),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1476 "unknown Dell", STAC_922X_DELL_D82),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1478 "unknown Dell", STAC_922X_DELL_D81),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1480 "unknown Dell", STAC_922X_DELL_D81),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1482 "Dell XPS M1210", STAC_922X_DELL_M82),
1486 static unsigned int ref927x_pin_configs[14] = {
1487 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1488 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1489 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1490 0x01c42190, 0x40000100,
1493 static unsigned int d965_3st_pin_configs[14] = {
1494 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1495 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1496 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1497 0x40000100, 0x40000100
1500 static unsigned int d965_5st_pin_configs[14] = {
1501 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1502 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1503 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1504 0x40000100, 0x40000100
1507 static unsigned int dell_3st_pin_configs[14] = {
1508 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1509 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1510 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1511 0x40c003fc, 0x40000100
1514 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1515 [STAC_D965_REF] = ref927x_pin_configs,
1516 [STAC_D965_3ST] = d965_3st_pin_configs,
1517 [STAC_D965_5ST] = d965_5st_pin_configs,
1518 [STAC_DELL_3ST] = dell_3st_pin_configs,
1519 [STAC_DELL_BIOS] = NULL,
1522 static const char *stac927x_models[STAC_927X_MODELS] = {
1523 [STAC_D965_REF] = "ref",
1524 [STAC_D965_3ST] = "3stack",
1525 [STAC_D965_5ST] = "5stack",
1526 [STAC_DELL_3ST] = "dell-3stack",
1527 [STAC_DELL_BIOS] = "dell-bios",
1530 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1531 /* SigmaTel reference board */
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1533 "DFI LanParty", STAC_D965_REF),
1534 /* Intel 946 based systems */
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1537 /* 965 based 3 stack systems */
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1550 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1554 /* Dell 3 stack systems */
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1559 /* Dell 3 stack systems with verb table in BIOS */
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell ", STAC_DELL_BIOS),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1568 /* 965 based 5 stack systems */
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1570 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1581 static unsigned int ref9205_pin_configs[12] = {
1582 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1583 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
1584 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1588 STAC 9205 pin configs for
1595 10280228 (Dell Vostro 1500)
1597 static unsigned int dell_9205_m42_pin_configs[12] = {
1598 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1599 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1600 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1604 STAC 9205 pin configs for
1608 102801FF (Dell Precision M4300)
1613 static unsigned int dell_9205_m43_pin_configs[12] = {
1614 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1615 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1616 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1619 static unsigned int dell_9205_m44_pin_configs[12] = {
1620 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1621 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1622 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1625 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1626 [STAC_9205_REF] = ref9205_pin_configs,
1627 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1628 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1629 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1632 static const char *stac9205_models[STAC_9205_MODELS] = {
1633 [STAC_9205_REF] = "ref",
1634 [STAC_9205_DELL_M42] = "dell-m42",
1635 [STAC_9205_DELL_M43] = "dell-m43",
1636 [STAC_9205_DELL_M44] = "dell-m44",
1639 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1640 /* SigmaTel reference board */
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1642 "DFI LanParty", STAC_9205_REF),
1643 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1644 "unknown Dell", STAC_9205_DELL_M42),
1645 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1646 "unknown Dell", STAC_9205_DELL_M42),
1647 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1648 "Dell Precision", STAC_9205_DELL_M43),
1649 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1650 "Dell Precision", STAC_9205_DELL_M43),
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1652 "Dell Precision", STAC_9205_DELL_M43),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1654 "Dell Precision", STAC_9205_DELL_M43),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1656 "Dell Precision", STAC_9205_DELL_M43),
1657 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1658 "unknown Dell", STAC_9205_DELL_M42),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1660 "unknown Dell", STAC_9205_DELL_M42),
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1662 "Dell Precision", STAC_9205_DELL_M43),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1664 "Dell Precision M4300", STAC_9205_DELL_M43),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1666 "Dell Precision", STAC_9205_DELL_M43),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1668 "Dell Inspiron", STAC_9205_DELL_M44),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1670 "Dell Inspiron", STAC_9205_DELL_M44),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1672 "Dell Inspiron", STAC_9205_DELL_M44),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1674 "Dell Inspiron", STAC_9205_DELL_M44),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1676 "unknown Dell", STAC_9205_DELL_M42),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1678 "Dell Inspiron", STAC_9205_DELL_M44),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1680 "Dell Vostro 1500", STAC_9205_DELL_M42),
1684 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1687 struct sigmatel_spec *spec = codec->spec;
1689 if (! spec->bios_pin_configs) {
1690 spec->bios_pin_configs = kcalloc(spec->num_pins,
1691 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1692 if (! spec->bios_pin_configs)
1696 for (i = 0; i < spec->num_pins; i++) {
1697 hda_nid_t nid = spec->pin_nids[i];
1698 unsigned int pin_cfg;
1700 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1701 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1702 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1704 spec->bios_pin_configs[i] = pin_cfg;
1710 static void stac92xx_set_config_reg(struct hda_codec *codec,
1711 hda_nid_t pin_nid, unsigned int pin_config)
1714 snd_hda_codec_write(codec, pin_nid, 0,
1715 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1716 pin_config & 0x000000ff);
1717 snd_hda_codec_write(codec, pin_nid, 0,
1718 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1719 (pin_config & 0x0000ff00) >> 8);
1720 snd_hda_codec_write(codec, pin_nid, 0,
1721 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1722 (pin_config & 0x00ff0000) >> 16);
1723 snd_hda_codec_write(codec, pin_nid, 0,
1724 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1726 i = snd_hda_codec_read(codec, pin_nid, 0,
1727 AC_VERB_GET_CONFIG_DEFAULT,
1729 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1733 static void stac92xx_set_config_regs(struct hda_codec *codec)
1736 struct sigmatel_spec *spec = codec->spec;
1738 if (!spec->pin_configs)
1741 for (i = 0; i < spec->num_pins; i++)
1742 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1743 spec->pin_configs[i]);
1747 * Analog playback callbacks
1749 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1750 struct hda_codec *codec,
1751 struct snd_pcm_substream *substream)
1753 struct sigmatel_spec *spec = codec->spec;
1754 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1758 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1759 struct hda_codec *codec,
1760 unsigned int stream_tag,
1761 unsigned int format,
1762 struct snd_pcm_substream *substream)
1764 struct sigmatel_spec *spec = codec->spec;
1765 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1768 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1769 struct hda_codec *codec,
1770 struct snd_pcm_substream *substream)
1772 struct sigmatel_spec *spec = codec->spec;
1773 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1777 * Digital playback callbacks
1779 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1780 struct hda_codec *codec,
1781 struct snd_pcm_substream *substream)
1783 struct sigmatel_spec *spec = codec->spec;
1784 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1787 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1788 struct hda_codec *codec,
1789 struct snd_pcm_substream *substream)
1791 struct sigmatel_spec *spec = codec->spec;
1792 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1795 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1796 struct hda_codec *codec,
1797 unsigned int stream_tag,
1798 unsigned int format,
1799 struct snd_pcm_substream *substream)
1801 struct sigmatel_spec *spec = codec->spec;
1802 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1803 stream_tag, format, substream);
1808 * Analog capture callbacks
1810 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1811 struct hda_codec *codec,
1812 unsigned int stream_tag,
1813 unsigned int format,
1814 struct snd_pcm_substream *substream)
1816 struct sigmatel_spec *spec = codec->spec;
1818 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1819 stream_tag, 0, format);
1823 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1824 struct hda_codec *codec,
1825 struct snd_pcm_substream *substream)
1827 struct sigmatel_spec *spec = codec->spec;
1829 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
1833 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1837 /* NID is set in stac92xx_build_pcms */
1839 .open = stac92xx_dig_playback_pcm_open,
1840 .close = stac92xx_dig_playback_pcm_close,
1841 .prepare = stac92xx_dig_playback_pcm_prepare
1845 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1849 /* NID is set in stac92xx_build_pcms */
1852 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1856 .nid = 0x02, /* NID to query formats and rates */
1858 .open = stac92xx_playback_pcm_open,
1859 .prepare = stac92xx_playback_pcm_prepare,
1860 .cleanup = stac92xx_playback_pcm_cleanup
1864 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1868 .nid = 0x06, /* NID to query formats and rates */
1870 .open = stac92xx_playback_pcm_open,
1871 .prepare = stac92xx_playback_pcm_prepare,
1872 .cleanup = stac92xx_playback_pcm_cleanup
1876 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1879 /* NID + .substreams is set in stac92xx_build_pcms */
1881 .prepare = stac92xx_capture_pcm_prepare,
1882 .cleanup = stac92xx_capture_pcm_cleanup
1886 static int stac92xx_build_pcms(struct hda_codec *codec)
1888 struct sigmatel_spec *spec = codec->spec;
1889 struct hda_pcm *info = spec->pcm_rec;
1891 codec->num_pcms = 1;
1892 codec->pcm_info = info;
1894 info->name = "STAC92xx Analog";
1895 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
1896 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
1897 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
1898 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
1900 if (spec->alt_switch) {
1903 info->name = "STAC92xx Analog Alt";
1904 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
1907 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
1910 info->name = "STAC92xx Digital";
1911 info->pcm_type = HDA_PCM_TYPE_SPDIF;
1912 if (spec->multiout.dig_out_nid) {
1913 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
1914 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
1916 if (spec->dig_in_nid) {
1917 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
1918 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
1925 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
1927 unsigned int pincap = snd_hda_param_read(codec, nid,
1929 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
1930 if (pincap & AC_PINCAP_VREF_100)
1931 return AC_PINCTL_VREF_100;
1932 if (pincap & AC_PINCAP_VREF_80)
1933 return AC_PINCTL_VREF_80;
1934 if (pincap & AC_PINCAP_VREF_50)
1935 return AC_PINCTL_VREF_50;
1936 if (pincap & AC_PINCAP_VREF_GRD)
1937 return AC_PINCTL_VREF_GRD;
1941 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
1944 snd_hda_codec_write_cache(codec, nid, 0,
1945 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
1948 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
1950 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1952 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1953 struct sigmatel_spec *spec = codec->spec;
1954 int io_idx = kcontrol-> private_value & 0xff;
1956 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
1960 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
1962 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1963 struct sigmatel_spec *spec = codec->spec;
1964 hda_nid_t nid = kcontrol->private_value >> 8;
1965 int io_idx = kcontrol-> private_value & 0xff;
1966 unsigned short val = !!ucontrol->value.integer.value[0];
1968 spec->io_switch[io_idx] = val;
1971 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
1973 unsigned int pinctl = AC_PINCTL_IN_EN;
1974 if (io_idx) /* set VREF for mic */
1975 pinctl |= stac92xx_get_vref(codec, nid);
1976 stac92xx_auto_set_pinctl(codec, nid, pinctl);
1979 /* check the auto-mute again: we need to mute/unmute the speaker
1980 * appropriately according to the pin direction
1982 if (spec->hp_detect)
1983 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
1988 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
1990 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
1991 struct snd_ctl_elem_value *ucontrol)
1993 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1994 struct sigmatel_spec *spec = codec->spec;
1996 ucontrol->value.integer.value[0] = spec->clfe_swap;
2000 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2001 struct snd_ctl_elem_value *ucontrol)
2003 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2004 struct sigmatel_spec *spec = codec->spec;
2005 hda_nid_t nid = kcontrol->private_value & 0xff;
2006 unsigned int val = !!ucontrol->value.integer.value[0];
2008 if (spec->clfe_swap == val)
2011 spec->clfe_swap = val;
2013 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2014 spec->clfe_swap ? 0x4 : 0x0);
2019 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2020 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2023 .info = stac92xx_io_switch_info, \
2024 .get = stac92xx_io_switch_get, \
2025 .put = stac92xx_io_switch_put, \
2026 .private_value = xpval, \
2029 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2030 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2033 .info = stac92xx_clfe_switch_info, \
2034 .get = stac92xx_clfe_switch_get, \
2035 .put = stac92xx_clfe_switch_put, \
2036 .private_value = xpval, \
2040 STAC_CTL_WIDGET_VOL,
2041 STAC_CTL_WIDGET_MUTE,
2042 STAC_CTL_WIDGET_MONO_MUX,
2043 STAC_CTL_WIDGET_IO_SWITCH,
2044 STAC_CTL_WIDGET_CLFE_SWITCH
2047 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2048 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2049 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2051 STAC_CODEC_IO_SWITCH(NULL, 0),
2052 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2055 /* add dynamic controls */
2056 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2058 struct snd_kcontrol_new *knew;
2060 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2061 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2063 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2066 if (spec->kctl_alloc) {
2067 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2068 kfree(spec->kctl_alloc);
2070 spec->kctl_alloc = knew;
2071 spec->num_kctl_alloc = num;
2074 knew = &spec->kctl_alloc[spec->num_kctl_used];
2075 *knew = stac92xx_control_templates[type];
2076 knew->name = kstrdup(name, GFP_KERNEL);
2079 knew->private_value = val;
2080 spec->num_kctl_used++;
2084 /* flag inputs as additional dynamic lineouts */
2085 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2087 struct sigmatel_spec *spec = codec->spec;
2088 unsigned int wcaps, wtype;
2089 int i, num_dacs = 0;
2091 /* use the wcaps cache to count all DACs available for line-outs */
2092 for (i = 0; i < codec->num_nodes; i++) {
2093 wcaps = codec->wcaps[i];
2094 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2096 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2100 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2102 switch (cfg->line_outs) {
2104 /* add line-in as side */
2105 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2106 cfg->line_out_pins[cfg->line_outs] =
2107 cfg->input_pins[AUTO_PIN_LINE];
2108 spec->line_switch = 1;
2113 /* add line-in as clfe and mic as side */
2114 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2115 cfg->line_out_pins[cfg->line_outs] =
2116 cfg->input_pins[AUTO_PIN_LINE];
2117 spec->line_switch = 1;
2120 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2121 cfg->line_out_pins[cfg->line_outs] =
2122 cfg->input_pins[AUTO_PIN_MIC];
2123 spec->mic_switch = 1;
2128 /* add line-in as surr and mic as clfe */
2129 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2130 cfg->line_out_pins[cfg->line_outs] =
2131 cfg->input_pins[AUTO_PIN_LINE];
2132 spec->line_switch = 1;
2135 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2136 cfg->line_out_pins[cfg->line_outs] =
2137 cfg->input_pins[AUTO_PIN_MIC];
2138 spec->mic_switch = 1;
2148 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2152 for (i = 0; i < spec->multiout.num_dacs; i++) {
2153 if (spec->multiout.dac_nids[i] == nid)
2161 * Fill in the dac_nids table from the parsed pin configuration
2162 * This function only works when every pin in line_out_pins[]
2163 * contains atleast one DAC in its connection list. Some 92xx
2164 * codecs are not connected directly to a DAC, such as the 9200
2165 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2167 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2168 struct auto_pin_cfg *cfg)
2170 struct sigmatel_spec *spec = codec->spec;
2171 int i, j, conn_len = 0;
2172 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2173 unsigned int wcaps, wtype;
2175 for (i = 0; i < cfg->line_outs; i++) {
2176 nid = cfg->line_out_pins[i];
2177 conn_len = snd_hda_get_connections(codec, nid, conn,
2178 HDA_MAX_CONNECTIONS);
2179 for (j = 0; j < conn_len; j++) {
2180 wcaps = snd_hda_param_read(codec, conn[j],
2181 AC_PAR_AUDIO_WIDGET_CAP);
2182 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2183 if (wtype != AC_WID_AUD_OUT ||
2184 (wcaps & AC_WCAP_DIGITAL))
2186 /* conn[j] is a DAC routed to this line-out */
2187 if (!is_in_dac_nids(spec, conn[j]))
2191 if (j == conn_len) {
2192 if (spec->multiout.num_dacs > 0) {
2193 /* we have already working output pins,
2194 * so let's drop the broken ones again
2196 cfg->line_outs = spec->multiout.num_dacs;
2199 /* error out, no available DAC found */
2201 "%s: No available DAC for pin 0x%x\n",
2206 spec->multiout.dac_nids[i] = conn[j];
2207 spec->multiout.num_dacs++;
2209 /* select this DAC in the pin's input mux */
2210 snd_hda_codec_write_cache(codec, nid, 0,
2211 AC_VERB_SET_CONNECT_SEL, j);
2216 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2217 spec->multiout.num_dacs,
2218 spec->multiout.dac_nids[0],
2219 spec->multiout.dac_nids[1],
2220 spec->multiout.dac_nids[2],
2221 spec->multiout.dac_nids[3],
2222 spec->multiout.dac_nids[4]);
2226 /* create volume control/switch for the given prefx type */
2227 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2232 sprintf(name, "%s Playback Volume", pfx);
2233 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2234 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2237 sprintf(name, "%s Playback Switch", pfx);
2238 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2239 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2245 /* add playback controls from the parsed DAC table */
2246 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2247 const struct auto_pin_cfg *cfg)
2249 static const char *chname[4] = {
2250 "Front", "Surround", NULL /*CLFE*/, "Side"
2255 struct sigmatel_spec *spec = codec->spec;
2256 unsigned int wid_caps, pincap;
2259 for (i = 0; i < cfg->line_outs; i++) {
2260 if (!spec->multiout.dac_nids[i])
2263 nid = spec->multiout.dac_nids[i];
2267 err = create_controls(spec, "Center", nid, 1);
2270 err = create_controls(spec, "LFE", nid, 2);
2274 wid_caps = get_wcaps(codec, nid);
2276 if (wid_caps & AC_WCAP_LR_SWAP) {
2277 err = stac92xx_add_control(spec,
2278 STAC_CTL_WIDGET_CLFE_SWITCH,
2279 "Swap Center/LFE Playback Switch", nid);
2286 err = create_controls(spec, chname[i], nid, 3);
2292 if (spec->line_switch) {
2293 nid = cfg->input_pins[AUTO_PIN_LINE];
2294 pincap = snd_hda_param_read(codec, nid,
2296 if (pincap & AC_PINCAP_OUT) {
2297 err = stac92xx_add_control(spec,
2298 STAC_CTL_WIDGET_IO_SWITCH,
2299 "Line In as Output Switch", nid << 8);
2305 if (spec->mic_switch) {
2306 unsigned int def_conf;
2307 nid = cfg->input_pins[AUTO_PIN_MIC];
2308 def_conf = snd_hda_codec_read(codec, nid, 0,
2309 AC_VERB_GET_CONFIG_DEFAULT, 0);
2311 /* some laptops have an internal analog microphone
2312 * which can't be used as a output */
2313 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2314 pincap = snd_hda_param_read(codec, nid,
2316 if (pincap & AC_PINCAP_OUT) {
2317 err = stac92xx_add_control(spec,
2318 STAC_CTL_WIDGET_IO_SWITCH,
2319 "Mic as Output Switch", (nid << 8) | 1);
2329 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2331 if (is_in_dac_nids(spec, nid))
2333 if (spec->multiout.hp_nid == nid)
2338 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2340 if (!spec->multiout.hp_nid)
2341 spec->multiout.hp_nid = nid;
2342 else if (spec->multiout.num_dacs > 4) {
2343 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2346 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2347 spec->multiout.num_dacs++;
2352 /* add playback controls for Speaker and HP outputs */
2353 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2354 struct auto_pin_cfg *cfg)
2356 struct sigmatel_spec *spec = codec->spec;
2358 int i, old_num_dacs, err;
2360 old_num_dacs = spec->multiout.num_dacs;
2361 for (i = 0; i < cfg->hp_outs; i++) {
2362 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2363 if (wid_caps & AC_WCAP_UNSOL_CAP)
2364 spec->hp_detect = 1;
2365 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2366 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2367 if (check_in_dac_nids(spec, nid))
2371 add_spec_dacs(spec, nid);
2373 for (i = 0; i < cfg->speaker_outs; i++) {
2374 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2375 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2376 if (check_in_dac_nids(spec, nid))
2380 add_spec_dacs(spec, nid);
2382 for (i = 0; i < cfg->line_outs; i++) {
2383 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2384 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2385 if (check_in_dac_nids(spec, nid))
2389 add_spec_dacs(spec, nid);
2391 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2392 static const char *pfxs[] = {
2393 "Speaker", "External Speaker", "Speaker2",
2395 err = create_controls(spec, pfxs[i - old_num_dacs],
2396 spec->multiout.dac_nids[i], 3);
2400 if (spec->multiout.hp_nid) {
2402 if (old_num_dacs == spec->multiout.num_dacs)
2406 err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
2414 /* labels for mono mux outputs */
2415 static const char *stac92xx_mono_labels[3] = {
2416 "DAC0", "DAC1", "Mixer"
2419 /* create mono mux for mono out on capable codecs */
2420 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2422 struct sigmatel_spec *spec = codec->spec;
2423 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2425 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2427 num_cons = snd_hda_get_connections(codec,
2430 HDA_MAX_NUM_INPUTS);
2431 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2434 for (i = 0; i < num_cons; i++) {
2435 mono_mux->items[mono_mux->num_items].label =
2436 stac92xx_mono_labels[i];
2437 mono_mux->items[mono_mux->num_items].index = i;
2438 mono_mux->num_items++;
2441 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2442 "Mono Mux", spec->mono_nid);
2445 /* labels for dmic mux inputs */
2446 static const char *stac92xx_dmic_labels[5] = {
2447 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2448 "Digital Mic 3", "Digital Mic 4"
2451 /* create playback/capture controls for input pins on dmic capable codecs */
2452 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2453 const struct auto_pin_cfg *cfg)
2455 struct sigmatel_spec *spec = codec->spec;
2456 struct hda_input_mux *dimux = &spec->private_dimux;
2457 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2461 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2462 dimux->items[dimux->num_items].index = 0;
2465 for (i = 0; i < spec->num_dmics; i++) {
2470 unsigned int def_conf;
2472 def_conf = snd_hda_codec_read(codec,
2475 AC_VERB_GET_CONFIG_DEFAULT,
2477 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2480 nid = spec->dmic_nids[i];
2481 num_cons = snd_hda_get_connections(codec,
2484 HDA_MAX_NUM_INPUTS);
2485 for (j = 0; j < num_cons; j++)
2486 if (con_lst[j] == nid) {
2492 wcaps = get_wcaps(codec, nid);
2494 if (wcaps & AC_WCAP_OUT_AMP) {
2495 sprintf(name, "%s Capture Volume",
2496 stac92xx_dmic_labels[dimux->num_items]);
2498 err = stac92xx_add_control(spec,
2499 STAC_CTL_WIDGET_VOL,
2501 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2506 dimux->items[dimux->num_items].label =
2507 stac92xx_dmic_labels[dimux->num_items];
2508 dimux->items[dimux->num_items].index = index;
2515 /* create playback/capture controls for input pins */
2516 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2518 struct sigmatel_spec *spec = codec->spec;
2519 struct hda_input_mux *imux = &spec->private_imux;
2520 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2523 for (i = 0; i < AUTO_PIN_LAST; i++) {
2526 if (!cfg->input_pins[i])
2529 for (j = 0; j < spec->num_muxes; j++) {
2531 num_cons = snd_hda_get_connections(codec,
2534 HDA_MAX_NUM_INPUTS);
2535 for (k = 0; k < num_cons; k++)
2536 if (con_lst[k] == cfg->input_pins[i]) {
2543 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2544 imux->items[imux->num_items].index = index;
2548 if (imux->num_items) {
2550 * Set the current input for the muxes.
2551 * The STAC9221 has two input muxes with identical source
2552 * NID lists. Hopefully this won't get confused.
2554 for (i = 0; i < spec->num_muxes; i++) {
2555 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2556 AC_VERB_SET_CONNECT_SEL,
2557 imux->items[0].index);
2564 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2566 struct sigmatel_spec *spec = codec->spec;
2569 for (i = 0; i < spec->autocfg.line_outs; i++) {
2570 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2571 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2575 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2577 struct sigmatel_spec *spec = codec->spec;
2580 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2582 pin = spec->autocfg.hp_pins[i];
2583 if (pin) /* connect to front */
2584 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2586 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2588 pin = spec->autocfg.speaker_pins[i];
2589 if (pin) /* connect to front */
2590 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2594 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2596 struct sigmatel_spec *spec = codec->spec;
2598 int hp_speaker_swap = 0;
2600 if ((err = snd_hda_parse_pin_def_config(codec,
2602 spec->dmic_nids)) < 0)
2604 if (! spec->autocfg.line_outs)
2605 return 0; /* can't find valid pin config */
2607 /* If we have no real line-out pin and multiple hp-outs, HPs should
2608 * be set up as multi-channel outputs.
2610 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2611 spec->autocfg.hp_outs > 1) {
2612 /* Copy hp_outs to line_outs, backup line_outs in
2613 * speaker_outs so that the following routines can handle
2614 * HP pins as primary outputs.
2616 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2617 sizeof(spec->autocfg.line_out_pins));
2618 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2619 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2620 sizeof(spec->autocfg.hp_pins));
2621 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2622 hp_speaker_swap = 1;
2624 if (spec->autocfg.mono_out_pin) {
2625 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2626 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2627 u32 caps = query_amp_caps(codec,
2628 spec->autocfg.mono_out_pin, dir);
2629 hda_nid_t conn_list[1];
2631 /* get the mixer node and then the mono mux if it exists */
2632 if (snd_hda_get_connections(codec,
2633 spec->autocfg.mono_out_pin, conn_list, 1) &&
2634 snd_hda_get_connections(codec, conn_list[0],
2637 int wcaps = get_wcaps(codec, conn_list[0]);
2638 int wid_type = (wcaps & AC_WCAP_TYPE)
2639 >> AC_WCAP_TYPE_SHIFT;
2640 /* LR swap check, some stac925x have a mux that
2641 * changes the DACs output path instead of the
2644 if (wid_type == AC_WID_AUD_SEL &&
2645 !(wcaps & AC_WCAP_LR_SWAP))
2646 spec->mono_nid = conn_list[0];
2648 /* all mono outs have a least a mute/unmute switch */
2649 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2650 "Mono Playback Switch",
2651 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2655 /* check to see if there is volume support for the amp */
2656 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2657 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2658 "Mono Playback Volume",
2659 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2665 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2669 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2671 if (spec->multiout.num_dacs == 0)
2672 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2675 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2680 if (hp_speaker_swap == 1) {
2681 /* Restore the hp_outs and line_outs */
2682 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2683 sizeof(spec->autocfg.line_out_pins));
2684 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2685 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2686 sizeof(spec->autocfg.speaker_pins));
2687 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2688 memset(spec->autocfg.speaker_pins, 0,
2689 sizeof(spec->autocfg.speaker_pins));
2690 spec->autocfg.speaker_outs = 0;
2693 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2698 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2703 if (spec->mono_nid > 0) {
2704 err = stac92xx_auto_create_mono_output_ctls(codec);
2709 if (spec->num_dmics > 0)
2710 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2711 &spec->autocfg)) < 0)
2714 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2715 if (spec->multiout.max_channels > 2)
2716 spec->surr_switch = 1;
2718 if (spec->autocfg.dig_out_pin)
2719 spec->multiout.dig_out_nid = dig_out;
2720 if (spec->autocfg.dig_in_pin)
2721 spec->dig_in_nid = dig_in;
2723 if (spec->kctl_alloc)
2724 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2726 spec->input_mux = &spec->private_imux;
2727 if (!spec->dinput_mux)
2728 spec->dinput_mux = &spec->private_dimux;
2729 spec->mono_mux = &spec->private_mono_mux;
2734 /* add playback controls for HP output */
2735 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2736 struct auto_pin_cfg *cfg)
2738 struct sigmatel_spec *spec = codec->spec;
2739 hda_nid_t pin = cfg->hp_pins[0];
2740 unsigned int wid_caps;
2745 wid_caps = get_wcaps(codec, pin);
2746 if (wid_caps & AC_WCAP_UNSOL_CAP)
2747 spec->hp_detect = 1;
2752 /* add playback controls for LFE output */
2753 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2754 struct auto_pin_cfg *cfg)
2756 struct sigmatel_spec *spec = codec->spec;
2758 hda_nid_t lfe_pin = 0x0;
2762 * search speaker outs and line outs for a mono speaker pin
2763 * with an amp. If one is found, add LFE controls
2766 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2767 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2768 unsigned long wcaps = get_wcaps(codec, pin);
2769 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2770 if (wcaps == AC_WCAP_OUT_AMP)
2771 /* found a mono speaker with an amp, must be lfe */
2775 /* if speaker_outs is 0, then speakers may be in line_outs */
2776 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2777 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2778 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2780 cfg = snd_hda_codec_read(codec, pin, 0,
2781 AC_VERB_GET_CONFIG_DEFAULT,
2783 if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
2784 unsigned long wcaps = get_wcaps(codec, pin);
2785 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2786 if (wcaps == AC_WCAP_OUT_AMP)
2787 /* found a mono speaker with an amp,
2795 err = create_controls(spec, "LFE", lfe_pin, 1);
2803 static int stac9200_parse_auto_config(struct hda_codec *codec)
2805 struct sigmatel_spec *spec = codec->spec;
2808 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2811 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2814 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2817 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2820 if (spec->autocfg.dig_out_pin)
2821 spec->multiout.dig_out_nid = 0x05;
2822 if (spec->autocfg.dig_in_pin)
2823 spec->dig_in_nid = 0x04;
2825 if (spec->kctl_alloc)
2826 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2828 spec->input_mux = &spec->private_imux;
2829 spec->dinput_mux = &spec->private_dimux;
2835 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
2836 * funky external mute control using GPIO pins.
2839 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
2840 unsigned int dir_mask, unsigned int data)
2842 unsigned int gpiostate, gpiomask, gpiodir;
2844 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
2845 AC_VERB_GET_GPIO_DATA, 0);
2846 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
2848 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
2849 AC_VERB_GET_GPIO_MASK, 0);
2852 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
2853 AC_VERB_GET_GPIO_DIRECTION, 0);
2854 gpiodir |= dir_mask;
2856 /* Configure GPIOx as CMOS */
2857 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
2859 snd_hda_codec_write(codec, codec->afg, 0,
2860 AC_VERB_SET_GPIO_MASK, gpiomask);
2861 snd_hda_codec_read(codec, codec->afg, 0,
2862 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
2866 snd_hda_codec_read(codec, codec->afg, 0,
2867 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
2870 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
2873 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
2874 snd_hda_codec_write_cache(codec, nid, 0,
2875 AC_VERB_SET_UNSOLICITED_ENABLE,
2876 (AC_USRSP_EN | event));
2879 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
2882 for (i = 0; i < cfg->hp_outs; i++)
2883 if (cfg->hp_pins[i] == nid)
2884 return 1; /* nid is a HP-Out */
2886 return 0; /* nid is not a HP-Out */
2889 static void stac92xx_power_down(struct hda_codec *codec)
2891 struct sigmatel_spec *spec = codec->spec;
2893 /* power down inactive DACs */
2895 for (dac = spec->dac_list; *dac; dac++)
2896 if (!is_in_dac_nids(spec, *dac))
2897 snd_hda_codec_write_cache(codec, *dac, 0,
2898 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2901 static int stac92xx_init(struct hda_codec *codec)
2903 struct sigmatel_spec *spec = codec->spec;
2904 struct auto_pin_cfg *cfg = &spec->autocfg;
2907 snd_hda_sequence_write(codec, spec->init);
2910 if (spec->hp_detect) {
2911 /* Enable unsolicited responses on the HP widget */
2912 for (i = 0; i < cfg->hp_outs; i++)
2913 enable_pin_detect(codec, cfg->hp_pins[i],
2915 /* force to enable the first line-out; the others are set up
2918 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
2920 stac92xx_auto_init_hp_out(codec);
2921 /* fake event to set up pins */
2922 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2924 stac92xx_auto_init_multi_out(codec);
2925 stac92xx_auto_init_hp_out(codec);
2927 for (i = 0; i < AUTO_PIN_LAST; i++) {
2928 hda_nid_t nid = cfg->input_pins[i];
2930 unsigned int pinctl = AC_PINCTL_IN_EN;
2931 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
2932 pinctl |= stac92xx_get_vref(codec, nid);
2933 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2936 for (i = 0; i < spec->num_dmics; i++)
2937 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
2939 for (i = 0; i < spec->num_pwrs; i++) {
2940 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
2941 ? STAC_HP_EVENT : STAC_PWR_EVENT;
2942 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
2943 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2944 /* outputs are only ports capable of power management
2945 * any attempts on powering down a input port cause the
2946 * referenced VREF to act quirky.
2948 if (pinctl & AC_PINCTL_IN_EN)
2950 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
2951 codec->patch_ops.unsol_event(codec, (event | i) << 26);
2954 stac92xx_power_down(codec);
2955 if (cfg->dig_out_pin)
2956 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
2958 if (cfg->dig_in_pin)
2959 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
2962 stac_gpio_set(codec, spec->gpio_mask,
2963 spec->gpio_dir, spec->gpio_data);
2968 static void stac92xx_free(struct hda_codec *codec)
2970 struct sigmatel_spec *spec = codec->spec;
2976 if (spec->kctl_alloc) {
2977 for (i = 0; i < spec->num_kctl_used; i++)
2978 kfree(spec->kctl_alloc[i].name);
2979 kfree(spec->kctl_alloc);
2982 if (spec->bios_pin_configs)
2983 kfree(spec->bios_pin_configs);
2988 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
2991 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
2992 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
2994 if (pin_ctl & AC_PINCTL_IN_EN) {
2996 * we need to check the current set-up direction of
2997 * shared input pins since they can be switched via
2998 * "xxx as Output" mixer switch
3000 struct sigmatel_spec *spec = codec->spec;
3001 struct auto_pin_cfg *cfg = &spec->autocfg;
3002 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3003 spec->line_switch) ||
3004 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3009 /* if setting pin direction bits, clear the current
3010 direction bits first */
3011 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3012 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3014 snd_hda_codec_write_cache(codec, nid, 0,
3015 AC_VERB_SET_PIN_WIDGET_CONTROL,
3019 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3022 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3023 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3024 snd_hda_codec_write_cache(codec, nid, 0,
3025 AC_VERB_SET_PIN_WIDGET_CONTROL,
3029 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3033 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3035 unsigned int pinctl;
3036 pinctl = snd_hda_codec_read(codec, nid, 0,
3037 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3038 if (pinctl & AC_PINCTL_IN_EN)
3039 return 0; /* mic- or line-input */
3041 return 1; /* HP-output */
3046 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3048 struct sigmatel_spec *spec = codec->spec;
3049 struct auto_pin_cfg *cfg = &spec->autocfg;
3053 if (spec->gpio_mute)
3054 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3055 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3057 for (i = 0; i < cfg->hp_outs; i++) {
3060 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3064 /* disable lineouts, enable hp */
3065 for (i = 0; i < cfg->line_outs; i++)
3066 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3068 for (i = 0; i < cfg->speaker_outs; i++)
3069 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3072 /* enable lineouts, disable hp */
3073 for (i = 0; i < cfg->line_outs; i++)
3074 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3076 for (i = 0; i < cfg->speaker_outs; i++)
3077 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3082 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3084 struct sigmatel_spec *spec = codec->spec;
3085 hda_nid_t nid = spec->pwr_nids[idx];
3087 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3089 presence = get_hp_pin_presence(codec, nid);
3097 /* power down unused output ports */
3098 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3101 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3103 struct sigmatel_spec *spec = codec->spec;
3104 int idx = res >> 26 & 0x0f;
3106 switch ((res >> 26) & 0x30) {
3108 stac92xx_hp_detect(codec, res);
3110 case STAC_PWR_EVENT:
3111 if (spec->num_pwrs > 0)
3112 stac92xx_pin_sense(codec, idx);
3116 #ifdef SND_HDA_NEEDS_RESUME
3117 static int stac92xx_resume(struct hda_codec *codec)
3119 struct sigmatel_spec *spec = codec->spec;
3121 stac92xx_set_config_regs(codec);
3122 snd_hda_sequence_write(codec, spec->init);
3123 stac_gpio_set(codec, spec->gpio_mask,
3124 spec->gpio_dir, spec->gpio_data);
3125 snd_hda_codec_resume_amp(codec);
3126 snd_hda_codec_resume_cache(codec);
3127 /* power down inactive DACs */
3129 stac92xx_power_down(codec);
3130 /* invoke unsolicited event to reset the HP state */
3131 if (spec->hp_detect)
3132 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3137 static struct hda_codec_ops stac92xx_patch_ops = {
3138 .build_controls = stac92xx_build_controls,
3139 .build_pcms = stac92xx_build_pcms,
3140 .init = stac92xx_init,
3141 .free = stac92xx_free,
3142 .unsol_event = stac92xx_unsol_event,
3143 #ifdef SND_HDA_NEEDS_RESUME
3144 .resume = stac92xx_resume,
3148 static int patch_stac9200(struct hda_codec *codec)
3150 struct sigmatel_spec *spec;
3153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3158 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3159 spec->pin_nids = stac9200_pin_nids;
3160 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3163 if (spec->board_config < 0) {
3164 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3165 err = stac92xx_save_bios_config_regs(codec);
3167 stac92xx_free(codec);
3170 spec->pin_configs = spec->bios_pin_configs;
3172 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3173 stac92xx_set_config_regs(codec);
3176 spec->multiout.max_channels = 2;
3177 spec->multiout.num_dacs = 1;
3178 spec->multiout.dac_nids = stac9200_dac_nids;
3179 spec->adc_nids = stac9200_adc_nids;
3180 spec->mux_nids = stac9200_mux_nids;
3181 spec->num_muxes = 1;
3182 spec->num_dmics = 0;
3186 if (spec->board_config == STAC_9200_GATEWAY ||
3187 spec->board_config == STAC_9200_OQO)
3188 spec->init = stac9200_eapd_init;
3190 spec->init = stac9200_core_init;
3191 spec->mixer = stac9200_mixer;
3193 err = stac9200_parse_auto_config(codec);
3195 stac92xx_free(codec);
3199 codec->patch_ops = stac92xx_patch_ops;
3204 static int patch_stac925x(struct hda_codec *codec)
3206 struct sigmatel_spec *spec;
3209 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3214 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3215 spec->pin_nids = stac925x_pin_nids;
3216 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3220 if (spec->board_config < 0) {
3221 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3222 "using BIOS defaults\n");
3223 err = stac92xx_save_bios_config_regs(codec);
3225 stac92xx_free(codec);
3228 spec->pin_configs = spec->bios_pin_configs;
3229 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3230 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3231 stac92xx_set_config_regs(codec);
3234 spec->multiout.max_channels = 2;
3235 spec->multiout.num_dacs = 1;
3236 spec->multiout.dac_nids = stac925x_dac_nids;
3237 spec->adc_nids = stac925x_adc_nids;
3238 spec->mux_nids = stac925x_mux_nids;
3239 spec->num_muxes = 1;
3242 switch (codec->vendor_id) {
3243 case 0x83847632: /* STAC9202 */
3244 case 0x83847633: /* STAC9202D */
3245 case 0x83847636: /* STAC9251 */
3246 case 0x83847637: /* STAC9251D */
3247 spec->num_dmics = STAC925X_NUM_DMICS;
3248 spec->dmic_nids = stac925x_dmic_nids;
3249 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3250 spec->dmux_nids = stac925x_dmux_nids;
3253 spec->num_dmics = 0;
3257 spec->init = stac925x_core_init;
3258 spec->mixer = stac925x_mixer;
3260 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
3262 if (spec->board_config < 0) {
3263 printk(KERN_WARNING "hda_codec: No auto-config is "
3264 "available, default to model=ref\n");
3265 spec->board_config = STAC_925x_REF;
3271 stac92xx_free(codec);
3275 codec->patch_ops = stac92xx_patch_ops;
3280 static struct hda_input_mux stac92hd73xx_dmux = {
3283 { "Analog Inputs", 0x0b },
3285 { "Digital Mic 1", 0x09 },
3286 { "Digital Mic 2", 0x0a },
3290 static int patch_stac92hd73xx(struct hda_codec *codec)
3292 struct sigmatel_spec *spec;
3293 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3296 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3301 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3302 spec->pin_nids = stac92hd73xx_pin_nids;
3303 spec->board_config = snd_hda_check_board_config(codec,
3304 STAC_92HD73XX_MODELS,
3305 stac92hd73xx_models,
3306 stac92hd73xx_cfg_tbl);
3308 if (spec->board_config < 0) {
3309 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3310 " STAC92HD73XX, using BIOS defaults\n");
3311 err = stac92xx_save_bios_config_regs(codec);
3313 stac92xx_free(codec);
3316 spec->pin_configs = spec->bios_pin_configs;
3318 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3319 stac92xx_set_config_regs(codec);
3322 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3323 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3325 if (spec->multiout.num_dacs < 0) {
3326 printk(KERN_WARNING "hda_codec: Could not determine "
3327 "number of channels defaulting to DAC count\n");
3328 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3331 switch (spec->multiout.num_dacs) {
3332 case 0x3: /* 6 Channel */
3333 spec->mixer = stac92hd73xx_6ch_mixer;
3334 spec->init = stac92hd73xx_6ch_core_init;
3336 case 0x4: /* 8 Channel */
3337 spec->multiout.hp_nid = 0x18;
3338 spec->mixer = stac92hd73xx_8ch_mixer;
3339 spec->init = stac92hd73xx_8ch_core_init;
3341 case 0x5: /* 10 Channel */
3342 spec->multiout.hp_nid = 0x19;
3343 spec->mixer = stac92hd73xx_10ch_mixer;
3344 spec->init = stac92hd73xx_10ch_core_init;
3347 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3348 spec->aloopback_mask = 0x01;
3349 spec->aloopback_shift = 8;
3351 spec->mux_nids = stac92hd73xx_mux_nids;
3352 spec->adc_nids = stac92hd73xx_adc_nids;
3353 spec->dmic_nids = stac92hd73xx_dmic_nids;
3354 spec->dmux_nids = stac92hd73xx_dmux_nids;
3356 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3357 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3358 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3359 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3360 spec->dinput_mux = &stac92hd73xx_dmux;
3361 /* GPIO0 High = Enable EAPD */
3362 spec->gpio_mask = spec->gpio_dir = 0x1;
3363 spec->gpio_data = 0x01;
3365 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3366 spec->pwr_nids = stac92hd73xx_pwr_nids;
3368 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3371 if (spec->board_config < 0) {
3372 printk(KERN_WARNING "hda_codec: No auto-config is "
3373 "available, default to model=ref\n");
3374 spec->board_config = STAC_92HD73XX_REF;
3381 stac92xx_free(codec);
3385 codec->patch_ops = stac92xx_patch_ops;
3390 static int patch_stac92hd71bxx(struct hda_codec *codec)
3392 struct sigmatel_spec *spec;
3395 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3400 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
3401 spec->pin_nids = stac92hd71bxx_pin_nids;
3402 spec->board_config = snd_hda_check_board_config(codec,
3403 STAC_92HD71BXX_MODELS,
3404 stac92hd71bxx_models,
3405 stac92hd71bxx_cfg_tbl);
3407 if (spec->board_config < 0) {
3408 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3409 " STAC92HD71BXX, using BIOS defaults\n");
3410 err = stac92xx_save_bios_config_regs(codec);
3412 stac92xx_free(codec);
3415 spec->pin_configs = spec->bios_pin_configs;
3417 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3418 stac92xx_set_config_regs(codec);
3421 switch (codec->vendor_id) {
3422 case 0x111d76b6: /* 4 Port without Analog Mixer */
3424 case 0x111d76b4: /* 6 Port without Analog Mixer */
3426 spec->mixer = stac92hd71bxx_mixer;
3427 spec->init = stac92hd71bxx_core_init;
3430 spec->mixer = stac92hd71bxx_analog_mixer;
3431 spec->init = stac92hd71bxx_analog_core_init;
3434 spec->aloopback_mask = 0x20;
3435 spec->aloopback_shift = 0;
3437 /* GPIO0 High = EAPD */
3438 spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1;
3440 spec->mux_nids = stac92hd71bxx_mux_nids;
3441 spec->adc_nids = stac92hd71bxx_adc_nids;
3442 spec->dmic_nids = stac92hd71bxx_dmic_nids;
3443 spec->dmux_nids = stac92hd71bxx_dmux_nids;
3445 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3446 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3447 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3448 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3450 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3451 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3453 spec->multiout.num_dacs = 2;
3454 spec->multiout.hp_nid = 0x11;
3455 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3457 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3459 if (spec->board_config < 0) {
3460 printk(KERN_WARNING "hda_codec: No auto-config is "
3461 "available, default to model=ref\n");
3462 spec->board_config = STAC_92HD71BXX_REF;
3469 stac92xx_free(codec);
3473 codec->patch_ops = stac92xx_patch_ops;
3478 static int patch_stac922x(struct hda_codec *codec)
3480 struct sigmatel_spec *spec;
3483 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3488 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
3489 spec->pin_nids = stac922x_pin_nids;
3490 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3493 if (spec->board_config == STAC_INTEL_MAC_V3) {
3494 spec->gpio_mask = spec->gpio_dir = 0x03;
3495 spec->gpio_data = 0x03;
3496 /* Intel Macs have all same PCI SSID, so we need to check
3497 * codec SSID to distinguish the exact models
3499 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
3500 switch (codec->subsystem_id) {
3503 spec->board_config = STAC_INTEL_MAC_V1;
3507 spec->board_config = STAC_INTEL_MAC_V2;
3515 spec->board_config = STAC_INTEL_MAC_V3;
3519 spec->board_config = STAC_INTEL_MAC_V4;
3523 spec->board_config = STAC_INTEL_MAC_V5;
3529 if (spec->board_config < 0) {
3530 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3531 "using BIOS defaults\n");
3532 err = stac92xx_save_bios_config_regs(codec);
3534 stac92xx_free(codec);
3537 spec->pin_configs = spec->bios_pin_configs;
3538 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
3539 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3540 stac92xx_set_config_regs(codec);
3543 spec->adc_nids = stac922x_adc_nids;
3544 spec->mux_nids = stac922x_mux_nids;
3545 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
3546 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
3547 spec->num_dmics = 0;
3550 spec->init = stac922x_core_init;
3551 spec->mixer = stac922x_mixer;
3553 spec->multiout.dac_nids = spec->dac_nids;
3555 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
3557 if (spec->board_config < 0) {
3558 printk(KERN_WARNING "hda_codec: No auto-config is "
3559 "available, default to model=ref\n");
3560 spec->board_config = STAC_D945_REF;
3566 stac92xx_free(codec);
3570 codec->patch_ops = stac92xx_patch_ops;
3572 /* Fix Mux capture level; max to 2 */
3573 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3574 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3575 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3576 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3577 (0 << AC_AMPCAP_MUTE_SHIFT));
3582 static int patch_stac927x(struct hda_codec *codec)
3584 struct sigmatel_spec *spec;
3587 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3592 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3593 spec->pin_nids = stac927x_pin_nids;
3594 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3598 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3599 if (spec->board_config < 0)
3600 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3601 "STAC927x, using BIOS defaults\n");
3602 err = stac92xx_save_bios_config_regs(codec);
3604 stac92xx_free(codec);
3607 spec->pin_configs = spec->bios_pin_configs;
3609 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3610 stac92xx_set_config_regs(codec);
3613 spec->adc_nids = stac927x_adc_nids;
3614 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3615 spec->mux_nids = stac927x_mux_nids;
3616 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3617 spec->dac_list = stac927x_dac_nids;
3618 spec->multiout.dac_nids = spec->dac_nids;
3620 switch (spec->board_config) {
3623 /* GPIO0 High = Enable EAPD */
3624 spec->gpio_mask = spec->gpio_dir = 0x01;
3625 spec->gpio_data = 0x01;
3626 spec->num_dmics = 0;
3628 spec->init = d965_core_init;
3629 spec->mixer = stac927x_mixer;
3631 case STAC_DELL_BIOS:
3632 /* correct the front output jack as a hp out */
3633 stac92xx_set_config_reg(codec, 0x0f, 0x02270110);
3634 /* correct the front input jack as a mic */
3635 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3638 /* GPIO2 High = Enable EAPD */
3639 spec->gpio_mask = spec->gpio_dir = 0x04;
3640 spec->gpio_data = 0x04;
3641 spec->dmic_nids = stac927x_dmic_nids;
3642 spec->num_dmics = STAC927X_NUM_DMICS;
3644 spec->init = d965_core_init;
3645 spec->mixer = stac927x_mixer;
3646 spec->dmux_nids = stac927x_dmux_nids;
3647 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3650 /* GPIO0 High = Enable EAPD */
3651 spec->gpio_mask = spec->gpio_dir = 0x1;
3652 spec->gpio_data = 0x01;
3653 spec->num_dmics = 0;
3655 spec->init = stac927x_core_init;
3656 spec->mixer = stac927x_mixer;
3660 spec->aloopback_mask = 0x40;
3661 spec->aloopback_shift = 0;
3663 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3665 if (spec->board_config < 0) {
3666 printk(KERN_WARNING "hda_codec: No auto-config is "
3667 "available, default to model=ref\n");
3668 spec->board_config = STAC_D965_REF;
3674 stac92xx_free(codec);
3678 codec->patch_ops = stac92xx_patch_ops;
3682 * The STAC927x seem to require fairly long delays for certain
3683 * command sequences. With too short delays (even if the answer
3684 * is set to RIRB properly), it results in the silence output
3685 * on some hardwares like Dell.
3687 * The below flag enables the longer delay (see get_response
3690 codec->bus->needs_damn_long_delay = 1;
3695 static int patch_stac9205(struct hda_codec *codec)
3697 struct sigmatel_spec *spec;
3700 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3705 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
3706 spec->pin_nids = stac9205_pin_nids;
3707 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
3711 if (spec->board_config < 0) {
3712 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
3713 err = stac92xx_save_bios_config_regs(codec);
3715 stac92xx_free(codec);
3718 spec->pin_configs = spec->bios_pin_configs;
3720 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
3721 stac92xx_set_config_regs(codec);
3724 spec->adc_nids = stac9205_adc_nids;
3725 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
3726 spec->mux_nids = stac9205_mux_nids;
3727 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
3728 spec->dmic_nids = stac9205_dmic_nids;
3729 spec->num_dmics = STAC9205_NUM_DMICS;
3730 spec->dmux_nids = stac9205_dmux_nids;
3731 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
3734 spec->init = stac9205_core_init;
3735 spec->mixer = stac9205_mixer;
3737 spec->aloopback_mask = 0x40;
3738 spec->aloopback_shift = 0;
3739 spec->multiout.dac_nids = spec->dac_nids;
3741 switch (spec->board_config){
3742 case STAC_9205_DELL_M43:
3743 /* Enable SPDIF in/out */
3744 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3745 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
3747 /* Enable unsol response for GPIO4/Dock HP connection */
3748 snd_hda_codec_write(codec, codec->afg, 0,
3749 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
3750 snd_hda_codec_write_cache(codec, codec->afg, 0,
3751 AC_VERB_SET_UNSOLICITED_ENABLE,
3752 (AC_USRSP_EN | STAC_HP_EVENT));
3754 spec->gpio_dir = 0x0b;
3755 spec->gpio_mask = 0x1b;
3756 spec->gpio_mute = 0x10;
3757 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
3760 spec->gpio_data = 0x01;
3763 /* GPIO0 High = EAPD */
3764 spec->gpio_mask = spec->gpio_dir = 0x1;
3765 spec->gpio_data = 0x01;
3769 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
3771 if (spec->board_config < 0) {
3772 printk(KERN_WARNING "hda_codec: No auto-config is "
3773 "available, default to model=ref\n");
3774 spec->board_config = STAC_9205_REF;
3780 stac92xx_free(codec);
3784 codec->patch_ops = stac92xx_patch_ops;
3793 /* static config for Sony VAIO FE550G and Sony VAIO AR */
3794 static hda_nid_t vaio_dacs[] = { 0x2 };
3795 #define VAIO_HP_DAC 0x5
3796 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
3797 static hda_nid_t vaio_mux_nids[] = { 0x15 };
3799 static struct hda_input_mux vaio_mux = {
3802 /* { "HP", 0x0 }, */
3803 { "Mic Jack", 0x1 },
3804 { "Internal Mic", 0x2 },
3809 static struct hda_verb vaio_init[] = {
3810 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3811 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
3812 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3813 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3814 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3816 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3817 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3818 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3819 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3820 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3825 static struct hda_verb vaio_ar_init[] = {
3826 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
3827 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
3828 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
3829 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
3830 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
3831 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
3832 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
3833 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
3834 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
3835 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
3836 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
3837 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
3838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
3842 /* bind volumes of both NID 0x02 and 0x05 */
3843 static struct hda_bind_ctls vaio_bind_master_vol = {
3844 .ops = &snd_hda_bind_vol,
3846 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
3847 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
3852 /* bind volumes of both NID 0x02 and 0x05 */
3853 static struct hda_bind_ctls vaio_bind_master_sw = {
3854 .ops = &snd_hda_bind_sw,
3856 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
3857 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
3862 static struct snd_kcontrol_new vaio_mixer[] = {
3863 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
3864 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
3865 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
3866 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
3867 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
3869 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3870 .name = "Capture Source",
3872 .info = stac92xx_mux_enum_info,
3873 .get = stac92xx_mux_enum_get,
3874 .put = stac92xx_mux_enum_put,
3879 static struct snd_kcontrol_new vaio_ar_mixer[] = {
3880 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
3881 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
3882 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
3883 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
3884 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
3885 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
3886 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
3888 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3889 .name = "Capture Source",
3891 .info = stac92xx_mux_enum_info,
3892 .get = stac92xx_mux_enum_get,
3893 .put = stac92xx_mux_enum_put,
3898 static struct hda_codec_ops stac9872_patch_ops = {
3899 .build_controls = stac92xx_build_controls,
3900 .build_pcms = stac92xx_build_pcms,
3901 .init = stac92xx_init,
3902 .free = stac92xx_free,
3903 #ifdef SND_HDA_NEEDS_RESUME
3904 .resume = stac92xx_resume,
3908 static int stac9872_vaio_init(struct hda_codec *codec)
3912 err = stac92xx_init(codec);
3915 if (codec->patch_ops.unsol_event)
3916 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3920 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
3922 if (get_hp_pin_presence(codec, 0x0a)) {
3923 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
3924 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
3926 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
3927 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
3931 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
3933 switch (res >> 26) {
3935 stac9872_vaio_hp_detect(codec, res);
3940 static struct hda_codec_ops stac9872_vaio_patch_ops = {
3941 .build_controls = stac92xx_build_controls,
3942 .build_pcms = stac92xx_build_pcms,
3943 .init = stac9872_vaio_init,
3944 .free = stac92xx_free,
3945 .unsol_event = stac9872_vaio_unsol_event,
3947 .resume = stac92xx_resume,
3951 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
3953 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
3955 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
3957 /* AR Series. id=0x83847664 and subsys=104D1300 */
3962 static const char *stac9872_models[STAC_9872_MODELS] = {
3963 [CXD9872RD_VAIO] = "vaio",
3964 [CXD9872AKD_VAIO] = "vaio-ar",
3967 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
3968 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
3969 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
3970 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
3971 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
3975 static int patch_stac9872(struct hda_codec *codec)
3977 struct sigmatel_spec *spec;
3980 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
3983 if (board_config < 0)
3984 /* unknown config, let generic-parser do its job... */
3985 return snd_hda_parse_generic_codec(codec);
3987 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3992 switch (board_config) {
3993 case CXD9872RD_VAIO:
3994 case STAC9872AK_VAIO:
3995 case STAC9872K_VAIO:
3996 spec->mixer = vaio_mixer;
3997 spec->init = vaio_init;
3998 spec->multiout.max_channels = 2;
3999 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4000 spec->multiout.dac_nids = vaio_dacs;
4001 spec->multiout.hp_nid = VAIO_HP_DAC;
4002 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4003 spec->adc_nids = vaio_adcs;
4005 spec->input_mux = &vaio_mux;
4006 spec->mux_nids = vaio_mux_nids;
4007 codec->patch_ops = stac9872_vaio_patch_ops;
4010 case CXD9872AKD_VAIO:
4011 spec->mixer = vaio_ar_mixer;
4012 spec->init = vaio_ar_init;
4013 spec->multiout.max_channels = 2;
4014 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4015 spec->multiout.dac_nids = vaio_dacs;
4016 spec->multiout.hp_nid = VAIO_HP_DAC;
4017 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4019 spec->adc_nids = vaio_adcs;
4020 spec->input_mux = &vaio_mux;
4021 spec->mux_nids = vaio_mux_nids;
4022 codec->patch_ops = stac9872_patch_ops;
4033 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4034 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4035 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4036 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4037 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4038 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4039 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4040 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4041 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4042 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4043 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4044 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4045 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4046 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4047 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4048 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4049 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4050 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4051 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4052 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4053 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4054 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4055 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4056 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
4057 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4058 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4059 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4060 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4061 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4062 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4063 /* The following does not take into account .id=0x83847661 when subsys =
4064 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4065 * currently not fully supported.
4067 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4068 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4069 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
4070 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4071 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4072 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4073 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4074 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4075 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4076 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4077 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4078 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4079 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4080 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4081 { .id = 0x111d7608, .name = "92HD71BXX", .patch = patch_stac92hd71bxx },
4082 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4083 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4084 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4085 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4086 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4087 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4088 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4089 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },