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"
38 #define NUM_CONTROL_ALLOC 32
39 #define STAC_PWR_EVENT 0x20
40 #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 */
124 struct sigmatel_spec {
125 struct snd_kcontrol_new *mixers[4];
126 unsigned int num_mixers;
129 unsigned int surr_switch: 1;
130 unsigned int line_switch: 1;
131 unsigned int mic_switch: 1;
132 unsigned int alt_switch: 1;
133 unsigned int hp_detect: 1;
136 unsigned int eapd_mask;
137 unsigned int gpio_mask;
138 unsigned int gpio_dir;
139 unsigned int gpio_data;
140 unsigned int gpio_mute;
142 /* analog loopback */
143 unsigned char aloopback_mask;
144 unsigned char aloopback_shift;
146 /* power management */
147 unsigned int num_pwrs;
152 struct hda_input_mux *mono_mux;
153 unsigned int cur_mmux;
154 struct hda_multi_out multiout;
155 hda_nid_t dac_nids[5];
159 unsigned int num_adcs;
161 unsigned int num_muxes;
162 hda_nid_t *dmic_nids;
163 unsigned int num_dmics;
164 hda_nid_t *dmux_nids;
165 unsigned int num_dmuxes;
166 hda_nid_t dig_in_nid;
168 hda_nid_t anabeep_nid;
169 hda_nid_t digbeep_nid;
173 unsigned int num_pins;
174 unsigned int *pin_configs;
175 unsigned int *bios_pin_configs;
177 /* codec specific stuff */
178 struct hda_verb *init;
179 struct snd_kcontrol_new *mixer;
182 struct hda_input_mux *dinput_mux;
183 unsigned int cur_dmux[2];
184 struct hda_input_mux *input_mux;
185 unsigned int cur_mux[3];
188 unsigned int io_switch[2];
189 unsigned int clfe_swap;
190 unsigned int hp_switch;
191 unsigned int aloopback;
193 struct hda_pcm pcm_rec[2]; /* PCM information */
195 /* dynamic controls and input_mux */
196 struct auto_pin_cfg autocfg;
197 unsigned int num_kctl_alloc, num_kctl_used;
198 struct snd_kcontrol_new *kctl_alloc;
199 struct hda_input_mux private_dimux;
200 struct hda_input_mux private_imux;
201 struct hda_input_mux private_mono_mux;
204 static hda_nid_t stac9200_adc_nids[1] = {
208 static hda_nid_t stac9200_mux_nids[1] = {
212 static hda_nid_t stac9200_dac_nids[1] = {
216 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
217 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
221 static hda_nid_t stac92hd73xx_adc_nids[2] = {
225 #define STAC92HD73XX_NUM_DMICS 2
226 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
230 #define STAC92HD73_DAC_COUNT 5
231 static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = {
232 0x15, 0x16, 0x17, 0x18, 0x19,
235 static hda_nid_t stac92hd73xx_mux_nids[4] = {
236 0x28, 0x29, 0x2a, 0x2b,
239 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
243 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
247 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
251 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
255 static hda_nid_t stac92hd71bxx_dmux_nids[1] = {
259 static hda_nid_t stac92hd71bxx_dac_nids[1] = {
263 #define STAC92HD71BXX_NUM_DMICS 2
264 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
268 static hda_nid_t stac925x_adc_nids[1] = {
272 static hda_nid_t stac925x_mux_nids[1] = {
276 static hda_nid_t stac925x_dac_nids[1] = {
280 #define STAC925X_NUM_DMICS 1
281 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
285 static hda_nid_t stac925x_dmux_nids[1] = {
289 static hda_nid_t stac922x_adc_nids[2] = {
293 static hda_nid_t stac922x_mux_nids[2] = {
297 static hda_nid_t stac927x_adc_nids[3] = {
301 static hda_nid_t stac927x_mux_nids[3] = {
305 static hda_nid_t stac927x_dac_nids[6] = {
306 0x02, 0x03, 0x04, 0x05, 0x06, 0
309 static hda_nid_t stac927x_dmux_nids[1] = {
313 #define STAC927X_NUM_DMICS 2
314 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
318 static hda_nid_t stac9205_adc_nids[2] = {
322 static hda_nid_t stac9205_mux_nids[2] = {
326 static hda_nid_t stac9205_dmux_nids[1] = {
330 #define STAC9205_NUM_DMICS 2
331 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
335 static hda_nid_t stac9200_pin_nids[8] = {
336 0x08, 0x09, 0x0d, 0x0e,
337 0x0f, 0x10, 0x11, 0x12,
340 static hda_nid_t stac925x_pin_nids[8] = {
341 0x07, 0x08, 0x0a, 0x0b,
342 0x0c, 0x0d, 0x10, 0x11,
345 static hda_nid_t stac922x_pin_nids[10] = {
346 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
347 0x0f, 0x10, 0x11, 0x15, 0x1b,
350 static hda_nid_t stac92hd73xx_pin_nids[13] = {
351 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
352 0x0f, 0x10, 0x11, 0x12, 0x13,
356 static hda_nid_t stac92hd71bxx_pin_nids[10] = {
357 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
358 0x0f, 0x14, 0x18, 0x19, 0x1e,
361 static hda_nid_t stac927x_pin_nids[14] = {
362 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
363 0x0f, 0x10, 0x11, 0x12, 0x13,
364 0x14, 0x21, 0x22, 0x23,
367 static hda_nid_t stac9205_pin_nids[12] = {
368 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
369 0x0f, 0x14, 0x16, 0x17, 0x18,
373 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_info *uinfo)
376 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
377 struct sigmatel_spec *spec = codec->spec;
378 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
381 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
382 struct snd_ctl_elem_value *ucontrol)
384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
385 struct sigmatel_spec *spec = codec->spec;
386 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
388 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
392 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
393 struct snd_ctl_elem_value *ucontrol)
395 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
396 struct sigmatel_spec *spec = codec->spec;
397 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
399 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
400 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
403 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
405 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
406 struct sigmatel_spec *spec = codec->spec;
407 return snd_hda_input_mux_info(spec->input_mux, uinfo);
410 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
412 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
413 struct sigmatel_spec *spec = codec->spec;
414 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
416 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
420 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
423 struct sigmatel_spec *spec = codec->spec;
424 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
426 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
427 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
430 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
431 struct snd_ctl_elem_info *uinfo)
433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
434 struct sigmatel_spec *spec = codec->spec;
435 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
438 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
439 struct snd_ctl_elem_value *ucontrol)
441 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
442 struct sigmatel_spec *spec = codec->spec;
444 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
448 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
449 struct snd_ctl_elem_value *ucontrol)
451 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
452 struct sigmatel_spec *spec = codec->spec;
454 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
455 spec->mono_nid, &spec->cur_mmux);
458 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
460 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
461 struct snd_ctl_elem_value *ucontrol)
463 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
464 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
465 struct sigmatel_spec *spec = codec->spec;
467 ucontrol->value.integer.value[0] = !!(spec->aloopback &
468 (spec->aloopback_mask << idx));
472 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
473 struct snd_ctl_elem_value *ucontrol)
475 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
476 struct sigmatel_spec *spec = codec->spec;
477 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
478 unsigned int dac_mode;
479 unsigned int val, idx_val;
481 idx_val = spec->aloopback_mask << idx;
482 if (ucontrol->value.integer.value[0])
483 val = spec->aloopback | idx_val;
485 val = spec->aloopback & ~idx_val;
486 if (spec->aloopback == val)
489 spec->aloopback = val;
491 /* Only return the bits defined by the shift value of the
492 * first two bytes of the mask
494 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
495 kcontrol->private_value & 0xFFFF, 0x0);
496 dac_mode >>= spec->aloopback_shift;
498 if (spec->aloopback & idx_val) {
499 snd_hda_power_up(codec);
502 snd_hda_power_down(codec);
503 dac_mode &= ~idx_val;
506 snd_hda_codec_write_cache(codec, codec->afg, 0,
507 kcontrol->private_value >> 16, dac_mode);
512 static struct hda_verb stac9200_core_init[] = {
513 /* set dac0mux for dac converter */
514 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
518 static struct hda_verb stac9200_eapd_init[] = {
519 /* set dac0mux for dac converter */
520 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
521 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
525 static struct hda_verb stac92hd73xx_6ch_core_init[] = {
526 /* set master volume and direct control */
527 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
528 /* setup audio connections */
529 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
530 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
531 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
532 /* setup adcs to point to mixer */
533 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
534 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
535 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
536 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
537 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
538 /* setup import muxs */
539 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
540 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
541 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
542 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
546 static struct hda_verb dell_eq_core_init[] = {
547 /* set master volume to max value without distortion
548 * and direct control */
549 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
550 /* setup audio connections */
551 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
552 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
553 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
554 /* setup adcs to point to mixer */
555 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
556 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
557 /* setup import muxs */
558 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
559 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
560 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
561 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
565 static struct hda_verb dell_m6_core_init[] = {
566 /* set master volume to max value without distortion
567 * and direct control */
568 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
569 /* setup audio connections */
570 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
571 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
572 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02},
573 /* setup adcs to point to mixer */
574 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
575 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
576 /* setup import muxs */
577 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
578 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
579 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
580 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
584 static struct hda_verb stac92hd73xx_8ch_core_init[] = {
585 /* set master volume and direct control */
586 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
587 /* setup audio connections */
588 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00},
589 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01},
590 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02},
591 /* connect hp ports to dac3 */
592 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03},
593 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03},
594 /* setup adcs to point to mixer */
595 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
596 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
597 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
598 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
599 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
600 /* setup import muxs */
601 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
602 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
603 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
604 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
608 static struct hda_verb stac92hd73xx_10ch_core_init[] = {
609 /* set master volume and direct control */
610 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
611 /* setup audio connections */
612 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
613 { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 },
614 { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 },
615 /* dac3 is connected to import3 mux */
616 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
617 /* connect hp ports to dac4 */
618 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04},
619 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04},
620 /* setup adcs to point to mixer */
621 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
622 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
623 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
624 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
625 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
626 /* setup import muxs */
627 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
628 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
629 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
630 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
634 static struct hda_verb stac92hd71bxx_core_init[] = {
635 /* set master volume and direct control */
636 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
637 /* connect headphone jack to dac1 */
638 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
639 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
640 /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */
641 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
642 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
643 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
646 #define HD_DISABLE_PORTF 3
647 static struct hda_verb stac92hd71bxx_analog_core_init[] = {
648 /* start of config #1 */
650 /* connect port 0f to audio mixer */
651 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
652 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Speaker */
653 /* unmute right and left channels for node 0x0f */
654 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
655 /* start of config #2 */
657 /* set master volume and direct control */
658 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
659 /* connect headphone jack to dac1 */
660 { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01},
661 /* connect port 0d to audio mixer */
662 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x2},
663 /* unmute dac0 input in audio mixer */
664 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
665 /* unmute right and left channels for nodes 0x0a, 0xd */
666 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
667 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
671 static struct hda_verb stac925x_core_init[] = {
672 /* set dac0mux for dac converter */
673 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
677 static struct hda_verb stac922x_core_init[] = {
678 /* set master volume and direct control */
679 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
683 static struct hda_verb d965_core_init[] = {
684 /* set master volume and direct control */
685 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
686 /* unmute node 0x1b */
687 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
688 /* select node 0x03 as DAC */
689 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
693 static struct hda_verb stac927x_core_init[] = {
694 /* set master volume and direct control */
695 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
696 /* enable analog pc beep path */
697 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
701 static struct hda_verb stac9205_core_init[] = {
702 /* set master volume and direct control */
703 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
707 #define STAC_MONO_MUX \
709 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
710 .name = "Mono Mux", \
712 .info = stac92xx_mono_mux_enum_info, \
713 .get = stac92xx_mono_mux_enum_get, \
714 .put = stac92xx_mono_mux_enum_put, \
717 #define STAC_INPUT_SOURCE(cnt) \
719 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
720 .name = "Input Source", \
722 .info = stac92xx_mux_enum_info, \
723 .get = stac92xx_mux_enum_get, \
724 .put = stac92xx_mux_enum_put, \
727 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
729 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
730 .name = "Analog Loopback", \
732 .info = stac92xx_aloopback_info, \
733 .get = stac92xx_aloopback_get, \
734 .put = stac92xx_aloopback_put, \
735 .private_value = verb_read | (verb_write << 16), \
738 static struct snd_kcontrol_new stac9200_mixer[] = {
739 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
740 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
741 STAC_INPUT_SOURCE(1),
742 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
743 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
744 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
748 static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
749 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
751 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
752 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
754 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
755 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
757 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
758 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
760 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
761 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
763 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
764 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
766 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
767 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
769 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
770 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
774 static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
775 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
777 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
778 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
780 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
781 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
783 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
784 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
786 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
787 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
789 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
790 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
792 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
793 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
795 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
796 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
800 static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
801 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
803 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
804 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
806 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
807 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
809 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
810 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
812 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
813 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
815 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
816 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
818 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
819 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
821 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
822 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
826 static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
827 STAC_INPUT_SOURCE(2),
829 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
830 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
831 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
833 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
834 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
835 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
837 /* analog pc-beep replaced with digital beep support */
839 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
840 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
843 HDA_CODEC_MUTE("Analog Loopback 1", 0x17, 0x3, HDA_INPUT),
844 HDA_CODEC_MUTE("Analog Loopback 2", 0x17, 0x4, HDA_INPUT),
848 static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
849 STAC_INPUT_SOURCE(2),
850 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2),
852 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
853 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
854 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x0, 0x1a, 0x0, HDA_OUTPUT),
856 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
857 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
858 HDA_CODEC_VOLUME_IDX("Capture Mux Volume", 0x1, 0x1b, 0x0, HDA_OUTPUT),
862 static struct snd_kcontrol_new stac925x_mixer[] = {
863 STAC_INPUT_SOURCE(1),
864 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
865 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
866 HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
870 static struct snd_kcontrol_new stac9205_mixer[] = {
871 STAC_INPUT_SOURCE(2),
872 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
874 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
875 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
876 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x19, 0x0, HDA_OUTPUT),
878 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
879 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
880 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x1A, 0x0, HDA_OUTPUT),
885 /* This needs to be generated dynamically based on sequence */
886 static struct snd_kcontrol_new stac922x_mixer[] = {
887 STAC_INPUT_SOURCE(2),
888 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
889 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
890 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x12, 0x0, HDA_OUTPUT),
892 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
893 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
894 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x13, 0x0, HDA_OUTPUT),
899 static struct snd_kcontrol_new stac927x_mixer[] = {
900 STAC_INPUT_SOURCE(3),
901 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
903 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
904 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
905 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x0, 0x15, 0x0, HDA_OUTPUT),
907 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
908 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
909 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x1, 0x16, 0x0, HDA_OUTPUT),
911 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
912 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
913 HDA_CODEC_VOLUME_IDX("Mux Capture Volume", 0x2, 0x17, 0x0, HDA_OUTPUT),
917 static struct snd_kcontrol_new stac_dmux_mixer = {
918 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
919 .name = "Digital Input Source",
920 /* count set later */
921 .info = stac92xx_dmux_enum_info,
922 .get = stac92xx_dmux_enum_get,
923 .put = stac92xx_dmux_enum_put,
926 static const char *slave_vols[] = {
927 "Front Playback Volume",
928 "Surround Playback Volume",
929 "Center Playback Volume",
930 "LFE Playback Volume",
931 "Side Playback Volume",
932 "Headphone Playback Volume",
933 "Headphone Playback Volume",
934 "Speaker Playback Volume",
935 "External Speaker Playback Volume",
936 "Speaker2 Playback Volume",
940 static const char *slave_sws[] = {
941 "Front Playback Switch",
942 "Surround Playback Switch",
943 "Center Playback Switch",
944 "LFE Playback Switch",
945 "Side Playback Switch",
946 "Headphone Playback Switch",
947 "Headphone Playback Switch",
948 "Speaker Playback Switch",
949 "External Speaker Playback Switch",
950 "Speaker2 Playback Switch",
951 "IEC958 Playback Switch",
955 static int stac92xx_build_controls(struct hda_codec *codec)
957 struct sigmatel_spec *spec = codec->spec;
961 err = snd_hda_add_new_ctls(codec, spec->mixer);
965 for (i = 0; i < spec->num_mixers; i++) {
966 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
970 if (spec->num_dmuxes > 0) {
971 stac_dmux_mixer.count = spec->num_dmuxes;
972 err = snd_ctl_add(codec->bus->card,
973 snd_ctl_new1(&stac_dmux_mixer, codec));
978 if (spec->multiout.dig_out_nid) {
979 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
982 err = snd_hda_create_spdif_share_sw(codec,
986 spec->multiout.share_spdif = 1;
988 if (spec->dig_in_nid) {
989 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
994 /* if we have no master control, let's create it */
995 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
996 unsigned int vmaster_tlv[4];
997 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
998 HDA_OUTPUT, vmaster_tlv);
999 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1000 vmaster_tlv, slave_vols);
1004 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1005 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1014 static unsigned int ref9200_pin_configs[8] = {
1015 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1016 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1020 STAC 9200 pin configs for
1025 static unsigned int dell9200_d21_pin_configs[8] = {
1026 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1027 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1031 STAC 9200 pin configs for
1035 static unsigned int dell9200_d22_pin_configs[8] = {
1036 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1037 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1041 STAC 9200 pin configs for
1042 102801C4 (Dell Dimension E310)
1049 static unsigned int dell9200_d23_pin_configs[8] = {
1050 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1051 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1056 STAC 9200-32 pin configs for
1057 102801B5 (Dell Inspiron 630m)
1058 102801D8 (Dell Inspiron 640m)
1060 static unsigned int dell9200_m21_pin_configs[8] = {
1061 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1062 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1066 STAC 9200-32 pin configs for
1067 102801C2 (Dell Latitude D620)
1069 102801CC (Dell Latitude D820)
1073 static unsigned int dell9200_m22_pin_configs[8] = {
1074 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1075 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1079 STAC 9200-32 pin configs for
1080 102801CE (Dell XPS M1710)
1081 102801CF (Dell Precision M90)
1083 static unsigned int dell9200_m23_pin_configs[8] = {
1084 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1085 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1089 STAC 9200-32 pin configs for
1092 102801CB (Dell Latitude 120L)
1095 static unsigned int dell9200_m24_pin_configs[8] = {
1096 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1097 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1101 STAC 9200-32 pin configs for
1102 102801BD (Dell Inspiron E1505n)
1106 static unsigned int dell9200_m25_pin_configs[8] = {
1107 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1108 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1112 STAC 9200-32 pin configs for
1113 102801F5 (Dell Inspiron 1501)
1116 static unsigned int dell9200_m26_pin_configs[8] = {
1117 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1118 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1123 102801CD (Dell Inspiron E1705/9400)
1125 static unsigned int dell9200_m27_pin_configs[8] = {
1126 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1127 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1130 static unsigned int oqo9200_pin_configs[8] = {
1131 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1132 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1136 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1137 [STAC_REF] = ref9200_pin_configs,
1138 [STAC_9200_OQO] = oqo9200_pin_configs,
1139 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1140 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1141 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1142 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1143 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1144 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1145 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1146 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1147 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1148 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1149 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1152 static const char *stac9200_models[STAC_9200_MODELS] = {
1154 [STAC_9200_OQO] = "oqo",
1155 [STAC_9200_DELL_D21] = "dell-d21",
1156 [STAC_9200_DELL_D22] = "dell-d22",
1157 [STAC_9200_DELL_D23] = "dell-d23",
1158 [STAC_9200_DELL_M21] = "dell-m21",
1159 [STAC_9200_DELL_M22] = "dell-m22",
1160 [STAC_9200_DELL_M23] = "dell-m23",
1161 [STAC_9200_DELL_M24] = "dell-m24",
1162 [STAC_9200_DELL_M25] = "dell-m25",
1163 [STAC_9200_DELL_M26] = "dell-m26",
1164 [STAC_9200_DELL_M27] = "dell-m27",
1165 [STAC_9200_GATEWAY] = "gateway",
1166 [STAC_9200_PANASONIC] = "panasonic",
1169 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1170 /* SigmaTel reference board */
1171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1172 "DFI LanParty", STAC_REF),
1173 /* Dell laptops have BIOS problem */
1174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1175 "unknown Dell", STAC_9200_DELL_D21),
1176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1177 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1179 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1181 "unknown Dell", STAC_9200_DELL_D22),
1182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1183 "unknown Dell", STAC_9200_DELL_D22),
1184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1185 "Dell Latitude D620", STAC_9200_DELL_M22),
1186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1187 "unknown Dell", STAC_9200_DELL_D23),
1188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1189 "unknown Dell", STAC_9200_DELL_D23),
1190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1191 "unknown Dell", STAC_9200_DELL_M22),
1192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1193 "unknown Dell", STAC_9200_DELL_M24),
1194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1195 "unknown Dell", STAC_9200_DELL_M24),
1196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1197 "Dell Latitude 120L", STAC_9200_DELL_M24),
1198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1199 "Dell Latitude D820", STAC_9200_DELL_M22),
1200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1201 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1203 "Dell XPS M1710", STAC_9200_DELL_M23),
1204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1205 "Dell Precision M90", STAC_9200_DELL_M23),
1206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1207 "unknown Dell", STAC_9200_DELL_M22),
1208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1209 "unknown Dell", STAC_9200_DELL_M22),
1210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1211 "unknown Dell", STAC_9200_DELL_M22),
1212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1213 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1215 "unknown Dell", STAC_9200_DELL_D23),
1216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1217 "unknown Dell", STAC_9200_DELL_D23),
1218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1219 "unknown Dell", STAC_9200_DELL_D21),
1220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1221 "unknown Dell", STAC_9200_DELL_D23),
1222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1223 "unknown Dell", STAC_9200_DELL_D21),
1224 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1225 "unknown Dell", STAC_9200_DELL_M25),
1226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1227 "unknown Dell", STAC_9200_DELL_M25),
1228 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1229 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1230 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1231 "unknown Dell", STAC_9200_DELL_M26),
1233 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1234 /* Gateway machines needs EAPD to be set on resume */
1235 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_GATEWAY),
1236 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*",
1238 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707",
1241 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1245 static unsigned int ref925x_pin_configs[8] = {
1246 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1247 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1250 static unsigned int stac925x_MA6_pin_configs[8] = {
1251 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1252 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
1255 static unsigned int stac925x_PA6_pin_configs[8] = {
1256 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1257 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
1260 static unsigned int stac925xM2_2_pin_configs[8] = {
1261 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
1262 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
1265 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1266 [STAC_REF] = ref925x_pin_configs,
1267 [STAC_M2_2] = stac925xM2_2_pin_configs,
1268 [STAC_MA6] = stac925x_MA6_pin_configs,
1269 [STAC_PA6] = stac925x_PA6_pin_configs,
1272 static const char *stac925x_models[STAC_925x_MODELS] = {
1274 [STAC_M2_2] = "m2-2",
1279 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1280 /* SigmaTel reference board */
1281 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1282 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1283 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
1284 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
1285 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
1286 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
1287 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
1291 static unsigned int ref92hd73xx_pin_configs[13] = {
1292 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1293 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1294 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1298 static unsigned int dell_m6_pin_configs[13] = {
1299 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1300 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1301 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1305 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1306 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1307 [STAC_DELL_M6] = dell_m6_pin_configs,
1310 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1311 [STAC_92HD73XX_REF] = "ref",
1312 [STAC_DELL_M6] = "dell-m6",
1315 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1316 /* SigmaTel reference board */
1317 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1318 "DFI LanParty", STAC_92HD73XX_REF),
1319 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1320 "unknown Dell", STAC_DELL_M6),
1321 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1322 "unknown Dell", STAC_DELL_M6),
1323 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1324 "unknown Dell", STAC_DELL_M6),
1325 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1326 "unknown Dell", STAC_DELL_M6),
1327 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1328 "unknown Dell", STAC_DELL_M6),
1329 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1330 "unknown Dell", STAC_DELL_M6),
1331 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1332 "unknown Dell", STAC_DELL_M6),
1336 static unsigned int ref92hd71bxx_pin_configs[10] = {
1337 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1338 0x0181302e, 0x01114010, 0x01019020, 0x90a000f0,
1339 0x90a000f0, 0x01452050,
1342 static unsigned int dell_m4_1_pin_configs[10] = {
1343 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1344 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1345 0x40f000f0, 0x4f0000f0,
1348 static unsigned int dell_m4_2_pin_configs[10] = {
1349 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1350 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1351 0x40f000f0, 0x044413b0,
1354 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1355 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1356 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1357 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1360 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1361 [STAC_92HD71BXX_REF] = "ref",
1362 [STAC_DELL_M4_1] = "dell-m4-1",
1363 [STAC_DELL_M4_2] = "dell-m4-2",
1366 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1367 /* SigmaTel reference board */
1368 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1369 "DFI LanParty", STAC_92HD71BXX_REF),
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1371 "unknown Dell", STAC_DELL_M4_1),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1373 "unknown Dell", STAC_DELL_M4_1),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1375 "unknown Dell", STAC_DELL_M4_1),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1377 "unknown Dell", STAC_DELL_M4_1),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1379 "unknown Dell", STAC_DELL_M4_1),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1381 "unknown Dell", STAC_DELL_M4_1),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1383 "unknown Dell", STAC_DELL_M4_1),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1385 "unknown Dell", STAC_DELL_M4_2),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1387 "unknown Dell", STAC_DELL_M4_2),
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1389 "unknown Dell", STAC_DELL_M4_2),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1391 "unknown Dell", STAC_DELL_M4_2),
1395 static unsigned int ref922x_pin_configs[10] = {
1396 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1397 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1398 0x40000100, 0x40000100,
1402 STAC 922X pin configs for
1409 static unsigned int dell_922x_d81_pin_configs[10] = {
1410 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1411 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1412 0x01813122, 0x400001f2,
1416 STAC 922X pin configs for
1420 static unsigned int dell_922x_d82_pin_configs[10] = {
1421 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1422 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1423 0x01813122, 0x400001f1,
1427 STAC 922X pin configs for
1430 static unsigned int dell_922x_m81_pin_configs[10] = {
1431 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1432 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1433 0x40C003f1, 0x405003f0,
1437 STAC 9221 A1 pin configs for
1438 102801D7 (Dell XPS M1210)
1440 static unsigned int dell_922x_m82_pin_configs[10] = {
1441 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1442 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1443 0x508003f3, 0x405003f4,
1446 static unsigned int d945gtp3_pin_configs[10] = {
1447 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1448 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1449 0x02a19120, 0x40000100,
1452 static unsigned int d945gtp5_pin_configs[10] = {
1453 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1454 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1455 0x02a19320, 0x40000100,
1458 static unsigned int intel_mac_v1_pin_configs[10] = {
1459 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1460 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1461 0x400000fc, 0x400000fb,
1464 static unsigned int intel_mac_v2_pin_configs[10] = {
1465 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1466 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1467 0x400000fc, 0x400000fb,
1470 static unsigned int intel_mac_v3_pin_configs[10] = {
1471 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1472 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1473 0x400000fc, 0x400000fb,
1476 static unsigned int intel_mac_v4_pin_configs[10] = {
1477 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1478 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1479 0x400000fc, 0x400000fb,
1482 static unsigned int intel_mac_v5_pin_configs[10] = {
1483 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1484 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1485 0x400000fc, 0x400000fb,
1489 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1490 [STAC_D945_REF] = ref922x_pin_configs,
1491 [STAC_D945GTP3] = d945gtp3_pin_configs,
1492 [STAC_D945GTP5] = d945gtp5_pin_configs,
1493 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1494 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1495 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1496 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1497 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1498 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1499 /* for backward compatibility */
1500 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1501 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1502 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1503 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1504 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1505 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1506 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1507 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1508 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1509 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1512 static const char *stac922x_models[STAC_922X_MODELS] = {
1513 [STAC_D945_REF] = "ref",
1514 [STAC_D945GTP5] = "5stack",
1515 [STAC_D945GTP3] = "3stack",
1516 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1517 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1518 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1519 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1520 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1521 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1522 /* for backward compatibility */
1523 [STAC_MACMINI] = "macmini",
1524 [STAC_MACBOOK] = "macbook",
1525 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1526 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1527 [STAC_IMAC_INTEL] = "imac-intel",
1528 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1529 [STAC_922X_DELL_D81] = "dell-d81",
1530 [STAC_922X_DELL_D82] = "dell-d82",
1531 [STAC_922X_DELL_M81] = "dell-m81",
1532 [STAC_922X_DELL_M82] = "dell-m82",
1535 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1536 /* SigmaTel reference board */
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1538 "DFI LanParty", STAC_D945_REF),
1539 /* Intel 945G based systems */
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1541 "Intel D945G", STAC_D945GTP3),
1542 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1543 "Intel D945G", STAC_D945GTP3),
1544 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1545 "Intel D945G", STAC_D945GTP3),
1546 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1547 "Intel D945G", STAC_D945GTP3),
1548 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1549 "Intel D945G", STAC_D945GTP3),
1550 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1551 "Intel D945G", STAC_D945GTP3),
1552 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1553 "Intel D945G", STAC_D945GTP3),
1554 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1555 "Intel D945G", STAC_D945GTP3),
1556 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1557 "Intel D945G", STAC_D945GTP3),
1558 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1559 "Intel D945G", STAC_D945GTP3),
1560 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1561 "Intel D945G", STAC_D945GTP3),
1562 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1563 "Intel D945G", STAC_D945GTP3),
1564 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1565 "Intel D945G", STAC_D945GTP3),
1566 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1567 "Intel D945G", STAC_D945GTP3),
1568 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1569 "Intel D945G", STAC_D945GTP3),
1570 /* Intel D945G 5-stack systems */
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1572 "Intel D945G", STAC_D945GTP5),
1573 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1574 "Intel D945G", STAC_D945GTP5),
1575 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1576 "Intel D945G", STAC_D945GTP5),
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1578 "Intel D945G", STAC_D945GTP5),
1579 /* Intel 945P based systems */
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1581 "Intel D945P", STAC_D945GTP3),
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1583 "Intel D945P", STAC_D945GTP3),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1585 "Intel D945P", STAC_D945GTP3),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1587 "Intel D945P", STAC_D945GTP3),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1589 "Intel D945P", STAC_D945GTP3),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1591 "Intel D945P", STAC_D945GTP5),
1593 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1594 SND_PCI_QUIRK(0x8384, 0x7680,
1595 "Mac", STAC_INTEL_MAC_AUTO),
1597 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1598 "unknown Dell", STAC_922X_DELL_D81),
1599 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1600 "unknown Dell", STAC_922X_DELL_D81),
1601 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1602 "unknown Dell", STAC_922X_DELL_D81),
1603 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1604 "unknown Dell", STAC_922X_DELL_D82),
1605 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1606 "unknown Dell", STAC_922X_DELL_M81),
1607 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1608 "unknown Dell", STAC_922X_DELL_D82),
1609 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1610 "unknown Dell", STAC_922X_DELL_D81),
1611 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
1612 "unknown Dell", STAC_922X_DELL_D81),
1613 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
1614 "Dell XPS M1210", STAC_922X_DELL_M82),
1618 static unsigned int ref927x_pin_configs[14] = {
1619 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1620 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
1621 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
1622 0x01c42190, 0x40000100,
1625 static unsigned int d965_3st_pin_configs[14] = {
1626 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
1627 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
1628 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1629 0x40000100, 0x40000100
1632 static unsigned int d965_5st_pin_configs[14] = {
1633 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
1634 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
1635 0x40000100, 0x40000100, 0x40000100, 0x01442070,
1636 0x40000100, 0x40000100
1639 static unsigned int dell_3st_pin_configs[14] = {
1640 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
1641 0x01111212, 0x01116211, 0x01813050, 0x01112214,
1642 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
1643 0x40c003fc, 0x40000100
1646 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
1647 [STAC_D965_REF] = ref927x_pin_configs,
1648 [STAC_D965_3ST] = d965_3st_pin_configs,
1649 [STAC_D965_5ST] = d965_5st_pin_configs,
1650 [STAC_DELL_3ST] = dell_3st_pin_configs,
1651 [STAC_DELL_BIOS] = NULL,
1654 static const char *stac927x_models[STAC_927X_MODELS] = {
1655 [STAC_D965_REF] = "ref",
1656 [STAC_D965_3ST] = "3stack",
1657 [STAC_D965_5ST] = "5stack",
1658 [STAC_DELL_3ST] = "dell-3stack",
1659 [STAC_DELL_BIOS] = "dell-bios",
1662 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
1663 /* SigmaTel reference board */
1664 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1665 "DFI LanParty", STAC_D965_REF),
1666 /* Intel 946 based systems */
1667 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
1668 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
1669 /* 965 based 3 stack systems */
1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
1671 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
1672 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
1673 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
1674 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
1675 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
1676 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
1677 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
1678 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
1680 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
1682 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
1684 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
1685 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
1686 /* Dell 3 stack systems */
1687 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
1689 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
1691 /* Dell 3 stack systems with verb table in BIOS */
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
1694 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST),
1696 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
1698 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
1700 /* 965 based 5 stack systems */
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
1707 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
1713 static unsigned int ref9205_pin_configs[12] = {
1714 0x40000100, 0x40000100, 0x01016011, 0x01014010,
1715 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
1716 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
1720 STAC 9205 pin configs for
1727 10280228 (Dell Vostro 1500)
1729 static unsigned int dell_9205_m42_pin_configs[12] = {
1730 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
1731 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
1732 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
1736 STAC 9205 pin configs for
1740 102801FF (Dell Precision M4300)
1745 static unsigned int dell_9205_m43_pin_configs[12] = {
1746 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
1747 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
1748 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
1751 static unsigned int dell_9205_m44_pin_configs[12] = {
1752 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
1753 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
1754 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
1757 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
1758 [STAC_9205_REF] = ref9205_pin_configs,
1759 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
1760 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
1761 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
1764 static const char *stac9205_models[STAC_9205_MODELS] = {
1765 [STAC_9205_REF] = "ref",
1766 [STAC_9205_DELL_M42] = "dell-m42",
1767 [STAC_9205_DELL_M43] = "dell-m43",
1768 [STAC_9205_DELL_M44] = "dell-m44",
1771 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
1772 /* SigmaTel reference board */
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1774 "DFI LanParty", STAC_9205_REF),
1775 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
1776 "unknown Dell", STAC_9205_DELL_M42),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
1778 "unknown Dell", STAC_9205_DELL_M42),
1779 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
1780 "Dell Precision", STAC_9205_DELL_M43),
1781 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
1782 "Dell Precision", STAC_9205_DELL_M43),
1783 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
1784 "Dell Precision", STAC_9205_DELL_M43),
1785 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
1786 "unknown Dell", STAC_9205_DELL_M42),
1787 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
1788 "unknown Dell", STAC_9205_DELL_M42),
1789 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
1790 "Dell Precision", STAC_9205_DELL_M43),
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
1792 "Dell Precision M4300", STAC_9205_DELL_M43),
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
1794 "unknown Dell", STAC_9205_DELL_M42),
1795 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
1796 "Dell Precision", STAC_9205_DELL_M43),
1797 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
1798 "Dell Precision", STAC_9205_DELL_M43),
1799 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
1800 "Dell Precision", STAC_9205_DELL_M43),
1801 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
1802 "Dell Inspiron", STAC_9205_DELL_M44),
1803 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
1804 "Dell Vostro 1500", STAC_9205_DELL_M42),
1808 static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
1811 struct sigmatel_spec *spec = codec->spec;
1813 if (! spec->bios_pin_configs) {
1814 spec->bios_pin_configs = kcalloc(spec->num_pins,
1815 sizeof(*spec->bios_pin_configs), GFP_KERNEL);
1816 if (! spec->bios_pin_configs)
1820 for (i = 0; i < spec->num_pins; i++) {
1821 hda_nid_t nid = spec->pin_nids[i];
1822 unsigned int pin_cfg;
1824 pin_cfg = snd_hda_codec_read(codec, nid, 0,
1825 AC_VERB_GET_CONFIG_DEFAULT, 0x00);
1826 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
1828 spec->bios_pin_configs[i] = pin_cfg;
1834 static void stac92xx_set_config_reg(struct hda_codec *codec,
1835 hda_nid_t pin_nid, unsigned int pin_config)
1838 snd_hda_codec_write(codec, pin_nid, 0,
1839 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
1840 pin_config & 0x000000ff);
1841 snd_hda_codec_write(codec, pin_nid, 0,
1842 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
1843 (pin_config & 0x0000ff00) >> 8);
1844 snd_hda_codec_write(codec, pin_nid, 0,
1845 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
1846 (pin_config & 0x00ff0000) >> 16);
1847 snd_hda_codec_write(codec, pin_nid, 0,
1848 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
1850 i = snd_hda_codec_read(codec, pin_nid, 0,
1851 AC_VERB_GET_CONFIG_DEFAULT,
1853 snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n",
1857 static void stac92xx_set_config_regs(struct hda_codec *codec)
1860 struct sigmatel_spec *spec = codec->spec;
1862 if (!spec->pin_configs)
1865 for (i = 0; i < spec->num_pins; i++)
1866 stac92xx_set_config_reg(codec, spec->pin_nids[i],
1867 spec->pin_configs[i]);
1871 * Analog playback callbacks
1873 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
1874 struct hda_codec *codec,
1875 struct snd_pcm_substream *substream)
1877 struct sigmatel_spec *spec = codec->spec;
1878 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
1882 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1883 struct hda_codec *codec,
1884 unsigned int stream_tag,
1885 unsigned int format,
1886 struct snd_pcm_substream *substream)
1888 struct sigmatel_spec *spec = codec->spec;
1889 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
1892 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1893 struct hda_codec *codec,
1894 struct snd_pcm_substream *substream)
1896 struct sigmatel_spec *spec = codec->spec;
1897 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
1901 * Digital playback callbacks
1903 static int stac92xx_dig_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_dig_open(codec, &spec->multiout);
1911 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
1912 struct hda_codec *codec,
1913 struct snd_pcm_substream *substream)
1915 struct sigmatel_spec *spec = codec->spec;
1916 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
1919 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1920 struct hda_codec *codec,
1921 unsigned int stream_tag,
1922 unsigned int format,
1923 struct snd_pcm_substream *substream)
1925 struct sigmatel_spec *spec = codec->spec;
1926 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
1927 stream_tag, format, substream);
1932 * Analog capture callbacks
1934 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
1935 struct hda_codec *codec,
1936 unsigned int stream_tag,
1937 unsigned int format,
1938 struct snd_pcm_substream *substream)
1940 struct sigmatel_spec *spec = codec->spec;
1942 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
1943 stream_tag, 0, format);
1947 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
1948 struct hda_codec *codec,
1949 struct snd_pcm_substream *substream)
1951 struct sigmatel_spec *spec = codec->spec;
1953 snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
1957 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
1961 /* NID is set in stac92xx_build_pcms */
1963 .open = stac92xx_dig_playback_pcm_open,
1964 .close = stac92xx_dig_playback_pcm_close,
1965 .prepare = stac92xx_dig_playback_pcm_prepare
1969 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
1973 /* NID is set in stac92xx_build_pcms */
1976 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
1980 .nid = 0x02, /* NID to query formats and rates */
1982 .open = stac92xx_playback_pcm_open,
1983 .prepare = stac92xx_playback_pcm_prepare,
1984 .cleanup = stac92xx_playback_pcm_cleanup
1988 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
1992 .nid = 0x06, /* NID to query formats and rates */
1994 .open = stac92xx_playback_pcm_open,
1995 .prepare = stac92xx_playback_pcm_prepare,
1996 .cleanup = stac92xx_playback_pcm_cleanup
2000 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2003 /* NID + .substreams is set in stac92xx_build_pcms */
2005 .prepare = stac92xx_capture_pcm_prepare,
2006 .cleanup = stac92xx_capture_pcm_cleanup
2010 static int stac92xx_build_pcms(struct hda_codec *codec)
2012 struct sigmatel_spec *spec = codec->spec;
2013 struct hda_pcm *info = spec->pcm_rec;
2015 codec->num_pcms = 1;
2016 codec->pcm_info = info;
2018 info->name = "STAC92xx Analog";
2019 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2020 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2021 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2022 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2024 if (spec->alt_switch) {
2027 info->name = "STAC92xx Analog Alt";
2028 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2031 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2034 info->name = "STAC92xx Digital";
2035 info->pcm_type = HDA_PCM_TYPE_SPDIF;
2036 if (spec->multiout.dig_out_nid) {
2037 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2038 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2040 if (spec->dig_in_nid) {
2041 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2042 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2049 static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
2051 unsigned int pincap = snd_hda_param_read(codec, nid,
2053 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2054 if (pincap & AC_PINCAP_VREF_100)
2055 return AC_PINCTL_VREF_100;
2056 if (pincap & AC_PINCAP_VREF_80)
2057 return AC_PINCTL_VREF_80;
2058 if (pincap & AC_PINCAP_VREF_50)
2059 return AC_PINCTL_VREF_50;
2060 if (pincap & AC_PINCAP_VREF_GRD)
2061 return AC_PINCTL_VREF_GRD;
2065 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2068 snd_hda_codec_write_cache(codec, nid, 0,
2069 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2072 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2074 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2075 struct snd_ctl_elem_value *ucontrol)
2077 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2078 struct sigmatel_spec *spec = codec->spec;
2080 ucontrol->value.integer.value[0] = spec->hp_switch;
2084 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2085 struct snd_ctl_elem_value *ucontrol)
2087 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2088 struct sigmatel_spec *spec = codec->spec;
2090 spec->hp_switch = ucontrol->value.integer.value[0];
2092 /* check to be sure that the ports are upto date with
2095 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2100 #define stac92xx_io_switch_info snd_ctl_boolean_mono_info
2102 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2104 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2105 struct sigmatel_spec *spec = codec->spec;
2106 int io_idx = kcontrol-> private_value & 0xff;
2108 ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
2112 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2114 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2115 struct sigmatel_spec *spec = codec->spec;
2116 hda_nid_t nid = kcontrol->private_value >> 8;
2117 int io_idx = kcontrol-> private_value & 0xff;
2118 unsigned short val = !!ucontrol->value.integer.value[0];
2120 spec->io_switch[io_idx] = val;
2123 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2125 unsigned int pinctl = AC_PINCTL_IN_EN;
2126 if (io_idx) /* set VREF for mic */
2127 pinctl |= stac92xx_get_vref(codec, nid);
2128 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2131 /* check the auto-mute again: we need to mute/unmute the speaker
2132 * appropriately according to the pin direction
2134 if (spec->hp_detect)
2135 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
2140 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2142 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2143 struct snd_ctl_elem_value *ucontrol)
2145 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2146 struct sigmatel_spec *spec = codec->spec;
2148 ucontrol->value.integer.value[0] = spec->clfe_swap;
2152 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2153 struct snd_ctl_elem_value *ucontrol)
2155 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2156 struct sigmatel_spec *spec = codec->spec;
2157 hda_nid_t nid = kcontrol->private_value & 0xff;
2158 unsigned int val = !!ucontrol->value.integer.value[0];
2160 if (spec->clfe_swap == val)
2163 spec->clfe_swap = val;
2165 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2166 spec->clfe_swap ? 0x4 : 0x0);
2171 #define STAC_CODEC_HP_SWITCH(xname) \
2172 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2175 .info = stac92xx_hp_switch_info, \
2176 .get = stac92xx_hp_switch_get, \
2177 .put = stac92xx_hp_switch_put, \
2180 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2181 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2184 .info = stac92xx_io_switch_info, \
2185 .get = stac92xx_io_switch_get, \
2186 .put = stac92xx_io_switch_put, \
2187 .private_value = xpval, \
2190 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2191 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2194 .info = stac92xx_clfe_switch_info, \
2195 .get = stac92xx_clfe_switch_get, \
2196 .put = stac92xx_clfe_switch_put, \
2197 .private_value = xpval, \
2201 STAC_CTL_WIDGET_VOL,
2202 STAC_CTL_WIDGET_MUTE,
2203 STAC_CTL_WIDGET_MONO_MUX,
2204 STAC_CTL_WIDGET_HP_SWITCH,
2205 STAC_CTL_WIDGET_IO_SWITCH,
2206 STAC_CTL_WIDGET_CLFE_SWITCH
2209 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2210 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2211 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2213 STAC_CODEC_HP_SWITCH(NULL),
2214 STAC_CODEC_IO_SWITCH(NULL, 0),
2215 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2218 /* add dynamic controls */
2219 static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
2221 struct snd_kcontrol_new *knew;
2223 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
2224 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
2226 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
2229 if (spec->kctl_alloc) {
2230 memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
2231 kfree(spec->kctl_alloc);
2233 spec->kctl_alloc = knew;
2234 spec->num_kctl_alloc = num;
2237 knew = &spec->kctl_alloc[spec->num_kctl_used];
2238 *knew = stac92xx_control_templates[type];
2239 knew->name = kstrdup(name, GFP_KERNEL);
2242 knew->private_value = val;
2243 spec->num_kctl_used++;
2247 /* flag inputs as additional dynamic lineouts */
2248 static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
2250 struct sigmatel_spec *spec = codec->spec;
2251 unsigned int wcaps, wtype;
2252 int i, num_dacs = 0;
2254 /* use the wcaps cache to count all DACs available for line-outs */
2255 for (i = 0; i < codec->num_nodes; i++) {
2256 wcaps = codec->wcaps[i];
2257 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2259 if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
2263 snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
2265 switch (cfg->line_outs) {
2267 /* add line-in as side */
2268 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
2269 cfg->line_out_pins[cfg->line_outs] =
2270 cfg->input_pins[AUTO_PIN_LINE];
2271 spec->line_switch = 1;
2276 /* add line-in as clfe and mic as side */
2277 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
2278 cfg->line_out_pins[cfg->line_outs] =
2279 cfg->input_pins[AUTO_PIN_LINE];
2280 spec->line_switch = 1;
2283 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
2284 cfg->line_out_pins[cfg->line_outs] =
2285 cfg->input_pins[AUTO_PIN_MIC];
2286 spec->mic_switch = 1;
2291 /* add line-in as surr and mic as clfe */
2292 if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
2293 cfg->line_out_pins[cfg->line_outs] =
2294 cfg->input_pins[AUTO_PIN_LINE];
2295 spec->line_switch = 1;
2298 if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
2299 cfg->line_out_pins[cfg->line_outs] =
2300 cfg->input_pins[AUTO_PIN_MIC];
2301 spec->mic_switch = 1;
2311 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2315 for (i = 0; i < spec->multiout.num_dacs; i++) {
2316 if (spec->multiout.dac_nids[i] == nid)
2324 * Fill in the dac_nids table from the parsed pin configuration
2325 * This function only works when every pin in line_out_pins[]
2326 * contains atleast one DAC in its connection list. Some 92xx
2327 * codecs are not connected directly to a DAC, such as the 9200
2328 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2330 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
2331 struct auto_pin_cfg *cfg)
2333 struct sigmatel_spec *spec = codec->spec;
2334 int i, j, conn_len = 0;
2335 hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
2336 unsigned int wcaps, wtype;
2338 for (i = 0; i < cfg->line_outs; i++) {
2339 nid = cfg->line_out_pins[i];
2340 conn_len = snd_hda_get_connections(codec, nid, conn,
2341 HDA_MAX_CONNECTIONS);
2342 for (j = 0; j < conn_len; j++) {
2343 wcaps = snd_hda_param_read(codec, conn[j],
2344 AC_PAR_AUDIO_WIDGET_CAP);
2345 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
2346 if (wtype != AC_WID_AUD_OUT ||
2347 (wcaps & AC_WCAP_DIGITAL))
2349 /* conn[j] is a DAC routed to this line-out */
2350 if (!is_in_dac_nids(spec, conn[j]))
2354 if (j == conn_len) {
2355 if (spec->multiout.num_dacs > 0) {
2356 /* we have already working output pins,
2357 * so let's drop the broken ones again
2359 cfg->line_outs = spec->multiout.num_dacs;
2362 /* error out, no available DAC found */
2364 "%s: No available DAC for pin 0x%x\n",
2369 spec->multiout.dac_nids[i] = conn[j];
2370 spec->multiout.num_dacs++;
2372 /* select this DAC in the pin's input mux */
2373 snd_hda_codec_write_cache(codec, nid, 0,
2374 AC_VERB_SET_CONNECT_SEL, j);
2379 snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
2380 spec->multiout.num_dacs,
2381 spec->multiout.dac_nids[0],
2382 spec->multiout.dac_nids[1],
2383 spec->multiout.dac_nids[2],
2384 spec->multiout.dac_nids[3],
2385 spec->multiout.dac_nids[4]);
2389 /* create volume control/switch for the given prefx type */
2390 static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
2395 sprintf(name, "%s Playback Volume", pfx);
2396 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
2397 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2400 sprintf(name, "%s Playback Switch", pfx);
2401 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
2402 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
2408 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
2410 if (!spec->multiout.hp_nid)
2411 spec->multiout.hp_nid = nid;
2412 else if (spec->multiout.num_dacs > 4) {
2413 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
2416 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
2417 spec->multiout.num_dacs++;
2422 static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2424 if (is_in_dac_nids(spec, nid))
2426 if (spec->multiout.hp_nid == nid)
2431 /* add playback controls from the parsed DAC table */
2432 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2433 const struct auto_pin_cfg *cfg)
2435 static const char *chname[4] = {
2436 "Front", "Surround", NULL /*CLFE*/, "Side"
2441 struct sigmatel_spec *spec = codec->spec;
2442 unsigned int wid_caps, pincap;
2445 for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) {
2446 if (!spec->multiout.dac_nids[i])
2449 nid = spec->multiout.dac_nids[i];
2453 err = create_controls(spec, "Center", nid, 1);
2456 err = create_controls(spec, "LFE", nid, 2);
2460 wid_caps = get_wcaps(codec, nid);
2462 if (wid_caps & AC_WCAP_LR_SWAP) {
2463 err = stac92xx_add_control(spec,
2464 STAC_CTL_WIDGET_CLFE_SWITCH,
2465 "Swap Center/LFE Playback Switch", nid);
2472 err = create_controls(spec, chname[i], nid, 3);
2478 if (cfg->hp_outs > 1) {
2479 err = stac92xx_add_control(spec,
2480 STAC_CTL_WIDGET_HP_SWITCH,
2481 "Headphone as Line Out Switch", 0);
2486 if (spec->line_switch) {
2487 nid = cfg->input_pins[AUTO_PIN_LINE];
2488 pincap = snd_hda_param_read(codec, nid,
2490 if (pincap & AC_PINCAP_OUT) {
2491 err = stac92xx_add_control(spec,
2492 STAC_CTL_WIDGET_IO_SWITCH,
2493 "Line In as Output Switch", nid << 8);
2499 if (spec->mic_switch) {
2500 unsigned int def_conf;
2501 unsigned int mic_pin = AUTO_PIN_MIC;
2503 nid = cfg->input_pins[mic_pin];
2504 def_conf = snd_hda_codec_read(codec, nid, 0,
2505 AC_VERB_GET_CONFIG_DEFAULT, 0);
2506 /* some laptops have an internal analog microphone
2507 * which can't be used as a output */
2508 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2509 pincap = snd_hda_param_read(codec, nid,
2511 if (pincap & AC_PINCAP_OUT) {
2512 err = stac92xx_add_control(spec,
2513 STAC_CTL_WIDGET_IO_SWITCH,
2514 "Mic as Output Switch", (nid << 8) | 1);
2515 nid = snd_hda_codec_read(codec, nid, 0,
2516 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2517 if (!check_in_dac_nids(spec, nid))
2518 add_spec_dacs(spec, nid);
2522 } else if (mic_pin == AUTO_PIN_MIC) {
2523 mic_pin = AUTO_PIN_FRONT_MIC;
2531 /* add playback controls for Speaker and HP outputs */
2532 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
2533 struct auto_pin_cfg *cfg)
2535 struct sigmatel_spec *spec = codec->spec;
2537 int i, old_num_dacs, err;
2539 old_num_dacs = spec->multiout.num_dacs;
2540 for (i = 0; i < cfg->hp_outs; i++) {
2541 unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
2542 if (wid_caps & AC_WCAP_UNSOL_CAP)
2543 spec->hp_detect = 1;
2544 nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
2545 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2546 if (check_in_dac_nids(spec, nid))
2550 add_spec_dacs(spec, nid);
2552 for (i = 0; i < cfg->speaker_outs; i++) {
2553 nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
2554 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2555 if (check_in_dac_nids(spec, nid))
2559 add_spec_dacs(spec, nid);
2561 for (i = 0; i < cfg->line_outs; i++) {
2562 nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0,
2563 AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
2564 if (check_in_dac_nids(spec, nid))
2568 add_spec_dacs(spec, nid);
2570 for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
2571 static const char *pfxs[] = {
2572 "Speaker", "External Speaker", "Speaker2",
2574 err = create_controls(spec, pfxs[i - old_num_dacs],
2575 spec->multiout.dac_nids[i], 3);
2579 if (spec->multiout.hp_nid) {
2580 err = create_controls(spec, "Headphone",
2581 spec->multiout.hp_nid, 3);
2589 /* labels for mono mux outputs */
2590 static const char *stac92xx_mono_labels[3] = {
2591 "DAC0", "DAC1", "Mixer"
2594 /* create mono mux for mono out on capable codecs */
2595 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
2597 struct sigmatel_spec *spec = codec->spec;
2598 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
2600 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
2602 num_cons = snd_hda_get_connections(codec,
2605 HDA_MAX_NUM_INPUTS);
2606 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
2609 for (i = 0; i < num_cons; i++) {
2610 mono_mux->items[mono_mux->num_items].label =
2611 stac92xx_mono_labels[i];
2612 mono_mux->items[mono_mux->num_items].index = i;
2613 mono_mux->num_items++;
2616 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
2617 "Mono Mux", spec->mono_nid);
2620 /* create PC beep volume controls */
2621 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
2624 struct sigmatel_spec *spec = codec->spec;
2625 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
2628 /* check for mute support for the the amp */
2629 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2630 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2631 "PC Beep Playback Switch",
2632 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2637 /* check to see if there is volume support for the amp */
2638 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2639 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2640 "PC Beep Playback Volume",
2641 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
2648 /* labels for dmic mux inputs */
2649 static const char *stac92xx_dmic_labels[5] = {
2650 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
2651 "Digital Mic 3", "Digital Mic 4"
2654 /* create playback/capture controls for input pins on dmic capable codecs */
2655 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
2656 const struct auto_pin_cfg *cfg)
2658 struct sigmatel_spec *spec = codec->spec;
2659 struct hda_input_mux *dimux = &spec->private_dimux;
2660 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2664 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
2665 dimux->items[dimux->num_items].index = 0;
2668 for (i = 0; i < spec->num_dmics; i++) {
2673 unsigned int def_conf;
2675 def_conf = snd_hda_codec_read(codec,
2678 AC_VERB_GET_CONFIG_DEFAULT,
2680 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
2683 nid = spec->dmic_nids[i];
2684 num_cons = snd_hda_get_connections(codec,
2687 HDA_MAX_NUM_INPUTS);
2688 for (j = 0; j < num_cons; j++)
2689 if (con_lst[j] == nid) {
2695 wcaps = get_wcaps(codec, nid);
2697 if (wcaps & AC_WCAP_OUT_AMP) {
2698 sprintf(name, "%s Capture Volume",
2699 stac92xx_dmic_labels[dimux->num_items]);
2701 err = stac92xx_add_control(spec,
2702 STAC_CTL_WIDGET_VOL,
2704 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
2709 dimux->items[dimux->num_items].label =
2710 stac92xx_dmic_labels[dimux->num_items];
2711 dimux->items[dimux->num_items].index = index;
2718 /* create playback/capture controls for input pins */
2719 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
2721 struct sigmatel_spec *spec = codec->spec;
2722 struct hda_input_mux *imux = &spec->private_imux;
2723 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
2726 for (i = 0; i < AUTO_PIN_LAST; i++) {
2729 if (!cfg->input_pins[i])
2732 for (j = 0; j < spec->num_muxes; j++) {
2734 num_cons = snd_hda_get_connections(codec,
2737 HDA_MAX_NUM_INPUTS);
2738 for (k = 0; k < num_cons; k++)
2739 if (con_lst[k] == cfg->input_pins[i]) {
2746 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
2747 imux->items[imux->num_items].index = index;
2751 if (imux->num_items) {
2753 * Set the current input for the muxes.
2754 * The STAC9221 has two input muxes with identical source
2755 * NID lists. Hopefully this won't get confused.
2757 for (i = 0; i < spec->num_muxes; i++) {
2758 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
2759 AC_VERB_SET_CONNECT_SEL,
2760 imux->items[0].index);
2767 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
2769 struct sigmatel_spec *spec = codec->spec;
2772 for (i = 0; i < spec->autocfg.line_outs; i++) {
2773 hda_nid_t nid = spec->autocfg.line_out_pins[i];
2774 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2778 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
2780 struct sigmatel_spec *spec = codec->spec;
2783 for (i = 0; i < spec->autocfg.hp_outs; i++) {
2785 pin = spec->autocfg.hp_pins[i];
2786 if (pin) /* connect to front */
2787 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
2789 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
2791 pin = spec->autocfg.speaker_pins[i];
2792 if (pin) /* connect to front */
2793 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
2797 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
2799 struct sigmatel_spec *spec = codec->spec;
2801 int hp_speaker_swap = 0;
2803 if ((err = snd_hda_parse_pin_def_config(codec,
2805 spec->dmic_nids)) < 0)
2807 if (! spec->autocfg.line_outs)
2808 return 0; /* can't find valid pin config */
2810 /* If we have no real line-out pin and multiple hp-outs, HPs should
2811 * be set up as multi-channel outputs.
2813 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
2814 spec->autocfg.hp_outs > 1) {
2815 /* Copy hp_outs to line_outs, backup line_outs in
2816 * speaker_outs so that the following routines can handle
2817 * HP pins as primary outputs.
2819 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
2820 sizeof(spec->autocfg.line_out_pins));
2821 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
2822 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
2823 sizeof(spec->autocfg.hp_pins));
2824 spec->autocfg.line_outs = spec->autocfg.hp_outs;
2825 hp_speaker_swap = 1;
2827 if (spec->autocfg.mono_out_pin) {
2828 int dir = (get_wcaps(codec, spec->autocfg.mono_out_pin)
2829 & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
2830 u32 caps = query_amp_caps(codec,
2831 spec->autocfg.mono_out_pin, dir);
2832 hda_nid_t conn_list[1];
2834 /* get the mixer node and then the mono mux if it exists */
2835 if (snd_hda_get_connections(codec,
2836 spec->autocfg.mono_out_pin, conn_list, 1) &&
2837 snd_hda_get_connections(codec, conn_list[0],
2840 int wcaps = get_wcaps(codec, conn_list[0]);
2841 int wid_type = (wcaps & AC_WCAP_TYPE)
2842 >> AC_WCAP_TYPE_SHIFT;
2843 /* LR swap check, some stac925x have a mux that
2844 * changes the DACs output path instead of the
2847 if (wid_type == AC_WID_AUD_SEL &&
2848 !(wcaps & AC_WCAP_LR_SWAP))
2849 spec->mono_nid = conn_list[0];
2851 /* all mono outs have a least a mute/unmute switch */
2852 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
2853 "Mono Playback Switch",
2854 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2858 /* check to see if there is volume support for the amp */
2859 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
2860 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
2861 "Mono Playback Volume",
2862 HDA_COMPOSE_AMP_VAL(spec->autocfg.mono_out_pin,
2868 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
2872 if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
2874 if (spec->multiout.num_dacs == 0)
2875 if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
2878 err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg);
2883 /* setup analog beep controls */
2884 if (spec->anabeep_nid > 0) {
2885 err = stac92xx_auto_create_beep_ctls(codec,
2891 /* setup digital beep controls and input device */
2892 #ifdef CONFIG_SND_HDA_INPUT_BEEP
2893 if (spec->digbeep_nid > 0) {
2894 hda_nid_t nid = spec->digbeep_nid;
2896 err = stac92xx_auto_create_beep_ctls(codec, nid);
2899 err = snd_hda_attach_beep_device(codec, nid);
2905 if (hp_speaker_swap == 1) {
2906 /* Restore the hp_outs and line_outs */
2907 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
2908 sizeof(spec->autocfg.line_out_pins));
2909 spec->autocfg.hp_outs = spec->autocfg.line_outs;
2910 memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins,
2911 sizeof(spec->autocfg.speaker_pins));
2912 spec->autocfg.line_outs = spec->autocfg.speaker_outs;
2913 memset(spec->autocfg.speaker_pins, 0,
2914 sizeof(spec->autocfg.speaker_pins));
2915 spec->autocfg.speaker_outs = 0;
2918 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
2923 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
2928 if (spec->mono_nid > 0) {
2929 err = stac92xx_auto_create_mono_output_ctls(codec);
2934 if (spec->num_dmics > 0)
2935 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
2936 &spec->autocfg)) < 0)
2939 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
2940 if (spec->multiout.max_channels > 2)
2941 spec->surr_switch = 1;
2943 if (spec->autocfg.dig_out_pin)
2944 spec->multiout.dig_out_nid = dig_out;
2945 if (spec->autocfg.dig_in_pin)
2946 spec->dig_in_nid = dig_in;
2948 if (spec->kctl_alloc)
2949 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
2951 spec->input_mux = &spec->private_imux;
2952 if (!spec->dinput_mux)
2953 spec->dinput_mux = &spec->private_dimux;
2954 spec->mono_mux = &spec->private_mono_mux;
2959 /* add playback controls for HP output */
2960 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
2961 struct auto_pin_cfg *cfg)
2963 struct sigmatel_spec *spec = codec->spec;
2964 hda_nid_t pin = cfg->hp_pins[0];
2965 unsigned int wid_caps;
2970 wid_caps = get_wcaps(codec, pin);
2971 if (wid_caps & AC_WCAP_UNSOL_CAP)
2972 spec->hp_detect = 1;
2977 /* add playback controls for LFE output */
2978 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
2979 struct auto_pin_cfg *cfg)
2981 struct sigmatel_spec *spec = codec->spec;
2983 hda_nid_t lfe_pin = 0x0;
2987 * search speaker outs and line outs for a mono speaker pin
2988 * with an amp. If one is found, add LFE controls
2991 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
2992 hda_nid_t pin = spec->autocfg.speaker_pins[i];
2993 unsigned int wcaps = get_wcaps(codec, pin);
2994 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
2995 if (wcaps == AC_WCAP_OUT_AMP)
2996 /* found a mono speaker with an amp, must be lfe */
3000 /* if speaker_outs is 0, then speakers may be in line_outs */
3001 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3002 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3003 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3004 unsigned int defcfg;
3005 defcfg = snd_hda_codec_read(codec, pin, 0,
3006 AC_VERB_GET_CONFIG_DEFAULT,
3008 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3009 unsigned int wcaps = get_wcaps(codec, pin);
3010 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3011 if (wcaps == AC_WCAP_OUT_AMP)
3012 /* found a mono speaker with an amp,
3020 err = create_controls(spec, "LFE", lfe_pin, 1);
3028 static int stac9200_parse_auto_config(struct hda_codec *codec)
3030 struct sigmatel_spec *spec = codec->spec;
3033 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3036 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3039 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3042 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3045 if (spec->autocfg.dig_out_pin)
3046 spec->multiout.dig_out_nid = 0x05;
3047 if (spec->autocfg.dig_in_pin)
3048 spec->dig_in_nid = 0x04;
3050 if (spec->kctl_alloc)
3051 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3053 spec->input_mux = &spec->private_imux;
3054 spec->dinput_mux = &spec->private_dimux;
3060 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
3061 * funky external mute control using GPIO pins.
3064 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
3065 unsigned int dir_mask, unsigned int data)
3067 unsigned int gpiostate, gpiomask, gpiodir;
3069 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
3070 AC_VERB_GET_GPIO_DATA, 0);
3071 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
3073 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
3074 AC_VERB_GET_GPIO_MASK, 0);
3077 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
3078 AC_VERB_GET_GPIO_DIRECTION, 0);
3079 gpiodir |= dir_mask;
3081 /* Configure GPIOx as CMOS */
3082 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
3084 snd_hda_codec_write(codec, codec->afg, 0,
3085 AC_VERB_SET_GPIO_MASK, gpiomask);
3086 snd_hda_codec_read(codec, codec->afg, 0,
3087 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
3091 snd_hda_codec_read(codec, codec->afg, 0,
3092 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
3095 static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
3098 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
3099 snd_hda_codec_write_cache(codec, nid, 0,
3100 AC_VERB_SET_UNSOLICITED_ENABLE,
3101 (AC_USRSP_EN | event));
3104 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
3107 for (i = 0; i < cfg->hp_outs; i++)
3108 if (cfg->hp_pins[i] == nid)
3109 return 1; /* nid is a HP-Out */
3111 return 0; /* nid is not a HP-Out */
3114 static void stac92xx_power_down(struct hda_codec *codec)
3116 struct sigmatel_spec *spec = codec->spec;
3118 /* power down inactive DACs */
3120 for (dac = spec->dac_list; *dac; dac++)
3121 if (!is_in_dac_nids(spec, *dac) &&
3122 spec->multiout.hp_nid != *dac)
3123 snd_hda_codec_write_cache(codec, *dac, 0,
3124 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
3127 static int stac92xx_init(struct hda_codec *codec)
3129 struct sigmatel_spec *spec = codec->spec;
3130 struct auto_pin_cfg *cfg = &spec->autocfg;
3133 snd_hda_sequence_write(codec, spec->init);
3136 if (spec->hp_detect) {
3137 /* Enable unsolicited responses on the HP widget */
3138 for (i = 0; i < cfg->hp_outs; i++)
3139 enable_pin_detect(codec, cfg->hp_pins[i],
3141 /* force to enable the first line-out; the others are set up
3144 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
3146 stac92xx_auto_init_hp_out(codec);
3147 /* fake event to set up pins */
3148 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3150 stac92xx_auto_init_multi_out(codec);
3151 stac92xx_auto_init_hp_out(codec);
3153 for (i = 0; i < AUTO_PIN_LAST; i++) {
3154 hda_nid_t nid = cfg->input_pins[i];
3156 unsigned int pinctl = AC_PINCTL_IN_EN;
3157 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
3158 pinctl |= stac92xx_get_vref(codec, nid);
3159 stac92xx_auto_set_pinctl(codec, nid, pinctl);
3162 for (i = 0; i < spec->num_dmics; i++)
3163 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
3165 for (i = 0; i < spec->num_pwrs; i++) {
3166 int event = is_nid_hp_pin(cfg, spec->pwr_nids[i])
3167 ? STAC_HP_EVENT : STAC_PWR_EVENT;
3168 int pinctl = snd_hda_codec_read(codec, spec->pwr_nids[i],
3169 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3170 int def_conf = snd_hda_codec_read(codec, spec->pwr_nids[i],
3171 0, AC_VERB_GET_CONFIG_DEFAULT, 0);
3172 def_conf = get_defcfg_connect(def_conf);
3173 /* outputs are only ports capable of power management
3174 * any attempts on powering down a input port cause the
3175 * referenced VREF to act quirky.
3177 if (pinctl & AC_PINCTL_IN_EN)
3179 /* skip any ports that don't have jacks since presence
3180 * detection is useless */
3181 if (def_conf && def_conf != AC_JACK_PORT_FIXED)
3183 enable_pin_detect(codec, spec->pwr_nids[i], event | i);
3184 codec->patch_ops.unsol_event(codec, (event | i) << 26);
3187 stac92xx_power_down(codec);
3188 if (cfg->dig_out_pin)
3189 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
3191 if (cfg->dig_in_pin)
3192 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
3195 stac_gpio_set(codec, spec->gpio_mask,
3196 spec->gpio_dir, spec->gpio_data);
3201 static void stac92xx_free(struct hda_codec *codec)
3203 struct sigmatel_spec *spec = codec->spec;
3209 if (spec->kctl_alloc) {
3210 for (i = 0; i < spec->num_kctl_used; i++)
3211 kfree(spec->kctl_alloc[i].name);
3212 kfree(spec->kctl_alloc);
3215 if (spec->bios_pin_configs)
3216 kfree(spec->bios_pin_configs);
3219 snd_hda_detach_beep_device(codec);
3222 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
3225 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3226 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3228 if (pin_ctl & AC_PINCTL_IN_EN) {
3230 * we need to check the current set-up direction of
3231 * shared input pins since they can be switched via
3232 * "xxx as Output" mixer switch
3234 struct sigmatel_spec *spec = codec->spec;
3235 struct auto_pin_cfg *cfg = &spec->autocfg;
3236 if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
3237 spec->line_switch) ||
3238 (nid == cfg->input_pins[AUTO_PIN_MIC] &&
3243 /* if setting pin direction bits, clear the current
3244 direction bits first */
3245 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
3246 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
3248 snd_hda_codec_write_cache(codec, nid, 0,
3249 AC_VERB_SET_PIN_WIDGET_CONTROL,
3253 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
3256 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
3257 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
3258 snd_hda_codec_write_cache(codec, nid, 0,
3259 AC_VERB_SET_PIN_WIDGET_CONTROL,
3263 static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid)
3267 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
3269 unsigned int pinctl;
3270 pinctl = snd_hda_codec_read(codec, nid, 0,
3271 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3272 if (pinctl & AC_PINCTL_IN_EN)
3273 return 0; /* mic- or line-input */
3275 return 1; /* HP-output */
3280 static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
3282 struct sigmatel_spec *spec = codec->spec;
3283 struct auto_pin_cfg *cfg = &spec->autocfg;
3284 int nid = cfg->hp_pins[cfg->hp_outs - 1];
3288 if (spec->gpio_mute)
3289 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
3290 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
3292 for (i = 0; i < cfg->hp_outs; i++) {
3295 if (spec->hp_switch && cfg->hp_pins[i] == nid)
3297 presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
3301 /* disable lineouts, enable hp */
3302 if (spec->hp_switch)
3303 stac92xx_reset_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3304 for (i = 0; i < cfg->line_outs; i++)
3305 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
3307 for (i = 0; i < cfg->speaker_outs; i++)
3308 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
3310 if (spec->eapd_mask)
3311 stac_gpio_set(codec, spec->gpio_mask,
3312 spec->gpio_dir, spec->gpio_data &
3315 /* enable lineouts, disable hp */
3316 if (spec->hp_switch)
3317 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3318 for (i = 0; i < cfg->line_outs; i++)
3319 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
3321 for (i = 0; i < cfg->speaker_outs; i++)
3322 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
3324 if (spec->eapd_mask)
3325 stac_gpio_set(codec, spec->gpio_mask,
3326 spec->gpio_dir, spec->gpio_data |
3329 if (!spec->hp_switch && cfg->hp_outs > 1 && presence)
3330 stac92xx_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3333 static void stac92xx_pin_sense(struct hda_codec *codec, int idx)
3335 struct sigmatel_spec *spec = codec->spec;
3336 hda_nid_t nid = spec->pwr_nids[idx];
3338 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0)
3340 presence = get_hp_pin_presence(codec, nid);
3348 /* power down unused output ports */
3349 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
3352 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
3354 struct sigmatel_spec *spec = codec->spec;
3355 int idx = res >> 26 & 0x0f;
3357 switch ((res >> 26) & 0x30) {
3359 stac92xx_hp_detect(codec, res);
3361 case STAC_PWR_EVENT:
3362 if (spec->num_pwrs > 0)
3363 stac92xx_pin_sense(codec, idx);
3367 #ifdef SND_HDA_NEEDS_RESUME
3368 static int stac92xx_resume(struct hda_codec *codec)
3370 struct sigmatel_spec *spec = codec->spec;
3372 stac92xx_set_config_regs(codec);
3373 snd_hda_sequence_write(codec, spec->init);
3374 stac_gpio_set(codec, spec->gpio_mask,
3375 spec->gpio_dir, spec->gpio_data);
3376 snd_hda_codec_resume_amp(codec);
3377 snd_hda_codec_resume_cache(codec);
3378 /* power down inactive DACs */
3380 stac92xx_power_down(codec);
3381 /* invoke unsolicited event to reset the HP state */
3382 if (spec->hp_detect)
3383 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
3388 static struct hda_codec_ops stac92xx_patch_ops = {
3389 .build_controls = stac92xx_build_controls,
3390 .build_pcms = stac92xx_build_pcms,
3391 .init = stac92xx_init,
3392 .free = stac92xx_free,
3393 .unsol_event = stac92xx_unsol_event,
3394 #ifdef SND_HDA_NEEDS_RESUME
3395 .resume = stac92xx_resume,
3399 static int patch_stac9200(struct hda_codec *codec)
3401 struct sigmatel_spec *spec;
3404 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3409 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
3410 spec->pin_nids = stac9200_pin_nids;
3411 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
3414 if (spec->board_config < 0) {
3415 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
3416 err = stac92xx_save_bios_config_regs(codec);
3418 stac92xx_free(codec);
3421 spec->pin_configs = spec->bios_pin_configs;
3423 spec->pin_configs = stac9200_brd_tbl[spec->board_config];
3424 stac92xx_set_config_regs(codec);
3427 spec->multiout.max_channels = 2;
3428 spec->multiout.num_dacs = 1;
3429 spec->multiout.dac_nids = stac9200_dac_nids;
3430 spec->adc_nids = stac9200_adc_nids;
3431 spec->mux_nids = stac9200_mux_nids;
3432 spec->num_muxes = 1;
3433 spec->num_dmics = 0;
3437 if (spec->board_config == STAC_9200_GATEWAY ||
3438 spec->board_config == STAC_9200_OQO)
3439 spec->init = stac9200_eapd_init;
3441 spec->init = stac9200_core_init;
3442 spec->mixer = stac9200_mixer;
3444 if (spec->board_config == STAC_9200_PANASONIC) {
3445 spec->gpio_mask = spec->gpio_dir = 0x09;
3446 spec->gpio_data = 0x00;
3449 err = stac9200_parse_auto_config(codec);
3451 stac92xx_free(codec);
3455 codec->patch_ops = stac92xx_patch_ops;
3460 static int patch_stac925x(struct hda_codec *codec)
3462 struct sigmatel_spec *spec;
3465 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3470 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
3471 spec->pin_nids = stac925x_pin_nids;
3472 spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
3476 if (spec->board_config < 0) {
3477 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
3478 "using BIOS defaults\n");
3479 err = stac92xx_save_bios_config_regs(codec);
3481 stac92xx_free(codec);
3484 spec->pin_configs = spec->bios_pin_configs;
3485 } else if (stac925x_brd_tbl[spec->board_config] != NULL){
3486 spec->pin_configs = stac925x_brd_tbl[spec->board_config];
3487 stac92xx_set_config_regs(codec);
3490 spec->multiout.max_channels = 2;
3491 spec->multiout.num_dacs = 1;
3492 spec->multiout.dac_nids = stac925x_dac_nids;
3493 spec->adc_nids = stac925x_adc_nids;
3494 spec->mux_nids = stac925x_mux_nids;
3495 spec->num_muxes = 1;
3498 switch (codec->vendor_id) {
3499 case 0x83847632: /* STAC9202 */
3500 case 0x83847633: /* STAC9202D */
3501 case 0x83847636: /* STAC9251 */
3502 case 0x83847637: /* STAC9251D */
3503 spec->num_dmics = STAC925X_NUM_DMICS;
3504 spec->dmic_nids = stac925x_dmic_nids;
3505 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
3506 spec->dmux_nids = stac925x_dmux_nids;
3509 spec->num_dmics = 0;
3513 spec->init = stac925x_core_init;
3514 spec->mixer = stac925x_mixer;
3516 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
3518 if (spec->board_config < 0) {
3519 printk(KERN_WARNING "hda_codec: No auto-config is "
3520 "available, default to model=ref\n");
3521 spec->board_config = STAC_925x_REF;
3527 stac92xx_free(codec);
3531 codec->patch_ops = stac92xx_patch_ops;
3536 static struct hda_input_mux stac92hd73xx_dmux = {
3539 { "Analog Inputs", 0x0b },
3541 { "Digital Mic 1", 0x09 },
3542 { "Digital Mic 2", 0x0a },
3546 static int patch_stac92hd73xx(struct hda_codec *codec)
3548 struct sigmatel_spec *spec;
3549 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
3552 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3557 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
3558 spec->pin_nids = stac92hd73xx_pin_nids;
3559 spec->board_config = snd_hda_check_board_config(codec,
3560 STAC_92HD73XX_MODELS,
3561 stac92hd73xx_models,
3562 stac92hd73xx_cfg_tbl);
3564 if (spec->board_config < 0) {
3565 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3566 " STAC92HD73XX, using BIOS defaults\n");
3567 err = stac92xx_save_bios_config_regs(codec);
3569 stac92xx_free(codec);
3572 spec->pin_configs = spec->bios_pin_configs;
3574 spec->pin_configs = stac92hd73xx_brd_tbl[spec->board_config];
3575 stac92xx_set_config_regs(codec);
3578 spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a,
3579 conn, STAC92HD73_DAC_COUNT + 2) - 1;
3581 if (spec->multiout.num_dacs < 0) {
3582 printk(KERN_WARNING "hda_codec: Could not determine "
3583 "number of channels defaulting to DAC count\n");
3584 spec->multiout.num_dacs = STAC92HD73_DAC_COUNT;
3587 switch (spec->multiout.num_dacs) {
3588 case 0x3: /* 6 Channel */
3589 spec->multiout.hp_nid = 0x17;
3590 spec->mixer = stac92hd73xx_6ch_mixer;
3591 spec->init = stac92hd73xx_6ch_core_init;
3593 case 0x4: /* 8 Channel */
3594 spec->multiout.hp_nid = 0x18;
3595 spec->mixer = stac92hd73xx_8ch_mixer;
3596 spec->init = stac92hd73xx_8ch_core_init;
3598 case 0x5: /* 10 Channel */
3599 spec->multiout.hp_nid = 0x19;
3600 spec->mixer = stac92hd73xx_10ch_mixer;
3601 spec->init = stac92hd73xx_10ch_core_init;
3604 spec->multiout.dac_nids = stac92hd73xx_dac_nids;
3605 spec->aloopback_mask = 0x01;
3606 spec->aloopback_shift = 8;
3608 spec->digbeep_nid = 0x1c;
3609 spec->mux_nids = stac92hd73xx_mux_nids;
3610 spec->adc_nids = stac92hd73xx_adc_nids;
3611 spec->dmic_nids = stac92hd73xx_dmic_nids;
3612 spec->dmux_nids = stac92hd73xx_dmux_nids;
3614 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
3615 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
3616 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
3617 spec->dinput_mux = &stac92hd73xx_dmux;
3618 /* GPIO0 High = Enable EAPD */
3619 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3620 spec->gpio_data = 0x01;
3622 switch (spec->board_config) {
3624 spec->init = dell_eq_core_init;
3625 switch (codec->subsystem_id) {
3626 case 0x1028025e: /* Analog Mics */
3628 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3629 spec->num_dmics = 0;
3631 case 0x10280271: /* Digital Mics */
3633 spec->init = dell_m6_core_init;
3637 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3638 spec->num_dmics = 1;
3640 case 0x10280256: /* Both */
3642 stac92xx_set_config_reg(codec, 0x0b, 0x90A70170);
3643 stac92xx_set_config_reg(codec, 0x13, 0x90A60160);
3644 spec->num_dmics = 1;
3649 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
3652 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
3653 spec->pwr_nids = stac92hd73xx_pwr_nids;
3655 err = stac92xx_parse_auto_config(codec, 0x22, 0x24);
3658 if (spec->board_config < 0) {
3659 printk(KERN_WARNING "hda_codec: No auto-config is "
3660 "available, default to model=ref\n");
3661 spec->board_config = STAC_92HD73XX_REF;
3668 stac92xx_free(codec);
3672 codec->patch_ops = stac92xx_patch_ops;
3677 static int patch_stac92hd71bxx(struct hda_codec *codec)
3679 struct sigmatel_spec *spec;
3682 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3687 spec->num_pins = ARRAY_SIZE(stac92hd71bxx_pin_nids);
3688 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
3689 spec->pin_nids = stac92hd71bxx_pin_nids;
3690 spec->board_config = snd_hda_check_board_config(codec,
3691 STAC_92HD71BXX_MODELS,
3692 stac92hd71bxx_models,
3693 stac92hd71bxx_cfg_tbl);
3695 if (spec->board_config < 0) {
3696 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3697 " STAC92HD71BXX, using BIOS defaults\n");
3698 err = stac92xx_save_bios_config_regs(codec);
3700 stac92xx_free(codec);
3703 spec->pin_configs = spec->bios_pin_configs;
3705 spec->pin_configs = stac92hd71bxx_brd_tbl[spec->board_config];
3706 stac92xx_set_config_regs(codec);
3709 switch (codec->vendor_id) {
3710 case 0x111d76b6: /* 4 Port without Analog Mixer */
3712 case 0x111d76b4: /* 6 Port without Analog Mixer */
3714 spec->mixer = stac92hd71bxx_mixer;
3715 spec->init = stac92hd71bxx_core_init;
3717 case 0x111d7608: /* 5 Port with Analog Mixer */
3718 /* no output amps */
3720 spec->mixer = stac92hd71bxx_analog_mixer;
3723 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF];
3724 stac92xx_set_config_reg(codec, 0xf, 0x40f000f0);
3726 case 0x111d7603: /* 6 Port with Analog Mixer */
3727 /* no output amps */
3731 spec->mixer = stac92hd71bxx_analog_mixer;
3732 spec->init = stac92hd71bxx_analog_core_init;
3735 spec->aloopback_mask = 0x20;
3736 spec->aloopback_shift = 0;
3738 /* GPIO0 High = EAPD */
3739 spec->gpio_mask = 0x01;
3740 spec->gpio_dir = 0x01;
3741 spec->gpio_data = 0x01;
3743 spec->digbeep_nid = 0x26;
3744 spec->mux_nids = stac92hd71bxx_mux_nids;
3745 spec->adc_nids = stac92hd71bxx_adc_nids;
3746 spec->dmic_nids = stac92hd71bxx_dmic_nids;
3747 spec->dmux_nids = stac92hd71bxx_dmux_nids;
3748 spec->pwr_nids = stac92hd71bxx_pwr_nids;
3750 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
3751 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
3752 spec->num_dmics = STAC92HD71BXX_NUM_DMICS;
3753 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
3755 spec->multiout.num_dacs = 1;
3756 spec->multiout.hp_nid = 0x11;
3757 spec->multiout.dac_nids = stac92hd71bxx_dac_nids;
3759 err = stac92xx_parse_auto_config(codec, 0x21, 0x23);
3761 if (spec->board_config < 0) {
3762 printk(KERN_WARNING "hda_codec: No auto-config is "
3763 "available, default to model=ref\n");
3764 spec->board_config = STAC_92HD71BXX_REF;
3771 stac92xx_free(codec);
3775 codec->patch_ops = stac92xx_patch_ops;
3780 static int patch_stac922x(struct hda_codec *codec)
3782 struct sigmatel_spec *spec;
3785 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3790 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
3791 spec->pin_nids = stac922x_pin_nids;
3792 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
3795 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
3796 spec->gpio_mask = spec->gpio_dir = 0x03;
3797 spec->gpio_data = 0x03;
3798 /* Intel Macs have all same PCI SSID, so we need to check
3799 * codec SSID to distinguish the exact models
3801 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
3802 switch (codec->subsystem_id) {
3805 spec->board_config = STAC_INTEL_MAC_V1;
3809 spec->board_config = STAC_INTEL_MAC_V2;
3817 spec->board_config = STAC_INTEL_MAC_V3;
3821 spec->board_config = STAC_INTEL_MAC_V4;
3825 spec->board_config = STAC_INTEL_MAC_V5;
3828 spec->board_config = STAC_INTEL_MAC_V3;
3834 if (spec->board_config < 0) {
3835 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
3836 "using BIOS defaults\n");
3837 err = stac92xx_save_bios_config_regs(codec);
3839 stac92xx_free(codec);
3842 spec->pin_configs = spec->bios_pin_configs;
3843 } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
3844 spec->pin_configs = stac922x_brd_tbl[spec->board_config];
3845 stac92xx_set_config_regs(codec);
3848 spec->adc_nids = stac922x_adc_nids;
3849 spec->mux_nids = stac922x_mux_nids;
3850 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
3851 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
3852 spec->num_dmics = 0;
3855 spec->init = stac922x_core_init;
3856 spec->mixer = stac922x_mixer;
3858 spec->multiout.dac_nids = spec->dac_nids;
3860 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
3862 if (spec->board_config < 0) {
3863 printk(KERN_WARNING "hda_codec: No auto-config is "
3864 "available, default to model=ref\n");
3865 spec->board_config = STAC_D945_REF;
3871 stac92xx_free(codec);
3875 codec->patch_ops = stac92xx_patch_ops;
3877 /* Fix Mux capture level; max to 2 */
3878 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
3879 (0 << AC_AMPCAP_OFFSET_SHIFT) |
3880 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
3881 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
3882 (0 << AC_AMPCAP_MUTE_SHIFT));
3887 static int patch_stac927x(struct hda_codec *codec)
3889 struct sigmatel_spec *spec;
3892 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
3897 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
3898 spec->pin_nids = stac927x_pin_nids;
3899 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
3903 if (spec->board_config < 0 || !stac927x_brd_tbl[spec->board_config]) {
3904 if (spec->board_config < 0)
3905 snd_printdd(KERN_INFO "hda_codec: Unknown model for"
3906 "STAC927x, using BIOS defaults\n");
3907 err = stac92xx_save_bios_config_regs(codec);
3909 stac92xx_free(codec);
3912 spec->pin_configs = spec->bios_pin_configs;
3914 spec->pin_configs = stac927x_brd_tbl[spec->board_config];
3915 stac92xx_set_config_regs(codec);
3918 spec->digbeep_nid = 0x23;
3919 spec->adc_nids = stac927x_adc_nids;
3920 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
3921 spec->mux_nids = stac927x_mux_nids;
3922 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
3923 spec->dac_list = stac927x_dac_nids;
3924 spec->multiout.dac_nids = spec->dac_nids;
3926 switch (spec->board_config) {
3929 /* GPIO0 High = Enable EAPD */
3930 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
3931 spec->gpio_data = 0x01;
3932 spec->num_dmics = 0;
3934 spec->init = d965_core_init;
3935 spec->mixer = stac927x_mixer;
3937 case STAC_DELL_BIOS:
3938 switch (codec->subsystem_id) {
3941 /* correct the device field to SPDIF out */
3942 stac92xx_set_config_reg(codec, 0x21, 0x01442070);
3945 /* configure the analog microphone on some laptops */
3946 stac92xx_set_config_reg(codec, 0x0c, 0x90a79130);
3947 /* correct the front output jack as a hp out */
3948 stac92xx_set_config_reg(codec, 0x0f, 0x0227011f);
3949 /* correct the front input jack as a mic */
3950 stac92xx_set_config_reg(codec, 0x0e, 0x02a79130);
3953 /* GPIO2 High = Enable EAPD */
3954 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
3955 spec->gpio_data = 0x04;
3956 spec->dmic_nids = stac927x_dmic_nids;
3957 spec->num_dmics = STAC927X_NUM_DMICS;
3959 spec->init = d965_core_init;
3960 spec->mixer = stac927x_mixer;
3961 spec->dmux_nids = stac927x_dmux_nids;
3962 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
3965 /* GPIO0 High = Enable EAPD */
3966 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
3967 spec->gpio_data = 0x01;
3968 spec->num_dmics = 0;
3970 spec->init = stac927x_core_init;
3971 spec->mixer = stac927x_mixer;
3975 spec->aloopback_mask = 0x40;
3976 spec->aloopback_shift = 0;
3978 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
3980 if (spec->board_config < 0) {
3981 printk(KERN_WARNING "hda_codec: No auto-config is "
3982 "available, default to model=ref\n");
3983 spec->board_config = STAC_D965_REF;
3989 stac92xx_free(codec);
3993 codec->patch_ops = stac92xx_patch_ops;
3997 * The STAC927x seem to require fairly long delays for certain
3998 * command sequences. With too short delays (even if the answer
3999 * is set to RIRB properly), it results in the silence output
4000 * on some hardwares like Dell.
4002 * The below flag enables the longer delay (see get_response
4005 codec->bus->needs_damn_long_delay = 1;
4010 static int patch_stac9205(struct hda_codec *codec)
4012 struct sigmatel_spec *spec;
4015 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4020 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
4021 spec->pin_nids = stac9205_pin_nids;
4022 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
4026 if (spec->board_config < 0) {
4027 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
4028 err = stac92xx_save_bios_config_regs(codec);
4030 stac92xx_free(codec);
4033 spec->pin_configs = spec->bios_pin_configs;
4035 spec->pin_configs = stac9205_brd_tbl[spec->board_config];
4036 stac92xx_set_config_regs(codec);
4039 spec->digbeep_nid = 0x23;
4040 spec->adc_nids = stac9205_adc_nids;
4041 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
4042 spec->mux_nids = stac9205_mux_nids;
4043 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
4044 spec->dmic_nids = stac9205_dmic_nids;
4045 spec->num_dmics = STAC9205_NUM_DMICS;
4046 spec->dmux_nids = stac9205_dmux_nids;
4047 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
4050 spec->init = stac9205_core_init;
4051 spec->mixer = stac9205_mixer;
4053 spec->aloopback_mask = 0x40;
4054 spec->aloopback_shift = 0;
4055 spec->multiout.dac_nids = spec->dac_nids;
4057 switch (spec->board_config){
4058 case STAC_9205_DELL_M43:
4059 /* Enable SPDIF in/out */
4060 stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
4061 stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
4063 /* Enable unsol response for GPIO4/Dock HP connection */
4064 snd_hda_codec_write(codec, codec->afg, 0,
4065 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
4066 snd_hda_codec_write_cache(codec, codec->afg, 0,
4067 AC_VERB_SET_UNSOLICITED_ENABLE,
4068 (AC_USRSP_EN | STAC_HP_EVENT));
4070 spec->gpio_dir = 0x0b;
4071 spec->eapd_mask = 0x01;
4072 spec->gpio_mask = 0x1b;
4073 spec->gpio_mute = 0x10;
4074 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
4077 spec->gpio_data = 0x01;
4080 /* GPIO0 High = EAPD */
4081 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
4082 spec->gpio_data = 0x01;
4086 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
4088 if (spec->board_config < 0) {
4089 printk(KERN_WARNING "hda_codec: No auto-config is "
4090 "available, default to model=ref\n");
4091 spec->board_config = STAC_9205_REF;
4097 stac92xx_free(codec);
4101 codec->patch_ops = stac92xx_patch_ops;
4110 /* static config for Sony VAIO FE550G and Sony VAIO AR */
4111 static hda_nid_t vaio_dacs[] = { 0x2 };
4112 #define VAIO_HP_DAC 0x5
4113 static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
4114 static hda_nid_t vaio_mux_nids[] = { 0x15 };
4116 static struct hda_input_mux vaio_mux = {
4119 /* { "HP", 0x0 }, */
4120 { "Mic Jack", 0x1 },
4121 { "Internal Mic", 0x2 },
4126 static struct hda_verb vaio_init[] = {
4127 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4128 {0x0a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | STAC_HP_EVENT},
4129 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4130 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4131 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4132 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4133 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4134 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4135 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4136 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4137 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4138 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4142 static struct hda_verb vaio_ar_init[] = {
4143 {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
4144 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
4145 {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
4146 {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
4147 /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
4148 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
4149 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
4150 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
4151 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
4152 /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
4153 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
4154 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
4155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
4159 /* bind volumes of both NID 0x02 and 0x05 */
4160 static struct hda_bind_ctls vaio_bind_master_vol = {
4161 .ops = &snd_hda_bind_vol,
4163 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4164 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4169 /* bind volumes of both NID 0x02 and 0x05 */
4170 static struct hda_bind_ctls vaio_bind_master_sw = {
4171 .ops = &snd_hda_bind_sw,
4173 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
4174 HDA_COMPOSE_AMP_VAL(0x05, 3, 0, HDA_OUTPUT),
4179 static struct snd_kcontrol_new vaio_mixer[] = {
4180 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4181 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4182 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4183 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4184 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4186 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4187 .name = "Capture Source",
4189 .info = stac92xx_mux_enum_info,
4190 .get = stac92xx_mux_enum_get,
4191 .put = stac92xx_mux_enum_put,
4196 static struct snd_kcontrol_new vaio_ar_mixer[] = {
4197 HDA_BIND_VOL("Master Playback Volume", &vaio_bind_master_vol),
4198 HDA_BIND_SW("Master Playback Switch", &vaio_bind_master_sw),
4199 /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
4200 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
4201 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
4202 /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
4203 HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
4205 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4206 .name = "Capture Source",
4208 .info = stac92xx_mux_enum_info,
4209 .get = stac92xx_mux_enum_get,
4210 .put = stac92xx_mux_enum_put,
4215 static struct hda_codec_ops stac9872_patch_ops = {
4216 .build_controls = stac92xx_build_controls,
4217 .build_pcms = stac92xx_build_pcms,
4218 .init = stac92xx_init,
4219 .free = stac92xx_free,
4220 #ifdef SND_HDA_NEEDS_RESUME
4221 .resume = stac92xx_resume,
4225 static int stac9872_vaio_init(struct hda_codec *codec)
4229 err = stac92xx_init(codec);
4232 if (codec->patch_ops.unsol_event)
4233 codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
4237 static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res)
4239 if (get_hp_pin_presence(codec, 0x0a)) {
4240 stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4241 stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4243 stac92xx_reset_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN);
4244 stac92xx_set_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN);
4248 static void stac9872_vaio_unsol_event(struct hda_codec *codec, unsigned int res)
4250 switch (res >> 26) {
4252 stac9872_vaio_hp_detect(codec, res);
4257 static struct hda_codec_ops stac9872_vaio_patch_ops = {
4258 .build_controls = stac92xx_build_controls,
4259 .build_pcms = stac92xx_build_pcms,
4260 .init = stac9872_vaio_init,
4261 .free = stac92xx_free,
4262 .unsol_event = stac9872_vaio_unsol_event,
4264 .resume = stac92xx_resume,
4268 enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
4270 /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
4272 /* Unknown. id=0x83847661 and subsys=0x104D1200. */
4274 /* AR Series. id=0x83847664 and subsys=104D1300 */
4279 static const char *stac9872_models[STAC_9872_MODELS] = {
4280 [CXD9872RD_VAIO] = "vaio",
4281 [CXD9872AKD_VAIO] = "vaio-ar",
4284 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
4285 SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
4286 SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
4287 SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
4288 SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
4292 static int patch_stac9872(struct hda_codec *codec)
4294 struct sigmatel_spec *spec;
4297 board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
4300 if (board_config < 0)
4301 /* unknown config, let generic-parser do its job... */
4302 return snd_hda_parse_generic_codec(codec);
4304 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4309 switch (board_config) {
4310 case CXD9872RD_VAIO:
4311 case STAC9872AK_VAIO:
4312 case STAC9872K_VAIO:
4313 spec->mixer = vaio_mixer;
4314 spec->init = vaio_init;
4315 spec->multiout.max_channels = 2;
4316 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4317 spec->multiout.dac_nids = vaio_dacs;
4318 spec->multiout.hp_nid = VAIO_HP_DAC;
4319 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4320 spec->adc_nids = vaio_adcs;
4322 spec->input_mux = &vaio_mux;
4323 spec->mux_nids = vaio_mux_nids;
4324 codec->patch_ops = stac9872_vaio_patch_ops;
4327 case CXD9872AKD_VAIO:
4328 spec->mixer = vaio_ar_mixer;
4329 spec->init = vaio_ar_init;
4330 spec->multiout.max_channels = 2;
4331 spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
4332 spec->multiout.dac_nids = vaio_dacs;
4333 spec->multiout.hp_nid = VAIO_HP_DAC;
4334 spec->num_adcs = ARRAY_SIZE(vaio_adcs);
4336 spec->adc_nids = vaio_adcs;
4337 spec->input_mux = &vaio_mux;
4338 spec->mux_nids = vaio_mux_nids;
4339 codec->patch_ops = stac9872_patch_ops;
4350 struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4351 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
4352 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
4353 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
4354 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
4355 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
4356 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
4357 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
4358 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
4359 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
4360 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
4361 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
4362 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
4363 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
4364 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
4365 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
4366 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
4367 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
4368 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
4369 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
4370 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
4371 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
4372 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
4373 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
4374 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
4375 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
4376 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
4377 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4378 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4379 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4380 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4381 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
4382 /* The following does not take into account .id=0x83847661 when subsys =
4383 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4384 * currently not fully supported.
4386 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
4387 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
4388 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
4389 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
4390 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
4391 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
4392 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
4393 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
4394 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
4395 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
4396 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
4397 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
4398 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
4399 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
4400 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
4401 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
4402 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4403 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
4404 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4405 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
4406 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4407 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
4408 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
4409 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },