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 <linux/module.h>
33 #include <sound/core.h>
34 #include <sound/asoundef.h>
35 #include <sound/jack.h>
36 #include <sound/tlv.h>
37 #include "hda_codec.h"
38 #include "hda_local.h"
82 STAC_92HD73XX_NO_JD, /* no jack-detection */
96 STAC_92HD83XXX_PWR_REF,
98 STAC_DELL_VOSTRO_3500,
99 STAC_92HD83XXX_HP_cNB11_INTQUAD,
101 STAC_92HD83XXX_MODELS
115 STAC_92HD71BXX_MODELS
141 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
142 * is given, one of the above models will be
143 * chosen according to the subsystem id. */
144 /* for backward compatibility */
161 STAC_D965_REF_NO_JD, /* no jack-detection */
178 struct sigmatel_event {
185 struct sigmatel_mic_route {
188 signed char dmux_idx;
191 #define MAX_PINS_NUM 16
192 #define MAX_ADCS_NUM 4
193 #define MAX_DMICS_NUM 4
195 struct sigmatel_spec {
196 struct snd_kcontrol_new *mixers[4];
197 unsigned int num_mixers;
200 unsigned int eapd_switch: 1;
201 unsigned int surr_switch: 1;
202 unsigned int alt_switch: 1;
203 unsigned int hp_detect: 1;
204 unsigned int spdif_mute: 1;
205 unsigned int check_volume_offset:1;
206 unsigned int auto_mic:1;
207 unsigned int linear_tone_beep:1;
210 unsigned int eapd_mask;
211 unsigned int gpio_mask;
212 unsigned int gpio_dir;
213 unsigned int gpio_data;
214 unsigned int gpio_mute;
215 unsigned int gpio_led;
216 unsigned int gpio_led_polarity;
217 unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
218 unsigned int vref_led;
221 unsigned int stream_delay;
223 /* analog loopback */
224 const struct snd_kcontrol_new *aloopback_ctl;
225 unsigned char aloopback_mask;
226 unsigned char aloopback_shift;
228 /* power management */
229 unsigned int num_pwrs;
230 const hda_nid_t *pwr_nids;
231 const hda_nid_t *dac_list;
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];
247 const hda_nid_t *adc_nids;
248 unsigned int num_adcs;
249 const hda_nid_t *mux_nids;
250 unsigned int num_muxes;
251 const hda_nid_t *dmic_nids;
252 unsigned int num_dmics;
253 const hda_nid_t *dmux_nids;
254 unsigned int num_dmuxes;
255 const hda_nid_t *smux_nids;
256 unsigned int num_smuxes;
257 unsigned int num_analog_muxes;
259 const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
260 const 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;
265 struct sigmatel_mic_route dock_mic;
267 const char * const *spdif_labels;
269 hda_nid_t dig_in_nid;
271 hda_nid_t anabeep_nid;
272 hda_nid_t digbeep_nid;
275 const hda_nid_t *pin_nids;
276 unsigned int num_pins;
278 /* codec specific stuff */
279 const struct hda_verb *init;
280 const struct snd_kcontrol_new *mixer;
283 struct hda_input_mux *dinput_mux;
284 unsigned int cur_dmux[2];
285 struct hda_input_mux *input_mux;
286 unsigned int cur_mux[3];
287 struct hda_input_mux *sinput_mux;
288 unsigned int cur_smux[2];
289 unsigned int cur_amux;
291 unsigned int powerdown_adcs;
294 unsigned int io_switch[2];
295 unsigned int clfe_swap;
296 hda_nid_t line_switch; /* shared line-in for input and output */
297 hda_nid_t mic_switch; /* shared mic-in for input and output */
298 hda_nid_t hp_switch; /* NID of HP as line-out */
299 unsigned int aloopback;
301 struct hda_pcm pcm_rec[2]; /* PCM information */
303 /* dynamic controls and input_mux */
304 struct auto_pin_cfg autocfg;
305 struct snd_array kctls;
306 struct hda_input_mux private_dimux;
307 struct hda_input_mux private_imux;
308 struct hda_input_mux private_smux;
309 struct hda_input_mux private_mono_mux;
312 unsigned auto_pin_cnt;
313 hda_nid_t auto_pin_nids[MAX_PINS_NUM];
314 unsigned auto_adc_cnt;
315 hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
316 hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
317 hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
318 unsigned long auto_capvols[MAX_ADCS_NUM];
319 unsigned auto_dmic_cnt;
320 hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
323 static const hda_nid_t stac9200_adc_nids[1] = {
327 static const hda_nid_t stac9200_mux_nids[1] = {
331 static const hda_nid_t stac9200_dac_nids[1] = {
335 static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
336 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
340 static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
344 static const hda_nid_t stac92hd73xx_adc_nids[2] = {
348 #define STAC92HD73XX_NUM_DMICS 2
349 static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
353 #define STAC92HD73_DAC_COUNT 5
355 static const hda_nid_t stac92hd73xx_mux_nids[2] = {
359 static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
363 static const hda_nid_t stac92hd73xx_smux_nids[2] = {
367 #define STAC92HD73XX_NUM_CAPS 2
368 static const unsigned long stac92hd73xx_capvols[] = {
369 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
370 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
372 #define stac92hd73xx_capsws stac92hd73xx_capvols
374 #define STAC92HD83_DAC_COUNT 3
376 static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
377 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
381 static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
385 static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
389 static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
393 static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
397 static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
401 static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
405 static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
409 #define STAC92HD71BXX_NUM_DMICS 2
410 static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
414 static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
418 static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
422 #define STAC92HD71BXX_NUM_CAPS 2
423 static const unsigned long stac92hd71bxx_capvols[] = {
424 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
425 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
427 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
429 static const hda_nid_t stac925x_adc_nids[1] = {
433 static const hda_nid_t stac925x_mux_nids[1] = {
437 static const hda_nid_t stac925x_dac_nids[1] = {
441 #define STAC925X_NUM_DMICS 1
442 static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
446 static const hda_nid_t stac925x_dmux_nids[1] = {
450 static const unsigned long stac925x_capvols[] = {
451 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
453 static const unsigned long stac925x_capsws[] = {
454 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
457 static const hda_nid_t stac922x_adc_nids[2] = {
461 static const hda_nid_t stac922x_mux_nids[2] = {
465 #define STAC922X_NUM_CAPS 2
466 static const unsigned long stac922x_capvols[] = {
467 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
468 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
470 #define stac922x_capsws stac922x_capvols
472 static const hda_nid_t stac927x_slave_dig_outs[2] = {
476 static const hda_nid_t stac927x_adc_nids[3] = {
480 static const hda_nid_t stac927x_mux_nids[3] = {
484 static const hda_nid_t stac927x_smux_nids[1] = {
488 static const hda_nid_t stac927x_dac_nids[6] = {
489 0x02, 0x03, 0x04, 0x05, 0x06, 0
492 static const hda_nid_t stac927x_dmux_nids[1] = {
496 #define STAC927X_NUM_DMICS 2
497 static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
501 #define STAC927X_NUM_CAPS 3
502 static const unsigned long stac927x_capvols[] = {
503 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
504 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
505 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
507 static const unsigned long stac927x_capsws[] = {
508 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
509 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
510 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
513 static const char * const stac927x_spdif_labels[5] = {
514 "Digital Playback", "ADAT", "Analog Mux 1",
515 "Analog Mux 2", "Analog Mux 3"
518 static const hda_nid_t stac9205_adc_nids[2] = {
522 static const hda_nid_t stac9205_mux_nids[2] = {
526 static const hda_nid_t stac9205_dmux_nids[1] = {
530 static const hda_nid_t stac9205_smux_nids[1] = {
534 #define STAC9205_NUM_DMICS 2
535 static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
539 #define STAC9205_NUM_CAPS 2
540 static const unsigned long stac9205_capvols[] = {
541 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
542 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
544 static const unsigned long stac9205_capsws[] = {
545 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
546 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
549 static const hda_nid_t stac9200_pin_nids[8] = {
550 0x08, 0x09, 0x0d, 0x0e,
551 0x0f, 0x10, 0x11, 0x12,
554 static const hda_nid_t stac925x_pin_nids[8] = {
555 0x07, 0x08, 0x0a, 0x0b,
556 0x0c, 0x0d, 0x10, 0x11,
559 static const hda_nid_t stac922x_pin_nids[10] = {
560 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
561 0x0f, 0x10, 0x11, 0x15, 0x1b,
564 static const hda_nid_t stac92hd73xx_pin_nids[13] = {
565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x12, 0x13,
570 #define STAC92HD71BXX_NUM_PINS 13
571 static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
572 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
573 0x00, 0x14, 0x18, 0x19, 0x1e,
576 static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
577 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
578 0x0f, 0x14, 0x18, 0x19, 0x1e,
582 static const hda_nid_t stac927x_pin_nids[14] = {
583 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
584 0x0f, 0x10, 0x11, 0x12, 0x13,
585 0x14, 0x21, 0x22, 0x23,
588 static const hda_nid_t stac9205_pin_nids[12] = {
589 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
590 0x0f, 0x14, 0x16, 0x17, 0x18,
594 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
595 struct snd_ctl_elem_info *uinfo)
597 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
598 struct sigmatel_spec *spec = codec->spec;
599 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
602 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
603 struct snd_ctl_elem_value *ucontrol)
605 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
606 struct sigmatel_spec *spec = codec->spec;
607 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
609 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
613 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
616 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
617 struct sigmatel_spec *spec = codec->spec;
618 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
620 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
621 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
624 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
625 struct snd_ctl_elem_info *uinfo)
627 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
628 struct sigmatel_spec *spec = codec->spec;
629 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
632 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
633 struct snd_ctl_elem_value *ucontrol)
635 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
636 struct sigmatel_spec *spec = codec->spec;
637 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
639 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
643 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
644 struct snd_ctl_elem_value *ucontrol)
646 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
647 struct sigmatel_spec *spec = codec->spec;
648 struct hda_input_mux *smux = &spec->private_smux;
649 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
653 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
654 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
658 if (spec->spdif_mute) {
660 nid = spec->multiout.dig_out_nid;
662 nid = codec->slave_dig_outs[smux_idx - 1];
663 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
667 /* un/mute SPDIF out */
668 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
674 #ifdef CONFIG_SND_HDA_POWER_SAVE
675 static int stac_vrefout_set(struct hda_codec *codec,
676 hda_nid_t nid, unsigned int new_vref)
680 snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
681 pinctl = snd_hda_codec_read(codec, nid, 0,
682 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
688 pinctl &= ~AC_PINCTL_VREFEN;
689 pinctl |= (new_vref & AC_PINCTL_VREFEN);
691 error = snd_hda_codec_write_cache(codec, nid, 0,
692 AC_VERB_SET_PIN_WIDGET_CONTROL, pinctl);
700 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
701 hda_nid_t nid, unsigned int new_vref)
705 pincfg = snd_hda_codec_read(codec, nid, 0,
706 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
709 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
712 if (new_vref == AC_PINCTL_VREF_HIZ)
713 pincfg |= AC_PINCTL_OUT_EN;
715 pincfg |= AC_PINCTL_IN_EN;
717 error = snd_hda_codec_write_cache(codec, nid, 0,
718 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
725 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
728 vref = snd_hda_codec_read(codec, nid, 0,
729 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
730 vref &= AC_PINCTL_VREFEN;
734 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
736 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
737 struct sigmatel_spec *spec = codec->spec;
738 return snd_hda_input_mux_info(spec->input_mux, uinfo);
741 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
744 struct sigmatel_spec *spec = codec->spec;
745 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
747 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
751 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
754 struct sigmatel_spec *spec = codec->spec;
755 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
756 const struct hda_input_mux *imux = spec->input_mux;
757 unsigned int idx, prev_idx, didx;
759 idx = ucontrol->value.enumerated.item[0];
760 if (idx >= imux->num_items)
761 idx = imux->num_items - 1;
762 prev_idx = spec->cur_mux[adc_idx];
765 if (idx < spec->num_analog_muxes) {
766 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
767 AC_VERB_SET_CONNECT_SEL,
768 imux->items[idx].index);
769 if (prev_idx >= spec->num_analog_muxes &&
770 spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
771 imux = spec->dinput_mux;
773 snd_hda_codec_write_cache(codec,
774 spec->dmux_nids[adc_idx], 0,
775 AC_VERB_SET_CONNECT_SEL,
776 imux->items[0].index);
779 imux = spec->dinput_mux;
780 /* first dimux item is hardcoded to select analog imux,
783 didx = idx - spec->num_analog_muxes + 1;
784 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
785 AC_VERB_SET_CONNECT_SEL,
786 imux->items[didx].index);
788 spec->cur_mux[adc_idx] = idx;
792 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
793 struct snd_ctl_elem_info *uinfo)
795 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
796 struct sigmatel_spec *spec = codec->spec;
797 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
800 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
801 struct snd_ctl_elem_value *ucontrol)
803 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
804 struct sigmatel_spec *spec = codec->spec;
806 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
810 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
811 struct snd_ctl_elem_value *ucontrol)
813 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
814 struct sigmatel_spec *spec = codec->spec;
816 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
817 spec->mono_nid, &spec->cur_mmux);
820 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
822 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
823 struct snd_ctl_elem_value *ucontrol)
825 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
826 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
827 struct sigmatel_spec *spec = codec->spec;
829 ucontrol->value.integer.value[0] = !!(spec->aloopback &
830 (spec->aloopback_mask << idx));
834 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
835 struct snd_ctl_elem_value *ucontrol)
837 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
838 struct sigmatel_spec *spec = codec->spec;
839 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
840 unsigned int dac_mode;
841 unsigned int val, idx_val;
843 idx_val = spec->aloopback_mask << idx;
844 if (ucontrol->value.integer.value[0])
845 val = spec->aloopback | idx_val;
847 val = spec->aloopback & ~idx_val;
848 if (spec->aloopback == val)
851 spec->aloopback = val;
853 /* Only return the bits defined by the shift value of the
854 * first two bytes of the mask
856 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
857 kcontrol->private_value & 0xFFFF, 0x0);
858 dac_mode >>= spec->aloopback_shift;
860 if (spec->aloopback & idx_val) {
861 snd_hda_power_up(codec);
864 snd_hda_power_down(codec);
865 dac_mode &= ~idx_val;
868 snd_hda_codec_write_cache(codec, codec->afg, 0,
869 kcontrol->private_value >> 16, dac_mode);
874 static const struct hda_verb stac9200_core_init[] = {
875 /* set dac0mux for dac converter */
876 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
880 static const struct hda_verb stac9200_eapd_init[] = {
881 /* set dac0mux for dac converter */
882 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
883 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
887 static const struct hda_verb dell_eq_core_init[] = {
888 /* set master volume to max value without distortion
889 * and direct control */
890 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
894 static const struct hda_verb stac92hd73xx_core_init[] = {
895 /* set master volume and direct control */
896 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
900 static const struct hda_verb stac92hd83xxx_core_init[] = {
901 /* power state controls amps */
902 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
906 static const struct hda_verb stac92hd71bxx_core_init[] = {
907 /* set master volume and direct control */
908 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
912 static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
913 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
914 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
915 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
916 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
920 static const struct hda_verb stac925x_core_init[] = {
921 /* set dac0mux for dac converter */
922 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
923 /* mute the master volume */
924 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
928 static const struct hda_verb stac922x_core_init[] = {
929 /* set master volume and direct control */
930 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
934 static const struct hda_verb d965_core_init[] = {
935 /* set master volume and direct control */
936 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
937 /* unmute node 0x1b */
938 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
939 /* select node 0x03 as DAC */
940 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
944 static const struct hda_verb dell_3st_core_init[] = {
945 /* don't set delta bit */
946 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
947 /* unmute node 0x1b */
948 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
949 /* select node 0x03 as DAC */
950 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
954 static const struct hda_verb stac927x_core_init[] = {
955 /* set master volume and direct control */
956 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
957 /* enable analog pc beep path */
958 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
962 static const struct hda_verb stac927x_volknob_core_init[] = {
963 /* don't set delta bit */
964 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
965 /* enable analog pc beep path */
966 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
970 static const struct hda_verb stac9205_core_init[] = {
971 /* set master volume and direct control */
972 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
973 /* enable analog pc beep path */
974 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
978 #define STAC_MONO_MUX \
980 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
981 .name = "Mono Mux", \
983 .info = stac92xx_mono_mux_enum_info, \
984 .get = stac92xx_mono_mux_enum_get, \
985 .put = stac92xx_mono_mux_enum_put, \
988 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
991 .name = "Analog Loopback", \
993 .info = stac92xx_aloopback_info, \
994 .get = stac92xx_aloopback_get, \
995 .put = stac92xx_aloopback_put, \
996 .private_value = verb_read | (verb_write << 16), \
999 #define DC_BIAS(xname, idx, nid) \
1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1004 .info = stac92xx_dc_bias_info, \
1005 .get = stac92xx_dc_bias_get, \
1006 .put = stac92xx_dc_bias_put, \
1007 .private_value = nid, \
1010 static const struct snd_kcontrol_new stac9200_mixer[] = {
1011 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1012 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1013 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1014 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1018 static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1019 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1023 static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1024 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1028 static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1029 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1034 static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1035 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1038 static const struct snd_kcontrol_new stac925x_mixer[] = {
1039 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
1040 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1044 static const struct snd_kcontrol_new stac9205_loopback[] = {
1045 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1049 static const struct snd_kcontrol_new stac927x_loopback[] = {
1050 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1054 static struct snd_kcontrol_new stac_dmux_mixer = {
1055 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1056 .name = "Digital Input Source",
1057 /* count set later */
1058 .info = stac92xx_dmux_enum_info,
1059 .get = stac92xx_dmux_enum_get,
1060 .put = stac92xx_dmux_enum_put,
1063 static struct snd_kcontrol_new stac_smux_mixer = {
1064 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1065 .name = "IEC958 Playback Source",
1066 /* count set later */
1067 .info = stac92xx_smux_enum_info,
1068 .get = stac92xx_smux_enum_get,
1069 .put = stac92xx_smux_enum_put,
1072 static const char * const slave_vols[] = {
1073 "Front Playback Volume",
1074 "Surround Playback Volume",
1075 "Center Playback Volume",
1076 "LFE Playback Volume",
1077 "Side Playback Volume",
1078 "Headphone Playback Volume",
1079 "Speaker Playback Volume",
1083 static const char * const slave_sws[] = {
1084 "Front Playback Switch",
1085 "Surround Playback Switch",
1086 "Center Playback Switch",
1087 "LFE Playback Switch",
1088 "Side Playback Switch",
1089 "Headphone Playback Switch",
1090 "Speaker Playback Switch",
1091 "IEC958 Playback Switch",
1095 static void stac92xx_free_kctls(struct hda_codec *codec);
1096 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1098 static int stac92xx_build_controls(struct hda_codec *codec)
1100 struct sigmatel_spec *spec = codec->spec;
1101 struct auto_pin_cfg *cfg = &spec->autocfg;
1107 err = snd_hda_add_new_ctls(codec, spec->mixer);
1112 for (i = 0; i < spec->num_mixers; i++) {
1113 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1117 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1118 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1119 stac_dmux_mixer.count = spec->num_dmuxes;
1120 err = snd_hda_ctl_add(codec, 0,
1121 snd_ctl_new1(&stac_dmux_mixer, codec));
1125 if (spec->num_smuxes > 0) {
1126 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1127 struct hda_input_mux *smux = &spec->private_smux;
1128 /* check for mute support on SPDIF out */
1129 if (wcaps & AC_WCAP_OUT_AMP) {
1130 snd_hda_add_imux_item(smux, "Off", 0, NULL);
1131 spec->spdif_mute = 1;
1133 stac_smux_mixer.count = spec->num_smuxes;
1134 err = snd_hda_ctl_add(codec, 0,
1135 snd_ctl_new1(&stac_smux_mixer, codec));
1140 if (spec->multiout.dig_out_nid) {
1141 err = snd_hda_create_spdif_out_ctls(codec,
1142 spec->multiout.dig_out_nid,
1143 spec->multiout.dig_out_nid);
1146 err = snd_hda_create_spdif_share_sw(codec,
1150 spec->multiout.share_spdif = 1;
1152 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1153 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1158 /* if we have no master control, let's create it */
1159 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1160 unsigned int vmaster_tlv[4];
1161 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1162 HDA_OUTPUT, vmaster_tlv);
1163 /* correct volume offset */
1164 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1165 /* minimum value is actually mute */
1166 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1167 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1168 vmaster_tlv, slave_vols);
1172 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1173 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1179 if (spec->aloopback_ctl &&
1180 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1181 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1186 stac92xx_free_kctls(codec); /* no longer needed */
1188 /* create jack input elements */
1189 if (spec->hp_detect) {
1190 for (i = 0; i < cfg->hp_outs; i++) {
1191 int type = SND_JACK_HEADPHONE;
1192 nid = cfg->hp_pins[i];
1193 /* jack detection */
1194 if (cfg->hp_outs == i)
1195 type |= SND_JACK_LINEOUT;
1196 err = stac92xx_add_jack(codec, nid, type);
1201 for (i = 0; i < cfg->line_outs; i++) {
1202 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1207 for (i = 0; i < cfg->num_inputs; i++) {
1208 nid = cfg->inputs[i].pin;
1209 err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE);
1217 static const unsigned int ref9200_pin_configs[8] = {
1218 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1219 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1222 static const unsigned int gateway9200_m4_pin_configs[8] = {
1223 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1224 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1226 static const unsigned int gateway9200_m4_2_pin_configs[8] = {
1227 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1228 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1232 STAC 9200 pin configs for
1237 static const unsigned int dell9200_d21_pin_configs[8] = {
1238 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1239 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1243 STAC 9200 pin configs for
1247 static const unsigned int dell9200_d22_pin_configs[8] = {
1248 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1249 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1253 STAC 9200 pin configs for
1254 102801C4 (Dell Dimension E310)
1261 static const unsigned int dell9200_d23_pin_configs[8] = {
1262 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1263 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1268 STAC 9200-32 pin configs for
1269 102801B5 (Dell Inspiron 630m)
1270 102801D8 (Dell Inspiron 640m)
1272 static const unsigned int dell9200_m21_pin_configs[8] = {
1273 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1274 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1278 STAC 9200-32 pin configs for
1279 102801C2 (Dell Latitude D620)
1281 102801CC (Dell Latitude D820)
1285 static const unsigned int dell9200_m22_pin_configs[8] = {
1286 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1287 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1291 STAC 9200-32 pin configs for
1292 102801CE (Dell XPS M1710)
1293 102801CF (Dell Precision M90)
1295 static const unsigned int dell9200_m23_pin_configs[8] = {
1296 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1297 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1301 STAC 9200-32 pin configs for
1304 102801CB (Dell Latitude 120L)
1307 static const unsigned int dell9200_m24_pin_configs[8] = {
1308 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1309 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1313 STAC 9200-32 pin configs for
1314 102801BD (Dell Inspiron E1505n)
1318 static const unsigned int dell9200_m25_pin_configs[8] = {
1319 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1320 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1324 STAC 9200-32 pin configs for
1325 102801F5 (Dell Inspiron 1501)
1328 static const unsigned int dell9200_m26_pin_configs[8] = {
1329 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1330 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1335 102801CD (Dell Inspiron E1705/9400)
1337 static const unsigned int dell9200_m27_pin_configs[8] = {
1338 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1339 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1342 static const unsigned int oqo9200_pin_configs[8] = {
1343 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1344 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1348 static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1349 [STAC_REF] = ref9200_pin_configs,
1350 [STAC_9200_OQO] = oqo9200_pin_configs,
1351 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1352 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1353 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1354 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1355 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1356 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1357 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1358 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1359 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1360 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1361 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1362 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1363 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1366 static const char * const stac9200_models[STAC_9200_MODELS] = {
1367 [STAC_AUTO] = "auto",
1369 [STAC_9200_OQO] = "oqo",
1370 [STAC_9200_DELL_D21] = "dell-d21",
1371 [STAC_9200_DELL_D22] = "dell-d22",
1372 [STAC_9200_DELL_D23] = "dell-d23",
1373 [STAC_9200_DELL_M21] = "dell-m21",
1374 [STAC_9200_DELL_M22] = "dell-m22",
1375 [STAC_9200_DELL_M23] = "dell-m23",
1376 [STAC_9200_DELL_M24] = "dell-m24",
1377 [STAC_9200_DELL_M25] = "dell-m25",
1378 [STAC_9200_DELL_M26] = "dell-m26",
1379 [STAC_9200_DELL_M27] = "dell-m27",
1380 [STAC_9200_M4] = "gateway-m4",
1381 [STAC_9200_M4_2] = "gateway-m4-2",
1382 [STAC_9200_PANASONIC] = "panasonic",
1385 static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
1386 /* SigmaTel reference board */
1387 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1388 "DFI LanParty", STAC_REF),
1389 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1390 "DFI LanParty", STAC_REF),
1391 /* Dell laptops have BIOS problem */
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1393 "unknown Dell", STAC_9200_DELL_D21),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1395 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1397 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1399 "unknown Dell", STAC_9200_DELL_D22),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1401 "unknown Dell", STAC_9200_DELL_D22),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1403 "Dell Latitude D620", STAC_9200_DELL_M22),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1405 "unknown Dell", STAC_9200_DELL_D23),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1407 "unknown Dell", STAC_9200_DELL_D23),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1409 "unknown Dell", STAC_9200_DELL_M22),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1411 "unknown Dell", STAC_9200_DELL_M24),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1413 "unknown Dell", STAC_9200_DELL_M24),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1415 "Dell Latitude 120L", STAC_9200_DELL_M24),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1417 "Dell Latitude D820", STAC_9200_DELL_M22),
1418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1419 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1421 "Dell XPS M1710", STAC_9200_DELL_M23),
1422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1423 "Dell Precision M90", STAC_9200_DELL_M23),
1424 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1425 "unknown Dell", STAC_9200_DELL_M22),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1427 "unknown Dell", STAC_9200_DELL_M22),
1428 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1429 "unknown Dell", STAC_9200_DELL_M22),
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1431 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1432 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1433 "unknown Dell", STAC_9200_DELL_D23),
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1435 "unknown Dell", STAC_9200_DELL_D23),
1436 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1437 "unknown Dell", STAC_9200_DELL_D21),
1438 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1439 "unknown Dell", STAC_9200_DELL_D23),
1440 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1441 "unknown Dell", STAC_9200_DELL_D21),
1442 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1443 "unknown Dell", STAC_9200_DELL_M25),
1444 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1445 "unknown Dell", STAC_9200_DELL_M25),
1446 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1447 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1448 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1449 "unknown Dell", STAC_9200_DELL_M26),
1451 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1452 /* Gateway machines needs EAPD to be set on resume */
1453 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1454 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1455 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1457 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1461 static const unsigned int ref925x_pin_configs[8] = {
1462 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1463 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1466 static const unsigned int stac925xM1_pin_configs[8] = {
1467 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1468 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1471 static const unsigned int stac925xM1_2_pin_configs[8] = {
1472 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1473 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1476 static const unsigned int stac925xM2_pin_configs[8] = {
1477 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1478 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1481 static const unsigned int stac925xM2_2_pin_configs[8] = {
1482 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1483 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1486 static const unsigned int stac925xM3_pin_configs[8] = {
1487 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1488 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1491 static const unsigned int stac925xM5_pin_configs[8] = {
1492 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1493 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1496 static const unsigned int stac925xM6_pin_configs[8] = {
1497 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1498 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1501 static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1502 [STAC_REF] = ref925x_pin_configs,
1503 [STAC_M1] = stac925xM1_pin_configs,
1504 [STAC_M1_2] = stac925xM1_2_pin_configs,
1505 [STAC_M2] = stac925xM2_pin_configs,
1506 [STAC_M2_2] = stac925xM2_2_pin_configs,
1507 [STAC_M3] = stac925xM3_pin_configs,
1508 [STAC_M5] = stac925xM5_pin_configs,
1509 [STAC_M6] = stac925xM6_pin_configs,
1512 static const char * const stac925x_models[STAC_925x_MODELS] = {
1513 [STAC_925x_AUTO] = "auto",
1516 [STAC_M1_2] = "m1-2",
1518 [STAC_M2_2] = "m2-2",
1524 static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1525 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1526 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1527 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1528 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1529 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1530 /* Not sure about the brand name for those */
1531 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1532 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1533 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1534 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1538 static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
1539 /* SigmaTel reference board */
1540 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1541 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1542 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1544 /* Default table for unknown ID */
1545 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1550 static const unsigned int ref92hd73xx_pin_configs[13] = {
1551 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1552 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1553 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1557 static const unsigned int dell_m6_pin_configs[13] = {
1558 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1559 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1560 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1564 static const unsigned int alienware_m17x_pin_configs[13] = {
1565 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1566 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1567 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1571 static const unsigned int intel_dg45id_pin_configs[13] = {
1572 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
1573 0x01A19250, 0x01011212, 0x01016211
1576 static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1577 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1578 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1579 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1580 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1581 [STAC_DELL_EQ] = dell_m6_pin_configs,
1582 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1583 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
1586 static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1587 [STAC_92HD73XX_AUTO] = "auto",
1588 [STAC_92HD73XX_NO_JD] = "no-jd",
1589 [STAC_92HD73XX_REF] = "ref",
1590 [STAC_92HD73XX_INTEL] = "intel",
1591 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1592 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1593 [STAC_DELL_M6_BOTH] = "dell-m6",
1594 [STAC_DELL_EQ] = "dell-eq",
1595 [STAC_ALIENWARE_M17X] = "alienware",
1598 static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1599 /* SigmaTel reference board */
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1601 "DFI LanParty", STAC_92HD73XX_REF),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1603 "DFI LanParty", STAC_92HD73XX_REF),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1605 "Intel DG45ID", STAC_92HD73XX_INTEL),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1607 "Intel DG45FC", STAC_92HD73XX_INTEL),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1609 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1611 "unknown Dell", STAC_DELL_M6_DMIC),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1613 "unknown Dell", STAC_DELL_M6_BOTH),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1615 "unknown Dell", STAC_DELL_M6_BOTH),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1617 "unknown Dell", STAC_DELL_M6_AMIC),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1619 "unknown Dell", STAC_DELL_M6_AMIC),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1621 "unknown Dell", STAC_DELL_M6_DMIC),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1623 "unknown Dell", STAC_DELL_M6_DMIC),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1625 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1627 "Dell Studio 17", STAC_DELL_M6_DMIC),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1629 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1631 "Dell Studio 1557", STAC_DELL_M6_DMIC),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1633 "Dell Studio XPS 1645", STAC_DELL_M6_BOTH),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1635 "Dell Studio 1558", STAC_DELL_M6_DMIC),
1639 static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1641 "Alienware M17x", STAC_ALIENWARE_M17X),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1643 "Alienware M17x", STAC_ALIENWARE_M17X),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
1645 "Alienware M17x", STAC_ALIENWARE_M17X),
1649 static const unsigned int ref92hd83xxx_pin_configs[10] = {
1650 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1651 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1652 0x01451160, 0x98560170,
1655 static const unsigned int dell_s14_pin_configs[10] = {
1656 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1657 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1658 0x40f000f0, 0x40f000f0,
1661 static const unsigned int dell_vostro_3500_pin_configs[10] = {
1662 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1663 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1664 0x400000f4, 0x400000f5,
1667 static const unsigned int hp_dv7_4000_pin_configs[10] = {
1668 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1669 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1670 0x40f000f0, 0x40f000f0,
1673 static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1674 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1675 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1676 0x40f000f0, 0x40f000f0,
1679 static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1680 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1681 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1682 [STAC_DELL_S14] = dell_s14_pin_configs,
1683 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
1684 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
1685 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
1688 static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1689 [STAC_92HD83XXX_AUTO] = "auto",
1690 [STAC_92HD83XXX_REF] = "ref",
1691 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1692 [STAC_DELL_S14] = "dell-s14",
1693 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
1694 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
1695 [STAC_HP_DV7_4000] = "hp-dv7-4000",
1698 static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1699 /* SigmaTel reference board */
1700 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1701 "DFI LanParty", STAC_92HD83XXX_REF),
1702 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1703 "DFI LanParty", STAC_92HD83XXX_REF),
1704 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1705 "unknown Dell", STAC_DELL_S14),
1706 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1707 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
1708 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1709 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1710 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1711 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1712 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1713 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1714 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1715 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1716 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1717 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1718 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1719 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1720 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1721 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1722 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1723 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1724 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1725 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1726 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1727 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1728 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1729 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1730 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1731 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1732 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1733 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1734 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1735 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1736 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1737 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1738 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1739 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1740 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1741 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1742 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1743 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1744 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1745 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1746 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1747 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1751 static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1752 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1753 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1754 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1758 static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1759 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1760 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1761 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1765 static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1766 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1767 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1768 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1772 static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1773 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1774 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1775 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1779 static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1780 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1781 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1782 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1783 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1784 [STAC_HP_M4] = NULL,
1785 [STAC_HP_DV4] = NULL,
1786 [STAC_HP_DV5] = NULL,
1787 [STAC_HP_HDX] = NULL,
1788 [STAC_HP_DV4_1222NR] = NULL,
1791 static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1792 [STAC_92HD71BXX_AUTO] = "auto",
1793 [STAC_92HD71BXX_REF] = "ref",
1794 [STAC_DELL_M4_1] = "dell-m4-1",
1795 [STAC_DELL_M4_2] = "dell-m4-2",
1796 [STAC_DELL_M4_3] = "dell-m4-3",
1797 [STAC_HP_M4] = "hp-m4",
1798 [STAC_HP_DV4] = "hp-dv4",
1799 [STAC_HP_DV5] = "hp-dv5",
1800 [STAC_HP_HDX] = "hp-hdx",
1801 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1804 static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1805 /* SigmaTel reference board */
1806 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1807 "DFI LanParty", STAC_92HD71BXX_REF),
1808 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1809 "DFI LanParty", STAC_92HD71BXX_REF),
1810 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1811 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1812 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1814 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1816 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1817 "HP dv4-7", STAC_HP_DV4),
1818 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1819 "HP dv4-7", STAC_HP_DV5),
1820 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1821 "HP HDX", STAC_HP_HDX), /* HDX18 */
1822 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1823 "HP mini 1000", STAC_HP_M4),
1824 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1825 "HP HDX", STAC_HP_HDX), /* HDX16 */
1826 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1827 "HP dv6", STAC_HP_DV5),
1828 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1829 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
1830 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1831 "HP DV6", STAC_HP_DV5),
1832 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1834 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1835 "unknown Dell", STAC_DELL_M4_1),
1836 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1837 "unknown Dell", STAC_DELL_M4_1),
1838 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1839 "unknown Dell", STAC_DELL_M4_1),
1840 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1841 "unknown Dell", STAC_DELL_M4_1),
1842 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1843 "unknown Dell", STAC_DELL_M4_1),
1844 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1845 "unknown Dell", STAC_DELL_M4_1),
1846 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1847 "unknown Dell", STAC_DELL_M4_1),
1848 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1849 "unknown Dell", STAC_DELL_M4_2),
1850 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1851 "unknown Dell", STAC_DELL_M4_2),
1852 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1853 "unknown Dell", STAC_DELL_M4_2),
1854 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1855 "unknown Dell", STAC_DELL_M4_2),
1856 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1857 "unknown Dell", STAC_DELL_M4_3),
1861 static const unsigned int ref922x_pin_configs[10] = {
1862 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1863 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1864 0x40000100, 0x40000100,
1868 STAC 922X pin configs for
1875 static const unsigned int dell_922x_d81_pin_configs[10] = {
1876 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1877 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1878 0x01813122, 0x400001f2,
1882 STAC 922X pin configs for
1886 static const unsigned int dell_922x_d82_pin_configs[10] = {
1887 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1888 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1889 0x01813122, 0x400001f1,
1893 STAC 922X pin configs for
1896 static const unsigned int dell_922x_m81_pin_configs[10] = {
1897 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1898 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1899 0x40C003f1, 0x405003f0,
1903 STAC 9221 A1 pin configs for
1904 102801D7 (Dell XPS M1210)
1906 static const unsigned int dell_922x_m82_pin_configs[10] = {
1907 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1908 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1909 0x508003f3, 0x405003f4,
1912 static const unsigned int d945gtp3_pin_configs[10] = {
1913 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1914 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1915 0x02a19120, 0x40000100,
1918 static const unsigned int d945gtp5_pin_configs[10] = {
1919 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1920 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1921 0x02a19320, 0x40000100,
1924 static const unsigned int intel_mac_v1_pin_configs[10] = {
1925 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1926 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1927 0x400000fc, 0x400000fb,
1930 static const unsigned int intel_mac_v2_pin_configs[10] = {
1931 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1932 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1933 0x400000fc, 0x400000fb,
1936 static const unsigned int intel_mac_v3_pin_configs[10] = {
1937 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1938 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1939 0x400000fc, 0x400000fb,
1942 static const unsigned int intel_mac_v4_pin_configs[10] = {
1943 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1944 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1945 0x400000fc, 0x400000fb,
1948 static const unsigned int intel_mac_v5_pin_configs[10] = {
1949 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1950 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1951 0x400000fc, 0x400000fb,
1954 static const unsigned int ecs202_pin_configs[10] = {
1955 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1956 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1957 0x9037012e, 0x40e000f2,
1960 static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1961 [STAC_D945_REF] = ref922x_pin_configs,
1962 [STAC_D945GTP3] = d945gtp3_pin_configs,
1963 [STAC_D945GTP5] = d945gtp5_pin_configs,
1964 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1965 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1966 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1967 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1968 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1969 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1970 /* for backward compatibility */
1971 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1972 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1973 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1974 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1975 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1976 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1977 [STAC_ECS_202] = ecs202_pin_configs,
1978 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1979 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1980 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1981 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1984 static const char * const stac922x_models[STAC_922X_MODELS] = {
1985 [STAC_922X_AUTO] = "auto",
1986 [STAC_D945_REF] = "ref",
1987 [STAC_D945GTP5] = "5stack",
1988 [STAC_D945GTP3] = "3stack",
1989 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1990 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1991 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1992 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1993 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1994 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1995 /* for backward compatibility */
1996 [STAC_MACMINI] = "macmini",
1997 [STAC_MACBOOK] = "macbook",
1998 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1999 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2000 [STAC_IMAC_INTEL] = "imac-intel",
2001 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2002 [STAC_ECS_202] = "ecs202",
2003 [STAC_922X_DELL_D81] = "dell-d81",
2004 [STAC_922X_DELL_D82] = "dell-d82",
2005 [STAC_922X_DELL_M81] = "dell-m81",
2006 [STAC_922X_DELL_M82] = "dell-m82",
2009 static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
2010 /* SigmaTel reference board */
2011 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2012 "DFI LanParty", STAC_D945_REF),
2013 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2014 "DFI LanParty", STAC_D945_REF),
2015 /* Intel 945G based systems */
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2017 "Intel D945G", STAC_D945GTP3),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2019 "Intel D945G", STAC_D945GTP3),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2021 "Intel D945G", STAC_D945GTP3),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2023 "Intel D945G", STAC_D945GTP3),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2025 "Intel D945G", STAC_D945GTP3),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2027 "Intel D945G", STAC_D945GTP3),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2029 "Intel D945G", STAC_D945GTP3),
2030 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2031 "Intel D945G", STAC_D945GTP3),
2032 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2033 "Intel D945G", STAC_D945GTP3),
2034 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2035 "Intel D945G", STAC_D945GTP3),
2036 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2037 "Intel D945G", STAC_D945GTP3),
2038 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2039 "Intel D945G", STAC_D945GTP3),
2040 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2041 "Intel D945G", STAC_D945GTP3),
2042 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2043 "Intel D945G", STAC_D945GTP3),
2044 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2045 "Intel D945G", STAC_D945GTP3),
2046 /* Intel D945G 5-stack systems */
2047 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2048 "Intel D945G", STAC_D945GTP5),
2049 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2050 "Intel D945G", STAC_D945GTP5),
2051 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2052 "Intel D945G", STAC_D945GTP5),
2053 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2054 "Intel D945G", STAC_D945GTP5),
2055 /* Intel 945P based systems */
2056 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2057 "Intel D945P", STAC_D945GTP3),
2058 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2059 "Intel D945P", STAC_D945GTP3),
2060 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2061 "Intel D945P", STAC_D945GTP3),
2062 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2063 "Intel D945P", STAC_D945GTP3),
2064 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2065 "Intel D945P", STAC_D945GTP3),
2066 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2067 "Intel D945P", STAC_D945GTP5),
2069 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2070 "Intel D945", STAC_D945_REF),
2072 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2073 SND_PCI_QUIRK(0x8384, 0x7680,
2074 "Mac", STAC_INTEL_MAC_AUTO),
2076 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2077 "unknown Dell", STAC_922X_DELL_D81),
2078 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2079 "unknown Dell", STAC_922X_DELL_D81),
2080 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2081 "unknown Dell", STAC_922X_DELL_D81),
2082 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2083 "unknown Dell", STAC_922X_DELL_D82),
2084 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2085 "unknown Dell", STAC_922X_DELL_M81),
2086 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2087 "unknown Dell", STAC_922X_DELL_D82),
2088 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2089 "unknown Dell", STAC_922X_DELL_D81),
2090 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2091 "unknown Dell", STAC_922X_DELL_D81),
2092 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2093 "Dell XPS M1210", STAC_922X_DELL_M82),
2094 /* ECS/PC Chips boards */
2095 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2096 "ECS/PC chips", STAC_ECS_202),
2100 static const unsigned int ref927x_pin_configs[14] = {
2101 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2102 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2103 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2104 0x01c42190, 0x40000100,
2107 static const unsigned int d965_3st_pin_configs[14] = {
2108 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2109 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2110 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2111 0x40000100, 0x40000100
2114 static const unsigned int d965_5st_pin_configs[14] = {
2115 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2116 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2117 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2118 0x40000100, 0x40000100
2121 static const unsigned int d965_5st_no_fp_pin_configs[14] = {
2122 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2123 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2124 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2125 0x40000100, 0x40000100
2128 static const unsigned int dell_3st_pin_configs[14] = {
2129 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2130 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2131 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2132 0x40c003fc, 0x40000100
2135 static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2136 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2137 [STAC_D965_REF] = ref927x_pin_configs,
2138 [STAC_D965_3ST] = d965_3st_pin_configs,
2139 [STAC_D965_5ST] = d965_5st_pin_configs,
2140 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2141 [STAC_DELL_3ST] = dell_3st_pin_configs,
2142 [STAC_DELL_BIOS] = NULL,
2143 [STAC_927X_VOLKNOB] = NULL,
2146 static const char * const stac927x_models[STAC_927X_MODELS] = {
2147 [STAC_927X_AUTO] = "auto",
2148 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2149 [STAC_D965_REF] = "ref",
2150 [STAC_D965_3ST] = "3stack",
2151 [STAC_D965_5ST] = "5stack",
2152 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2153 [STAC_DELL_3ST] = "dell-3stack",
2154 [STAC_DELL_BIOS] = "dell-bios",
2155 [STAC_927X_VOLKNOB] = "volknob",
2158 static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
2159 /* SigmaTel reference board */
2160 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2161 "DFI LanParty", STAC_D965_REF),
2162 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2163 "DFI LanParty", STAC_D965_REF),
2164 /* Intel 946 based systems */
2165 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2167 /* 965 based 3 stack systems */
2168 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2169 "Intel D965", STAC_D965_3ST),
2170 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2171 "Intel D965", STAC_D965_3ST),
2172 /* Dell 3 stack systems */
2173 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2176 /* Dell 3 stack systems with verb table in BIOS */
2177 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2186 /* 965 based 5 stack systems */
2187 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2188 "Intel D965", STAC_D965_5ST),
2189 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2190 "Intel D965", STAC_D965_5ST),
2191 /* volume-knob fixes */
2192 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
2196 static const unsigned int ref9205_pin_configs[12] = {
2197 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2198 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2199 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2203 STAC 9205 pin configs for
2210 10280228 (Dell Vostro 1500)
2211 10280229 (Dell Vostro 1700)
2213 static const unsigned int dell_9205_m42_pin_configs[12] = {
2214 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2215 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2216 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2220 STAC 9205 pin configs for
2224 102801FF (Dell Precision M4300)
2229 static const unsigned int dell_9205_m43_pin_configs[12] = {
2230 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2231 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2232 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2235 static const unsigned int dell_9205_m44_pin_configs[12] = {
2236 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2237 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2238 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2241 static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2242 [STAC_9205_REF] = ref9205_pin_configs,
2243 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2244 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2245 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2246 [STAC_9205_EAPD] = NULL,
2249 static const char * const stac9205_models[STAC_9205_MODELS] = {
2250 [STAC_9205_AUTO] = "auto",
2251 [STAC_9205_REF] = "ref",
2252 [STAC_9205_DELL_M42] = "dell-m42",
2253 [STAC_9205_DELL_M43] = "dell-m43",
2254 [STAC_9205_DELL_M44] = "dell-m44",
2255 [STAC_9205_EAPD] = "eapd",
2258 static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
2259 /* SigmaTel reference board */
2260 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2261 "DFI LanParty", STAC_9205_REF),
2262 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2263 "SigmaTel", STAC_9205_REF),
2264 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2265 "DFI LanParty", STAC_9205_REF),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2268 "unknown Dell", STAC_9205_DELL_M42),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2270 "unknown Dell", STAC_9205_DELL_M42),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2272 "Dell Precision", STAC_9205_DELL_M43),
2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2274 "Dell Precision", STAC_9205_DELL_M43),
2275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2276 "Dell Precision", STAC_9205_DELL_M43),
2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2278 "unknown Dell", STAC_9205_DELL_M42),
2279 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2280 "unknown Dell", STAC_9205_DELL_M42),
2281 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2282 "Dell Precision", STAC_9205_DELL_M43),
2283 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2284 "Dell Precision M4300", STAC_9205_DELL_M43),
2285 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2286 "unknown Dell", STAC_9205_DELL_M42),
2287 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2288 "Dell Precision", STAC_9205_DELL_M43),
2289 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2290 "Dell Precision", STAC_9205_DELL_M43),
2291 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2292 "Dell Precision", STAC_9205_DELL_M43),
2293 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2294 "Dell Inspiron", STAC_9205_DELL_M44),
2295 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2296 "Dell Vostro 1500", STAC_9205_DELL_M42),
2297 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2298 "Dell Vostro 1700", STAC_9205_DELL_M42),
2300 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2301 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2305 static void stac92xx_set_config_regs(struct hda_codec *codec,
2306 const unsigned int *pincfgs)
2309 struct sigmatel_spec *spec = codec->spec;
2314 for (i = 0; i < spec->num_pins; i++)
2315 if (spec->pin_nids[i] && pincfgs[i])
2316 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2321 * Analog playback callbacks
2323 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2324 struct hda_codec *codec,
2325 struct snd_pcm_substream *substream)
2327 struct sigmatel_spec *spec = codec->spec;
2328 if (spec->stream_delay)
2329 msleep(spec->stream_delay);
2330 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2334 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2335 struct hda_codec *codec,
2336 unsigned int stream_tag,
2337 unsigned int format,
2338 struct snd_pcm_substream *substream)
2340 struct sigmatel_spec *spec = codec->spec;
2341 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2344 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2345 struct hda_codec *codec,
2346 struct snd_pcm_substream *substream)
2348 struct sigmatel_spec *spec = codec->spec;
2349 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2353 * Digital playback callbacks
2355 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2356 struct hda_codec *codec,
2357 struct snd_pcm_substream *substream)
2359 struct sigmatel_spec *spec = codec->spec;
2360 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2363 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2364 struct hda_codec *codec,
2365 struct snd_pcm_substream *substream)
2367 struct sigmatel_spec *spec = codec->spec;
2368 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2371 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2372 struct hda_codec *codec,
2373 unsigned int stream_tag,
2374 unsigned int format,
2375 struct snd_pcm_substream *substream)
2377 struct sigmatel_spec *spec = codec->spec;
2378 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2379 stream_tag, format, substream);
2382 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2383 struct hda_codec *codec,
2384 struct snd_pcm_substream *substream)
2386 struct sigmatel_spec *spec = codec->spec;
2387 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2392 * Analog capture callbacks
2394 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2395 struct hda_codec *codec,
2396 unsigned int stream_tag,
2397 unsigned int format,
2398 struct snd_pcm_substream *substream)
2400 struct sigmatel_spec *spec = codec->spec;
2401 hda_nid_t nid = spec->adc_nids[substream->number];
2403 if (spec->powerdown_adcs) {
2405 snd_hda_codec_write(codec, nid, 0,
2406 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2408 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2412 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2413 struct hda_codec *codec,
2414 struct snd_pcm_substream *substream)
2416 struct sigmatel_spec *spec = codec->spec;
2417 hda_nid_t nid = spec->adc_nids[substream->number];
2419 snd_hda_codec_cleanup_stream(codec, nid);
2420 if (spec->powerdown_adcs)
2421 snd_hda_codec_write(codec, nid, 0,
2422 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2426 static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2430 /* NID is set in stac92xx_build_pcms */
2432 .open = stac92xx_dig_playback_pcm_open,
2433 .close = stac92xx_dig_playback_pcm_close,
2434 .prepare = stac92xx_dig_playback_pcm_prepare,
2435 .cleanup = stac92xx_dig_playback_pcm_cleanup
2439 static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2443 /* NID is set in stac92xx_build_pcms */
2446 static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2450 .nid = 0x02, /* NID to query formats and rates */
2452 .open = stac92xx_playback_pcm_open,
2453 .prepare = stac92xx_playback_pcm_prepare,
2454 .cleanup = stac92xx_playback_pcm_cleanup
2458 static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2462 .nid = 0x06, /* NID to query formats and rates */
2464 .open = stac92xx_playback_pcm_open,
2465 .prepare = stac92xx_playback_pcm_prepare,
2466 .cleanup = stac92xx_playback_pcm_cleanup
2470 static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2473 /* NID + .substreams is set in stac92xx_build_pcms */
2475 .prepare = stac92xx_capture_pcm_prepare,
2476 .cleanup = stac92xx_capture_pcm_cleanup
2480 static int stac92xx_build_pcms(struct hda_codec *codec)
2482 struct sigmatel_spec *spec = codec->spec;
2483 struct hda_pcm *info = spec->pcm_rec;
2485 codec->num_pcms = 1;
2486 codec->pcm_info = info;
2488 info->name = "STAC92xx Analog";
2489 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2490 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2491 spec->multiout.dac_nids[0];
2492 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2493 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2494 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2496 if (spec->alt_switch) {
2499 info->name = "STAC92xx Analog Alt";
2500 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2503 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2506 info->name = "STAC92xx Digital";
2507 info->pcm_type = spec->autocfg.dig_out_type[0];
2508 if (spec->multiout.dig_out_nid) {
2509 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2510 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2512 if (spec->dig_in_nid) {
2513 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2514 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2521 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2524 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2525 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2526 if (pincap & AC_PINCAP_VREF_100)
2527 return AC_PINCTL_VREF_100;
2528 if (pincap & AC_PINCAP_VREF_80)
2529 return AC_PINCTL_VREF_80;
2530 if (pincap & AC_PINCAP_VREF_50)
2531 return AC_PINCTL_VREF_50;
2532 if (pincap & AC_PINCAP_VREF_GRD)
2533 return AC_PINCTL_VREF_GRD;
2537 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2540 snd_hda_codec_write_cache(codec, nid, 0,
2541 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2544 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2546 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2547 struct snd_ctl_elem_value *ucontrol)
2549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2550 struct sigmatel_spec *spec = codec->spec;
2552 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2556 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2558 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2559 struct snd_ctl_elem_value *ucontrol)
2561 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2562 struct sigmatel_spec *spec = codec->spec;
2563 int nid = kcontrol->private_value;
2565 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2567 /* check to be sure that the ports are up to date with
2570 stac_issue_unsol_event(codec, nid);
2575 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2576 struct snd_ctl_elem_info *uinfo)
2579 static const char * const texts[] = {
2580 "Mic In", "Line In", "Line Out"
2583 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2584 struct sigmatel_spec *spec = codec->spec;
2585 hda_nid_t nid = kcontrol->private_value;
2587 if (nid == spec->mic_switch || nid == spec->line_switch)
2592 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2593 uinfo->value.enumerated.items = i;
2595 if (uinfo->value.enumerated.item >= i)
2596 uinfo->value.enumerated.item = i-1;
2597 strcpy(uinfo->value.enumerated.name,
2598 texts[uinfo->value.enumerated.item]);
2603 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2604 struct snd_ctl_elem_value *ucontrol)
2606 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2607 hda_nid_t nid = kcontrol->private_value;
2608 unsigned int vref = stac92xx_vref_get(codec, nid);
2610 if (vref == stac92xx_get_default_vref(codec, nid))
2611 ucontrol->value.enumerated.item[0] = 0;
2612 else if (vref == AC_PINCTL_VREF_GRD)
2613 ucontrol->value.enumerated.item[0] = 1;
2614 else if (vref == AC_PINCTL_VREF_HIZ)
2615 ucontrol->value.enumerated.item[0] = 2;
2620 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2621 struct snd_ctl_elem_value *ucontrol)
2623 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2624 unsigned int new_vref = 0;
2626 hda_nid_t nid = kcontrol->private_value;
2628 if (ucontrol->value.enumerated.item[0] == 0)
2629 new_vref = stac92xx_get_default_vref(codec, nid);
2630 else if (ucontrol->value.enumerated.item[0] == 1)
2631 new_vref = AC_PINCTL_VREF_GRD;
2632 else if (ucontrol->value.enumerated.item[0] == 2)
2633 new_vref = AC_PINCTL_VREF_HIZ;
2637 if (new_vref != stac92xx_vref_get(codec, nid)) {
2638 error = stac92xx_vref_set(codec, nid, new_vref);
2645 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2646 struct snd_ctl_elem_info *uinfo)
2649 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2650 struct sigmatel_spec *spec = codec->spec;
2652 if (kcontrol->private_value == spec->line_switch)
2653 texts[0] = "Line In";
2655 texts[0] = "Mic In";
2656 texts[1] = "Line Out";
2657 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2658 uinfo->value.enumerated.items = 2;
2661 if (uinfo->value.enumerated.item >= 2)
2662 uinfo->value.enumerated.item = 1;
2663 strcpy(uinfo->value.enumerated.name,
2664 texts[uinfo->value.enumerated.item]);
2669 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2671 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2672 struct sigmatel_spec *spec = codec->spec;
2673 hda_nid_t nid = kcontrol->private_value;
2674 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2676 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2680 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2682 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2683 struct sigmatel_spec *spec = codec->spec;
2684 hda_nid_t nid = kcontrol->private_value;
2685 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2686 unsigned short val = !!ucontrol->value.enumerated.item[0];
2688 spec->io_switch[io_idx] = val;
2691 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2693 unsigned int pinctl = AC_PINCTL_IN_EN;
2694 if (io_idx) /* set VREF for mic */
2695 pinctl |= stac92xx_get_default_vref(codec, nid);
2696 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2699 /* check the auto-mute again: we need to mute/unmute the speaker
2700 * appropriately according to the pin direction
2702 if (spec->hp_detect)
2703 stac_issue_unsol_event(codec, nid);
2708 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2710 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2711 struct snd_ctl_elem_value *ucontrol)
2713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2714 struct sigmatel_spec *spec = codec->spec;
2716 ucontrol->value.integer.value[0] = spec->clfe_swap;
2720 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2721 struct snd_ctl_elem_value *ucontrol)
2723 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2724 struct sigmatel_spec *spec = codec->spec;
2725 hda_nid_t nid = kcontrol->private_value & 0xff;
2726 unsigned int val = !!ucontrol->value.integer.value[0];
2728 if (spec->clfe_swap == val)
2731 spec->clfe_swap = val;
2733 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2734 spec->clfe_swap ? 0x4 : 0x0);
2739 #define STAC_CODEC_HP_SWITCH(xname) \
2740 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2743 .info = stac92xx_hp_switch_info, \
2744 .get = stac92xx_hp_switch_get, \
2745 .put = stac92xx_hp_switch_put, \
2748 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2749 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2752 .info = stac92xx_io_switch_info, \
2753 .get = stac92xx_io_switch_get, \
2754 .put = stac92xx_io_switch_put, \
2755 .private_value = xpval, \
2758 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2759 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2762 .info = stac92xx_clfe_switch_info, \
2763 .get = stac92xx_clfe_switch_get, \
2764 .put = stac92xx_clfe_switch_put, \
2765 .private_value = xpval, \
2769 STAC_CTL_WIDGET_VOL,
2770 STAC_CTL_WIDGET_MUTE,
2771 STAC_CTL_WIDGET_MUTE_BEEP,
2772 STAC_CTL_WIDGET_MONO_MUX,
2773 STAC_CTL_WIDGET_HP_SWITCH,
2774 STAC_CTL_WIDGET_IO_SWITCH,
2775 STAC_CTL_WIDGET_CLFE_SWITCH,
2776 STAC_CTL_WIDGET_DC_BIAS
2779 static const struct snd_kcontrol_new stac92xx_control_templates[] = {
2780 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2781 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2782 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
2784 STAC_CODEC_HP_SWITCH(NULL),
2785 STAC_CODEC_IO_SWITCH(NULL, 0),
2786 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2787 DC_BIAS(NULL, 0, 0),
2790 /* add dynamic controls */
2791 static struct snd_kcontrol_new *
2792 stac_control_new(struct sigmatel_spec *spec,
2793 const struct snd_kcontrol_new *ktemp,
2795 unsigned int subdev)
2797 struct snd_kcontrol_new *knew;
2799 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2800 knew = snd_array_new(&spec->kctls);
2804 knew->name = kstrdup(name, GFP_KERNEL);
2807 memset(knew, 0, sizeof(*knew));
2808 spec->kctls.alloced--;
2811 knew->subdevice = subdev;
2815 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2816 const struct snd_kcontrol_new *ktemp,
2817 int idx, const char *name,
2820 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
2821 HDA_SUBDEV_AMP_FLAG);
2825 knew->private_value = val;
2829 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2830 int type, int idx, const char *name,
2833 return stac92xx_add_control_temp(spec,
2834 &stac92xx_control_templates[type],
2839 /* add dynamic controls */
2840 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2841 const char *name, unsigned long val)
2843 return stac92xx_add_control_idx(spec, type, 0, name, val);
2846 static const struct snd_kcontrol_new stac_input_src_temp = {
2847 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2848 .name = "Input Source",
2849 .info = stac92xx_mux_enum_info,
2850 .get = stac92xx_mux_enum_get,
2851 .put = stac92xx_mux_enum_put,
2854 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2855 hda_nid_t nid, int idx)
2857 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2859 struct sigmatel_spec *spec = codec->spec;
2862 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2863 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2864 && nid == spec->line_switch)
2865 control = STAC_CTL_WIDGET_IO_SWITCH;
2866 else if (snd_hda_query_pin_caps(codec, nid)
2867 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2868 control = STAC_CTL_WIDGET_DC_BIAS;
2869 else if (nid == spec->mic_switch)
2870 control = STAC_CTL_WIDGET_IO_SWITCH;
2874 strcpy(name, hda_get_input_pin_label(codec, nid, 1));
2875 return stac92xx_add_control(codec->spec, control,
2876 strcat(name, " Jack Mode"), nid);
2882 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2884 struct snd_kcontrol_new *knew;
2885 struct hda_input_mux *imux = &spec->private_imux;
2888 return 0; /* no need for input source */
2889 if (!spec->num_adcs || imux->num_items <= 1)
2890 return 0; /* no need for input source control */
2891 knew = stac_control_new(spec, &stac_input_src_temp,
2892 stac_input_src_temp.name, 0);
2895 knew->count = spec->num_adcs;
2899 /* check whether the line-input can be used as line-out */
2900 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2902 struct sigmatel_spec *spec = codec->spec;
2903 struct auto_pin_cfg *cfg = &spec->autocfg;
2905 unsigned int pincap;
2908 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2910 for (i = 0; i < cfg->num_inputs; i++) {
2911 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
2912 nid = cfg->inputs[i].pin;
2913 pincap = snd_hda_query_pin_caps(codec, nid);
2914 if (pincap & AC_PINCAP_OUT)
2921 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2923 /* check whether the mic-input can be used as line-out */
2924 static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
2926 struct sigmatel_spec *spec = codec->spec;
2927 struct auto_pin_cfg *cfg = &spec->autocfg;
2928 unsigned int def_conf, pincap;
2932 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2934 for (i = 0; i < cfg->num_inputs; i++) {
2935 hda_nid_t nid = cfg->inputs[i].pin;
2936 if (cfg->inputs[i].type != AUTO_PIN_MIC)
2938 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2939 /* some laptops have an internal analog microphone
2940 * which can't be used as a output */
2941 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2942 pincap = snd_hda_query_pin_caps(codec, nid);
2943 if (pincap & AC_PINCAP_OUT) {
2944 *dac = get_unassigned_dac(codec, nid);
2953 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2957 for (i = 0; i < spec->multiout.num_dacs; i++) {
2958 if (spec->multiout.dac_nids[i] == nid)
2965 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2968 if (is_in_dac_nids(spec, nid))
2970 for (i = 0; i < spec->autocfg.hp_outs; i++)
2971 if (spec->hp_dacs[i] == nid)
2973 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2974 if (spec->speaker_dacs[i] == nid)
2979 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2981 struct sigmatel_spec *spec = codec->spec;
2982 struct auto_pin_cfg *cfg = &spec->autocfg;
2984 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
2985 unsigned int wcaps, wtype;
2987 conn_len = snd_hda_get_connections(codec, nid, conn,
2988 HDA_MAX_CONNECTIONS);
2989 /* 92HD88: trace back up the link of nids to find the DAC */
2990 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2991 != AC_WID_AUD_OUT)) {
2993 conn_len = snd_hda_get_connections(codec, nid, conn,
2994 HDA_MAX_CONNECTIONS);
2996 for (j = 0; j < conn_len; j++) {
2997 wcaps = get_wcaps(codec, conn[j]);
2998 wtype = get_wcaps_type(wcaps);
2999 /* we check only analog outputs */
3000 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3002 /* if this route has a free DAC, assign it */
3003 if (!check_all_dac_nids(spec, conn[j])) {
3005 /* select this DAC in the pin's input mux */
3006 snd_hda_codec_write_cache(codec, nid, 0,
3007 AC_VERB_SET_CONNECT_SEL, j);
3013 /* if all DACs are already assigned, connect to the primary DAC,
3014 unless we're assigning a secondary headphone */
3015 fallback_dac = spec->multiout.dac_nids[0];
3016 if (spec->multiout.hp_nid) {
3017 for (j = 0; j < cfg->hp_outs; j++)
3018 if (cfg->hp_pins[j] == nid) {
3019 fallback_dac = spec->multiout.hp_nid;
3025 for (j = 0; j < conn_len; j++) {
3026 if (conn[j] == fallback_dac) {
3027 snd_hda_codec_write_cache(codec, nid, 0,
3028 AC_VERB_SET_CONNECT_SEL, j);
3036 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3037 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3040 * Fill in the dac_nids table from the parsed pin configuration
3041 * This function only works when every pin in line_out_pins[]
3042 * contains atleast one DAC in its connection list. Some 92xx
3043 * codecs are not connected directly to a DAC, such as the 9200
3044 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3046 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3048 struct sigmatel_spec *spec = codec->spec;
3049 struct auto_pin_cfg *cfg = &spec->autocfg;
3053 for (i = 0; i < cfg->line_outs; i++) {
3054 nid = cfg->line_out_pins[i];
3055 dac = get_unassigned_dac(codec, nid);
3057 if (spec->multiout.num_dacs > 0) {
3058 /* we have already working output pins,
3059 * so let's drop the broken ones again
3061 cfg->line_outs = spec->multiout.num_dacs;
3064 /* error out, no available DAC found */
3066 "%s: No available DAC for pin 0x%x\n",
3070 add_spec_dacs(spec, dac);
3073 for (i = 0; i < cfg->hp_outs; i++) {
3074 nid = cfg->hp_pins[i];
3075 dac = get_unassigned_dac(codec, nid);
3077 if (!spec->multiout.hp_nid)
3078 spec->multiout.hp_nid = dac;
3080 add_spec_extra_dacs(spec, dac);
3082 spec->hp_dacs[i] = dac;
3085 for (i = 0; i < cfg->speaker_outs; i++) {
3086 nid = cfg->speaker_pins[i];
3087 dac = get_unassigned_dac(codec, nid);
3089 add_spec_extra_dacs(spec, dac);
3090 spec->speaker_dacs[i] = dac;
3093 /* add line-in as output */
3094 nid = check_line_out_switch(codec);
3096 dac = get_unassigned_dac(codec, nid);
3098 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3099 nid, cfg->line_outs);
3100 cfg->line_out_pins[cfg->line_outs] = nid;
3102 spec->line_switch = nid;
3103 add_spec_dacs(spec, dac);
3106 /* add mic as output */
3107 nid = check_mic_out_switch(codec, &dac);
3109 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3110 nid, cfg->line_outs);
3111 cfg->line_out_pins[cfg->line_outs] = nid;
3113 spec->mic_switch = nid;
3114 add_spec_dacs(spec, dac);
3117 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3118 spec->multiout.num_dacs,
3119 spec->multiout.dac_nids[0],
3120 spec->multiout.dac_nids[1],
3121 spec->multiout.dac_nids[2],
3122 spec->multiout.dac_nids[3],
3123 spec->multiout.dac_nids[4]);
3128 /* create volume control/switch for the given prefx type */
3129 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3130 int idx, hda_nid_t nid, int chs)
3132 struct sigmatel_spec *spec = codec->spec;
3136 if (!spec->check_volume_offset) {
3137 unsigned int caps, step, nums, db_scale;
3138 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3139 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3140 AC_AMPCAP_STEP_SIZE_SHIFT;
3141 step = (step + 1) * 25; /* in .01dB unit */
3142 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3143 AC_AMPCAP_NUM_STEPS_SHIFT;
3144 db_scale = nums * step;
3145 /* if dB scale is over -64dB, and finer enough,
3146 * let's reduce it to half
3148 if (db_scale > 6400 && nums >= 0x1f)
3149 spec->volume_offset = nums / 2;
3150 spec->check_volume_offset = 1;
3153 sprintf(name, "%s Playback Volume", pfx);
3154 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3155 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3156 spec->volume_offset));
3159 sprintf(name, "%s Playback Switch", pfx);
3160 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3161 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3167 #define create_controls(codec, pfx, nid, chs) \
3168 create_controls_idx(codec, pfx, 0, nid, chs)
3170 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3172 if (spec->multiout.num_dacs > 4) {
3173 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3176 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3177 spec->dac_nids[spec->multiout.num_dacs] = nid;
3178 spec->multiout.num_dacs++;
3183 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3186 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3187 if (!spec->multiout.extra_out_nid[i]) {
3188 spec->multiout.extra_out_nid[i] = nid;
3192 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3196 /* Create output controls
3197 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3199 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3200 const hda_nid_t *pins,
3201 const hda_nid_t *dac_nids,
3204 struct sigmatel_spec *spec = codec->spec;
3205 static const char * const chname[4] = {
3206 "Front", "Surround", NULL /*CLFE*/, "Side"
3210 unsigned int wid_caps;
3212 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3213 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3214 if (is_jack_detectable(codec, pins[i]))
3215 spec->hp_detect = 1;
3220 if (type != AUTO_PIN_HP_OUT && i == 2) {
3222 err = create_controls(codec, "Center", nid, 1);
3225 err = create_controls(codec, "LFE", nid, 2);
3229 wid_caps = get_wcaps(codec, nid);
3231 if (wid_caps & AC_WCAP_LR_SWAP) {
3232 err = stac92xx_add_control(spec,
3233 STAC_CTL_WIDGET_CLFE_SWITCH,
3234 "Swap Center/LFE Playback Switch", nid);
3244 case AUTO_PIN_HP_OUT:
3248 case AUTO_PIN_SPEAKER_OUT:
3257 err = create_controls_idx(codec, name, idx, nid, 3);
3265 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3266 unsigned long sw, int idx)
3269 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3270 "Capture Volume", vol);
3273 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3274 "Capture Switch", sw);
3280 /* add playback controls from the parsed DAC table */
3281 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3282 const struct auto_pin_cfg *cfg)
3284 struct sigmatel_spec *spec = codec->spec;
3289 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3290 spec->multiout.dac_nids,
3291 cfg->line_out_type);
3295 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3296 err = stac92xx_add_control(spec,
3297 STAC_CTL_WIDGET_HP_SWITCH,
3298 "Headphone as Line Out Switch",
3299 cfg->hp_pins[cfg->hp_outs - 1]);
3304 for (idx = 0; idx < cfg->num_inputs; idx++) {
3305 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
3307 nid = cfg->inputs[idx].pin;
3308 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3316 /* add playback controls for Speaker and HP outputs */
3317 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3318 struct auto_pin_cfg *cfg)
3320 struct sigmatel_spec *spec = codec->spec;
3323 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3324 spec->hp_dacs, AUTO_PIN_HP_OUT);
3328 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3329 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3336 /* labels for mono mux outputs */
3337 static const char * const stac92xx_mono_labels[4] = {
3338 "DAC0", "DAC1", "Mixer", "DAC2"
3341 /* create mono mux for mono out on capable codecs */
3342 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3344 struct sigmatel_spec *spec = codec->spec;
3345 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3347 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3349 num_cons = snd_hda_get_connections(codec,
3352 HDA_MAX_NUM_INPUTS);
3353 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3356 for (i = 0; i < num_cons; i++)
3357 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3360 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3361 "Mono Mux", spec->mono_nid);
3364 /* create PC beep volume controls */
3365 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3368 struct sigmatel_spec *spec = codec->spec;
3369 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3370 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3372 if (spec->anabeep_nid == nid)
3373 type = STAC_CTL_WIDGET_MUTE;
3375 /* check for mute support for the the amp */
3376 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3377 err = stac92xx_add_control(spec, type,
3378 "Beep Playback Switch",
3379 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3384 /* check to see if there is volume support for the amp */
3385 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3386 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3387 "Beep Playback Volume",
3388 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3395 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3396 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3398 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3399 struct snd_ctl_elem_value *ucontrol)
3401 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3402 ucontrol->value.integer.value[0] = codec->beep->enabled;
3406 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3407 struct snd_ctl_elem_value *ucontrol)
3409 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3410 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
3413 static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3414 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3415 .info = stac92xx_dig_beep_switch_info,
3416 .get = stac92xx_dig_beep_switch_get,
3417 .put = stac92xx_dig_beep_switch_put,
3420 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3422 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3423 0, "Beep Playback Switch", 0);
3427 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3429 struct sigmatel_spec *spec = codec->spec;
3432 for (i = 0; i < spec->num_muxes; i++) {
3437 nid = spec->mux_nids[i];
3438 wcaps = get_wcaps(codec, nid);
3439 if (!(wcaps & AC_WCAP_OUT_AMP))
3442 /* check whether already the same control was created as
3443 * normal Capture Volume.
3445 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3446 for (j = 0; j < spec->num_caps; j++) {
3447 if (spec->capvols[j] == val)
3450 if (j < spec->num_caps)
3453 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3454 "Mux Capture Volume", val);
3461 static const char * const stac92xx_spdif_labels[3] = {
3462 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3465 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3467 struct sigmatel_spec *spec = codec->spec;
3468 struct hda_input_mux *spdif_mux = &spec->private_smux;
3469 const char * const *labels = spec->spdif_labels;
3471 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3473 num_cons = snd_hda_get_connections(codec,
3476 HDA_MAX_NUM_INPUTS);
3481 labels = stac92xx_spdif_labels;
3483 for (i = 0; i < num_cons; i++)
3484 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
3489 /* labels for dmic mux inputs */
3490 static const char * const stac92xx_dmic_labels[5] = {
3491 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3492 "Digital Mic 3", "Digital Mic 4"
3495 static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3498 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3500 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3501 if (idx >= 0 && idx < nums)
3506 /* look for NID recursively */
3507 #define get_connection_index(codec, mux, nid) \
3508 snd_hda_get_conn_index(codec, mux, nid, 1)
3510 /* create a volume assigned to the given pin (only if supported) */
3511 /* return 1 if the volume control is created */
3512 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3513 const char *label, int idx, int direction)
3515 unsigned int caps, nums;
3519 if (direction == HDA_OUTPUT)
3520 caps = AC_WCAP_OUT_AMP;
3522 caps = AC_WCAP_IN_AMP;
3523 if (!(get_wcaps(codec, nid) & caps))
3525 caps = query_amp_caps(codec, nid, direction);
3526 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3529 snprintf(name, sizeof(name), "%s Capture Volume", label);
3530 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3531 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3537 /* create playback/capture controls for input pins on dmic capable codecs */
3538 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3539 const struct auto_pin_cfg *cfg)
3541 struct sigmatel_spec *spec = codec->spec;
3542 struct hda_input_mux *imux = &spec->private_imux;
3543 struct hda_input_mux *dimux = &spec->private_dimux;
3545 unsigned int def_conf;
3547 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
3549 for (i = 0; i < spec->num_dmics; i++) {
3551 int index, type_idx;
3554 nid = spec->dmic_nids[i];
3555 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3557 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3558 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3561 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3565 label = hda_get_input_pin_label(codec, nid, 1);
3566 snd_hda_add_imux_item(dimux, label, index, &type_idx);
3567 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3568 snd_hda_add_imux_item(imux, label, index, &type_idx);
3570 err = create_elem_capture_vol(codec, nid, label, type_idx,
3575 err = create_elem_capture_vol(codec, nid, label,
3576 type_idx, HDA_OUTPUT);
3580 nid = get_connected_node(codec,
3581 spec->dmux_nids[0], index);
3583 err = create_elem_capture_vol(codec,
3585 type_idx, HDA_INPUT);
3595 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3596 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
3603 cfg = snd_hda_codec_get_pincfg(codec, nid);
3604 type = get_defcfg_device(cfg);
3605 switch (snd_hda_get_input_pin_attr(cfg)) {
3606 case INPUT_PIN_ATTR_INT:
3608 return 1; /* already occupied */
3609 if (type != AC_JACK_MIC_IN)
3610 return 1; /* invalid type */
3613 case INPUT_PIN_ATTR_UNUSED:
3615 case INPUT_PIN_ATTR_DOCK:
3617 return 1; /* already occupied */
3618 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3619 return 1; /* invalid type */
3624 return 1; /* already occupied */
3625 if (type != AC_JACK_MIC_IN)
3626 return 1; /* invalid type */
3633 static int set_mic_route(struct hda_codec *codec,
3634 struct sigmatel_mic_route *mic,
3637 struct sigmatel_spec *spec = codec->spec;
3638 struct auto_pin_cfg *cfg = &spec->autocfg;
3644 for (i = 0; i < cfg->num_inputs; i++) {
3645 if (pin == cfg->inputs[i].pin)
3648 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
3650 i = get_connection_index(codec, spec->mux_nids[0], pin);
3655 if (spec->dmux_nids)
3656 mic->dmux_idx = get_connection_index(codec,
3659 } else if (spec->dmux_nids) {
3661 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3667 mic->mux_idx = get_connection_index(codec,
3669 spec->dmux_nids[0]);
3674 /* return non-zero if the device is for automatic mic switch */
3675 static int stac_check_auto_mic(struct hda_codec *codec)
3677 struct sigmatel_spec *spec = codec->spec;
3678 struct auto_pin_cfg *cfg = &spec->autocfg;
3679 hda_nid_t fixed, ext, dock;
3682 fixed = ext = dock = 0;
3683 for (i = 0; i < cfg->num_inputs; i++)
3684 if (check_mic_pin(codec, cfg->inputs[i].pin,
3685 &fixed, &ext, &dock))
3687 for (i = 0; i < spec->num_dmics; i++)
3688 if (check_mic_pin(codec, spec->dmic_nids[i],
3689 &fixed, &ext, &dock))
3691 if (!fixed || (!ext && !dock))
3692 return 0; /* no input to switch */
3693 if (!is_jack_detectable(codec, ext))
3694 return 0; /* no unsol support */
3695 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3696 set_mic_route(codec, &spec->int_mic, fixed) ||
3697 set_mic_route(codec, &spec->dock_mic, dock))
3698 return 0; /* something is wrong */
3702 /* create playback/capture controls for input pins */
3703 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3705 struct sigmatel_spec *spec = codec->spec;
3706 struct hda_input_mux *imux = &spec->private_imux;
3710 for (i = 0; i < cfg->num_inputs; i++) {
3711 hda_nid_t nid = cfg->inputs[i].pin;
3712 int index, err, type_idx;
3715 for (j = 0; j < spec->num_muxes; j++) {
3716 index = get_connection_index(codec, spec->mux_nids[j],
3724 label = hda_get_autocfg_input_label(codec, cfg, i);
3725 snd_hda_add_imux_item(imux, label, index, &type_idx);
3727 err = create_elem_capture_vol(codec, nid,
3733 spec->num_analog_muxes = imux->num_items;
3735 if (imux->num_items) {
3737 * Set the current input for the muxes.
3738 * The STAC9221 has two input muxes with identical source
3739 * NID lists. Hopefully this won't get confused.
3741 for (i = 0; i < spec->num_muxes; i++) {
3742 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3743 AC_VERB_SET_CONNECT_SEL,
3744 imux->items[0].index);
3751 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3753 struct sigmatel_spec *spec = codec->spec;
3756 for (i = 0; i < spec->autocfg.line_outs; i++) {
3757 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3758 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3762 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3764 struct sigmatel_spec *spec = codec->spec;
3767 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3769 pin = spec->autocfg.hp_pins[i];
3770 if (pin) /* connect to front */
3771 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3773 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3775 pin = spec->autocfg.speaker_pins[i];
3776 if (pin) /* connect to front */
3777 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3781 static int is_dual_headphones(struct hda_codec *codec)
3783 struct sigmatel_spec *spec = codec->spec;
3786 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3787 spec->autocfg.hp_outs <= 1)
3790 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3791 hda_nid_t nid = spec->autocfg.hp_pins[i];
3792 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3793 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3797 return (valid_hps > 1);
3801 static int stac92xx_parse_auto_config(struct hda_codec *codec)
3803 struct sigmatel_spec *spec = codec->spec;
3804 hda_nid_t dig_out = 0, dig_in = 0;
3808 if ((err = snd_hda_parse_pin_def_config(codec,
3810 spec->dmic_nids)) < 0)
3812 if (! spec->autocfg.line_outs)
3813 return 0; /* can't find valid pin config */
3815 /* If we have no real line-out pin and multiple hp-outs, HPs should
3816 * be set up as multi-channel outputs.
3818 if (is_dual_headphones(codec)) {
3819 /* Copy hp_outs to line_outs, backup line_outs in
3820 * speaker_outs so that the following routines can handle
3821 * HP pins as primary outputs.
3823 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3824 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3825 sizeof(spec->autocfg.line_out_pins));
3826 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3827 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3828 sizeof(spec->autocfg.hp_pins));
3829 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3830 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3831 spec->autocfg.hp_outs = 0;
3834 if (spec->autocfg.mono_out_pin) {
3835 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3836 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3837 u32 caps = query_amp_caps(codec,
3838 spec->autocfg.mono_out_pin, dir);
3839 hda_nid_t conn_list[1];
3841 /* get the mixer node and then the mono mux if it exists */
3842 if (snd_hda_get_connections(codec,
3843 spec->autocfg.mono_out_pin, conn_list, 1) &&
3844 snd_hda_get_connections(codec, conn_list[0],
3845 conn_list, 1) > 0) {
3847 int wcaps = get_wcaps(codec, conn_list[0]);
3848 int wid_type = get_wcaps_type(wcaps);
3849 /* LR swap check, some stac925x have a mux that
3850 * changes the DACs output path instead of the
3853 if (wid_type == AC_WID_AUD_SEL &&
3854 !(wcaps & AC_WCAP_LR_SWAP))
3855 spec->mono_nid = conn_list[0];
3858 hda_nid_t nid = spec->autocfg.mono_out_pin;
3860 /* most mono outs have a least a mute/unmute switch */
3861 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3862 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3863 "Mono Playback Switch",
3864 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3867 /* check for volume support for the amp */
3868 if ((caps & AC_AMPCAP_NUM_STEPS)
3869 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3870 err = stac92xx_add_control(spec,
3871 STAC_CTL_WIDGET_VOL,
3872 "Mono Playback Volume",
3873 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3879 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3883 if (!spec->multiout.num_dacs) {
3884 err = stac92xx_auto_fill_dac_nids(codec);
3887 err = stac92xx_auto_create_multi_out_ctls(codec,
3893 /* setup analog beep controls */
3894 if (spec->anabeep_nid > 0) {
3895 err = stac92xx_auto_create_beep_ctls(codec,
3901 /* setup digital beep controls and input device */
3902 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3903 if (spec->digbeep_nid > 0) {
3904 hda_nid_t nid = spec->digbeep_nid;
3907 err = stac92xx_auto_create_beep_ctls(codec, nid);
3910 err = snd_hda_attach_beep_device(codec, nid);
3914 /* IDT/STAC codecs have linear beep tone parameter */
3915 codec->beep->linear_tone = spec->linear_tone_beep;
3916 /* if no beep switch is available, make its own one */
3917 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3918 if (!(caps & AC_AMPCAP_MUTE)) {
3919 err = stac92xx_beep_switch_ctl(codec);
3927 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3931 /* All output parsing done, now restore the swapped hp pins */
3933 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3934 sizeof(spec->autocfg.hp_pins));
3935 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3936 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3937 spec->autocfg.line_outs = 0;
3940 if (stac_check_auto_mic(codec)) {
3942 /* only one capture for auto-mic */
3945 spec->num_muxes = 1;
3948 for (i = 0; i < spec->num_caps; i++) {
3949 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3950 spec->capsws[i], i);
3955 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3959 if (spec->mono_nid > 0) {
3960 err = stac92xx_auto_create_mono_output_ctls(codec);
3964 if (spec->num_dmics > 0 && !spec->dinput_mux)
3965 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3966 &spec->autocfg)) < 0)
3968 if (spec->num_muxes > 0) {
3969 err = stac92xx_auto_create_mux_input_ctls(codec);
3973 if (spec->num_smuxes > 0) {
3974 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3979 err = stac92xx_add_input_source(spec);
3983 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3984 if (spec->multiout.max_channels > 2)
3985 spec->surr_switch = 1;
3987 /* find digital out and in converters */
3988 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3989 unsigned int wid_caps = get_wcaps(codec, i);
3990 if (wid_caps & AC_WCAP_DIGITAL) {
3991 switch (get_wcaps_type(wid_caps)) {
3992 case AC_WID_AUD_OUT:
4003 if (spec->autocfg.dig_outs)
4004 spec->multiout.dig_out_nid = dig_out;
4005 if (dig_in && spec->autocfg.dig_in_pin)
4006 spec->dig_in_nid = dig_in;
4008 if (spec->kctls.list)
4009 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4011 spec->input_mux = &spec->private_imux;
4012 if (!spec->dinput_mux)
4013 spec->dinput_mux = &spec->private_dimux;
4014 spec->sinput_mux = &spec->private_smux;
4015 spec->mono_mux = &spec->private_mono_mux;
4019 /* add playback controls for HP output */
4020 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4021 struct auto_pin_cfg *cfg)
4023 struct sigmatel_spec *spec = codec->spec;
4024 hda_nid_t pin = cfg->hp_pins[0];
4029 if (is_jack_detectable(codec, pin))
4030 spec->hp_detect = 1;
4035 /* add playback controls for LFE output */
4036 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4037 struct auto_pin_cfg *cfg)
4039 struct sigmatel_spec *spec = codec->spec;
4041 hda_nid_t lfe_pin = 0x0;
4045 * search speaker outs and line outs for a mono speaker pin
4046 * with an amp. If one is found, add LFE controls
4049 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4050 hda_nid_t pin = spec->autocfg.speaker_pins[i];
4051 unsigned int wcaps = get_wcaps(codec, pin);
4052 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4053 if (wcaps == AC_WCAP_OUT_AMP)
4054 /* found a mono speaker with an amp, must be lfe */
4058 /* if speaker_outs is 0, then speakers may be in line_outs */
4059 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4060 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4061 hda_nid_t pin = spec->autocfg.line_out_pins[i];
4062 unsigned int defcfg;
4063 defcfg = snd_hda_codec_get_pincfg(codec, pin);
4064 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
4065 unsigned int wcaps = get_wcaps(codec, pin);
4066 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4067 if (wcaps == AC_WCAP_OUT_AMP)
4068 /* found a mono speaker with an amp,
4076 err = create_controls(codec, "LFE", lfe_pin, 1);
4084 static int stac9200_parse_auto_config(struct hda_codec *codec)
4086 struct sigmatel_spec *spec = codec->spec;
4089 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
4092 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4095 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4098 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4101 if (spec->num_muxes > 0) {
4102 err = stac92xx_auto_create_mux_input_ctls(codec);
4107 err = stac92xx_add_input_source(spec);
4111 if (spec->autocfg.dig_outs)
4112 spec->multiout.dig_out_nid = 0x05;
4113 if (spec->autocfg.dig_in_pin)
4114 spec->dig_in_nid = 0x04;
4116 if (spec->kctls.list)
4117 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4119 spec->input_mux = &spec->private_imux;
4120 spec->dinput_mux = &spec->private_dimux;
4126 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4127 * funky external mute control using GPIO pins.
4130 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4131 unsigned int dir_mask, unsigned int data)
4133 unsigned int gpiostate, gpiomask, gpiodir;
4135 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4137 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4138 AC_VERB_GET_GPIO_DATA, 0);
4139 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4141 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4142 AC_VERB_GET_GPIO_MASK, 0);
4145 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4146 AC_VERB_GET_GPIO_DIRECTION, 0);
4147 gpiodir |= dir_mask;
4149 /* Configure GPIOx as CMOS */
4150 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4152 snd_hda_codec_write(codec, codec->afg, 0,
4153 AC_VERB_SET_GPIO_MASK, gpiomask);
4154 snd_hda_codec_read(codec, codec->afg, 0,
4155 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4159 snd_hda_codec_read(codec, codec->afg, 0,
4160 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4163 static int stac92xx_add_jack(struct hda_codec *codec,
4164 hda_nid_t nid, int type)
4166 #ifdef CONFIG_SND_HDA_INPUT_JACK
4167 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4168 int connectivity = get_defcfg_connect(def_conf);
4170 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4173 return snd_hda_input_jack_add(codec, nid, type, NULL);
4176 #endif /* CONFIG_SND_HDA_INPUT_JACK */
4179 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4180 unsigned char type, int data)
4182 struct sigmatel_event *event;
4184 snd_array_init(&spec->events, sizeof(*event), 32);
4185 event = snd_array_new(&spec->events);
4190 event->tag = spec->events.used;
4196 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4199 struct sigmatel_spec *spec = codec->spec;
4200 struct sigmatel_event *event = spec->events.list;
4203 for (i = 0; i < spec->events.used; i++, event++) {
4204 if (event->nid == nid)
4210 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4213 struct sigmatel_spec *spec = codec->spec;
4214 struct sigmatel_event *event = spec->events.list;
4217 for (i = 0; i < spec->events.used; i++, event++) {
4218 if (event->tag == tag)
4224 /* check if given nid is a valid pin and no other events are assigned
4225 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4226 * Otherwise, returns zero.
4228 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4231 struct sigmatel_event *event;
4234 if (!is_jack_detectable(codec, nid))
4236 event = stac_get_event(codec, nid);
4238 if (event->type != type)
4242 tag = stac_add_event(codec->spec, nid, type, 0);
4246 snd_hda_codec_write_cache(codec, nid, 0,
4247 AC_VERB_SET_UNSOLICITED_ENABLE,
4252 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4255 for (i = 0; i < cfg->hp_outs; i++)
4256 if (cfg->hp_pins[i] == nid)
4257 return 1; /* nid is a HP-Out */
4259 return 0; /* nid is not a HP-Out */
4262 static void stac92xx_power_down(struct hda_codec *codec)
4264 struct sigmatel_spec *spec = codec->spec;
4266 /* power down inactive DACs */
4267 const hda_nid_t *dac;
4268 for (dac = spec->dac_list; *dac; dac++)
4269 if (!check_all_dac_nids(spec, *dac))
4270 snd_hda_codec_write(codec, *dac, 0,
4271 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4274 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4277 static inline int get_int_hint(struct hda_codec *codec, const char *key,
4281 p = snd_hda_get_hint(codec, key);
4284 if (!strict_strtoul(p, 0, &val)) {
4292 /* override some hints from the hwdep entry */
4293 static void stac_store_hints(struct hda_codec *codec)
4295 struct sigmatel_spec *spec = codec->spec;
4298 val = snd_hda_get_bool_hint(codec, "hp_detect");
4300 spec->hp_detect = val;
4301 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
4302 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4305 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4306 spec->gpio_mask &= spec->gpio_mask;
4307 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4308 spec->gpio_dir &= spec->gpio_mask;
4309 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4310 spec->eapd_mask &= spec->gpio_mask;
4311 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4312 spec->gpio_mute &= spec->gpio_mask;
4313 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4315 spec->eapd_switch = val;
4316 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4317 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4318 spec->gpio_mask |= spec->gpio_led;
4319 spec->gpio_dir |= spec->gpio_led;
4320 if (spec->gpio_led_polarity)
4321 spec->gpio_data |= spec->gpio_led;
4325 static int stac92xx_init(struct hda_codec *codec)
4327 struct sigmatel_spec *spec = codec->spec;
4328 struct auto_pin_cfg *cfg = &spec->autocfg;
4332 snd_hda_sequence_write(codec, spec->init);
4334 /* power down adcs initially */
4335 if (spec->powerdown_adcs)
4336 for (i = 0; i < spec->num_adcs; i++)
4337 snd_hda_codec_write(codec,
4338 spec->adc_nids[i], 0,
4339 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4341 /* override some hints */
4342 stac_store_hints(codec);
4345 gpio = spec->gpio_data;
4346 /* turn on EAPD statically when spec->eapd_switch isn't set.
4347 * otherwise, unsol event will turn it on/off dynamically
4349 if (!spec->eapd_switch)
4350 gpio |= spec->eapd_mask;
4351 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4354 if (spec->hp_detect) {
4355 /* Enable unsolicited responses on the HP widget */
4356 for (i = 0; i < cfg->hp_outs; i++) {
4357 hda_nid_t nid = cfg->hp_pins[i];
4358 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4360 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4361 cfg->speaker_outs > 0) {
4362 /* enable pin-detect for line-outs as well */
4363 for (i = 0; i < cfg->line_outs; i++) {
4364 hda_nid_t nid = cfg->line_out_pins[i];
4365 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4369 /* force to enable the first line-out; the others are set up
4372 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4374 /* fake event to set up pins */
4375 if (cfg->hp_pins[0])
4376 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4377 else if (cfg->line_out_pins[0])
4378 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4380 stac92xx_auto_init_multi_out(codec);
4381 stac92xx_auto_init_hp_out(codec);
4382 for (i = 0; i < cfg->hp_outs; i++)
4383 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4385 if (spec->auto_mic) {
4386 /* initialize connection to analog input */
4387 if (spec->dmux_nids)
4388 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4389 AC_VERB_SET_CONNECT_SEL, 0);
4390 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4391 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4392 if (enable_pin_detect(codec, spec->dock_mic.pin,
4394 stac_issue_unsol_event(codec, spec->dock_mic.pin);
4396 for (i = 0; i < cfg->num_inputs; i++) {
4397 hda_nid_t nid = cfg->inputs[i].pin;
4398 int type = cfg->inputs[i].type;
4399 unsigned int pinctl, conf;
4400 if (type == AUTO_PIN_MIC) {
4401 /* for mic pins, force to initialize */
4402 pinctl = stac92xx_get_default_vref(codec, nid);
4403 pinctl |= AC_PINCTL_IN_EN;
4404 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4406 pinctl = snd_hda_codec_read(codec, nid, 0,
4407 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4408 /* if PINCTL already set then skip */
4409 /* Also, if both INPUT and OUTPUT are set,
4410 * it must be a BIOS bug; need to override, too
4412 if (!(pinctl & AC_PINCTL_IN_EN) ||
4413 (pinctl & AC_PINCTL_OUT_EN)) {
4414 pinctl &= ~AC_PINCTL_OUT_EN;
4415 pinctl |= AC_PINCTL_IN_EN;
4416 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4419 conf = snd_hda_codec_get_pincfg(codec, nid);
4420 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4421 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4422 stac_issue_unsol_event(codec, nid);
4425 for (i = 0; i < spec->num_dmics; i++)
4426 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4428 if (cfg->dig_out_pins[0])
4429 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4431 if (cfg->dig_in_pin)
4432 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4434 for (i = 0; i < spec->num_pwrs; i++) {
4435 hda_nid_t nid = spec->pwr_nids[i];
4436 int pinctl, def_conf;
4438 /* power on when no jack detection is available */
4439 /* or when the VREF is used for controlling LED */
4440 if (!spec->hp_detect ||
4441 spec->vref_mute_led_nid == nid) {
4442 stac_toggle_power_map(codec, nid, 1);
4446 if (is_nid_hp_pin(cfg, nid))
4447 continue; /* already has an unsol event */
4449 pinctl = snd_hda_codec_read(codec, nid, 0,
4450 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4451 /* outputs are only ports capable of power management
4452 * any attempts on powering down a input port cause the
4453 * referenced VREF to act quirky.
4455 if (pinctl & AC_PINCTL_IN_EN) {
4456 stac_toggle_power_map(codec, nid, 1);
4459 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4460 def_conf = get_defcfg_connect(def_conf);
4461 /* skip any ports that don't have jacks since presence
4462 * detection is useless */
4463 if (def_conf != AC_JACK_PORT_COMPLEX) {
4464 if (def_conf != AC_JACK_PORT_NONE)
4465 stac_toggle_power_map(codec, nid, 1);
4468 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
4469 stac_issue_unsol_event(codec, nid);
4472 /* none of the above, turn the port OFF */
4473 stac_toggle_power_map(codec, nid, 0);
4478 hda_call_check_power_status(codec, 0x01);
4480 stac92xx_power_down(codec);
4484 static void stac92xx_free_kctls(struct hda_codec *codec)
4486 struct sigmatel_spec *spec = codec->spec;
4488 if (spec->kctls.list) {
4489 struct snd_kcontrol_new *kctl = spec->kctls.list;
4491 for (i = 0; i < spec->kctls.used; i++)
4492 kfree(kctl[i].name);
4494 snd_array_free(&spec->kctls);
4497 static void stac92xx_shutup_pins(struct hda_codec *codec)
4499 unsigned int i, def_conf;
4501 if (codec->bus->shutdown)
4503 for (i = 0; i < codec->init_pins.used; i++) {
4504 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4505 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4506 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
4507 snd_hda_codec_write(codec, pin->nid, 0,
4508 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4512 static void stac92xx_shutup(struct hda_codec *codec)
4514 struct sigmatel_spec *spec = codec->spec;
4516 stac92xx_shutup_pins(codec);
4518 if (spec->eapd_mask)
4519 stac_gpio_set(codec, spec->gpio_mask,
4520 spec->gpio_dir, spec->gpio_data &
4524 static void stac92xx_free(struct hda_codec *codec)
4526 struct sigmatel_spec *spec = codec->spec;
4531 stac92xx_shutup(codec);
4532 snd_hda_input_jack_free(codec);
4533 snd_array_free(&spec->events);
4536 snd_hda_detach_beep_device(codec);
4539 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4542 unsigned int old_ctl, pin_ctl;
4544 pin_ctl = snd_hda_codec_read(codec, nid,
4545 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4547 if (pin_ctl & AC_PINCTL_IN_EN) {
4549 * we need to check the current set-up direction of
4550 * shared input pins since they can be switched via
4551 * "xxx as Output" mixer switch
4553 struct sigmatel_spec *spec = codec->spec;
4554 if (nid == spec->line_switch || nid == spec->mic_switch)
4559 /* if setting pin direction bits, clear the current
4560 direction bits first */
4561 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4562 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4565 if (old_ctl != pin_ctl)
4566 snd_hda_codec_write_cache(codec, nid, 0,
4567 AC_VERB_SET_PIN_WIDGET_CONTROL,
4571 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4574 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4575 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4577 snd_hda_codec_write_cache(codec, nid, 0,
4578 AC_VERB_SET_PIN_WIDGET_CONTROL,
4582 static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4586 return snd_hda_jack_detect(codec, nid);
4589 static void stac92xx_line_out_detect(struct hda_codec *codec,
4592 struct sigmatel_spec *spec = codec->spec;
4593 struct auto_pin_cfg *cfg = &spec->autocfg;
4596 for (i = 0; i < cfg->line_outs; i++) {
4599 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4601 unsigned int pinctl;
4602 pinctl = snd_hda_codec_read(codec,
4603 cfg->line_out_pins[i], 0,
4604 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4605 if (pinctl & AC_PINCTL_IN_EN)
4606 presence = 0; /* mic- or line-input */
4611 /* disable speakers */
4612 for (i = 0; i < cfg->speaker_outs; i++)
4613 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4615 if (spec->eapd_mask && spec->eapd_switch)
4616 stac_gpio_set(codec, spec->gpio_mask,
4617 spec->gpio_dir, spec->gpio_data &
4620 /* enable speakers */
4621 for (i = 0; i < cfg->speaker_outs; i++)
4622 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4624 if (spec->eapd_mask && spec->eapd_switch)
4625 stac_gpio_set(codec, spec->gpio_mask,
4626 spec->gpio_dir, spec->gpio_data |
4631 /* return non-zero if the hp-pin of the given array index isn't
4632 * a jack-detection target
4634 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4636 struct auto_pin_cfg *cfg = &spec->autocfg;
4638 /* ignore sensing of shared line and mic jacks */
4639 if (cfg->hp_pins[i] == spec->line_switch)
4641 if (cfg->hp_pins[i] == spec->mic_switch)
4643 /* ignore if the pin is set as line-out */
4644 if (cfg->hp_pins[i] == spec->hp_switch)
4649 static void stac92xx_hp_detect(struct hda_codec *codec)
4651 struct sigmatel_spec *spec = codec->spec;
4652 struct auto_pin_cfg *cfg = &spec->autocfg;
4656 if (spec->gpio_mute)
4657 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4658 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4660 for (i = 0; i < cfg->hp_outs; i++) {
4663 if (no_hp_sensing(spec, i))
4665 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4667 unsigned int pinctl;
4668 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4669 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4670 if (pinctl & AC_PINCTL_IN_EN)
4671 presence = 0; /* mic- or line-input */
4676 /* disable lineouts */
4677 if (spec->hp_switch)
4678 stac92xx_reset_pinctl(codec, spec->hp_switch,
4680 for (i = 0; i < cfg->line_outs; i++)
4681 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4684 /* enable lineouts */
4685 if (spec->hp_switch)
4686 stac92xx_set_pinctl(codec, spec->hp_switch,
4688 for (i = 0; i < cfg->line_outs; i++)
4689 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4692 stac92xx_line_out_detect(codec, presence);
4693 /* toggle hp outs */
4694 for (i = 0; i < cfg->hp_outs; i++) {
4695 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4696 if (no_hp_sensing(spec, i))
4699 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4701 /* Resetting the pinctl like below may lead to (a sort of) regressions
4702 * on some devices since they use the HP pin actually for line/speaker
4703 * outs although the default pin config shows a different pin (that is
4704 * wrong and useless).
4706 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4707 * But, disabling the code below just works around it, and I'm too tired of
4708 * bug reports with such devices...
4711 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4716 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4719 struct sigmatel_spec *spec = codec->spec;
4720 unsigned int idx, val;
4722 for (idx = 0; idx < spec->num_pwrs; idx++) {
4723 if (spec->pwr_nids[idx] == nid)
4726 if (idx >= spec->num_pwrs)
4731 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4737 /* power down unused output ports */
4738 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4741 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4743 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4746 /* get the pin connection (fixed, none, etc) */
4747 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4749 struct sigmatel_spec *spec = codec->spec;
4752 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4753 return get_defcfg_connect(cfg);
4756 static int stac92xx_connected_ports(struct hda_codec *codec,
4757 const hda_nid_t *nids, int num_nids)
4759 struct sigmatel_spec *spec = codec->spec;
4761 unsigned int def_conf;
4763 for (num = 0; num < num_nids; num++) {
4764 for (idx = 0; idx < spec->num_pins; idx++)
4765 if (spec->pin_nids[idx] == nids[num])
4767 if (idx >= spec->num_pins)
4769 def_conf = stac_get_defcfg_connect(codec, idx);
4770 if (def_conf == AC_JACK_PORT_NONE)
4776 static void stac92xx_mic_detect(struct hda_codec *codec)
4778 struct sigmatel_spec *spec = codec->spec;
4779 struct sigmatel_mic_route *mic;
4781 if (get_pin_presence(codec, spec->ext_mic.pin))
4782 mic = &spec->ext_mic;
4783 else if (get_pin_presence(codec, spec->dock_mic.pin))
4784 mic = &spec->dock_mic;
4786 mic = &spec->int_mic;
4787 if (mic->dmux_idx >= 0)
4788 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4789 AC_VERB_SET_CONNECT_SEL,
4791 if (mic->mux_idx >= 0)
4792 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4793 AC_VERB_SET_CONNECT_SEL,
4797 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4799 struct sigmatel_event *event = stac_get_event(codec, nid);
4802 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4805 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4807 struct sigmatel_spec *spec = codec->spec;
4808 struct sigmatel_event *event;
4811 tag = (res >> 26) & 0x7f;
4812 event = stac_get_event_from_tag(codec, tag);
4816 switch (event->type) {
4819 stac92xx_hp_detect(codec);
4821 case STAC_MIC_EVENT:
4822 stac92xx_mic_detect(codec);
4826 switch (event->type) {
4829 case STAC_MIC_EVENT:
4830 case STAC_INSERT_EVENT:
4831 case STAC_PWR_EVENT:
4832 if (spec->num_pwrs > 0)
4833 stac92xx_pin_sense(codec, event->nid);
4834 snd_hda_input_jack_report(codec, event->nid);
4836 switch (codec->subsystem_id) {
4838 if (event->nid == 0xb) {
4839 int pin = AC_PINCTL_IN_EN;
4841 if (get_pin_presence(codec, 0xa)
4842 && get_pin_presence(codec, 0xb))
4843 pin |= AC_PINCTL_VREF_80;
4844 if (!get_pin_presence(codec, 0xb))
4845 pin |= AC_PINCTL_VREF_80;
4847 /* toggle VREF state based on mic + hp pin
4850 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4854 case STAC_VREF_EVENT:
4855 data = snd_hda_codec_read(codec, codec->afg, 0,
4856 AC_VERB_GET_GPIO_DATA, 0);
4857 /* toggle VREF state based on GPIOx status */
4858 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4859 !!(data & (1 << event->data)));
4864 static int hp_blike_system(u32 subsystem_id);
4866 static void set_hp_led_gpio(struct hda_codec *codec)
4868 struct sigmatel_spec *spec = codec->spec;
4874 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4875 gpio &= AC_GPIO_IO_COUNT;
4877 spec->gpio_led = 0x08; /* GPIO 3 */
4879 spec->gpio_led = 0x01; /* GPIO 0 */
4883 * This method searches for the mute LED GPIO configuration
4884 * provided as OEM string in SMBIOS. The format of that string
4885 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4886 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4887 * that corresponds to the NOT muted state of the master volume
4888 * and G is the index of the GPIO to use as the mute LED control (0..9)
4889 * If _G portion is missing it is assigned based on the codec ID
4891 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4892 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4895 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4896 * SMBIOS - at least the ones I have seen do not have them - which include
4897 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4898 * HP Pavilion dv9500t CTO.
4899 * Need more information on whether it is true across the entire series.
4902 static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
4904 struct sigmatel_spec *spec = codec->spec;
4905 const struct dmi_device *dev = NULL;
4907 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4908 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4910 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
4911 &spec->gpio_led_polarity,
4912 &spec->gpio_led) == 2) {
4913 unsigned int max_gpio;
4914 max_gpio = snd_hda_param_read(codec, codec->afg,
4916 max_gpio &= AC_GPIO_IO_COUNT;
4917 if (spec->gpio_led < max_gpio)
4918 spec->gpio_led = 1 << spec->gpio_led;
4920 spec->vref_mute_led_nid = spec->gpio_led;
4923 if (sscanf(dev->name, "HP_Mute_LED_%d",
4924 &spec->gpio_led_polarity) == 1) {
4925 set_hp_led_gpio(codec);
4931 * Fallback case - if we don't find the DMI strings,
4932 * we statically set the GPIO - if not a B-series system
4933 * and default polarity is provided
4935 if (!hp_blike_system(codec->subsystem_id) &&
4936 (default_polarity == 0 || default_polarity == 1)) {
4937 set_hp_led_gpio(codec);
4938 spec->gpio_led_polarity = default_polarity;
4945 static int hp_blike_system(u32 subsystem_id)
4947 switch (subsystem_id) {
4974 #ifdef CONFIG_PROC_FS
4975 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4976 struct hda_codec *codec, hda_nid_t nid)
4978 if (nid == codec->afg)
4979 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4980 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4983 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4984 struct hda_codec *codec,
4987 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4988 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4991 /* stac92hd71bxx, stac92hd73xx */
4992 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4993 struct hda_codec *codec, hda_nid_t nid)
4995 stac92hd_proc_hook(buffer, codec, nid);
4996 if (nid == codec->afg)
4997 analog_loop_proc_hook(buffer, codec, 0xfa0);
5000 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
5001 struct hda_codec *codec, hda_nid_t nid)
5003 if (nid == codec->afg)
5004 analog_loop_proc_hook(buffer, codec, 0xfe0);
5007 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
5008 struct hda_codec *codec, hda_nid_t nid)
5010 if (nid == codec->afg)
5011 analog_loop_proc_hook(buffer, codec, 0xfeb);
5014 #define stac92hd_proc_hook NULL
5015 #define stac92hd7x_proc_hook NULL
5016 #define stac9205_proc_hook NULL
5017 #define stac927x_proc_hook NULL
5021 static int stac92xx_resume(struct hda_codec *codec)
5023 struct sigmatel_spec *spec = codec->spec;
5025 stac92xx_init(codec);
5026 snd_hda_codec_resume_amp(codec);
5027 snd_hda_codec_resume_cache(codec);
5028 /* fake event to set up pins again to override cached values */
5029 if (spec->hp_detect) {
5030 if (spec->autocfg.hp_pins[0])
5031 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
5032 else if (spec->autocfg.line_out_pins[0])
5033 stac_issue_unsol_event(codec,
5034 spec->autocfg.line_out_pins[0]);
5039 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5041 stac92xx_shutup(codec);
5045 #ifdef CONFIG_SND_HDA_POWER_SAVE
5046 static int stac92xx_pre_resume(struct hda_codec *codec)
5048 struct sigmatel_spec *spec = codec->spec;
5051 if (spec->vref_mute_led_nid)
5052 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5054 else if (spec->gpio_led)
5055 stac_gpio_set(codec, spec->gpio_mask,
5056 spec->gpio_dir, spec->gpio_data);
5060 static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5061 unsigned int power_state)
5063 unsigned int afg_power_state = power_state;
5064 struct sigmatel_spec *spec = codec->spec;
5066 if (power_state == AC_PWRST_D3) {
5067 if (spec->vref_mute_led_nid) {
5068 /* with vref-out pin used for mute led control
5069 * codec AFG is prevented from D3 state
5071 afg_power_state = AC_PWRST_D1;
5073 /* this delay seems necessary to avoid click noise at power-down */
5076 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5078 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5082 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed
5083 * as mute LED state is updated in check_power_status hook
5085 static int stac92xx_update_led_status(struct hda_codec *codec)
5087 struct sigmatel_spec *spec = codec->spec;
5088 int i, num_ext_dacs, muted = 1;
5089 unsigned int muted_lvl, notmtd_lvl;
5092 if (!spec->gpio_led)
5095 for (i = 0; i < spec->multiout.num_dacs; i++) {
5096 nid = spec->multiout.dac_nids[i];
5097 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
5099 muted = 0; /* something heard */
5103 if (muted && spec->multiout.hp_nid)
5104 if (!(snd_hda_codec_amp_read(codec,
5105 spec->multiout.hp_nid, 0, HDA_OUTPUT, 0) &
5107 muted = 0; /* HP is not muted */
5109 num_ext_dacs = ARRAY_SIZE(spec->multiout.extra_out_nid);
5110 for (i = 0; muted && i < num_ext_dacs; i++) {
5111 nid = spec->multiout.extra_out_nid[i];
5114 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
5116 muted = 0; /* extra output is not muted */
5119 /*polarity defines *not* muted state level*/
5120 if (!spec->vref_mute_led_nid) {
5122 spec->gpio_data &= ~spec->gpio_led; /* orange */
5124 spec->gpio_data |= spec->gpio_led; /* white */
5126 if (!spec->gpio_led_polarity) {
5127 /* LED state is inverted on these systems */
5128 spec->gpio_data ^= spec->gpio_led;
5130 stac_gpio_set(codec, spec->gpio_mask,
5131 spec->gpio_dir, spec->gpio_data);
5133 notmtd_lvl = spec->gpio_led_polarity ?
5134 AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_GRD;
5135 muted_lvl = spec->gpio_led_polarity ?
5136 AC_PINCTL_VREF_GRD : AC_PINCTL_VREF_HIZ;
5137 spec->vref_led = muted ? muted_lvl : notmtd_lvl;
5138 stac_vrefout_set(codec, spec->vref_mute_led_nid,
5145 * use power check for controlling mute led of HP notebooks
5147 static int stac92xx_check_power_status(struct hda_codec *codec,
5150 stac92xx_update_led_status(codec);
5154 #endif /* CONFIG_SND_HDA_POWER_SAVE */
5155 #endif /* CONFIG_PM */
5157 static const struct hda_codec_ops stac92xx_patch_ops = {
5158 .build_controls = stac92xx_build_controls,
5159 .build_pcms = stac92xx_build_pcms,
5160 .init = stac92xx_init,
5161 .free = stac92xx_free,
5162 .unsol_event = stac92xx_unsol_event,
5164 .suspend = stac92xx_suspend,
5165 .resume = stac92xx_resume,
5167 .reboot_notify = stac92xx_shutup,
5170 static int patch_stac9200(struct hda_codec *codec)
5172 struct sigmatel_spec *spec;
5175 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5179 codec->no_trigger_sense = 1;
5181 spec->linear_tone_beep = 1;
5182 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
5183 spec->pin_nids = stac9200_pin_nids;
5184 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5187 if (spec->board_config < 0)
5188 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5191 stac92xx_set_config_regs(codec,
5192 stac9200_brd_tbl[spec->board_config]);
5194 spec->multiout.max_channels = 2;
5195 spec->multiout.num_dacs = 1;
5196 spec->multiout.dac_nids = stac9200_dac_nids;
5197 spec->adc_nids = stac9200_adc_nids;
5198 spec->mux_nids = stac9200_mux_nids;
5199 spec->num_muxes = 1;
5200 spec->num_dmics = 0;
5204 if (spec->board_config == STAC_9200_M4 ||
5205 spec->board_config == STAC_9200_M4_2 ||
5206 spec->board_config == STAC_9200_OQO)
5207 spec->init = stac9200_eapd_init;
5209 spec->init = stac9200_core_init;
5210 spec->mixer = stac9200_mixer;
5212 if (spec->board_config == STAC_9200_PANASONIC) {
5213 spec->gpio_mask = spec->gpio_dir = 0x09;
5214 spec->gpio_data = 0x00;
5217 err = stac9200_parse_auto_config(codec);
5219 stac92xx_free(codec);
5223 /* CF-74 has no headphone detection, and the driver should *NOT*
5224 * do detection and HP/speaker toggle because the hardware does it.
5226 if (spec->board_config == STAC_9200_PANASONIC)
5227 spec->hp_detect = 0;
5229 codec->patch_ops = stac92xx_patch_ops;
5234 static int patch_stac925x(struct hda_codec *codec)
5236 struct sigmatel_spec *spec;
5239 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5243 codec->no_trigger_sense = 1;
5245 spec->linear_tone_beep = 1;
5246 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
5247 spec->pin_nids = stac925x_pin_nids;
5249 /* Check first for codec ID */
5250 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5253 stac925x_codec_id_cfg_tbl);
5255 /* Now checks for PCI ID, if codec ID is not found */
5256 if (spec->board_config < 0)
5257 spec->board_config = snd_hda_check_board_config(codec,
5262 if (spec->board_config < 0)
5263 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5266 stac92xx_set_config_regs(codec,
5267 stac925x_brd_tbl[spec->board_config]);
5269 spec->multiout.max_channels = 2;
5270 spec->multiout.num_dacs = 1;
5271 spec->multiout.dac_nids = stac925x_dac_nids;
5272 spec->adc_nids = stac925x_adc_nids;
5273 spec->mux_nids = stac925x_mux_nids;
5274 spec->num_muxes = 1;
5277 switch (codec->vendor_id) {
5278 case 0x83847632: /* STAC9202 */
5279 case 0x83847633: /* STAC9202D */
5280 case 0x83847636: /* STAC9251 */
5281 case 0x83847637: /* STAC9251D */
5282 spec->num_dmics = STAC925X_NUM_DMICS;
5283 spec->dmic_nids = stac925x_dmic_nids;
5284 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5285 spec->dmux_nids = stac925x_dmux_nids;
5288 spec->num_dmics = 0;
5292 spec->init = stac925x_core_init;
5293 spec->mixer = stac925x_mixer;
5295 spec->capvols = stac925x_capvols;
5296 spec->capsws = stac925x_capsws;
5298 err = stac92xx_parse_auto_config(codec);
5300 if (spec->board_config < 0) {
5301 printk(KERN_WARNING "hda_codec: No auto-config is "
5302 "available, default to model=ref\n");
5303 spec->board_config = STAC_925x_REF;
5309 stac92xx_free(codec);
5313 codec->patch_ops = stac92xx_patch_ops;
5318 static int patch_stac92hd73xx(struct hda_codec *codec)
5320 struct sigmatel_spec *spec;
5321 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5325 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5329 codec->no_trigger_sense = 1;
5331 spec->linear_tone_beep = 0;
5332 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5333 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5334 spec->pin_nids = stac92hd73xx_pin_nids;
5335 spec->board_config = snd_hda_check_board_config(codec,
5336 STAC_92HD73XX_MODELS,
5337 stac92hd73xx_models,
5338 stac92hd73xx_cfg_tbl);
5339 /* check codec subsystem id if not found */
5340 if (spec->board_config < 0)
5341 spec->board_config =
5342 snd_hda_check_board_codec_sid_config(codec,
5343 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5344 stac92hd73xx_codec_id_cfg_tbl);
5346 if (spec->board_config < 0)
5347 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5350 stac92xx_set_config_regs(codec,
5351 stac92hd73xx_brd_tbl[spec->board_config]);
5353 num_dacs = snd_hda_get_connections(codec, 0x0a,
5354 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5356 if (num_dacs < 3 || num_dacs > 5) {
5357 printk(KERN_WARNING "hda_codec: Could not determine "
5358 "number of channels defaulting to DAC count\n");
5359 num_dacs = STAC92HD73_DAC_COUNT;
5361 spec->init = stac92hd73xx_core_init;
5363 case 0x3: /* 6 Channel */
5364 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5366 case 0x4: /* 8 Channel */
5367 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5369 case 0x5: /* 10 Channel */
5370 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5373 spec->multiout.dac_nids = spec->dac_nids;
5375 spec->aloopback_mask = 0x01;
5376 spec->aloopback_shift = 8;
5378 spec->digbeep_nid = 0x1c;
5379 spec->mux_nids = stac92hd73xx_mux_nids;
5380 spec->adc_nids = stac92hd73xx_adc_nids;
5381 spec->dmic_nids = stac92hd73xx_dmic_nids;
5382 spec->dmux_nids = stac92hd73xx_dmux_nids;
5383 spec->smux_nids = stac92hd73xx_smux_nids;
5385 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5386 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5387 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5389 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5390 spec->capvols = stac92hd73xx_capvols;
5391 spec->capsws = stac92hd73xx_capsws;
5393 switch (spec->board_config) {
5395 spec->init = dell_eq_core_init;
5397 case STAC_DELL_M6_AMIC:
5398 case STAC_DELL_M6_DMIC:
5399 case STAC_DELL_M6_BOTH:
5400 spec->num_smuxes = 0;
5401 spec->eapd_switch = 0;
5403 switch (spec->board_config) {
5404 case STAC_DELL_M6_AMIC: /* Analog Mics */
5405 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5406 spec->num_dmics = 0;
5408 case STAC_DELL_M6_DMIC: /* Digital Mics */
5409 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5410 spec->num_dmics = 1;
5412 case STAC_DELL_M6_BOTH: /* Both */
5413 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5414 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5415 spec->num_dmics = 1;
5419 case STAC_ALIENWARE_M17X:
5420 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5421 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5422 spec->eapd_switch = 0;
5425 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5426 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5427 spec->eapd_switch = 1;
5430 if (spec->board_config != STAC_92HD73XX_REF) {
5431 /* GPIO0 High = Enable EAPD */
5432 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5433 spec->gpio_data = 0x01;
5436 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5437 spec->pwr_nids = stac92hd73xx_pwr_nids;
5439 err = stac92xx_parse_auto_config(codec);
5442 if (spec->board_config < 0) {
5443 printk(KERN_WARNING "hda_codec: No auto-config is "
5444 "available, default to model=ref\n");
5445 spec->board_config = STAC_92HD73XX_REF;
5452 stac92xx_free(codec);
5456 if (spec->board_config == STAC_92HD73XX_NO_JD)
5457 spec->hp_detect = 0;
5459 codec->patch_ops = stac92xx_patch_ops;
5461 codec->proc_widget_hook = stac92hd7x_proc_hook;
5466 static int hp_bnb2011_with_dock(struct hda_codec *codec)
5468 if (codec->vendor_id != 0x111d7605 &&
5469 codec->vendor_id != 0x111d76d1)
5472 switch (codec->subsystem_id) {
5506 static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5508 struct sigmatel_spec *spec = codec->spec;
5509 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5512 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5513 spec->auto_pin_cnt++;
5515 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5516 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5517 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5518 if (nid == stac92hd83xxx_dmic_nids[i]) {
5519 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5520 spec->auto_dmic_cnt++;
5526 static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5528 struct sigmatel_spec *spec = codec->spec;
5530 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5531 spec->auto_adc_cnt++;
5534 static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5537 struct sigmatel_spec *spec = codec->spec;
5539 for (i = 0; i < spec->auto_adc_cnt; i++) {
5540 if (get_connection_index(codec,
5541 spec->auto_adc_nids[i], nid) >= 0) {
5542 /* mux and volume for adc_nids[i] */
5543 if (!spec->auto_mux_nids[i]) {
5544 spec->auto_mux_nids[i] = nid;
5545 /* 92hd codecs capture volume is in mux */
5546 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5549 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5550 if (get_connection_index(codec, nid,
5551 spec->auto_dmic_nids[j]) >= 0) {
5552 /* dmux for adc_nids[i] */
5553 if (!spec->auto_dmux_nids[i])
5554 spec->auto_dmux_nids[i] = nid;
5563 static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5565 hda_nid_t nid, end_nid;
5566 unsigned int wid_caps, wid_type;
5567 struct sigmatel_spec *spec = codec->spec;
5569 end_nid = codec->start_nid + codec->num_nodes;
5571 for (nid = codec->start_nid; nid < end_nid; nid++) {
5572 wid_caps = get_wcaps(codec, nid);
5573 wid_type = get_wcaps_type(wid_caps);
5575 if (wid_type == AC_WID_PIN)
5576 stac92hd8x_add_pin(codec, nid);
5578 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5579 stac92hd8x_add_adc(codec, nid);
5582 for (nid = codec->start_nid; nid < end_nid; nid++) {
5583 wid_caps = get_wcaps(codec, nid);
5584 wid_type = get_wcaps_type(wid_caps);
5586 if (wid_type == AC_WID_AUD_SEL)
5587 stac92hd8x_add_mux(codec, nid);
5590 spec->pin_nids = spec->auto_pin_nids;
5591 spec->num_pins = spec->auto_pin_cnt;
5592 spec->adc_nids = spec->auto_adc_nids;
5593 spec->num_adcs = spec->auto_adc_cnt;
5594 spec->capvols = spec->auto_capvols;
5595 spec->capsws = spec->auto_capvols;
5596 spec->num_caps = spec->auto_adc_cnt;
5597 spec->mux_nids = spec->auto_mux_nids;
5598 spec->num_muxes = spec->auto_adc_cnt;
5599 spec->dmux_nids = spec->auto_dmux_nids;
5600 spec->num_dmuxes = spec->auto_adc_cnt;
5601 spec->dmic_nids = spec->auto_dmic_nids;
5602 spec->num_dmics = spec->auto_dmic_cnt;
5605 static int patch_stac92hd83xxx(struct hda_codec *codec)
5607 struct sigmatel_spec *spec;
5610 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5614 if (hp_bnb2011_with_dock(codec)) {
5615 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5616 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5619 codec->no_trigger_sense = 1;
5622 stac92hd8x_fill_auto_spec(codec);
5624 spec->linear_tone_beep = 0;
5625 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5626 spec->digbeep_nid = 0x21;
5627 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5628 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5629 spec->multiout.dac_nids = spec->dac_nids;
5630 spec->init = stac92hd83xxx_core_init;
5632 spec->board_config = snd_hda_check_board_config(codec,
5633 STAC_92HD83XXX_MODELS,
5634 stac92hd83xxx_models,
5635 stac92hd83xxx_cfg_tbl);
5637 if (spec->board_config < 0)
5638 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5641 stac92xx_set_config_regs(codec,
5642 stac92hd83xxx_brd_tbl[spec->board_config]);
5644 codec->patch_ops = stac92xx_patch_ops;
5646 if (find_mute_led_cfg(codec, -1/*no default cfg*/))
5647 snd_printd("mute LED gpio %d polarity %d\n",
5649 spec->gpio_led_polarity);
5651 #ifdef CONFIG_SND_HDA_POWER_SAVE
5652 if (spec->gpio_led) {
5653 if (!spec->vref_mute_led_nid) {
5654 spec->gpio_mask |= spec->gpio_led;
5655 spec->gpio_dir |= spec->gpio_led;
5656 spec->gpio_data |= spec->gpio_led;
5658 codec->patch_ops.set_power_state =
5659 stac92xx_set_power_state;
5661 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5662 codec->patch_ops.check_power_status =
5663 stac92xx_check_power_status;
5667 err = stac92xx_parse_auto_config(codec);
5669 if (spec->board_config < 0) {
5670 printk(KERN_WARNING "hda_codec: No auto-config is "
5671 "available, default to model=ref\n");
5672 spec->board_config = STAC_92HD83XXX_REF;
5679 stac92xx_free(codec);
5683 codec->proc_widget_hook = stac92hd_proc_hook;
5688 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5691 struct sigmatel_spec *spec = codec->spec;
5694 for (idx = 0; idx < spec->num_pins; idx++)
5695 if (spec->pin_nids[idx] == dig0pin)
5697 if ((idx + 2) >= spec->num_pins)
5701 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5704 /* dig0pin + dig2pin case */
5705 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5707 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5713 /* HP dv7 bass switch - GPIO5 */
5714 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5715 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5716 struct snd_ctl_elem_value *ucontrol)
5718 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5719 struct sigmatel_spec *spec = codec->spec;
5720 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5724 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5725 struct snd_ctl_elem_value *ucontrol)
5727 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5728 struct sigmatel_spec *spec = codec->spec;
5729 unsigned int gpio_data;
5731 gpio_data = (spec->gpio_data & ~0x20) |
5732 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5733 if (gpio_data == spec->gpio_data)
5735 spec->gpio_data = gpio_data;
5736 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5740 static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
5741 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5742 .info = stac_hp_bass_gpio_info,
5743 .get = stac_hp_bass_gpio_get,
5744 .put = stac_hp_bass_gpio_put,
5747 static int stac_add_hp_bass_switch(struct hda_codec *codec)
5749 struct sigmatel_spec *spec = codec->spec;
5751 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5752 "Bass Speaker Playback Switch", 0))
5755 spec->gpio_mask |= 0x20;
5756 spec->gpio_dir |= 0x20;
5757 spec->gpio_data |= 0x20;
5761 static int patch_stac92hd71bxx(struct hda_codec *codec)
5763 struct sigmatel_spec *spec;
5764 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5765 unsigned int pin_cfg;
5768 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5772 codec->no_trigger_sense = 1;
5774 spec->linear_tone_beep = 0;
5775 codec->patch_ops = stac92xx_patch_ops;
5776 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5777 switch (codec->vendor_id) {
5780 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5784 /* On 92HD75Bx 0x27 isn't a pin nid */
5788 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5790 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5791 spec->board_config = snd_hda_check_board_config(codec,
5792 STAC_92HD71BXX_MODELS,
5793 stac92hd71bxx_models,
5794 stac92hd71bxx_cfg_tbl);
5796 if (spec->board_config < 0)
5797 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5800 stac92xx_set_config_regs(codec,
5801 stac92hd71bxx_brd_tbl[spec->board_config]);
5803 if (spec->board_config != STAC_92HD71BXX_REF) {
5805 spec->gpio_mask = 0x01;
5806 spec->gpio_dir = 0x01;
5807 spec->gpio_data = 0x01;
5810 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5811 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5813 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5814 spec->capvols = stac92hd71bxx_capvols;
5815 spec->capsws = stac92hd71bxx_capsws;
5817 switch (codec->vendor_id) {
5818 case 0x111d76b6: /* 4 Port without Analog Mixer */
5822 case 0x111d76b4: /* 6 Port without Analog Mixer */
5824 spec->init = stac92hd71bxx_core_init;
5825 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5826 spec->num_dmics = stac92xx_connected_ports(codec,
5827 stac92hd71bxx_dmic_nids,
5828 STAC92HD71BXX_NUM_DMICS);
5830 case 0x111d7608: /* 5 Port with Analog Mixer */
5831 switch (spec->board_config) {
5833 /* Enable VREF power saving on GPIO1 detect */
5834 err = stac_add_event(spec, codec->afg,
5835 STAC_VREF_EVENT, 0x02);
5838 snd_hda_codec_write_cache(codec, codec->afg, 0,
5839 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5840 snd_hda_codec_write_cache(codec, codec->afg, 0,
5841 AC_VERB_SET_UNSOLICITED_ENABLE,
5843 spec->gpio_mask |= 0x02;
5846 if ((codec->revision_id & 0xf) == 0 ||
5847 (codec->revision_id & 0xf) == 1)
5848 spec->stream_delay = 40; /* 40 milliseconds */
5851 spec->init = stac92hd71bxx_core_init;
5853 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5854 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5855 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
5856 spec->num_dmics = stac92xx_connected_ports(codec,
5857 stac92hd71bxx_dmic_5port_nids,
5858 STAC92HD71BXX_NUM_DMICS - 1);
5860 case 0x111d7603: /* 6 Port with Analog Mixer */
5861 if ((codec->revision_id & 0xf) == 1)
5862 spec->stream_delay = 40; /* 40 milliseconds */
5866 spec->init = stac92hd71bxx_core_init;
5867 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5868 spec->num_dmics = stac92xx_connected_ports(codec,
5869 stac92hd71bxx_dmic_nids,
5870 STAC92HD71BXX_NUM_DMICS);
5874 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5875 snd_hda_sequence_write_cache(codec, unmute_init);
5877 spec->aloopback_ctl = stac92hd71bxx_loopback;
5878 spec->aloopback_mask = 0x50;
5879 spec->aloopback_shift = 0;
5881 spec->powerdown_adcs = 1;
5882 spec->digbeep_nid = 0x26;
5883 spec->mux_nids = stac92hd71bxx_mux_nids;
5884 spec->adc_nids = stac92hd71bxx_adc_nids;
5885 spec->smux_nids = stac92hd71bxx_smux_nids;
5886 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5888 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5889 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5890 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5891 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5893 snd_printdd("Found board config: %d\n", spec->board_config);
5895 switch (spec->board_config) {
5897 /* enable internal microphone */
5898 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5899 stac92xx_auto_set_pinctl(codec, 0x0e,
5900 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5902 case STAC_DELL_M4_2:
5903 spec->num_dmics = 0;
5904 spec->num_smuxes = 0;
5905 spec->num_dmuxes = 0;
5907 case STAC_DELL_M4_1:
5908 case STAC_DELL_M4_3:
5909 spec->num_dmics = 1;
5910 spec->num_smuxes = 0;
5911 spec->num_dmuxes = 1;
5913 case STAC_HP_DV4_1222NR:
5914 spec->num_dmics = 1;
5915 /* I don't know if it needs 1 or 2 smuxes - will wait for
5916 * bug reports to fix if needed
5918 spec->num_smuxes = 1;
5919 spec->num_dmuxes = 1;
5922 spec->gpio_led = 0x01;
5925 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5926 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5927 /* HP dv6 gives the headphone pin as a line-out. Thus we
5928 * need to set hp_detect flag here to force to enable HP
5931 spec->hp_detect = 1;
5934 spec->num_dmics = 1;
5935 spec->num_dmuxes = 1;
5936 spec->num_smuxes = 1;
5937 spec->gpio_led = 0x08;
5941 if (hp_blike_system(codec->subsystem_id)) {
5942 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5943 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5944 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5945 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5946 /* It was changed in the BIOS to just satisfy MS DTM.
5947 * Lets turn it back into slaved HP
5949 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5950 | (AC_JACK_HP_OUT <<
5951 AC_DEFCFG_DEVICE_SHIFT);
5952 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5953 | AC_DEFCFG_SEQUENCE)))
5955 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5959 if (find_mute_led_cfg(codec, 1))
5960 snd_printd("mute LED gpio %d polarity %d\n",
5962 spec->gpio_led_polarity);
5964 #ifdef CONFIG_SND_HDA_POWER_SAVE
5965 if (spec->gpio_led) {
5966 if (!spec->vref_mute_led_nid) {
5967 spec->gpio_mask |= spec->gpio_led;
5968 spec->gpio_dir |= spec->gpio_led;
5969 spec->gpio_data |= spec->gpio_led;
5971 codec->patch_ops.set_power_state =
5972 stac92xx_set_power_state;
5974 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5975 codec->patch_ops.check_power_status =
5976 stac92xx_check_power_status;
5980 spec->multiout.dac_nids = spec->dac_nids;
5982 err = stac92xx_parse_auto_config(codec);
5984 if (spec->board_config < 0) {
5985 printk(KERN_WARNING "hda_codec: No auto-config is "
5986 "available, default to model=ref\n");
5987 spec->board_config = STAC_92HD71BXX_REF;
5994 stac92xx_free(codec);
5998 /* enable bass on HP dv7 */
5999 if (spec->board_config == STAC_HP_DV4 ||
6000 spec->board_config == STAC_HP_DV5) {
6002 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
6003 cap &= AC_GPIO_IO_COUNT;
6005 stac_add_hp_bass_switch(codec);
6008 codec->proc_widget_hook = stac92hd7x_proc_hook;
6013 static int patch_stac922x(struct hda_codec *codec)
6015 struct sigmatel_spec *spec;
6018 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6022 codec->no_trigger_sense = 1;
6024 spec->linear_tone_beep = 1;
6025 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
6026 spec->pin_nids = stac922x_pin_nids;
6027 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
6030 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
6031 spec->gpio_mask = spec->gpio_dir = 0x03;
6032 spec->gpio_data = 0x03;
6033 /* Intel Macs have all same PCI SSID, so we need to check
6034 * codec SSID to distinguish the exact models
6036 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
6037 switch (codec->subsystem_id) {
6040 spec->board_config = STAC_INTEL_MAC_V1;
6044 spec->board_config = STAC_INTEL_MAC_V2;
6052 spec->board_config = STAC_INTEL_MAC_V3;
6056 spec->board_config = STAC_INTEL_MAC_V4;
6060 spec->board_config = STAC_INTEL_MAC_V5;
6063 spec->board_config = STAC_INTEL_MAC_V3;
6069 if (spec->board_config < 0)
6070 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6073 stac92xx_set_config_regs(codec,
6074 stac922x_brd_tbl[spec->board_config]);
6076 spec->adc_nids = stac922x_adc_nids;
6077 spec->mux_nids = stac922x_mux_nids;
6078 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
6079 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
6080 spec->num_dmics = 0;
6083 spec->init = stac922x_core_init;
6085 spec->num_caps = STAC922X_NUM_CAPS;
6086 spec->capvols = stac922x_capvols;
6087 spec->capsws = stac922x_capsws;
6089 spec->multiout.dac_nids = spec->dac_nids;
6091 err = stac92xx_parse_auto_config(codec);
6093 if (spec->board_config < 0) {
6094 printk(KERN_WARNING "hda_codec: No auto-config is "
6095 "available, default to model=ref\n");
6096 spec->board_config = STAC_D945_REF;
6102 stac92xx_free(codec);
6106 codec->patch_ops = stac92xx_patch_ops;
6108 /* Fix Mux capture level; max to 2 */
6109 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6110 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6111 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6112 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6113 (0 << AC_AMPCAP_MUTE_SHIFT));
6118 static int patch_stac927x(struct hda_codec *codec)
6120 struct sigmatel_spec *spec;
6123 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6127 codec->no_trigger_sense = 1;
6129 spec->linear_tone_beep = 1;
6130 codec->slave_dig_outs = stac927x_slave_dig_outs;
6131 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
6132 spec->pin_nids = stac927x_pin_nids;
6133 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6137 if (spec->board_config < 0)
6138 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6141 stac92xx_set_config_regs(codec,
6142 stac927x_brd_tbl[spec->board_config]);
6144 spec->digbeep_nid = 0x23;
6145 spec->adc_nids = stac927x_adc_nids;
6146 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6147 spec->mux_nids = stac927x_mux_nids;
6148 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
6149 spec->smux_nids = stac927x_smux_nids;
6150 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
6151 spec->spdif_labels = stac927x_spdif_labels;
6152 spec->dac_list = stac927x_dac_nids;
6153 spec->multiout.dac_nids = spec->dac_nids;
6155 if (spec->board_config != STAC_D965_REF) {
6156 /* GPIO0 High = Enable EAPD */
6157 spec->eapd_mask = spec->gpio_mask = 0x01;
6158 spec->gpio_dir = spec->gpio_data = 0x01;
6161 switch (spec->board_config) {
6164 /* GPIO0 High = Enable EAPD */
6165 spec->num_dmics = 0;
6166 spec->init = d965_core_init;
6168 case STAC_DELL_BIOS:
6169 switch (codec->subsystem_id) {
6172 /* correct the device field to SPDIF out */
6173 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
6176 /* configure the analog microphone on some laptops */
6177 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
6178 /* correct the front output jack as a hp out */
6179 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
6180 /* correct the front input jack as a mic */
6181 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
6184 if (codec->subsystem_id != 0x1028022f) {
6185 /* GPIO2 High = Enable EAPD */
6186 spec->eapd_mask = spec->gpio_mask = 0x04;
6187 spec->gpio_dir = spec->gpio_data = 0x04;
6189 spec->dmic_nids = stac927x_dmic_nids;
6190 spec->num_dmics = STAC927X_NUM_DMICS;
6192 spec->init = dell_3st_core_init;
6193 spec->dmux_nids = stac927x_dmux_nids;
6194 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
6196 case STAC_927X_VOLKNOB:
6197 spec->num_dmics = 0;
6198 spec->init = stac927x_volknob_core_init;
6201 spec->num_dmics = 0;
6202 spec->init = stac927x_core_init;
6206 spec->num_caps = STAC927X_NUM_CAPS;
6207 spec->capvols = stac927x_capvols;
6208 spec->capsws = stac927x_capsws;
6211 spec->aloopback_ctl = stac927x_loopback;
6212 spec->aloopback_mask = 0x40;
6213 spec->aloopback_shift = 0;
6214 spec->eapd_switch = 1;
6216 err = stac92xx_parse_auto_config(codec);
6218 if (spec->board_config < 0) {
6219 printk(KERN_WARNING "hda_codec: No auto-config is "
6220 "available, default to model=ref\n");
6221 spec->board_config = STAC_D965_REF;
6227 stac92xx_free(codec);
6231 codec->patch_ops = stac92xx_patch_ops;
6233 codec->proc_widget_hook = stac927x_proc_hook;
6237 * The STAC927x seem to require fairly long delays for certain
6238 * command sequences. With too short delays (even if the answer
6239 * is set to RIRB properly), it results in the silence output
6240 * on some hardwares like Dell.
6242 * The below flag enables the longer delay (see get_response
6245 codec->bus->needs_damn_long_delay = 1;
6247 /* no jack detecion for ref-no-jd model */
6248 if (spec->board_config == STAC_D965_REF_NO_JD)
6249 spec->hp_detect = 0;
6254 static int patch_stac9205(struct hda_codec *codec)
6256 struct sigmatel_spec *spec;
6259 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6263 codec->no_trigger_sense = 1;
6265 spec->linear_tone_beep = 1;
6266 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
6267 spec->pin_nids = stac9205_pin_nids;
6268 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6272 if (spec->board_config < 0)
6273 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6276 stac92xx_set_config_regs(codec,
6277 stac9205_brd_tbl[spec->board_config]);
6279 spec->digbeep_nid = 0x23;
6280 spec->adc_nids = stac9205_adc_nids;
6281 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
6282 spec->mux_nids = stac9205_mux_nids;
6283 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
6284 spec->smux_nids = stac9205_smux_nids;
6285 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
6286 spec->dmic_nids = stac9205_dmic_nids;
6287 spec->num_dmics = STAC9205_NUM_DMICS;
6288 spec->dmux_nids = stac9205_dmux_nids;
6289 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
6292 spec->init = stac9205_core_init;
6293 spec->aloopback_ctl = stac9205_loopback;
6295 spec->num_caps = STAC9205_NUM_CAPS;
6296 spec->capvols = stac9205_capvols;
6297 spec->capsws = stac9205_capsws;
6299 spec->aloopback_mask = 0x40;
6300 spec->aloopback_shift = 0;
6301 /* Turn on/off EAPD per HP plugging */
6302 if (spec->board_config != STAC_9205_EAPD)
6303 spec->eapd_switch = 1;
6304 spec->multiout.dac_nids = spec->dac_nids;
6306 switch (spec->board_config){
6307 case STAC_9205_DELL_M43:
6308 /* Enable SPDIF in/out */
6309 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6310 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
6312 /* Enable unsol response for GPIO4/Dock HP connection */
6313 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6316 snd_hda_codec_write_cache(codec, codec->afg, 0,
6317 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6318 snd_hda_codec_write_cache(codec, codec->afg, 0,
6319 AC_VERB_SET_UNSOLICITED_ENABLE,
6322 spec->gpio_dir = 0x0b;
6323 spec->eapd_mask = 0x01;
6324 spec->gpio_mask = 0x1b;
6325 spec->gpio_mute = 0x10;
6326 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
6329 spec->gpio_data = 0x01;
6332 /* SPDIF-In enabled */
6335 /* GPIO0 High = EAPD */
6336 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6337 spec->gpio_data = 0x01;
6341 err = stac92xx_parse_auto_config(codec);
6343 if (spec->board_config < 0) {
6344 printk(KERN_WARNING "hda_codec: No auto-config is "
6345 "available, default to model=ref\n");
6346 spec->board_config = STAC_9205_REF;
6352 stac92xx_free(codec);
6356 codec->patch_ops = stac92xx_patch_ops;
6358 codec->proc_widget_hook = stac9205_proc_hook;
6367 static const struct hda_verb stac9872_core_init[] = {
6368 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
6369 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6373 static const hda_nid_t stac9872_pin_nids[] = {
6374 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6378 static const hda_nid_t stac9872_adc_nids[] = {
6382 static const hda_nid_t stac9872_mux_nids[] = {
6386 static const unsigned long stac9872_capvols[] = {
6387 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6389 #define stac9872_capsws stac9872_capvols
6391 static const unsigned int stac9872_vaio_pin_configs[9] = {
6392 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6393 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6397 static const char * const stac9872_models[STAC_9872_MODELS] = {
6398 [STAC_9872_AUTO] = "auto",
6399 [STAC_9872_VAIO] = "vaio",
6402 static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6403 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6406 static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
6407 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6408 "Sony VAIO F/S", STAC_9872_VAIO),
6412 static int patch_stac9872(struct hda_codec *codec)
6414 struct sigmatel_spec *spec;
6417 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6420 codec->no_trigger_sense = 1;
6422 spec->linear_tone_beep = 1;
6423 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6424 spec->pin_nids = stac9872_pin_nids;
6426 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6429 if (spec->board_config < 0)
6430 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6433 stac92xx_set_config_regs(codec,
6434 stac9872_brd_tbl[spec->board_config]);
6436 spec->multiout.dac_nids = spec->dac_nids;
6437 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6438 spec->adc_nids = stac9872_adc_nids;
6439 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6440 spec->mux_nids = stac9872_mux_nids;
6441 spec->init = stac9872_core_init;
6443 spec->capvols = stac9872_capvols;
6444 spec->capsws = stac9872_capsws;
6446 err = stac92xx_parse_auto_config(codec);
6448 stac92xx_free(codec);
6451 spec->input_mux = &spec->private_imux;
6452 codec->patch_ops = stac92xx_patch_ops;
6460 static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6461 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6462 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6463 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6464 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6465 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6466 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6467 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6468 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6469 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6470 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6471 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6472 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6473 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6474 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6475 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6476 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6477 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6478 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6479 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6480 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6481 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6482 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6483 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6484 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6485 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6486 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6487 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6488 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6489 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6490 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6491 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6492 /* The following does not take into account .id=0x83847661 when subsys =
6493 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6494 * currently not fully supported.
6496 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6497 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6498 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6499 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6500 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6501 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6502 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6503 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6504 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6505 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6506 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6507 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6508 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6509 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6510 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
6511 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6512 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6513 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6514 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
6515 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6516 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6517 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6518 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
6519 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6520 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6521 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6522 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6523 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6524 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6525 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6526 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6527 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6528 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6529 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6530 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6531 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6532 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6533 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6534 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6535 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6536 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6537 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6538 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6539 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6540 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6541 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6542 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6543 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6544 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6545 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
6546 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
6547 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
6548 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6549 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
6550 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
6551 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6552 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6553 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6554 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6555 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6556 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6557 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6558 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6559 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6560 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6561 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6562 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
6566 MODULE_ALIAS("snd-hda-codec-id:8384*");
6567 MODULE_ALIAS("snd-hda-codec-id:111d*");
6569 MODULE_LICENSE("GPL");
6570 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6572 static struct hda_codec_preset_list sigmatel_list = {
6573 .preset = snd_hda_preset_sigmatel,
6574 .owner = THIS_MODULE,
6577 static int __init patch_sigmatel_init(void)
6579 return snd_hda_add_codec_preset(&sigmatel_list);
6582 static void __exit patch_sigmatel_exit(void)
6584 snd_hda_delete_codec_preset(&sigmatel_list);
6587 module_init(patch_sigmatel_init)
6588 module_exit(patch_sigmatel_exit)