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"
35 #include "hda_patch.h"
37 #define NUM_CONTROL_ALLOC 32
38 #define STAC_PWR_EVENT 0x20
39 #define STAC_HP_EVENT 0x30
97 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
98 * is given, one of the above models will be
99 * chosen according to the subsystem id. */
100 /* for backward compatibility */
123 struct sigmatel_spec {
124 struct snd_kcontrol_new *mixers[4];
125 unsigned int num_mixers;
128 unsigned int surr_switch: 1;
129 unsigned int line_switch: 1;
130 unsigned int mic_switch: 1;
131 unsigned int alt_switch: 1;
132 unsigned int hp_detect: 1;
135 unsigned int eapd_mask;
136 unsigned int gpio_mask;
137 unsigned int gpio_dir;
138 unsigned int gpio_data;
139 unsigned int gpio_mute;
141 /* analog loopback */
142 unsigned char aloopback_mask;
143 unsigned char aloopback_shift;
145 /* power management */
146 unsigned int num_pwrs;
151 struct hda_input_mux *mono_mux;
152 unsigned int cur_mmux;
153 struct hda_multi_out multiout;
154 hda_nid_t dac_nids[5];
158 unsigned int num_adcs;
160 unsigned int num_muxes;
161 hda_nid_t *dmic_nids;
162 unsigned int num_dmics;
163 hda_nid_t *dmux_nids;
164 unsigned int num_dmuxes;
165 hda_nid_t dig_in_nid;
170 unsigned int num_pins;
171 unsigned int *pin_configs;
172 unsigned int *bios_pin_configs;
174 /* codec specific stuff */
175 struct hda_verb *init;
176 struct snd_kcontrol_new *mixer;
179 struct hda_input_mux *dinput_mux;
180 unsigned int cur_dmux[2];
181 struct hda_input_mux *input_mux;
182 unsigned int cur_mux[3];
185 unsigned int io_switch[2];
186 unsigned int clfe_swap;
187 unsigned int hp_switch;
188 unsigned int aloopback;
190 struct hda_pcm pcm_rec[2]; /* PCM information */
192 /* dynamic controls and input_mux */
193 struct auto_pin_cfg autocfg;
194 unsigned int num_kctl_alloc, num_kctl_used;
195 struct snd_kcontrol_new *kctl_alloc;
196 struct hda_input_mux private_dimux;
197 struct hda_input_mux private_imux;
198 struct hda_input_mux private_mono_mux;
201 static hda_nid_t stac9200_adc_nids[1] = {
205 static hda_nid_t stac9200_mux_nids[1] = {
209 static hda_nid_t stac9200_dac_nids[1] = {
213 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
214 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
218 static hda_nid_t stac92hd73xx_adc_nids[2] = {
222 #define STAC92HD73XX_NUM_DMICS 2
223 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
227 #define STAC92HD73_DAC_COUNT 5
228 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
229 0x15, 0x16, 0x17, 0x18, 0x19,
232 static hda_nid_t stac92hd73xx_mux_nids[4] = {
233 0x28, 0x29, 0x2a, 0x2b,
236 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
240 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
244 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
248 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
252 static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
256 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
260 #define STAC92HD71BXX_NUM_DMICS 2
261 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
265 static hda_nid_t stac925x_adc_nids[1] = {
269 static hda_nid_t stac925x_mux_nids[1] = {
273 static hda_nid_t stac925x_dac_nids[1] = {
277 #define STAC925X_NUM_DMICS 1
278 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
282 static hda_nid_t stac925x_dmux_nids[1] = {
286 static hda_nid_t stac922x_adc_nids[2] = {
290 static hda_nid_t stac922x_mux_nids[2] = {
294 static hda_nid_t stac927x_adc_nids[3] = {
298 static hda_nid_t stac927x_mux_nids[3] = {
302 static hda_nid_t stac927x_dac_nids[6] = {
303 0x02, 0x03, 0x04, 0x05, 0x06, 0
306 static hda_nid_t stac927x_dmux_nids[1] = {
310 #define STAC927X_NUM_DMICS 2
311 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
315 static hda_nid_t stac9205_adc_nids[2] = {
319 static hda_nid_t stac9205_mux_nids[2] = {
323 static hda_nid_t stac9205_dmux_nids[1] = {
327 #define STAC9205_NUM_DMICS 2
328 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
332 static hda_nid_t stac9200_pin_nids[8] = {
333 0x08, 0x09, 0x0d, 0x0e,
334 0x0f, 0x10, 0x11, 0x12,
337 static hda_nid_t stac925x_pin_nids[8] = {
338 0x07, 0x08, 0x0a, 0x0b,
339 0x0c, 0x0d, 0x10, 0x11,
342 static hda_nid_t stac922x_pin_nids[10] = {
343 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
344 0x0f, 0x10, 0x11, 0x15, 0x1b,
347 static hda_nid_t stac92hd73xx_pin_nids[13] = {
348 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
349 0x0f, 0x10, 0x11, 0x12, 0x13,
353 static hda_nid_t stac92hd71bxx_pin_nids[10] = {
354 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
355 0x0f, 0x14, 0x18, 0x19, 0x1e,
358 static hda_nid_t stac927x_pin_nids[14] = {
359 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
360 0x0f, 0x10, 0x11, 0x12, 0x13,
361 0x14, 0x21, 0x22, 0x23,
364 static hda_nid_t stac9205_pin_nids[12] = {
365 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
366 0x0f, 0x14, 0x16, 0x17, 0x18,
370 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_info *uinfo)
373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
374 struct sigmatel_spec *spec = codec->spec;
375 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
378 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
379 struct snd_ctl_elem_value *ucontrol)
381 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
382 struct sigmatel_spec *spec = codec->spec;
383 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
385 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
389 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
390 struct snd_ctl_elem_value *ucontrol)
392 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
393 struct sigmatel_spec *spec = codec->spec;
394 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
396 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
397 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
400 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
402 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
403 struct sigmatel_spec *spec = codec->spec;
404 return snd_hda_input_mux_info(spec->input_mux, uinfo);
407 static int stac92xx_mux_enum_get(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 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
417 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
419 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
420 struct sigmatel_spec *spec = codec->spec;
421 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
423 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
424 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
427 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
428 struct snd_ctl_elem_info *uinfo)
430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
431 struct sigmatel_spec *spec = codec->spec;
432 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
435 static int stac92xx_mono_mux_enum_get(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 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
445 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_value *ucontrol)
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct sigmatel_spec *spec = codec->spec;
451 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
452 spec->mono_nid, &spec->cur_mmux);
455 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
457 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
458 struct snd_ctl_elem_value *ucontrol)
460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
462 struct sigmatel_spec *spec = codec->spec;
464 ucontrol->value.integer.value[0] = !!(spec->aloopback &
465 (spec->aloopback_mask << idx));
469 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct sigmatel_spec *spec = codec->spec;
474 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
475 unsigned int dac_mode;
476 unsigned int val, idx_val;
478 idx_val = spec->aloopback_mask << idx;
479 if (ucontrol->value.integer.value[0])
480 val = spec->aloopback | idx_val;
482 val = spec->aloopback & ~idx_val;
483 if (spec->aloopback == val)
486 spec->aloopback = val;
488 /* Only return the bits defined by the shift value of the
489 * first two bytes of the mask
491 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
492 kcontrol->private_value & 0xFFFF, 0x0);
493 dac_mode >>= spec->aloopback_shift;
495 if (spec->aloopback & idx_val) {
496 snd_hda_power_up(codec);
499 snd_hda_power_down(codec);
500 dac_mode &= ~idx_val;
503 snd_hda_codec_write_cache(codec, codec->afg, 0,
504 kcontrol->private_value >> 16, dac_mode);
509 static struct hda_verb stac9200_core_init[] = {
510 /* set dac0mux for dac converter */
511 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
515 static struct hda_verb stac9200_eapd_init[] = {
516 /* set dac0mux for dac converter */
517 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
518 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
522 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
523 /* set master volume and direct control */
524 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
525 /* setup audio connections */
526 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
527 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
528 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
529 /* setup adcs to point to mixer */
530 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
531 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
532 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
533 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
534 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
535 /* setup import muxs */
536 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
537 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
538 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
539 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
543 static struct hda_verb dell_eq_core_init[] = {
544 /* set master volume to max value without distortion
545 * and direct control */
546 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
547 /* setup audio connections */
548 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
549 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
550 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
551 /* setup adcs to point to mixer */
552 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
553 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
554 /* setup import muxs */
555 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
556 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
557 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
558 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
562 static struct hda_verb dell_m6_core_init[] = {
563 /* set master volume to max value without distortion
564 * and direct control */
565 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
566 /* setup audio connections */
567 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
568 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
569 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
570 /* setup adcs to point to mixer */
571 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
572 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
573 /* setup import muxs */
574 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
575 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
576 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
577 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
581 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
582 /* set master volume and direct control */
583 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
584 /* setup audio connections */
585 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
586 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
587 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
588 /* connect hp ports to dac3 */
589 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
590 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
591 /* setup adcs to point to mixer */
592 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
593 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
594 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
595 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
596 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
597 /* setup import muxs */
598 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
599 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
600 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
601 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
605 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
606 /* set master volume and direct control */
607 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
608 /* setup audio connections */
609 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
610 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
611 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
612 /* dac3 is connected to import3 mux */
613 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
614 /* connect hp ports to dac4 */
615 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
616 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
617 /* setup adcs to point to mixer */
618 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
619 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
620 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
621 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
622 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
623 /* setup import muxs */
624 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
625 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
626 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
627 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
631 static struct hda_verb stac92hd71bxx_core_init[] = {
632 /* set master volume and direct control */
633 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
634 /* connect headphone jack to dac1 */
635 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
636 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
637 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
638 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
639 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
640 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
643 #define HD_DISABLE_PORTF 3
644 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
645 /* start of config #1 */
647 /* connect port 0f to audio mixer */
648 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
649 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
650 /* unmute right and left channels for node 0x0f */
651 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
652 /* start of config #2 */
654 /* set master volume and direct control */
655 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
656 /* connect headphone jack to dac1 */
657 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
658 /* connect port 0d to audio mixer */
659 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
660 /* unmute dac0 input in audio mixer */
661 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
662 /* unmute right and left channels for nodes 0x0a, 0xd */
663 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
664 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
668 static struct hda_verb stac925x_core_init[] = {
669 /* set dac0mux for dac converter */
670 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
674 static struct hda_verb stac922x_core_init[] = {
675 /* set master volume and direct control */
676 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
680 static struct hda_verb d965_core_init[] = {
681 /* set master volume and direct control */
682 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
683 /* unmute node 0x1b */
684 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
685 /* select node 0x03 as DAC */
686 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
690 static struct hda_verb stac927x_core_init[] = {
691 /* set master volume and direct control */
692 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
696 static struct hda_verb stac9205_core_init[] = {
697 /* set master volume and direct control */
698 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
702 #define STAC_MONO_MUX \
704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
705 .name = "Mono Mux", \
707 .info = stac92xx_mono_mux_enum_info, \
708 .get = stac92xx_mono_mux_enum_get, \
709 .put = stac92xx_mono_mux_enum_put, \
712 #define STAC_INPUT_SOURCE(cnt) \
714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
715 .name = "Input Source", \
717 .info = stac92xx_mux_enum_info, \
718 .get = stac92xx_mux_enum_get, \
719 .put = stac92xx_mux_enum_put, \
722 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
725 .name = "Analog Loopback", \
727 .info = stac92xx_aloopback_info, \
728 .get = stac92xx_aloopback_get, \
729 .put = stac92xx_aloopback_put, \
730 .private_value = verb_read | (verb_write << 16), \
733 static struct snd_kcontrol_new stac9200_mixer[] = {
734 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
735 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
736 STAC_INPUT_SOURCE(1),
737 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
738 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
739 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
743 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
744 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
746 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
747 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
749 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
750 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
752 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
753 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
755 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
756 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
758 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
759 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
761 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
762 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
764 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
765 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
769 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
770 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
772 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
773 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
775 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
776 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
778 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
779 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
781 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
782 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
784 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
785 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
787 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
788 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
790 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
791 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
795 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
796 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
798 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
799 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
801 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
802 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
804 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
805 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
807 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
808 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
810 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
811 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
813 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
814 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
816 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
817 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
821 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
822 STAC_INPUT_SOURCE(2),
824 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
825 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
826 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
828 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
829 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
830 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
832 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
833 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
835 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
836 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
840 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
841 STAC_INPUT_SOURCE(2),
842 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
844 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
845 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
846 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
848 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
849 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
850 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
854 static struct snd_kcontrol_new stac925x_mixer[] = {
855 STAC_INPUT_SOURCE(1),
856 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
857 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
858 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
862 static struct snd_kcontrol_new stac9205_mixer[] = {
863 STAC_INPUT_SOURCE(2),
864 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
866 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
867 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
868 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
870 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
871 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
872 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
877 /* This needs to be generated dynamically based on sequence */
878 static struct snd_kcontrol_new stac922x_mixer[] = {
879 STAC_INPUT_SOURCE(2),
880 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
881 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
882 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
884 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
885 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
886 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
891 static struct snd_kcontrol_new stac927x_mixer[] = {
892 STAC_INPUT_SOURCE(3),
893 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
895 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
896 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
897 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
899 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
900 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
901 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
903 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
904 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
905 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
909 static struct snd_kcontrol_new stac_dmux_mixer = {
910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
911 .name = "Digital Input Source",
912 /* count set later */
913 .info = stac92xx_dmux_enum_info,
914 .get = stac92xx_dmux_enum_get,
915 .put = stac92xx_dmux_enum_put,
918 static const char *slave_vols[] = {
919 "Front Playback Volume",
920 "Surround Playback Volume",
921 "Center Playback Volume",
922 "LFE Playback Volume",
923 "Side Playback Volume",
924 "Headphone Playback Volume",
925 "Headphone Playback Volume",
926 "Speaker Playback Volume",
927 "External Speaker Playback Volume",
928 "Speaker2 Playback Volume",
932 static const char *slave_sws[] = {
933 "Front Playback Switch",
934 "Surround Playback Switch",
935 "Center Playback Switch",
936 "LFE Playback Switch",
937 "Side Playback Switch",
938 "Headphone Playback Switch",
939 "Headphone Playback Switch",
940 "Speaker Playback Switch",
941 "External Speaker Playback Switch",
942 "Speaker2 Playback Switch",
943 "IEC958 Playback Switch",
947 static int stac92xx_build_controls(struct hda_codec *codec)
949 struct sigmatel_spec *spec = codec->spec;
953 err = snd_hda_add_new_ctls(codec, spec->mixer);
957 for (i = 0; i < spec->num_mixers; i++) {
958 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
962 if (spec->num_dmuxes > 0) {
963 stac_dmux_mixer.count = spec->num_dmuxes;
964 err = snd_ctl_add(codec->bus->card,
965 snd_ctl_new1(&stac_dmux_mixer, codec));
970 if (spec->multiout.dig_out_nid) {
971 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
974 err = snd_hda_create_spdif_share_sw(codec,
978 spec->multiout.share_spdif = 1;
980 if (spec->dig_in_nid) {
981 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
986 /* if we have no master control, let's create it */
987 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
988 unsigned int vmaster_tlv[4];
989 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
990 HDA_OUTPUT, vmaster_tlv);
991 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
992 vmaster_tlv, slave_vols);
996 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
997 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1006 static unsigned int ref9200_pin_configs[8] = {
1007 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1008 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1012 STAC 9200 pin configs for
1017 static unsigned int dell9200_d21_pin_configs[8] = {
1018 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1019 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1023 STAC 9200 pin configs for
1027 static unsigned int dell9200_d22_pin_configs[8] = {
1028 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1029 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1033 STAC 9200 pin configs for
1034 102801C4 (Dell Dimension E310)
1041 static unsigned int dell9200_d23_pin_configs[8] = {
1042 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1043 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1048 STAC 9200-32 pin configs for
1049 102801B5 (Dell Inspiron 630m)
1050 102801D8 (Dell Inspiron 640m)
1052 static unsigned int dell9200_m21_pin_configs[8] = {
1053 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1054 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1058 STAC 9200-32 pin configs for
1059 102801C2 (Dell Latitude D620)
1061 102801CC (Dell Latitude D820)
1065 static unsigned int dell9200_m22_pin_configs[8] = {
1066 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1067 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1071 STAC 9200-32 pin configs for
1072 102801CE (Dell XPS M1710)
1073 102801CF (Dell Precision M90)
1075 static unsigned int dell9200_m23_pin_configs[8] = {
1076 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1077 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1081 STAC 9200-32 pin configs for
1084 102801CB (Dell Latitude 120L)
1087 static unsigned int dell9200_m24_pin_configs[8] = {
1088 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1089 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1093 STAC 9200-32 pin configs for
1094 102801BD (Dell Inspiron E1505n)
1098 static unsigned int dell9200_m25_pin_configs[8] = {
1099 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1100 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1104 STAC 9200-32 pin configs for
1105 102801F5 (Dell Inspiron 1501)
1108 static unsigned int dell9200_m26_pin_configs[8] = {
1109 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1110 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1115 102801CD (Dell Inspiron E1705/9400)
1117 static unsigned int dell9200_m27_pin_configs[8] = {
1118 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1119 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1122 static unsigned int oqo9200_pin_configs[8] = {
1123 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1124 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1128 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1129 [STAC_REF] = ref9200_pin_configs,
1130 [STAC_9200_OQO] = oqo9200_pin_configs,
1131 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1132 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1133 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1134 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1135 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1136 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1137 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1138 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1139 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1140 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1141 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1144 static const char *stac9200_models[STAC_9200_MODELS] = {
1146 [STAC_9200_OQO] = "oqo",
1147 [STAC_9200_DELL_D21] = "dell-d21",
1148 [STAC_9200_DELL_D22] = "dell-d22",
1149 [STAC_9200_DELL_D23] = "dell-d23",
1150 [STAC_9200_DELL_M21] = "dell-m21",
1151 [STAC_9200_DELL_M22] = "dell-m22",
1152 [STAC_9200_DELL_M23] = "dell-m23",
1153 [STAC_9200_DELL_M24] = "dell-m24",
1154 [STAC_9200_DELL_M25] = "dell-m25",
1155 [STAC_9200_DELL_M26] = "dell-m26",
1156 [STAC_9200_DELL_M27] = "dell-m27",
1157 [STAC_9200_GATEWAY] = "gateway",
1158 [STAC_9200_PANASONIC] = "panasonic",
1161 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1162 /* SigmaTel reference board */
1163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1164 "DFI LanParty", STAC_REF),
1165 /* Dell laptops have BIOS problem */
1166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1167 "unknown Dell", STAC_9200_DELL_D21),
1168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1169 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1171 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1173 "unknown Dell", STAC_9200_DELL_D22),
1174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1175 "unknown Dell", STAC_9200_DELL_D22),
1176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1177 "Dell Latitude D620", STAC_9200_DELL_M22),
1178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1179 "unknown Dell", STAC_9200_DELL_D23),
1180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1181 "unknown Dell", STAC_9200_DELL_D23),
1182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1183 "unknown Dell", STAC_9200_DELL_M22),
1184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1185 "unknown Dell", STAC_9200_DELL_M24),
1186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1187 "unknown Dell", STAC_9200_DELL_M24),
1188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1189 "Dell Latitude 120L", STAC_9200_DELL_M24),
1190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1191 "Dell Latitude D820", STAC_9200_DELL_M22),
1192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1193 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1195 "Dell XPS M1710", STAC_9200_DELL_M23),
1196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1197 "Dell Precision M90", STAC_9200_DELL_M23),
1198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1199 "unknown Dell", STAC_9200_DELL_M22),
1200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1201 "unknown Dell", STAC_9200_DELL_M22),
1202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1203 "unknown Dell", STAC_9200_DELL_M22),
1204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1205 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1207 "unknown Dell", STAC_9200_DELL_D23),
1208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1209 "unknown Dell", STAC_9200_DELL_D23),
1210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1211 "unknown Dell", STAC_9200_DELL_D21),
1212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1213 "unknown Dell", STAC_9200_DELL_D23),
1214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1215 "unknown Dell", STAC_9200_DELL_D21),
1216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1217 "unknown Dell", STAC_9200_DELL_M25),
1218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1219 "unknown Dell", STAC_9200_DELL_M25),
1220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1221 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1223 "unknown Dell", STAC_9200_DELL_M26),
1225 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1226 /* Gateway machines needs EAPD to be set on resume */
1227 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1228 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1230 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1233 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1237 static unsigned int ref925x_pin_configs[8] = {
1238 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1239 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1242 static unsigned int stac925x_MA6_pin_configs[8] = {
1243 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1244 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1247 static unsigned int stac925x_PA6_pin_configs[8] = {
1248 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1249 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1252 static unsigned int stac925xM2_2_pin_configs[8] = {
1253 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1254 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1257 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1258 [STAC_REF] = ref925x_pin_configs,
1259 [STAC_M2_2] = stac925xM2_2_pin_configs,
1260 [STAC_MA6] = stac925x_MA6_pin_configs,
1261 [STAC_PA6] = stac925x_PA6_pin_configs,
1264 static const char *stac925x_models[STAC_925x_MODELS] = {
1266 [STAC_M2_2] = "m2-2",
1271 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1272 /* SigmaTel reference board */
1273 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1274 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1275 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1276 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1277 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1278 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1279 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1283 static unsigned int ref92hd73xx_pin_configs[13] = {
1284 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1285 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1286 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1290 static unsigned int dell_m6_pin_configs[13] = {
1291 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1292 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1293 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1297 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1298 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1299 [STAC_DELL_M6] = dell_m6_pin_configs,
1302 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1303 [STAC_92HD73XX_REF] = "ref",
1304 [STAC_DELL_M6] = "dell-m6",
1307 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1308 /* SigmaTel reference board */
1309 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1310 "DFI LanParty", STAC_92HD73XX_REF),
1311 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1312 "unknown Dell", STAC_DELL_M6),
1313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1314 "unknown Dell", STAC_DELL_M6),
1315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1316 "unknown Dell", STAC_DELL_M6),
1317 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1318 "unknown Dell", STAC_DELL_M6),
1319 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1320 "unknown Dell", STAC_DELL_M6),
1321 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1322 "unknown Dell", STAC_DELL_M6),
1323 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1324 "unknown Dell", STAC_DELL_M6),
1328 static unsigned int ref92hd71bxx_pin_configs[10] = {
1329 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1330 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1331 0x90a000f0, 0x01452050,
1334 static unsigned int dell_m4_1_pin_configs[10] = {
1335 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1336 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1337 0x40f000f0, 0x4f0000f0,
1340 static unsigned int dell_m4_2_pin_configs[10] = {
1341 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1342 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1343 0x40f000f0, 0x044413b0,
1346 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1347 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1348 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1349 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1352 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1353 [STAC_92HD71BXX_REF] = "ref",
1354 [STAC_DELL_M4_1] = "dell-m4-1",
1355 [STAC_DELL_M4_2] = "dell-m4-2",
1358 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1359 /* SigmaTel reference board */
1360 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1361 "DFI LanParty", STAC_92HD71BXX_REF),
1362 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1363 "unknown Dell", STAC_DELL_M4_1),
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1365 "unknown Dell", STAC_DELL_M4_1),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1367 "unknown Dell", STAC_DELL_M4_1),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1369 "unknown Dell", STAC_DELL_M4_1),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1371 "unknown Dell", STAC_DELL_M4_1),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1373 "unknown Dell", STAC_DELL_M4_1),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1375 "unknown Dell", STAC_DELL_M4_1),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1377 "unknown Dell", STAC_DELL_M4_2),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1379 "unknown Dell", STAC_DELL_M4_2),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1381 "unknown Dell", STAC_DELL_M4_2),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1383 "unknown Dell", STAC_DELL_M4_2),
1387 static unsigned int ref922x_pin_configs[10] = {
1388 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1389 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1390 0x40000100, 0x40000100,
1394 STAC 922X pin configs for
1401 static unsigned int dell_922x_d81_pin_configs[10] = {
1402 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1403 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1404 0x01813122, 0x400001f2,
1408 STAC 922X pin configs for
1412 static unsigned int dell_922x_d82_pin_configs[10] = {
1413 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1414 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1415 0x01813122, 0x400001f1,
1419 STAC 922X pin configs for
1422 static unsigned int dell_922x_m81_pin_configs[10] = {
1423 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1424 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1425 0x40C003f1, 0x405003f0,
1429 STAC 9221 A1 pin configs for
1430 102801D7 (Dell XPS M1210)
1432 static unsigned int dell_922x_m82_pin_configs[10] = {
1433 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1434 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1435 0x508003f3, 0x405003f4,
1438 static unsigned int d945gtp3_pin_configs[10] = {
1439 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1440 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1441 0x02a19120, 0x40000100,
1444 static unsigned int d945gtp5_pin_configs[10] = {
1445 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1446 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1447 0x02a19320, 0x40000100,
1450 static unsigned int intel_mac_v1_pin_configs[10] = {
1451 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1452 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1453 0x400000fc, 0x400000fb,
1456 static unsigned int intel_mac_v2_pin_configs[10] = {
1457 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1458 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1459 0x400000fc, 0x400000fb,
1462 static unsigned int intel_mac_v3_pin_configs[10] = {
1463 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1464 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1465 0x400000fc, 0x400000fb,
1468 static unsigned int intel_mac_v4_pin_configs[10] = {
1469 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1470 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1471 0x400000fc, 0x400000fb,
1474 static unsigned int intel_mac_v5_pin_configs[10] = {
1475 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1476 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1477 0x400000fc, 0x400000fb,
1481 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1482 [STAC_D945_REF] = ref922x_pin_configs,
1483 [STAC_D945GTP3] = d945gtp3_pin_configs,
1484 [STAC_D945GTP5] = d945gtp5_pin_configs,
1485 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1486 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1487 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1488 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1489 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1490 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1491 /* for backward compatibility */
1492 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1493 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1494 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1495 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1496 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1497 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1498 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1499 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1500 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1501 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1504 static const char *stac922x_models[STAC_922X_MODELS] = {
1505 [STAC_D945_REF] = "ref",
1506 [STAC_D945GTP5] = "5stack",
1507 [STAC_D945GTP3] = "3stack",
1508 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1509 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1510 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1511 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1512 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1513 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1514 /* for backward compatibility */
1515 [STAC_MACMINI] = "macmini",
1516 [STAC_MACBOOK] = "macbook",
1517 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1518 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1519 [STAC_IMAC_INTEL] = "imac-intel",
1520 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1521 [STAC_922X_DELL_D81] = "dell-d81",
1522 [STAC_922X_DELL_D82] = "dell-d82",
1523 [STAC_922X_DELL_M81] = "dell-m81",
1524 [STAC_922X_DELL_M82] = "dell-m82",
1527 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1528 /* SigmaTel reference board */
1529 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1530 "DFI LanParty", STAC_D945_REF),
1531 /* Intel 945G based systems */
1532 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1533 "Intel D945G", STAC_D945GTP3),
1534 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1535 "Intel D945G", STAC_D945GTP3),
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1537 "Intel D945G", STAC_D945GTP3),
1538 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1539 "Intel D945G", STAC_D945GTP3),
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1541 "Intel D945G", STAC_D945GTP3),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1543 "Intel D945G", STAC_D945GTP3),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1545 "Intel D945G", STAC_D945GTP3),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1547 "Intel D945G", STAC_D945GTP3),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1549 "Intel D945G", STAC_D945GTP3),
1550 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1551 "Intel D945G", STAC_D945GTP3),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1553 "Intel D945G", STAC_D945GTP3),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1555 "Intel D945G", STAC_D945GTP3),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1557 "Intel D945G", STAC_D945GTP3),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1559 "Intel D945G", STAC_D945GTP3),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1561 "Intel D945G", STAC_D945GTP3),
1562 /* Intel D945G 5-stack systems */
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1564 "Intel D945G", STAC_D945GTP5),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1566 "Intel D945G", STAC_D945GTP5),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1568 "Intel D945G", STAC_D945GTP5),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1570 "Intel D945G", STAC_D945GTP5),
1571 /* Intel 945P based systems */
1572 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1573 "Intel D945P", STAC_D945GTP3),
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1575 "Intel D945P", STAC_D945GTP3),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1577 "Intel D945P", STAC_D945GTP3),
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1579 "Intel D945P", STAC_D945GTP3),
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1581 "Intel D945P", STAC_D945GTP3),
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1583 "Intel D945P", STAC_D945GTP5),
1585 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1586 SND_PCI_QUIRK(0x8384, 0x7680,
1587 "Mac", STAC_INTEL_MAC_AUTO),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1590 "unknown Dell", STAC_922X_DELL_D81),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1592 "unknown Dell", STAC_922X_DELL_D81),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1594 "unknown Dell", STAC_922X_DELL_D81),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1596 "unknown Dell", STAC_922X_DELL_D82),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1598 "unknown Dell", STAC_922X_DELL_M81),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1600 "unknown Dell", STAC_922X_DELL_D82),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1602 "unknown Dell", STAC_922X_DELL_D81),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1604 "unknown Dell", STAC_922X_DELL_D81),
1605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1606 "Dell XPS M1210", STAC_922X_DELL_M82),
1610 static unsigned int ref927x_pin_configs[14] = {
1611 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1612 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1613 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1614 0x01c42190, 0x40000100,
1617 static unsigned int d965_3st_pin_configs[14] = {
1618 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1619 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1620 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1621 0x40000100, 0x40000100
1624 static unsigned int d965_5st_pin_configs[14] = {
1625 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1626 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1627 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1628 0x40000100, 0x40000100
1631 static unsigned int dell_3st_pin_configs[14] = {
1632 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1633 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1634 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1635 0x40c003fc, 0x40000100
1638 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1639 [STAC_D965_REF] = ref927x_pin_configs,
1640 [STAC_D965_3ST] = d965_3st_pin_configs,
1641 [STAC_D965_5ST] = d965_5st_pin_configs,
1642 [STAC_DELL_3ST] = dell_3st_pin_configs,
1643 [STAC_DELL_BIOS] = NULL,
1646 static const char *stac927x_models[STAC_927X_MODELS] = {
1647 [STAC_D965_REF] = "ref",
1648 [STAC_D965_3ST] = "3stack",
1649 [STAC_D965_5ST] = "5stack",
1650 [STAC_DELL_3ST] = "dell-3stack",
1651 [STAC_DELL_BIOS] = "dell-bios",
1654 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1655 /* SigmaTel reference board */
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1657 "DFI LanParty", STAC_D965_REF),
1658 /* Intel 946 based systems */
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1660 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1661 /* 965 based 3 stack systems */
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1678 /* Dell 3 stack systems */
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1683 /* Dell 3 stack systems with verb table in BIOS */
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell ", STAC_DELL_BIOS),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1691 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1692 /* 965 based 5 stack systems */
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1705 static unsigned int ref9205_pin_configs[12] = {
1706 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1707 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
1708 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1712 STAC 9205 pin configs for
1719 10280228 (Dell Vostro 1500)
1721 static unsigned int dell_9205_m42_pin_configs[12] = {
1722 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1723 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1724 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1728 STAC 9205 pin configs for
1732 102801FF (Dell Precision M4300)
1737 static unsigned int dell_9205_m43_pin_configs[12] = {
1738 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1739 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1740 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1743 static unsigned int dell_9205_m44_pin_configs[12] = {
1744 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1745 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1746 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1749 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1750 [STAC_9205_REF] = ref9205_pin_configs,
1751 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1752 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1753 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1756 static const char *stac9205_models[STAC_9205_MODELS] = {
1757 [STAC_9205_REF] = "ref",
1758 [STAC_9205_DELL_M42] = "dell-m42",
1759 [STAC_9205_DELL_M43] = "dell-m43",
1760 [STAC_9205_DELL_M44] = "dell-m44",
1763 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1764 /* SigmaTel reference board */
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1766 "DFI LanParty", STAC_9205_REF),
1767 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1768 "unknown Dell", STAC_9205_DELL_M42),
1769 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1770 "unknown Dell", STAC_9205_DELL_M42),
1771 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1772 "Dell Precision", STAC_9205_DELL_M43),
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1774 "Dell Precision", STAC_9205_DELL_M43),
1775 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1776 "Dell Precision", STAC_9205_DELL_M43),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1778 "unknown Dell", STAC_9205_DELL_M42),
1779 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1780 "unknown Dell", STAC_9205_DELL_M42),
1781 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1782 "Dell Precision", STAC_9205_DELL_M43),
1783 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1784 "Dell Precision M4300", STAC_9205_DELL_M43),
1785 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1786 "unknown Dell", STAC_9205_DELL_M42),
1787 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1788 "Dell Precision", STAC_9205_DELL_M43),
1789 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1790 "Dell Precision", STAC_9205_DELL_M43),
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1792 "Dell Precision", STAC_9205_DELL_M43),
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1794 "Dell Inspiron", STAC_9205_DELL_M44),
1795 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1796 "Dell Vostro 1500", STAC_9205_DELL_M42),
1800 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1803 struct sigmatel_spec *spec = codec->spec;
1805 if (! spec->bios_pin_configs) {
1806 spec->bios_pin_configs = kcalloc(spec->num_pins,
1807 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1808 if (! spec->bios_pin_configs)
1812 for (i = 0; i < spec->num_pins; i++) {
1813 hda_nid_t nid = spec->pin_nids[i];
1814 unsigned int pin_cfg;
1816 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1817 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1818 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1820 spec->bios_pin_configs[i] = pin_cfg;
1826 static void stac92xx_set_config_reg(struct hda_codec *codec,
1827 hda_nid_t pin_nid, unsigned int pin_config)
1830 snd_hda_codec_write(codec, pin_nid, 0,
1831 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1832 pin_config & 0x000000ff);
1833 snd_hda_codec_write(codec, pin_nid, 0,
1834 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1835 (pin_config & 0x0000ff00) >> 8);
1836 snd_hda_codec_write(codec, pin_nid, 0,
1837 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1838 (pin_config & 0x00ff0000) >> 16);
1839 snd_hda_codec_write(codec, pin_nid, 0,
1840 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1842 i = snd_hda_codec_read(codec, pin_nid, 0,
1843 AC_VERB_GET_CONFIG_DEFAULT,
1845 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1849 static void stac92xx_set_config_regs(struct hda_codec *codec)
1852 struct sigmatel_spec *spec = codec->spec;
1854 if (!spec->pin_configs)
1857 for (i = 0; i < spec->num_pins; i++)
1858 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1859 spec->pin_configs[i]);
1863 * Analog playback callbacks
1865 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1866 struct hda_codec *codec,
1867 struct snd_pcm_substream *substream)
1869 struct sigmatel_spec *spec = codec->spec;
1870 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1874 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1875 struct hda_codec *codec,
1876 unsigned int stream_tag,
1877 unsigned int format,
1878 struct snd_pcm_substream *substream)
1880 struct sigmatel_spec *spec = codec->spec;
1881 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1884 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1885 struct hda_codec *codec,
1886 struct snd_pcm_substream *substream)
1888 struct sigmatel_spec *spec = codec->spec;
1889 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1893 * Digital playback callbacks
1895 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1896 struct hda_codec *codec,
1897 struct snd_pcm_substream *substream)
1899 struct sigmatel_spec *spec = codec->spec;
1900 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1903 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1904 struct hda_codec *codec,
1905 struct snd_pcm_substream *substream)
1907 struct sigmatel_spec *spec = codec->spec;
1908 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1911 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1912 struct hda_codec *codec,
1913 unsigned int stream_tag,
1914 unsigned int format,
1915 struct snd_pcm_substream *substream)
1917 struct sigmatel_spec *spec = codec->spec;
1918 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1919 stream_tag, format, substream);
1924 * Analog capture callbacks
1926 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1927 struct hda_codec *codec,
1928 unsigned int stream_tag,
1929 unsigned int format,
1930 struct snd_pcm_substream *substream)
1932 struct sigmatel_spec *spec = codec->spec;
1934 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1935 stream_tag, 0, format);
1939 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1940 struct hda_codec *codec,
1941 struct snd_pcm_substream *substream)
1943 struct sigmatel_spec *spec = codec->spec;
1945 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
1949 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1953 /* NID is set in stac92xx_build_pcms */
1955 .open = stac92xx_dig_playback_pcm_open,
1956 .close = stac92xx_dig_playback_pcm_close,
1957 .prepare = stac92xx_dig_playback_pcm_prepare
1961 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1965 /* NID is set in stac92xx_build_pcms */
1968 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1972 .nid = 0x02, /* NID to query formats and rates */
1974 .open = stac92xx_playback_pcm_open,
1975 .prepare = stac92xx_playback_pcm_prepare,
1976 .cleanup = stac92xx_playback_pcm_cleanup
1980 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1984 .nid = 0x06, /* NID to query formats and rates */
1986 .open = stac92xx_playback_pcm_open,
1987 .prepare = stac92xx_playback_pcm_prepare,
1988 .cleanup = stac92xx_playback_pcm_cleanup
1992 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1995 /* NID + .substreams is set in stac92xx_build_pcms */
1997 .prepare = stac92xx_capture_pcm_prepare,
1998 .cleanup = stac92xx_capture_pcm_cleanup
2002 static int stac92xx_build_pcms(struct hda_codec *codec)
2004 struct sigmatel_spec *spec = codec->spec;
2005 struct hda_pcm *info = spec->pcm_rec;
2007 codec->num_pcms = 1;
2008 codec->pcm_info = info;
2010 info->name = "STAC92xx Analog";
2011 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2012 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2013 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2014 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2016 if (spec->alt_switch) {
2019 info->name = "STAC92xx Analog Alt";
2020 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2023 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2026 info->name = "STAC92xx Digital";
2027 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2028 if (spec->multiout.dig_out_nid) {
2029 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2030 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2032 if (spec->dig_in_nid) {
2033 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2034 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2041 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2043 unsigned int pincap = snd_hda_param_read(codec, nid,
2045 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2046 if (pincap & AC_PINCAP_VREF_100)
2047 return AC_PINCTL_VREF_100;
2048 if (pincap & AC_PINCAP_VREF_80)
2049 return AC_PINCTL_VREF_80;
2050 if (pincap & AC_PINCAP_VREF_50)
2051 return AC_PINCTL_VREF_50;
2052 if (pincap & AC_PINCAP_VREF_GRD)
2053 return AC_PINCTL_VREF_GRD;
2057 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2060 snd_hda_codec_write_cache(codec, nid, 0,
2061 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2064 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2066 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2067 struct snd_ctl_elem_value *ucontrol)
2069 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2070 struct sigmatel_spec *spec = codec->spec;
2072 ucontrol->value.integer.value[0] = spec->hp_switch;
2076 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2077 struct snd_ctl_elem_value *ucontrol)
2079 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2080 struct sigmatel_spec *spec = codec->spec;
2082 spec->hp_switch = ucontrol->value.integer.value[0];
2084 /* check to be sure that the ports are upto date with
2087 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2092 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2094 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2096 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2097 struct sigmatel_spec *spec = codec->spec;
2098 int io_idx = kcontrol-> private_value & 0xff;
2100 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2104 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2106 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2107 struct sigmatel_spec *spec = codec->spec;
2108 hda_nid_t nid = kcontrol->private_value >> 8;
2109 int io_idx = kcontrol-> private_value & 0xff;
2110 unsigned short val = !!ucontrol->value.integer.value[0];
2112 spec->io_switch[io_idx] = val;
2115 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2117 unsigned int pinctl = AC_PINCTL_IN_EN;
2118 if (io_idx) /* set VREF for mic */
2119 pinctl |= stac92xx_get_vref(codec, nid);
2120 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2123 /* check the auto-mute again: we need to mute/unmute the speaker
2124 * appropriately according to the pin direction
2126 if (spec->hp_detect)
2127 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2132 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2134 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2135 struct snd_ctl_elem_value *ucontrol)
2137 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2138 struct sigmatel_spec *spec = codec->spec;
2140 ucontrol->value.integer.value[0] = spec->clfe_swap;
2144 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2145 struct snd_ctl_elem_value *ucontrol)
2147 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2148 struct sigmatel_spec *spec = codec->spec;
2149 hda_nid_t nid = kcontrol->private_value & 0xff;
2150 unsigned int val = !!ucontrol->value.integer.value[0];
2152 if (spec->clfe_swap == val)
2155 spec->clfe_swap = val;
2157 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2158 spec->clfe_swap ? 0x4 : 0x0);
2163 #define STAC_CODEC_HP_SWITCH(xname) \
2164 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2167 .info = stac92xx_hp_switch_info, \
2168 .get = stac92xx_hp_switch_get, \
2169 .put = stac92xx_hp_switch_put, \
2172 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2173 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2176 .info = stac92xx_io_switch_info, \
2177 .get = stac92xx_io_switch_get, \
2178 .put = stac92xx_io_switch_put, \
2179 .private_value = xpval, \
2182 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2183 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2186 .info = stac92xx_clfe_switch_info, \
2187 .get = stac92xx_clfe_switch_get, \
2188 .put = stac92xx_clfe_switch_put, \
2189 .private_value = xpval, \
2193 STAC_CTL_WIDGET_VOL,
2194 STAC_CTL_WIDGET_MUTE,
2195 STAC_CTL_WIDGET_MONO_MUX,
2196 STAC_CTL_WIDGET_HP_SWITCH,
2197 STAC_CTL_WIDGET_IO_SWITCH,
2198 STAC_CTL_WIDGET_CLFE_SWITCH
2201 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2202 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2203 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2205 STAC_CODEC_HP_SWITCH(NULL),
2206 STAC_CODEC_IO_SWITCH(NULL, 0),
2207 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2210 /* add dynamic controls */
2211 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2213 struct snd_kcontrol_new *knew;
2215 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2216 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2218 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2221 if (spec->kctl_alloc) {
2222 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2223 kfree(spec->kctl_alloc);
2225 spec->kctl_alloc = knew;
2226 spec->num_kctl_alloc = num;
2229 knew = &spec->kctl_alloc[spec->num_kctl_used];
2230 *knew = stac92xx_control_templates[type];
2231 knew->name = kstrdup(name, GFP_KERNEL);
2234 knew->private_value = val;
2235 spec->num_kctl_used++;
2239 /* flag inputs as additional dynamic lineouts */
2240 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2242 struct sigmatel_spec *spec = codec->spec;
2243 unsigned int wcaps, wtype;
2244 int i, num_dacs = 0;
2246 /* use the wcaps cache to count all DACs available for line-outs */
2247 for (i = 0; i < codec->num_nodes; i++) {
2248 wcaps = codec->wcaps[i];
2249 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2251 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2255 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2257 switch (cfg->line_outs) {
2259 /* add line-in as side */
2260 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2261 cfg->line_out_pins[cfg->line_outs] =
2262 cfg->input_pins[AUTO_PIN_LINE];
2263 spec->line_switch = 1;
2268 /* add line-in as clfe and mic as side */
2269 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2270 cfg->line_out_pins[cfg->line_outs] =
2271 cfg->input_pins[AUTO_PIN_LINE];
2272 spec->line_switch = 1;
2275 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2276 cfg->line_out_pins[cfg->line_outs] =
2277 cfg->input_pins[AUTO_PIN_MIC];
2278 spec->mic_switch = 1;
2283 /* add line-in as surr and mic as clfe */
2284 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2285 cfg->line_out_pins[cfg->line_outs] =
2286 cfg->input_pins[AUTO_PIN_LINE];
2287 spec->line_switch = 1;
2290 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2291 cfg->line_out_pins[cfg->line_outs] =
2292 cfg->input_pins[AUTO_PIN_MIC];
2293 spec->mic_switch = 1;
2303 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2307 for (i = 0; i < spec->multiout.num_dacs; i++) {
2308 if (spec->multiout.dac_nids[i] == nid)
2316 * Fill in the dac_nids table from the parsed pin configuration
2317 * This function only works when every pin in line_out_pins[]
2318 * contains atleast one DAC in its connection list. Some 92xx
2319 * codecs are not connected directly to a DAC, such as the 9200
2320 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2322 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2323 struct auto_pin_cfg *cfg)
2325 struct sigmatel_spec *spec = codec->spec;
2326 int i, j, conn_len = 0;
2327 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2328 unsigned int wcaps, wtype;
2330 for (i = 0; i < cfg->line_outs; i++) {
2331 nid = cfg->line_out_pins[i];
2332 conn_len = snd_hda_get_connections(codec, nid, conn,
2333 HDA_MAX_CONNECTIONS);
2334 for (j = 0; j < conn_len; j++) {
2335 wcaps = snd_hda_param_read(codec, conn[j],
2336 AC_PAR_AUDIO_WIDGET_CAP);
2337 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2338 if (wtype != AC_WID_AUD_OUT ||
2339 (wcaps & AC_WCAP_DIGITAL))
2341 /* conn[j] is a DAC routed to this line-out */
2342 if (!is_in_dac_nids(spec, conn[j]))
2346 if (j == conn_len) {
2347 if (spec->multiout.num_dacs > 0) {
2348 /* we have already working output pins,
2349 * so let's drop the broken ones again
2351 cfg->line_outs = spec->multiout.num_dacs;
2354 /* error out, no available DAC found */
2356 "%s: No available DAC for pin 0x%x\n",
2361 spec->multiout.dac_nids[i] = conn[j];
2362 spec->multiout.num_dacs++;
2364 /* select this DAC in the pin's input mux */
2365 snd_hda_codec_write_cache(codec, nid, 0,
2366 AC_VERB_SET_CONNECT_SEL, j);
2371 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2372 spec->multiout.num_dacs,
2373 spec->multiout.dac_nids[0],
2374 spec->multiout.dac_nids[1],
2375 spec->multiout.dac_nids[2],
2376 spec->multiout.dac_nids[3],
2377 spec->multiout.dac_nids[4]);
2381 /* create volume control/switch for the given prefx type */
2382 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2387 sprintf(name, "%s Playback Volume", pfx);
2388 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2389 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2392 sprintf(name, "%s Playback Switch", pfx);
2393 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2394 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2400 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2402 if (!spec->multiout.hp_nid)
2403 spec->multiout.hp_nid = nid;
2404 else if (spec->multiout.num_dacs > 4) {
2405 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2408 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2409 spec->multiout.num_dacs++;
2414 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2416 if (is_in_dac_nids(spec, nid))
2418 if (spec->multiout.hp_nid == nid)
2423 /* add playback controls from the parsed DAC table */
2424 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2425 const struct auto_pin_cfg *cfg)
2427 static const char *chname[4] = {
2428 "Front", "Surround", NULL /*CLFE*/, "Side"
2433 struct sigmatel_spec *spec = codec->spec;
2434 unsigned int wid_caps, pincap;
2437 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2438 if (!spec->multiout.dac_nids[i])
2441 nid = spec->multiout.dac_nids[i];
2445 err = create_controls(spec, "Center", nid, 1);
2448 err = create_controls(spec, "LFE", nid, 2);
2452 wid_caps = get_wcaps(codec, nid);
2454 if (wid_caps & AC_WCAP_LR_SWAP) {
2455 err = stac92xx_add_control(spec,
2456 STAC_CTL_WIDGET_CLFE_SWITCH,
2457 "Swap Center/LFE Playback Switch", nid);
2464 err = create_controls(spec, chname[i], nid, 3);
2470 if (cfg->hp_outs > 1) {
2471 err = stac92xx_add_control(spec,
2472 STAC_CTL_WIDGET_HP_SWITCH,
2473 "Headphone as Line Out Switch", 0);
2478 if (spec->line_switch) {
2479 nid = cfg->input_pins[AUTO_PIN_LINE];
2480 pincap = snd_hda_param_read(codec, nid,
2482 if (pincap & AC_PINCAP_OUT) {
2483 err = stac92xx_add_control(spec,
2484 STAC_CTL_WIDGET_IO_SWITCH,
2485 "Line In as Output Switch", nid << 8);
2491 if (spec->mic_switch) {
2492 unsigned int def_conf;
2493 unsigned int mic_pin = AUTO_PIN_MIC;
2495 nid = cfg->input_pins[mic_pin];
2496 def_conf = snd_hda_codec_read(codec, nid, 0,
2497 AC_VERB_GET_CONFIG_DEFAULT, 0);
2498 /* some laptops have an internal analog microphone
2499 * which can't be used as a output */
2500 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2501 pincap = snd_hda_param_read(codec, nid,
2503 if (pincap & AC_PINCAP_OUT) {
2504 err = stac92xx_add_control(spec,
2505 STAC_CTL_WIDGET_IO_SWITCH,
2506 "Mic as Output Switch", (nid << 8) | 1);
2507 nid = snd_hda_codec_read(codec, nid, 0,
2508 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2509 if (!check_in_dac_nids(spec, nid))
2510 add_spec_dacs(spec, nid);
2514 } else if (mic_pin == AUTO_PIN_MIC) {
2515 mic_pin = AUTO_PIN_FRONT_MIC;
2523 /* add playback controls for Speaker and HP outputs */
2524 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2525 struct auto_pin_cfg *cfg)
2527 struct sigmatel_spec *spec = codec->spec;
2529 int i, old_num_dacs, err;
2531 old_num_dacs = spec->multiout.num_dacs;
2532 for (i = 0; i < cfg->hp_outs; i++) {
2533 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2534 if (wid_caps & AC_WCAP_UNSOL_CAP)
2535 spec->hp_detect = 1;
2536 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2537 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2538 if (check_in_dac_nids(spec, nid))
2542 add_spec_dacs(spec, nid);
2544 for (i = 0; i < cfg->speaker_outs; i++) {
2545 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2546 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2547 if (check_in_dac_nids(spec, nid))
2551 add_spec_dacs(spec, nid);
2553 for (i = 0; i < cfg->line_outs; i++) {
2554 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2555 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2556 if (check_in_dac_nids(spec, nid))
2560 add_spec_dacs(spec, nid);
2562 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2563 static const char *pfxs[] = {
2564 "Speaker", "External Speaker", "Speaker2",
2566 err = create_controls(spec, pfxs[i - old_num_dacs],
2567 spec->multiout.dac_nids[i], 3);
2571 if (spec->multiout.hp_nid) {
2572 err = create_controls(spec, "Headphone",
2573 spec->multiout.hp_nid, 3);
2581 /* labels for mono mux outputs */
2582 static const char *stac92xx_mono_labels[3] = {
2583 "DAC0", "DAC1", "Mixer"
2586 /* create mono mux for mono out on capable codecs */
2587 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2589 struct sigmatel_spec *spec = codec->spec;
2590 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2592 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2594 num_cons = snd_hda_get_connections(codec,
2597 HDA_MAX_NUM_INPUTS);
2598 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2601 for (i = 0; i < num_cons; i++) {
2602 mono_mux->items[mono_mux->num_items].label =
2603 stac92xx_mono_labels[i];
2604 mono_mux->items[mono_mux->num_items].index = i;
2605 mono_mux->num_items++;
2608 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2609 "Mono Mux", spec->mono_nid);
2612 /* labels for dmic mux inputs */
2613 static const char *stac92xx_dmic_labels[5] = {
2614 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2615 "Digital Mic 3", "Digital Mic 4"
2618 /* create playback/capture controls for input pins on dmic capable codecs */
2619 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2620 const struct auto_pin_cfg *cfg)
2622 struct sigmatel_spec *spec = codec->spec;
2623 struct hda_input_mux *dimux = &spec->private_dimux;
2624 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2628 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2629 dimux->items[dimux->num_items].index = 0;
2632 for (i = 0; i < spec->num_dmics; i++) {
2637 unsigned int def_conf;
2639 def_conf = snd_hda_codec_read(codec,
2642 AC_VERB_GET_CONFIG_DEFAULT,
2644 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2647 nid = spec->dmic_nids[i];
2648 num_cons = snd_hda_get_connections(codec,
2651 HDA_MAX_NUM_INPUTS);
2652 for (j = 0; j < num_cons; j++)
2653 if (con_lst[j] == nid) {
2659 wcaps = get_wcaps(codec, nid);
2661 if (wcaps & AC_WCAP_OUT_AMP) {
2662 sprintf(name, "%s Capture Volume",
2663 stac92xx_dmic_labels[dimux->num_items]);
2665 err = stac92xx_add_control(spec,
2666 STAC_CTL_WIDGET_VOL,
2668 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2673 dimux->items[dimux->num_items].label =
2674 stac92xx_dmic_labels[dimux->num_items];
2675 dimux->items[dimux->num_items].index = index;
2682 /* create playback/capture controls for input pins */
2683 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2685 struct sigmatel_spec *spec = codec->spec;
2686 struct hda_input_mux *imux = &spec->private_imux;
2687 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2690 for (i = 0; i < AUTO_PIN_LAST; i++) {
2693 if (!cfg->input_pins[i])
2696 for (j = 0; j < spec->num_muxes; j++) {
2698 num_cons = snd_hda_get_connections(codec,
2701 HDA_MAX_NUM_INPUTS);
2702 for (k = 0; k < num_cons; k++)
2703 if (con_lst[k] == cfg->input_pins[i]) {
2710 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2711 imux->items[imux->num_items].index = index;
2715 if (imux->num_items) {
2717 * Set the current input for the muxes.
2718 * The STAC9221 has two input muxes with identical source
2719 * NID lists. Hopefully this won't get confused.
2721 for (i = 0; i < spec->num_muxes; i++) {
2722 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2723 AC_VERB_SET_CONNECT_SEL,
2724 imux->items[0].index);
2731 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2733 struct sigmatel_spec *spec = codec->spec;
2736 for (i = 0; i < spec->autocfg.line_outs; i++) {
2737 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2738 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2742 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2744 struct sigmatel_spec *spec = codec->spec;
2747 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2749 pin = spec->autocfg.hp_pins[i];
2750 if (pin) /* connect to front */
2751 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2753 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2755 pin = spec->autocfg.speaker_pins[i];
2756 if (pin) /* connect to front */
2757 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2761 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2763 struct sigmatel_spec *spec = codec->spec;
2765 int hp_speaker_swap = 0;
2767 if ((err = snd_hda_parse_pin_def_config(codec,
2769 spec->dmic_nids)) < 0)
2771 if (! spec->autocfg.line_outs)
2772 return 0; /* can't find valid pin config */
2774 /* If we have no real line-out pin and multiple hp-outs, HPs should
2775 * be set up as multi-channel outputs.
2777 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2778 spec->autocfg.hp_outs > 1) {
2779 /* Copy hp_outs to line_outs, backup line_outs in
2780 * speaker_outs so that the following routines can handle
2781 * HP pins as primary outputs.
2783 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2784 sizeof(spec->autocfg.line_out_pins));
2785 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2786 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2787 sizeof(spec->autocfg.hp_pins));
2788 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2789 hp_speaker_swap = 1;
2791 if (spec->autocfg.mono_out_pin) {
2792 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2793 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2794 u32 caps = query_amp_caps(codec,
2795 spec->autocfg.mono_out_pin, dir);
2796 hda_nid_t conn_list[1];
2798 /* get the mixer node and then the mono mux if it exists */
2799 if (snd_hda_get_connections(codec,
2800 spec->autocfg.mono_out_pin, conn_list, 1) &&
2801 snd_hda_get_connections(codec, conn_list[0],
2804 int wcaps = get_wcaps(codec, conn_list[0]);
2805 int wid_type = (wcaps & AC_WCAP_TYPE)
2806 >> AC_WCAP_TYPE_SHIFT;
2807 /* LR swap check, some stac925x have a mux that
2808 * changes the DACs output path instead of the
2811 if (wid_type == AC_WID_AUD_SEL &&
2812 !(wcaps & AC_WCAP_LR_SWAP))
2813 spec->mono_nid = conn_list[0];
2815 /* all mono outs have a least a mute/unmute switch */
2816 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2817 "Mono Playback Switch",
2818 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2822 /* check to see if there is volume support for the amp */
2823 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2824 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2825 "Mono Playback Volume",
2826 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2832 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2836 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2838 if (spec->multiout.num_dacs == 0)
2839 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2842 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2847 if (hp_speaker_swap == 1) {
2848 /* Restore the hp_outs and line_outs */
2849 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2850 sizeof(spec->autocfg.line_out_pins));
2851 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2852 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2853 sizeof(spec->autocfg.speaker_pins));
2854 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2855 memset(spec->autocfg.speaker_pins, 0,
2856 sizeof(spec->autocfg.speaker_pins));
2857 spec->autocfg.speaker_outs = 0;
2860 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2865 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2870 if (spec->mono_nid > 0) {
2871 err = stac92xx_auto_create_mono_output_ctls(codec);
2876 if (spec->num_dmics > 0)
2877 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2878 &spec->autocfg)) < 0)
2881 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2882 if (spec->multiout.max_channels > 2)
2883 spec->surr_switch = 1;
2885 if (spec->autocfg.dig_out_pin)
2886 spec->multiout.dig_out_nid = dig_out;
2887 if (spec->autocfg.dig_in_pin)
2888 spec->dig_in_nid = dig_in;
2890 if (spec->kctl_alloc)
2891 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2893 spec->input_mux = &spec->private_imux;
2894 if (!spec->dinput_mux)
2895 spec->dinput_mux = &spec->private_dimux;
2896 spec->mono_mux = &spec->private_mono_mux;
2901 /* add playback controls for HP output */
2902 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2903 struct auto_pin_cfg *cfg)
2905 struct sigmatel_spec *spec = codec->spec;
2906 hda_nid_t pin = cfg->hp_pins[0];
2907 unsigned int wid_caps;
2912 wid_caps = get_wcaps(codec, pin);
2913 if (wid_caps & AC_WCAP_UNSOL_CAP)
2914 spec->hp_detect = 1;
2919 /* add playback controls for LFE output */
2920 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2921 struct auto_pin_cfg *cfg)
2923 struct sigmatel_spec *spec = codec->spec;
2925 hda_nid_t lfe_pin = 0x0;
2929 * search speaker outs and line outs for a mono speaker pin
2930 * with an amp. If one is found, add LFE controls
2933 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2934 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2935 unsigned int wcaps = get_wcaps(codec, pin);
2936 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2937 if (wcaps == AC_WCAP_OUT_AMP)
2938 /* found a mono speaker with an amp, must be lfe */
2942 /* if speaker_outs is 0, then speakers may be in line_outs */
2943 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2944 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2945 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2946 unsigned int defcfg;
2947 defcfg = snd_hda_codec_read(codec, pin, 0,
2948 AC_VERB_GET_CONFIG_DEFAULT,
2950 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2951 unsigned int wcaps = get_wcaps(codec, pin);
2952 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2953 if (wcaps == AC_WCAP_OUT_AMP)
2954 /* found a mono speaker with an amp,
2962 err = create_controls(spec, "LFE", lfe_pin, 1);
2970 static int stac9200_parse_auto_config(struct hda_codec *codec)
2972 struct sigmatel_spec *spec = codec->spec;
2975 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2978 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2981 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2984 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2987 if (spec->autocfg.dig_out_pin)
2988 spec->multiout.dig_out_nid = 0x05;
2989 if (spec->autocfg.dig_in_pin)
2990 spec->dig_in_nid = 0x04;
2992 if (spec->kctl_alloc)
2993 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2995 spec->input_mux = &spec->private_imux;
2996 spec->dinput_mux = &spec->private_dimux;
3002 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3003 * funky external mute control using GPIO pins.
3006 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3007 unsigned int dir_mask, unsigned int data)
3009 unsigned int gpiostate, gpiomask, gpiodir;
3011 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3012 AC_VERB_GET_GPIO_DATA, 0);
3013 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3015 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3016 AC_VERB_GET_GPIO_MASK, 0);
3019 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3020 AC_VERB_GET_GPIO_DIRECTION, 0);
3021 gpiodir |= dir_mask;
3023 /* Configure GPIOx as CMOS */
3024 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3026 snd_hda_codec_write(codec, codec->afg, 0,
3027 AC_VERB_SET_GPIO_MASK, gpiomask);
3028 snd_hda_codec_read(codec, codec->afg, 0,
3029 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3033 snd_hda_codec_read(codec, codec->afg, 0,
3034 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3037 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3040 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3041 snd_hda_codec_write_cache(codec, nid, 0,
3042 AC_VERB_SET_UNSOLICITED_ENABLE,
3043 (AC_USRSP_EN | event));
3046 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3049 for (i = 0; i < cfg->hp_outs; i++)
3050 if (cfg->hp_pins[i] == nid)
3051 return 1; /* nid is a HP-Out */
3053 return 0; /* nid is not a HP-Out */
3056 static void stac92xx_power_down(struct hda_codec *codec)
3058 struct sigmatel_spec *spec = codec->spec;
3060 /* power down inactive DACs */
3062 for (dac = spec->dac_list; *dac; dac++)
3063 if (!is_in_dac_nids(spec, *dac) &&
3064 spec->multiout.hp_nid != *dac)
3065 snd_hda_codec_write_cache(codec, *dac, 0,
3066 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3069 static int stac92xx_init(struct hda_codec *codec)
3071 struct sigmatel_spec *spec = codec->spec;
3072 struct auto_pin_cfg *cfg = &spec->autocfg;
3075 snd_hda_sequence_write(codec, spec->init);
3078 if (spec->hp_detect) {
3079 /* Enable unsolicited responses on the HP widget */
3080 for (i = 0; i < cfg->hp_outs; i++)
3081 enable_pin_detect(codec, cfg->hp_pins[i],
3083 /* force to enable the first line-out; the others are set up
3086 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3088 stac92xx_auto_init_hp_out(codec);
3089 /* fake event to set up pins */
3090 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3092 stac92xx_auto_init_multi_out(codec);
3093 stac92xx_auto_init_hp_out(codec);
3095 for (i = 0; i < AUTO_PIN_LAST; i++) {
3096 hda_nid_t nid = cfg->input_pins[i];
3098 unsigned int pinctl = AC_PINCTL_IN_EN;
3099 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3100 pinctl |= stac92xx_get_vref(codec, nid);
3101 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3104 for (i = 0; i < spec->num_dmics; i++)
3105 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3107 for (i = 0; i < spec->num_pwrs; i++) {
3108 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3109 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3110 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3111 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3112 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3113 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3114 def_conf = get_defcfg_connect(def_conf);
3115 /* outputs are only ports capable of power management
3116 * any attempts on powering down a input port cause the
3117 * referenced VREF to act quirky.
3119 if (pinctl & AC_PINCTL_IN_EN)
3121 /* skip any ports that don't have jacks since presence
3122 * detection is useless */
3123 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3125 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3126 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3129 stac92xx_power_down(codec);
3130 if (cfg->dig_out_pin)
3131 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3133 if (cfg->dig_in_pin)
3134 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3137 stac_gpio_set(codec, spec->gpio_mask,
3138 spec->gpio_dir, spec->gpio_data);
3143 static void stac92xx_free(struct hda_codec *codec)
3145 struct sigmatel_spec *spec = codec->spec;
3151 if (spec->kctl_alloc) {
3152 for (i = 0; i < spec->num_kctl_used; i++)
3153 kfree(spec->kctl_alloc[i].name);
3154 kfree(spec->kctl_alloc);
3157 if (spec->bios_pin_configs)
3158 kfree(spec->bios_pin_configs);
3163 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3166 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3167 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3169 if (pin_ctl & AC_PINCTL_IN_EN) {
3171 * we need to check the current set-up direction of
3172 * shared input pins since they can be switched via
3173 * "xxx as Output" mixer switch
3175 struct sigmatel_spec *spec = codec->spec;
3176 struct auto_pin_cfg *cfg = &spec->autocfg;
3177 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3178 spec->line_switch) ||
3179 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3184 /* if setting pin direction bits, clear the current
3185 direction bits first */
3186 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3187 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3189 snd_hda_codec_write_cache(codec, nid, 0,
3190 AC_VERB_SET_PIN_WIDGET_CONTROL,
3194 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3197 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3198 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3199 snd_hda_codec_write_cache(codec, nid, 0,
3200 AC_VERB_SET_PIN_WIDGET_CONTROL,
3204 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3208 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3210 unsigned int pinctl;
3211 pinctl = snd_hda_codec_read(codec, nid, 0,
3212 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3213 if (pinctl & AC_PINCTL_IN_EN)
3214 return 0; /* mic- or line-input */
3216 return 1; /* HP-output */
3221 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3223 struct sigmatel_spec *spec = codec->spec;
3224 struct auto_pin_cfg *cfg = &spec->autocfg;
3225 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3229 if (spec->gpio_mute)
3230 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3231 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3233 for (i = 0; i < cfg->hp_outs; i++) {
3236 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3238 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3242 /* disable lineouts, enable hp */
3243 if (spec->hp_switch)
3244 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3245 for (i = 0; i < cfg->line_outs; i++)
3246 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3248 for (i = 0; i < cfg->speaker_outs; i++)
3249 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3251 if (spec->eapd_mask)
3252 stac_gpio_set(codec, spec->gpio_mask,
3253 spec->gpio_dir, spec->gpio_data &
3256 /* enable lineouts, disable hp */
3257 if (spec->hp_switch)
3258 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3259 for (i = 0; i < cfg->line_outs; i++)
3260 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3262 for (i = 0; i < cfg->speaker_outs; i++)
3263 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3265 if (spec->eapd_mask)
3266 stac_gpio_set(codec, spec->gpio_mask,
3267 spec->gpio_dir, spec->gpio_data |
3270 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3271 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3274 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3276 struct sigmatel_spec *spec = codec->spec;
3277 hda_nid_t nid = spec->pwr_nids[idx];
3279 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3281 presence = get_hp_pin_presence(codec, nid);
3289 /* power down unused output ports */
3290 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3293 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3295 struct sigmatel_spec *spec = codec->spec;
3296 int idx = res >> 26 & 0x0f;
3298 switch ((res >> 26) & 0x30) {
3300 stac92xx_hp_detect(codec, res);
3302 case STAC_PWR_EVENT:
3303 if (spec->num_pwrs > 0)
3304 stac92xx_pin_sense(codec, idx);
3308 #ifdef SND_HDA_NEEDS_RESUME
3309 static int stac92xx_resume(struct hda_codec *codec)
3311 struct sigmatel_spec *spec = codec->spec;
3313 stac92xx_set_config_regs(codec);
3314 snd_hda_sequence_write(codec, spec->init);
3315 stac_gpio_set(codec, spec->gpio_mask,
3316 spec->gpio_dir, spec->gpio_data);
3317 snd_hda_codec_resume_amp(codec);
3318 snd_hda_codec_resume_cache(codec);
3319 /* power down inactive DACs */
3321 stac92xx_power_down(codec);
3322 /* invoke unsolicited event to reset the HP state */
3323 if (spec->hp_detect)
3324 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3329 static struct hda_codec_ops stac92xx_patch_ops = {
3330 .build_controls = stac92xx_build_controls,
3331 .build_pcms = stac92xx_build_pcms,
3332 .init = stac92xx_init,
3333 .free = stac92xx_free,
3334 .unsol_event = stac92xx_unsol_event,
3335 #ifdef SND_HDA_NEEDS_RESUME
3336 .resume = stac92xx_resume,
3340 static int patch_stac9200(struct hda_codec *codec)
3342 struct sigmatel_spec *spec;
3345 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3350 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3351 spec->pin_nids = stac9200_pin_nids;
3352 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3355 if (spec->board_config < 0) {
3356 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3357 err = stac92xx_save_bios_config_regs(codec);
3359 stac92xx_free(codec);
3362 spec->pin_configs = spec->bios_pin_configs;
3364 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3365 stac92xx_set_config_regs(codec);
3368 spec->multiout.max_channels = 2;
3369 spec->multiout.num_dacs = 1;
3370 spec->multiout.dac_nids = stac9200_dac_nids;
3371 spec->adc_nids = stac9200_adc_nids;
3372 spec->mux_nids = stac9200_mux_nids;
3373 spec->num_muxes = 1;
3374 spec->num_dmics = 0;
3378 if (spec->board_config == STAC_9200_GATEWAY ||
3379 spec->board_config == STAC_9200_OQO)
3380 spec->init = stac9200_eapd_init;
3382 spec->init = stac9200_core_init;
3383 spec->mixer = stac9200_mixer;
3385 if (spec->board_config == STAC_9200_PANASONIC) {
3386 spec->gpio_mask = spec->gpio_dir = 0x09;
3387 spec->gpio_data = 0x00;
3390 err = stac9200_parse_auto_config(codec);
3392 stac92xx_free(codec);
3396 codec->patch_ops = stac92xx_patch_ops;
3401 static int patch_stac925x(struct hda_codec *codec)
3403 struct sigmatel_spec *spec;
3406 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3411 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3412 spec->pin_nids = stac925x_pin_nids;
3413 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3417 if (spec->board_config < 0) {
3418 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3419 "using BIOS defaults\n");
3420 err = stac92xx_save_bios_config_regs(codec);
3422 stac92xx_free(codec);
3425 spec->pin_configs = spec->bios_pin_configs;
3426 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3427 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3428 stac92xx_set_config_regs(codec);
3431 spec->multiout.max_channels = 2;
3432 spec->multiout.num_dacs = 1;
3433 spec->multiout.dac_nids = stac925x_dac_nids;
3434 spec->adc_nids = stac925x_adc_nids;
3435 spec->mux_nids = stac925x_mux_nids;
3436 spec->num_muxes = 1;
3439 switch (codec->vendor_id) {
3440 case 0x83847632: /* STAC9202 */
3441 case 0x83847633: /* STAC9202D */
3442 case 0x83847636: /* STAC9251 */
3443 case 0x83847637: /* STAC9251D */
3444 spec->num_dmics = STAC925X_NUM_DMICS;
3445 spec->dmic_nids = stac925x_dmic_nids;
3446 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3447 spec->dmux_nids = stac925x_dmux_nids;
3450 spec->num_dmics = 0;
3454 spec->init = stac925x_core_init;
3455 spec->mixer = stac925x_mixer;
3457 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
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_925x_REF;
3468 stac92xx_free(codec);
3472 codec->patch_ops = stac92xx_patch_ops;
3477 static struct hda_input_mux stac92hd73xx_dmux = {
3480 { "Analog Inputs", 0x0b },
3482 { "Digital Mic 1", 0x09 },
3483 { "Digital Mic 2", 0x0a },
3487 static int patch_stac92hd73xx(struct hda_codec *codec)
3489 struct sigmatel_spec *spec;
3490 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3493 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3498 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3499 spec->pin_nids = stac92hd73xx_pin_nids;
3500 spec->board_config = snd_hda_check_board_config(codec,
3501 STAC_92HD73XX_MODELS,
3502 stac92hd73xx_models,
3503 stac92hd73xx_cfg_tbl);
3505 if (spec->board_config < 0) {
3506 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3507 " STAC92HD73XX, using BIOS defaults\n");
3508 err = stac92xx_save_bios_config_regs(codec);
3510 stac92xx_free(codec);
3513 spec->pin_configs = spec->bios_pin_configs;
3515 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3516 stac92xx_set_config_regs(codec);
3519 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3520 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3522 if (spec->multiout.num_dacs < 0) {
3523 printk(KERN_WARNING "hda_codec: Could not determine "
3524 "number of channels defaulting to DAC count\n");
3525 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3528 switch (spec->multiout.num_dacs) {
3529 case 0x3: /* 6 Channel */
3530 spec->multiout.hp_nid = 0x17;
3531 spec->mixer = stac92hd73xx_6ch_mixer;
3532 spec->init = stac92hd73xx_6ch_core_init;
3534 case 0x4: /* 8 Channel */
3535 spec->multiout.hp_nid = 0x18;
3536 spec->mixer = stac92hd73xx_8ch_mixer;
3537 spec->init = stac92hd73xx_8ch_core_init;
3539 case 0x5: /* 10 Channel */
3540 spec->multiout.hp_nid = 0x19;
3541 spec->mixer = stac92hd73xx_10ch_mixer;
3542 spec->init = stac92hd73xx_10ch_core_init;
3545 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3546 spec->aloopback_mask = 0x01;
3547 spec->aloopback_shift = 8;
3549 spec->mux_nids = stac92hd73xx_mux_nids;
3550 spec->adc_nids = stac92hd73xx_adc_nids;
3551 spec->dmic_nids = stac92hd73xx_dmic_nids;
3552 spec->dmux_nids = stac92hd73xx_dmux_nids;
3554 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3555 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3556 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3557 spec->dinput_mux = &stac92hd73xx_dmux;
3558 /* GPIO0 High = Enable EAPD */
3559 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3560 spec->gpio_data = 0x01;
3562 switch (spec->board_config) {
3564 spec->init = dell_eq_core_init;
3565 switch (codec->subsystem_id) {
3566 case 0x1028025e: /* Analog Mics */
3568 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3569 spec->num_dmics = 0;
3571 case 0x10280271: /* Digital Mics */
3573 spec->init = dell_m6_core_init;
3577 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3578 spec->num_dmics = 1;
3580 case 0x10280256: /* Both */
3582 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3583 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3584 spec->num_dmics = 1;
3589 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3592 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3593 spec->pwr_nids = stac92hd73xx_pwr_nids;
3595 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3598 if (spec->board_config < 0) {
3599 printk(KERN_WARNING "hda_codec: No auto-config is "
3600 "available, default to model=ref\n");
3601 spec->board_config = STAC_92HD73XX_REF;
3608 stac92xx_free(codec);
3612 codec->patch_ops = stac92xx_patch_ops;
3617 static int patch_stac92hd71bxx(struct hda_codec *codec)
3619 struct sigmatel_spec *spec;
3622 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3627 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
3628 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3629 spec->pin_nids = stac92hd71bxx_pin_nids;
3630 spec->board_config = snd_hda_check_board_config(codec,
3631 STAC_92HD71BXX_MODELS,
3632 stac92hd71bxx_models,
3633 stac92hd71bxx_cfg_tbl);
3635 if (spec->board_config < 0) {
3636 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3637 " STAC92HD71BXX, using BIOS defaults\n");
3638 err = stac92xx_save_bios_config_regs(codec);
3640 stac92xx_free(codec);
3643 spec->pin_configs = spec->bios_pin_configs;
3645 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3646 stac92xx_set_config_regs(codec);
3649 switch (codec->vendor_id) {
3650 case 0x111d76b6: /* 4 Port without Analog Mixer */
3652 case 0x111d76b4: /* 6 Port without Analog Mixer */
3654 spec->mixer = stac92hd71bxx_mixer;
3655 spec->init = stac92hd71bxx_core_init;
3657 case 0x111d7608: /* 5 Port with Analog Mixer */
3658 /* no output amps */
3660 spec->mixer = stac92hd71bxx_analog_mixer;
3663 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3664 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3666 case 0x111d7603: /* 6 Port with Analog Mixer */
3667 /* no output amps */
3671 spec->mixer = stac92hd71bxx_analog_mixer;
3672 spec->init = stac92hd71bxx_analog_core_init;
3675 spec->aloopback_mask = 0x20;
3676 spec->aloopback_shift = 0;
3678 /* GPIO0 High = EAPD */
3679 spec->gpio_mask = 0x01;
3680 spec->gpio_dir = 0x01;
3681 spec->gpio_data = 0x01;
3683 spec->mux_nids = stac92hd71bxx_mux_nids;
3684 spec->adc_nids = stac92hd71bxx_adc_nids;
3685 spec->dmic_nids = stac92hd71bxx_dmic_nids;
3686 spec->dmux_nids = stac92hd71bxx_dmux_nids;
3687 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3689 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3690 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3691 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3692 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3694 spec->multiout.num_dacs = 1;
3695 spec->multiout.hp_nid = 0x11;
3696 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3698 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3700 if (spec->board_config < 0) {
3701 printk(KERN_WARNING "hda_codec: No auto-config is "
3702 "available, default to model=ref\n");
3703 spec->board_config = STAC_92HD71BXX_REF;
3710 stac92xx_free(codec);
3714 codec->patch_ops = stac92xx_patch_ops;
3719 static int patch_stac922x(struct hda_codec *codec)
3721 struct sigmatel_spec *spec;
3724 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3729 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
3730 spec->pin_nids = stac922x_pin_nids;
3731 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3734 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
3735 spec->gpio_mask = spec->gpio_dir = 0x03;
3736 spec->gpio_data = 0x03;
3737 /* Intel Macs have all same PCI SSID, so we need to check
3738 * codec SSID to distinguish the exact models
3740 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
3741 switch (codec->subsystem_id) {
3744 spec->board_config = STAC_INTEL_MAC_V1;
3748 spec->board_config = STAC_INTEL_MAC_V2;
3756 spec->board_config = STAC_INTEL_MAC_V3;
3760 spec->board_config = STAC_INTEL_MAC_V4;
3764 spec->board_config = STAC_INTEL_MAC_V5;
3767 spec->board_config = STAC_INTEL_MAC_V3;
3773 if (spec->board_config < 0) {
3774 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3775 "using BIOS defaults\n");
3776 err = stac92xx_save_bios_config_regs(codec);
3778 stac92xx_free(codec);
3781 spec->pin_configs = spec->bios_pin_configs;
3782 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
3783 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3784 stac92xx_set_config_regs(codec);
3787 spec->adc_nids = stac922x_adc_nids;
3788 spec->mux_nids = stac922x_mux_nids;
3789 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
3790 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
3791 spec->num_dmics = 0;
3794 spec->init = stac922x_core_init;
3795 spec->mixer = stac922x_mixer;
3797 spec->multiout.dac_nids = spec->dac_nids;
3799 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
3801 if (spec->board_config < 0) {
3802 printk(KERN_WARNING "hda_codec: No auto-config is "
3803 "available, default to model=ref\n");
3804 spec->board_config = STAC_D945_REF;
3810 stac92xx_free(codec);
3814 codec->patch_ops = stac92xx_patch_ops;
3816 /* Fix Mux capture level; max to 2 */
3817 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3818 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3819 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3820 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3821 (0 << AC_AMPCAP_MUTE_SHIFT));
3826 static int patch_stac927x(struct hda_codec *codec)
3828 struct sigmatel_spec *spec;
3831 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3836 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3837 spec->pin_nids = stac927x_pin_nids;
3838 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3842 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3843 if (spec->board_config < 0)
3844 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3845 "STAC927x, using BIOS defaults\n");
3846 err = stac92xx_save_bios_config_regs(codec);
3848 stac92xx_free(codec);
3851 spec->pin_configs = spec->bios_pin_configs;
3853 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3854 stac92xx_set_config_regs(codec);
3857 spec->adc_nids = stac927x_adc_nids;
3858 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3859 spec->mux_nids = stac927x_mux_nids;
3860 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3861 spec->dac_list = stac927x_dac_nids;
3862 spec->multiout.dac_nids = spec->dac_nids;
3864 switch (spec->board_config) {
3867 /* GPIO0 High = Enable EAPD */
3868 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
3869 spec->gpio_data = 0x01;
3870 spec->num_dmics = 0;
3872 spec->init = d965_core_init;
3873 spec->mixer = stac927x_mixer;
3875 case STAC_DELL_BIOS:
3876 switch (codec->subsystem_id) {
3879 /* correct the device field to SPDIF out */
3880 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3883 /* configure the analog microphone on some laptops */
3884 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3885 /* correct the front output jack as a hp out */
3886 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3887 /* correct the front input jack as a mic */
3888 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3891 /* GPIO2 High = Enable EAPD */
3892 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3893 spec->gpio_data = 0x04;
3894 spec->dmic_nids = stac927x_dmic_nids;
3895 spec->num_dmics = STAC927X_NUM_DMICS;
3897 spec->init = d965_core_init;
3898 spec->mixer = stac927x_mixer;
3899 spec->dmux_nids = stac927x_dmux_nids;
3900 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3903 /* GPIO0 High = Enable EAPD */
3904 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3905 spec->gpio_data = 0x01;
3906 spec->num_dmics = 0;
3908 spec->init = stac927x_core_init;
3909 spec->mixer = stac927x_mixer;
3913 spec->aloopback_mask = 0x40;
3914 spec->aloopback_shift = 0;
3916 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3918 if (spec->board_config < 0) {
3919 printk(KERN_WARNING "hda_codec: No auto-config is "
3920 "available, default to model=ref\n");
3921 spec->board_config = STAC_D965_REF;
3927 stac92xx_free(codec);
3931 codec->patch_ops = stac92xx_patch_ops;
3935 * The STAC927x seem to require fairly long delays for certain
3936 * command sequences. With too short delays (even if the answer
3937 * is set to RIRB properly), it results in the silence output
3938 * on some hardwares like Dell.
3940 * The below flag enables the longer delay (see get_response
3943 codec->bus->needs_damn_long_delay = 1;
3948 static int patch_stac9205(struct hda_codec *codec)
3950 struct sigmatel_spec *spec;
3953 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3958 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
3959 spec->pin_nids = stac9205_pin_nids;
3960 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
3964 if (spec->board_config < 0) {
3965 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
3966 err = stac92xx_save_bios_config_regs(codec);
3968 stac92xx_free(codec);
3971 spec->pin_configs = spec->bios_pin_configs;
3973 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
3974 stac92xx_set_config_regs(codec);
3977 spec->adc_nids = stac9205_adc_nids;
3978 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
3979 spec->mux_nids = stac9205_mux_nids;
3980 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
3981 spec->dmic_nids = stac9205_dmic_nids;
3982 spec->num_dmics = STAC9205_NUM_DMICS;
3983 spec->dmux_nids = stac9205_dmux_nids;
3984 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
3987 spec->init = stac9205_core_init;
3988 spec->mixer = stac9205_mixer;
3990 spec->aloopback_mask = 0x40;
3991 spec->aloopback_shift = 0;
3992 spec->multiout.dac_nids = spec->dac_nids;
3994 switch (spec->board_config){
3995 case STAC_9205_DELL_M43:
3996 /* Enable SPDIF in/out */
3997 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3998 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4000 /* Enable unsol response for GPIO4/Dock HP connection */
4001 snd_hda_codec_write(codec, codec->afg, 0,
4002 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4003 snd_hda_codec_write_cache(codec, codec->afg, 0,
4004 AC_VERB_SET_UNSOLICITED_ENABLE,
4005 (AC_USRSP_EN | STAC_HP_EVENT));
4007 spec->gpio_dir = 0x0b;
4008 spec->eapd_mask = 0x01;
4009 spec->gpio_mask = 0x1b;
4010 spec->gpio_mute = 0x10;
4011 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4014 spec->gpio_data = 0x01;
4017 /* GPIO0 High = EAPD */
4018 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4019 spec->gpio_data = 0x01;
4023 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4025 if (spec->board_config < 0) {
4026 printk(KERN_WARNING "hda_codec: No auto-config is "
4027 "available, default to model=ref\n");
4028 spec->board_config = STAC_9205_REF;
4034 stac92xx_free(codec);
4038 codec->patch_ops = stac92xx_patch_ops;
4047 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4048 static hda_nid_t vaio_dacs[] = { 0x2 };
4049 #define VAIO_HP_DAC 0x5
4050 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4051 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4053 static struct hda_input_mux vaio_mux = {
4056 /* { "HP", 0x0 }, */
4057 { "Mic Jack", 0x1 },
4058 { "Internal Mic", 0x2 },
4063 static struct hda_verb vaio_init[] = {
4064 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4065 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
4066 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4067 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4068 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4069 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4070 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4071 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4072 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4073 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4074 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4075 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4079 static struct hda_verb vaio_ar_init[] = {
4080 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4081 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4082 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4083 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4084 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4086 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4087 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4088 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4089 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4090 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4091 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4096 /* bind volumes of both NID 0x02 and 0x05 */
4097 static struct hda_bind_ctls vaio_bind_master_vol = {
4098 .ops = &snd_hda_bind_vol,
4100 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4101 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4106 /* bind volumes of both NID 0x02 and 0x05 */
4107 static struct hda_bind_ctls vaio_bind_master_sw = {
4108 .ops = &snd_hda_bind_sw,
4110 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4111 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4116 static struct snd_kcontrol_new vaio_mixer[] = {
4117 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4118 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4119 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4120 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4121 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4123 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4124 .name = "Capture Source",
4126 .info = stac92xx_mux_enum_info,
4127 .get = stac92xx_mux_enum_get,
4128 .put = stac92xx_mux_enum_put,
4133 static struct snd_kcontrol_new vaio_ar_mixer[] = {
4134 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4135 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4136 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4137 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4138 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4139 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4140 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4143 .name = "Capture Source",
4145 .info = stac92xx_mux_enum_info,
4146 .get = stac92xx_mux_enum_get,
4147 .put = stac92xx_mux_enum_put,
4152 static struct hda_codec_ops stac9872_patch_ops = {
4153 .build_controls = stac92xx_build_controls,
4154 .build_pcms = stac92xx_build_pcms,
4155 .init = stac92xx_init,
4156 .free = stac92xx_free,
4157 #ifdef SND_HDA_NEEDS_RESUME
4158 .resume = stac92xx_resume,
4162 static int stac9872_vaio_init(struct hda_codec *codec)
4166 err = stac92xx_init(codec);
4169 if (codec->patch_ops.unsol_event)
4170 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4174 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4176 if (get_hp_pin_presence(codec, 0x0a)) {
4177 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4178 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4180 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4181 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4185 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4187 switch (res >> 26) {
4189 stac9872_vaio_hp_detect(codec, res);
4194 static struct hda_codec_ops stac9872_vaio_patch_ops = {
4195 .build_controls = stac92xx_build_controls,
4196 .build_pcms = stac92xx_build_pcms,
4197 .init = stac9872_vaio_init,
4198 .free = stac92xx_free,
4199 .unsol_event = stac9872_vaio_unsol_event,
4201 .resume = stac92xx_resume,
4205 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4207 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4209 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4211 /* AR Series. id=0x83847664 and subsys=104D1300 */
4216 static const char *stac9872_models[STAC_9872_MODELS] = {
4217 [CXD9872RD_VAIO] = "vaio",
4218 [CXD9872AKD_VAIO] = "vaio-ar",
4221 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4222 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4223 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4224 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
4225 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
4229 static int patch_stac9872(struct hda_codec *codec)
4231 struct sigmatel_spec *spec;
4234 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4237 if (board_config < 0)
4238 /* unknown config, let generic-parser do its job... */
4239 return snd_hda_parse_generic_codec(codec);
4241 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4246 switch (board_config) {
4247 case CXD9872RD_VAIO:
4248 case STAC9872AK_VAIO:
4249 case STAC9872K_VAIO:
4250 spec->mixer = vaio_mixer;
4251 spec->init = vaio_init;
4252 spec->multiout.max_channels = 2;
4253 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4254 spec->multiout.dac_nids = vaio_dacs;
4255 spec->multiout.hp_nid = VAIO_HP_DAC;
4256 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4257 spec->adc_nids = vaio_adcs;
4259 spec->input_mux = &vaio_mux;
4260 spec->mux_nids = vaio_mux_nids;
4261 codec->patch_ops = stac9872_vaio_patch_ops;
4264 case CXD9872AKD_VAIO:
4265 spec->mixer = vaio_ar_mixer;
4266 spec->init = vaio_ar_init;
4267 spec->multiout.max_channels = 2;
4268 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4269 spec->multiout.dac_nids = vaio_dacs;
4270 spec->multiout.hp_nid = VAIO_HP_DAC;
4271 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4273 spec->adc_nids = vaio_adcs;
4274 spec->input_mux = &vaio_mux;
4275 spec->mux_nids = vaio_mux_nids;
4276 codec->patch_ops = stac9872_patch_ops;
4287 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4288 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4289 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4290 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4291 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4292 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4293 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4294 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4295 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4296 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4297 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4298 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4299 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4300 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4301 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4302 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4303 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4304 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4305 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4306 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4307 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4308 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4309 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4310 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
4311 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4312 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4313 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4314 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4315 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4316 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4317 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4318 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
4319 /* The following does not take into account .id=0x83847661 when subsys =
4320 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4321 * currently not fully supported.
4323 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4324 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4325 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
4326 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4327 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4328 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4329 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4330 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4331 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4332 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4333 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4334 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4335 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
4336 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4337 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4338 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4339 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4340 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4341 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4342 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4343 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4344 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4345 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4346 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },