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 <linux/dmi.h>
32 #include <sound/core.h>
33 #include <sound/asoundef.h>
34 #include <sound/jack.h>
35 #include "hda_codec.h"
36 #include "hda_local.h"
80 STAC_92HD73XX_NO_JD, /* no jack-detection */
94 STAC_92HD83XXX_PWR_REF,
111 STAC_92HD71BXX_MODELS
137 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
138 * is given, one of the above models will be
139 * chosen according to the subsystem id. */
140 /* for backward compatibility */
157 STAC_D965_REF_NO_JD, /* no jack-detection */
174 struct sigmatel_event {
181 struct sigmatel_jack {
184 struct snd_jack *jack;
187 struct sigmatel_mic_route {
190 signed char dmux_idx;
193 struct sigmatel_spec {
194 struct snd_kcontrol_new *mixers[4];
195 unsigned int num_mixers;
198 unsigned int eapd_switch: 1;
199 unsigned int surr_switch: 1;
200 unsigned int alt_switch: 1;
201 unsigned int hp_detect: 1;
202 unsigned int spdif_mute: 1;
203 unsigned int check_volume_offset:1;
204 unsigned int auto_mic:1;
205 unsigned int linear_tone_beep:1;
208 unsigned int eapd_mask;
209 unsigned int gpio_mask;
210 unsigned int gpio_dir;
211 unsigned int gpio_data;
212 unsigned int gpio_mute;
213 unsigned int gpio_led;
214 unsigned int gpio_led_polarity;
217 unsigned int stream_delay;
219 /* analog loopback */
220 struct snd_kcontrol_new *aloopback_ctl;
221 unsigned char aloopback_mask;
222 unsigned char aloopback_shift;
224 /* power management */
225 unsigned int num_pwrs;
226 unsigned int *pwr_mapping;
231 struct snd_array jacks;
234 struct snd_array events;
237 struct hda_input_mux *mono_mux;
238 unsigned int cur_mmux;
239 struct hda_multi_out multiout;
240 hda_nid_t dac_nids[5];
241 hda_nid_t hp_dacs[5];
242 hda_nid_t speaker_dacs[5];
248 unsigned int num_adcs;
250 unsigned int num_muxes;
251 hda_nid_t *dmic_nids;
252 unsigned int num_dmics;
253 hda_nid_t *dmux_nids;
254 unsigned int num_dmuxes;
255 hda_nid_t *smux_nids;
256 unsigned int num_smuxes;
257 unsigned int num_analog_muxes;
259 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
260 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
261 unsigned int num_caps; /* number of capture volume/switch elements */
263 struct sigmatel_mic_route ext_mic;
264 struct sigmatel_mic_route int_mic;
266 const char **spdif_labels;
268 hda_nid_t dig_in_nid;
270 hda_nid_t anabeep_nid;
271 hda_nid_t digbeep_nid;
275 unsigned int num_pins;
277 /* codec specific stuff */
278 struct hda_verb *init;
279 struct snd_kcontrol_new *mixer;
282 struct hda_input_mux *dinput_mux;
283 unsigned int cur_dmux[2];
284 struct hda_input_mux *input_mux;
285 unsigned int cur_mux[3];
286 struct hda_input_mux *sinput_mux;
287 unsigned int cur_smux[2];
288 unsigned int cur_amux;
290 unsigned int powerdown_adcs;
293 unsigned int io_switch[2];
294 unsigned int clfe_swap;
295 hda_nid_t line_switch; /* shared line-in for input and output */
296 hda_nid_t mic_switch; /* shared mic-in for input and output */
297 hda_nid_t hp_switch; /* NID of HP as line-out */
298 unsigned int aloopback;
300 struct hda_pcm pcm_rec[2]; /* PCM information */
302 /* dynamic controls and input_mux */
303 struct auto_pin_cfg autocfg;
304 struct snd_array kctls;
305 struct hda_input_mux private_dimux;
306 struct hda_input_mux private_imux;
307 struct hda_input_mux private_smux;
308 struct hda_input_mux private_mono_mux;
311 static hda_nid_t stac9200_adc_nids[1] = {
315 static hda_nid_t stac9200_mux_nids[1] = {
319 static hda_nid_t stac9200_dac_nids[1] = {
323 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
324 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
328 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
332 static hda_nid_t stac92hd73xx_adc_nids[2] = {
336 #define STAC92HD73XX_NUM_DMICS 2
337 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
341 #define STAC92HD73_DAC_COUNT 5
343 static hda_nid_t stac92hd73xx_mux_nids[2] = {
347 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
351 static hda_nid_t stac92hd73xx_smux_nids[2] = {
355 #define STAC92HD73XX_NUM_CAPS 2
356 static unsigned long stac92hd73xx_capvols[] = {
357 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
358 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
360 #define stac92hd73xx_capsws stac92hd73xx_capvols
362 #define STAC92HD83_DAC_COUNT 3
364 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
368 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
372 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
376 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
380 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
381 0x03, 0x0c, 0x20, 0x40,
384 #define STAC92HD83XXX_NUM_CAPS 2
385 static unsigned long stac92hd83xxx_capvols[] = {
386 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
387 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
389 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
391 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
395 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
399 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
403 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
407 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
411 #define STAC92HD71BXX_NUM_DMICS 2
412 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
416 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
420 #define STAC92HD71BXX_NUM_CAPS 2
421 static unsigned long stac92hd71bxx_capvols[] = {
422 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
423 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
425 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
427 static hda_nid_t stac925x_adc_nids[1] = {
431 static hda_nid_t stac925x_mux_nids[1] = {
435 static hda_nid_t stac925x_dac_nids[1] = {
439 #define STAC925X_NUM_DMICS 1
440 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
444 static hda_nid_t stac925x_dmux_nids[1] = {
448 static unsigned long stac925x_capvols[] = {
449 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
451 static unsigned long stac925x_capsws[] = {
452 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
455 static hda_nid_t stac922x_adc_nids[2] = {
459 static hda_nid_t stac922x_mux_nids[2] = {
463 #define STAC922X_NUM_CAPS 2
464 static unsigned long stac922x_capvols[] = {
465 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
466 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
468 #define stac922x_capsws stac922x_capvols
470 static hda_nid_t stac927x_slave_dig_outs[2] = {
474 static hda_nid_t stac927x_adc_nids[3] = {
478 static hda_nid_t stac927x_mux_nids[3] = {
482 static hda_nid_t stac927x_smux_nids[1] = {
486 static hda_nid_t stac927x_dac_nids[6] = {
487 0x02, 0x03, 0x04, 0x05, 0x06, 0
490 static hda_nid_t stac927x_dmux_nids[1] = {
494 #define STAC927X_NUM_DMICS 2
495 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
499 #define STAC927X_NUM_CAPS 3
500 static unsigned long stac927x_capvols[] = {
501 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
502 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
503 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
505 static unsigned long stac927x_capsws[] = {
506 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
507 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
508 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
511 static const char *stac927x_spdif_labels[5] = {
512 "Digital Playback", "ADAT", "Analog Mux 1",
513 "Analog Mux 2", "Analog Mux 3"
516 static hda_nid_t stac9205_adc_nids[2] = {
520 static hda_nid_t stac9205_mux_nids[2] = {
524 static hda_nid_t stac9205_dmux_nids[1] = {
528 static hda_nid_t stac9205_smux_nids[1] = {
532 #define STAC9205_NUM_DMICS 2
533 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
537 #define STAC9205_NUM_CAPS 2
538 static unsigned long stac9205_capvols[] = {
539 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
540 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
542 static unsigned long stac9205_capsws[] = {
543 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
544 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
547 static hda_nid_t stac9200_pin_nids[8] = {
548 0x08, 0x09, 0x0d, 0x0e,
549 0x0f, 0x10, 0x11, 0x12,
552 static hda_nid_t stac925x_pin_nids[8] = {
553 0x07, 0x08, 0x0a, 0x0b,
554 0x0c, 0x0d, 0x10, 0x11,
557 static hda_nid_t stac922x_pin_nids[10] = {
558 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
559 0x0f, 0x10, 0x11, 0x15, 0x1b,
562 static hda_nid_t stac92hd73xx_pin_nids[13] = {
563 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
564 0x0f, 0x10, 0x11, 0x12, 0x13,
568 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
569 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
570 0x0f, 0x10, 0x11, 0x1f, 0x20,
573 static hda_nid_t stac92hd88xxx_pin_nids[10] = {
574 0x0a, 0x0b, 0x0c, 0x0d,
575 0x0f, 0x11, 0x1f, 0x20,
578 #define STAC92HD71BXX_NUM_PINS 13
579 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
580 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
581 0x00, 0x14, 0x18, 0x19, 0x1e,
584 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
585 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
586 0x0f, 0x14, 0x18, 0x19, 0x1e,
590 static hda_nid_t stac927x_pin_nids[14] = {
591 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
592 0x0f, 0x10, 0x11, 0x12, 0x13,
593 0x14, 0x21, 0x22, 0x23,
596 static hda_nid_t stac9205_pin_nids[12] = {
597 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
598 0x0f, 0x14, 0x16, 0x17, 0x18,
602 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_info *uinfo)
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
610 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
611 struct snd_ctl_elem_value *ucontrol)
613 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
614 struct sigmatel_spec *spec = codec->spec;
615 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
617 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
621 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_value *ucontrol)
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
628 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
629 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
632 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_info *uinfo)
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
640 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
647 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
651 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_value *ucontrol)
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 struct hda_input_mux *smux = &spec->private_smux;
657 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
661 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
662 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
666 if (spec->spdif_mute) {
668 nid = spec->multiout.dig_out_nid;
670 nid = codec->slave_dig_outs[smux_idx - 1];
671 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
675 /* un/mute SPDIF out */
676 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
682 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
683 hda_nid_t nid, unsigned int new_vref)
687 pincfg = snd_hda_codec_read(codec, nid, 0,
688 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
691 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
694 if (new_vref == AC_PINCTL_VREF_HIZ)
695 pincfg |= AC_PINCTL_OUT_EN;
697 pincfg |= AC_PINCTL_IN_EN;
699 error = snd_hda_codec_write_cache(codec, nid, 0,
700 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
707 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
710 vref = snd_hda_codec_read(codec, nid, 0,
711 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
712 vref &= AC_PINCTL_VREFEN;
716 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
718 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
719 struct sigmatel_spec *spec = codec->spec;
720 return snd_hda_input_mux_info(spec->input_mux, uinfo);
723 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
726 struct sigmatel_spec *spec = codec->spec;
727 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
729 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
733 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
735 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
736 struct sigmatel_spec *spec = codec->spec;
737 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
738 const struct hda_input_mux *imux = spec->input_mux;
739 unsigned int idx, prev_idx;
741 idx = ucontrol->value.enumerated.item[0];
742 if (idx >= imux->num_items)
743 idx = imux->num_items - 1;
744 prev_idx = spec->cur_mux[adc_idx];
747 if (idx < spec->num_analog_muxes) {
748 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
749 AC_VERB_SET_CONNECT_SEL,
750 imux->items[idx].index);
751 if (prev_idx >= spec->num_analog_muxes) {
752 imux = spec->dinput_mux;
754 snd_hda_codec_write_cache(codec,
755 spec->dmux_nids[adc_idx], 0,
756 AC_VERB_SET_CONNECT_SEL,
757 imux->items[0].index);
760 imux = spec->dinput_mux;
761 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
762 AC_VERB_SET_CONNECT_SEL,
763 imux->items[idx - 1].index);
765 spec->cur_mux[adc_idx] = idx;
769 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
770 struct snd_ctl_elem_info *uinfo)
772 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
773 struct sigmatel_spec *spec = codec->spec;
774 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
777 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
778 struct snd_ctl_elem_value *ucontrol)
780 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
781 struct sigmatel_spec *spec = codec->spec;
783 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
787 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
788 struct snd_ctl_elem_value *ucontrol)
790 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
791 struct sigmatel_spec *spec = codec->spec;
793 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
794 spec->mono_nid, &spec->cur_mmux);
797 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
799 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
800 struct snd_ctl_elem_value *ucontrol)
802 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
803 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
804 struct sigmatel_spec *spec = codec->spec;
806 ucontrol->value.integer.value[0] = !!(spec->aloopback &
807 (spec->aloopback_mask << idx));
811 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
812 struct snd_ctl_elem_value *ucontrol)
814 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
815 struct sigmatel_spec *spec = codec->spec;
816 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
817 unsigned int dac_mode;
818 unsigned int val, idx_val;
820 idx_val = spec->aloopback_mask << idx;
821 if (ucontrol->value.integer.value[0])
822 val = spec->aloopback | idx_val;
824 val = spec->aloopback & ~idx_val;
825 if (spec->aloopback == val)
828 spec->aloopback = val;
830 /* Only return the bits defined by the shift value of the
831 * first two bytes of the mask
833 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
834 kcontrol->private_value & 0xFFFF, 0x0);
835 dac_mode >>= spec->aloopback_shift;
837 if (spec->aloopback & idx_val) {
838 snd_hda_power_up(codec);
841 snd_hda_power_down(codec);
842 dac_mode &= ~idx_val;
845 snd_hda_codec_write_cache(codec, codec->afg, 0,
846 kcontrol->private_value >> 16, dac_mode);
851 static struct hda_verb stac9200_core_init[] = {
852 /* set dac0mux for dac converter */
853 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
857 static struct hda_verb stac9200_eapd_init[] = {
858 /* set dac0mux for dac converter */
859 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
860 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
864 static struct hda_verb dell_eq_core_init[] = {
865 /* set master volume to max value without distortion
866 * and direct control */
867 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
871 static struct hda_verb stac92hd73xx_core_init[] = {
872 /* set master volume and direct control */
873 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
877 static struct hda_verb stac92hd83xxx_core_init[] = {
878 /* power state controls amps */
879 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
883 static struct hda_verb stac92hd71bxx_core_init[] = {
884 /* set master volume and direct control */
885 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
889 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
890 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
891 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
892 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
893 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
897 static struct hda_verb stac925x_core_init[] = {
898 /* set dac0mux for dac converter */
899 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
900 /* mute the master volume */
901 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
905 static struct hda_verb stac922x_core_init[] = {
906 /* set master volume and direct control */
907 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
911 static struct hda_verb d965_core_init[] = {
912 /* set master volume and direct control */
913 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
914 /* unmute node 0x1b */
915 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
916 /* select node 0x03 as DAC */
917 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
921 static struct hda_verb dell_3st_core_init[] = {
922 /* don't set delta bit */
923 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
924 /* unmute node 0x1b */
925 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
926 /* select node 0x03 as DAC */
927 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
931 static struct hda_verb stac927x_core_init[] = {
932 /* set master volume and direct control */
933 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
934 /* enable analog pc beep path */
935 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
939 static struct hda_verb stac927x_volknob_core_init[] = {
940 /* don't set delta bit */
941 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
942 /* enable analog pc beep path */
943 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
947 static struct hda_verb stac9205_core_init[] = {
948 /* set master volume and direct control */
949 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
950 /* enable analog pc beep path */
951 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
955 #define STAC_MONO_MUX \
957 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
958 .name = "Mono Mux", \
960 .info = stac92xx_mono_mux_enum_info, \
961 .get = stac92xx_mono_mux_enum_get, \
962 .put = stac92xx_mono_mux_enum_put, \
965 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
967 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
968 .name = "Analog Loopback", \
970 .info = stac92xx_aloopback_info, \
971 .get = stac92xx_aloopback_get, \
972 .put = stac92xx_aloopback_put, \
973 .private_value = verb_read | (verb_write << 16), \
976 #define DC_BIAS(xname, idx, nid) \
978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .info = stac92xx_dc_bias_info, \
982 .get = stac92xx_dc_bias_get, \
983 .put = stac92xx_dc_bias_put, \
984 .private_value = nid, \
987 static struct snd_kcontrol_new stac9200_mixer[] = {
988 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
989 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
990 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
991 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
995 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
996 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1000 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1001 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1005 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1006 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1011 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1012 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1015 static struct snd_kcontrol_new stac925x_mixer[] = {
1016 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1017 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1021 static struct snd_kcontrol_new stac9205_loopback[] = {
1022 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1026 static struct snd_kcontrol_new stac927x_loopback[] = {
1027 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1031 static struct snd_kcontrol_new stac_dmux_mixer = {
1032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1033 .name = "Digital Input Source",
1034 /* count set later */
1035 .info = stac92xx_dmux_enum_info,
1036 .get = stac92xx_dmux_enum_get,
1037 .put = stac92xx_dmux_enum_put,
1040 static struct snd_kcontrol_new stac_smux_mixer = {
1041 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1042 .name = "IEC958 Playback Source",
1043 /* count set later */
1044 .info = stac92xx_smux_enum_info,
1045 .get = stac92xx_smux_enum_get,
1046 .put = stac92xx_smux_enum_put,
1049 static const char *slave_vols[] = {
1050 "Front Playback Volume",
1051 "Surround Playback Volume",
1052 "Center Playback Volume",
1053 "LFE Playback Volume",
1054 "Side Playback Volume",
1055 "Headphone Playback Volume",
1056 "Speaker Playback Volume",
1060 static const char *slave_sws[] = {
1061 "Front Playback Switch",
1062 "Surround Playback Switch",
1063 "Center Playback Switch",
1064 "LFE Playback Switch",
1065 "Side Playback Switch",
1066 "Headphone Playback Switch",
1067 "Speaker Playback Switch",
1068 "IEC958 Playback Switch",
1072 static void stac92xx_free_kctls(struct hda_codec *codec);
1073 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1075 static int stac92xx_build_controls(struct hda_codec *codec)
1077 struct sigmatel_spec *spec = codec->spec;
1078 struct auto_pin_cfg *cfg = &spec->autocfg;
1084 err = snd_hda_add_new_ctls(codec, spec->mixer);
1089 for (i = 0; i < spec->num_mixers; i++) {
1090 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1094 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1095 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1096 stac_dmux_mixer.count = spec->num_dmuxes;
1097 err = snd_hda_ctl_add(codec, 0,
1098 snd_ctl_new1(&stac_dmux_mixer, codec));
1102 if (spec->num_smuxes > 0) {
1103 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1104 struct hda_input_mux *smux = &spec->private_smux;
1105 /* check for mute support on SPDIF out */
1106 if (wcaps & AC_WCAP_OUT_AMP) {
1107 smux->items[smux->num_items].label = "Off";
1108 smux->items[smux->num_items].index = 0;
1110 spec->spdif_mute = 1;
1112 stac_smux_mixer.count = spec->num_smuxes;
1113 err = snd_hda_ctl_add(codec, 0,
1114 snd_ctl_new1(&stac_smux_mixer, codec));
1119 if (spec->multiout.dig_out_nid) {
1120 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1123 err = snd_hda_create_spdif_share_sw(codec,
1127 spec->multiout.share_spdif = 1;
1129 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1130 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1135 /* if we have no master control, let's create it */
1136 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1137 unsigned int vmaster_tlv[4];
1138 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1139 HDA_OUTPUT, vmaster_tlv);
1140 /* correct volume offset */
1141 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1142 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1143 vmaster_tlv, slave_vols);
1147 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1148 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1154 if (spec->aloopback_ctl &&
1155 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1156 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1161 stac92xx_free_kctls(codec); /* no longer needed */
1163 /* create jack input elements */
1164 if (spec->hp_detect) {
1165 for (i = 0; i < cfg->hp_outs; i++) {
1166 int type = SND_JACK_HEADPHONE;
1167 nid = cfg->hp_pins[i];
1168 /* jack detection */
1169 if (cfg->hp_outs == i)
1170 type |= SND_JACK_LINEOUT;
1171 err = stac92xx_add_jack(codec, nid, type);
1176 for (i = 0; i < cfg->line_outs; i++) {
1177 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1182 for (i = 0; i < AUTO_PIN_LAST; i++) {
1183 nid = cfg->input_pins[i];
1185 err = stac92xx_add_jack(codec, nid,
1186 SND_JACK_MICROPHONE);
1195 static unsigned int ref9200_pin_configs[8] = {
1196 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1197 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1200 static unsigned int gateway9200_m4_pin_configs[8] = {
1201 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1202 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1204 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1205 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1206 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1210 STAC 9200 pin configs for
1215 static unsigned int dell9200_d21_pin_configs[8] = {
1216 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1217 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1221 STAC 9200 pin configs for
1225 static unsigned int dell9200_d22_pin_configs[8] = {
1226 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1227 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1231 STAC 9200 pin configs for
1232 102801C4 (Dell Dimension E310)
1239 static unsigned int dell9200_d23_pin_configs[8] = {
1240 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1241 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1246 STAC 9200-32 pin configs for
1247 102801B5 (Dell Inspiron 630m)
1248 102801D8 (Dell Inspiron 640m)
1250 static unsigned int dell9200_m21_pin_configs[8] = {
1251 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1252 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1256 STAC 9200-32 pin configs for
1257 102801C2 (Dell Latitude D620)
1259 102801CC (Dell Latitude D820)
1263 static unsigned int dell9200_m22_pin_configs[8] = {
1264 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1265 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1269 STAC 9200-32 pin configs for
1270 102801CE (Dell XPS M1710)
1271 102801CF (Dell Precision M90)
1273 static unsigned int dell9200_m23_pin_configs[8] = {
1274 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1275 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1279 STAC 9200-32 pin configs for
1282 102801CB (Dell Latitude 120L)
1285 static unsigned int dell9200_m24_pin_configs[8] = {
1286 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1287 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1291 STAC 9200-32 pin configs for
1292 102801BD (Dell Inspiron E1505n)
1296 static unsigned int dell9200_m25_pin_configs[8] = {
1297 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1298 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1302 STAC 9200-32 pin configs for
1303 102801F5 (Dell Inspiron 1501)
1306 static unsigned int dell9200_m26_pin_configs[8] = {
1307 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1308 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1313 102801CD (Dell Inspiron E1705/9400)
1315 static unsigned int dell9200_m27_pin_configs[8] = {
1316 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1317 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1320 static unsigned int oqo9200_pin_configs[8] = {
1321 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1322 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1326 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1327 [STAC_REF] = ref9200_pin_configs,
1328 [STAC_9200_OQO] = oqo9200_pin_configs,
1329 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1330 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1331 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1332 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1333 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1334 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1335 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1336 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1337 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1338 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1339 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1340 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1341 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1344 static const char *stac9200_models[STAC_9200_MODELS] = {
1345 [STAC_AUTO] = "auto",
1347 [STAC_9200_OQO] = "oqo",
1348 [STAC_9200_DELL_D21] = "dell-d21",
1349 [STAC_9200_DELL_D22] = "dell-d22",
1350 [STAC_9200_DELL_D23] = "dell-d23",
1351 [STAC_9200_DELL_M21] = "dell-m21",
1352 [STAC_9200_DELL_M22] = "dell-m22",
1353 [STAC_9200_DELL_M23] = "dell-m23",
1354 [STAC_9200_DELL_M24] = "dell-m24",
1355 [STAC_9200_DELL_M25] = "dell-m25",
1356 [STAC_9200_DELL_M26] = "dell-m26",
1357 [STAC_9200_DELL_M27] = "dell-m27",
1358 [STAC_9200_M4] = "gateway-m4",
1359 [STAC_9200_M4_2] = "gateway-m4-2",
1360 [STAC_9200_PANASONIC] = "panasonic",
1363 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1364 /* SigmaTel reference board */
1365 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1366 "DFI LanParty", STAC_REF),
1367 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1368 "DFI LanParty", STAC_REF),
1369 /* Dell laptops have BIOS problem */
1370 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1371 "unknown Dell", STAC_9200_DELL_D21),
1372 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1373 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1374 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1375 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1376 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1377 "unknown Dell", STAC_9200_DELL_D22),
1378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1379 "unknown Dell", STAC_9200_DELL_D22),
1380 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1381 "Dell Latitude D620", STAC_9200_DELL_M22),
1382 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1383 "unknown Dell", STAC_9200_DELL_D23),
1384 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1385 "unknown Dell", STAC_9200_DELL_D23),
1386 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1387 "unknown Dell", STAC_9200_DELL_M22),
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1389 "unknown Dell", STAC_9200_DELL_M24),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1391 "unknown Dell", STAC_9200_DELL_M24),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1393 "Dell Latitude 120L", STAC_9200_DELL_M24),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1395 "Dell Latitude D820", STAC_9200_DELL_M22),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1397 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1399 "Dell XPS M1710", STAC_9200_DELL_M23),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1401 "Dell Precision M90", STAC_9200_DELL_M23),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1403 "unknown Dell", STAC_9200_DELL_M22),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1405 "unknown Dell", STAC_9200_DELL_M22),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1407 "unknown Dell", STAC_9200_DELL_M22),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1409 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1411 "unknown Dell", STAC_9200_DELL_D23),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1413 "unknown Dell", STAC_9200_DELL_D23),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1415 "unknown Dell", STAC_9200_DELL_D21),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1417 "unknown Dell", STAC_9200_DELL_D23),
1418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1419 "unknown Dell", STAC_9200_DELL_D21),
1420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1421 "unknown Dell", STAC_9200_DELL_M25),
1422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1423 "unknown Dell", STAC_9200_DELL_M25),
1424 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1425 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1427 "unknown Dell", STAC_9200_DELL_M26),
1429 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1430 /* Gateway machines needs EAPD to be set on resume */
1431 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1432 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1433 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1435 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1439 static unsigned int ref925x_pin_configs[8] = {
1440 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1441 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1444 static unsigned int stac925xM1_pin_configs[8] = {
1445 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1446 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1449 static unsigned int stac925xM1_2_pin_configs[8] = {
1450 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1451 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1454 static unsigned int stac925xM2_pin_configs[8] = {
1455 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1456 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1459 static unsigned int stac925xM2_2_pin_configs[8] = {
1460 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1461 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1464 static unsigned int stac925xM3_pin_configs[8] = {
1465 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1466 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1469 static unsigned int stac925xM5_pin_configs[8] = {
1470 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1471 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1474 static unsigned int stac925xM6_pin_configs[8] = {
1475 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1476 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1479 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1480 [STAC_REF] = ref925x_pin_configs,
1481 [STAC_M1] = stac925xM1_pin_configs,
1482 [STAC_M1_2] = stac925xM1_2_pin_configs,
1483 [STAC_M2] = stac925xM2_pin_configs,
1484 [STAC_M2_2] = stac925xM2_2_pin_configs,
1485 [STAC_M3] = stac925xM3_pin_configs,
1486 [STAC_M5] = stac925xM5_pin_configs,
1487 [STAC_M6] = stac925xM6_pin_configs,
1490 static const char *stac925x_models[STAC_925x_MODELS] = {
1491 [STAC_925x_AUTO] = "auto",
1494 [STAC_M1_2] = "m1-2",
1496 [STAC_M2_2] = "m2-2",
1502 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1503 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1504 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1505 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1506 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1507 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1508 /* Not sure about the brand name for those */
1509 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1510 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1511 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1512 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1516 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1517 /* SigmaTel reference board */
1518 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1519 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1520 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1522 /* Default table for unknown ID */
1523 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1528 static unsigned int ref92hd73xx_pin_configs[13] = {
1529 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1530 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1531 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1535 static unsigned int dell_m6_pin_configs[13] = {
1536 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1537 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1538 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1542 static unsigned int alienware_m17x_pin_configs[13] = {
1543 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1544 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1545 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1549 static unsigned int intel_dg45id_pin_configs[13] = {
1550 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
1551 0x01A19250, 0x01011212, 0x01016211
1554 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1555 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1556 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1557 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1558 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1559 [STAC_DELL_EQ] = dell_m6_pin_configs,
1560 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1561 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
1564 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1565 [STAC_92HD73XX_AUTO] = "auto",
1566 [STAC_92HD73XX_NO_JD] = "no-jd",
1567 [STAC_92HD73XX_REF] = "ref",
1568 [STAC_92HD73XX_INTEL] = "intel",
1569 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1570 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1571 [STAC_DELL_M6_BOTH] = "dell-m6",
1572 [STAC_DELL_EQ] = "dell-eq",
1573 [STAC_ALIENWARE_M17X] = "alienware",
1576 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1577 /* SigmaTel reference board */
1578 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1579 "DFI LanParty", STAC_92HD73XX_REF),
1580 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1581 "DFI LanParty", STAC_92HD73XX_REF),
1582 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1583 "Intel DG45ID", STAC_92HD73XX_INTEL),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1585 "Intel DG45FC", STAC_92HD73XX_INTEL),
1586 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1587 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1588 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1589 "unknown Dell", STAC_DELL_M6_DMIC),
1590 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1591 "unknown Dell", STAC_DELL_M6_BOTH),
1592 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1593 "unknown Dell", STAC_DELL_M6_BOTH),
1594 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1595 "unknown Dell", STAC_DELL_M6_AMIC),
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1597 "unknown Dell", STAC_DELL_M6_AMIC),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1599 "unknown Dell", STAC_DELL_M6_DMIC),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1601 "unknown Dell", STAC_DELL_M6_DMIC),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1603 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1605 "Dell Studio 17", STAC_DELL_M6_DMIC),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1607 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1609 "Dell Studio 1557", STAC_DELL_M6_DMIC),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1611 "Dell Studio XPS 1645", STAC_DELL_M6_BOTH),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1613 "Dell Studio 1558", STAC_DELL_M6_BOTH),
1617 static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1619 "Alienware M17x", STAC_ALIENWARE_M17X),
1623 static unsigned int ref92hd83xxx_pin_configs[10] = {
1624 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1625 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1626 0x01451160, 0x98560170,
1629 static unsigned int dell_s14_pin_configs[10] = {
1630 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1631 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1632 0x40f000f0, 0x40f000f0,
1635 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1636 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1637 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1638 [STAC_DELL_S14] = dell_s14_pin_configs,
1641 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1642 [STAC_92HD83XXX_AUTO] = "auto",
1643 [STAC_92HD83XXX_REF] = "ref",
1644 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1645 [STAC_DELL_S14] = "dell-s14",
1646 [STAC_92HD83XXX_HP] = "hp",
1649 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1650 /* SigmaTel reference board */
1651 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1652 "DFI LanParty", STAC_92HD83XXX_REF),
1653 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1654 "DFI LanParty", STAC_92HD83XXX_REF),
1655 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1656 "unknown Dell", STAC_DELL_S14),
1657 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1658 "HP", STAC_92HD83XXX_HP),
1662 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1663 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1664 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1665 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1669 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1670 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1671 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1672 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1676 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1677 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1678 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1679 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1683 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1684 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1685 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1686 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1690 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1691 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1692 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1693 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1694 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1695 [STAC_HP_M4] = NULL,
1696 [STAC_HP_DV4] = NULL,
1697 [STAC_HP_DV5] = NULL,
1698 [STAC_HP_HDX] = NULL,
1699 [STAC_HP_DV4_1222NR] = NULL,
1702 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1703 [STAC_92HD71BXX_AUTO] = "auto",
1704 [STAC_92HD71BXX_REF] = "ref",
1705 [STAC_DELL_M4_1] = "dell-m4-1",
1706 [STAC_DELL_M4_2] = "dell-m4-2",
1707 [STAC_DELL_M4_3] = "dell-m4-3",
1708 [STAC_HP_M4] = "hp-m4",
1709 [STAC_HP_DV4] = "hp-dv4",
1710 [STAC_HP_DV5] = "hp-dv5",
1711 [STAC_HP_HDX] = "hp-hdx",
1712 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1715 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1716 /* SigmaTel reference board */
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1718 "DFI LanParty", STAC_92HD71BXX_REF),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1720 "DFI LanParty", STAC_92HD71BXX_REF),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1722 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1723 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1725 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1727 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1728 "HP dv4-7", STAC_HP_DV4),
1729 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1730 "HP dv4-7", STAC_HP_DV5),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1732 "HP HDX", STAC_HP_HDX), /* HDX18 */
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1734 "HP mini 1000", STAC_HP_M4),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1736 "HP HDX", STAC_HP_HDX), /* HDX16 */
1737 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1738 "HP dv6", STAC_HP_DV5),
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1740 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
1741 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1743 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1744 "unknown Dell", STAC_DELL_M4_1),
1745 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1746 "unknown Dell", STAC_DELL_M4_1),
1747 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1748 "unknown Dell", STAC_DELL_M4_1),
1749 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1750 "unknown Dell", STAC_DELL_M4_1),
1751 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1752 "unknown Dell", STAC_DELL_M4_1),
1753 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1754 "unknown Dell", STAC_DELL_M4_1),
1755 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1756 "unknown Dell", STAC_DELL_M4_1),
1757 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1758 "unknown Dell", STAC_DELL_M4_2),
1759 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1760 "unknown Dell", STAC_DELL_M4_2),
1761 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1762 "unknown Dell", STAC_DELL_M4_2),
1763 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1764 "unknown Dell", STAC_DELL_M4_2),
1765 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1766 "unknown Dell", STAC_DELL_M4_3),
1770 static unsigned int ref922x_pin_configs[10] = {
1771 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1772 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1773 0x40000100, 0x40000100,
1777 STAC 922X pin configs for
1784 static unsigned int dell_922x_d81_pin_configs[10] = {
1785 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1786 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1787 0x01813122, 0x400001f2,
1791 STAC 922X pin configs for
1795 static unsigned int dell_922x_d82_pin_configs[10] = {
1796 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1797 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1798 0x01813122, 0x400001f1,
1802 STAC 922X pin configs for
1805 static unsigned int dell_922x_m81_pin_configs[10] = {
1806 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1807 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1808 0x40C003f1, 0x405003f0,
1812 STAC 9221 A1 pin configs for
1813 102801D7 (Dell XPS M1210)
1815 static unsigned int dell_922x_m82_pin_configs[10] = {
1816 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1817 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1818 0x508003f3, 0x405003f4,
1821 static unsigned int d945gtp3_pin_configs[10] = {
1822 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1823 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1824 0x02a19120, 0x40000100,
1827 static unsigned int d945gtp5_pin_configs[10] = {
1828 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1829 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1830 0x02a19320, 0x40000100,
1833 static unsigned int intel_mac_v1_pin_configs[10] = {
1834 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1835 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1836 0x400000fc, 0x400000fb,
1839 static unsigned int intel_mac_v2_pin_configs[10] = {
1840 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1841 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1842 0x400000fc, 0x400000fb,
1845 static unsigned int intel_mac_v3_pin_configs[10] = {
1846 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1847 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1848 0x400000fc, 0x400000fb,
1851 static unsigned int intel_mac_v4_pin_configs[10] = {
1852 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1853 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1854 0x400000fc, 0x400000fb,
1857 static unsigned int intel_mac_v5_pin_configs[10] = {
1858 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1859 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1860 0x400000fc, 0x400000fb,
1863 static unsigned int ecs202_pin_configs[10] = {
1864 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1865 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1866 0x9037012e, 0x40e000f2,
1869 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1870 [STAC_D945_REF] = ref922x_pin_configs,
1871 [STAC_D945GTP3] = d945gtp3_pin_configs,
1872 [STAC_D945GTP5] = d945gtp5_pin_configs,
1873 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1874 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1875 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1876 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1877 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1878 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1879 /* for backward compatibility */
1880 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1881 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1882 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1883 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1884 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1885 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1886 [STAC_ECS_202] = ecs202_pin_configs,
1887 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1888 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1889 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1890 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1893 static const char *stac922x_models[STAC_922X_MODELS] = {
1894 [STAC_922X_AUTO] = "auto",
1895 [STAC_D945_REF] = "ref",
1896 [STAC_D945GTP5] = "5stack",
1897 [STAC_D945GTP3] = "3stack",
1898 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1899 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1900 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1901 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1902 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1903 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1904 /* for backward compatibility */
1905 [STAC_MACMINI] = "macmini",
1906 [STAC_MACBOOK] = "macbook",
1907 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1908 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1909 [STAC_IMAC_INTEL] = "imac-intel",
1910 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1911 [STAC_ECS_202] = "ecs202",
1912 [STAC_922X_DELL_D81] = "dell-d81",
1913 [STAC_922X_DELL_D82] = "dell-d82",
1914 [STAC_922X_DELL_M81] = "dell-m81",
1915 [STAC_922X_DELL_M82] = "dell-m82",
1918 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1919 /* SigmaTel reference board */
1920 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1921 "DFI LanParty", STAC_D945_REF),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1923 "DFI LanParty", STAC_D945_REF),
1924 /* Intel 945G based systems */
1925 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1926 "Intel D945G", STAC_D945GTP3),
1927 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1928 "Intel D945G", STAC_D945GTP3),
1929 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1930 "Intel D945G", STAC_D945GTP3),
1931 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1932 "Intel D945G", STAC_D945GTP3),
1933 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1934 "Intel D945G", STAC_D945GTP3),
1935 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1936 "Intel D945G", STAC_D945GTP3),
1937 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1938 "Intel D945G", STAC_D945GTP3),
1939 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1940 "Intel D945G", STAC_D945GTP3),
1941 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1942 "Intel D945G", STAC_D945GTP3),
1943 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1944 "Intel D945G", STAC_D945GTP3),
1945 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1946 "Intel D945G", STAC_D945GTP3),
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1948 "Intel D945G", STAC_D945GTP3),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1950 "Intel D945G", STAC_D945GTP3),
1951 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1952 "Intel D945G", STAC_D945GTP3),
1953 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1954 "Intel D945G", STAC_D945GTP3),
1955 /* Intel D945G 5-stack systems */
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1957 "Intel D945G", STAC_D945GTP5),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1959 "Intel D945G", STAC_D945GTP5),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1961 "Intel D945G", STAC_D945GTP5),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1963 "Intel D945G", STAC_D945GTP5),
1964 /* Intel 945P based systems */
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1966 "Intel D945P", STAC_D945GTP3),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1968 "Intel D945P", STAC_D945GTP3),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1970 "Intel D945P", STAC_D945GTP3),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1972 "Intel D945P", STAC_D945GTP3),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
1974 "Intel D945P", STAC_D945GTP3),
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
1976 "Intel D945P", STAC_D945GTP5),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
1979 "Intel D945", STAC_D945_REF),
1981 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
1982 SND_PCI_QUIRK(0x8384, 0x7680,
1983 "Mac", STAC_INTEL_MAC_AUTO),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
1986 "unknown Dell", STAC_922X_DELL_D81),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
1988 "unknown Dell", STAC_922X_DELL_D81),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
1990 "unknown Dell", STAC_922X_DELL_D81),
1991 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
1992 "unknown Dell", STAC_922X_DELL_D82),
1993 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
1994 "unknown Dell", STAC_922X_DELL_M81),
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
1996 "unknown Dell", STAC_922X_DELL_D82),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
1998 "unknown Dell", STAC_922X_DELL_D81),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2000 "unknown Dell", STAC_922X_DELL_D81),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2002 "Dell XPS M1210", STAC_922X_DELL_M82),
2003 /* ECS/PC Chips boards */
2004 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2005 "ECS/PC chips", STAC_ECS_202),
2009 static unsigned int ref927x_pin_configs[14] = {
2010 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2011 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2012 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2013 0x01c42190, 0x40000100,
2016 static unsigned int d965_3st_pin_configs[14] = {
2017 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2018 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2019 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2020 0x40000100, 0x40000100
2023 static unsigned int d965_5st_pin_configs[14] = {
2024 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2025 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2026 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2027 0x40000100, 0x40000100
2030 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2031 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2032 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2033 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2034 0x40000100, 0x40000100
2037 static unsigned int dell_3st_pin_configs[14] = {
2038 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2039 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2040 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2041 0x40c003fc, 0x40000100
2044 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2045 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2046 [STAC_D965_REF] = ref927x_pin_configs,
2047 [STAC_D965_3ST] = d965_3st_pin_configs,
2048 [STAC_D965_5ST] = d965_5st_pin_configs,
2049 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2050 [STAC_DELL_3ST] = dell_3st_pin_configs,
2051 [STAC_DELL_BIOS] = NULL,
2052 [STAC_927X_VOLKNOB] = NULL,
2055 static const char *stac927x_models[STAC_927X_MODELS] = {
2056 [STAC_927X_AUTO] = "auto",
2057 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2058 [STAC_D965_REF] = "ref",
2059 [STAC_D965_3ST] = "3stack",
2060 [STAC_D965_5ST] = "5stack",
2061 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2062 [STAC_DELL_3ST] = "dell-3stack",
2063 [STAC_DELL_BIOS] = "dell-bios",
2064 [STAC_927X_VOLKNOB] = "volknob",
2067 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2068 /* SigmaTel reference board */
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2070 "DFI LanParty", STAC_D965_REF),
2071 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2072 "DFI LanParty", STAC_D965_REF),
2073 /* Intel 946 based systems */
2074 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2075 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2076 /* 965 based 3 stack systems */
2077 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2078 "Intel D965", STAC_D965_3ST),
2079 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2080 "Intel D965", STAC_D965_3ST),
2081 /* Dell 3 stack systems */
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2085 /* Dell 3 stack systems with verb table in BIOS */
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2095 /* 965 based 5 stack systems */
2096 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2097 "Intel D965", STAC_D965_5ST),
2098 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2099 "Intel D965", STAC_D965_5ST),
2100 /* volume-knob fixes */
2101 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
2105 static unsigned int ref9205_pin_configs[12] = {
2106 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2107 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2108 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2112 STAC 9205 pin configs for
2119 10280228 (Dell Vostro 1500)
2120 10280229 (Dell Vostro 1700)
2122 static unsigned int dell_9205_m42_pin_configs[12] = {
2123 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2124 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2125 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2129 STAC 9205 pin configs for
2133 102801FF (Dell Precision M4300)
2138 static unsigned int dell_9205_m43_pin_configs[12] = {
2139 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2140 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2141 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2144 static unsigned int dell_9205_m44_pin_configs[12] = {
2145 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2146 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2147 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2150 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2151 [STAC_9205_REF] = ref9205_pin_configs,
2152 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2153 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2154 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2155 [STAC_9205_EAPD] = NULL,
2158 static const char *stac9205_models[STAC_9205_MODELS] = {
2159 [STAC_9205_AUTO] = "auto",
2160 [STAC_9205_REF] = "ref",
2161 [STAC_9205_DELL_M42] = "dell-m42",
2162 [STAC_9205_DELL_M43] = "dell-m43",
2163 [STAC_9205_DELL_M44] = "dell-m44",
2164 [STAC_9205_EAPD] = "eapd",
2167 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2168 /* SigmaTel reference board */
2169 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2170 "DFI LanParty", STAC_9205_REF),
2171 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2172 "SigmaTel", STAC_9205_REF),
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2174 "DFI LanParty", STAC_9205_REF),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2177 "unknown Dell", STAC_9205_DELL_M42),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2179 "unknown Dell", STAC_9205_DELL_M42),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2181 "Dell Precision", STAC_9205_DELL_M43),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2183 "Dell Precision", STAC_9205_DELL_M43),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2185 "Dell Precision", STAC_9205_DELL_M43),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2187 "unknown Dell", STAC_9205_DELL_M42),
2188 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2189 "unknown Dell", STAC_9205_DELL_M42),
2190 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2191 "Dell Precision", STAC_9205_DELL_M43),
2192 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2193 "Dell Precision M4300", STAC_9205_DELL_M43),
2194 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2195 "unknown Dell", STAC_9205_DELL_M42),
2196 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2197 "Dell Precision", STAC_9205_DELL_M43),
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2199 "Dell Precision", STAC_9205_DELL_M43),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2201 "Dell Precision", STAC_9205_DELL_M43),
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2203 "Dell Inspiron", STAC_9205_DELL_M44),
2204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2205 "Dell Vostro 1500", STAC_9205_DELL_M42),
2206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2207 "Dell Vostro 1700", STAC_9205_DELL_M42),
2209 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2210 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2214 static void stac92xx_set_config_regs(struct hda_codec *codec,
2215 unsigned int *pincfgs)
2218 struct sigmatel_spec *spec = codec->spec;
2223 for (i = 0; i < spec->num_pins; i++)
2224 if (spec->pin_nids[i] && pincfgs[i])
2225 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2230 * Analog playback callbacks
2232 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2233 struct hda_codec *codec,
2234 struct snd_pcm_substream *substream)
2236 struct sigmatel_spec *spec = codec->spec;
2237 if (spec->stream_delay)
2238 msleep(spec->stream_delay);
2239 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2243 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2244 struct hda_codec *codec,
2245 unsigned int stream_tag,
2246 unsigned int format,
2247 struct snd_pcm_substream *substream)
2249 struct sigmatel_spec *spec = codec->spec;
2250 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2253 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2254 struct hda_codec *codec,
2255 struct snd_pcm_substream *substream)
2257 struct sigmatel_spec *spec = codec->spec;
2258 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2262 * Digital playback callbacks
2264 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2265 struct hda_codec *codec,
2266 struct snd_pcm_substream *substream)
2268 struct sigmatel_spec *spec = codec->spec;
2269 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2272 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2273 struct hda_codec *codec,
2274 struct snd_pcm_substream *substream)
2276 struct sigmatel_spec *spec = codec->spec;
2277 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2280 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2281 struct hda_codec *codec,
2282 unsigned int stream_tag,
2283 unsigned int format,
2284 struct snd_pcm_substream *substream)
2286 struct sigmatel_spec *spec = codec->spec;
2287 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2288 stream_tag, format, substream);
2291 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2292 struct hda_codec *codec,
2293 struct snd_pcm_substream *substream)
2295 struct sigmatel_spec *spec = codec->spec;
2296 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2301 * Analog capture callbacks
2303 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2304 struct hda_codec *codec,
2305 unsigned int stream_tag,
2306 unsigned int format,
2307 struct snd_pcm_substream *substream)
2309 struct sigmatel_spec *spec = codec->spec;
2310 hda_nid_t nid = spec->adc_nids[substream->number];
2312 if (spec->powerdown_adcs) {
2314 snd_hda_codec_write(codec, nid, 0,
2315 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2317 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2321 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2322 struct hda_codec *codec,
2323 struct snd_pcm_substream *substream)
2325 struct sigmatel_spec *spec = codec->spec;
2326 hda_nid_t nid = spec->adc_nids[substream->number];
2328 snd_hda_codec_cleanup_stream(codec, nid);
2329 if (spec->powerdown_adcs)
2330 snd_hda_codec_write(codec, nid, 0,
2331 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2335 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2339 /* NID is set in stac92xx_build_pcms */
2341 .open = stac92xx_dig_playback_pcm_open,
2342 .close = stac92xx_dig_playback_pcm_close,
2343 .prepare = stac92xx_dig_playback_pcm_prepare,
2344 .cleanup = stac92xx_dig_playback_pcm_cleanup
2348 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2352 /* NID is set in stac92xx_build_pcms */
2355 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2359 .nid = 0x02, /* NID to query formats and rates */
2361 .open = stac92xx_playback_pcm_open,
2362 .prepare = stac92xx_playback_pcm_prepare,
2363 .cleanup = stac92xx_playback_pcm_cleanup
2367 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2371 .nid = 0x06, /* NID to query formats and rates */
2373 .open = stac92xx_playback_pcm_open,
2374 .prepare = stac92xx_playback_pcm_prepare,
2375 .cleanup = stac92xx_playback_pcm_cleanup
2379 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2382 /* NID + .substreams is set in stac92xx_build_pcms */
2384 .prepare = stac92xx_capture_pcm_prepare,
2385 .cleanup = stac92xx_capture_pcm_cleanup
2389 static int stac92xx_build_pcms(struct hda_codec *codec)
2391 struct sigmatel_spec *spec = codec->spec;
2392 struct hda_pcm *info = spec->pcm_rec;
2394 codec->num_pcms = 1;
2395 codec->pcm_info = info;
2397 info->name = "STAC92xx Analog";
2398 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2399 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2400 spec->multiout.dac_nids[0];
2401 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2402 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2403 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2405 if (spec->alt_switch) {
2408 info->name = "STAC92xx Analog Alt";
2409 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2412 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2415 info->name = "STAC92xx Digital";
2416 info->pcm_type = spec->autocfg.dig_out_type[0];
2417 if (spec->multiout.dig_out_nid) {
2418 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2419 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2421 if (spec->dig_in_nid) {
2422 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2423 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2430 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2433 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2434 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2435 if (pincap & AC_PINCAP_VREF_100)
2436 return AC_PINCTL_VREF_100;
2437 if (pincap & AC_PINCAP_VREF_80)
2438 return AC_PINCTL_VREF_80;
2439 if (pincap & AC_PINCAP_VREF_50)
2440 return AC_PINCTL_VREF_50;
2441 if (pincap & AC_PINCAP_VREF_GRD)
2442 return AC_PINCTL_VREF_GRD;
2446 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2449 snd_hda_codec_write_cache(codec, nid, 0,
2450 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2453 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2455 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2456 struct snd_ctl_elem_value *ucontrol)
2458 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2459 struct sigmatel_spec *spec = codec->spec;
2461 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2465 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2467 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2468 struct snd_ctl_elem_value *ucontrol)
2470 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2471 struct sigmatel_spec *spec = codec->spec;
2472 int nid = kcontrol->private_value;
2474 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2476 /* check to be sure that the ports are upto date with
2479 stac_issue_unsol_event(codec, nid);
2484 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2485 struct snd_ctl_elem_info *uinfo)
2488 static char *texts[] = {
2489 "Mic In", "Line In", "Line Out"
2492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2493 struct sigmatel_spec *spec = codec->spec;
2494 hda_nid_t nid = kcontrol->private_value;
2496 if (nid == spec->mic_switch || nid == spec->line_switch)
2501 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2502 uinfo->value.enumerated.items = i;
2504 if (uinfo->value.enumerated.item >= i)
2505 uinfo->value.enumerated.item = i-1;
2506 strcpy(uinfo->value.enumerated.name,
2507 texts[uinfo->value.enumerated.item]);
2512 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2513 struct snd_ctl_elem_value *ucontrol)
2515 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2516 hda_nid_t nid = kcontrol->private_value;
2517 unsigned int vref = stac92xx_vref_get(codec, nid);
2519 if (vref == stac92xx_get_default_vref(codec, nid))
2520 ucontrol->value.enumerated.item[0] = 0;
2521 else if (vref == AC_PINCTL_VREF_GRD)
2522 ucontrol->value.enumerated.item[0] = 1;
2523 else if (vref == AC_PINCTL_VREF_HIZ)
2524 ucontrol->value.enumerated.item[0] = 2;
2529 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2530 struct snd_ctl_elem_value *ucontrol)
2532 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2533 unsigned int new_vref = 0;
2535 hda_nid_t nid = kcontrol->private_value;
2537 if (ucontrol->value.enumerated.item[0] == 0)
2538 new_vref = stac92xx_get_default_vref(codec, nid);
2539 else if (ucontrol->value.enumerated.item[0] == 1)
2540 new_vref = AC_PINCTL_VREF_GRD;
2541 else if (ucontrol->value.enumerated.item[0] == 2)
2542 new_vref = AC_PINCTL_VREF_HIZ;
2546 if (new_vref != stac92xx_vref_get(codec, nid)) {
2547 error = stac92xx_vref_set(codec, nid, new_vref);
2554 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2555 struct snd_ctl_elem_info *uinfo)
2557 static char *texts[2];
2558 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2559 struct sigmatel_spec *spec = codec->spec;
2561 if (kcontrol->private_value == spec->line_switch)
2562 texts[0] = "Line In";
2564 texts[0] = "Mic In";
2565 texts[1] = "Line Out";
2566 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2567 uinfo->value.enumerated.items = 2;
2570 if (uinfo->value.enumerated.item >= 2)
2571 uinfo->value.enumerated.item = 1;
2572 strcpy(uinfo->value.enumerated.name,
2573 texts[uinfo->value.enumerated.item]);
2578 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2580 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2581 struct sigmatel_spec *spec = codec->spec;
2582 hda_nid_t nid = kcontrol->private_value;
2583 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2585 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2589 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2591 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2592 struct sigmatel_spec *spec = codec->spec;
2593 hda_nid_t nid = kcontrol->private_value;
2594 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2595 unsigned short val = !!ucontrol->value.enumerated.item[0];
2597 spec->io_switch[io_idx] = val;
2600 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2602 unsigned int pinctl = AC_PINCTL_IN_EN;
2603 if (io_idx) /* set VREF for mic */
2604 pinctl |= stac92xx_get_default_vref(codec, nid);
2605 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2608 /* check the auto-mute again: we need to mute/unmute the speaker
2609 * appropriately according to the pin direction
2611 if (spec->hp_detect)
2612 stac_issue_unsol_event(codec, nid);
2617 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2619 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2620 struct snd_ctl_elem_value *ucontrol)
2622 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2623 struct sigmatel_spec *spec = codec->spec;
2625 ucontrol->value.integer.value[0] = spec->clfe_swap;
2629 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2630 struct snd_ctl_elem_value *ucontrol)
2632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2633 struct sigmatel_spec *spec = codec->spec;
2634 hda_nid_t nid = kcontrol->private_value & 0xff;
2635 unsigned int val = !!ucontrol->value.integer.value[0];
2637 if (spec->clfe_swap == val)
2640 spec->clfe_swap = val;
2642 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2643 spec->clfe_swap ? 0x4 : 0x0);
2648 #define STAC_CODEC_HP_SWITCH(xname) \
2649 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2652 .info = stac92xx_hp_switch_info, \
2653 .get = stac92xx_hp_switch_get, \
2654 .put = stac92xx_hp_switch_put, \
2657 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2658 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2661 .info = stac92xx_io_switch_info, \
2662 .get = stac92xx_io_switch_get, \
2663 .put = stac92xx_io_switch_put, \
2664 .private_value = xpval, \
2667 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2668 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2671 .info = stac92xx_clfe_switch_info, \
2672 .get = stac92xx_clfe_switch_get, \
2673 .put = stac92xx_clfe_switch_put, \
2674 .private_value = xpval, \
2678 STAC_CTL_WIDGET_VOL,
2679 STAC_CTL_WIDGET_MUTE,
2680 STAC_CTL_WIDGET_MUTE_BEEP,
2681 STAC_CTL_WIDGET_MONO_MUX,
2682 STAC_CTL_WIDGET_HP_SWITCH,
2683 STAC_CTL_WIDGET_IO_SWITCH,
2684 STAC_CTL_WIDGET_CLFE_SWITCH,
2685 STAC_CTL_WIDGET_DC_BIAS
2688 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2689 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2690 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2691 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
2693 STAC_CODEC_HP_SWITCH(NULL),
2694 STAC_CODEC_IO_SWITCH(NULL, 0),
2695 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2696 DC_BIAS(NULL, 0, 0),
2699 /* add dynamic controls */
2700 static struct snd_kcontrol_new *
2701 stac_control_new(struct sigmatel_spec *spec,
2702 struct snd_kcontrol_new *ktemp,
2704 unsigned int subdev)
2706 struct snd_kcontrol_new *knew;
2708 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2709 knew = snd_array_new(&spec->kctls);
2713 knew->name = kstrdup(name, GFP_KERNEL);
2716 memset(knew, 0, sizeof(*knew));
2717 spec->kctls.alloced--;
2720 knew->subdevice = subdev;
2724 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2725 struct snd_kcontrol_new *ktemp,
2726 int idx, const char *name,
2729 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
2730 HDA_SUBDEV_AMP_FLAG);
2734 knew->private_value = val;
2738 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2739 int type, int idx, const char *name,
2742 return stac92xx_add_control_temp(spec,
2743 &stac92xx_control_templates[type],
2748 /* add dynamic controls */
2749 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2750 const char *name, unsigned long val)
2752 return stac92xx_add_control_idx(spec, type, 0, name, val);
2755 static struct snd_kcontrol_new stac_input_src_temp = {
2756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2757 .name = "Input Source",
2758 .info = stac92xx_mux_enum_info,
2759 .get = stac92xx_mux_enum_get,
2760 .put = stac92xx_mux_enum_put,
2763 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2764 hda_nid_t nid, int idx)
2766 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2768 struct sigmatel_spec *spec = codec->spec;
2771 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2772 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2773 && nid == spec->line_switch)
2774 control = STAC_CTL_WIDGET_IO_SWITCH;
2775 else if (snd_hda_query_pin_caps(codec, nid)
2776 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2777 control = STAC_CTL_WIDGET_DC_BIAS;
2778 else if (nid == spec->mic_switch)
2779 control = STAC_CTL_WIDGET_IO_SWITCH;
2783 strcpy(name, auto_pin_cfg_labels[idx]);
2784 return stac92xx_add_control(codec->spec, control,
2785 strcat(name, " Jack Mode"), nid);
2791 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2793 struct snd_kcontrol_new *knew;
2794 struct hda_input_mux *imux = &spec->private_imux;
2797 return 0; /* no need for input source */
2798 if (!spec->num_adcs || imux->num_items <= 1)
2799 return 0; /* no need for input source control */
2800 knew = stac_control_new(spec, &stac_input_src_temp,
2801 stac_input_src_temp.name, 0);
2804 knew->count = spec->num_adcs;
2808 /* check whether the line-input can be used as line-out */
2809 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2811 struct sigmatel_spec *spec = codec->spec;
2812 struct auto_pin_cfg *cfg = &spec->autocfg;
2814 unsigned int pincap;
2816 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2818 nid = cfg->input_pins[AUTO_PIN_LINE];
2819 pincap = snd_hda_query_pin_caps(codec, nid);
2820 if (pincap & AC_PINCAP_OUT)
2825 /* check whether the mic-input can be used as line-out */
2826 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2828 struct sigmatel_spec *spec = codec->spec;
2829 struct auto_pin_cfg *cfg = &spec->autocfg;
2830 unsigned int def_conf, pincap;
2831 unsigned int mic_pin;
2833 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2835 mic_pin = AUTO_PIN_MIC;
2837 hda_nid_t nid = cfg->input_pins[mic_pin];
2838 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2839 /* some laptops have an internal analog microphone
2840 * which can't be used as a output */
2841 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2842 pincap = snd_hda_query_pin_caps(codec, nid);
2843 if (pincap & AC_PINCAP_OUT)
2846 if (mic_pin == AUTO_PIN_MIC)
2847 mic_pin = AUTO_PIN_FRONT_MIC;
2854 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2858 for (i = 0; i < spec->multiout.num_dacs; i++) {
2859 if (spec->multiout.dac_nids[i] == nid)
2866 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2869 if (is_in_dac_nids(spec, nid))
2871 for (i = 0; i < spec->autocfg.hp_outs; i++)
2872 if (spec->hp_dacs[i] == nid)
2874 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2875 if (spec->speaker_dacs[i] == nid)
2880 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2882 struct sigmatel_spec *spec = codec->spec;
2884 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2885 unsigned int wcaps, wtype;
2887 conn_len = snd_hda_get_connections(codec, nid, conn,
2888 HDA_MAX_CONNECTIONS);
2889 /* 92HD88: trace back up the link of nids to find the DAC */
2890 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2891 != AC_WID_AUD_OUT)) {
2893 conn_len = snd_hda_get_connections(codec, nid, conn,
2894 HDA_MAX_CONNECTIONS);
2896 for (j = 0; j < conn_len; j++) {
2897 wcaps = get_wcaps(codec, conn[j]);
2898 wtype = get_wcaps_type(wcaps);
2899 /* we check only analog outputs */
2900 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2902 /* if this route has a free DAC, assign it */
2903 if (!check_all_dac_nids(spec, conn[j])) {
2905 /* select this DAC in the pin's input mux */
2906 snd_hda_codec_write_cache(codec, nid, 0,
2907 AC_VERB_SET_CONNECT_SEL, j);
2912 /* if all DACs are already assigned, connect to the primary DAC */
2914 for (j = 0; j < conn_len; j++) {
2915 if (conn[j] == spec->multiout.dac_nids[0]) {
2916 snd_hda_codec_write_cache(codec, nid, 0,
2917 AC_VERB_SET_CONNECT_SEL, j);
2925 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2926 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2929 * Fill in the dac_nids table from the parsed pin configuration
2930 * This function only works when every pin in line_out_pins[]
2931 * contains atleast one DAC in its connection list. Some 92xx
2932 * codecs are not connected directly to a DAC, such as the 9200
2933 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2935 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2937 struct sigmatel_spec *spec = codec->spec;
2938 struct auto_pin_cfg *cfg = &spec->autocfg;
2942 for (i = 0; i < cfg->line_outs; i++) {
2943 nid = cfg->line_out_pins[i];
2944 dac = get_unassigned_dac(codec, nid);
2946 if (spec->multiout.num_dacs > 0) {
2947 /* we have already working output pins,
2948 * so let's drop the broken ones again
2950 cfg->line_outs = spec->multiout.num_dacs;
2953 /* error out, no available DAC found */
2955 "%s: No available DAC for pin 0x%x\n",
2959 add_spec_dacs(spec, dac);
2962 for (i = 0; i < cfg->hp_outs; i++) {
2963 nid = cfg->hp_pins[i];
2964 dac = get_unassigned_dac(codec, nid);
2966 if (!spec->multiout.hp_nid)
2967 spec->multiout.hp_nid = dac;
2969 add_spec_extra_dacs(spec, dac);
2971 spec->hp_dacs[i] = dac;
2974 for (i = 0; i < cfg->speaker_outs; i++) {
2975 nid = cfg->speaker_pins[i];
2976 dac = get_unassigned_dac(codec, nid);
2978 add_spec_extra_dacs(spec, dac);
2979 spec->speaker_dacs[i] = dac;
2982 /* add line-in as output */
2983 nid = check_line_out_switch(codec);
2985 dac = get_unassigned_dac(codec, nid);
2987 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
2988 nid, cfg->line_outs);
2989 cfg->line_out_pins[cfg->line_outs] = nid;
2991 spec->line_switch = nid;
2992 add_spec_dacs(spec, dac);
2995 /* add mic as output */
2996 nid = check_mic_out_switch(codec);
2998 dac = get_unassigned_dac(codec, nid);
3000 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3001 nid, cfg->line_outs);
3002 cfg->line_out_pins[cfg->line_outs] = nid;
3004 spec->mic_switch = nid;
3005 add_spec_dacs(spec, dac);
3009 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3010 spec->multiout.num_dacs,
3011 spec->multiout.dac_nids[0],
3012 spec->multiout.dac_nids[1],
3013 spec->multiout.dac_nids[2],
3014 spec->multiout.dac_nids[3],
3015 spec->multiout.dac_nids[4]);
3020 /* create volume control/switch for the given prefx type */
3021 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3022 int idx, hda_nid_t nid, int chs)
3024 struct sigmatel_spec *spec = codec->spec;
3028 if (!spec->check_volume_offset) {
3029 unsigned int caps, step, nums, db_scale;
3030 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3031 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3032 AC_AMPCAP_STEP_SIZE_SHIFT;
3033 step = (step + 1) * 25; /* in .01dB unit */
3034 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3035 AC_AMPCAP_NUM_STEPS_SHIFT;
3036 db_scale = nums * step;
3037 /* if dB scale is over -64dB, and finer enough,
3038 * let's reduce it to half
3040 if (db_scale > 6400 && nums >= 0x1f)
3041 spec->volume_offset = nums / 2;
3042 spec->check_volume_offset = 1;
3045 sprintf(name, "%s Playback Volume", pfx);
3046 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3047 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3048 spec->volume_offset));
3051 sprintf(name, "%s Playback Switch", pfx);
3052 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3053 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3059 #define create_controls(codec, pfx, nid, chs) \
3060 create_controls_idx(codec, pfx, 0, nid, chs)
3062 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3064 if (spec->multiout.num_dacs > 4) {
3065 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3068 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3069 spec->multiout.num_dacs++;
3074 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3077 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3078 if (!spec->multiout.extra_out_nid[i]) {
3079 spec->multiout.extra_out_nid[i] = nid;
3083 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3087 /* Create output controls
3088 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3090 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3091 const hda_nid_t *pins,
3092 const hda_nid_t *dac_nids,
3095 struct sigmatel_spec *spec = codec->spec;
3096 static const char *chname[4] = {
3097 "Front", "Surround", NULL /*CLFE*/, "Side"
3101 unsigned int wid_caps;
3103 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3104 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3105 wid_caps = get_wcaps(codec, pins[i]);
3106 if (wid_caps & AC_WCAP_UNSOL_CAP)
3107 spec->hp_detect = 1;
3112 if (type != AUTO_PIN_HP_OUT && i == 2) {
3114 err = create_controls(codec, "Center", nid, 1);
3117 err = create_controls(codec, "LFE", nid, 2);
3121 wid_caps = get_wcaps(codec, nid);
3123 if (wid_caps & AC_WCAP_LR_SWAP) {
3124 err = stac92xx_add_control(spec,
3125 STAC_CTL_WIDGET_CLFE_SWITCH,
3126 "Swap Center/LFE Playback Switch", nid);
3136 case AUTO_PIN_HP_OUT:
3140 case AUTO_PIN_SPEAKER_OUT:
3149 err = create_controls_idx(codec, name, idx, nid, 3);
3157 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3158 unsigned long sw, int idx)
3161 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3162 "Capture Volume", vol);
3165 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3166 "Capture Switch", sw);
3172 /* add playback controls from the parsed DAC table */
3173 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3174 const struct auto_pin_cfg *cfg)
3176 struct sigmatel_spec *spec = codec->spec;
3181 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3182 spec->multiout.dac_nids,
3183 cfg->line_out_type);
3187 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3188 err = stac92xx_add_control(spec,
3189 STAC_CTL_WIDGET_HP_SWITCH,
3190 "Headphone as Line Out Switch",
3191 cfg->hp_pins[cfg->hp_outs - 1]);
3196 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3197 nid = cfg->input_pins[idx];
3199 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3208 /* add playback controls for Speaker and HP outputs */
3209 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3210 struct auto_pin_cfg *cfg)
3212 struct sigmatel_spec *spec = codec->spec;
3215 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3216 spec->hp_dacs, AUTO_PIN_HP_OUT);
3220 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3221 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3228 /* labels for mono mux outputs */
3229 static const char *stac92xx_mono_labels[4] = {
3230 "DAC0", "DAC1", "Mixer", "DAC2"
3233 /* create mono mux for mono out on capable codecs */
3234 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3236 struct sigmatel_spec *spec = codec->spec;
3237 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3239 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3241 num_cons = snd_hda_get_connections(codec,
3244 HDA_MAX_NUM_INPUTS);
3245 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3248 for (i = 0; i < num_cons; i++) {
3249 mono_mux->items[mono_mux->num_items].label =
3250 stac92xx_mono_labels[i];
3251 mono_mux->items[mono_mux->num_items].index = i;
3252 mono_mux->num_items++;
3255 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3256 "Mono Mux", spec->mono_nid);
3259 /* create PC beep volume controls */
3260 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3263 struct sigmatel_spec *spec = codec->spec;
3264 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3265 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3267 if (spec->anabeep_nid == nid)
3268 type = STAC_CTL_WIDGET_MUTE;
3270 /* check for mute support for the the amp */
3271 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3272 err = stac92xx_add_control(spec, type,
3273 "Beep Playback Switch",
3274 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3279 /* check to see if there is volume support for the amp */
3280 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3281 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3282 "Beep Playback Volume",
3283 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3290 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3291 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3293 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3294 struct snd_ctl_elem_value *ucontrol)
3296 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3297 ucontrol->value.integer.value[0] = codec->beep->enabled;
3301 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3302 struct snd_ctl_elem_value *ucontrol)
3304 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3305 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
3308 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3309 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3310 .info = stac92xx_dig_beep_switch_info,
3311 .get = stac92xx_dig_beep_switch_get,
3312 .put = stac92xx_dig_beep_switch_put,
3315 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3317 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3318 0, "Beep Playback Switch", 0);
3322 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3324 struct sigmatel_spec *spec = codec->spec;
3327 for (i = 0; i < spec->num_muxes; i++) {
3332 nid = spec->mux_nids[i];
3333 wcaps = get_wcaps(codec, nid);
3334 if (!(wcaps & AC_WCAP_OUT_AMP))
3337 /* check whether already the same control was created as
3338 * normal Capture Volume.
3340 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3341 for (j = 0; j < spec->num_caps; j++) {
3342 if (spec->capvols[j] == val)
3345 if (j < spec->num_caps)
3348 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3349 "Mux Capture Volume", val);
3356 static const char *stac92xx_spdif_labels[3] = {
3357 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3360 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3362 struct sigmatel_spec *spec = codec->spec;
3363 struct hda_input_mux *spdif_mux = &spec->private_smux;
3364 const char **labels = spec->spdif_labels;
3366 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3368 num_cons = snd_hda_get_connections(codec,
3371 HDA_MAX_NUM_INPUTS);
3376 labels = stac92xx_spdif_labels;
3378 for (i = 0; i < num_cons; i++) {
3379 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3380 spdif_mux->items[spdif_mux->num_items].index = i;
3381 spdif_mux->num_items++;
3387 /* labels for dmic mux inputs */
3388 static const char *stac92xx_dmic_labels[5] = {
3389 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3390 "Digital Mic 3", "Digital Mic 4"
3393 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3396 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3399 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3400 for (i = 0; i < nums; i++)
3406 /* create a volume assigned to the given pin (only if supported) */
3407 /* return 1 if the volume control is created */
3408 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3409 const char *label, int direction)
3411 unsigned int caps, nums;
3415 if (direction == HDA_OUTPUT)
3416 caps = AC_WCAP_OUT_AMP;
3418 caps = AC_WCAP_IN_AMP;
3419 if (!(get_wcaps(codec, nid) & caps))
3421 caps = query_amp_caps(codec, nid, direction);
3422 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3425 snprintf(name, sizeof(name), "%s Capture Volume", label);
3426 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3427 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3433 /* create playback/capture controls for input pins on dmic capable codecs */
3434 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3435 const struct auto_pin_cfg *cfg)
3437 struct sigmatel_spec *spec = codec->spec;
3438 struct hda_input_mux *imux = &spec->private_imux;
3439 struct hda_input_mux *dimux = &spec->private_dimux;
3440 int err, i, active_mics;
3441 unsigned int def_conf;
3443 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3444 dimux->items[dimux->num_items].index = 0;
3448 for (i = 0; i < spec->num_dmics; i++) {
3449 /* check the validity: sometimes it's a dead vendor-spec node */
3450 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3453 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3454 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3458 for (i = 0; i < spec->num_dmics; i++) {
3463 nid = spec->dmic_nids[i];
3464 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3466 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3467 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3470 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3474 if (active_mics == 1)
3475 label = "Digital Mic";
3477 label = stac92xx_dmic_labels[dimux->num_items];
3479 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
3483 err = create_elem_capture_vol(codec, nid, label,
3489 dimux->items[dimux->num_items].label = label;
3490 dimux->items[dimux->num_items].index = index;
3492 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3493 imux->items[imux->num_items].label = label;
3494 imux->items[imux->num_items].index = index;
3502 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3503 hda_nid_t *fixed, hda_nid_t *ext)
3509 cfg = snd_hda_codec_get_pincfg(codec, nid);
3510 switch (get_defcfg_connect(cfg)) {
3511 case AC_JACK_PORT_FIXED:
3513 return 1; /* already occupied */
3516 case AC_JACK_PORT_COMPLEX:
3518 return 1; /* already occupied */
3525 static int set_mic_route(struct hda_codec *codec,
3526 struct sigmatel_mic_route *mic,
3529 struct sigmatel_spec *spec = codec->spec;
3530 struct auto_pin_cfg *cfg = &spec->autocfg;
3534 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3535 if (pin == cfg->input_pins[i])
3537 if (i <= AUTO_PIN_FRONT_MIC) {
3539 i = get_connection_index(codec, spec->mux_nids[0], pin);
3544 if (spec->dmux_nids)
3545 mic->dmux_idx = get_connection_index(codec,
3548 } else if (spec->dmux_nids) {
3550 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3556 mic->mux_idx = get_connection_index(codec,
3558 spec->dmux_nids[0]);
3563 /* return non-zero if the device is for automatic mic switch */
3564 static int stac_check_auto_mic(struct hda_codec *codec)
3566 struct sigmatel_spec *spec = codec->spec;
3567 struct auto_pin_cfg *cfg = &spec->autocfg;
3568 hda_nid_t fixed, ext;
3571 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3572 if (cfg->input_pins[i])
3573 return 0; /* must be exclusively mics */
3576 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3577 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3579 for (i = 0; i < spec->num_dmics; i++)
3580 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3584 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3585 return 0; /* no unsol support */
3586 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3587 set_mic_route(codec, &spec->int_mic, fixed))
3588 return 0; /* something is wrong */
3592 /* create playback/capture controls for input pins */
3593 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3595 struct sigmatel_spec *spec = codec->spec;
3596 struct hda_input_mux *imux = &spec->private_imux;
3599 for (i = 0; i < AUTO_PIN_LAST; i++) {
3600 hda_nid_t nid = cfg->input_pins[i];
3606 for (j = 0; j < spec->num_muxes; j++) {
3607 index = get_connection_index(codec, spec->mux_nids[j],
3615 err = create_elem_capture_vol(codec, nid,
3616 auto_pin_cfg_labels[i],
3621 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3622 imux->items[imux->num_items].index = index;
3625 spec->num_analog_muxes = imux->num_items;
3627 if (imux->num_items) {
3629 * Set the current input for the muxes.
3630 * The STAC9221 has two input muxes with identical source
3631 * NID lists. Hopefully this won't get confused.
3633 for (i = 0; i < spec->num_muxes; i++) {
3634 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3635 AC_VERB_SET_CONNECT_SEL,
3636 imux->items[0].index);
3643 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3645 struct sigmatel_spec *spec = codec->spec;
3648 for (i = 0; i < spec->autocfg.line_outs; i++) {
3649 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3650 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3654 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3656 struct sigmatel_spec *spec = codec->spec;
3659 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3661 pin = spec->autocfg.hp_pins[i];
3662 if (pin) /* connect to front */
3663 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3665 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3667 pin = spec->autocfg.speaker_pins[i];
3668 if (pin) /* connect to front */
3669 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3673 static int is_dual_headphones(struct hda_codec *codec)
3675 struct sigmatel_spec *spec = codec->spec;
3678 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3679 spec->autocfg.hp_outs <= 1)
3682 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3683 hda_nid_t nid = spec->autocfg.hp_pins[i];
3684 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3685 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3689 return (valid_hps > 1);
3693 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3695 struct sigmatel_spec *spec = codec->spec;
3699 if ((err = snd_hda_parse_pin_def_config(codec,
3701 spec->dmic_nids)) < 0)
3703 if (! spec->autocfg.line_outs)
3704 return 0; /* can't find valid pin config */
3706 /* If we have no real line-out pin and multiple hp-outs, HPs should
3707 * be set up as multi-channel outputs.
3709 if (is_dual_headphones(codec)) {
3710 /* Copy hp_outs to line_outs, backup line_outs in
3711 * speaker_outs so that the following routines can handle
3712 * HP pins as primary outputs.
3714 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3715 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3716 sizeof(spec->autocfg.line_out_pins));
3717 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3718 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3719 sizeof(spec->autocfg.hp_pins));
3720 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3721 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3722 spec->autocfg.hp_outs = 0;
3725 if (spec->autocfg.mono_out_pin) {
3726 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3727 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3728 u32 caps = query_amp_caps(codec,
3729 spec->autocfg.mono_out_pin, dir);
3730 hda_nid_t conn_list[1];
3732 /* get the mixer node and then the mono mux if it exists */
3733 if (snd_hda_get_connections(codec,
3734 spec->autocfg.mono_out_pin, conn_list, 1) &&
3735 snd_hda_get_connections(codec, conn_list[0],
3736 conn_list, 1) > 0) {
3738 int wcaps = get_wcaps(codec, conn_list[0]);
3739 int wid_type = get_wcaps_type(wcaps);
3740 /* LR swap check, some stac925x have a mux that
3741 * changes the DACs output path instead of the
3744 if (wid_type == AC_WID_AUD_SEL &&
3745 !(wcaps & AC_WCAP_LR_SWAP))
3746 spec->mono_nid = conn_list[0];
3749 hda_nid_t nid = spec->autocfg.mono_out_pin;
3751 /* most mono outs have a least a mute/unmute switch */
3752 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3753 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3754 "Mono Playback Switch",
3755 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3758 /* check for volume support for the amp */
3759 if ((caps & AC_AMPCAP_NUM_STEPS)
3760 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3761 err = stac92xx_add_control(spec,
3762 STAC_CTL_WIDGET_VOL,
3763 "Mono Playback Volume",
3764 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3770 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3774 if (!spec->multiout.num_dacs) {
3775 err = stac92xx_auto_fill_dac_nids(codec);
3778 err = stac92xx_auto_create_multi_out_ctls(codec,
3784 /* setup analog beep controls */
3785 if (spec->anabeep_nid > 0) {
3786 err = stac92xx_auto_create_beep_ctls(codec,
3792 /* setup digital beep controls and input device */
3793 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3794 if (spec->digbeep_nid > 0) {
3795 hda_nid_t nid = spec->digbeep_nid;
3798 err = stac92xx_auto_create_beep_ctls(codec, nid);
3801 err = snd_hda_attach_beep_device(codec, nid);
3805 /* IDT/STAC codecs have linear beep tone parameter */
3806 codec->beep->linear_tone = spec->linear_tone_beep;
3807 /* if no beep switch is available, make its own one */
3808 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3809 if (!(caps & AC_AMPCAP_MUTE)) {
3810 err = stac92xx_beep_switch_ctl(codec);
3818 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3822 /* All output parsing done, now restore the swapped hp pins */
3824 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3825 sizeof(spec->autocfg.hp_pins));
3826 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3827 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3828 spec->autocfg.line_outs = 0;
3831 if (stac_check_auto_mic(codec)) {
3833 /* only one capture for auto-mic */
3836 spec->num_muxes = 1;
3839 for (i = 0; i < spec->num_caps; i++) {
3840 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3841 spec->capsws[i], i);
3846 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3850 if (spec->mono_nid > 0) {
3851 err = stac92xx_auto_create_mono_output_ctls(codec);
3855 if (spec->num_dmics > 0 && !spec->dinput_mux)
3856 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3857 &spec->autocfg)) < 0)
3859 if (spec->num_muxes > 0) {
3860 err = stac92xx_auto_create_mux_input_ctls(codec);
3864 if (spec->num_smuxes > 0) {
3865 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3870 err = stac92xx_add_input_source(spec);
3874 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3875 if (spec->multiout.max_channels > 2)
3876 spec->surr_switch = 1;
3878 if (spec->autocfg.dig_outs)
3879 spec->multiout.dig_out_nid = dig_out;
3880 if (dig_in && spec->autocfg.dig_in_pin)
3881 spec->dig_in_nid = dig_in;
3883 if (spec->kctls.list)
3884 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3886 spec->input_mux = &spec->private_imux;
3887 if (!spec->dinput_mux)
3888 spec->dinput_mux = &spec->private_dimux;
3889 spec->sinput_mux = &spec->private_smux;
3890 spec->mono_mux = &spec->private_mono_mux;
3894 /* add playback controls for HP output */
3895 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3896 struct auto_pin_cfg *cfg)
3898 struct sigmatel_spec *spec = codec->spec;
3899 hda_nid_t pin = cfg->hp_pins[0];
3900 unsigned int wid_caps;
3905 wid_caps = get_wcaps(codec, pin);
3906 if (wid_caps & AC_WCAP_UNSOL_CAP)
3907 spec->hp_detect = 1;
3912 /* add playback controls for LFE output */
3913 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3914 struct auto_pin_cfg *cfg)
3916 struct sigmatel_spec *spec = codec->spec;
3918 hda_nid_t lfe_pin = 0x0;
3922 * search speaker outs and line outs for a mono speaker pin
3923 * with an amp. If one is found, add LFE controls
3926 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3927 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3928 unsigned int wcaps = get_wcaps(codec, pin);
3929 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3930 if (wcaps == AC_WCAP_OUT_AMP)
3931 /* found a mono speaker with an amp, must be lfe */
3935 /* if speaker_outs is 0, then speakers may be in line_outs */
3936 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3937 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3938 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3939 unsigned int defcfg;
3940 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3941 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3942 unsigned int wcaps = get_wcaps(codec, pin);
3943 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3944 if (wcaps == AC_WCAP_OUT_AMP)
3945 /* found a mono speaker with an amp,
3953 err = create_controls(codec, "LFE", lfe_pin, 1);
3961 static int stac9200_parse_auto_config(struct hda_codec *codec)
3963 struct sigmatel_spec *spec = codec->spec;
3966 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3969 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3972 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3975 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3978 if (spec->num_muxes > 0) {
3979 err = stac92xx_auto_create_mux_input_ctls(codec);
3984 err = stac92xx_add_input_source(spec);
3988 if (spec->autocfg.dig_outs)
3989 spec->multiout.dig_out_nid = 0x05;
3990 if (spec->autocfg.dig_in_pin)
3991 spec->dig_in_nid = 0x04;
3993 if (spec->kctls.list)
3994 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3996 spec->input_mux = &spec->private_imux;
3997 spec->dinput_mux = &spec->private_dimux;
4003 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4004 * funky external mute control using GPIO pins.
4007 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4008 unsigned int dir_mask, unsigned int data)
4010 unsigned int gpiostate, gpiomask, gpiodir;
4012 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4013 AC_VERB_GET_GPIO_DATA, 0);
4014 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4016 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4017 AC_VERB_GET_GPIO_MASK, 0);
4020 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4021 AC_VERB_GET_GPIO_DIRECTION, 0);
4022 gpiodir |= dir_mask;
4024 /* Configure GPIOx as CMOS */
4025 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4027 snd_hda_codec_write(codec, codec->afg, 0,
4028 AC_VERB_SET_GPIO_MASK, gpiomask);
4029 snd_hda_codec_read(codec, codec->afg, 0,
4030 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4034 snd_hda_codec_read(codec, codec->afg, 0,
4035 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4038 #ifdef CONFIG_SND_HDA_INPUT_JACK
4039 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4041 struct sigmatel_jack *jacks = jack->private_data;
4047 static int stac92xx_add_jack(struct hda_codec *codec,
4048 hda_nid_t nid, int type)
4050 #ifdef CONFIG_SND_HDA_INPUT_JACK
4051 struct sigmatel_spec *spec = codec->spec;
4052 struct sigmatel_jack *jack;
4053 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4054 int connectivity = get_defcfg_connect(def_conf);
4058 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4061 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4062 jack = snd_array_new(&spec->jacks);
4068 snprintf(name, sizeof(name), "%s at %s %s Jack",
4069 snd_hda_get_jack_type(def_conf),
4070 snd_hda_get_jack_connectivity(def_conf),
4071 snd_hda_get_jack_location(def_conf));
4073 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4078 jack->jack->private_data = jack;
4079 jack->jack->private_free = stac92xx_free_jack_priv;
4084 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4085 unsigned char type, int data)
4087 struct sigmatel_event *event;
4089 snd_array_init(&spec->events, sizeof(*event), 32);
4090 event = snd_array_new(&spec->events);
4095 event->tag = spec->events.used;
4101 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4104 struct sigmatel_spec *spec = codec->spec;
4105 struct sigmatel_event *event = spec->events.list;
4108 for (i = 0; i < spec->events.used; i++, event++) {
4109 if (event->nid == nid)
4115 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4118 struct sigmatel_spec *spec = codec->spec;
4119 struct sigmatel_event *event = spec->events.list;
4122 for (i = 0; i < spec->events.used; i++, event++) {
4123 if (event->tag == tag)
4129 /* check if given nid is a valid pin and no other events are assigned
4130 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4131 * Otherwise, returns zero.
4133 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4136 struct sigmatel_event *event;
4139 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4141 event = stac_get_event(codec, nid);
4143 if (event->type != type)
4147 tag = stac_add_event(codec->spec, nid, type, 0);
4151 snd_hda_codec_write_cache(codec, nid, 0,
4152 AC_VERB_SET_UNSOLICITED_ENABLE,
4157 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4160 for (i = 0; i < cfg->hp_outs; i++)
4161 if (cfg->hp_pins[i] == nid)
4162 return 1; /* nid is a HP-Out */
4164 return 0; /* nid is not a HP-Out */
4167 static void stac92xx_power_down(struct hda_codec *codec)
4169 struct sigmatel_spec *spec = codec->spec;
4171 /* power down inactive DACs */
4173 for (dac = spec->dac_list; *dac; dac++)
4174 if (!check_all_dac_nids(spec, *dac))
4175 snd_hda_codec_write(codec, *dac, 0,
4176 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4179 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4182 static inline int get_int_hint(struct hda_codec *codec, const char *key,
4186 p = snd_hda_get_hint(codec, key);
4189 if (!strict_strtoul(p, 0, &val)) {
4197 /* override some hints from the hwdep entry */
4198 static void stac_store_hints(struct hda_codec *codec)
4200 struct sigmatel_spec *spec = codec->spec;
4203 val = snd_hda_get_bool_hint(codec, "hp_detect");
4205 spec->hp_detect = val;
4206 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
4207 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4210 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4211 spec->gpio_mask &= spec->gpio_mask;
4212 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4213 spec->gpio_dir &= spec->gpio_mask;
4214 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4215 spec->eapd_mask &= spec->gpio_mask;
4216 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4217 spec->gpio_mute &= spec->gpio_mask;
4218 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4220 spec->eapd_switch = val;
4221 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4222 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4223 spec->gpio_mask |= spec->gpio_led;
4224 spec->gpio_dir |= spec->gpio_led;
4225 if (spec->gpio_led_polarity)
4226 spec->gpio_data |= spec->gpio_led;
4230 static int stac92xx_init(struct hda_codec *codec)
4232 struct sigmatel_spec *spec = codec->spec;
4233 struct auto_pin_cfg *cfg = &spec->autocfg;
4237 snd_hda_sequence_write(codec, spec->init);
4239 /* power down adcs initially */
4240 if (spec->powerdown_adcs)
4241 for (i = 0; i < spec->num_adcs; i++)
4242 snd_hda_codec_write(codec,
4243 spec->adc_nids[i], 0,
4244 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4246 /* override some hints */
4247 stac_store_hints(codec);
4250 gpio = spec->gpio_data;
4251 /* turn on EAPD statically when spec->eapd_switch isn't set.
4252 * otherwise, unsol event will turn it on/off dynamically
4254 if (!spec->eapd_switch)
4255 gpio |= spec->eapd_mask;
4256 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4259 if (spec->hp_detect) {
4260 /* Enable unsolicited responses on the HP widget */
4261 for (i = 0; i < cfg->hp_outs; i++) {
4262 hda_nid_t nid = cfg->hp_pins[i];
4263 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4265 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4266 cfg->speaker_outs > 0) {
4267 /* enable pin-detect for line-outs as well */
4268 for (i = 0; i < cfg->line_outs; i++) {
4269 hda_nid_t nid = cfg->line_out_pins[i];
4270 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4274 /* force to enable the first line-out; the others are set up
4277 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4279 /* fake event to set up pins */
4280 if (cfg->hp_pins[0])
4281 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4282 else if (cfg->line_out_pins[0])
4283 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4285 stac92xx_auto_init_multi_out(codec);
4286 stac92xx_auto_init_hp_out(codec);
4287 for (i = 0; i < cfg->hp_outs; i++)
4288 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4290 if (spec->auto_mic) {
4291 /* initialize connection to analog input */
4292 if (spec->dmux_nids)
4293 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4294 AC_VERB_SET_CONNECT_SEL, 0);
4295 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4296 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4298 for (i = 0; i < AUTO_PIN_LAST; i++) {
4299 hda_nid_t nid = cfg->input_pins[i];
4301 unsigned int pinctl, conf;
4302 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4303 /* for mic pins, force to initialize */
4304 pinctl = stac92xx_get_default_vref(codec, nid);
4305 pinctl |= AC_PINCTL_IN_EN;
4306 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4308 pinctl = snd_hda_codec_read(codec, nid, 0,
4309 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4310 /* if PINCTL already set then skip */
4311 /* Also, if both INPUT and OUTPUT are set,
4312 * it must be a BIOS bug; need to override, too
4314 if (!(pinctl & AC_PINCTL_IN_EN) ||
4315 (pinctl & AC_PINCTL_OUT_EN)) {
4316 pinctl &= ~AC_PINCTL_OUT_EN;
4317 pinctl |= AC_PINCTL_IN_EN;
4318 stac92xx_auto_set_pinctl(codec, nid,
4322 conf = snd_hda_codec_get_pincfg(codec, nid);
4323 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4324 if (enable_pin_detect(codec, nid,
4326 stac_issue_unsol_event(codec, nid);
4330 for (i = 0; i < spec->num_dmics; i++)
4331 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4333 if (cfg->dig_out_pins[0])
4334 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4336 if (cfg->dig_in_pin)
4337 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4339 for (i = 0; i < spec->num_pwrs; i++) {
4340 hda_nid_t nid = spec->pwr_nids[i];
4341 int pinctl, def_conf;
4343 /* power on when no jack detection is available */
4344 if (!spec->hp_detect) {
4345 stac_toggle_power_map(codec, nid, 1);
4349 if (is_nid_hp_pin(cfg, nid))
4350 continue; /* already has an unsol event */
4352 pinctl = snd_hda_codec_read(codec, nid, 0,
4353 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4354 /* outputs are only ports capable of power management
4355 * any attempts on powering down a input port cause the
4356 * referenced VREF to act quirky.
4358 if (pinctl & AC_PINCTL_IN_EN) {
4359 stac_toggle_power_map(codec, nid, 1);
4362 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4363 def_conf = get_defcfg_connect(def_conf);
4364 /* skip any ports that don't have jacks since presence
4365 * detection is useless */
4366 if (def_conf != AC_JACK_PORT_COMPLEX) {
4367 if (def_conf != AC_JACK_PORT_NONE)
4368 stac_toggle_power_map(codec, nid, 1);
4371 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4372 stac_issue_unsol_event(codec, nid);
4375 #ifdef CONFIG_SND_HDA_POWER_SAVE
4377 if (spec->gpio_led && codec->patch_ops.check_power_status)
4378 codec->patch_ops.check_power_status(codec, 0x01);
4381 stac92xx_power_down(codec);
4385 static void stac92xx_free_jacks(struct hda_codec *codec)
4387 #ifdef CONFIG_SND_HDA_INPUT_JACK
4388 /* free jack instances manually when clearing/reconfiguring */
4389 struct sigmatel_spec *spec = codec->spec;
4390 if (!codec->bus->shutdown && spec->jacks.list) {
4391 struct sigmatel_jack *jacks = spec->jacks.list;
4393 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4395 snd_device_free(codec->bus->card, jacks->jack);
4398 snd_array_free(&spec->jacks);
4402 static void stac92xx_free_kctls(struct hda_codec *codec)
4404 struct sigmatel_spec *spec = codec->spec;
4406 if (spec->kctls.list) {
4407 struct snd_kcontrol_new *kctl = spec->kctls.list;
4409 for (i = 0; i < spec->kctls.used; i++)
4410 kfree(kctl[i].name);
4412 snd_array_free(&spec->kctls);
4415 static void stac92xx_shutup(struct hda_codec *codec)
4417 struct sigmatel_spec *spec = codec->spec;
4419 snd_hda_shutup_pins(codec);
4421 if (spec->eapd_mask)
4422 stac_gpio_set(codec, spec->gpio_mask,
4423 spec->gpio_dir, spec->gpio_data &
4427 static void stac92xx_free(struct hda_codec *codec)
4429 struct sigmatel_spec *spec = codec->spec;
4434 stac92xx_shutup(codec);
4435 stac92xx_free_jacks(codec);
4436 snd_array_free(&spec->events);
4439 snd_hda_detach_beep_device(codec);
4442 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4445 unsigned int old_ctl, pin_ctl;
4447 pin_ctl = snd_hda_codec_read(codec, nid,
4448 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4450 if (pin_ctl & AC_PINCTL_IN_EN) {
4452 * we need to check the current set-up direction of
4453 * shared input pins since they can be switched via
4454 * "xxx as Output" mixer switch
4456 struct sigmatel_spec *spec = codec->spec;
4457 if (nid == spec->line_switch || nid == spec->mic_switch)
4462 /* if setting pin direction bits, clear the current
4463 direction bits first */
4464 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4465 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4468 if (old_ctl != pin_ctl)
4469 snd_hda_codec_write_cache(codec, nid, 0,
4470 AC_VERB_SET_PIN_WIDGET_CONTROL,
4474 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4477 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4478 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4480 snd_hda_codec_write_cache(codec, nid, 0,
4481 AC_VERB_SET_PIN_WIDGET_CONTROL,
4485 static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4489 return snd_hda_jack_detect(codec, nid);
4492 static void stac92xx_line_out_detect(struct hda_codec *codec,
4495 struct sigmatel_spec *spec = codec->spec;
4496 struct auto_pin_cfg *cfg = &spec->autocfg;
4499 for (i = 0; i < cfg->line_outs; i++) {
4502 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4504 unsigned int pinctl;
4505 pinctl = snd_hda_codec_read(codec,
4506 cfg->line_out_pins[i], 0,
4507 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4508 if (pinctl & AC_PINCTL_IN_EN)
4509 presence = 0; /* mic- or line-input */
4514 /* disable speakers */
4515 for (i = 0; i < cfg->speaker_outs; i++)
4516 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4518 if (spec->eapd_mask && spec->eapd_switch)
4519 stac_gpio_set(codec, spec->gpio_mask,
4520 spec->gpio_dir, spec->gpio_data &
4523 /* enable speakers */
4524 for (i = 0; i < cfg->speaker_outs; i++)
4525 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4527 if (spec->eapd_mask && spec->eapd_switch)
4528 stac_gpio_set(codec, spec->gpio_mask,
4529 spec->gpio_dir, spec->gpio_data |
4534 /* return non-zero if the hp-pin of the given array index isn't
4535 * a jack-detection target
4537 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4539 struct auto_pin_cfg *cfg = &spec->autocfg;
4541 /* ignore sensing of shared line and mic jacks */
4542 if (cfg->hp_pins[i] == spec->line_switch)
4544 if (cfg->hp_pins[i] == spec->mic_switch)
4546 /* ignore if the pin is set as line-out */
4547 if (cfg->hp_pins[i] == spec->hp_switch)
4552 static void stac92xx_hp_detect(struct hda_codec *codec)
4554 struct sigmatel_spec *spec = codec->spec;
4555 struct auto_pin_cfg *cfg = &spec->autocfg;
4559 if (spec->gpio_mute)
4560 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4561 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4563 for (i = 0; i < cfg->hp_outs; i++) {
4566 if (no_hp_sensing(spec, i))
4568 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4570 unsigned int pinctl;
4571 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4572 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4573 if (pinctl & AC_PINCTL_IN_EN)
4574 presence = 0; /* mic- or line-input */
4579 /* disable lineouts */
4580 if (spec->hp_switch)
4581 stac92xx_reset_pinctl(codec, spec->hp_switch,
4583 for (i = 0; i < cfg->line_outs; i++)
4584 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4587 /* enable lineouts */
4588 if (spec->hp_switch)
4589 stac92xx_set_pinctl(codec, spec->hp_switch,
4591 for (i = 0; i < cfg->line_outs; i++)
4592 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4595 stac92xx_line_out_detect(codec, presence);
4596 /* toggle hp outs */
4597 for (i = 0; i < cfg->hp_outs; i++) {
4598 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4599 if (no_hp_sensing(spec, i))
4602 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4604 /* Resetting the pinctl like below may lead to (a sort of) regressions
4605 * on some devices since they use the HP pin actually for line/speaker
4606 * outs although the default pin config shows a different pin (that is
4607 * wrong and useless).
4609 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4610 * But, disabling the code below just works around it, and I'm too tired of
4611 * bug reports with such devices...
4614 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4619 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4622 struct sigmatel_spec *spec = codec->spec;
4623 unsigned int idx, val;
4625 for (idx = 0; idx < spec->num_pwrs; idx++) {
4626 if (spec->pwr_nids[idx] == nid)
4629 if (idx >= spec->num_pwrs)
4632 /* several codecs have two power down bits */
4633 if (spec->pwr_mapping)
4634 idx = spec->pwr_mapping[idx];
4638 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4644 /* power down unused output ports */
4645 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4648 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4650 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4653 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4655 struct sigmatel_spec *spec = codec->spec;
4656 struct sigmatel_jack *jacks = spec->jacks.list;
4660 for (i = 0; i < spec->jacks.used; i++) {
4661 if (jacks->nid == nid) {
4662 unsigned int pin_ctl =
4663 snd_hda_codec_read(codec, nid,
4664 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4666 int type = jacks->type;
4667 if (type == (SND_JACK_LINEOUT
4668 | SND_JACK_HEADPHONE))
4669 type = (pin_ctl & AC_PINCTL_HP_EN)
4670 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4671 snd_jack_report(jacks->jack,
4672 get_pin_presence(codec, nid)
4680 static void stac92xx_mic_detect(struct hda_codec *codec)
4682 struct sigmatel_spec *spec = codec->spec;
4683 struct sigmatel_mic_route *mic;
4685 if (get_pin_presence(codec, spec->ext_mic.pin))
4686 mic = &spec->ext_mic;
4688 mic = &spec->int_mic;
4689 if (mic->dmux_idx >= 0)
4690 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4691 AC_VERB_SET_CONNECT_SEL,
4693 if (mic->mux_idx >= 0)
4694 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4695 AC_VERB_SET_CONNECT_SEL,
4699 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4701 struct sigmatel_event *event = stac_get_event(codec, nid);
4704 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4707 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4709 struct sigmatel_spec *spec = codec->spec;
4710 struct sigmatel_event *event;
4713 tag = (res >> 26) & 0x7f;
4714 event = stac_get_event_from_tag(codec, tag);
4718 switch (event->type) {
4721 stac92xx_hp_detect(codec);
4723 case STAC_MIC_EVENT:
4724 stac92xx_mic_detect(codec);
4728 switch (event->type) {
4731 case STAC_MIC_EVENT:
4732 case STAC_INSERT_EVENT:
4733 case STAC_PWR_EVENT:
4734 if (spec->num_pwrs > 0)
4735 stac92xx_pin_sense(codec, event->nid);
4736 stac92xx_report_jack(codec, event->nid);
4738 switch (codec->subsystem_id) {
4740 if (event->nid == 0xb) {
4741 int pin = AC_PINCTL_IN_EN;
4743 if (get_pin_presence(codec, 0xa)
4744 && get_pin_presence(codec, 0xb))
4745 pin |= AC_PINCTL_VREF_80;
4746 if (!get_pin_presence(codec, 0xb))
4747 pin |= AC_PINCTL_VREF_80;
4749 /* toggle VREF state based on mic + hp pin
4752 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4756 case STAC_VREF_EVENT:
4757 data = snd_hda_codec_read(codec, codec->afg, 0,
4758 AC_VERB_GET_GPIO_DATA, 0);
4759 /* toggle VREF state based on GPIOx status */
4760 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4761 !!(data & (1 << event->data)));
4766 static int hp_blike_system(u32 subsystem_id);
4768 static void set_hp_led_gpio(struct hda_codec *codec)
4770 struct sigmatel_spec *spec = codec->spec;
4776 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4777 gpio &= AC_GPIO_IO_COUNT;
4779 spec->gpio_led = 0x08; /* GPIO 3 */
4781 spec->gpio_led = 0x01; /* GPIO 0 */
4785 * This method searches for the mute LED GPIO configuration
4786 * provided as OEM string in SMBIOS. The format of that string
4787 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4788 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4789 * that corresponds to the NOT muted state of the master volume
4790 * and G is the index of the GPIO to use as the mute LED control (0..9)
4791 * If _G portion is missing it is assigned based on the codec ID
4793 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4794 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4797 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4798 * SMBIOS - at least the ones I have seen do not have them - which include
4799 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4800 * HP Pavilion dv9500t CTO.
4801 * Need more information on whether it is true across the entire series.
4804 static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4806 struct sigmatel_spec *spec = codec->spec;
4807 const struct dmi_device *dev = NULL;
4809 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4810 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4812 if (sscanf(dev->name, "HP_Mute_LED_%d_%d",
4813 &spec->gpio_led_polarity,
4814 &spec->gpio_led) == 2) {
4815 spec->gpio_led = 1 << spec->gpio_led;
4818 if (sscanf(dev->name, "HP_Mute_LED_%d",
4819 &spec->gpio_led_polarity) == 1) {
4820 set_hp_led_gpio(codec);
4826 * Fallback case - if we don't find the DMI strings,
4827 * we statically set the GPIO - if not a B-series system.
4829 if (!hp_blike_system(codec->subsystem_id)) {
4830 set_hp_led_gpio(codec);
4831 spec->gpio_led_polarity = default_polarity;
4838 static int hp_blike_system(u32 subsystem_id)
4840 switch (subsystem_id) {
4867 #ifdef CONFIG_PROC_FS
4868 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4869 struct hda_codec *codec, hda_nid_t nid)
4871 if (nid == codec->afg)
4872 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4873 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4876 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4877 struct hda_codec *codec,
4880 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4881 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4884 /* stac92hd71bxx, stac92hd73xx */
4885 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4886 struct hda_codec *codec, hda_nid_t nid)
4888 stac92hd_proc_hook(buffer, codec, nid);
4889 if (nid == codec->afg)
4890 analog_loop_proc_hook(buffer, codec, 0xfa0);
4893 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4894 struct hda_codec *codec, hda_nid_t nid)
4896 if (nid == codec->afg)
4897 analog_loop_proc_hook(buffer, codec, 0xfe0);
4900 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4901 struct hda_codec *codec, hda_nid_t nid)
4903 if (nid == codec->afg)
4904 analog_loop_proc_hook(buffer, codec, 0xfeb);
4907 #define stac92hd_proc_hook NULL
4908 #define stac92hd7x_proc_hook NULL
4909 #define stac9205_proc_hook NULL
4910 #define stac927x_proc_hook NULL
4913 #ifdef SND_HDA_NEEDS_RESUME
4914 static int stac92xx_resume(struct hda_codec *codec)
4916 struct sigmatel_spec *spec = codec->spec;
4918 stac92xx_init(codec);
4919 snd_hda_codec_resume_amp(codec);
4920 snd_hda_codec_resume_cache(codec);
4921 /* fake event to set up pins again to override cached values */
4922 if (spec->hp_detect) {
4923 if (spec->autocfg.hp_pins[0])
4924 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4925 else if (spec->autocfg.line_out_pins[0])
4926 stac_issue_unsol_event(codec,
4927 spec->autocfg.line_out_pins[0]);
4929 #ifdef CONFIG_SND_HDA_POWER_SAVE
4931 if (spec->gpio_led && codec->patch_ops.check_power_status)
4932 codec->patch_ops.check_power_status(codec, 0x01);
4938 * using power check for controlling mute led of HP notebooks
4939 * check for mute state only on Speakers (nid = 0x10)
4941 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4942 * the LED is NOT working properly !
4944 * Changed name to reflect that it now works for any designated
4945 * model, not just HP HDX.
4948 #ifdef CONFIG_SND_HDA_POWER_SAVE
4949 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4952 struct sigmatel_spec *spec = codec->spec;
4955 for (i = 0; i < spec->multiout.num_dacs; i++) {
4956 nid = spec->multiout.dac_nids[i];
4957 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4959 muted = 0; /* something heard */
4964 spec->gpio_data &= ~spec->gpio_led; /* orange */
4966 spec->gpio_data |= spec->gpio_led; /* white */
4968 if (!spec->gpio_led_polarity) {
4969 /* LED state is inverted on these systems */
4970 spec->gpio_data ^= spec->gpio_led;
4973 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
4978 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4980 stac92xx_shutup(codec);
4985 static struct hda_codec_ops stac92xx_patch_ops = {
4986 .build_controls = stac92xx_build_controls,
4987 .build_pcms = stac92xx_build_pcms,
4988 .init = stac92xx_init,
4989 .free = stac92xx_free,
4990 .unsol_event = stac92xx_unsol_event,
4991 #ifdef SND_HDA_NEEDS_RESUME
4992 .suspend = stac92xx_suspend,
4993 .resume = stac92xx_resume,
4995 .reboot_notify = stac92xx_shutup,
4998 static int patch_stac9200(struct hda_codec *codec)
5000 struct sigmatel_spec *spec;
5003 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5007 codec->no_trigger_sense = 1;
5009 spec->linear_tone_beep = 1;
5010 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
5011 spec->pin_nids = stac9200_pin_nids;
5012 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5015 if (spec->board_config < 0)
5016 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5019 stac92xx_set_config_regs(codec,
5020 stac9200_brd_tbl[spec->board_config]);
5022 spec->multiout.max_channels = 2;
5023 spec->multiout.num_dacs = 1;
5024 spec->multiout.dac_nids = stac9200_dac_nids;
5025 spec->adc_nids = stac9200_adc_nids;
5026 spec->mux_nids = stac9200_mux_nids;
5027 spec->num_muxes = 1;
5028 spec->num_dmics = 0;
5032 if (spec->board_config == STAC_9200_M4 ||
5033 spec->board_config == STAC_9200_M4_2 ||
5034 spec->board_config == STAC_9200_OQO)
5035 spec->init = stac9200_eapd_init;
5037 spec->init = stac9200_core_init;
5038 spec->mixer = stac9200_mixer;
5040 if (spec->board_config == STAC_9200_PANASONIC) {
5041 spec->gpio_mask = spec->gpio_dir = 0x09;
5042 spec->gpio_data = 0x00;
5045 err = stac9200_parse_auto_config(codec);
5047 stac92xx_free(codec);
5051 /* CF-74 has no headphone detection, and the driver should *NOT*
5052 * do detection and HP/speaker toggle because the hardware does it.
5054 if (spec->board_config == STAC_9200_PANASONIC)
5055 spec->hp_detect = 0;
5057 codec->patch_ops = stac92xx_patch_ops;
5062 static int patch_stac925x(struct hda_codec *codec)
5064 struct sigmatel_spec *spec;
5067 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5071 codec->no_trigger_sense = 1;
5073 spec->linear_tone_beep = 1;
5074 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
5075 spec->pin_nids = stac925x_pin_nids;
5077 /* Check first for codec ID */
5078 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5081 stac925x_codec_id_cfg_tbl);
5083 /* Now checks for PCI ID, if codec ID is not found */
5084 if (spec->board_config < 0)
5085 spec->board_config = snd_hda_check_board_config(codec,
5090 if (spec->board_config < 0)
5091 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5094 stac92xx_set_config_regs(codec,
5095 stac925x_brd_tbl[spec->board_config]);
5097 spec->multiout.max_channels = 2;
5098 spec->multiout.num_dacs = 1;
5099 spec->multiout.dac_nids = stac925x_dac_nids;
5100 spec->adc_nids = stac925x_adc_nids;
5101 spec->mux_nids = stac925x_mux_nids;
5102 spec->num_muxes = 1;
5105 switch (codec->vendor_id) {
5106 case 0x83847632: /* STAC9202 */
5107 case 0x83847633: /* STAC9202D */
5108 case 0x83847636: /* STAC9251 */
5109 case 0x83847637: /* STAC9251D */
5110 spec->num_dmics = STAC925X_NUM_DMICS;
5111 spec->dmic_nids = stac925x_dmic_nids;
5112 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5113 spec->dmux_nids = stac925x_dmux_nids;
5116 spec->num_dmics = 0;
5120 spec->init = stac925x_core_init;
5121 spec->mixer = stac925x_mixer;
5123 spec->capvols = stac925x_capvols;
5124 spec->capsws = stac925x_capsws;
5126 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
5128 if (spec->board_config < 0) {
5129 printk(KERN_WARNING "hda_codec: No auto-config is "
5130 "available, default to model=ref\n");
5131 spec->board_config = STAC_925x_REF;
5137 stac92xx_free(codec);
5141 codec->patch_ops = stac92xx_patch_ops;
5146 static int patch_stac92hd73xx(struct hda_codec *codec)
5148 struct sigmatel_spec *spec;
5149 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5153 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5157 codec->no_trigger_sense = 1;
5159 spec->linear_tone_beep = 0;
5160 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5161 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5162 spec->pin_nids = stac92hd73xx_pin_nids;
5163 spec->board_config = snd_hda_check_board_config(codec,
5164 STAC_92HD73XX_MODELS,
5165 stac92hd73xx_models,
5166 stac92hd73xx_cfg_tbl);
5167 /* check codec subsystem id if not found */
5168 if (spec->board_config < 0)
5169 spec->board_config =
5170 snd_hda_check_board_codec_sid_config(codec,
5171 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5172 stac92hd73xx_codec_id_cfg_tbl);
5174 if (spec->board_config < 0)
5175 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5178 stac92xx_set_config_regs(codec,
5179 stac92hd73xx_brd_tbl[spec->board_config]);
5181 num_dacs = snd_hda_get_connections(codec, 0x0a,
5182 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5184 if (num_dacs < 3 || num_dacs > 5) {
5185 printk(KERN_WARNING "hda_codec: Could not determine "
5186 "number of channels defaulting to DAC count\n");
5187 num_dacs = STAC92HD73_DAC_COUNT;
5189 spec->init = stac92hd73xx_core_init;
5191 case 0x3: /* 6 Channel */
5192 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5194 case 0x4: /* 8 Channel */
5195 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5197 case 0x5: /* 10 Channel */
5198 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5201 spec->multiout.dac_nids = spec->dac_nids;
5203 spec->aloopback_mask = 0x01;
5204 spec->aloopback_shift = 8;
5206 spec->digbeep_nid = 0x1c;
5207 spec->mux_nids = stac92hd73xx_mux_nids;
5208 spec->adc_nids = stac92hd73xx_adc_nids;
5209 spec->dmic_nids = stac92hd73xx_dmic_nids;
5210 spec->dmux_nids = stac92hd73xx_dmux_nids;
5211 spec->smux_nids = stac92hd73xx_smux_nids;
5213 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5214 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5215 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5217 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5218 spec->capvols = stac92hd73xx_capvols;
5219 spec->capsws = stac92hd73xx_capsws;
5221 switch (spec->board_config) {
5223 spec->init = dell_eq_core_init;
5225 case STAC_DELL_M6_AMIC:
5226 case STAC_DELL_M6_DMIC:
5227 case STAC_DELL_M6_BOTH:
5228 spec->num_smuxes = 0;
5229 spec->eapd_switch = 0;
5231 switch (spec->board_config) {
5232 case STAC_DELL_M6_AMIC: /* Analog Mics */
5233 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5234 spec->num_dmics = 0;
5236 case STAC_DELL_M6_DMIC: /* Digital Mics */
5237 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5238 spec->num_dmics = 1;
5240 case STAC_DELL_M6_BOTH: /* Both */
5241 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5242 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5243 spec->num_dmics = 1;
5247 case STAC_ALIENWARE_M17X:
5248 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5249 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5250 spec->eapd_switch = 0;
5253 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5254 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5255 spec->eapd_switch = 1;
5258 if (spec->board_config != STAC_92HD73XX_REF) {
5259 /* GPIO0 High = Enable EAPD */
5260 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5261 spec->gpio_data = 0x01;
5264 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5265 spec->pwr_nids = stac92hd73xx_pwr_nids;
5267 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5270 if (spec->board_config < 0) {
5271 printk(KERN_WARNING "hda_codec: No auto-config is "
5272 "available, default to model=ref\n");
5273 spec->board_config = STAC_92HD73XX_REF;
5280 stac92xx_free(codec);
5284 if (spec->board_config == STAC_92HD73XX_NO_JD)
5285 spec->hp_detect = 0;
5287 codec->patch_ops = stac92xx_patch_ops;
5289 codec->proc_widget_hook = stac92hd7x_proc_hook;
5294 static int patch_stac92hd83xxx(struct hda_codec *codec)
5296 struct sigmatel_spec *spec;
5297 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5301 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5305 codec->no_trigger_sense = 1;
5307 spec->linear_tone_beep = 1;
5308 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5309 spec->digbeep_nid = 0x21;
5310 spec->mux_nids = stac92hd83xxx_mux_nids;
5311 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5312 spec->adc_nids = stac92hd83xxx_adc_nids;
5313 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5314 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5315 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5316 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5317 spec->multiout.dac_nids = spec->dac_nids;
5319 spec->init = stac92hd83xxx_core_init;
5320 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5321 spec->pin_nids = stac92hd83xxx_pin_nids;
5322 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5323 spec->capvols = stac92hd83xxx_capvols;
5324 spec->capsws = stac92hd83xxx_capsws;
5326 spec->board_config = snd_hda_check_board_config(codec,
5327 STAC_92HD83XXX_MODELS,
5328 stac92hd83xxx_models,
5329 stac92hd83xxx_cfg_tbl);
5331 if (spec->board_config < 0)
5332 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5335 stac92xx_set_config_regs(codec,
5336 stac92hd83xxx_brd_tbl[spec->board_config]);
5338 switch (codec->vendor_id) {
5343 spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids);
5344 spec->pin_nids = stac92hd88xxx_pin_nids;
5346 spec->digbeep_nid = 0;
5353 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5359 codec->patch_ops = stac92xx_patch_ops;
5361 if (find_mute_led_gpio(codec, 0))
5362 snd_printd("mute LED gpio %d polarity %d\n",
5364 spec->gpio_led_polarity);
5366 #ifdef CONFIG_SND_HDA_POWER_SAVE
5367 if (spec->gpio_led) {
5368 spec->gpio_mask |= spec->gpio_led;
5369 spec->gpio_dir |= spec->gpio_led;
5370 spec->gpio_data |= spec->gpio_led;
5371 /* register check_power_status callback. */
5372 codec->patch_ops.check_power_status =
5373 stac92xx_hp_check_power_status;
5377 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5379 if (spec->board_config < 0) {
5380 printk(KERN_WARNING "hda_codec: No auto-config is "
5381 "available, default to model=ref\n");
5382 spec->board_config = STAC_92HD83XXX_REF;
5389 stac92xx_free(codec);
5393 /* docking output support */
5394 num_dacs = snd_hda_get_connections(codec, 0xF,
5395 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5396 /* skip non-DAC connections */
5397 while (num_dacs >= 0 &&
5398 (get_wcaps_type(get_wcaps(codec, conn[num_dacs]))
5401 /* set port E and F to select the last DAC */
5402 if (num_dacs >= 0) {
5403 snd_hda_codec_write_cache(codec, 0xE, 0,
5404 AC_VERB_SET_CONNECT_SEL, num_dacs);
5405 snd_hda_codec_write_cache(codec, 0xF, 0,
5406 AC_VERB_SET_CONNECT_SEL, num_dacs);
5409 codec->proc_widget_hook = stac92hd_proc_hook;
5414 /* get the pin connection (fixed, none, etc) */
5415 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5417 struct sigmatel_spec *spec = codec->spec;
5420 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5421 return get_defcfg_connect(cfg);
5424 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5425 hda_nid_t *nids, int num_nids)
5427 struct sigmatel_spec *spec = codec->spec;
5429 unsigned int def_conf;
5431 for (num = 0; num < num_nids; num++) {
5432 for (idx = 0; idx < spec->num_pins; idx++)
5433 if (spec->pin_nids[idx] == nids[num])
5435 if (idx >= spec->num_pins)
5437 def_conf = stac_get_defcfg_connect(codec, idx);
5438 if (def_conf == AC_JACK_PORT_NONE)
5444 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5447 struct sigmatel_spec *spec = codec->spec;
5450 for (idx = 0; idx < spec->num_pins; idx++)
5451 if (spec->pin_nids[idx] == dig0pin)
5453 if ((idx + 2) >= spec->num_pins)
5457 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5460 /* dig0pin + dig2pin case */
5461 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5463 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5469 /* HP dv7 bass switch - GPIO5 */
5470 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5471 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5472 struct snd_ctl_elem_value *ucontrol)
5474 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5475 struct sigmatel_spec *spec = codec->spec;
5476 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5480 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5481 struct snd_ctl_elem_value *ucontrol)
5483 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5484 struct sigmatel_spec *spec = codec->spec;
5485 unsigned int gpio_data;
5487 gpio_data = (spec->gpio_data & ~0x20) |
5488 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5489 if (gpio_data == spec->gpio_data)
5491 spec->gpio_data = gpio_data;
5492 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5496 static struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
5497 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5498 .info = stac_hp_bass_gpio_info,
5499 .get = stac_hp_bass_gpio_get,
5500 .put = stac_hp_bass_gpio_put,
5503 static int stac_add_hp_bass_switch(struct hda_codec *codec)
5505 struct sigmatel_spec *spec = codec->spec;
5507 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5508 "Bass Speaker Playback Switch", 0))
5511 spec->gpio_mask |= 0x20;
5512 spec->gpio_dir |= 0x20;
5513 spec->gpio_data |= 0x20;
5517 static int patch_stac92hd71bxx(struct hda_codec *codec)
5519 struct sigmatel_spec *spec;
5520 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5521 unsigned int pin_cfg;
5524 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5528 codec->no_trigger_sense = 1;
5530 spec->linear_tone_beep = 0;
5531 codec->patch_ops = stac92xx_patch_ops;
5532 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5533 switch (codec->vendor_id) {
5536 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5540 /* On 92HD75Bx 0x27 isn't a pin nid */
5544 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5546 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5547 spec->board_config = snd_hda_check_board_config(codec,
5548 STAC_92HD71BXX_MODELS,
5549 stac92hd71bxx_models,
5550 stac92hd71bxx_cfg_tbl);
5552 if (spec->board_config < 0)
5553 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5556 stac92xx_set_config_regs(codec,
5557 stac92hd71bxx_brd_tbl[spec->board_config]);
5559 if (spec->board_config != STAC_92HD71BXX_REF) {
5561 spec->gpio_mask = 0x01;
5562 spec->gpio_dir = 0x01;
5563 spec->gpio_data = 0x01;
5566 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5567 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5569 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5570 spec->capvols = stac92hd71bxx_capvols;
5571 spec->capsws = stac92hd71bxx_capsws;
5573 switch (codec->vendor_id) {
5574 case 0x111d76b6: /* 4 Port without Analog Mixer */
5578 case 0x111d76b4: /* 6 Port without Analog Mixer */
5580 spec->init = stac92hd71bxx_core_init;
5581 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5582 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5583 stac92hd71bxx_dmic_nids,
5584 STAC92HD71BXX_NUM_DMICS);
5586 case 0x111d7608: /* 5 Port with Analog Mixer */
5587 switch (spec->board_config) {
5589 /* Enable VREF power saving on GPIO1 detect */
5590 err = stac_add_event(spec, codec->afg,
5591 STAC_VREF_EVENT, 0x02);
5594 snd_hda_codec_write_cache(codec, codec->afg, 0,
5595 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5596 snd_hda_codec_write_cache(codec, codec->afg, 0,
5597 AC_VERB_SET_UNSOLICITED_ENABLE,
5599 spec->gpio_mask |= 0x02;
5602 if ((codec->revision_id & 0xf) == 0 ||
5603 (codec->revision_id & 0xf) == 1)
5604 spec->stream_delay = 40; /* 40 milliseconds */
5606 /* no output amps */
5609 spec->init = stac92hd71bxx_core_init;
5611 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5612 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5613 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5614 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5615 stac92hd71bxx_dmic_nids,
5616 STAC92HD71BXX_NUM_DMICS - 1);
5618 case 0x111d7603: /* 6 Port with Analog Mixer */
5619 if ((codec->revision_id & 0xf) == 1)
5620 spec->stream_delay = 40; /* 40 milliseconds */
5622 /* no output amps */
5626 spec->init = stac92hd71bxx_core_init;
5627 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5628 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5629 stac92hd71bxx_dmic_nids,
5630 STAC92HD71BXX_NUM_DMICS);
5634 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5635 snd_hda_sequence_write_cache(codec, unmute_init);
5637 /* Some HP machines seem to have unstable codec communications
5638 * especially with ATI fglrx driver. For recovering from the
5639 * CORB/RIRB stall, allow the BUS reset and keep always sync
5641 if (spec->board_config == STAC_HP_DV5) {
5642 codec->bus->sync_write = 1;
5643 codec->bus->allow_bus_reset = 1;
5646 spec->aloopback_ctl = stac92hd71bxx_loopback;
5647 spec->aloopback_mask = 0x50;
5648 spec->aloopback_shift = 0;
5650 spec->powerdown_adcs = 1;
5651 spec->digbeep_nid = 0x26;
5652 spec->mux_nids = stac92hd71bxx_mux_nids;
5653 spec->adc_nids = stac92hd71bxx_adc_nids;
5654 spec->smux_nids = stac92hd71bxx_smux_nids;
5655 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5657 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5658 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5659 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5660 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5662 snd_printdd("Found board config: %d\n", spec->board_config);
5664 switch (spec->board_config) {
5666 /* enable internal microphone */
5667 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5668 stac92xx_auto_set_pinctl(codec, 0x0e,
5669 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5671 case STAC_DELL_M4_2:
5672 spec->num_dmics = 0;
5673 spec->num_smuxes = 0;
5674 spec->num_dmuxes = 0;
5676 case STAC_DELL_M4_1:
5677 case STAC_DELL_M4_3:
5678 spec->num_dmics = 1;
5679 spec->num_smuxes = 0;
5680 spec->num_dmuxes = 1;
5682 case STAC_HP_DV4_1222NR:
5683 spec->num_dmics = 1;
5684 /* I don't know if it needs 1 or 2 smuxes - will wait for
5685 * bug reports to fix if needed
5687 spec->num_smuxes = 1;
5688 spec->num_dmuxes = 1;
5691 spec->gpio_led = 0x01;
5694 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5695 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5696 /* HP dv6 gives the headphone pin as a line-out. Thus we
5697 * need to set hp_detect flag here to force to enable HP
5700 spec->hp_detect = 1;
5703 spec->num_dmics = 1;
5704 spec->num_dmuxes = 1;
5705 spec->num_smuxes = 1;
5706 spec->gpio_led = 0x08;
5710 if (hp_blike_system(codec->subsystem_id)) {
5711 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5712 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5713 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5714 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5715 /* It was changed in the BIOS to just satisfy MS DTM.
5716 * Lets turn it back into slaved HP
5718 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5719 | (AC_JACK_HP_OUT <<
5720 AC_DEFCFG_DEVICE_SHIFT);
5721 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5722 | AC_DEFCFG_SEQUENCE)))
5724 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5728 if (find_mute_led_gpio(codec, 1))
5729 snd_printd("mute LED gpio %d polarity %d\n",
5731 spec->gpio_led_polarity);
5733 #ifdef CONFIG_SND_HDA_POWER_SAVE
5734 if (spec->gpio_led) {
5735 spec->gpio_mask |= spec->gpio_led;
5736 spec->gpio_dir |= spec->gpio_led;
5737 spec->gpio_data |= spec->gpio_led;
5738 /* register check_power_status callback. */
5739 codec->patch_ops.check_power_status =
5740 stac92xx_hp_check_power_status;
5744 spec->multiout.dac_nids = spec->dac_nids;
5746 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5748 if (spec->board_config < 0) {
5749 printk(KERN_WARNING "hda_codec: No auto-config is "
5750 "available, default to model=ref\n");
5751 spec->board_config = STAC_92HD71BXX_REF;
5758 stac92xx_free(codec);
5762 /* enable bass on HP dv7 */
5763 if (spec->board_config == STAC_HP_DV4 ||
5764 spec->board_config == STAC_HP_DV5) {
5766 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5767 cap &= AC_GPIO_IO_COUNT;
5769 stac_add_hp_bass_switch(codec);
5772 codec->proc_widget_hook = stac92hd7x_proc_hook;
5777 static int patch_stac922x(struct hda_codec *codec)
5779 struct sigmatel_spec *spec;
5782 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5786 codec->no_trigger_sense = 1;
5788 spec->linear_tone_beep = 1;
5789 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5790 spec->pin_nids = stac922x_pin_nids;
5791 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5794 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5795 spec->gpio_mask = spec->gpio_dir = 0x03;
5796 spec->gpio_data = 0x03;
5797 /* Intel Macs have all same PCI SSID, so we need to check
5798 * codec SSID to distinguish the exact models
5800 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5801 switch (codec->subsystem_id) {
5804 spec->board_config = STAC_INTEL_MAC_V1;
5808 spec->board_config = STAC_INTEL_MAC_V2;
5816 spec->board_config = STAC_INTEL_MAC_V3;
5820 spec->board_config = STAC_INTEL_MAC_V4;
5824 spec->board_config = STAC_INTEL_MAC_V5;
5827 spec->board_config = STAC_INTEL_MAC_V3;
5833 if (spec->board_config < 0)
5834 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5837 stac92xx_set_config_regs(codec,
5838 stac922x_brd_tbl[spec->board_config]);
5840 spec->adc_nids = stac922x_adc_nids;
5841 spec->mux_nids = stac922x_mux_nids;
5842 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5843 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5844 spec->num_dmics = 0;
5847 spec->init = stac922x_core_init;
5849 spec->num_caps = STAC922X_NUM_CAPS;
5850 spec->capvols = stac922x_capvols;
5851 spec->capsws = stac922x_capsws;
5853 spec->multiout.dac_nids = spec->dac_nids;
5855 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5857 if (spec->board_config < 0) {
5858 printk(KERN_WARNING "hda_codec: No auto-config is "
5859 "available, default to model=ref\n");
5860 spec->board_config = STAC_D945_REF;
5866 stac92xx_free(codec);
5870 codec->patch_ops = stac92xx_patch_ops;
5872 /* Fix Mux capture level; max to 2 */
5873 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5874 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5875 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5876 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5877 (0 << AC_AMPCAP_MUTE_SHIFT));
5882 static int patch_stac927x(struct hda_codec *codec)
5884 struct sigmatel_spec *spec;
5887 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5891 codec->no_trigger_sense = 1;
5893 spec->linear_tone_beep = 1;
5894 codec->slave_dig_outs = stac927x_slave_dig_outs;
5895 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5896 spec->pin_nids = stac927x_pin_nids;
5897 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5901 if (spec->board_config < 0)
5902 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5905 stac92xx_set_config_regs(codec,
5906 stac927x_brd_tbl[spec->board_config]);
5908 spec->digbeep_nid = 0x23;
5909 spec->adc_nids = stac927x_adc_nids;
5910 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5911 spec->mux_nids = stac927x_mux_nids;
5912 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5913 spec->smux_nids = stac927x_smux_nids;
5914 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5915 spec->spdif_labels = stac927x_spdif_labels;
5916 spec->dac_list = stac927x_dac_nids;
5917 spec->multiout.dac_nids = spec->dac_nids;
5919 if (spec->board_config != STAC_D965_REF) {
5920 /* GPIO0 High = Enable EAPD */
5921 spec->eapd_mask = spec->gpio_mask = 0x01;
5922 spec->gpio_dir = spec->gpio_data = 0x01;
5925 switch (spec->board_config) {
5928 /* GPIO0 High = Enable EAPD */
5929 spec->num_dmics = 0;
5930 spec->init = d965_core_init;
5932 case STAC_DELL_BIOS:
5933 switch (codec->subsystem_id) {
5936 /* correct the device field to SPDIF out */
5937 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5940 /* configure the analog microphone on some laptops */
5941 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5942 /* correct the front output jack as a hp out */
5943 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5944 /* correct the front input jack as a mic */
5945 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5948 if (codec->subsystem_id != 0x1028022f) {
5949 /* GPIO2 High = Enable EAPD */
5950 spec->eapd_mask = spec->gpio_mask = 0x04;
5951 spec->gpio_dir = spec->gpio_data = 0x04;
5953 spec->dmic_nids = stac927x_dmic_nids;
5954 spec->num_dmics = STAC927X_NUM_DMICS;
5956 spec->init = dell_3st_core_init;
5957 spec->dmux_nids = stac927x_dmux_nids;
5958 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5960 case STAC_927X_VOLKNOB:
5961 spec->num_dmics = 0;
5962 spec->init = stac927x_volknob_core_init;
5965 spec->num_dmics = 0;
5966 spec->init = stac927x_core_init;
5970 spec->num_caps = STAC927X_NUM_CAPS;
5971 spec->capvols = stac927x_capvols;
5972 spec->capsws = stac927x_capsws;
5975 spec->aloopback_ctl = stac927x_loopback;
5976 spec->aloopback_mask = 0x40;
5977 spec->aloopback_shift = 0;
5978 spec->eapd_switch = 1;
5980 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5982 if (spec->board_config < 0) {
5983 printk(KERN_WARNING "hda_codec: No auto-config is "
5984 "available, default to model=ref\n");
5985 spec->board_config = STAC_D965_REF;
5991 stac92xx_free(codec);
5995 codec->patch_ops = stac92xx_patch_ops;
5997 codec->proc_widget_hook = stac927x_proc_hook;
6001 * The STAC927x seem to require fairly long delays for certain
6002 * command sequences. With too short delays (even if the answer
6003 * is set to RIRB properly), it results in the silence output
6004 * on some hardwares like Dell.
6006 * The below flag enables the longer delay (see get_response
6009 codec->bus->needs_damn_long_delay = 1;
6011 /* no jack detecion for ref-no-jd model */
6012 if (spec->board_config == STAC_D965_REF_NO_JD)
6013 spec->hp_detect = 0;
6018 static int patch_stac9205(struct hda_codec *codec)
6020 struct sigmatel_spec *spec;
6023 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6027 codec->no_trigger_sense = 1;
6029 spec->linear_tone_beep = 1;
6030 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
6031 spec->pin_nids = stac9205_pin_nids;
6032 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6036 if (spec->board_config < 0)
6037 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6040 stac92xx_set_config_regs(codec,
6041 stac9205_brd_tbl[spec->board_config]);
6043 spec->digbeep_nid = 0x23;
6044 spec->adc_nids = stac9205_adc_nids;
6045 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
6046 spec->mux_nids = stac9205_mux_nids;
6047 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
6048 spec->smux_nids = stac9205_smux_nids;
6049 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
6050 spec->dmic_nids = stac9205_dmic_nids;
6051 spec->num_dmics = STAC9205_NUM_DMICS;
6052 spec->dmux_nids = stac9205_dmux_nids;
6053 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
6056 spec->init = stac9205_core_init;
6057 spec->aloopback_ctl = stac9205_loopback;
6059 spec->num_caps = STAC9205_NUM_CAPS;
6060 spec->capvols = stac9205_capvols;
6061 spec->capsws = stac9205_capsws;
6063 spec->aloopback_mask = 0x40;
6064 spec->aloopback_shift = 0;
6065 /* Turn on/off EAPD per HP plugging */
6066 if (spec->board_config != STAC_9205_EAPD)
6067 spec->eapd_switch = 1;
6068 spec->multiout.dac_nids = spec->dac_nids;
6070 switch (spec->board_config){
6071 case STAC_9205_DELL_M43:
6072 /* Enable SPDIF in/out */
6073 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6074 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
6076 /* Enable unsol response for GPIO4/Dock HP connection */
6077 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6080 snd_hda_codec_write_cache(codec, codec->afg, 0,
6081 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6082 snd_hda_codec_write_cache(codec, codec->afg, 0,
6083 AC_VERB_SET_UNSOLICITED_ENABLE,
6086 spec->gpio_dir = 0x0b;
6087 spec->eapd_mask = 0x01;
6088 spec->gpio_mask = 0x1b;
6089 spec->gpio_mute = 0x10;
6090 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
6093 spec->gpio_data = 0x01;
6096 /* SPDIF-In enabled */
6099 /* GPIO0 High = EAPD */
6100 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6101 spec->gpio_data = 0x01;
6105 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
6107 if (spec->board_config < 0) {
6108 printk(KERN_WARNING "hda_codec: No auto-config is "
6109 "available, default to model=ref\n");
6110 spec->board_config = STAC_9205_REF;
6116 stac92xx_free(codec);
6120 codec->patch_ops = stac92xx_patch_ops;
6122 codec->proc_widget_hook = stac9205_proc_hook;
6131 static struct hda_verb stac9872_core_init[] = {
6132 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
6133 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6137 static hda_nid_t stac9872_pin_nids[] = {
6138 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6142 static hda_nid_t stac9872_adc_nids[] = {
6146 static hda_nid_t stac9872_mux_nids[] = {
6150 static unsigned long stac9872_capvols[] = {
6151 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6153 #define stac9872_capsws stac9872_capvols
6155 static unsigned int stac9872_vaio_pin_configs[9] = {
6156 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6157 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6161 static const char *stac9872_models[STAC_9872_MODELS] = {
6162 [STAC_9872_AUTO] = "auto",
6163 [STAC_9872_VAIO] = "vaio",
6166 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6167 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6170 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
6171 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6172 "Sony VAIO F/S", STAC_9872_VAIO),
6176 static int patch_stac9872(struct hda_codec *codec)
6178 struct sigmatel_spec *spec;
6181 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6184 codec->no_trigger_sense = 1;
6186 spec->linear_tone_beep = 1;
6187 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6188 spec->pin_nids = stac9872_pin_nids;
6190 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6193 if (spec->board_config < 0)
6194 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6197 stac92xx_set_config_regs(codec,
6198 stac9872_brd_tbl[spec->board_config]);
6200 spec->multiout.dac_nids = spec->dac_nids;
6201 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6202 spec->adc_nids = stac9872_adc_nids;
6203 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6204 spec->mux_nids = stac9872_mux_nids;
6205 spec->init = stac9872_core_init;
6207 spec->capvols = stac9872_capvols;
6208 spec->capsws = stac9872_capsws;
6210 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
6212 stac92xx_free(codec);
6215 spec->input_mux = &spec->private_imux;
6216 codec->patch_ops = stac92xx_patch_ops;
6224 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6225 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6226 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6227 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6228 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6229 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6230 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6231 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6232 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6233 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6234 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6235 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6236 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6237 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6238 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6239 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6240 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6241 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6242 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6243 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6244 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6245 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6246 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6247 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6248 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6249 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6250 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6251 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6252 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6253 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6254 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6255 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6256 /* The following does not take into account .id=0x83847661 when subsys =
6257 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6258 * currently not fully supported.
6260 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6261 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6262 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6263 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6264 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6265 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6266 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6267 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6268 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6269 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6270 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6271 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6272 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6273 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6274 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
6275 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6276 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6277 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6278 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6279 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6280 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
6281 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6282 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6283 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6284 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6285 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6286 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6287 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6288 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6289 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6290 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6291 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6292 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6296 MODULE_ALIAS("snd-hda-codec-id:8384*");
6297 MODULE_ALIAS("snd-hda-codec-id:111d*");
6299 MODULE_LICENSE("GPL");
6300 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6302 static struct hda_codec_preset_list sigmatel_list = {
6303 .preset = snd_hda_preset_sigmatel,
6304 .owner = THIS_MODULE,
6307 static int __init patch_sigmatel_init(void)
6309 return snd_hda_add_codec_preset(&sigmatel_list);
6312 static void __exit patch_sigmatel_exit(void)
6314 snd_hda_delete_codec_preset(&sigmatel_list);
6317 module_init(patch_sigmatel_init)
6318 module_exit(patch_sigmatel_exit)