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
98 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
99 * is given, one of the above models will be
100 * chosen according to the subsystem id. */
101 /* for backward compatibility */
125 struct sigmatel_spec {
126 struct snd_kcontrol_new *mixers[4];
127 unsigned int num_mixers;
130 unsigned int surr_switch: 1;
131 unsigned int line_switch: 1;
132 unsigned int mic_switch: 1;
133 unsigned int alt_switch: 1;
134 unsigned int hp_detect: 1;
137 unsigned int eapd_mask;
138 unsigned int gpio_mask;
139 unsigned int gpio_dir;
140 unsigned int gpio_data;
141 unsigned int gpio_mute;
143 /* analog loopback */
144 unsigned char aloopback_mask;
145 unsigned char aloopback_shift;
147 /* power management */
148 unsigned int num_pwrs;
153 struct hda_input_mux *mono_mux;
154 unsigned int cur_mmux;
155 struct hda_multi_out multiout;
156 hda_nid_t dac_nids[5];
160 unsigned int num_adcs;
162 unsigned int num_muxes;
163 hda_nid_t *dmic_nids;
164 unsigned int num_dmics;
165 hda_nid_t *dmux_nids;
166 unsigned int num_dmuxes;
167 hda_nid_t dig_in_nid;
172 unsigned int num_pins;
173 unsigned int *pin_configs;
174 unsigned int *bios_pin_configs;
176 /* codec specific stuff */
177 struct hda_verb *init;
178 struct snd_kcontrol_new *mixer;
181 struct hda_input_mux *dinput_mux;
182 unsigned int cur_dmux[2];
183 struct hda_input_mux *input_mux;
184 unsigned int cur_mux[3];
187 unsigned int io_switch[2];
188 unsigned int clfe_swap;
189 unsigned int hp_switch;
190 unsigned int aloopback;
192 struct hda_pcm pcm_rec[2]; /* PCM information */
194 /* dynamic controls and input_mux */
195 struct auto_pin_cfg autocfg;
196 unsigned int num_kctl_alloc, num_kctl_used;
197 struct snd_kcontrol_new *kctl_alloc;
198 struct hda_input_mux private_dimux;
199 struct hda_input_mux private_imux;
200 struct hda_input_mux private_mono_mux;
203 static hda_nid_t stac9200_adc_nids[1] = {
207 static hda_nid_t stac9200_mux_nids[1] = {
211 static hda_nid_t stac9200_dac_nids[1] = {
215 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
216 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
220 static hda_nid_t stac92hd73xx_adc_nids[2] = {
224 #define STAC92HD73XX_NUM_DMICS 2
225 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
229 #define STAC92HD73_DAC_COUNT 5
230 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
231 0x15, 0x16, 0x17, 0x18, 0x19,
234 static hda_nid_t stac92hd73xx_mux_nids[4] = {
235 0x28, 0x29, 0x2a, 0x2b,
238 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
242 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
246 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
250 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
254 static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
258 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
262 #define STAC92HD71BXX_NUM_DMICS 2
263 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
267 static hda_nid_t stac925x_adc_nids[1] = {
271 static hda_nid_t stac925x_mux_nids[1] = {
275 static hda_nid_t stac925x_dac_nids[1] = {
279 #define STAC925X_NUM_DMICS 1
280 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
284 static hda_nid_t stac925x_dmux_nids[1] = {
288 static hda_nid_t stac922x_adc_nids[2] = {
292 static hda_nid_t stac922x_mux_nids[2] = {
296 static hda_nid_t stac927x_adc_nids[3] = {
300 static hda_nid_t stac927x_mux_nids[3] = {
304 static hda_nid_t stac927x_dac_nids[6] = {
305 0x02, 0x03, 0x04, 0x05, 0x06, 0
308 static hda_nid_t stac927x_dmux_nids[1] = {
312 #define STAC927X_NUM_DMICS 2
313 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
317 static hda_nid_t stac9205_adc_nids[2] = {
321 static hda_nid_t stac9205_mux_nids[2] = {
325 static hda_nid_t stac9205_dmux_nids[1] = {
329 #define STAC9205_NUM_DMICS 2
330 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
334 static hda_nid_t stac9200_pin_nids[8] = {
335 0x08, 0x09, 0x0d, 0x0e,
336 0x0f, 0x10, 0x11, 0x12,
339 static hda_nid_t stac925x_pin_nids[8] = {
340 0x07, 0x08, 0x0a, 0x0b,
341 0x0c, 0x0d, 0x10, 0x11,
344 static hda_nid_t stac922x_pin_nids[10] = {
345 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
346 0x0f, 0x10, 0x11, 0x15, 0x1b,
349 static hda_nid_t stac92hd73xx_pin_nids[13] = {
350 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
351 0x0f, 0x10, 0x11, 0x12, 0x13,
355 static hda_nid_t stac92hd71bxx_pin_nids[10] = {
356 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
357 0x0f, 0x14, 0x18, 0x19, 0x1e,
360 static hda_nid_t stac927x_pin_nids[14] = {
361 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
362 0x0f, 0x10, 0x11, 0x12, 0x13,
363 0x14, 0x21, 0x22, 0x23,
366 static hda_nid_t stac9205_pin_nids[12] = {
367 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
368 0x0f, 0x14, 0x16, 0x17, 0x18,
372 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
373 struct snd_ctl_elem_info *uinfo)
375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
376 struct sigmatel_spec *spec = codec->spec;
377 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
380 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
381 struct snd_ctl_elem_value *ucontrol)
383 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
384 struct sigmatel_spec *spec = codec->spec;
385 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
387 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
391 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct sigmatel_spec *spec = codec->spec;
396 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
398 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
399 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
402 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
404 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
405 struct sigmatel_spec *spec = codec->spec;
406 return snd_hda_input_mux_info(spec->input_mux, uinfo);
409 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
411 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
412 struct sigmatel_spec *spec = codec->spec;
413 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
415 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
419 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
421 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
422 struct sigmatel_spec *spec = codec->spec;
423 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
425 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
426 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
429 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
430 struct snd_ctl_elem_info *uinfo)
432 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
433 struct sigmatel_spec *spec = codec->spec;
434 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
437 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
438 struct snd_ctl_elem_value *ucontrol)
440 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
441 struct sigmatel_spec *spec = codec->spec;
443 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
447 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_value *ucontrol)
450 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
451 struct sigmatel_spec *spec = codec->spec;
453 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
454 spec->mono_nid, &spec->cur_mmux);
457 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
459 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
464 struct sigmatel_spec *spec = codec->spec;
466 ucontrol->value.integer.value[0] = !!(spec->aloopback &
467 (spec->aloopback_mask << idx));
471 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
472 struct snd_ctl_elem_value *ucontrol)
474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
475 struct sigmatel_spec *spec = codec->spec;
476 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
477 unsigned int dac_mode;
478 unsigned int val, idx_val;
480 idx_val = spec->aloopback_mask << idx;
481 if (ucontrol->value.integer.value[0])
482 val = spec->aloopback | idx_val;
484 val = spec->aloopback & ~idx_val;
485 if (spec->aloopback == val)
488 spec->aloopback = val;
490 /* Only return the bits defined by the shift value of the
491 * first two bytes of the mask
493 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
494 kcontrol->private_value & 0xFFFF, 0x0);
495 dac_mode >>= spec->aloopback_shift;
497 if (spec->aloopback & idx_val) {
498 snd_hda_power_up(codec);
501 snd_hda_power_down(codec);
502 dac_mode &= ~idx_val;
505 snd_hda_codec_write_cache(codec, codec->afg, 0,
506 kcontrol->private_value >> 16, dac_mode);
511 static struct hda_verb stac9200_core_init[] = {
512 /* set dac0mux for dac converter */
513 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
517 static struct hda_verb stac9200_eapd_init[] = {
518 /* set dac0mux for dac converter */
519 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
520 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
524 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
525 /* set master volume and direct control */
526 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
527 /* setup audio connections */
528 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
529 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
530 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
531 /* setup adcs to point to mixer */
532 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
533 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
534 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
535 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
536 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
537 /* setup import muxs */
538 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
539 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
540 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
541 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
545 static struct hda_verb dell_eq_core_init[] = {
546 /* set master volume to max value without distortion
547 * and direct control */
548 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
549 /* setup audio connections */
550 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
551 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02},
552 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01},
553 /* setup adcs to point to mixer */
554 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
555 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
556 /* setup import muxs */
557 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
558 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
559 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
560 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
564 static struct hda_verb dell_m6_core_init[] = {
565 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
566 /* setup audio connections */
567 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
568 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
569 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
570 /* setup adcs to point to mixer */
571 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
572 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
573 /* setup import muxs */
574 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
575 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
576 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
577 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
581 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
582 /* set master volume and direct control */
583 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
584 /* setup audio connections */
585 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
586 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
587 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
588 /* connect hp ports to dac3 */
589 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
590 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
591 /* setup adcs to point to mixer */
592 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
593 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
594 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
595 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
596 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
597 /* setup import muxs */
598 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
599 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
600 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
601 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
605 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
606 /* set master volume and direct control */
607 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
608 /* setup audio connections */
609 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
610 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
611 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
612 /* dac3 is connected to import3 mux */
613 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
614 /* connect hp ports to dac4 */
615 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
616 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
617 /* setup adcs to point to mixer */
618 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
619 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
620 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
621 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
622 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
623 /* setup import muxs */
624 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
625 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
626 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
627 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
631 static struct hda_verb stac92hd71bxx_core_init[] = {
632 /* set master volume and direct control */
633 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
634 /* connect headphone jack to dac1 */
635 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
636 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
637 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
638 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
639 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
640 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
643 #define HD_DISABLE_PORTF 3
644 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
645 /* start of config #1 */
647 /* connect port 0f to audio mixer */
648 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
649 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
650 /* unmute right and left channels for node 0x0f */
651 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
652 /* start of config #2 */
654 /* set master volume and direct control */
655 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
656 /* connect headphone jack to dac1 */
657 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
658 /* connect port 0d to audio mixer */
659 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
660 /* unmute dac0 input in audio mixer */
661 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
662 /* unmute right and left channels for nodes 0x0a, 0xd */
663 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
664 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
668 static struct hda_verb stac925x_core_init[] = {
669 /* set dac0mux for dac converter */
670 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
674 static struct hda_verb stac922x_core_init[] = {
675 /* set master volume and direct control */
676 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
680 static struct hda_verb d965_core_init[] = {
681 /* set master volume and direct control */
682 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
683 /* unmute node 0x1b */
684 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
685 /* select node 0x03 as DAC */
686 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
690 static struct hda_verb stac927x_core_init[] = {
691 /* set master volume and direct control */
692 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
696 static struct hda_verb stac9205_core_init[] = {
697 /* set master volume and direct control */
698 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
702 #define STAC_MONO_MUX \
704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
705 .name = "Mono Mux", \
707 .info = stac92xx_mono_mux_enum_info, \
708 .get = stac92xx_mono_mux_enum_get, \
709 .put = stac92xx_mono_mux_enum_put, \
712 #define STAC_INPUT_SOURCE(cnt) \
714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
715 .name = "Input Source", \
717 .info = stac92xx_mux_enum_info, \
718 .get = stac92xx_mux_enum_get, \
719 .put = stac92xx_mux_enum_put, \
722 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
724 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
725 .name = "Analog Loopback", \
727 .info = stac92xx_aloopback_info, \
728 .get = stac92xx_aloopback_get, \
729 .put = stac92xx_aloopback_put, \
730 .private_value = verb_read | (verb_write << 16), \
733 static struct snd_kcontrol_new stac9200_mixer[] = {
734 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
735 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
736 STAC_INPUT_SOURCE(1),
737 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
738 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
739 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
743 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
744 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
746 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
747 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
749 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
750 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
752 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
753 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
755 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
756 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
758 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
759 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
761 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
762 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
764 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
765 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
769 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
770 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
772 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
773 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
775 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
776 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
778 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
779 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
781 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
782 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
784 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
785 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
787 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
788 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
790 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
791 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
795 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
796 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
798 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
799 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
801 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
802 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
804 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
805 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
807 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
808 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
810 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
811 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
813 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
814 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
816 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
817 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
821 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
822 STAC_INPUT_SOURCE(2),
824 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
825 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
826 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
828 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
829 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
830 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
832 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
833 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
835 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
836 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
840 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
841 STAC_INPUT_SOURCE(2),
842 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
844 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
845 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
846 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
848 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
849 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
850 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
854 static struct snd_kcontrol_new stac925x_mixer[] = {
855 STAC_INPUT_SOURCE(1),
856 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
857 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
858 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
862 static struct snd_kcontrol_new stac9205_mixer[] = {
863 STAC_INPUT_SOURCE(2),
864 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
866 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
867 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
868 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
870 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
871 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
872 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
877 /* This needs to be generated dynamically based on sequence */
878 static struct snd_kcontrol_new stac922x_mixer[] = {
879 STAC_INPUT_SOURCE(2),
880 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
881 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
882 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
884 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
885 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
886 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
891 static struct snd_kcontrol_new stac927x_mixer[] = {
892 STAC_INPUT_SOURCE(3),
893 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
895 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
896 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
897 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
899 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
900 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
901 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
903 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
904 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
905 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
909 static struct snd_kcontrol_new stac_dmux_mixer = {
910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
911 .name = "Digital Input Source",
912 /* count set later */
913 .info = stac92xx_dmux_enum_info,
914 .get = stac92xx_dmux_enum_get,
915 .put = stac92xx_dmux_enum_put,
918 static const char *slave_vols[] = {
919 "Front Playback Volume",
920 "Surround Playback Volume",
921 "Center Playback Volume",
922 "LFE Playback Volume",
923 "Side Playback Volume",
924 "Headphone Playback Volume",
925 "Headphone Playback Volume",
926 "Speaker Playback Volume",
927 "External Speaker Playback Volume",
928 "Speaker2 Playback Volume",
932 static const char *slave_sws[] = {
933 "Front Playback Switch",
934 "Surround Playback Switch",
935 "Center Playback Switch",
936 "LFE Playback Switch",
937 "Side Playback Switch",
938 "Headphone Playback Switch",
939 "Headphone Playback Switch",
940 "Speaker Playback Switch",
941 "External Speaker Playback Switch",
942 "Speaker2 Playback Switch",
943 "IEC958 Playback Switch",
947 static int stac92xx_build_controls(struct hda_codec *codec)
949 struct sigmatel_spec *spec = codec->spec;
953 err = snd_hda_add_new_ctls(codec, spec->mixer);
957 for (i = 0; i < spec->num_mixers; i++) {
958 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
962 if (spec->num_dmuxes > 0) {
963 stac_dmux_mixer.count = spec->num_dmuxes;
964 err = snd_ctl_add(codec->bus->card,
965 snd_ctl_new1(&stac_dmux_mixer, codec));
970 if (spec->multiout.dig_out_nid) {
971 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
974 err = snd_hda_create_spdif_share_sw(codec,
978 spec->multiout.share_spdif = 1;
980 if (spec->dig_in_nid) {
981 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
986 /* if we have no master control, let's create it */
987 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
988 unsigned int vmaster_tlv[4];
989 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
990 HDA_OUTPUT, vmaster_tlv);
991 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
992 vmaster_tlv, slave_vols);
996 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
997 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1006 static unsigned int ref9200_pin_configs[8] = {
1007 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1008 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1012 STAC 9200 pin configs for
1017 static unsigned int dell9200_d21_pin_configs[8] = {
1018 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1019 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1023 STAC 9200 pin configs for
1027 static unsigned int dell9200_d22_pin_configs[8] = {
1028 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1029 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1033 STAC 9200 pin configs for
1034 102801C4 (Dell Dimension E310)
1041 static unsigned int dell9200_d23_pin_configs[8] = {
1042 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1043 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1048 STAC 9200-32 pin configs for
1049 102801B5 (Dell Inspiron 630m)
1050 102801D8 (Dell Inspiron 640m)
1052 static unsigned int dell9200_m21_pin_configs[8] = {
1053 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1054 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1058 STAC 9200-32 pin configs for
1059 102801C2 (Dell Latitude D620)
1061 102801CC (Dell Latitude D820)
1065 static unsigned int dell9200_m22_pin_configs[8] = {
1066 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1067 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1071 STAC 9200-32 pin configs for
1072 102801CE (Dell XPS M1710)
1073 102801CF (Dell Precision M90)
1075 static unsigned int dell9200_m23_pin_configs[8] = {
1076 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1077 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1081 STAC 9200-32 pin configs for
1084 102801CB (Dell Latitude 120L)
1087 static unsigned int dell9200_m24_pin_configs[8] = {
1088 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1089 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1093 STAC 9200-32 pin configs for
1094 102801BD (Dell Inspiron E1505n)
1098 static unsigned int dell9200_m25_pin_configs[8] = {
1099 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1100 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1104 STAC 9200-32 pin configs for
1105 102801F5 (Dell Inspiron 1501)
1108 static unsigned int dell9200_m26_pin_configs[8] = {
1109 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1110 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1115 102801CD (Dell Inspiron E1705/9400)
1117 static unsigned int dell9200_m27_pin_configs[8] = {
1118 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1119 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1122 static unsigned int oqo9200_pin_configs[8] = {
1123 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1124 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1128 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1129 [STAC_REF] = ref9200_pin_configs,
1130 [STAC_9200_OQO] = oqo9200_pin_configs,
1131 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1132 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1133 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1134 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1135 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1136 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1137 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1138 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1139 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1140 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1141 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1144 static const char *stac9200_models[STAC_9200_MODELS] = {
1146 [STAC_9200_OQO] = "oqo",
1147 [STAC_9200_DELL_D21] = "dell-d21",
1148 [STAC_9200_DELL_D22] = "dell-d22",
1149 [STAC_9200_DELL_D23] = "dell-d23",
1150 [STAC_9200_DELL_M21] = "dell-m21",
1151 [STAC_9200_DELL_M22] = "dell-m22",
1152 [STAC_9200_DELL_M23] = "dell-m23",
1153 [STAC_9200_DELL_M24] = "dell-m24",
1154 [STAC_9200_DELL_M25] = "dell-m25",
1155 [STAC_9200_DELL_M26] = "dell-m26",
1156 [STAC_9200_DELL_M27] = "dell-m27",
1157 [STAC_9200_GATEWAY] = "gateway",
1158 [STAC_9200_PANASONIC] = "panasonic",
1161 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1162 /* SigmaTel reference board */
1163 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1164 "DFI LanParty", STAC_REF),
1165 /* Dell laptops have BIOS problem */
1166 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1167 "unknown Dell", STAC_9200_DELL_D21),
1168 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1169 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1170 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1171 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1172 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1173 "unknown Dell", STAC_9200_DELL_D22),
1174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1175 "unknown Dell", STAC_9200_DELL_D22),
1176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1177 "Dell Latitude D620", STAC_9200_DELL_M22),
1178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1179 "unknown Dell", STAC_9200_DELL_D23),
1180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1181 "unknown Dell", STAC_9200_DELL_D23),
1182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1183 "unknown Dell", STAC_9200_DELL_M22),
1184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1185 "unknown Dell", STAC_9200_DELL_M24),
1186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1187 "unknown Dell", STAC_9200_DELL_M24),
1188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1189 "Dell Latitude 120L", STAC_9200_DELL_M24),
1190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1191 "Dell Latitude D820", STAC_9200_DELL_M22),
1192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1193 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1195 "Dell XPS M1710", STAC_9200_DELL_M23),
1196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1197 "Dell Precision M90", STAC_9200_DELL_M23),
1198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1199 "unknown Dell", STAC_9200_DELL_M22),
1200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1201 "unknown Dell", STAC_9200_DELL_M22),
1202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1203 "unknown Dell", STAC_9200_DELL_M22),
1204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1205 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1207 "unknown Dell", STAC_9200_DELL_D23),
1208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1209 "unknown Dell", STAC_9200_DELL_D23),
1210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1211 "unknown Dell", STAC_9200_DELL_D21),
1212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1213 "unknown Dell", STAC_9200_DELL_D23),
1214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1215 "unknown Dell", STAC_9200_DELL_D21),
1216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1217 "unknown Dell", STAC_9200_DELL_M25),
1218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1219 "unknown Dell", STAC_9200_DELL_M25),
1220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1221 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1223 "unknown Dell", STAC_9200_DELL_M26),
1225 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1226 /* Gateway machines needs EAPD to be set on resume */
1227 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1228 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1230 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1233 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1237 static unsigned int ref925x_pin_configs[8] = {
1238 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1239 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1242 static unsigned int stac925x_MA6_pin_configs[8] = {
1243 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1244 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1247 static unsigned int stac925x_PA6_pin_configs[8] = {
1248 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1249 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1252 static unsigned int stac925xM2_2_pin_configs[8] = {
1253 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1254 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1257 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1258 [STAC_REF] = ref925x_pin_configs,
1259 [STAC_M2_2] = stac925xM2_2_pin_configs,
1260 [STAC_MA6] = stac925x_MA6_pin_configs,
1261 [STAC_PA6] = stac925x_PA6_pin_configs,
1264 static const char *stac925x_models[STAC_925x_MODELS] = {
1266 [STAC_M2_2] = "m2-2",
1271 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1272 /* SigmaTel reference board */
1273 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1274 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1275 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1276 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1277 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1278 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1279 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1283 static unsigned int ref92hd73xx_pin_configs[13] = {
1284 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1285 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1286 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1290 static unsigned int dell_m6_pin_configs[13] = {
1291 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1292 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1293 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1297 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1298 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1299 [STAC_DELL_M6] = dell_m6_pin_configs,
1300 [STAC_DELL_EQ] = dell_m6_pin_configs,
1303 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1304 [STAC_92HD73XX_REF] = "ref",
1305 [STAC_DELL_M6] = "dell-m6",
1306 [STAC_DELL_EQ] = "dell-eq",
1309 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1310 /* SigmaTel reference board */
1311 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1312 "DFI LanParty", STAC_92HD73XX_REF),
1313 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1314 "Dell Studio 1535", STAC_DELL_M6),
1315 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1316 "unknown Dell", STAC_DELL_M6),
1317 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1318 "unknown Dell", STAC_DELL_M6),
1319 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1320 "unknown Dell", STAC_DELL_M6),
1321 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1322 "unknown Dell", STAC_DELL_M6),
1323 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1324 "unknown Dell", STAC_DELL_M6),
1325 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1326 "unknown Dell", STAC_DELL_M6),
1327 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1328 "Dell Studio 15", STAC_DELL_M6),
1332 static unsigned int ref92hd71bxx_pin_configs[10] = {
1333 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1334 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1335 0x90a000f0, 0x01452050,
1338 static unsigned int dell_m4_1_pin_configs[10] = {
1339 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1340 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1341 0x40f000f0, 0x4f0000f0,
1344 static unsigned int dell_m4_2_pin_configs[10] = {
1345 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1346 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1347 0x40f000f0, 0x044413b0,
1350 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1351 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1352 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1353 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1356 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1357 [STAC_92HD71BXX_REF] = "ref",
1358 [STAC_DELL_M4_1] = "dell-m4-1",
1359 [STAC_DELL_M4_2] = "dell-m4-2",
1362 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1363 /* SigmaTel reference board */
1364 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1365 "DFI LanParty", STAC_92HD71BXX_REF),
1366 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1367 "unknown Dell", STAC_DELL_M4_1),
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1369 "unknown Dell", STAC_DELL_M4_1),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1371 "unknown Dell", STAC_DELL_M4_1),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1373 "unknown Dell", STAC_DELL_M4_1),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1375 "unknown Dell", STAC_DELL_M4_1),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1377 "unknown Dell", STAC_DELL_M4_1),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1379 "unknown Dell", STAC_DELL_M4_1),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1381 "unknown Dell", STAC_DELL_M4_2),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1383 "unknown Dell", STAC_DELL_M4_2),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1385 "unknown Dell", STAC_DELL_M4_2),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1387 "unknown Dell", STAC_DELL_M4_2),
1391 static unsigned int ref922x_pin_configs[10] = {
1392 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1393 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1394 0x40000100, 0x40000100,
1398 STAC 922X pin configs for
1405 static unsigned int dell_922x_d81_pin_configs[10] = {
1406 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1407 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1408 0x01813122, 0x400001f2,
1412 STAC 922X pin configs for
1416 static unsigned int dell_922x_d82_pin_configs[10] = {
1417 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1418 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1419 0x01813122, 0x400001f1,
1423 STAC 922X pin configs for
1426 static unsigned int dell_922x_m81_pin_configs[10] = {
1427 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1428 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1429 0x40C003f1, 0x405003f0,
1433 STAC 9221 A1 pin configs for
1434 102801D7 (Dell XPS M1210)
1436 static unsigned int dell_922x_m82_pin_configs[10] = {
1437 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1438 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1439 0x508003f3, 0x405003f4,
1442 static unsigned int d945gtp3_pin_configs[10] = {
1443 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1444 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1445 0x02a19120, 0x40000100,
1448 static unsigned int d945gtp5_pin_configs[10] = {
1449 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1450 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1451 0x02a19320, 0x40000100,
1454 static unsigned int intel_mac_v1_pin_configs[10] = {
1455 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1456 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1457 0x400000fc, 0x400000fb,
1460 static unsigned int intel_mac_v2_pin_configs[10] = {
1461 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1462 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1463 0x400000fc, 0x400000fb,
1466 static unsigned int intel_mac_v3_pin_configs[10] = {
1467 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1468 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1469 0x400000fc, 0x400000fb,
1472 static unsigned int intel_mac_v4_pin_configs[10] = {
1473 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1474 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1475 0x400000fc, 0x400000fb,
1478 static unsigned int intel_mac_v5_pin_configs[10] = {
1479 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1480 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1481 0x400000fc, 0x400000fb,
1484 static unsigned int ecs202_pin_configs[10] = {
1485 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1486 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1487 0x9037012e, 0x40e000f2,
1490 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1491 [STAC_D945_REF] = ref922x_pin_configs,
1492 [STAC_D945GTP3] = d945gtp3_pin_configs,
1493 [STAC_D945GTP5] = d945gtp5_pin_configs,
1494 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1495 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1496 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1497 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1498 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1499 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1500 /* for backward compatibility */
1501 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1502 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1503 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1504 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1505 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1506 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1507 [STAC_ECS_202] = ecs202_pin_configs,
1508 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1509 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1510 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1511 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1514 static const char *stac922x_models[STAC_922X_MODELS] = {
1515 [STAC_D945_REF] = "ref",
1516 [STAC_D945GTP5] = "5stack",
1517 [STAC_D945GTP3] = "3stack",
1518 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1519 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1520 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1521 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1522 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1523 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1524 /* for backward compatibility */
1525 [STAC_MACMINI] = "macmini",
1526 [STAC_MACBOOK] = "macbook",
1527 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1528 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1529 [STAC_IMAC_INTEL] = "imac-intel",
1530 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1531 [STAC_ECS_202] = "ecs202",
1532 [STAC_922X_DELL_D81] = "dell-d81",
1533 [STAC_922X_DELL_D82] = "dell-d82",
1534 [STAC_922X_DELL_M81] = "dell-m81",
1535 [STAC_922X_DELL_M82] = "dell-m82",
1538 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1539 /* SigmaTel reference board */
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1541 "DFI LanParty", STAC_D945_REF),
1542 /* Intel 945G based systems */
1543 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1544 "Intel D945G", STAC_D945GTP3),
1545 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1546 "Intel D945G", STAC_D945GTP3),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1548 "Intel D945G", STAC_D945GTP3),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1550 "Intel D945G", STAC_D945GTP3),
1551 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1552 "Intel D945G", STAC_D945GTP3),
1553 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1554 "Intel D945G", STAC_D945GTP3),
1555 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1556 "Intel D945G", STAC_D945GTP3),
1557 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1558 "Intel D945G", STAC_D945GTP3),
1559 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1560 "Intel D945G", STAC_D945GTP3),
1561 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1562 "Intel D945G", STAC_D945GTP3),
1563 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1564 "Intel D945G", STAC_D945GTP3),
1565 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1566 "Intel D945G", STAC_D945GTP3),
1567 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1568 "Intel D945G", STAC_D945GTP3),
1569 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1570 "Intel D945G", STAC_D945GTP3),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1572 "Intel D945G", STAC_D945GTP3),
1573 /* Intel D945G 5-stack systems */
1574 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1575 "Intel D945G", STAC_D945GTP5),
1576 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1577 "Intel D945G", STAC_D945GTP5),
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1579 "Intel D945G", STAC_D945GTP5),
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1581 "Intel D945G", STAC_D945GTP5),
1582 /* Intel 945P based systems */
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1584 "Intel D945P", STAC_D945GTP3),
1585 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1586 "Intel D945P", STAC_D945GTP3),
1587 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1588 "Intel D945P", STAC_D945GTP3),
1589 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1590 "Intel D945P", STAC_D945GTP3),
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1592 "Intel D945P", STAC_D945GTP3),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1594 "Intel D945P", STAC_D945GTP5),
1596 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1597 SND_PCI_QUIRK(0x8384, 0x7680,
1598 "Mac", STAC_INTEL_MAC_AUTO),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1601 "unknown Dell", STAC_922X_DELL_D81),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1603 "unknown Dell", STAC_922X_DELL_D81),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1605 "unknown Dell", STAC_922X_DELL_D81),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1607 "unknown Dell", STAC_922X_DELL_D82),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1609 "unknown Dell", STAC_922X_DELL_M81),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1611 "unknown Dell", STAC_922X_DELL_D82),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1613 "unknown Dell", STAC_922X_DELL_D81),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1615 "unknown Dell", STAC_922X_DELL_D81),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1617 "Dell XPS M1210", STAC_922X_DELL_M82),
1618 /* ECS/PC Chips boards */
1619 SND_PCI_QUIRK(0x1019, 0x2144,
1620 "ECS/PC chips", STAC_ECS_202),
1621 SND_PCI_QUIRK(0x1019, 0x2608,
1622 "ECS/PC chips", STAC_ECS_202),
1623 SND_PCI_QUIRK(0x1019, 0x2633,
1624 "ECS/PC chips P17G/1333", STAC_ECS_202),
1625 SND_PCI_QUIRK(0x1019, 0x2811,
1626 "ECS/PC chips", STAC_ECS_202),
1627 SND_PCI_QUIRK(0x1019, 0x2812,
1628 "ECS/PC chips", STAC_ECS_202),
1629 SND_PCI_QUIRK(0x1019, 0x2813,
1630 "ECS/PC chips", STAC_ECS_202),
1631 SND_PCI_QUIRK(0x1019, 0x2814,
1632 "ECS/PC chips", STAC_ECS_202),
1633 SND_PCI_QUIRK(0x1019, 0x2815,
1634 "ECS/PC chips", STAC_ECS_202),
1635 SND_PCI_QUIRK(0x1019, 0x2816,
1636 "ECS/PC chips", STAC_ECS_202),
1637 SND_PCI_QUIRK(0x1019, 0x2817,
1638 "ECS/PC chips", STAC_ECS_202),
1639 SND_PCI_QUIRK(0x1019, 0x2818,
1640 "ECS/PC chips", STAC_ECS_202),
1641 SND_PCI_QUIRK(0x1019, 0x2819,
1642 "ECS/PC chips", STAC_ECS_202),
1643 SND_PCI_QUIRK(0x1019, 0x2820,
1644 "ECS/PC chips", STAC_ECS_202),
1648 static unsigned int ref927x_pin_configs[14] = {
1649 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1650 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1651 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1652 0x01c42190, 0x40000100,
1655 static unsigned int d965_3st_pin_configs[14] = {
1656 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1657 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1658 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1659 0x40000100, 0x40000100
1662 static unsigned int d965_5st_pin_configs[14] = {
1663 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1664 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1665 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1666 0x40000100, 0x40000100
1669 static unsigned int dell_3st_pin_configs[14] = {
1670 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1671 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1672 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1673 0x40c003fc, 0x40000100
1676 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1677 [STAC_D965_REF] = ref927x_pin_configs,
1678 [STAC_D965_3ST] = d965_3st_pin_configs,
1679 [STAC_D965_5ST] = d965_5st_pin_configs,
1680 [STAC_DELL_3ST] = dell_3st_pin_configs,
1681 [STAC_DELL_BIOS] = NULL,
1684 static const char *stac927x_models[STAC_927X_MODELS] = {
1685 [STAC_D965_REF] = "ref",
1686 [STAC_D965_3ST] = "3stack",
1687 [STAC_D965_5ST] = "5stack",
1688 [STAC_DELL_3ST] = "dell-3stack",
1689 [STAC_DELL_BIOS] = "dell-bios",
1692 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1693 /* SigmaTel reference board */
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1695 "DFI LanParty", STAC_D965_REF),
1696 /* Intel 946 based systems */
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1699 /* 965 based 3 stack systems */
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1716 /* Dell 3 stack systems */
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1721 /* Dell 3 stack systems with verb table in BIOS */
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1730 /* 965 based 5 stack systems */
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1737 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1743 static unsigned int ref9205_pin_configs[12] = {
1744 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1745 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
1746 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1750 STAC 9205 pin configs for
1757 10280228 (Dell Vostro 1500)
1759 static unsigned int dell_9205_m42_pin_configs[12] = {
1760 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1761 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1762 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1766 STAC 9205 pin configs for
1770 102801FF (Dell Precision M4300)
1775 static unsigned int dell_9205_m43_pin_configs[12] = {
1776 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1777 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1778 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1781 static unsigned int dell_9205_m44_pin_configs[12] = {
1782 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1783 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1784 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1787 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1788 [STAC_9205_REF] = ref9205_pin_configs,
1789 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1790 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1791 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1794 static const char *stac9205_models[STAC_9205_MODELS] = {
1795 [STAC_9205_REF] = "ref",
1796 [STAC_9205_DELL_M42] = "dell-m42",
1797 [STAC_9205_DELL_M43] = "dell-m43",
1798 [STAC_9205_DELL_M44] = "dell-m44",
1801 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1802 /* SigmaTel reference board */
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1804 "DFI LanParty", STAC_9205_REF),
1805 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1806 "unknown Dell", STAC_9205_DELL_M42),
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1808 "unknown Dell", STAC_9205_DELL_M42),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1810 "Dell Precision", STAC_9205_DELL_M43),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1812 "Dell Precision", STAC_9205_DELL_M43),
1813 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1814 "Dell Precision", STAC_9205_DELL_M43),
1815 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1816 "unknown Dell", STAC_9205_DELL_M42),
1817 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1818 "unknown Dell", STAC_9205_DELL_M42),
1819 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1820 "Dell Precision", STAC_9205_DELL_M43),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1822 "Dell Precision M4300", STAC_9205_DELL_M43),
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1824 "unknown Dell", STAC_9205_DELL_M42),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1826 "Dell Precision", STAC_9205_DELL_M43),
1827 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1828 "Dell Precision", STAC_9205_DELL_M43),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1830 "Dell Precision", STAC_9205_DELL_M43),
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1832 "Dell Inspiron", STAC_9205_DELL_M44),
1833 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1834 "Dell Vostro 1500", STAC_9205_DELL_M42),
1838 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1841 struct sigmatel_spec *spec = codec->spec;
1843 if (! spec->bios_pin_configs) {
1844 spec->bios_pin_configs = kcalloc(spec->num_pins,
1845 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1846 if (! spec->bios_pin_configs)
1850 for (i = 0; i < spec->num_pins; i++) {
1851 hda_nid_t nid = spec->pin_nids[i];
1852 unsigned int pin_cfg;
1854 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1855 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1856 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1858 spec->bios_pin_configs[i] = pin_cfg;
1864 static void stac92xx_set_config_reg(struct hda_codec *codec,
1865 hda_nid_t pin_nid, unsigned int pin_config)
1868 snd_hda_codec_write(codec, pin_nid, 0,
1869 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1870 pin_config & 0x000000ff);
1871 snd_hda_codec_write(codec, pin_nid, 0,
1872 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1873 (pin_config & 0x0000ff00) >> 8);
1874 snd_hda_codec_write(codec, pin_nid, 0,
1875 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1876 (pin_config & 0x00ff0000) >> 16);
1877 snd_hda_codec_write(codec, pin_nid, 0,
1878 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1880 i = snd_hda_codec_read(codec, pin_nid, 0,
1881 AC_VERB_GET_CONFIG_DEFAULT,
1883 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1887 static void stac92xx_set_config_regs(struct hda_codec *codec)
1890 struct sigmatel_spec *spec = codec->spec;
1892 if (!spec->pin_configs)
1895 for (i = 0; i < spec->num_pins; i++)
1896 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1897 spec->pin_configs[i]);
1901 * Analog playback callbacks
1903 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1904 struct hda_codec *codec,
1905 struct snd_pcm_substream *substream)
1907 struct sigmatel_spec *spec = codec->spec;
1908 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1912 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1913 struct hda_codec *codec,
1914 unsigned int stream_tag,
1915 unsigned int format,
1916 struct snd_pcm_substream *substream)
1918 struct sigmatel_spec *spec = codec->spec;
1919 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1922 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1923 struct hda_codec *codec,
1924 struct snd_pcm_substream *substream)
1926 struct sigmatel_spec *spec = codec->spec;
1927 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1931 * Digital playback callbacks
1933 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
1934 struct hda_codec *codec,
1935 struct snd_pcm_substream *substream)
1937 struct sigmatel_spec *spec = codec->spec;
1938 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
1941 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1942 struct hda_codec *codec,
1943 struct snd_pcm_substream *substream)
1945 struct sigmatel_spec *spec = codec->spec;
1946 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1949 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1950 struct hda_codec *codec,
1951 unsigned int stream_tag,
1952 unsigned int format,
1953 struct snd_pcm_substream *substream)
1955 struct sigmatel_spec *spec = codec->spec;
1956 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1957 stream_tag, format, substream);
1962 * Analog capture callbacks
1964 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1965 struct hda_codec *codec,
1966 unsigned int stream_tag,
1967 unsigned int format,
1968 struct snd_pcm_substream *substream)
1970 struct sigmatel_spec *spec = codec->spec;
1972 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1973 stream_tag, 0, format);
1977 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1978 struct hda_codec *codec,
1979 struct snd_pcm_substream *substream)
1981 struct sigmatel_spec *spec = codec->spec;
1983 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
1987 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1991 /* NID is set in stac92xx_build_pcms */
1993 .open = stac92xx_dig_playback_pcm_open,
1994 .close = stac92xx_dig_playback_pcm_close,
1995 .prepare = stac92xx_dig_playback_pcm_prepare
1999 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2003 /* NID is set in stac92xx_build_pcms */
2006 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2010 .nid = 0x02, /* NID to query formats and rates */
2012 .open = stac92xx_playback_pcm_open,
2013 .prepare = stac92xx_playback_pcm_prepare,
2014 .cleanup = stac92xx_playback_pcm_cleanup
2018 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2022 .nid = 0x06, /* NID to query formats and rates */
2024 .open = stac92xx_playback_pcm_open,
2025 .prepare = stac92xx_playback_pcm_prepare,
2026 .cleanup = stac92xx_playback_pcm_cleanup
2030 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2033 /* NID + .substreams is set in stac92xx_build_pcms */
2035 .prepare = stac92xx_capture_pcm_prepare,
2036 .cleanup = stac92xx_capture_pcm_cleanup
2040 static int stac92xx_build_pcms(struct hda_codec *codec)
2042 struct sigmatel_spec *spec = codec->spec;
2043 struct hda_pcm *info = spec->pcm_rec;
2045 codec->num_pcms = 1;
2046 codec->pcm_info = info;
2048 info->name = "STAC92xx Analog";
2049 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2050 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2051 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2052 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2054 if (spec->alt_switch) {
2057 info->name = "STAC92xx Analog Alt";
2058 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2061 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2064 info->name = "STAC92xx Digital";
2065 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2066 if (spec->multiout.dig_out_nid) {
2067 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2068 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2070 if (spec->dig_in_nid) {
2071 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2072 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2079 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2081 unsigned int pincap = snd_hda_param_read(codec, nid,
2083 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2084 if (pincap & AC_PINCAP_VREF_100)
2085 return AC_PINCTL_VREF_100;
2086 if (pincap & AC_PINCAP_VREF_80)
2087 return AC_PINCTL_VREF_80;
2088 if (pincap & AC_PINCAP_VREF_50)
2089 return AC_PINCTL_VREF_50;
2090 if (pincap & AC_PINCAP_VREF_GRD)
2091 return AC_PINCTL_VREF_GRD;
2095 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2098 snd_hda_codec_write_cache(codec, nid, 0,
2099 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2102 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2104 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2105 struct snd_ctl_elem_value *ucontrol)
2107 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2108 struct sigmatel_spec *spec = codec->spec;
2110 ucontrol->value.integer.value[0] = spec->hp_switch;
2114 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2115 struct snd_ctl_elem_value *ucontrol)
2117 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2118 struct sigmatel_spec *spec = codec->spec;
2120 spec->hp_switch = ucontrol->value.integer.value[0];
2122 /* check to be sure that the ports are upto date with
2125 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2130 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2132 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2134 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2135 struct sigmatel_spec *spec = codec->spec;
2136 int io_idx = kcontrol-> private_value & 0xff;
2138 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2142 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2144 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2145 struct sigmatel_spec *spec = codec->spec;
2146 hda_nid_t nid = kcontrol->private_value >> 8;
2147 int io_idx = kcontrol-> private_value & 0xff;
2148 unsigned short val = !!ucontrol->value.integer.value[0];
2150 spec->io_switch[io_idx] = val;
2153 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2155 unsigned int pinctl = AC_PINCTL_IN_EN;
2156 if (io_idx) /* set VREF for mic */
2157 pinctl |= stac92xx_get_vref(codec, nid);
2158 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2161 /* check the auto-mute again: we need to mute/unmute the speaker
2162 * appropriately according to the pin direction
2164 if (spec->hp_detect)
2165 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2170 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2172 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2173 struct snd_ctl_elem_value *ucontrol)
2175 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2176 struct sigmatel_spec *spec = codec->spec;
2178 ucontrol->value.integer.value[0] = spec->clfe_swap;
2182 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2183 struct snd_ctl_elem_value *ucontrol)
2185 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2186 struct sigmatel_spec *spec = codec->spec;
2187 hda_nid_t nid = kcontrol->private_value & 0xff;
2188 unsigned int val = !!ucontrol->value.integer.value[0];
2190 if (spec->clfe_swap == val)
2193 spec->clfe_swap = val;
2195 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2196 spec->clfe_swap ? 0x4 : 0x0);
2201 #define STAC_CODEC_HP_SWITCH(xname) \
2202 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2205 .info = stac92xx_hp_switch_info, \
2206 .get = stac92xx_hp_switch_get, \
2207 .put = stac92xx_hp_switch_put, \
2210 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2211 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2214 .info = stac92xx_io_switch_info, \
2215 .get = stac92xx_io_switch_get, \
2216 .put = stac92xx_io_switch_put, \
2217 .private_value = xpval, \
2220 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2221 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2224 .info = stac92xx_clfe_switch_info, \
2225 .get = stac92xx_clfe_switch_get, \
2226 .put = stac92xx_clfe_switch_put, \
2227 .private_value = xpval, \
2231 STAC_CTL_WIDGET_VOL,
2232 STAC_CTL_WIDGET_MUTE,
2233 STAC_CTL_WIDGET_MONO_MUX,
2234 STAC_CTL_WIDGET_HP_SWITCH,
2235 STAC_CTL_WIDGET_IO_SWITCH,
2236 STAC_CTL_WIDGET_CLFE_SWITCH
2239 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2240 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2241 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2243 STAC_CODEC_HP_SWITCH(NULL),
2244 STAC_CODEC_IO_SWITCH(NULL, 0),
2245 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2248 /* add dynamic controls */
2249 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2251 struct snd_kcontrol_new *knew;
2253 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2254 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2256 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2259 if (spec->kctl_alloc) {
2260 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2261 kfree(spec->kctl_alloc);
2263 spec->kctl_alloc = knew;
2264 spec->num_kctl_alloc = num;
2267 knew = &spec->kctl_alloc[spec->num_kctl_used];
2268 *knew = stac92xx_control_templates[type];
2269 knew->name = kstrdup(name, GFP_KERNEL);
2272 knew->private_value = val;
2273 spec->num_kctl_used++;
2277 /* flag inputs as additional dynamic lineouts */
2278 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2280 struct sigmatel_spec *spec = codec->spec;
2281 unsigned int wcaps, wtype;
2282 int i, num_dacs = 0;
2284 /* use the wcaps cache to count all DACs available for line-outs */
2285 for (i = 0; i < codec->num_nodes; i++) {
2286 wcaps = codec->wcaps[i];
2287 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2289 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2293 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2295 switch (cfg->line_outs) {
2297 /* add line-in as side */
2298 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2299 cfg->line_out_pins[cfg->line_outs] =
2300 cfg->input_pins[AUTO_PIN_LINE];
2301 spec->line_switch = 1;
2306 /* add line-in as clfe and mic as side */
2307 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2308 cfg->line_out_pins[cfg->line_outs] =
2309 cfg->input_pins[AUTO_PIN_LINE];
2310 spec->line_switch = 1;
2313 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2314 cfg->line_out_pins[cfg->line_outs] =
2315 cfg->input_pins[AUTO_PIN_MIC];
2316 spec->mic_switch = 1;
2321 /* add line-in as surr and mic as clfe */
2322 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2323 cfg->line_out_pins[cfg->line_outs] =
2324 cfg->input_pins[AUTO_PIN_LINE];
2325 spec->line_switch = 1;
2328 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2329 cfg->line_out_pins[cfg->line_outs] =
2330 cfg->input_pins[AUTO_PIN_MIC];
2331 spec->mic_switch = 1;
2341 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2345 for (i = 0; i < spec->multiout.num_dacs; i++) {
2346 if (spec->multiout.dac_nids[i] == nid)
2354 * Fill in the dac_nids table from the parsed pin configuration
2355 * This function only works when every pin in line_out_pins[]
2356 * contains atleast one DAC in its connection list. Some 92xx
2357 * codecs are not connected directly to a DAC, such as the 9200
2358 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2360 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2361 struct auto_pin_cfg *cfg)
2363 struct sigmatel_spec *spec = codec->spec;
2364 int i, j, conn_len = 0;
2365 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2366 unsigned int wcaps, wtype;
2368 for (i = 0; i < cfg->line_outs; i++) {
2369 nid = cfg->line_out_pins[i];
2370 conn_len = snd_hda_get_connections(codec, nid, conn,
2371 HDA_MAX_CONNECTIONS);
2372 for (j = 0; j < conn_len; j++) {
2373 wcaps = snd_hda_param_read(codec, conn[j],
2374 AC_PAR_AUDIO_WIDGET_CAP);
2375 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2376 if (wtype != AC_WID_AUD_OUT ||
2377 (wcaps & AC_WCAP_DIGITAL))
2379 /* conn[j] is a DAC routed to this line-out */
2380 if (!is_in_dac_nids(spec, conn[j]))
2384 if (j == conn_len) {
2385 if (spec->multiout.num_dacs > 0) {
2386 /* we have already working output pins,
2387 * so let's drop the broken ones again
2389 cfg->line_outs = spec->multiout.num_dacs;
2392 /* error out, no available DAC found */
2394 "%s: No available DAC for pin 0x%x\n",
2399 spec->multiout.dac_nids[i] = conn[j];
2400 spec->multiout.num_dacs++;
2402 /* select this DAC in the pin's input mux */
2403 snd_hda_codec_write_cache(codec, nid, 0,
2404 AC_VERB_SET_CONNECT_SEL, j);
2409 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2410 spec->multiout.num_dacs,
2411 spec->multiout.dac_nids[0],
2412 spec->multiout.dac_nids[1],
2413 spec->multiout.dac_nids[2],
2414 spec->multiout.dac_nids[3],
2415 spec->multiout.dac_nids[4]);
2419 /* create volume control/switch for the given prefx type */
2420 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2425 sprintf(name, "%s Playback Volume", pfx);
2426 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2427 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2430 sprintf(name, "%s Playback Switch", pfx);
2431 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2432 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2438 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2440 if (!spec->multiout.hp_nid)
2441 spec->multiout.hp_nid = nid;
2442 else if (spec->multiout.num_dacs > 4) {
2443 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2446 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2447 spec->multiout.num_dacs++;
2452 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2454 if (is_in_dac_nids(spec, nid))
2456 if (spec->multiout.hp_nid == nid)
2461 /* add playback controls from the parsed DAC table */
2462 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2463 const struct auto_pin_cfg *cfg)
2465 static const char *chname[4] = {
2466 "Front", "Surround", NULL /*CLFE*/, "Side"
2471 struct sigmatel_spec *spec = codec->spec;
2472 unsigned int wid_caps, pincap;
2475 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2476 if (!spec->multiout.dac_nids[i])
2479 nid = spec->multiout.dac_nids[i];
2483 err = create_controls(spec, "Center", nid, 1);
2486 err = create_controls(spec, "LFE", nid, 2);
2490 wid_caps = get_wcaps(codec, nid);
2492 if (wid_caps & AC_WCAP_LR_SWAP) {
2493 err = stac92xx_add_control(spec,
2494 STAC_CTL_WIDGET_CLFE_SWITCH,
2495 "Swap Center/LFE Playback Switch", nid);
2502 err = create_controls(spec, chname[i], nid, 3);
2508 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
2509 err = stac92xx_add_control(spec,
2510 STAC_CTL_WIDGET_HP_SWITCH,
2511 "Headphone as Line Out Switch", 0);
2516 if (spec->line_switch) {
2517 nid = cfg->input_pins[AUTO_PIN_LINE];
2518 pincap = snd_hda_param_read(codec, nid,
2520 if (pincap & AC_PINCAP_OUT) {
2521 err = stac92xx_add_control(spec,
2522 STAC_CTL_WIDGET_IO_SWITCH,
2523 "Line In as Output Switch", nid << 8);
2529 if (spec->mic_switch) {
2530 unsigned int def_conf;
2531 unsigned int mic_pin = AUTO_PIN_MIC;
2533 nid = cfg->input_pins[mic_pin];
2534 def_conf = snd_hda_codec_read(codec, nid, 0,
2535 AC_VERB_GET_CONFIG_DEFAULT, 0);
2536 /* some laptops have an internal analog microphone
2537 * which can't be used as a output */
2538 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2539 pincap = snd_hda_param_read(codec, nid,
2541 if (pincap & AC_PINCAP_OUT) {
2542 err = stac92xx_add_control(spec,
2543 STAC_CTL_WIDGET_IO_SWITCH,
2544 "Mic as Output Switch", (nid << 8) | 1);
2545 nid = snd_hda_codec_read(codec, nid, 0,
2546 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2547 if (!check_in_dac_nids(spec, nid))
2548 add_spec_dacs(spec, nid);
2552 } else if (mic_pin == AUTO_PIN_MIC) {
2553 mic_pin = AUTO_PIN_FRONT_MIC;
2561 /* add playback controls for Speaker and HP outputs */
2562 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2563 struct auto_pin_cfg *cfg)
2565 struct sigmatel_spec *spec = codec->spec;
2567 int i, old_num_dacs, err;
2569 old_num_dacs = spec->multiout.num_dacs;
2570 for (i = 0; i < cfg->hp_outs; i++) {
2571 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2572 if (wid_caps & AC_WCAP_UNSOL_CAP)
2573 spec->hp_detect = 1;
2574 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2575 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2576 if (check_in_dac_nids(spec, nid))
2580 add_spec_dacs(spec, nid);
2582 for (i = 0; i < cfg->speaker_outs; i++) {
2583 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2584 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2585 if (check_in_dac_nids(spec, nid))
2589 add_spec_dacs(spec, nid);
2591 for (i = 0; i < cfg->line_outs; i++) {
2592 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2593 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2594 if (check_in_dac_nids(spec, nid))
2598 add_spec_dacs(spec, nid);
2600 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2601 static const char *pfxs[] = {
2602 "Speaker", "External Speaker", "Speaker2",
2604 err = create_controls(spec, pfxs[i - old_num_dacs],
2605 spec->multiout.dac_nids[i], 3);
2609 if (spec->multiout.hp_nid) {
2610 err = create_controls(spec, "Headphone",
2611 spec->multiout.hp_nid, 3);
2619 /* labels for mono mux outputs */
2620 static const char *stac92xx_mono_labels[3] = {
2621 "DAC0", "DAC1", "Mixer"
2624 /* create mono mux for mono out on capable codecs */
2625 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2627 struct sigmatel_spec *spec = codec->spec;
2628 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2630 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2632 num_cons = snd_hda_get_connections(codec,
2635 HDA_MAX_NUM_INPUTS);
2636 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2639 for (i = 0; i < num_cons; i++) {
2640 mono_mux->items[mono_mux->num_items].label =
2641 stac92xx_mono_labels[i];
2642 mono_mux->items[mono_mux->num_items].index = i;
2643 mono_mux->num_items++;
2646 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2647 "Mono Mux", spec->mono_nid);
2650 /* labels for dmic mux inputs */
2651 static const char *stac92xx_dmic_labels[5] = {
2652 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2653 "Digital Mic 3", "Digital Mic 4"
2656 /* create playback/capture controls for input pins on dmic capable codecs */
2657 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2658 const struct auto_pin_cfg *cfg)
2660 struct sigmatel_spec *spec = codec->spec;
2661 struct hda_input_mux *dimux = &spec->private_dimux;
2662 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2666 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2667 dimux->items[dimux->num_items].index = 0;
2670 for (i = 0; i < spec->num_dmics; i++) {
2675 unsigned int def_conf;
2677 def_conf = snd_hda_codec_read(codec,
2680 AC_VERB_GET_CONFIG_DEFAULT,
2682 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2685 nid = spec->dmic_nids[i];
2686 num_cons = snd_hda_get_connections(codec,
2689 HDA_MAX_NUM_INPUTS);
2690 for (j = 0; j < num_cons; j++)
2691 if (con_lst[j] == nid) {
2697 wcaps = get_wcaps(codec, nid);
2699 if (wcaps & AC_WCAP_OUT_AMP) {
2700 sprintf(name, "%s Capture Volume",
2701 stac92xx_dmic_labels[dimux->num_items]);
2703 err = stac92xx_add_control(spec,
2704 STAC_CTL_WIDGET_VOL,
2706 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2711 dimux->items[dimux->num_items].label =
2712 stac92xx_dmic_labels[dimux->num_items];
2713 dimux->items[dimux->num_items].index = index;
2720 /* create playback/capture controls for input pins */
2721 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2723 struct sigmatel_spec *spec = codec->spec;
2724 struct hda_input_mux *imux = &spec->private_imux;
2725 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2728 for (i = 0; i < AUTO_PIN_LAST; i++) {
2731 if (!cfg->input_pins[i])
2734 for (j = 0; j < spec->num_muxes; j++) {
2736 num_cons = snd_hda_get_connections(codec,
2739 HDA_MAX_NUM_INPUTS);
2740 for (k = 0; k < num_cons; k++)
2741 if (con_lst[k] == cfg->input_pins[i]) {
2748 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2749 imux->items[imux->num_items].index = index;
2753 if (imux->num_items) {
2755 * Set the current input for the muxes.
2756 * The STAC9221 has two input muxes with identical source
2757 * NID lists. Hopefully this won't get confused.
2759 for (i = 0; i < spec->num_muxes; i++) {
2760 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2761 AC_VERB_SET_CONNECT_SEL,
2762 imux->items[0].index);
2769 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2771 struct sigmatel_spec *spec = codec->spec;
2774 for (i = 0; i < spec->autocfg.line_outs; i++) {
2775 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2776 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2780 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2782 struct sigmatel_spec *spec = codec->spec;
2785 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2787 pin = spec->autocfg.hp_pins[i];
2788 if (pin) /* connect to front */
2789 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2791 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2793 pin = spec->autocfg.speaker_pins[i];
2794 if (pin) /* connect to front */
2795 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2799 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2801 struct sigmatel_spec *spec = codec->spec;
2803 int hp_speaker_swap = 0;
2805 if ((err = snd_hda_parse_pin_def_config(codec,
2807 spec->dmic_nids)) < 0)
2809 if (! spec->autocfg.line_outs)
2810 return 0; /* can't find valid pin config */
2812 /* If we have no real line-out pin and multiple hp-outs, HPs should
2813 * be set up as multi-channel outputs.
2815 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2816 spec->autocfg.hp_outs > 1) {
2817 /* Copy hp_outs to line_outs, backup line_outs in
2818 * speaker_outs so that the following routines can handle
2819 * HP pins as primary outputs.
2821 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2822 sizeof(spec->autocfg.line_out_pins));
2823 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2824 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2825 sizeof(spec->autocfg.hp_pins));
2826 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2827 hp_speaker_swap = 1;
2829 if (spec->autocfg.mono_out_pin) {
2830 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2831 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2832 u32 caps = query_amp_caps(codec,
2833 spec->autocfg.mono_out_pin, dir);
2834 hda_nid_t conn_list[1];
2836 /* get the mixer node and then the mono mux if it exists */
2837 if (snd_hda_get_connections(codec,
2838 spec->autocfg.mono_out_pin, conn_list, 1) &&
2839 snd_hda_get_connections(codec, conn_list[0],
2842 int wcaps = get_wcaps(codec, conn_list[0]);
2843 int wid_type = (wcaps & AC_WCAP_TYPE)
2844 >> AC_WCAP_TYPE_SHIFT;
2845 /* LR swap check, some stac925x have a mux that
2846 * changes the DACs output path instead of the
2849 if (wid_type == AC_WID_AUD_SEL &&
2850 !(wcaps & AC_WCAP_LR_SWAP))
2851 spec->mono_nid = conn_list[0];
2853 /* all mono outs have a least a mute/unmute switch */
2854 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2855 "Mono Playback Switch",
2856 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2860 /* check to see if there is volume support for the amp */
2861 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2862 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2863 "Mono Playback Volume",
2864 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2870 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2874 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2876 if (spec->multiout.num_dacs == 0)
2877 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2880 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2885 if (hp_speaker_swap == 1) {
2886 /* Restore the hp_outs and line_outs */
2887 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2888 sizeof(spec->autocfg.line_out_pins));
2889 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2890 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2891 sizeof(spec->autocfg.speaker_pins));
2892 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2893 memset(spec->autocfg.speaker_pins, 0,
2894 sizeof(spec->autocfg.speaker_pins));
2895 spec->autocfg.speaker_outs = 0;
2898 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2903 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2908 if (spec->mono_nid > 0) {
2909 err = stac92xx_auto_create_mono_output_ctls(codec);
2914 if (spec->num_dmics > 0)
2915 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2916 &spec->autocfg)) < 0)
2919 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2920 if (spec->multiout.max_channels > 2)
2921 spec->surr_switch = 1;
2923 if (spec->autocfg.dig_out_pin)
2924 spec->multiout.dig_out_nid = dig_out;
2925 if (spec->autocfg.dig_in_pin)
2926 spec->dig_in_nid = dig_in;
2928 if (spec->kctl_alloc)
2929 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2931 spec->input_mux = &spec->private_imux;
2932 if (!spec->dinput_mux)
2933 spec->dinput_mux = &spec->private_dimux;
2934 spec->mono_mux = &spec->private_mono_mux;
2939 /* add playback controls for HP output */
2940 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2941 struct auto_pin_cfg *cfg)
2943 struct sigmatel_spec *spec = codec->spec;
2944 hda_nid_t pin = cfg->hp_pins[0];
2945 unsigned int wid_caps;
2950 wid_caps = get_wcaps(codec, pin);
2951 if (wid_caps & AC_WCAP_UNSOL_CAP)
2952 spec->hp_detect = 1;
2957 /* add playback controls for LFE output */
2958 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2959 struct auto_pin_cfg *cfg)
2961 struct sigmatel_spec *spec = codec->spec;
2963 hda_nid_t lfe_pin = 0x0;
2967 * search speaker outs and line outs for a mono speaker pin
2968 * with an amp. If one is found, add LFE controls
2971 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2972 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2973 unsigned int wcaps = get_wcaps(codec, pin);
2974 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2975 if (wcaps == AC_WCAP_OUT_AMP)
2976 /* found a mono speaker with an amp, must be lfe */
2980 /* if speaker_outs is 0, then speakers may be in line_outs */
2981 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
2982 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
2983 hda_nid_t pin = spec->autocfg.line_out_pins[i];
2984 unsigned int defcfg;
2985 defcfg = snd_hda_codec_read(codec, pin, 0,
2986 AC_VERB_GET_CONFIG_DEFAULT,
2988 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
2989 unsigned int wcaps = get_wcaps(codec, pin);
2990 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2991 if (wcaps == AC_WCAP_OUT_AMP)
2992 /* found a mono speaker with an amp,
3000 err = create_controls(spec, "LFE", lfe_pin, 1);
3008 static int stac9200_parse_auto_config(struct hda_codec *codec)
3010 struct sigmatel_spec *spec = codec->spec;
3013 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3016 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3019 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3022 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3025 if (spec->autocfg.dig_out_pin)
3026 spec->multiout.dig_out_nid = 0x05;
3027 if (spec->autocfg.dig_in_pin)
3028 spec->dig_in_nid = 0x04;
3030 if (spec->kctl_alloc)
3031 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3033 spec->input_mux = &spec->private_imux;
3034 spec->dinput_mux = &spec->private_dimux;
3040 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3041 * funky external mute control using GPIO pins.
3044 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3045 unsigned int dir_mask, unsigned int data)
3047 unsigned int gpiostate, gpiomask, gpiodir;
3049 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3050 AC_VERB_GET_GPIO_DATA, 0);
3051 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3053 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3054 AC_VERB_GET_GPIO_MASK, 0);
3057 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3058 AC_VERB_GET_GPIO_DIRECTION, 0);
3059 gpiodir |= dir_mask;
3061 /* Configure GPIOx as CMOS */
3062 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3064 snd_hda_codec_write(codec, codec->afg, 0,
3065 AC_VERB_SET_GPIO_MASK, gpiomask);
3066 snd_hda_codec_read(codec, codec->afg, 0,
3067 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3071 snd_hda_codec_read(codec, codec->afg, 0,
3072 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3075 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3078 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3079 snd_hda_codec_write_cache(codec, nid, 0,
3080 AC_VERB_SET_UNSOLICITED_ENABLE,
3081 (AC_USRSP_EN | event));
3084 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3087 for (i = 0; i < cfg->hp_outs; i++)
3088 if (cfg->hp_pins[i] == nid)
3089 return 1; /* nid is a HP-Out */
3091 return 0; /* nid is not a HP-Out */
3094 static void stac92xx_power_down(struct hda_codec *codec)
3096 struct sigmatel_spec *spec = codec->spec;
3098 /* power down inactive DACs */
3100 for (dac = spec->dac_list; *dac; dac++)
3101 if (!is_in_dac_nids(spec, *dac) &&
3102 spec->multiout.hp_nid != *dac)
3103 snd_hda_codec_write_cache(codec, *dac, 0,
3104 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3107 static int stac92xx_init(struct hda_codec *codec)
3109 struct sigmatel_spec *spec = codec->spec;
3110 struct auto_pin_cfg *cfg = &spec->autocfg;
3113 snd_hda_sequence_write(codec, spec->init);
3116 if (spec->hp_detect) {
3117 /* Enable unsolicited responses on the HP widget */
3118 for (i = 0; i < cfg->hp_outs; i++)
3119 enable_pin_detect(codec, cfg->hp_pins[i],
3121 /* force to enable the first line-out; the others are set up
3124 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3126 stac92xx_auto_init_hp_out(codec);
3127 /* fake event to set up pins */
3128 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3130 stac92xx_auto_init_multi_out(codec);
3131 stac92xx_auto_init_hp_out(codec);
3133 for (i = 0; i < AUTO_PIN_LAST; i++) {
3134 hda_nid_t nid = cfg->input_pins[i];
3136 unsigned int pinctl = AC_PINCTL_IN_EN;
3137 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3138 pinctl |= stac92xx_get_vref(codec, nid);
3139 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3142 for (i = 0; i < spec->num_dmics; i++)
3143 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3145 for (i = 0; i < spec->num_pwrs; i++) {
3146 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3147 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3148 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3149 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3150 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3151 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3152 def_conf = get_defcfg_connect(def_conf);
3153 /* outputs are only ports capable of power management
3154 * any attempts on powering down a input port cause the
3155 * referenced VREF to act quirky.
3157 if (pinctl & AC_PINCTL_IN_EN)
3159 /* skip any ports that don't have jacks since presence
3160 * detection is useless */
3161 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3163 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3164 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3167 stac92xx_power_down(codec);
3168 if (cfg->dig_out_pin)
3169 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3171 if (cfg->dig_in_pin)
3172 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3175 stac_gpio_set(codec, spec->gpio_mask,
3176 spec->gpio_dir, spec->gpio_data);
3181 static void stac92xx_free(struct hda_codec *codec)
3183 struct sigmatel_spec *spec = codec->spec;
3189 if (spec->kctl_alloc) {
3190 for (i = 0; i < spec->num_kctl_used; i++)
3191 kfree(spec->kctl_alloc[i].name);
3192 kfree(spec->kctl_alloc);
3195 if (spec->bios_pin_configs)
3196 kfree(spec->bios_pin_configs);
3201 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3204 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3205 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3207 if (pin_ctl & AC_PINCTL_IN_EN) {
3209 * we need to check the current set-up direction of
3210 * shared input pins since they can be switched via
3211 * "xxx as Output" mixer switch
3213 struct sigmatel_spec *spec = codec->spec;
3214 struct auto_pin_cfg *cfg = &spec->autocfg;
3215 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3216 spec->line_switch) ||
3217 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3222 /* if setting pin direction bits, clear the current
3223 direction bits first */
3224 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3225 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3227 snd_hda_codec_write_cache(codec, nid, 0,
3228 AC_VERB_SET_PIN_WIDGET_CONTROL,
3232 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3235 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3236 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3237 snd_hda_codec_write_cache(codec, nid, 0,
3238 AC_VERB_SET_PIN_WIDGET_CONTROL,
3242 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3246 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3248 unsigned int pinctl;
3249 pinctl = snd_hda_codec_read(codec, nid, 0,
3250 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3251 if (pinctl & AC_PINCTL_IN_EN)
3252 return 0; /* mic- or line-input */
3254 return 1; /* HP-output */
3259 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3261 struct sigmatel_spec *spec = codec->spec;
3262 struct auto_pin_cfg *cfg = &spec->autocfg;
3263 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3267 if (spec->gpio_mute)
3268 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3269 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3271 for (i = 0; i < cfg->hp_outs; i++) {
3274 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3276 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3280 /* disable lineouts, enable hp */
3281 if (spec->hp_switch)
3282 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3283 for (i = 0; i < cfg->line_outs; i++)
3284 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3286 for (i = 0; i < cfg->speaker_outs; i++)
3287 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3289 if (spec->eapd_mask)
3290 stac_gpio_set(codec, spec->gpio_mask,
3291 spec->gpio_dir, spec->gpio_data &
3294 /* enable lineouts, disable hp */
3295 if (spec->hp_switch)
3296 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3297 for (i = 0; i < cfg->line_outs; i++)
3298 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3300 for (i = 0; i < cfg->speaker_outs; i++)
3301 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3303 if (spec->eapd_mask)
3304 stac_gpio_set(codec, spec->gpio_mask,
3305 spec->gpio_dir, spec->gpio_data |
3308 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3309 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3312 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3314 struct sigmatel_spec *spec = codec->spec;
3315 hda_nid_t nid = spec->pwr_nids[idx];
3317 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3319 presence = get_hp_pin_presence(codec, nid);
3327 /* power down unused output ports */
3328 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3331 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3333 struct sigmatel_spec *spec = codec->spec;
3334 int idx = res >> 26 & 0x0f;
3336 switch ((res >> 26) & 0x30) {
3338 stac92xx_hp_detect(codec, res);
3340 case STAC_PWR_EVENT:
3341 if (spec->num_pwrs > 0)
3342 stac92xx_pin_sense(codec, idx);
3346 #ifdef SND_HDA_NEEDS_RESUME
3347 static int stac92xx_resume(struct hda_codec *codec)
3349 struct sigmatel_spec *spec = codec->spec;
3351 stac92xx_set_config_regs(codec);
3352 snd_hda_sequence_write(codec, spec->init);
3353 stac_gpio_set(codec, spec->gpio_mask,
3354 spec->gpio_dir, spec->gpio_data);
3355 snd_hda_codec_resume_amp(codec);
3356 snd_hda_codec_resume_cache(codec);
3357 /* power down inactive DACs */
3359 stac92xx_power_down(codec);
3360 /* invoke unsolicited event to reset the HP state */
3361 if (spec->hp_detect)
3362 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3367 static struct hda_codec_ops stac92xx_patch_ops = {
3368 .build_controls = stac92xx_build_controls,
3369 .build_pcms = stac92xx_build_pcms,
3370 .init = stac92xx_init,
3371 .free = stac92xx_free,
3372 .unsol_event = stac92xx_unsol_event,
3373 #ifdef SND_HDA_NEEDS_RESUME
3374 .resume = stac92xx_resume,
3378 static int patch_stac9200(struct hda_codec *codec)
3380 struct sigmatel_spec *spec;
3383 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3388 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3389 spec->pin_nids = stac9200_pin_nids;
3390 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3393 if (spec->board_config < 0) {
3394 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3395 err = stac92xx_save_bios_config_regs(codec);
3397 stac92xx_free(codec);
3400 spec->pin_configs = spec->bios_pin_configs;
3402 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3403 stac92xx_set_config_regs(codec);
3406 spec->multiout.max_channels = 2;
3407 spec->multiout.num_dacs = 1;
3408 spec->multiout.dac_nids = stac9200_dac_nids;
3409 spec->adc_nids = stac9200_adc_nids;
3410 spec->mux_nids = stac9200_mux_nids;
3411 spec->num_muxes = 1;
3412 spec->num_dmics = 0;
3416 if (spec->board_config == STAC_9200_GATEWAY ||
3417 spec->board_config == STAC_9200_OQO)
3418 spec->init = stac9200_eapd_init;
3420 spec->init = stac9200_core_init;
3421 spec->mixer = stac9200_mixer;
3423 if (spec->board_config == STAC_9200_PANASONIC) {
3424 spec->gpio_mask = spec->gpio_dir = 0x09;
3425 spec->gpio_data = 0x00;
3428 err = stac9200_parse_auto_config(codec);
3430 stac92xx_free(codec);
3434 codec->patch_ops = stac92xx_patch_ops;
3439 static int patch_stac925x(struct hda_codec *codec)
3441 struct sigmatel_spec *spec;
3444 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3449 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3450 spec->pin_nids = stac925x_pin_nids;
3451 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3455 if (spec->board_config < 0) {
3456 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3457 "using BIOS defaults\n");
3458 err = stac92xx_save_bios_config_regs(codec);
3460 stac92xx_free(codec);
3463 spec->pin_configs = spec->bios_pin_configs;
3464 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3465 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3466 stac92xx_set_config_regs(codec);
3469 spec->multiout.max_channels = 2;
3470 spec->multiout.num_dacs = 1;
3471 spec->multiout.dac_nids = stac925x_dac_nids;
3472 spec->adc_nids = stac925x_adc_nids;
3473 spec->mux_nids = stac925x_mux_nids;
3474 spec->num_muxes = 1;
3477 switch (codec->vendor_id) {
3478 case 0x83847632: /* STAC9202 */
3479 case 0x83847633: /* STAC9202D */
3480 case 0x83847636: /* STAC9251 */
3481 case 0x83847637: /* STAC9251D */
3482 spec->num_dmics = STAC925X_NUM_DMICS;
3483 spec->dmic_nids = stac925x_dmic_nids;
3484 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3485 spec->dmux_nids = stac925x_dmux_nids;
3488 spec->num_dmics = 0;
3492 spec->init = stac925x_core_init;
3493 spec->mixer = stac925x_mixer;
3495 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
3497 if (spec->board_config < 0) {
3498 printk(KERN_WARNING "hda_codec: No auto-config is "
3499 "available, default to model=ref\n");
3500 spec->board_config = STAC_925x_REF;
3506 stac92xx_free(codec);
3510 codec->patch_ops = stac92xx_patch_ops;
3515 static struct hda_input_mux stac92hd73xx_dmux = {
3518 { "Analog Inputs", 0x0b },
3520 { "Digital Mic 1", 0x09 },
3521 { "Digital Mic 2", 0x0a },
3525 static int patch_stac92hd73xx(struct hda_codec *codec)
3527 struct sigmatel_spec *spec;
3528 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3531 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3536 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3537 spec->pin_nids = stac92hd73xx_pin_nids;
3538 spec->board_config = snd_hda_check_board_config(codec,
3539 STAC_92HD73XX_MODELS,
3540 stac92hd73xx_models,
3541 stac92hd73xx_cfg_tbl);
3543 if (spec->board_config < 0) {
3544 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3545 " STAC92HD73XX, using BIOS defaults\n");
3546 err = stac92xx_save_bios_config_regs(codec);
3548 stac92xx_free(codec);
3551 spec->pin_configs = spec->bios_pin_configs;
3553 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3554 stac92xx_set_config_regs(codec);
3557 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3558 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3560 if (spec->multiout.num_dacs < 0) {
3561 printk(KERN_WARNING "hda_codec: Could not determine "
3562 "number of channels defaulting to DAC count\n");
3563 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3566 switch (spec->multiout.num_dacs) {
3567 case 0x3: /* 6 Channel */
3568 spec->multiout.hp_nid = 0x17;
3569 spec->mixer = stac92hd73xx_6ch_mixer;
3570 spec->init = stac92hd73xx_6ch_core_init;
3572 case 0x4: /* 8 Channel */
3573 spec->multiout.hp_nid = 0x18;
3574 spec->mixer = stac92hd73xx_8ch_mixer;
3575 spec->init = stac92hd73xx_8ch_core_init;
3577 case 0x5: /* 10 Channel */
3578 spec->multiout.hp_nid = 0x19;
3579 spec->mixer = stac92hd73xx_10ch_mixer;
3580 spec->init = stac92hd73xx_10ch_core_init;
3583 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3584 spec->aloopback_mask = 0x01;
3585 spec->aloopback_shift = 8;
3587 spec->mux_nids = stac92hd73xx_mux_nids;
3588 spec->adc_nids = stac92hd73xx_adc_nids;
3589 spec->dmic_nids = stac92hd73xx_dmic_nids;
3590 spec->dmux_nids = stac92hd73xx_dmux_nids;
3592 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3593 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3594 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3595 spec->dinput_mux = &stac92hd73xx_dmux;
3596 /* GPIO0 High = Enable EAPD */
3597 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3598 spec->gpio_data = 0x01;
3600 switch (spec->board_config) {
3602 spec->init = dell_eq_core_init;
3606 spec->init = dell_m6_core_init;
3607 switch (codec->subsystem_id) {
3608 case 0x1028025e: /* Analog Mics */
3610 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3611 spec->num_dmics = 0;
3613 case 0x10280271: /* Digital Mics */
3617 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3618 spec->num_dmics = 1;
3620 case 0x10280256: /* Both */
3622 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3623 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3624 spec->num_dmics = 1;
3629 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3632 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3633 spec->pwr_nids = stac92hd73xx_pwr_nids;
3635 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3638 if (spec->board_config < 0) {
3639 printk(KERN_WARNING "hda_codec: No auto-config is "
3640 "available, default to model=ref\n");
3641 spec->board_config = STAC_92HD73XX_REF;
3648 stac92xx_free(codec);
3652 codec->patch_ops = stac92xx_patch_ops;
3657 static int patch_stac92hd71bxx(struct hda_codec *codec)
3659 struct sigmatel_spec *spec;
3662 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3667 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
3668 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3669 spec->pin_nids = stac92hd71bxx_pin_nids;
3670 spec->board_config = snd_hda_check_board_config(codec,
3671 STAC_92HD71BXX_MODELS,
3672 stac92hd71bxx_models,
3673 stac92hd71bxx_cfg_tbl);
3675 if (spec->board_config < 0) {
3676 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3677 " STAC92HD71BXX, using BIOS defaults\n");
3678 err = stac92xx_save_bios_config_regs(codec);
3680 stac92xx_free(codec);
3683 spec->pin_configs = spec->bios_pin_configs;
3685 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3686 stac92xx_set_config_regs(codec);
3689 switch (codec->vendor_id) {
3690 case 0x111d76b6: /* 4 Port without Analog Mixer */
3692 case 0x111d76b4: /* 6 Port without Analog Mixer */
3694 spec->mixer = stac92hd71bxx_mixer;
3695 spec->init = stac92hd71bxx_core_init;
3697 case 0x111d7608: /* 5 Port with Analog Mixer */
3698 /* no output amps */
3700 spec->mixer = stac92hd71bxx_analog_mixer;
3703 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3704 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3706 case 0x111d7603: /* 6 Port with Analog Mixer */
3707 /* no output amps */
3711 spec->mixer = stac92hd71bxx_analog_mixer;
3712 spec->init = stac92hd71bxx_analog_core_init;
3715 spec->aloopback_mask = 0x20;
3716 spec->aloopback_shift = 0;
3718 /* GPIO0 High = EAPD */
3719 spec->gpio_mask = 0x01;
3720 spec->gpio_dir = 0x01;
3721 spec->gpio_data = 0x01;
3723 spec->mux_nids = stac92hd71bxx_mux_nids;
3724 spec->adc_nids = stac92hd71bxx_adc_nids;
3725 spec->dmic_nids = stac92hd71bxx_dmic_nids;
3726 spec->dmux_nids = stac92hd71bxx_dmux_nids;
3727 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3729 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3730 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3731 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3732 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3734 spec->multiout.num_dacs = 1;
3735 spec->multiout.hp_nid = 0x11;
3736 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3738 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3740 if (spec->board_config < 0) {
3741 printk(KERN_WARNING "hda_codec: No auto-config is "
3742 "available, default to model=ref\n");
3743 spec->board_config = STAC_92HD71BXX_REF;
3750 stac92xx_free(codec);
3754 codec->patch_ops = stac92xx_patch_ops;
3759 static int patch_stac922x(struct hda_codec *codec)
3761 struct sigmatel_spec *spec;
3764 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3769 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
3770 spec->pin_nids = stac922x_pin_nids;
3771 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3774 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
3775 spec->gpio_mask = spec->gpio_dir = 0x03;
3776 spec->gpio_data = 0x03;
3777 /* Intel Macs have all same PCI SSID, so we need to check
3778 * codec SSID to distinguish the exact models
3780 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
3781 switch (codec->subsystem_id) {
3784 spec->board_config = STAC_INTEL_MAC_V1;
3788 spec->board_config = STAC_INTEL_MAC_V2;
3796 spec->board_config = STAC_INTEL_MAC_V3;
3800 spec->board_config = STAC_INTEL_MAC_V4;
3804 spec->board_config = STAC_INTEL_MAC_V5;
3807 spec->board_config = STAC_INTEL_MAC_V3;
3813 if (spec->board_config < 0) {
3814 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3815 "using BIOS defaults\n");
3816 err = stac92xx_save_bios_config_regs(codec);
3818 stac92xx_free(codec);
3821 spec->pin_configs = spec->bios_pin_configs;
3822 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
3823 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3824 stac92xx_set_config_regs(codec);
3827 spec->adc_nids = stac922x_adc_nids;
3828 spec->mux_nids = stac922x_mux_nids;
3829 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
3830 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
3831 spec->num_dmics = 0;
3834 spec->init = stac922x_core_init;
3835 spec->mixer = stac922x_mixer;
3837 spec->multiout.dac_nids = spec->dac_nids;
3839 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
3841 if (spec->board_config < 0) {
3842 printk(KERN_WARNING "hda_codec: No auto-config is "
3843 "available, default to model=ref\n");
3844 spec->board_config = STAC_D945_REF;
3850 stac92xx_free(codec);
3854 codec->patch_ops = stac92xx_patch_ops;
3856 /* Fix Mux capture level; max to 2 */
3857 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3858 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3859 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3860 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3861 (0 << AC_AMPCAP_MUTE_SHIFT));
3866 static int patch_stac927x(struct hda_codec *codec)
3868 struct sigmatel_spec *spec;
3871 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3876 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3877 spec->pin_nids = stac927x_pin_nids;
3878 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3882 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3883 if (spec->board_config < 0)
3884 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3885 "STAC927x, using BIOS defaults\n");
3886 err = stac92xx_save_bios_config_regs(codec);
3888 stac92xx_free(codec);
3891 spec->pin_configs = spec->bios_pin_configs;
3893 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3894 stac92xx_set_config_regs(codec);
3897 spec->adc_nids = stac927x_adc_nids;
3898 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3899 spec->mux_nids = stac927x_mux_nids;
3900 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3901 spec->dac_list = stac927x_dac_nids;
3902 spec->multiout.dac_nids = spec->dac_nids;
3904 switch (spec->board_config) {
3907 /* GPIO0 High = Enable EAPD */
3908 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
3909 spec->gpio_data = 0x01;
3910 spec->num_dmics = 0;
3912 spec->init = d965_core_init;
3913 spec->mixer = stac927x_mixer;
3915 case STAC_DELL_BIOS:
3916 switch (codec->subsystem_id) {
3919 /* correct the device field to SPDIF out */
3920 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3923 /* configure the analog microphone on some laptops */
3924 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3925 /* correct the front output jack as a hp out */
3926 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3927 /* correct the front input jack as a mic */
3928 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3931 /* GPIO2 High = Enable EAPD */
3932 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3933 spec->gpio_data = 0x04;
3934 spec->dmic_nids = stac927x_dmic_nids;
3935 spec->num_dmics = STAC927X_NUM_DMICS;
3937 spec->init = d965_core_init;
3938 spec->mixer = stac927x_mixer;
3939 spec->dmux_nids = stac927x_dmux_nids;
3940 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3943 /* GPIO0 High = Enable EAPD */
3944 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3945 spec->gpio_data = 0x01;
3946 spec->num_dmics = 0;
3948 spec->init = stac927x_core_init;
3949 spec->mixer = stac927x_mixer;
3953 spec->aloopback_mask = 0x40;
3954 spec->aloopback_shift = 0;
3956 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3958 if (spec->board_config < 0) {
3959 printk(KERN_WARNING "hda_codec: No auto-config is "
3960 "available, default to model=ref\n");
3961 spec->board_config = STAC_D965_REF;
3967 stac92xx_free(codec);
3971 codec->patch_ops = stac92xx_patch_ops;
3975 * The STAC927x seem to require fairly long delays for certain
3976 * command sequences. With too short delays (even if the answer
3977 * is set to RIRB properly), it results in the silence output
3978 * on some hardwares like Dell.
3980 * The below flag enables the longer delay (see get_response
3983 codec->bus->needs_damn_long_delay = 1;
3988 static int patch_stac9205(struct hda_codec *codec)
3990 struct sigmatel_spec *spec;
3993 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3998 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
3999 spec->pin_nids = stac9205_pin_nids;
4000 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4004 if (spec->board_config < 0) {
4005 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4006 err = stac92xx_save_bios_config_regs(codec);
4008 stac92xx_free(codec);
4011 spec->pin_configs = spec->bios_pin_configs;
4013 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4014 stac92xx_set_config_regs(codec);
4017 spec->adc_nids = stac9205_adc_nids;
4018 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4019 spec->mux_nids = stac9205_mux_nids;
4020 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4021 spec->dmic_nids = stac9205_dmic_nids;
4022 spec->num_dmics = STAC9205_NUM_DMICS;
4023 spec->dmux_nids = stac9205_dmux_nids;
4024 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4027 spec->init = stac9205_core_init;
4028 spec->mixer = stac9205_mixer;
4030 spec->aloopback_mask = 0x40;
4031 spec->aloopback_shift = 0;
4032 spec->multiout.dac_nids = spec->dac_nids;
4034 switch (spec->board_config){
4035 case STAC_9205_DELL_M43:
4036 /* Enable SPDIF in/out */
4037 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4038 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4040 /* Enable unsol response for GPIO4/Dock HP connection */
4041 snd_hda_codec_write(codec, codec->afg, 0,
4042 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4043 snd_hda_codec_write_cache(codec, codec->afg, 0,
4044 AC_VERB_SET_UNSOLICITED_ENABLE,
4045 (AC_USRSP_EN | STAC_HP_EVENT));
4047 spec->gpio_dir = 0x0b;
4048 spec->eapd_mask = 0x01;
4049 spec->gpio_mask = 0x1b;
4050 spec->gpio_mute = 0x10;
4051 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4054 spec->gpio_data = 0x01;
4057 /* GPIO0 High = EAPD */
4058 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4059 spec->gpio_data = 0x01;
4063 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4065 if (spec->board_config < 0) {
4066 printk(KERN_WARNING "hda_codec: No auto-config is "
4067 "available, default to model=ref\n");
4068 spec->board_config = STAC_9205_REF;
4074 stac92xx_free(codec);
4078 codec->patch_ops = stac92xx_patch_ops;
4087 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4088 static hda_nid_t vaio_dacs[] = { 0x2 };
4089 #define VAIO_HP_DAC 0x5
4090 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4091 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4093 static struct hda_input_mux vaio_mux = {
4096 /* { "HP", 0x0 }, */
4097 { "Mic Jack", 0x1 },
4098 { "Internal Mic", 0x2 },
4103 static struct hda_verb vaio_init[] = {
4104 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4105 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
4106 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4107 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4108 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4109 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4110 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4111 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4112 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4113 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4114 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4115 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4119 static struct hda_verb vaio_ar_init[] = {
4120 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4121 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4122 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4123 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4124 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4125 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4126 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4127 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4128 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4129 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4130 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4136 /* bind volumes of both NID 0x02 and 0x05 */
4137 static struct hda_bind_ctls vaio_bind_master_vol = {
4138 .ops = &snd_hda_bind_vol,
4140 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4141 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4146 /* bind volumes of both NID 0x02 and 0x05 */
4147 static struct hda_bind_ctls vaio_bind_master_sw = {
4148 .ops = &snd_hda_bind_sw,
4150 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4151 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4156 static struct snd_kcontrol_new vaio_mixer[] = {
4157 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4158 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4159 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4160 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4161 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4163 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4164 .name = "Capture Source",
4166 .info = stac92xx_mux_enum_info,
4167 .get = stac92xx_mux_enum_get,
4168 .put = stac92xx_mux_enum_put,
4173 static struct snd_kcontrol_new vaio_ar_mixer[] = {
4174 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4175 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4176 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4177 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4178 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4179 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4180 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4182 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4183 .name = "Capture Source",
4185 .info = stac92xx_mux_enum_info,
4186 .get = stac92xx_mux_enum_get,
4187 .put = stac92xx_mux_enum_put,
4192 static struct hda_codec_ops stac9872_patch_ops = {
4193 .build_controls = stac92xx_build_controls,
4194 .build_pcms = stac92xx_build_pcms,
4195 .init = stac92xx_init,
4196 .free = stac92xx_free,
4197 #ifdef SND_HDA_NEEDS_RESUME
4198 .resume = stac92xx_resume,
4202 static int stac9872_vaio_init(struct hda_codec *codec)
4206 err = stac92xx_init(codec);
4209 if (codec->patch_ops.unsol_event)
4210 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4214 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4216 if (get_hp_pin_presence(codec, 0x0a)) {
4217 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4218 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4220 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4221 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4225 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4227 switch (res >> 26) {
4229 stac9872_vaio_hp_detect(codec, res);
4234 static struct hda_codec_ops stac9872_vaio_patch_ops = {
4235 .build_controls = stac92xx_build_controls,
4236 .build_pcms = stac92xx_build_pcms,
4237 .init = stac9872_vaio_init,
4238 .free = stac92xx_free,
4239 .unsol_event = stac9872_vaio_unsol_event,
4241 .resume = stac92xx_resume,
4245 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4247 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4249 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4251 /* AR Series. id=0x83847664 and subsys=104D1300 */
4256 static const char *stac9872_models[STAC_9872_MODELS] = {
4257 [CXD9872RD_VAIO] = "vaio",
4258 [CXD9872AKD_VAIO] = "vaio-ar",
4261 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4262 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4263 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4264 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
4265 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
4269 static int patch_stac9872(struct hda_codec *codec)
4271 struct sigmatel_spec *spec;
4274 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4277 if (board_config < 0)
4278 /* unknown config, let generic-parser do its job... */
4279 return snd_hda_parse_generic_codec(codec);
4281 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4286 switch (board_config) {
4287 case CXD9872RD_VAIO:
4288 case STAC9872AK_VAIO:
4289 case STAC9872K_VAIO:
4290 spec->mixer = vaio_mixer;
4291 spec->init = vaio_init;
4292 spec->multiout.max_channels = 2;
4293 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4294 spec->multiout.dac_nids = vaio_dacs;
4295 spec->multiout.hp_nid = VAIO_HP_DAC;
4296 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4297 spec->adc_nids = vaio_adcs;
4299 spec->input_mux = &vaio_mux;
4300 spec->mux_nids = vaio_mux_nids;
4301 codec->patch_ops = stac9872_vaio_patch_ops;
4304 case CXD9872AKD_VAIO:
4305 spec->mixer = vaio_ar_mixer;
4306 spec->init = vaio_ar_init;
4307 spec->multiout.max_channels = 2;
4308 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4309 spec->multiout.dac_nids = vaio_dacs;
4310 spec->multiout.hp_nid = VAIO_HP_DAC;
4311 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4313 spec->adc_nids = vaio_adcs;
4314 spec->input_mux = &vaio_mux;
4315 spec->mux_nids = vaio_mux_nids;
4316 codec->patch_ops = stac9872_patch_ops;
4327 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4328 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4329 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4330 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4331 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4332 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4333 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4334 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4335 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4336 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4337 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4338 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4339 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4340 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4341 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4342 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4343 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4344 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4345 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4346 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4347 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4348 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4349 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4350 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
4351 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4352 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4353 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4354 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4355 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4356 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4357 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4358 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
4359 /* The following does not take into account .id=0x83847661 when subsys =
4360 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4361 * currently not fully supported.
4363 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4364 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4365 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
4366 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4367 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4368 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4369 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4370 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4371 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4372 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4373 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4374 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4375 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
4376 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4377 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4378 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4379 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4380 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4381 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4382 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4383 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4384 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4385 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4386 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },