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 and direct control */
564 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
565 /* setup audio connections */
566 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
567 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
568 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
569 /* setup adcs to point to mixer */
570 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
571 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
572 /* setup import muxs */
573 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
574 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
575 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
576 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
580 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
581 /* set master volume and direct control */
582 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
583 /* setup audio connections */
584 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
585 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
586 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
587 /* connect hp ports to dac3 */
588 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
589 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
590 /* setup adcs to point to mixer */
591 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
592 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
593 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
594 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
595 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
596 /* setup import muxs */
597 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
598 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
599 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
600 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
604 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
605 /* set master volume and direct control */
606 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
607 /* setup audio connections */
608 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
609 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
610 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
611 /* dac3 is connected to import3 mux */
612 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
613 /* connect hp ports to dac4 */
614 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
615 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
616 /* setup adcs to point to mixer */
617 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
618 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
619 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
620 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
621 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
622 /* setup import muxs */
623 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
624 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
625 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
626 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
630 static struct hda_verb stac92hd71bxx_core_init[] = {
631 /* set master volume and direct control */
632 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
633 /* connect headphone jack to dac1 */
634 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
635 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
636 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
637 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
638 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
639 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
642 #define HD_DISABLE_PORTF 3
643 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
644 /* start of config #1 */
646 /* connect port 0f to audio mixer */
647 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
648 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
649 /* unmute right and left channels for node 0x0f */
650 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
651 /* start of config #2 */
653 /* set master volume and direct control */
654 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
655 /* connect headphone jack to dac1 */
656 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
657 /* connect port 0d to audio mixer */
658 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
659 /* unmute dac0 input in audio mixer */
660 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
661 /* unmute right and left channels for nodes 0x0a, 0xd */
662 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
663 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
667 static struct hda_verb stac925x_core_init[] = {
668 /* set dac0mux for dac converter */
669 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
673 static struct hda_verb stac922x_core_init[] = {
674 /* set master volume and direct control */
675 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
679 static struct hda_verb d965_core_init[] = {
680 /* set master volume and direct control */
681 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
682 /* unmute node 0x1b */
683 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
684 /* select node 0x03 as DAC */
685 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
689 static struct hda_verb stac927x_core_init[] = {
690 /* set master volume and direct control */
691 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
695 static struct hda_verb stac9205_core_init[] = {
696 /* set master volume and direct control */
697 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
701 #define STAC_MONO_MUX \
703 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
704 .name = "Mono Mux", \
706 .info = stac92xx_mono_mux_enum_info, \
707 .get = stac92xx_mono_mux_enum_get, \
708 .put = stac92xx_mono_mux_enum_put, \
711 #define STAC_INPUT_SOURCE(cnt) \
713 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
714 .name = "Input Source", \
716 .info = stac92xx_mux_enum_info, \
717 .get = stac92xx_mux_enum_get, \
718 .put = stac92xx_mux_enum_put, \
721 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
723 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
724 .name = "Analog Loopback", \
726 .info = stac92xx_aloopback_info, \
727 .get = stac92xx_aloopback_get, \
728 .put = stac92xx_aloopback_put, \
729 .private_value = verb_read | (verb_write << 16), \
732 static struct snd_kcontrol_new stac9200_mixer[] = {
733 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
734 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
735 STAC_INPUT_SOURCE(1),
736 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
737 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
738 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
742 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
743 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
745 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
746 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
748 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
749 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
751 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
752 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
754 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
755 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
757 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
758 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
760 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
761 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
763 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
764 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
768 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
769 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
771 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
772 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
774 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
775 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
777 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
778 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
780 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
781 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
783 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
784 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
786 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
787 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
789 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
790 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
794 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
795 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
797 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
798 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
800 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
801 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
803 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
804 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
806 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
807 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
809 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
810 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
812 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
813 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
815 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
816 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
820 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
821 STAC_INPUT_SOURCE(2),
823 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
824 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
825 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
827 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
828 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
829 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
831 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
832 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
834 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
835 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
839 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
840 STAC_INPUT_SOURCE(2),
841 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
843 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
844 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
845 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
847 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
848 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
849 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
853 static struct snd_kcontrol_new stac925x_mixer[] = {
854 STAC_INPUT_SOURCE(1),
855 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
856 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
857 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
861 static struct snd_kcontrol_new stac9205_mixer[] = {
862 STAC_INPUT_SOURCE(2),
863 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
865 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
866 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
867 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
869 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
870 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
871 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
876 /* This needs to be generated dynamically based on sequence */
877 static struct snd_kcontrol_new stac922x_mixer[] = {
878 STAC_INPUT_SOURCE(2),
879 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
880 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
881 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
883 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
884 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
885 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
890 static struct snd_kcontrol_new stac927x_mixer[] = {
891 STAC_INPUT_SOURCE(3),
892 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
894 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
895 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
896 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
898 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
899 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
900 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
902 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
903 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
904 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
908 static struct snd_kcontrol_new stac_dmux_mixer = {
909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
910 .name = "Digital Input Source",
911 /* count set later */
912 .info = stac92xx_dmux_enum_info,
913 .get = stac92xx_dmux_enum_get,
914 .put = stac92xx_dmux_enum_put,
917 static const char *slave_vols[] = {
918 "Front Playback Volume",
919 "Surround Playback Volume",
920 "Center Playback Volume",
921 "LFE Playback Volume",
922 "Side Playback Volume",
923 "Headphone Playback Volume",
924 "Headphone Playback Volume",
925 "Speaker Playback Volume",
926 "External Speaker Playback Volume",
927 "Speaker2 Playback Volume",
931 static const char *slave_sws[] = {
932 "Front Playback Switch",
933 "Surround Playback Switch",
934 "Center Playback Switch",
935 "LFE Playback Switch",
936 "Side Playback Switch",
937 "Headphone Playback Switch",
938 "Headphone Playback Switch",
939 "Speaker Playback Switch",
940 "External Speaker Playback Switch",
941 "Speaker2 Playback Switch",
942 "IEC958 Playback Switch",
946 static int stac92xx_build_controls(struct hda_codec *codec)
948 struct sigmatel_spec *spec = codec->spec;
952 err = snd_hda_add_new_ctls(codec, spec->mixer);
956 for (i = 0; i < spec->num_mixers; i++) {
957 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
961 if (spec->num_dmuxes > 0) {
962 stac_dmux_mixer.count = spec->num_dmuxes;
963 err = snd_ctl_add(codec->bus->card,
964 snd_ctl_new1(&stac_dmux_mixer, codec));
969 if (spec->multiout.dig_out_nid) {
970 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
973 err = snd_hda_create_spdif_share_sw(codec,
977 spec->multiout.share_spdif = 1;
979 if (spec->dig_in_nid) {
980 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
985 /* if we have no master control, let's create it */
986 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
987 unsigned int vmaster_tlv[4];
988 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
989 HDA_OUTPUT, vmaster_tlv);
990 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
991 vmaster_tlv, slave_vols);
995 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
996 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1005 static unsigned int ref9200_pin_configs[8] = {
1006 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1007 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1011 STAC 9200 pin configs for
1016 static unsigned int dell9200_d21_pin_configs[8] = {
1017 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1018 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1022 STAC 9200 pin configs for
1026 static unsigned int dell9200_d22_pin_configs[8] = {
1027 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1028 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1032 STAC 9200 pin configs for
1033 102801C4 (Dell Dimension E310)
1040 static unsigned int dell9200_d23_pin_configs[8] = {
1041 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1042 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1047 STAC 9200-32 pin configs for
1048 102801B5 (Dell Inspiron 630m)
1049 102801D8 (Dell Inspiron 640m)
1051 static unsigned int dell9200_m21_pin_configs[8] = {
1052 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1053 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1057 STAC 9200-32 pin configs for
1058 102801C2 (Dell Latitude D620)
1060 102801CC (Dell Latitude D820)
1064 static unsigned int dell9200_m22_pin_configs[8] = {
1065 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1066 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1070 STAC 9200-32 pin configs for
1071 102801CE (Dell XPS M1710)
1072 102801CF (Dell Precision M90)
1074 static unsigned int dell9200_m23_pin_configs[8] = {
1075 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1076 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1080 STAC 9200-32 pin configs for
1083 102801CB (Dell Latitude 120L)
1086 static unsigned int dell9200_m24_pin_configs[8] = {
1087 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1088 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1092 STAC 9200-32 pin configs for
1093 102801BD (Dell Inspiron E1505n)
1097 static unsigned int dell9200_m25_pin_configs[8] = {
1098 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1099 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1103 STAC 9200-32 pin configs for
1104 102801F5 (Dell Inspiron 1501)
1107 static unsigned int dell9200_m26_pin_configs[8] = {
1108 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1109 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1114 102801CD (Dell Inspiron E1705/9400)
1116 static unsigned int dell9200_m27_pin_configs[8] = {
1117 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1118 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1121 static unsigned int oqo9200_pin_configs[8] = {
1122 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1123 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1127 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1128 [STAC_REF] = ref9200_pin_configs,
1129 [STAC_9200_OQO] = oqo9200_pin_configs,
1130 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1131 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1132 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1133 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1134 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1135 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1136 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1137 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1138 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1139 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1140 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1143 static const char *stac9200_models[STAC_9200_MODELS] = {
1145 [STAC_9200_OQO] = "oqo",
1146 [STAC_9200_DELL_D21] = "dell-d21",
1147 [STAC_9200_DELL_D22] = "dell-d22",
1148 [STAC_9200_DELL_D23] = "dell-d23",
1149 [STAC_9200_DELL_M21] = "dell-m21",
1150 [STAC_9200_DELL_M22] = "dell-m22",
1151 [STAC_9200_DELL_M23] = "dell-m23",
1152 [STAC_9200_DELL_M24] = "dell-m24",
1153 [STAC_9200_DELL_M25] = "dell-m25",
1154 [STAC_9200_DELL_M26] = "dell-m26",
1155 [STAC_9200_DELL_M27] = "dell-m27",
1156 [STAC_9200_GATEWAY] = "gateway",
1157 [STAC_9200_PANASONIC] = "panasonic",
1160 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1161 /* SigmaTel reference board */
1162 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1163 "DFI LanParty", STAC_REF),
1164 /* Dell laptops have BIOS problem */
1165 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1166 "unknown Dell", STAC_9200_DELL_D21),
1167 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1168 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1169 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1170 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1171 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1172 "unknown Dell", STAC_9200_DELL_D22),
1173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1174 "unknown Dell", STAC_9200_DELL_D22),
1175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1176 "Dell Latitude D620", STAC_9200_DELL_M22),
1177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1178 "unknown Dell", STAC_9200_DELL_D23),
1179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1180 "unknown Dell", STAC_9200_DELL_D23),
1181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1182 "unknown Dell", STAC_9200_DELL_M22),
1183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1184 "unknown Dell", STAC_9200_DELL_M24),
1185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1186 "unknown Dell", STAC_9200_DELL_M24),
1187 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1188 "Dell Latitude 120L", STAC_9200_DELL_M24),
1189 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1190 "Dell Latitude D820", STAC_9200_DELL_M22),
1191 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1192 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1193 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1194 "Dell XPS M1710", STAC_9200_DELL_M23),
1195 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1196 "Dell Precision M90", STAC_9200_DELL_M23),
1197 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1198 "unknown Dell", STAC_9200_DELL_M22),
1199 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1200 "unknown Dell", STAC_9200_DELL_M22),
1201 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1202 "unknown Dell", STAC_9200_DELL_M22),
1203 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1204 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1205 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1206 "unknown Dell", STAC_9200_DELL_D23),
1207 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1208 "unknown Dell", STAC_9200_DELL_D23),
1209 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1210 "unknown Dell", STAC_9200_DELL_D21),
1211 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1212 "unknown Dell", STAC_9200_DELL_D23),
1213 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1214 "unknown Dell", STAC_9200_DELL_D21),
1215 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1216 "unknown Dell", STAC_9200_DELL_M25),
1217 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1218 "unknown Dell", STAC_9200_DELL_M25),
1219 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1220 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1221 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1222 "unknown Dell", STAC_9200_DELL_M26),
1224 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1225 /* Gateway machines needs EAPD to be set on resume */
1226 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1227 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1229 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1232 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1236 static unsigned int ref925x_pin_configs[8] = {
1237 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1238 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1241 static unsigned int stac925x_MA6_pin_configs[8] = {
1242 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1243 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1246 static unsigned int stac925x_PA6_pin_configs[8] = {
1247 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1248 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1251 static unsigned int stac925xM2_2_pin_configs[8] = {
1252 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1253 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1256 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1257 [STAC_REF] = ref925x_pin_configs,
1258 [STAC_M2_2] = stac925xM2_2_pin_configs,
1259 [STAC_MA6] = stac925x_MA6_pin_configs,
1260 [STAC_PA6] = stac925x_PA6_pin_configs,
1263 static const char *stac925x_models[STAC_925x_MODELS] = {
1265 [STAC_M2_2] = "m2-2",
1270 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1271 /* SigmaTel reference board */
1272 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1273 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1274 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1275 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1276 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1277 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1278 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1282 static unsigned int ref92hd73xx_pin_configs[13] = {
1283 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1284 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1285 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1289 static unsigned int dell_m6_pin_configs[13] = {
1290 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1291 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1292 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1296 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1297 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1298 [STAC_DELL_M6] = dell_m6_pin_configs,
1301 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1302 [STAC_92HD73XX_REF] = "ref",
1303 [STAC_DELL_M6] = "dell-m6",
1306 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1307 /* SigmaTel reference board */
1308 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1309 "DFI LanParty", STAC_92HD73XX_REF),
1310 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1311 "unknown Dell", STAC_DELL_M6),
1312 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1313 "unknown Dell", STAC_DELL_M6),
1314 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1315 "unknown Dell", STAC_DELL_M6),
1316 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1317 "unknown Dell", STAC_DELL_M6),
1318 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1319 "unknown Dell", STAC_DELL_M6),
1320 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1321 "unknown Dell", STAC_DELL_M6),
1322 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1323 "unknown Dell", STAC_DELL_M6),
1327 static unsigned int ref92hd71bxx_pin_configs[10] = {
1328 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1329 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1330 0x90a000f0, 0x01452050,
1333 static unsigned int dell_m4_1_pin_configs[10] = {
1334 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1335 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1336 0x40f000f0, 0x4f0000f0,
1339 static unsigned int dell_m4_2_pin_configs[10] = {
1340 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1341 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1342 0x40f000f0, 0x044413b0,
1345 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1346 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1347 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1348 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1351 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1352 [STAC_92HD71BXX_REF] = "ref",
1353 [STAC_DELL_M4_1] = "dell-m4-1",
1354 [STAC_DELL_M4_2] = "dell-m4-2",
1357 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1358 /* SigmaTel reference board */
1359 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1360 "DFI LanParty", STAC_92HD71BXX_REF),
1361 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1362 "unknown Dell", STAC_DELL_M4_1),
1363 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1364 "unknown Dell", STAC_DELL_M4_1),
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1366 "unknown Dell", STAC_DELL_M4_1),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1368 "unknown Dell", STAC_DELL_M4_1),
1369 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1370 "unknown Dell", STAC_DELL_M4_1),
1371 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1372 "unknown Dell", STAC_DELL_M4_1),
1373 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1374 "unknown Dell", STAC_DELL_M4_1),
1375 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1376 "unknown Dell", STAC_DELL_M4_2),
1377 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1378 "unknown Dell", STAC_DELL_M4_2),
1379 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1380 "unknown Dell", STAC_DELL_M4_2),
1381 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1382 "unknown Dell", STAC_DELL_M4_2),
1386 static unsigned int ref922x_pin_configs[10] = {
1387 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1388 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1389 0x40000100, 0x40000100,
1393 STAC 922X pin configs for
1400 static unsigned int dell_922x_d81_pin_configs[10] = {
1401 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1402 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1403 0x01813122, 0x400001f2,
1407 STAC 922X pin configs for
1411 static unsigned int dell_922x_d82_pin_configs[10] = {
1412 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1413 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1414 0x01813122, 0x400001f1,
1418 STAC 922X pin configs for
1421 static unsigned int dell_922x_m81_pin_configs[10] = {
1422 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1423 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1424 0x40C003f1, 0x405003f0,
1428 STAC 9221 A1 pin configs for
1429 102801D7 (Dell XPS M1210)
1431 static unsigned int dell_922x_m82_pin_configs[10] = {
1432 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1433 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1434 0x508003f3, 0x405003f4,
1437 static unsigned int d945gtp3_pin_configs[10] = {
1438 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1439 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1440 0x02a19120, 0x40000100,
1443 static unsigned int d945gtp5_pin_configs[10] = {
1444 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1445 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1446 0x02a19320, 0x40000100,
1449 static unsigned int intel_mac_v1_pin_configs[10] = {
1450 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1451 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1452 0x400000fc, 0x400000fb,
1455 static unsigned int intel_mac_v2_pin_configs[10] = {
1456 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1457 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1458 0x400000fc, 0x400000fb,
1461 static unsigned int intel_mac_v3_pin_configs[10] = {
1462 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1463 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1464 0x400000fc, 0x400000fb,
1467 static unsigned int intel_mac_v4_pin_configs[10] = {
1468 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1469 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1470 0x400000fc, 0x400000fb,
1473 static unsigned int intel_mac_v5_pin_configs[10] = {
1474 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1475 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1476 0x400000fc, 0x400000fb,
1480 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1481 [STAC_D945_REF] = ref922x_pin_configs,
1482 [STAC_D945GTP3] = d945gtp3_pin_configs,
1483 [STAC_D945GTP5] = d945gtp5_pin_configs,
1484 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1485 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1486 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1487 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1488 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1489 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1490 /* for backward compatibility */
1491 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1492 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1493 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1494 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1495 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1496 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1497 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1498 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1499 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1500 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1503 static const char *stac922x_models[STAC_922X_MODELS] = {
1504 [STAC_D945_REF] = "ref",
1505 [STAC_D945GTP5] = "5stack",
1506 [STAC_D945GTP3] = "3stack",
1507 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1508 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1509 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1510 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1511 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1512 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1513 /* for backward compatibility */
1514 [STAC_MACMINI] = "macmini",
1515 [STAC_MACBOOK] = "macbook",
1516 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1517 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1518 [STAC_IMAC_INTEL] = "imac-intel",
1519 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1520 [STAC_922X_DELL_D81] = "dell-d81",
1521 [STAC_922X_DELL_D82] = "dell-d82",
1522 [STAC_922X_DELL_M81] = "dell-m81",
1523 [STAC_922X_DELL_M82] = "dell-m82",
1526 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1527 /* SigmaTel reference board */
1528 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1529 "DFI LanParty", STAC_D945_REF),
1530 /* Intel 945G based systems */
1531 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1532 "Intel D945G", STAC_D945GTP3),
1533 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1534 "Intel D945G", STAC_D945GTP3),
1535 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1536 "Intel D945G", STAC_D945GTP3),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1538 "Intel D945G", STAC_D945GTP3),
1539 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1540 "Intel D945G", STAC_D945GTP3),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1542 "Intel D945G", STAC_D945GTP3),
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1544 "Intel D945G", STAC_D945GTP3),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1546 "Intel D945G", STAC_D945GTP3),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1548 "Intel D945G", STAC_D945GTP3),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1550 "Intel D945G", STAC_D945GTP3),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1552 "Intel D945G", STAC_D945GTP3),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1554 "Intel D945G", STAC_D945GTP3),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1556 "Intel D945G", STAC_D945GTP3),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1558 "Intel D945G", STAC_D945GTP3),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1560 "Intel D945G", STAC_D945GTP3),
1561 /* Intel D945G 5-stack systems */
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1563 "Intel D945G", STAC_D945GTP5),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1565 "Intel D945G", STAC_D945GTP5),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1567 "Intel D945G", STAC_D945GTP5),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1569 "Intel D945G", STAC_D945GTP5),
1570 /* Intel 945P based systems */
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1572 "Intel D945P", STAC_D945GTP3),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1574 "Intel D945P", STAC_D945GTP3),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1576 "Intel D945P", STAC_D945GTP3),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1578 "Intel D945P", STAC_D945GTP3),
1579 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1580 "Intel D945P", STAC_D945GTP3),
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1582 "Intel D945P", STAC_D945GTP5),
1584 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1585 SND_PCI_QUIRK(0x8384, 0x7680,
1586 "Mac", STAC_INTEL_MAC_AUTO),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1589 "unknown Dell", STAC_922X_DELL_D81),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1591 "unknown Dell", STAC_922X_DELL_D81),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1593 "unknown Dell", STAC_922X_DELL_D81),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1595 "unknown Dell", STAC_922X_DELL_D82),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1597 "unknown Dell", STAC_922X_DELL_M81),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1599 "unknown Dell", STAC_922X_DELL_D82),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1601 "unknown Dell", STAC_922X_DELL_D81),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1603 "unknown Dell", STAC_922X_DELL_D81),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1605 "Dell XPS M1210", STAC_922X_DELL_M82),
1609 static unsigned int ref927x_pin_configs[14] = {
1610 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1611 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1612 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1613 0x01c42190, 0x40000100,
1616 static unsigned int d965_3st_pin_configs[14] = {
1617 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1618 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1619 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1620 0x40000100, 0x40000100
1623 static unsigned int d965_5st_pin_configs[14] = {
1624 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1625 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1626 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1627 0x40000100, 0x40000100
1630 static unsigned int dell_3st_pin_configs[14] = {
1631 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1632 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1633 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1634 0x40c003fc, 0x40000100
1637 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1638 [STAC_D965_REF] = ref927x_pin_configs,
1639 [STAC_D965_3ST] = d965_3st_pin_configs,
1640 [STAC_D965_5ST] = d965_5st_pin_configs,
1641 [STAC_DELL_3ST] = dell_3st_pin_configs,
1642 [STAC_DELL_BIOS] = NULL,
1645 static const char *stac927x_models[STAC_927X_MODELS] = {
1646 [STAC_D965_REF] = "ref",
1647 [STAC_D965_3ST] = "3stack",
1648 [STAC_D965_5ST] = "5stack",
1649 [STAC_DELL_3ST] = "dell-3stack",
1650 [STAC_DELL_BIOS] = "dell-bios",
1653 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1654 /* SigmaTel reference board */
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1656 "DFI LanParty", STAC_D965_REF),
1657 /* Intel 946 based systems */
1658 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1659 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1660 /* 965 based 3 stack systems */
1661 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1662 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1665 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1666 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1669 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1677 /* Dell 3 stack systems */
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1682 /* Dell 3 stack systems with verb table in BIOS */
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell ", STAC_DELL_BIOS),
1686 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1691 /* 965 based 5 stack systems */
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1704 static unsigned int ref9205_pin_configs[12] = {
1705 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1706 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
1707 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1711 STAC 9205 pin configs for
1718 10280228 (Dell Vostro 1500)
1720 static unsigned int dell_9205_m42_pin_configs[12] = {
1721 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1722 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1723 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1727 STAC 9205 pin configs for
1731 102801FF (Dell Precision M4300)
1736 static unsigned int dell_9205_m43_pin_configs[12] = {
1737 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1738 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1739 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1742 static unsigned int dell_9205_m44_pin_configs[12] = {
1743 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1744 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1745 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1748 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1749 [STAC_9205_REF] = ref9205_pin_configs,
1750 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1751 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1752 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1755 static const char *stac9205_models[STAC_9205_MODELS] = {
1756 [STAC_9205_REF] = "ref",
1757 [STAC_9205_DELL_M42] = "dell-m42",
1758 [STAC_9205_DELL_M43] = "dell-m43",
1759 [STAC_9205_DELL_M44] = "dell-m44",
1762 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1763 /* SigmaTel reference board */
1764 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1765 "DFI LanParty", STAC_9205_REF),
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1767 "unknown Dell", STAC_9205_DELL_M42),
1768 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1769 "unknown Dell", STAC_9205_DELL_M42),
1770 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1771 "Dell Precision", STAC_9205_DELL_M43),
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1773 "Dell Precision", STAC_9205_DELL_M43),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1775 "Dell Precision", STAC_9205_DELL_M43),
1776 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1777 "unknown Dell", STAC_9205_DELL_M42),
1778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1779 "unknown Dell", STAC_9205_DELL_M42),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1781 "Dell Precision", STAC_9205_DELL_M43),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1783 "Dell Precision M4300", STAC_9205_DELL_M43),
1784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1785 "unknown Dell", STAC_9205_DELL_M42),
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1787 "Dell Precision", STAC_9205_DELL_M43),
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1789 "Dell Precision", STAC_9205_DELL_M43),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1791 "Dell Precision", STAC_9205_DELL_M43),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1793 "Dell Inspiron", STAC_9205_DELL_M44),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1795 "Dell Vostro 1500", STAC_9205_DELL_M42),
1799 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1802 struct sigmatel_spec *spec = codec->spec;
1804 if (! spec->bios_pin_configs) {
1805 spec->bios_pin_configs = kcalloc(spec->num_pins,
1806 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1807 if (! spec->bios_pin_configs)
1811 for (i = 0; i < spec->num_pins; i++) {
1812 hda_nid_t nid = spec->pin_nids[i];
1813 unsigned int pin_cfg;
1815 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1816 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1817 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1819 spec->bios_pin_configs[i] = pin_cfg;
1825 static void stac92xx_set_config_reg(struct hda_codec *codec,
1826 hda_nid_t pin_nid, unsigned int pin_config)
1829 snd_hda_codec_write(codec, pin_nid, 0,
1830 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1831 pin_config & 0x000000ff);
1832 snd_hda_codec_write(codec, pin_nid, 0,
1833 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1834 (pin_config & 0x0000ff00) >> 8);
1835 snd_hda_codec_write(codec, pin_nid, 0,
1836 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1837 (pin_config & 0x00ff0000) >> 16);
1838 snd_hda_codec_write(codec, pin_nid, 0,
1839 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1841 i = snd_hda_codec_read(codec, pin_nid, 0,
1842 AC_VERB_GET_CONFIG_DEFAULT,
1844 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1848 static void stac92xx_set_config_regs(struct hda_codec *codec)
1851 struct sigmatel_spec *spec = codec->spec;
1853 if (!spec->pin_configs)
1856 for (i = 0; i < spec->num_pins; i++)
1857 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1858 spec->pin_configs[i]);
1862 * Analog playback callbacks
1864 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1865 struct hda_codec *codec,
1866 struct snd_pcm_substream *substream)
1868 struct sigmatel_spec *spec = codec->spec;
1869 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1873 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1874 struct hda_codec *codec,
1875 unsigned int stream_tag,
1876 unsigned int format,
1877 struct snd_pcm_substream *substream)
1879 struct sigmatel_spec *spec = codec->spec;
1880 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1883 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1884 struct hda_codec *codec,
1885 struct snd_pcm_substream *substream)
1887 struct sigmatel_spec *spec = codec->spec;
1888 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1892 * Digital playback callbacks
1894 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1895 struct hda_codec *codec,
1896 struct snd_pcm_substream *substream)
1898 struct sigmatel_spec *spec = codec->spec;
1899 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1902 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1903 struct hda_codec *codec,
1904 struct snd_pcm_substream *substream)
1906 struct sigmatel_spec *spec = codec->spec;
1907 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1910 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1911 struct hda_codec *codec,
1912 unsigned int stream_tag,
1913 unsigned int format,
1914 struct snd_pcm_substream *substream)
1916 struct sigmatel_spec *spec = codec->spec;
1917 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1918 stream_tag, format, substream);
1923 * Analog capture callbacks
1925 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1926 struct hda_codec *codec,
1927 unsigned int stream_tag,
1928 unsigned int format,
1929 struct snd_pcm_substream *substream)
1931 struct sigmatel_spec *spec = codec->spec;
1933 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1934 stream_tag, 0, format);
1938 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1939 struct hda_codec *codec,
1940 struct snd_pcm_substream *substream)
1942 struct sigmatel_spec *spec = codec->spec;
1944 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
1948 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1952 /* NID is set in stac92xx_build_pcms */
1954 .open = stac92xx_dig_playback_pcm_open,
1955 .close = stac92xx_dig_playback_pcm_close,
1956 .prepare = stac92xx_dig_playback_pcm_prepare
1960 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1964 /* NID is set in stac92xx_build_pcms */
1967 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1971 .nid = 0x02, /* NID to query formats and rates */
1973 .open = stac92xx_playback_pcm_open,
1974 .prepare = stac92xx_playback_pcm_prepare,
1975 .cleanup = stac92xx_playback_pcm_cleanup
1979 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1983 .nid = 0x06, /* NID to query formats and rates */
1985 .open = stac92xx_playback_pcm_open,
1986 .prepare = stac92xx_playback_pcm_prepare,
1987 .cleanup = stac92xx_playback_pcm_cleanup
1991 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
1994 /* NID + .substreams is set in stac92xx_build_pcms */
1996 .prepare = stac92xx_capture_pcm_prepare,
1997 .cleanup = stac92xx_capture_pcm_cleanup
2001 static int stac92xx_build_pcms(struct hda_codec *codec)
2003 struct sigmatel_spec *spec = codec->spec;
2004 struct hda_pcm *info = spec->pcm_rec;
2006 codec->num_pcms = 1;
2007 codec->pcm_info = info;
2009 info->name = "STAC92xx Analog";
2010 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2011 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2012 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2013 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2015 if (spec->alt_switch) {
2018 info->name = "STAC92xx Analog Alt";
2019 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2022 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2025 info->name = "STAC92xx Digital";
2026 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2027 if (spec->multiout.dig_out_nid) {
2028 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2029 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2031 if (spec->dig_in_nid) {
2032 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2033 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2040 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2042 unsigned int pincap = snd_hda_param_read(codec, nid,
2044 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2045 if (pincap & AC_PINCAP_VREF_100)
2046 return AC_PINCTL_VREF_100;
2047 if (pincap & AC_PINCAP_VREF_80)
2048 return AC_PINCTL_VREF_80;
2049 if (pincap & AC_PINCAP_VREF_50)
2050 return AC_PINCTL_VREF_50;
2051 if (pincap & AC_PINCAP_VREF_GRD)
2052 return AC_PINCTL_VREF_GRD;
2056 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2059 snd_hda_codec_write_cache(codec, nid, 0,
2060 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2063 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2065 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2066 struct snd_ctl_elem_value *ucontrol)
2068 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2069 struct sigmatel_spec *spec = codec->spec;
2071 ucontrol->value.integer.value[0] = spec->hp_switch;
2075 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2076 struct snd_ctl_elem_value *ucontrol)
2078 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2079 struct sigmatel_spec *spec = codec->spec;
2081 spec->hp_switch = ucontrol->value.integer.value[0];
2083 /* check to be sure that the ports are upto date with
2086 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2091 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2093 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2095 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2096 struct sigmatel_spec *spec = codec->spec;
2097 int io_idx = kcontrol-> private_value & 0xff;
2099 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2103 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2105 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2106 struct sigmatel_spec *spec = codec->spec;
2107 hda_nid_t nid = kcontrol->private_value >> 8;
2108 int io_idx = kcontrol-> private_value & 0xff;
2109 unsigned short val = !!ucontrol->value.integer.value[0];
2111 spec->io_switch[io_idx] = val;
2114 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2116 unsigned int pinctl = AC_PINCTL_IN_EN;
2117 if (io_idx) /* set VREF for mic */
2118 pinctl |= stac92xx_get_vref(codec, nid);
2119 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2122 /* check the auto-mute again: we need to mute/unmute the speaker
2123 * appropriately according to the pin direction
2125 if (spec->hp_detect)
2126 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2131 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2133 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2134 struct snd_ctl_elem_value *ucontrol)
2136 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2137 struct sigmatel_spec *spec = codec->spec;
2139 ucontrol->value.integer.value[0] = spec->clfe_swap;
2143 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2144 struct snd_ctl_elem_value *ucontrol)
2146 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2147 struct sigmatel_spec *spec = codec->spec;
2148 hda_nid_t nid = kcontrol->private_value & 0xff;
2149 unsigned int val = !!ucontrol->value.integer.value[0];
2151 if (spec->clfe_swap == val)
2154 spec->clfe_swap = val;
2156 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2157 spec->clfe_swap ? 0x4 : 0x0);
2162 #define STAC_CODEC_HP_SWITCH(xname) \
2163 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2166 .info = stac92xx_hp_switch_info, \
2167 .get = stac92xx_hp_switch_get, \
2168 .put = stac92xx_hp_switch_put, \
2171 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2172 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2175 .info = stac92xx_io_switch_info, \
2176 .get = stac92xx_io_switch_get, \
2177 .put = stac92xx_io_switch_put, \
2178 .private_value = xpval, \
2181 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2182 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2185 .info = stac92xx_clfe_switch_info, \
2186 .get = stac92xx_clfe_switch_get, \
2187 .put = stac92xx_clfe_switch_put, \
2188 .private_value = xpval, \
2192 STAC_CTL_WIDGET_VOL,
2193 STAC_CTL_WIDGET_MUTE,
2194 STAC_CTL_WIDGET_MONO_MUX,
2195 STAC_CTL_WIDGET_HP_SWITCH,
2196 STAC_CTL_WIDGET_IO_SWITCH,
2197 STAC_CTL_WIDGET_CLFE_SWITCH
2200 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2201 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2202 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2204 STAC_CODEC_HP_SWITCH(NULL),
2205 STAC_CODEC_IO_SWITCH(NULL, 0),
2206 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2209 /* add dynamic controls */
2210 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2212 struct snd_kcontrol_new *knew;
2214 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2215 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2217 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2220 if (spec->kctl_alloc) {
2221 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2222 kfree(spec->kctl_alloc);
2224 spec->kctl_alloc = knew;
2225 spec->num_kctl_alloc = num;
2228 knew = &spec->kctl_alloc[spec->num_kctl_used];
2229 *knew = stac92xx_control_templates[type];
2230 knew->name = kstrdup(name, GFP_KERNEL);
2233 knew->private_value = val;
2234 spec->num_kctl_used++;
2238 /* flag inputs as additional dynamic lineouts */
2239 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2241 struct sigmatel_spec *spec = codec->spec;
2242 unsigned int wcaps, wtype;
2243 int i, num_dacs = 0;
2245 /* use the wcaps cache to count all DACs available for line-outs */
2246 for (i = 0; i < codec->num_nodes; i++) {
2247 wcaps = codec->wcaps[i];
2248 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2250 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2254 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2256 switch (cfg->line_outs) {
2258 /* add line-in as side */
2259 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2260 cfg->line_out_pins[cfg->line_outs] =
2261 cfg->input_pins[AUTO_PIN_LINE];
2262 spec->line_switch = 1;
2267 /* add line-in as clfe and mic as side */
2268 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2269 cfg->line_out_pins[cfg->line_outs] =
2270 cfg->input_pins[AUTO_PIN_LINE];
2271 spec->line_switch = 1;
2274 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2275 cfg->line_out_pins[cfg->line_outs] =
2276 cfg->input_pins[AUTO_PIN_MIC];
2277 spec->mic_switch = 1;
2282 /* add line-in as surr and mic as clfe */
2283 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2284 cfg->line_out_pins[cfg->line_outs] =
2285 cfg->input_pins[AUTO_PIN_LINE];
2286 spec->line_switch = 1;
2289 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2290 cfg->line_out_pins[cfg->line_outs] =
2291 cfg->input_pins[AUTO_PIN_MIC];
2292 spec->mic_switch = 1;
2302 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2306 for (i = 0; i < spec->multiout.num_dacs; i++) {
2307 if (spec->multiout.dac_nids[i] == nid)
2315 * Fill in the dac_nids table from the parsed pin configuration
2316 * This function only works when every pin in line_out_pins[]
2317 * contains atleast one DAC in its connection list. Some 92xx
2318 * codecs are not connected directly to a DAC, such as the 9200
2319 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2321 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2322 struct auto_pin_cfg *cfg)
2324 struct sigmatel_spec *spec = codec->spec;
2325 int i, j, conn_len = 0;
2326 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2327 unsigned int wcaps, wtype;
2329 for (i = 0; i < cfg->line_outs; i++) {
2330 nid = cfg->line_out_pins[i];
2331 conn_len = snd_hda_get_connections(codec, nid, conn,
2332 HDA_MAX_CONNECTIONS);
2333 for (j = 0; j < conn_len; j++) {
2334 wcaps = snd_hda_param_read(codec, conn[j],
2335 AC_PAR_AUDIO_WIDGET_CAP);
2336 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2337 if (wtype != AC_WID_AUD_OUT ||
2338 (wcaps & AC_WCAP_DIGITAL))
2340 /* conn[j] is a DAC routed to this line-out */
2341 if (!is_in_dac_nids(spec, conn[j]))
2345 if (j == conn_len) {
2346 if (spec->multiout.num_dacs > 0) {
2347 /* we have already working output pins,
2348 * so let's drop the broken ones again
2350 cfg->line_outs = spec->multiout.num_dacs;
2353 /* error out, no available DAC found */
2355 "%s: No available DAC for pin 0x%x\n",
2360 spec->multiout.dac_nids[i] = conn[j];
2361 spec->multiout.num_dacs++;
2363 /* select this DAC in the pin's input mux */
2364 snd_hda_codec_write_cache(codec, nid, 0,
2365 AC_VERB_SET_CONNECT_SEL, j);
2370 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2371 spec->multiout.num_dacs,
2372 spec->multiout.dac_nids[0],
2373 spec->multiout.dac_nids[1],
2374 spec->multiout.dac_nids[2],
2375 spec->multiout.dac_nids[3],
2376 spec->multiout.dac_nids[4]);
2380 /* create volume control/switch for the given prefx type */
2381 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2386 sprintf(name, "%s Playback Volume", pfx);
2387 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2388 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2391 sprintf(name, "%s Playback Switch", pfx);
2392 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2393 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2399 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2401 if (!spec->multiout.hp_nid)
2402 spec->multiout.hp_nid = nid;
2403 else if (spec->multiout.num_dacs > 4) {
2404 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2407 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2408 spec->multiout.num_dacs++;
2413 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2415 if (is_in_dac_nids(spec, nid))
2417 if (spec->multiout.hp_nid == nid)
2422 /* add playback controls from the parsed DAC table */
2423 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2424 const struct auto_pin_cfg *cfg)
2426 static const char *chname[4] = {
2427 "Front", "Surround", NULL /*CLFE*/, "Side"
2432 struct sigmatel_spec *spec = codec->spec;
2433 unsigned int wid_caps, pincap;
2436 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2437 if (!spec->multiout.dac_nids[i])
2440 nid = spec->multiout.dac_nids[i];
2444 err = create_controls(spec, "Center", nid, 1);
2447 err = create_controls(spec, "LFE", nid, 2);
2451 wid_caps = get_wcaps(codec, nid);
2453 if (wid_caps & AC_WCAP_LR_SWAP) {
2454 err = stac92xx_add_control(spec,
2455 STAC_CTL_WIDGET_CLFE_SWITCH,
2456 "Swap Center/LFE Playback Switch", nid);
2463 err = create_controls(spec, chname[i], nid, 3);
2469 if (cfg->hp_outs > 1) {
2470 err = stac92xx_add_control(spec,
2471 STAC_CTL_WIDGET_HP_SWITCH,
2472 "Headphone as Line Out Switch", 0);
2477 if (spec->line_switch) {
2478 nid = cfg->input_pins[AUTO_PIN_LINE];
2479 pincap = snd_hda_param_read(codec, nid,
2481 if (pincap & AC_PINCAP_OUT) {
2482 err = stac92xx_add_control(spec,
2483 STAC_CTL_WIDGET_IO_SWITCH,
2484 "Line In as Output Switch", nid << 8);
2490 if (spec->mic_switch) {
2491 unsigned int def_conf;
2492 unsigned int mic_pin = AUTO_PIN_MIC;
2494 nid = cfg->input_pins[mic_pin];
2495 def_conf = snd_hda_codec_read(codec, nid, 0,
2496 AC_VERB_GET_CONFIG_DEFAULT, 0);
2497 /* some laptops have an internal analog microphone
2498 * which can't be used as a output */
2499 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2500 pincap = snd_hda_param_read(codec, nid,
2502 if (pincap & AC_PINCAP_OUT) {
2503 err = stac92xx_add_control(spec,
2504 STAC_CTL_WIDGET_IO_SWITCH,
2505 "Mic as Output Switch", (nid << 8) | 1);
2506 nid = snd_hda_codec_read(codec, nid, 0,
2507 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2508 if (!check_in_dac_nids(spec, nid))
2509 add_spec_dacs(spec, nid);
2513 } else if (mic_pin == AUTO_PIN_MIC) {
2514 mic_pin = AUTO_PIN_FRONT_MIC;
2522 /* add playback controls for Speaker and HP outputs */
2523 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2524 struct auto_pin_cfg *cfg)
2526 struct sigmatel_spec *spec = codec->spec;
2528 int i, old_num_dacs, err;
2530 old_num_dacs = spec->multiout.num_dacs;
2531 for (i = 0; i < cfg->hp_outs; i++) {
2532 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2533 if (wid_caps & AC_WCAP_UNSOL_CAP)
2534 spec->hp_detect = 1;
2535 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2536 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2537 if (check_in_dac_nids(spec, nid))
2541 add_spec_dacs(spec, nid);
2543 for (i = 0; i < cfg->speaker_outs; i++) {
2544 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2545 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2546 if (check_in_dac_nids(spec, nid))
2550 add_spec_dacs(spec, nid);
2552 for (i = 0; i < cfg->line_outs; i++) {
2553 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2554 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2555 if (check_in_dac_nids(spec, nid))
2559 add_spec_dacs(spec, nid);
2561 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2562 static const char *pfxs[] = {
2563 "Speaker", "External Speaker", "Speaker2",
2565 err = create_controls(spec, pfxs[i - old_num_dacs],
2566 spec->multiout.dac_nids[i], 3);
2570 if (spec->multiout.hp_nid) {
2571 err = create_controls(spec, "Headphone",
2572 spec->multiout.hp_nid, 3);
2580 /* labels for mono mux outputs */
2581 static const char *stac92xx_mono_labels[3] = {
2582 "DAC0", "DAC1", "Mixer"
2585 /* create mono mux for mono out on capable codecs */
2586 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2588 struct sigmatel_spec *spec = codec->spec;
2589 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2591 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2593 num_cons = snd_hda_get_connections(codec,
2596 HDA_MAX_NUM_INPUTS);
2597 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2600 for (i = 0; i < num_cons; i++) {
2601 mono_mux->items[mono_mux->num_items].label =
2602 stac92xx_mono_labels[i];
2603 mono_mux->items[mono_mux->num_items].index = i;
2604 mono_mux->num_items++;
2607 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2608 "Mono Mux", spec->mono_nid);
2611 /* labels for dmic mux inputs */
2612 static const char *stac92xx_dmic_labels[5] = {
2613 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2614 "Digital Mic 3", "Digital Mic 4"
2617 /* create playback/capture controls for input pins on dmic capable codecs */
2618 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2619 const struct auto_pin_cfg *cfg)
2621 struct sigmatel_spec *spec = codec->spec;
2622 struct hda_input_mux *dimux = &spec->private_dimux;
2623 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2627 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2628 dimux->items[dimux->num_items].index = 0;
2631 for (i = 0; i < spec->num_dmics; i++) {
2636 unsigned int def_conf;
2638 def_conf = snd_hda_codec_read(codec,
2641 AC_VERB_GET_CONFIG_DEFAULT,
2643 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2646 nid = spec->dmic_nids[i];
2647 num_cons = snd_hda_get_connections(codec,
2650 HDA_MAX_NUM_INPUTS);
2651 for (j = 0; j < num_cons; j++)
2652 if (con_lst[j] == nid) {
2658 wcaps = get_wcaps(codec, nid);
2660 if (wcaps & AC_WCAP_OUT_AMP) {
2661 sprintf(name, "%s Capture Volume",
2662 stac92xx_dmic_labels[dimux->num_items]);
2664 err = stac92xx_add_control(spec,
2665 STAC_CTL_WIDGET_VOL,
2667 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2672 dimux->items[dimux->num_items].label =
2673 stac92xx_dmic_labels[dimux->num_items];
2674 dimux->items[dimux->num_items].index = index;
2681 /* create playback/capture controls for input pins */
2682 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2684 struct sigmatel_spec *spec = codec->spec;
2685 struct hda_input_mux *imux = &spec->private_imux;
2686 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2689 for (i = 0; i < AUTO_PIN_LAST; i++) {
2692 if (!cfg->input_pins[i])
2695 for (j = 0; j < spec->num_muxes; j++) {
2697 num_cons = snd_hda_get_connections(codec,
2700 HDA_MAX_NUM_INPUTS);
2701 for (k = 0; k < num_cons; k++)
2702 if (con_lst[k] == cfg->input_pins[i]) {
2709 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2710 imux->items[imux->num_items].index = index;
2714 if (imux->num_items) {
2716 * Set the current input for the muxes.
2717 * The STAC9221 has two input muxes with identical source
2718 * NID lists. Hopefully this won't get confused.
2720 for (i = 0; i < spec->num_muxes; i++) {
2721 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2722 AC_VERB_SET_CONNECT_SEL,
2723 imux->items[0].index);
2730 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2732 struct sigmatel_spec *spec = codec->spec;
2735 for (i = 0; i < spec->autocfg.line_outs; i++) {
2736 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2737 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2741 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2743 struct sigmatel_spec *spec = codec->spec;
2746 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2748 pin = spec->autocfg.hp_pins[i];
2749 if (pin) /* connect to front */
2750 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2752 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2754 pin = spec->autocfg.speaker_pins[i];
2755 if (pin) /* connect to front */
2756 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2760 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2762 struct sigmatel_spec *spec = codec->spec;
2764 int hp_speaker_swap = 0;
2766 if ((err = snd_hda_parse_pin_def_config(codec,
2768 spec->dmic_nids)) < 0)
2770 if (! spec->autocfg.line_outs)
2771 return 0; /* can't find valid pin config */
2773 /* If we have no real line-out pin and multiple hp-outs, HPs should
2774 * be set up as multi-channel outputs.
2776 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2777 spec->autocfg.hp_outs > 1) {
2778 /* Copy hp_outs to line_outs, backup line_outs in
2779 * speaker_outs so that the following routines can handle
2780 * HP pins as primary outputs.
2782 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2783 sizeof(spec->autocfg.line_out_pins));
2784 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2785 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2786 sizeof(spec->autocfg.hp_pins));
2787 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2788 hp_speaker_swap = 1;
2790 if (spec->autocfg.mono_out_pin) {
2791 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2792 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2793 u32 caps = query_amp_caps(codec,
2794 spec->autocfg.mono_out_pin, dir);
2795 hda_nid_t conn_list[1];
2797 /* get the mixer node and then the mono mux if it exists */
2798 if (snd_hda_get_connections(codec,
2799 spec->autocfg.mono_out_pin, conn_list, 1) &&
2800 snd_hda_get_connections(codec, conn_list[0],
2803 int wcaps = get_wcaps(codec, conn_list[0]);
2804 int wid_type = (wcaps & AC_WCAP_TYPE)
2805 >> AC_WCAP_TYPE_SHIFT;
2806 /* LR swap check, some stac925x have a mux that
2807 * changes the DACs output path instead of the
2810 if (wid_type == AC_WID_AUD_SEL &&
2811 !(wcaps & AC_WCAP_LR_SWAP))
2812 spec->mono_nid = conn_list[0];
2814 /* all mono outs have a least a mute/unmute switch */
2815 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2816 "Mono Playback Switch",
2817 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2821 /* check to see if there is volume support for the amp */
2822 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2823 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2824 "Mono Playback Volume",
2825 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2831 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2835 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2837 if (spec->multiout.num_dacs == 0)
2838 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2841 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2846 if (hp_speaker_swap == 1) {
2847 /* Restore the hp_outs and line_outs */
2848 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2849 sizeof(spec->autocfg.line_out_pins));
2850 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2851 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2852 sizeof(spec->autocfg.speaker_pins));
2853 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2854 memset(spec->autocfg.speaker_pins, 0,
2855 sizeof(spec->autocfg.speaker_pins));
2856 spec->autocfg.speaker_outs = 0;
2859 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2864 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2869 if (spec->mono_nid > 0) {
2870 err = stac92xx_auto_create_mono_output_ctls(codec);
2875 if (spec->num_dmics > 0)
2876 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2877 &spec->autocfg)) < 0)
2880 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2881 if (spec->multiout.max_channels > 2)
2882 spec->surr_switch = 1;
2884 if (spec->autocfg.dig_out_pin)
2885 spec->multiout.dig_out_nid = dig_out;
2886 if (spec->autocfg.dig_in_pin)
2887 spec->dig_in_nid = dig_in;
2889 if (spec->kctl_alloc)
2890 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2892 spec->input_mux = &spec->private_imux;
2893 if (!spec->dinput_mux)
2894 spec->dinput_mux = &spec->private_dimux;
2895 spec->mono_mux = &spec->private_mono_mux;
2900 /* add playback controls for HP output */
2901 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2902 struct auto_pin_cfg *cfg)
2904 struct sigmatel_spec *spec = codec->spec;
2905 hda_nid_t pin = cfg->hp_pins[0];
2906 unsigned int wid_caps;
2911 wid_caps = get_wcaps(codec, pin);
2912 if (wid_caps & AC_WCAP_UNSOL_CAP)
2913 spec->hp_detect = 1;
2918 /* add playback controls for LFE output */
2919 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2920 struct auto_pin_cfg *cfg)
2922 struct sigmatel_spec *spec = codec->spec;
2924 hda_nid_t lfe_pin = 0x0;
2928 * search speaker outs and line outs for a mono speaker pin
2929 * with an amp. If one is found, add LFE controls
2932 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2933 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2934 unsigned int wcaps = get_wcaps(codec, pin);
2935 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2936 if (wcaps == AC_WCAP_OUT_AMP)
2937 /* found a mono speaker with an amp, must be lfe */
2941 /* if speaker_outs is 0, then speakers may be in line_outs */
2942 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2943 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2944 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2945 unsigned int defcfg;
2946 defcfg = snd_hda_codec_read(codec, pin, 0,
2947 AC_VERB_GET_CONFIG_DEFAULT,
2949 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2950 unsigned int wcaps = get_wcaps(codec, pin);
2951 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2952 if (wcaps == AC_WCAP_OUT_AMP)
2953 /* found a mono speaker with an amp,
2961 err = create_controls(spec, "LFE", lfe_pin, 1);
2969 static int stac9200_parse_auto_config(struct hda_codec *codec)
2971 struct sigmatel_spec *spec = codec->spec;
2974 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
2977 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
2980 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
2983 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
2986 if (spec->autocfg.dig_out_pin)
2987 spec->multiout.dig_out_nid = 0x05;
2988 if (spec->autocfg.dig_in_pin)
2989 spec->dig_in_nid = 0x04;
2991 if (spec->kctl_alloc)
2992 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2994 spec->input_mux = &spec->private_imux;
2995 spec->dinput_mux = &spec->private_dimux;
3001 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3002 * funky external mute control using GPIO pins.
3005 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3006 unsigned int dir_mask, unsigned int data)
3008 unsigned int gpiostate, gpiomask, gpiodir;
3010 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3011 AC_VERB_GET_GPIO_DATA, 0);
3012 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3014 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3015 AC_VERB_GET_GPIO_MASK, 0);
3018 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3019 AC_VERB_GET_GPIO_DIRECTION, 0);
3020 gpiodir |= dir_mask;
3022 /* Configure GPIOx as CMOS */
3023 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3025 snd_hda_codec_write(codec, codec->afg, 0,
3026 AC_VERB_SET_GPIO_MASK, gpiomask);
3027 snd_hda_codec_read(codec, codec->afg, 0,
3028 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3032 snd_hda_codec_read(codec, codec->afg, 0,
3033 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3036 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3039 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3040 snd_hda_codec_write_cache(codec, nid, 0,
3041 AC_VERB_SET_UNSOLICITED_ENABLE,
3042 (AC_USRSP_EN | event));
3045 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3048 for (i = 0; i < cfg->hp_outs; i++)
3049 if (cfg->hp_pins[i] == nid)
3050 return 1; /* nid is a HP-Out */
3052 return 0; /* nid is not a HP-Out */
3055 static void stac92xx_power_down(struct hda_codec *codec)
3057 struct sigmatel_spec *spec = codec->spec;
3059 /* power down inactive DACs */
3061 for (dac = spec->dac_list; *dac; dac++)
3062 if (!is_in_dac_nids(spec, *dac) &&
3063 spec->multiout.hp_nid != *dac)
3064 snd_hda_codec_write_cache(codec, *dac, 0,
3065 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3068 static int stac92xx_init(struct hda_codec *codec)
3070 struct sigmatel_spec *spec = codec->spec;
3071 struct auto_pin_cfg *cfg = &spec->autocfg;
3074 snd_hda_sequence_write(codec, spec->init);
3077 if (spec->hp_detect) {
3078 /* Enable unsolicited responses on the HP widget */
3079 for (i = 0; i < cfg->hp_outs; i++)
3080 enable_pin_detect(codec, cfg->hp_pins[i],
3082 /* force to enable the first line-out; the others are set up
3085 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3087 stac92xx_auto_init_hp_out(codec);
3088 /* fake event to set up pins */
3089 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3091 stac92xx_auto_init_multi_out(codec);
3092 stac92xx_auto_init_hp_out(codec);
3094 for (i = 0; i < AUTO_PIN_LAST; i++) {
3095 hda_nid_t nid = cfg->input_pins[i];
3097 unsigned int pinctl = AC_PINCTL_IN_EN;
3098 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3099 pinctl |= stac92xx_get_vref(codec, nid);
3100 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3103 for (i = 0; i < spec->num_dmics; i++)
3104 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3106 for (i = 0; i < spec->num_pwrs; i++) {
3107 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3108 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3109 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3110 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3111 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3112 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3113 def_conf = get_defcfg_connect(def_conf);
3114 /* outputs are only ports capable of power management
3115 * any attempts on powering down a input port cause the
3116 * referenced VREF to act quirky.
3118 if (pinctl & AC_PINCTL_IN_EN)
3120 /* skip any ports that don't have jacks since presence
3121 * detection is useless */
3122 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3124 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3125 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3128 stac92xx_power_down(codec);
3129 if (cfg->dig_out_pin)
3130 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3132 if (cfg->dig_in_pin)
3133 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3136 stac_gpio_set(codec, spec->gpio_mask,
3137 spec->gpio_dir, spec->gpio_data);
3142 static void stac92xx_free(struct hda_codec *codec)
3144 struct sigmatel_spec *spec = codec->spec;
3150 if (spec->kctl_alloc) {
3151 for (i = 0; i < spec->num_kctl_used; i++)
3152 kfree(spec->kctl_alloc[i].name);
3153 kfree(spec->kctl_alloc);
3156 if (spec->bios_pin_configs)
3157 kfree(spec->bios_pin_configs);
3162 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3165 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3166 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3168 if (pin_ctl & AC_PINCTL_IN_EN) {
3170 * we need to check the current set-up direction of
3171 * shared input pins since they can be switched via
3172 * "xxx as Output" mixer switch
3174 struct sigmatel_spec *spec = codec->spec;
3175 struct auto_pin_cfg *cfg = &spec->autocfg;
3176 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3177 spec->line_switch) ||
3178 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3183 /* if setting pin direction bits, clear the current
3184 direction bits first */
3185 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3186 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3188 snd_hda_codec_write_cache(codec, nid, 0,
3189 AC_VERB_SET_PIN_WIDGET_CONTROL,
3193 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3196 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3197 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3198 snd_hda_codec_write_cache(codec, nid, 0,
3199 AC_VERB_SET_PIN_WIDGET_CONTROL,
3203 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3207 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3209 unsigned int pinctl;
3210 pinctl = snd_hda_codec_read(codec, nid, 0,
3211 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3212 if (pinctl & AC_PINCTL_IN_EN)
3213 return 0; /* mic- or line-input */
3215 return 1; /* HP-output */
3220 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3222 struct sigmatel_spec *spec = codec->spec;
3223 struct auto_pin_cfg *cfg = &spec->autocfg;
3224 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3228 if (spec->gpio_mute)
3229 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3230 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3232 for (i = 0; i < cfg->hp_outs; i++) {
3235 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3237 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3241 /* disable lineouts, enable hp */
3242 if (spec->hp_switch)
3243 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3244 for (i = 0; i < cfg->line_outs; i++)
3245 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3247 for (i = 0; i < cfg->speaker_outs; i++)
3248 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3250 if (spec->eapd_mask)
3251 stac_gpio_set(codec, spec->gpio_mask,
3252 spec->gpio_dir, spec->gpio_data &
3255 /* enable lineouts, disable hp */
3256 if (spec->hp_switch)
3257 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3258 for (i = 0; i < cfg->line_outs; i++)
3259 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3261 for (i = 0; i < cfg->speaker_outs; i++)
3262 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3264 if (spec->eapd_mask)
3265 stac_gpio_set(codec, spec->gpio_mask,
3266 spec->gpio_dir, spec->gpio_data |
3269 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3270 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3273 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3275 struct sigmatel_spec *spec = codec->spec;
3276 hda_nid_t nid = spec->pwr_nids[idx];
3278 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3280 presence = get_hp_pin_presence(codec, nid);
3288 /* power down unused output ports */
3289 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3292 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3294 struct sigmatel_spec *spec = codec->spec;
3295 int idx = res >> 26 & 0x0f;
3297 switch ((res >> 26) & 0x30) {
3299 stac92xx_hp_detect(codec, res);
3301 case STAC_PWR_EVENT:
3302 if (spec->num_pwrs > 0)
3303 stac92xx_pin_sense(codec, idx);
3307 #ifdef SND_HDA_NEEDS_RESUME
3308 static int stac92xx_resume(struct hda_codec *codec)
3310 struct sigmatel_spec *spec = codec->spec;
3312 stac92xx_set_config_regs(codec);
3313 snd_hda_sequence_write(codec, spec->init);
3314 stac_gpio_set(codec, spec->gpio_mask,
3315 spec->gpio_dir, spec->gpio_data);
3316 snd_hda_codec_resume_amp(codec);
3317 snd_hda_codec_resume_cache(codec);
3318 /* power down inactive DACs */
3320 stac92xx_power_down(codec);
3321 /* invoke unsolicited event to reset the HP state */
3322 if (spec->hp_detect)
3323 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3328 static struct hda_codec_ops stac92xx_patch_ops = {
3329 .build_controls = stac92xx_build_controls,
3330 .build_pcms = stac92xx_build_pcms,
3331 .init = stac92xx_init,
3332 .free = stac92xx_free,
3333 .unsol_event = stac92xx_unsol_event,
3334 #ifdef SND_HDA_NEEDS_RESUME
3335 .resume = stac92xx_resume,
3339 static int patch_stac9200(struct hda_codec *codec)
3341 struct sigmatel_spec *spec;
3344 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3349 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3350 spec->pin_nids = stac9200_pin_nids;
3351 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3354 if (spec->board_config < 0) {
3355 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3356 err = stac92xx_save_bios_config_regs(codec);
3358 stac92xx_free(codec);
3361 spec->pin_configs = spec->bios_pin_configs;
3363 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3364 stac92xx_set_config_regs(codec);
3367 spec->multiout.max_channels = 2;
3368 spec->multiout.num_dacs = 1;
3369 spec->multiout.dac_nids = stac9200_dac_nids;
3370 spec->adc_nids = stac9200_adc_nids;
3371 spec->mux_nids = stac9200_mux_nids;
3372 spec->num_muxes = 1;
3373 spec->num_dmics = 0;
3377 if (spec->board_config == STAC_9200_GATEWAY ||
3378 spec->board_config == STAC_9200_OQO)
3379 spec->init = stac9200_eapd_init;
3381 spec->init = stac9200_core_init;
3382 spec->mixer = stac9200_mixer;
3384 if (spec->board_config == STAC_9200_PANASONIC) {
3385 spec->gpio_mask = spec->gpio_dir = 0x09;
3386 spec->gpio_data = 0x00;
3389 err = stac9200_parse_auto_config(codec);
3391 stac92xx_free(codec);
3395 codec->patch_ops = stac92xx_patch_ops;
3400 static int patch_stac925x(struct hda_codec *codec)
3402 struct sigmatel_spec *spec;
3405 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3410 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3411 spec->pin_nids = stac925x_pin_nids;
3412 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3416 if (spec->board_config < 0) {
3417 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3418 "using BIOS defaults\n");
3419 err = stac92xx_save_bios_config_regs(codec);
3421 stac92xx_free(codec);
3424 spec->pin_configs = spec->bios_pin_configs;
3425 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3426 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3427 stac92xx_set_config_regs(codec);
3430 spec->multiout.max_channels = 2;
3431 spec->multiout.num_dacs = 1;
3432 spec->multiout.dac_nids = stac925x_dac_nids;
3433 spec->adc_nids = stac925x_adc_nids;
3434 spec->mux_nids = stac925x_mux_nids;
3435 spec->num_muxes = 1;
3438 switch (codec->vendor_id) {
3439 case 0x83847632: /* STAC9202 */
3440 case 0x83847633: /* STAC9202D */
3441 case 0x83847636: /* STAC9251 */
3442 case 0x83847637: /* STAC9251D */
3443 spec->num_dmics = STAC925X_NUM_DMICS;
3444 spec->dmic_nids = stac925x_dmic_nids;
3445 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3446 spec->dmux_nids = stac925x_dmux_nids;
3449 spec->num_dmics = 0;
3453 spec->init = stac925x_core_init;
3454 spec->mixer = stac925x_mixer;
3456 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
3458 if (spec->board_config < 0) {
3459 printk(KERN_WARNING "hda_codec: No auto-config is "
3460 "available, default to model=ref\n");
3461 spec->board_config = STAC_925x_REF;
3467 stac92xx_free(codec);
3471 codec->patch_ops = stac92xx_patch_ops;
3476 static struct hda_input_mux stac92hd73xx_dmux = {
3479 { "Analog Inputs", 0x0b },
3481 { "Digital Mic 1", 0x09 },
3482 { "Digital Mic 2", 0x0a },
3486 static int patch_stac92hd73xx(struct hda_codec *codec)
3488 struct sigmatel_spec *spec;
3489 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3492 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3497 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3498 spec->pin_nids = stac92hd73xx_pin_nids;
3499 spec->board_config = snd_hda_check_board_config(codec,
3500 STAC_92HD73XX_MODELS,
3501 stac92hd73xx_models,
3502 stac92hd73xx_cfg_tbl);
3504 if (spec->board_config < 0) {
3505 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3506 " STAC92HD73XX, using BIOS defaults\n");
3507 err = stac92xx_save_bios_config_regs(codec);
3509 stac92xx_free(codec);
3512 spec->pin_configs = spec->bios_pin_configs;
3514 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3515 stac92xx_set_config_regs(codec);
3518 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3519 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3521 if (spec->multiout.num_dacs < 0) {
3522 printk(KERN_WARNING "hda_codec: Could not determine "
3523 "number of channels defaulting to DAC count\n");
3524 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3527 switch (spec->multiout.num_dacs) {
3528 case 0x3: /* 6 Channel */
3529 spec->multiout.hp_nid = 0x17;
3530 spec->mixer = stac92hd73xx_6ch_mixer;
3531 spec->init = stac92hd73xx_6ch_core_init;
3533 case 0x4: /* 8 Channel */
3534 spec->multiout.hp_nid = 0x18;
3535 spec->mixer = stac92hd73xx_8ch_mixer;
3536 spec->init = stac92hd73xx_8ch_core_init;
3538 case 0x5: /* 10 Channel */
3539 spec->multiout.hp_nid = 0x19;
3540 spec->mixer = stac92hd73xx_10ch_mixer;
3541 spec->init = stac92hd73xx_10ch_core_init;
3544 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3545 spec->aloopback_mask = 0x01;
3546 spec->aloopback_shift = 8;
3548 spec->mux_nids = stac92hd73xx_mux_nids;
3549 spec->adc_nids = stac92hd73xx_adc_nids;
3550 spec->dmic_nids = stac92hd73xx_dmic_nids;
3551 spec->dmux_nids = stac92hd73xx_dmux_nids;
3553 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3554 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3555 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3556 spec->dinput_mux = &stac92hd73xx_dmux;
3557 /* GPIO0 High = Enable EAPD */
3558 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3559 spec->gpio_data = 0x01;
3561 switch (spec->board_config) {
3563 spec->init = dell_eq_core_init;
3564 switch (codec->subsystem_id) {
3565 case 0x1028025e: /* Analog Mics */
3567 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3568 spec->num_dmics = 0;
3570 case 0x10280271: /* Digital Mics */
3572 spec->init = dell_m6_core_init;
3576 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3577 spec->num_dmics = 1;
3579 case 0x10280256: /* Both */
3581 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3582 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3583 spec->num_dmics = 1;
3588 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3591 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3592 spec->pwr_nids = stac92hd73xx_pwr_nids;
3594 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3597 if (spec->board_config < 0) {
3598 printk(KERN_WARNING "hda_codec: No auto-config is "
3599 "available, default to model=ref\n");
3600 spec->board_config = STAC_92HD73XX_REF;
3607 stac92xx_free(codec);
3611 codec->patch_ops = stac92xx_patch_ops;
3616 static int patch_stac92hd71bxx(struct hda_codec *codec)
3618 struct sigmatel_spec *spec;
3621 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3626 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
3627 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3628 spec->pin_nids = stac92hd71bxx_pin_nids;
3629 spec->board_config = snd_hda_check_board_config(codec,
3630 STAC_92HD71BXX_MODELS,
3631 stac92hd71bxx_models,
3632 stac92hd71bxx_cfg_tbl);
3634 if (spec->board_config < 0) {
3635 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3636 " STAC92HD71BXX, using BIOS defaults\n");
3637 err = stac92xx_save_bios_config_regs(codec);
3639 stac92xx_free(codec);
3642 spec->pin_configs = spec->bios_pin_configs;
3644 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3645 stac92xx_set_config_regs(codec);
3648 switch (codec->vendor_id) {
3649 case 0x111d76b6: /* 4 Port without Analog Mixer */
3651 case 0x111d76b4: /* 6 Port without Analog Mixer */
3653 spec->mixer = stac92hd71bxx_mixer;
3654 spec->init = stac92hd71bxx_core_init;
3656 case 0x111d7608: /* 5 Port with Analog Mixer */
3657 /* no output amps */
3659 spec->mixer = stac92hd71bxx_analog_mixer;
3662 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3663 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3665 case 0x111d7603: /* 6 Port with Analog Mixer */
3666 /* no output amps */
3670 spec->mixer = stac92hd71bxx_analog_mixer;
3671 spec->init = stac92hd71bxx_analog_core_init;
3674 spec->aloopback_mask = 0x20;
3675 spec->aloopback_shift = 0;
3677 /* GPIO0 High = EAPD */
3678 spec->gpio_mask = 0x01;
3679 spec->gpio_dir = 0x01;
3680 spec->gpio_data = 0x01;
3682 spec->mux_nids = stac92hd71bxx_mux_nids;
3683 spec->adc_nids = stac92hd71bxx_adc_nids;
3684 spec->dmic_nids = stac92hd71bxx_dmic_nids;
3685 spec->dmux_nids = stac92hd71bxx_dmux_nids;
3686 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3688 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3689 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3690 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3691 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3693 spec->multiout.num_dacs = 1;
3694 spec->multiout.hp_nid = 0x11;
3695 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3697 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3699 if (spec->board_config < 0) {
3700 printk(KERN_WARNING "hda_codec: No auto-config is "
3701 "available, default to model=ref\n");
3702 spec->board_config = STAC_92HD71BXX_REF;
3709 stac92xx_free(codec);
3713 codec->patch_ops = stac92xx_patch_ops;
3718 static int patch_stac922x(struct hda_codec *codec)
3720 struct sigmatel_spec *spec;
3723 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3728 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
3729 spec->pin_nids = stac922x_pin_nids;
3730 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3733 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
3734 spec->gpio_mask = spec->gpio_dir = 0x03;
3735 spec->gpio_data = 0x03;
3736 /* Intel Macs have all same PCI SSID, so we need to check
3737 * codec SSID to distinguish the exact models
3739 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
3740 switch (codec->subsystem_id) {
3743 spec->board_config = STAC_INTEL_MAC_V1;
3747 spec->board_config = STAC_INTEL_MAC_V2;
3755 spec->board_config = STAC_INTEL_MAC_V3;
3759 spec->board_config = STAC_INTEL_MAC_V4;
3763 spec->board_config = STAC_INTEL_MAC_V5;
3766 spec->board_config = STAC_INTEL_MAC_V3;
3772 if (spec->board_config < 0) {
3773 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3774 "using BIOS defaults\n");
3775 err = stac92xx_save_bios_config_regs(codec);
3777 stac92xx_free(codec);
3780 spec->pin_configs = spec->bios_pin_configs;
3781 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
3782 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3783 stac92xx_set_config_regs(codec);
3786 spec->adc_nids = stac922x_adc_nids;
3787 spec->mux_nids = stac922x_mux_nids;
3788 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
3789 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
3790 spec->num_dmics = 0;
3793 spec->init = stac922x_core_init;
3794 spec->mixer = stac922x_mixer;
3796 spec->multiout.dac_nids = spec->dac_nids;
3798 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
3800 if (spec->board_config < 0) {
3801 printk(KERN_WARNING "hda_codec: No auto-config is "
3802 "available, default to model=ref\n");
3803 spec->board_config = STAC_D945_REF;
3809 stac92xx_free(codec);
3813 codec->patch_ops = stac92xx_patch_ops;
3815 /* Fix Mux capture level; max to 2 */
3816 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3817 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3818 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3819 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3820 (0 << AC_AMPCAP_MUTE_SHIFT));
3825 static int patch_stac927x(struct hda_codec *codec)
3827 struct sigmatel_spec *spec;
3830 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3835 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3836 spec->pin_nids = stac927x_pin_nids;
3837 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3841 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3842 if (spec->board_config < 0)
3843 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3844 "STAC927x, using BIOS defaults\n");
3845 err = stac92xx_save_bios_config_regs(codec);
3847 stac92xx_free(codec);
3850 spec->pin_configs = spec->bios_pin_configs;
3852 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3853 stac92xx_set_config_regs(codec);
3856 spec->adc_nids = stac927x_adc_nids;
3857 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3858 spec->mux_nids = stac927x_mux_nids;
3859 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3860 spec->dac_list = stac927x_dac_nids;
3861 spec->multiout.dac_nids = spec->dac_nids;
3863 switch (spec->board_config) {
3866 /* GPIO0 High = Enable EAPD */
3867 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
3868 spec->gpio_data = 0x01;
3869 spec->num_dmics = 0;
3871 spec->init = d965_core_init;
3872 spec->mixer = stac927x_mixer;
3874 case STAC_DELL_BIOS:
3875 switch (codec->subsystem_id) {
3878 /* correct the device field to SPDIF out */
3879 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3882 /* configure the analog microphone on some laptops */
3883 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3884 /* correct the front output jack as a hp out */
3885 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3886 /* correct the front input jack as a mic */
3887 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3890 /* GPIO2 High = Enable EAPD */
3891 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3892 spec->gpio_data = 0x04;
3893 spec->dmic_nids = stac927x_dmic_nids;
3894 spec->num_dmics = STAC927X_NUM_DMICS;
3896 spec->init = d965_core_init;
3897 spec->mixer = stac927x_mixer;
3898 spec->dmux_nids = stac927x_dmux_nids;
3899 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3902 /* GPIO0 High = Enable EAPD */
3903 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3904 spec->gpio_data = 0x01;
3905 spec->num_dmics = 0;
3907 spec->init = stac927x_core_init;
3908 spec->mixer = stac927x_mixer;
3912 spec->aloopback_mask = 0x40;
3913 spec->aloopback_shift = 0;
3915 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3917 if (spec->board_config < 0) {
3918 printk(KERN_WARNING "hda_codec: No auto-config is "
3919 "available, default to model=ref\n");
3920 spec->board_config = STAC_D965_REF;
3926 stac92xx_free(codec);
3930 codec->patch_ops = stac92xx_patch_ops;
3934 * The STAC927x seem to require fairly long delays for certain
3935 * command sequences. With too short delays (even if the answer
3936 * is set to RIRB properly), it results in the silence output
3937 * on some hardwares like Dell.
3939 * The below flag enables the longer delay (see get_response
3942 codec->bus->needs_damn_long_delay = 1;
3947 static int patch_stac9205(struct hda_codec *codec)
3949 struct sigmatel_spec *spec;
3952 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3957 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
3958 spec->pin_nids = stac9205_pin_nids;
3959 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
3963 if (spec->board_config < 0) {
3964 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
3965 err = stac92xx_save_bios_config_regs(codec);
3967 stac92xx_free(codec);
3970 spec->pin_configs = spec->bios_pin_configs;
3972 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
3973 stac92xx_set_config_regs(codec);
3976 spec->adc_nids = stac9205_adc_nids;
3977 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
3978 spec->mux_nids = stac9205_mux_nids;
3979 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
3980 spec->dmic_nids = stac9205_dmic_nids;
3981 spec->num_dmics = STAC9205_NUM_DMICS;
3982 spec->dmux_nids = stac9205_dmux_nids;
3983 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
3986 spec->init = stac9205_core_init;
3987 spec->mixer = stac9205_mixer;
3989 spec->aloopback_mask = 0x40;
3990 spec->aloopback_shift = 0;
3991 spec->multiout.dac_nids = spec->dac_nids;
3993 switch (spec->board_config){
3994 case STAC_9205_DELL_M43:
3995 /* Enable SPDIF in/out */
3996 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
3997 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
3999 /* Enable unsol response for GPIO4/Dock HP connection */
4000 snd_hda_codec_write(codec, codec->afg, 0,
4001 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4002 snd_hda_codec_write_cache(codec, codec->afg, 0,
4003 AC_VERB_SET_UNSOLICITED_ENABLE,
4004 (AC_USRSP_EN | STAC_HP_EVENT));
4006 spec->gpio_dir = 0x0b;
4007 spec->eapd_mask = 0x01;
4008 spec->gpio_mask = 0x1b;
4009 spec->gpio_mute = 0x10;
4010 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4013 spec->gpio_data = 0x01;
4016 /* GPIO0 High = EAPD */
4017 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4018 spec->gpio_data = 0x01;
4022 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4024 if (spec->board_config < 0) {
4025 printk(KERN_WARNING "hda_codec: No auto-config is "
4026 "available, default to model=ref\n");
4027 spec->board_config = STAC_9205_REF;
4033 stac92xx_free(codec);
4037 codec->patch_ops = stac92xx_patch_ops;
4046 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4047 static hda_nid_t vaio_dacs[] = { 0x2 };
4048 #define VAIO_HP_DAC 0x5
4049 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4050 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4052 static struct hda_input_mux vaio_mux = {
4055 /* { "HP", 0x0 }, */
4056 { "Mic Jack", 0x1 },
4057 { "Internal Mic", 0x2 },
4062 static struct hda_verb vaio_init[] = {
4063 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4064 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
4065 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4066 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4067 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4068 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4069 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4070 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4071 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4073 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4074 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4078 static struct hda_verb vaio_ar_init[] = {
4079 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4080 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4081 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4082 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4083 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4085 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4086 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4087 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4088 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4090 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4091 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4095 /* bind volumes of both NID 0x02 and 0x05 */
4096 static struct hda_bind_ctls vaio_bind_master_vol = {
4097 .ops = &snd_hda_bind_vol,
4099 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4100 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4105 /* bind volumes of both NID 0x02 and 0x05 */
4106 static struct hda_bind_ctls vaio_bind_master_sw = {
4107 .ops = &snd_hda_bind_sw,
4109 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4110 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4115 static struct snd_kcontrol_new vaio_mixer[] = {
4116 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4117 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4118 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4119 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4120 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4122 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4123 .name = "Capture Source",
4125 .info = stac92xx_mux_enum_info,
4126 .get = stac92xx_mux_enum_get,
4127 .put = stac92xx_mux_enum_put,
4132 static struct snd_kcontrol_new vaio_ar_mixer[] = {
4133 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4134 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4135 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4136 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4137 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4138 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4139 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4142 .name = "Capture Source",
4144 .info = stac92xx_mux_enum_info,
4145 .get = stac92xx_mux_enum_get,
4146 .put = stac92xx_mux_enum_put,
4151 static struct hda_codec_ops stac9872_patch_ops = {
4152 .build_controls = stac92xx_build_controls,
4153 .build_pcms = stac92xx_build_pcms,
4154 .init = stac92xx_init,
4155 .free = stac92xx_free,
4156 #ifdef SND_HDA_NEEDS_RESUME
4157 .resume = stac92xx_resume,
4161 static int stac9872_vaio_init(struct hda_codec *codec)
4165 err = stac92xx_init(codec);
4168 if (codec->patch_ops.unsol_event)
4169 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4173 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4175 if (get_hp_pin_presence(codec, 0x0a)) {
4176 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4177 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4179 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4180 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4184 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4186 switch (res >> 26) {
4188 stac9872_vaio_hp_detect(codec, res);
4193 static struct hda_codec_ops stac9872_vaio_patch_ops = {
4194 .build_controls = stac92xx_build_controls,
4195 .build_pcms = stac92xx_build_pcms,
4196 .init = stac9872_vaio_init,
4197 .free = stac92xx_free,
4198 .unsol_event = stac9872_vaio_unsol_event,
4200 .resume = stac92xx_resume,
4204 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4206 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4208 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4210 /* AR Series. id=0x83847664 and subsys=104D1300 */
4215 static const char *stac9872_models[STAC_9872_MODELS] = {
4216 [CXD9872RD_VAIO] = "vaio",
4217 [CXD9872AKD_VAIO] = "vaio-ar",
4220 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4221 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4222 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4223 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
4224 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
4228 static int patch_stac9872(struct hda_codec *codec)
4230 struct sigmatel_spec *spec;
4233 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4236 if (board_config < 0)
4237 /* unknown config, let generic-parser do its job... */
4238 return snd_hda_parse_generic_codec(codec);
4240 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4245 switch (board_config) {
4246 case CXD9872RD_VAIO:
4247 case STAC9872AK_VAIO:
4248 case STAC9872K_VAIO:
4249 spec->mixer = vaio_mixer;
4250 spec->init = vaio_init;
4251 spec->multiout.max_channels = 2;
4252 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4253 spec->multiout.dac_nids = vaio_dacs;
4254 spec->multiout.hp_nid = VAIO_HP_DAC;
4255 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4256 spec->adc_nids = vaio_adcs;
4258 spec->input_mux = &vaio_mux;
4259 spec->mux_nids = vaio_mux_nids;
4260 codec->patch_ops = stac9872_vaio_patch_ops;
4263 case CXD9872AKD_VAIO:
4264 spec->mixer = vaio_ar_mixer;
4265 spec->init = vaio_ar_init;
4266 spec->multiout.max_channels = 2;
4267 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4268 spec->multiout.dac_nids = vaio_dacs;
4269 spec->multiout.hp_nid = VAIO_HP_DAC;
4270 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4272 spec->adc_nids = vaio_adcs;
4273 spec->input_mux = &vaio_mux;
4274 spec->mux_nids = vaio_mux_nids;
4275 codec->patch_ops = stac9872_patch_ops;
4286 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4287 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4288 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4289 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4290 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4291 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4292 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4293 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4294 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4295 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4296 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4297 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4298 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4299 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4300 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4301 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4302 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4303 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4304 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4305 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4306 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4307 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4308 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4309 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
4310 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4311 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4312 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4313 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4314 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4315 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4316 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4317 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
4318 /* The following does not take into account .id=0x83847661 when subsys =
4319 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4320 * currently not fully supported.
4322 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4323 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4324 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
4325 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4326 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4327 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4328 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4329 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4330 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4331 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4332 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4333 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4334 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
4335 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4336 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4337 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4338 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4339 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4340 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4341 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4342 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4343 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4344 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4345 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },