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,
100 STAC_92HD83XXX_HP_cNB11_INTQUAD,
102 STAC_92HD83XXX_MODELS
116 STAC_92HD71BXX_MODELS
142 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
143 * is given, one of the above models will be
144 * chosen according to the subsystem id. */
145 /* for backward compatibility */
162 STAC_D965_REF_NO_JD, /* no jack-detection */
179 struct sigmatel_event {
186 struct sigmatel_mic_route {
189 signed char dmux_idx;
192 #define MAX_PINS_NUM 16
193 #define MAX_ADCS_NUM 4
194 #define MAX_DMICS_NUM 4
196 struct sigmatel_spec {
197 struct snd_kcontrol_new *mixers[4];
198 unsigned int num_mixers;
201 unsigned int eapd_switch: 1;
202 unsigned int surr_switch: 1;
203 unsigned int alt_switch: 1;
204 unsigned int hp_detect: 1;
205 unsigned int spdif_mute: 1;
206 unsigned int check_volume_offset:1;
207 unsigned int auto_mic:1;
208 unsigned int linear_tone_beep:1;
211 unsigned int eapd_mask;
212 unsigned int gpio_mask;
213 unsigned int gpio_dir;
214 unsigned int gpio_data;
215 unsigned int gpio_mute;
216 unsigned int gpio_led;
217 unsigned int gpio_led_polarity;
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),
1647 static const unsigned int ref92hd83xxx_pin_configs[10] = {
1648 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1649 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1650 0x01451160, 0x98560170,
1653 static const unsigned int dell_s14_pin_configs[10] = {
1654 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1655 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1656 0x40f000f0, 0x40f000f0,
1659 static const unsigned int dell_vostro_3500_pin_configs[10] = {
1660 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
1661 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
1662 0x400000f4, 0x400000f5,
1665 static const unsigned int hp_dv7_4000_pin_configs[10] = {
1666 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1667 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1668 0x40f000f0, 0x40f000f0,
1671 static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
1672 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
1673 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
1674 0x40f000f0, 0x40f000f0,
1677 static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1678 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1679 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1680 [STAC_DELL_S14] = dell_s14_pin_configs,
1681 [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
1682 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
1683 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
1686 static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1687 [STAC_92HD83XXX_AUTO] = "auto",
1688 [STAC_92HD83XXX_REF] = "ref",
1689 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1690 [STAC_DELL_S14] = "dell-s14",
1691 [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
1692 [STAC_92HD83XXX_HP] = "hp",
1693 [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
1694 [STAC_HP_DV7_4000] = "hp-dv7-4000",
1697 static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1698 /* SigmaTel reference board */
1699 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1700 "DFI LanParty", STAC_92HD83XXX_REF),
1701 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1702 "DFI LanParty", STAC_92HD83XXX_REF),
1703 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1704 "unknown Dell", STAC_DELL_S14),
1705 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
1706 "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
1707 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1708 "HP", STAC_92HD83XXX_HP),
1709 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
1710 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1711 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
1712 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1713 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
1714 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1715 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
1716 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1717 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
1718 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1719 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
1720 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1721 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
1722 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1723 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
1724 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1725 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
1726 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1727 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
1728 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1729 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
1730 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1731 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
1732 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1733 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
1734 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1735 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
1736 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1737 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
1738 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1739 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
1740 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1741 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
1742 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1743 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
1744 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1745 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
1746 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1747 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
1748 "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
1752 static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1753 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1754 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1755 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1759 static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1760 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1761 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1762 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1766 static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1767 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1768 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1769 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1773 static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1774 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1775 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1776 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1780 static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1781 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1782 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1783 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1784 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1785 [STAC_HP_M4] = NULL,
1786 [STAC_HP_DV4] = NULL,
1787 [STAC_HP_DV5] = NULL,
1788 [STAC_HP_HDX] = NULL,
1789 [STAC_HP_DV4_1222NR] = NULL,
1792 static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1793 [STAC_92HD71BXX_AUTO] = "auto",
1794 [STAC_92HD71BXX_REF] = "ref",
1795 [STAC_DELL_M4_1] = "dell-m4-1",
1796 [STAC_DELL_M4_2] = "dell-m4-2",
1797 [STAC_DELL_M4_3] = "dell-m4-3",
1798 [STAC_HP_M4] = "hp-m4",
1799 [STAC_HP_DV4] = "hp-dv4",
1800 [STAC_HP_DV5] = "hp-dv5",
1801 [STAC_HP_HDX] = "hp-hdx",
1802 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1805 static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1806 /* SigmaTel reference board */
1807 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1808 "DFI LanParty", STAC_92HD71BXX_REF),
1809 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1810 "DFI LanParty", STAC_92HD71BXX_REF),
1811 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1812 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1813 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1815 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1817 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1818 "HP dv4-7", STAC_HP_DV4),
1819 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1820 "HP dv4-7", STAC_HP_DV5),
1821 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1822 "HP HDX", STAC_HP_HDX), /* HDX18 */
1823 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1824 "HP mini 1000", STAC_HP_M4),
1825 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1826 "HP HDX", STAC_HP_HDX), /* HDX16 */
1827 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1828 "HP dv6", STAC_HP_DV5),
1829 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1830 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
1831 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1832 "HP DV6", STAC_HP_DV5),
1833 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1835 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1836 "unknown Dell", STAC_DELL_M4_1),
1837 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1838 "unknown Dell", STAC_DELL_M4_1),
1839 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1840 "unknown Dell", STAC_DELL_M4_1),
1841 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1842 "unknown Dell", STAC_DELL_M4_1),
1843 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1844 "unknown Dell", STAC_DELL_M4_1),
1845 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1846 "unknown Dell", STAC_DELL_M4_1),
1847 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1848 "unknown Dell", STAC_DELL_M4_1),
1849 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1850 "unknown Dell", STAC_DELL_M4_2),
1851 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1852 "unknown Dell", STAC_DELL_M4_2),
1853 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1854 "unknown Dell", STAC_DELL_M4_2),
1855 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1856 "unknown Dell", STAC_DELL_M4_2),
1857 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1858 "unknown Dell", STAC_DELL_M4_3),
1862 static const unsigned int ref922x_pin_configs[10] = {
1863 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1864 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1865 0x40000100, 0x40000100,
1869 STAC 922X pin configs for
1876 static const unsigned int dell_922x_d81_pin_configs[10] = {
1877 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1878 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1879 0x01813122, 0x400001f2,
1883 STAC 922X pin configs for
1887 static const unsigned int dell_922x_d82_pin_configs[10] = {
1888 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1889 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1890 0x01813122, 0x400001f1,
1894 STAC 922X pin configs for
1897 static const unsigned int dell_922x_m81_pin_configs[10] = {
1898 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1899 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1900 0x40C003f1, 0x405003f0,
1904 STAC 9221 A1 pin configs for
1905 102801D7 (Dell XPS M1210)
1907 static const unsigned int dell_922x_m82_pin_configs[10] = {
1908 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1909 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1910 0x508003f3, 0x405003f4,
1913 static const unsigned int d945gtp3_pin_configs[10] = {
1914 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1915 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1916 0x02a19120, 0x40000100,
1919 static const unsigned int d945gtp5_pin_configs[10] = {
1920 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1921 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1922 0x02a19320, 0x40000100,
1925 static const unsigned int intel_mac_v1_pin_configs[10] = {
1926 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1927 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1928 0x400000fc, 0x400000fb,
1931 static const unsigned int intel_mac_v2_pin_configs[10] = {
1932 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1933 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1934 0x400000fc, 0x400000fb,
1937 static const unsigned int intel_mac_v3_pin_configs[10] = {
1938 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1939 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1940 0x400000fc, 0x400000fb,
1943 static const unsigned int intel_mac_v4_pin_configs[10] = {
1944 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1945 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1946 0x400000fc, 0x400000fb,
1949 static const unsigned int intel_mac_v5_pin_configs[10] = {
1950 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1951 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1952 0x400000fc, 0x400000fb,
1955 static const unsigned int ecs202_pin_configs[10] = {
1956 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1957 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1958 0x9037012e, 0x40e000f2,
1961 static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1962 [STAC_D945_REF] = ref922x_pin_configs,
1963 [STAC_D945GTP3] = d945gtp3_pin_configs,
1964 [STAC_D945GTP5] = d945gtp5_pin_configs,
1965 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1966 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1967 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1968 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1969 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1970 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1971 /* for backward compatibility */
1972 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1973 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1974 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1975 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1976 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1977 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1978 [STAC_ECS_202] = ecs202_pin_configs,
1979 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1980 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1981 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1982 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1985 static const char * const stac922x_models[STAC_922X_MODELS] = {
1986 [STAC_922X_AUTO] = "auto",
1987 [STAC_D945_REF] = "ref",
1988 [STAC_D945GTP5] = "5stack",
1989 [STAC_D945GTP3] = "3stack",
1990 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1991 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1992 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1993 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1994 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1995 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1996 /* for backward compatibility */
1997 [STAC_MACMINI] = "macmini",
1998 [STAC_MACBOOK] = "macbook",
1999 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
2000 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
2001 [STAC_IMAC_INTEL] = "imac-intel",
2002 [STAC_IMAC_INTEL_20] = "imac-intel-20",
2003 [STAC_ECS_202] = "ecs202",
2004 [STAC_922X_DELL_D81] = "dell-d81",
2005 [STAC_922X_DELL_D82] = "dell-d82",
2006 [STAC_922X_DELL_M81] = "dell-m81",
2007 [STAC_922X_DELL_M82] = "dell-m82",
2010 static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
2011 /* SigmaTel reference board */
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2013 "DFI LanParty", STAC_D945_REF),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2015 "DFI LanParty", STAC_D945_REF),
2016 /* Intel 945G based systems */
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
2018 "Intel D945G", STAC_D945GTP3),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
2020 "Intel D945G", STAC_D945GTP3),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
2022 "Intel D945G", STAC_D945GTP3),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
2024 "Intel D945G", STAC_D945GTP3),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
2026 "Intel D945G", STAC_D945GTP3),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
2028 "Intel D945G", STAC_D945GTP3),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
2030 "Intel D945G", STAC_D945GTP3),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
2032 "Intel D945G", STAC_D945GTP3),
2033 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
2034 "Intel D945G", STAC_D945GTP3),
2035 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
2036 "Intel D945G", STAC_D945GTP3),
2037 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
2038 "Intel D945G", STAC_D945GTP3),
2039 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
2040 "Intel D945G", STAC_D945GTP3),
2041 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
2042 "Intel D945G", STAC_D945GTP3),
2043 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
2044 "Intel D945G", STAC_D945GTP3),
2045 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
2046 "Intel D945G", STAC_D945GTP3),
2047 /* Intel D945G 5-stack systems */
2048 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
2049 "Intel D945G", STAC_D945GTP5),
2050 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
2051 "Intel D945G", STAC_D945GTP5),
2052 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
2053 "Intel D945G", STAC_D945GTP5),
2054 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
2055 "Intel D945G", STAC_D945GTP5),
2056 /* Intel 945P based systems */
2057 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
2058 "Intel D945P", STAC_D945GTP3),
2059 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
2060 "Intel D945P", STAC_D945GTP3),
2061 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2062 "Intel D945P", STAC_D945GTP3),
2063 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2064 "Intel D945P", STAC_D945GTP3),
2065 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2066 "Intel D945P", STAC_D945GTP3),
2067 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2068 "Intel D945P", STAC_D945GTP5),
2070 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2071 "Intel D945", STAC_D945_REF),
2073 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2074 SND_PCI_QUIRK(0x8384, 0x7680,
2075 "Mac", STAC_INTEL_MAC_AUTO),
2077 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2078 "unknown Dell", STAC_922X_DELL_D81),
2079 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2080 "unknown Dell", STAC_922X_DELL_D81),
2081 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2082 "unknown Dell", STAC_922X_DELL_D81),
2083 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2084 "unknown Dell", STAC_922X_DELL_D82),
2085 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2086 "unknown Dell", STAC_922X_DELL_M81),
2087 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2088 "unknown Dell", STAC_922X_DELL_D82),
2089 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2090 "unknown Dell", STAC_922X_DELL_D81),
2091 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2092 "unknown Dell", STAC_922X_DELL_D81),
2093 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2094 "Dell XPS M1210", STAC_922X_DELL_M82),
2095 /* ECS/PC Chips boards */
2096 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2097 "ECS/PC chips", STAC_ECS_202),
2101 static const unsigned int ref927x_pin_configs[14] = {
2102 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2103 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2104 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2105 0x01c42190, 0x40000100,
2108 static const unsigned int d965_3st_pin_configs[14] = {
2109 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2110 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2111 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2112 0x40000100, 0x40000100
2115 static const unsigned int d965_5st_pin_configs[14] = {
2116 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2117 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2118 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2119 0x40000100, 0x40000100
2122 static const unsigned int d965_5st_no_fp_pin_configs[14] = {
2123 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2124 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2125 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2126 0x40000100, 0x40000100
2129 static const unsigned int dell_3st_pin_configs[14] = {
2130 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2131 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2132 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2133 0x40c003fc, 0x40000100
2136 static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2137 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2138 [STAC_D965_REF] = ref927x_pin_configs,
2139 [STAC_D965_3ST] = d965_3st_pin_configs,
2140 [STAC_D965_5ST] = d965_5st_pin_configs,
2141 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2142 [STAC_DELL_3ST] = dell_3st_pin_configs,
2143 [STAC_DELL_BIOS] = NULL,
2144 [STAC_927X_VOLKNOB] = NULL,
2147 static const char * const stac927x_models[STAC_927X_MODELS] = {
2148 [STAC_927X_AUTO] = "auto",
2149 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2150 [STAC_D965_REF] = "ref",
2151 [STAC_D965_3ST] = "3stack",
2152 [STAC_D965_5ST] = "5stack",
2153 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2154 [STAC_DELL_3ST] = "dell-3stack",
2155 [STAC_DELL_BIOS] = "dell-bios",
2156 [STAC_927X_VOLKNOB] = "volknob",
2159 static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
2160 /* SigmaTel reference board */
2161 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2162 "DFI LanParty", STAC_D965_REF),
2163 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2164 "DFI LanParty", STAC_D965_REF),
2165 /* Intel 946 based systems */
2166 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2167 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2168 /* 965 based 3 stack systems */
2169 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2170 "Intel D965", STAC_D965_3ST),
2171 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2172 "Intel D965", STAC_D965_3ST),
2173 /* Dell 3 stack systems */
2174 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2175 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2176 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2177 /* Dell 3 stack systems with verb table in BIOS */
2178 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2179 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
2180 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2181 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2182 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2183 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2184 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2185 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2186 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2187 /* 965 based 5 stack systems */
2188 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2189 "Intel D965", STAC_D965_5ST),
2190 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2191 "Intel D965", STAC_D965_5ST),
2192 /* volume-knob fixes */
2193 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
2197 static const unsigned int ref9205_pin_configs[12] = {
2198 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2199 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2200 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2204 STAC 9205 pin configs for
2211 10280228 (Dell Vostro 1500)
2212 10280229 (Dell Vostro 1700)
2214 static const unsigned int dell_9205_m42_pin_configs[12] = {
2215 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2216 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2217 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2221 STAC 9205 pin configs for
2225 102801FF (Dell Precision M4300)
2230 static const unsigned int dell_9205_m43_pin_configs[12] = {
2231 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2232 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2233 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2236 static const unsigned int dell_9205_m44_pin_configs[12] = {
2237 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2238 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2239 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2242 static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2243 [STAC_9205_REF] = ref9205_pin_configs,
2244 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2245 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2246 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2247 [STAC_9205_EAPD] = NULL,
2250 static const char * const stac9205_models[STAC_9205_MODELS] = {
2251 [STAC_9205_AUTO] = "auto",
2252 [STAC_9205_REF] = "ref",
2253 [STAC_9205_DELL_M42] = "dell-m42",
2254 [STAC_9205_DELL_M43] = "dell-m43",
2255 [STAC_9205_DELL_M44] = "dell-m44",
2256 [STAC_9205_EAPD] = "eapd",
2259 static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
2260 /* SigmaTel reference board */
2261 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2262 "DFI LanParty", STAC_9205_REF),
2263 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2264 "SigmaTel", STAC_9205_REF),
2265 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2266 "DFI LanParty", STAC_9205_REF),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2269 "unknown Dell", STAC_9205_DELL_M42),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2271 "unknown Dell", STAC_9205_DELL_M42),
2272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2273 "Dell Precision", STAC_9205_DELL_M43),
2274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2275 "Dell Precision", STAC_9205_DELL_M43),
2276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2277 "Dell Precision", STAC_9205_DELL_M43),
2278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2279 "unknown Dell", STAC_9205_DELL_M42),
2280 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2281 "unknown Dell", STAC_9205_DELL_M42),
2282 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2283 "Dell Precision", STAC_9205_DELL_M43),
2284 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2285 "Dell Precision M4300", STAC_9205_DELL_M43),
2286 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2287 "unknown Dell", STAC_9205_DELL_M42),
2288 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2289 "Dell Precision", STAC_9205_DELL_M43),
2290 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2291 "Dell Precision", STAC_9205_DELL_M43),
2292 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2293 "Dell Precision", STAC_9205_DELL_M43),
2294 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2295 "Dell Inspiron", STAC_9205_DELL_M44),
2296 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2297 "Dell Vostro 1500", STAC_9205_DELL_M42),
2298 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2299 "Dell Vostro 1700", STAC_9205_DELL_M42),
2301 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2302 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2306 static void stac92xx_set_config_regs(struct hda_codec *codec,
2307 const unsigned int *pincfgs)
2310 struct sigmatel_spec *spec = codec->spec;
2315 for (i = 0; i < spec->num_pins; i++)
2316 if (spec->pin_nids[i] && pincfgs[i])
2317 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2322 * Analog playback callbacks
2324 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2325 struct hda_codec *codec,
2326 struct snd_pcm_substream *substream)
2328 struct sigmatel_spec *spec = codec->spec;
2329 if (spec->stream_delay)
2330 msleep(spec->stream_delay);
2331 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2335 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2336 struct hda_codec *codec,
2337 unsigned int stream_tag,
2338 unsigned int format,
2339 struct snd_pcm_substream *substream)
2341 struct sigmatel_spec *spec = codec->spec;
2342 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2345 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2346 struct hda_codec *codec,
2347 struct snd_pcm_substream *substream)
2349 struct sigmatel_spec *spec = codec->spec;
2350 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2354 * Digital playback callbacks
2356 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2357 struct hda_codec *codec,
2358 struct snd_pcm_substream *substream)
2360 struct sigmatel_spec *spec = codec->spec;
2361 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2364 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2365 struct hda_codec *codec,
2366 struct snd_pcm_substream *substream)
2368 struct sigmatel_spec *spec = codec->spec;
2369 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2372 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2373 struct hda_codec *codec,
2374 unsigned int stream_tag,
2375 unsigned int format,
2376 struct snd_pcm_substream *substream)
2378 struct sigmatel_spec *spec = codec->spec;
2379 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2380 stream_tag, format, substream);
2383 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2384 struct hda_codec *codec,
2385 struct snd_pcm_substream *substream)
2387 struct sigmatel_spec *spec = codec->spec;
2388 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2393 * Analog capture callbacks
2395 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2396 struct hda_codec *codec,
2397 unsigned int stream_tag,
2398 unsigned int format,
2399 struct snd_pcm_substream *substream)
2401 struct sigmatel_spec *spec = codec->spec;
2402 hda_nid_t nid = spec->adc_nids[substream->number];
2404 if (spec->powerdown_adcs) {
2406 snd_hda_codec_write(codec, nid, 0,
2407 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2409 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2413 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2414 struct hda_codec *codec,
2415 struct snd_pcm_substream *substream)
2417 struct sigmatel_spec *spec = codec->spec;
2418 hda_nid_t nid = spec->adc_nids[substream->number];
2420 snd_hda_codec_cleanup_stream(codec, nid);
2421 if (spec->powerdown_adcs)
2422 snd_hda_codec_write(codec, nid, 0,
2423 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2427 static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2431 /* NID is set in stac92xx_build_pcms */
2433 .open = stac92xx_dig_playback_pcm_open,
2434 .close = stac92xx_dig_playback_pcm_close,
2435 .prepare = stac92xx_dig_playback_pcm_prepare,
2436 .cleanup = stac92xx_dig_playback_pcm_cleanup
2440 static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2444 /* NID is set in stac92xx_build_pcms */
2447 static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2451 .nid = 0x02, /* NID to query formats and rates */
2453 .open = stac92xx_playback_pcm_open,
2454 .prepare = stac92xx_playback_pcm_prepare,
2455 .cleanup = stac92xx_playback_pcm_cleanup
2459 static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2463 .nid = 0x06, /* NID to query formats and rates */
2465 .open = stac92xx_playback_pcm_open,
2466 .prepare = stac92xx_playback_pcm_prepare,
2467 .cleanup = stac92xx_playback_pcm_cleanup
2471 static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2474 /* NID + .substreams is set in stac92xx_build_pcms */
2476 .prepare = stac92xx_capture_pcm_prepare,
2477 .cleanup = stac92xx_capture_pcm_cleanup
2481 static int stac92xx_build_pcms(struct hda_codec *codec)
2483 struct sigmatel_spec *spec = codec->spec;
2484 struct hda_pcm *info = spec->pcm_rec;
2486 codec->num_pcms = 1;
2487 codec->pcm_info = info;
2489 info->name = "STAC92xx Analog";
2490 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2491 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2492 spec->multiout.dac_nids[0];
2493 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2494 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2495 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2497 if (spec->alt_switch) {
2500 info->name = "STAC92xx Analog Alt";
2501 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2504 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2507 info->name = "STAC92xx Digital";
2508 info->pcm_type = spec->autocfg.dig_out_type[0];
2509 if (spec->multiout.dig_out_nid) {
2510 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2511 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2513 if (spec->dig_in_nid) {
2514 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2515 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2522 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2525 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2526 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2527 if (pincap & AC_PINCAP_VREF_100)
2528 return AC_PINCTL_VREF_100;
2529 if (pincap & AC_PINCAP_VREF_80)
2530 return AC_PINCTL_VREF_80;
2531 if (pincap & AC_PINCAP_VREF_50)
2532 return AC_PINCTL_VREF_50;
2533 if (pincap & AC_PINCAP_VREF_GRD)
2534 return AC_PINCTL_VREF_GRD;
2538 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2541 snd_hda_codec_write_cache(codec, nid, 0,
2542 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2545 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2547 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2548 struct snd_ctl_elem_value *ucontrol)
2550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2551 struct sigmatel_spec *spec = codec->spec;
2553 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2557 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2559 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2560 struct snd_ctl_elem_value *ucontrol)
2562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2563 struct sigmatel_spec *spec = codec->spec;
2564 int nid = kcontrol->private_value;
2566 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2568 /* check to be sure that the ports are up to date with
2571 stac_issue_unsol_event(codec, nid);
2576 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2577 struct snd_ctl_elem_info *uinfo)
2580 static const char * const texts[] = {
2581 "Mic In", "Line In", "Line Out"
2584 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2585 struct sigmatel_spec *spec = codec->spec;
2586 hda_nid_t nid = kcontrol->private_value;
2588 if (nid == spec->mic_switch || nid == spec->line_switch)
2593 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2594 uinfo->value.enumerated.items = i;
2596 if (uinfo->value.enumerated.item >= i)
2597 uinfo->value.enumerated.item = i-1;
2598 strcpy(uinfo->value.enumerated.name,
2599 texts[uinfo->value.enumerated.item]);
2604 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2605 struct snd_ctl_elem_value *ucontrol)
2607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2608 hda_nid_t nid = kcontrol->private_value;
2609 unsigned int vref = stac92xx_vref_get(codec, nid);
2611 if (vref == stac92xx_get_default_vref(codec, nid))
2612 ucontrol->value.enumerated.item[0] = 0;
2613 else if (vref == AC_PINCTL_VREF_GRD)
2614 ucontrol->value.enumerated.item[0] = 1;
2615 else if (vref == AC_PINCTL_VREF_HIZ)
2616 ucontrol->value.enumerated.item[0] = 2;
2621 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2622 struct snd_ctl_elem_value *ucontrol)
2624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2625 unsigned int new_vref = 0;
2627 hda_nid_t nid = kcontrol->private_value;
2629 if (ucontrol->value.enumerated.item[0] == 0)
2630 new_vref = stac92xx_get_default_vref(codec, nid);
2631 else if (ucontrol->value.enumerated.item[0] == 1)
2632 new_vref = AC_PINCTL_VREF_GRD;
2633 else if (ucontrol->value.enumerated.item[0] == 2)
2634 new_vref = AC_PINCTL_VREF_HIZ;
2638 if (new_vref != stac92xx_vref_get(codec, nid)) {
2639 error = stac92xx_vref_set(codec, nid, new_vref);
2646 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2647 struct snd_ctl_elem_info *uinfo)
2650 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2651 struct sigmatel_spec *spec = codec->spec;
2653 if (kcontrol->private_value == spec->line_switch)
2654 texts[0] = "Line In";
2656 texts[0] = "Mic In";
2657 texts[1] = "Line Out";
2658 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2659 uinfo->value.enumerated.items = 2;
2662 if (uinfo->value.enumerated.item >= 2)
2663 uinfo->value.enumerated.item = 1;
2664 strcpy(uinfo->value.enumerated.name,
2665 texts[uinfo->value.enumerated.item]);
2670 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2673 struct sigmatel_spec *spec = codec->spec;
2674 hda_nid_t nid = kcontrol->private_value;
2675 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2677 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2681 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2683 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2684 struct sigmatel_spec *spec = codec->spec;
2685 hda_nid_t nid = kcontrol->private_value;
2686 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2687 unsigned short val = !!ucontrol->value.enumerated.item[0];
2689 spec->io_switch[io_idx] = val;
2692 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2694 unsigned int pinctl = AC_PINCTL_IN_EN;
2695 if (io_idx) /* set VREF for mic */
2696 pinctl |= stac92xx_get_default_vref(codec, nid);
2697 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2700 /* check the auto-mute again: we need to mute/unmute the speaker
2701 * appropriately according to the pin direction
2703 if (spec->hp_detect)
2704 stac_issue_unsol_event(codec, nid);
2709 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2711 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2712 struct snd_ctl_elem_value *ucontrol)
2714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2715 struct sigmatel_spec *spec = codec->spec;
2717 ucontrol->value.integer.value[0] = spec->clfe_swap;
2721 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2722 struct snd_ctl_elem_value *ucontrol)
2724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2725 struct sigmatel_spec *spec = codec->spec;
2726 hda_nid_t nid = kcontrol->private_value & 0xff;
2727 unsigned int val = !!ucontrol->value.integer.value[0];
2729 if (spec->clfe_swap == val)
2732 spec->clfe_swap = val;
2734 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2735 spec->clfe_swap ? 0x4 : 0x0);
2740 #define STAC_CODEC_HP_SWITCH(xname) \
2741 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2744 .info = stac92xx_hp_switch_info, \
2745 .get = stac92xx_hp_switch_get, \
2746 .put = stac92xx_hp_switch_put, \
2749 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2750 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2753 .info = stac92xx_io_switch_info, \
2754 .get = stac92xx_io_switch_get, \
2755 .put = stac92xx_io_switch_put, \
2756 .private_value = xpval, \
2759 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2760 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2763 .info = stac92xx_clfe_switch_info, \
2764 .get = stac92xx_clfe_switch_get, \
2765 .put = stac92xx_clfe_switch_put, \
2766 .private_value = xpval, \
2770 STAC_CTL_WIDGET_VOL,
2771 STAC_CTL_WIDGET_MUTE,
2772 STAC_CTL_WIDGET_MUTE_BEEP,
2773 STAC_CTL_WIDGET_MONO_MUX,
2774 STAC_CTL_WIDGET_HP_SWITCH,
2775 STAC_CTL_WIDGET_IO_SWITCH,
2776 STAC_CTL_WIDGET_CLFE_SWITCH,
2777 STAC_CTL_WIDGET_DC_BIAS
2780 static const struct snd_kcontrol_new stac92xx_control_templates[] = {
2781 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2782 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2783 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
2785 STAC_CODEC_HP_SWITCH(NULL),
2786 STAC_CODEC_IO_SWITCH(NULL, 0),
2787 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2788 DC_BIAS(NULL, 0, 0),
2791 /* add dynamic controls */
2792 static struct snd_kcontrol_new *
2793 stac_control_new(struct sigmatel_spec *spec,
2794 const struct snd_kcontrol_new *ktemp,
2796 unsigned int subdev)
2798 struct snd_kcontrol_new *knew;
2800 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2801 knew = snd_array_new(&spec->kctls);
2805 knew->name = kstrdup(name, GFP_KERNEL);
2808 memset(knew, 0, sizeof(*knew));
2809 spec->kctls.alloced--;
2812 knew->subdevice = subdev;
2816 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2817 const struct snd_kcontrol_new *ktemp,
2818 int idx, const char *name,
2821 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
2822 HDA_SUBDEV_AMP_FLAG);
2826 knew->private_value = val;
2830 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2831 int type, int idx, const char *name,
2834 return stac92xx_add_control_temp(spec,
2835 &stac92xx_control_templates[type],
2840 /* add dynamic controls */
2841 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2842 const char *name, unsigned long val)
2844 return stac92xx_add_control_idx(spec, type, 0, name, val);
2847 static const struct snd_kcontrol_new stac_input_src_temp = {
2848 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2849 .name = "Input Source",
2850 .info = stac92xx_mux_enum_info,
2851 .get = stac92xx_mux_enum_get,
2852 .put = stac92xx_mux_enum_put,
2855 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2856 hda_nid_t nid, int idx)
2858 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2860 struct sigmatel_spec *spec = codec->spec;
2863 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2864 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2865 && nid == spec->line_switch)
2866 control = STAC_CTL_WIDGET_IO_SWITCH;
2867 else if (snd_hda_query_pin_caps(codec, nid)
2868 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2869 control = STAC_CTL_WIDGET_DC_BIAS;
2870 else if (nid == spec->mic_switch)
2871 control = STAC_CTL_WIDGET_IO_SWITCH;
2875 strcpy(name, hda_get_input_pin_label(codec, nid, 1));
2876 return stac92xx_add_control(codec->spec, control,
2877 strcat(name, " Jack Mode"), nid);
2883 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2885 struct snd_kcontrol_new *knew;
2886 struct hda_input_mux *imux = &spec->private_imux;
2889 return 0; /* no need for input source */
2890 if (!spec->num_adcs || imux->num_items <= 1)
2891 return 0; /* no need for input source control */
2892 knew = stac_control_new(spec, &stac_input_src_temp,
2893 stac_input_src_temp.name, 0);
2896 knew->count = spec->num_adcs;
2900 /* check whether the line-input can be used as line-out */
2901 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2903 struct sigmatel_spec *spec = codec->spec;
2904 struct auto_pin_cfg *cfg = &spec->autocfg;
2906 unsigned int pincap;
2909 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2911 for (i = 0; i < cfg->num_inputs; i++) {
2912 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
2913 nid = cfg->inputs[i].pin;
2914 pincap = snd_hda_query_pin_caps(codec, nid);
2915 if (pincap & AC_PINCAP_OUT)
2922 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2924 /* check whether the mic-input can be used as line-out */
2925 static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
2927 struct sigmatel_spec *spec = codec->spec;
2928 struct auto_pin_cfg *cfg = &spec->autocfg;
2929 unsigned int def_conf, pincap;
2933 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2935 for (i = 0; i < cfg->num_inputs; i++) {
2936 hda_nid_t nid = cfg->inputs[i].pin;
2937 if (cfg->inputs[i].type != AUTO_PIN_MIC)
2939 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2940 /* some laptops have an internal analog microphone
2941 * which can't be used as a output */
2942 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2943 pincap = snd_hda_query_pin_caps(codec, nid);
2944 if (pincap & AC_PINCAP_OUT) {
2945 *dac = get_unassigned_dac(codec, nid);
2954 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2958 for (i = 0; i < spec->multiout.num_dacs; i++) {
2959 if (spec->multiout.dac_nids[i] == nid)
2966 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2969 if (is_in_dac_nids(spec, nid))
2971 for (i = 0; i < spec->autocfg.hp_outs; i++)
2972 if (spec->hp_dacs[i] == nid)
2974 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2975 if (spec->speaker_dacs[i] == nid)
2980 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2982 struct sigmatel_spec *spec = codec->spec;
2983 struct auto_pin_cfg *cfg = &spec->autocfg;
2985 hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
2986 unsigned int wcaps, wtype;
2988 conn_len = snd_hda_get_connections(codec, nid, conn,
2989 HDA_MAX_CONNECTIONS);
2990 /* 92HD88: trace back up the link of nids to find the DAC */
2991 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2992 != AC_WID_AUD_OUT)) {
2994 conn_len = snd_hda_get_connections(codec, nid, conn,
2995 HDA_MAX_CONNECTIONS);
2997 for (j = 0; j < conn_len; j++) {
2998 wcaps = get_wcaps(codec, conn[j]);
2999 wtype = get_wcaps_type(wcaps);
3000 /* we check only analog outputs */
3001 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3003 /* if this route has a free DAC, assign it */
3004 if (!check_all_dac_nids(spec, conn[j])) {
3006 /* select this DAC in the pin's input mux */
3007 snd_hda_codec_write_cache(codec, nid, 0,
3008 AC_VERB_SET_CONNECT_SEL, j);
3014 /* if all DACs are already assigned, connect to the primary DAC,
3015 unless we're assigning a secondary headphone */
3016 fallback_dac = spec->multiout.dac_nids[0];
3017 if (spec->multiout.hp_nid) {
3018 for (j = 0; j < cfg->hp_outs; j++)
3019 if (cfg->hp_pins[j] == nid) {
3020 fallback_dac = spec->multiout.hp_nid;
3026 for (j = 0; j < conn_len; j++) {
3027 if (conn[j] == fallback_dac) {
3028 snd_hda_codec_write_cache(codec, nid, 0,
3029 AC_VERB_SET_CONNECT_SEL, j);
3037 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3038 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
3041 * Fill in the dac_nids table from the parsed pin configuration
3042 * This function only works when every pin in line_out_pins[]
3043 * contains atleast one DAC in its connection list. Some 92xx
3044 * codecs are not connected directly to a DAC, such as the 9200
3045 * and 9202/925x. For those, dac_nids[] must be hard-coded.
3047 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
3049 struct sigmatel_spec *spec = codec->spec;
3050 struct auto_pin_cfg *cfg = &spec->autocfg;
3054 for (i = 0; i < cfg->line_outs; i++) {
3055 nid = cfg->line_out_pins[i];
3056 dac = get_unassigned_dac(codec, nid);
3058 if (spec->multiout.num_dacs > 0) {
3059 /* we have already working output pins,
3060 * so let's drop the broken ones again
3062 cfg->line_outs = spec->multiout.num_dacs;
3065 /* error out, no available DAC found */
3067 "%s: No available DAC for pin 0x%x\n",
3071 add_spec_dacs(spec, dac);
3074 for (i = 0; i < cfg->hp_outs; i++) {
3075 nid = cfg->hp_pins[i];
3076 dac = get_unassigned_dac(codec, nid);
3078 if (!spec->multiout.hp_nid)
3079 spec->multiout.hp_nid = dac;
3081 add_spec_extra_dacs(spec, dac);
3083 spec->hp_dacs[i] = dac;
3086 for (i = 0; i < cfg->speaker_outs; i++) {
3087 nid = cfg->speaker_pins[i];
3088 dac = get_unassigned_dac(codec, nid);
3090 add_spec_extra_dacs(spec, dac);
3091 spec->speaker_dacs[i] = dac;
3094 /* add line-in as output */
3095 nid = check_line_out_switch(codec);
3097 dac = get_unassigned_dac(codec, nid);
3099 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3100 nid, cfg->line_outs);
3101 cfg->line_out_pins[cfg->line_outs] = nid;
3103 spec->line_switch = nid;
3104 add_spec_dacs(spec, dac);
3107 /* add mic as output */
3108 nid = check_mic_out_switch(codec, &dac);
3110 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3111 nid, cfg->line_outs);
3112 cfg->line_out_pins[cfg->line_outs] = nid;
3114 spec->mic_switch = nid;
3115 add_spec_dacs(spec, dac);
3118 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3119 spec->multiout.num_dacs,
3120 spec->multiout.dac_nids[0],
3121 spec->multiout.dac_nids[1],
3122 spec->multiout.dac_nids[2],
3123 spec->multiout.dac_nids[3],
3124 spec->multiout.dac_nids[4]);
3129 /* create volume control/switch for the given prefx type */
3130 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3131 int idx, hda_nid_t nid, int chs)
3133 struct sigmatel_spec *spec = codec->spec;
3137 if (!spec->check_volume_offset) {
3138 unsigned int caps, step, nums, db_scale;
3139 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3140 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3141 AC_AMPCAP_STEP_SIZE_SHIFT;
3142 step = (step + 1) * 25; /* in .01dB unit */
3143 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3144 AC_AMPCAP_NUM_STEPS_SHIFT;
3145 db_scale = nums * step;
3146 /* if dB scale is over -64dB, and finer enough,
3147 * let's reduce it to half
3149 if (db_scale > 6400 && nums >= 0x1f)
3150 spec->volume_offset = nums / 2;
3151 spec->check_volume_offset = 1;
3154 sprintf(name, "%s Playback Volume", pfx);
3155 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3156 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3157 spec->volume_offset));
3160 sprintf(name, "%s Playback Switch", pfx);
3161 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3162 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3168 #define create_controls(codec, pfx, nid, chs) \
3169 create_controls_idx(codec, pfx, 0, nid, chs)
3171 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3173 if (spec->multiout.num_dacs > 4) {
3174 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3177 snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
3178 spec->dac_nids[spec->multiout.num_dacs] = nid;
3179 spec->multiout.num_dacs++;
3184 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3187 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3188 if (!spec->multiout.extra_out_nid[i]) {
3189 spec->multiout.extra_out_nid[i] = nid;
3193 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3197 /* Create output controls
3198 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3200 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3201 const hda_nid_t *pins,
3202 const hda_nid_t *dac_nids,
3205 struct sigmatel_spec *spec = codec->spec;
3206 static const char * const chname[4] = {
3207 "Front", "Surround", NULL /*CLFE*/, "Side"
3211 unsigned int wid_caps;
3213 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3214 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3215 if (is_jack_detectable(codec, pins[i]))
3216 spec->hp_detect = 1;
3221 if (type != AUTO_PIN_HP_OUT && i == 2) {
3223 err = create_controls(codec, "Center", nid, 1);
3226 err = create_controls(codec, "LFE", nid, 2);
3230 wid_caps = get_wcaps(codec, nid);
3232 if (wid_caps & AC_WCAP_LR_SWAP) {
3233 err = stac92xx_add_control(spec,
3234 STAC_CTL_WIDGET_CLFE_SWITCH,
3235 "Swap Center/LFE Playback Switch", nid);
3245 case AUTO_PIN_HP_OUT:
3249 case AUTO_PIN_SPEAKER_OUT:
3258 err = create_controls_idx(codec, name, idx, nid, 3);
3266 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3267 unsigned long sw, int idx)
3270 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3271 "Capture Volume", vol);
3274 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3275 "Capture Switch", sw);
3281 /* add playback controls from the parsed DAC table */
3282 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3283 const struct auto_pin_cfg *cfg)
3285 struct sigmatel_spec *spec = codec->spec;
3290 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3291 spec->multiout.dac_nids,
3292 cfg->line_out_type);
3296 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3297 err = stac92xx_add_control(spec,
3298 STAC_CTL_WIDGET_HP_SWITCH,
3299 "Headphone as Line Out Switch",
3300 cfg->hp_pins[cfg->hp_outs - 1]);
3305 for (idx = 0; idx < cfg->num_inputs; idx++) {
3306 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
3308 nid = cfg->inputs[idx].pin;
3309 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3317 /* add playback controls for Speaker and HP outputs */
3318 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3319 struct auto_pin_cfg *cfg)
3321 struct sigmatel_spec *spec = codec->spec;
3324 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3325 spec->hp_dacs, AUTO_PIN_HP_OUT);
3329 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3330 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3337 /* labels for mono mux outputs */
3338 static const char * const stac92xx_mono_labels[4] = {
3339 "DAC0", "DAC1", "Mixer", "DAC2"
3342 /* create mono mux for mono out on capable codecs */
3343 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3345 struct sigmatel_spec *spec = codec->spec;
3346 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3348 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3350 num_cons = snd_hda_get_connections(codec,
3353 HDA_MAX_NUM_INPUTS);
3354 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3357 for (i = 0; i < num_cons; i++)
3358 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3361 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3362 "Mono Mux", spec->mono_nid);
3365 /* create PC beep volume controls */
3366 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3369 struct sigmatel_spec *spec = codec->spec;
3370 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3371 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3373 if (spec->anabeep_nid == nid)
3374 type = STAC_CTL_WIDGET_MUTE;
3376 /* check for mute support for the the amp */
3377 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3378 err = stac92xx_add_control(spec, type,
3379 "Beep Playback Switch",
3380 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3385 /* check to see if there is volume support for the amp */
3386 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3387 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3388 "Beep Playback Volume",
3389 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3396 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3397 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3399 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3400 struct snd_ctl_elem_value *ucontrol)
3402 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3403 ucontrol->value.integer.value[0] = codec->beep->enabled;
3407 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3408 struct snd_ctl_elem_value *ucontrol)
3410 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3411 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
3414 static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3415 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3416 .info = stac92xx_dig_beep_switch_info,
3417 .get = stac92xx_dig_beep_switch_get,
3418 .put = stac92xx_dig_beep_switch_put,
3421 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3423 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3424 0, "Beep Playback Switch", 0);
3428 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3430 struct sigmatel_spec *spec = codec->spec;
3433 for (i = 0; i < spec->num_muxes; i++) {
3438 nid = spec->mux_nids[i];
3439 wcaps = get_wcaps(codec, nid);
3440 if (!(wcaps & AC_WCAP_OUT_AMP))
3443 /* check whether already the same control was created as
3444 * normal Capture Volume.
3446 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3447 for (j = 0; j < spec->num_caps; j++) {
3448 if (spec->capvols[j] == val)
3451 if (j < spec->num_caps)
3454 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3455 "Mux Capture Volume", val);
3462 static const char * const stac92xx_spdif_labels[3] = {
3463 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3466 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3468 struct sigmatel_spec *spec = codec->spec;
3469 struct hda_input_mux *spdif_mux = &spec->private_smux;
3470 const char * const *labels = spec->spdif_labels;
3472 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3474 num_cons = snd_hda_get_connections(codec,
3477 HDA_MAX_NUM_INPUTS);
3482 labels = stac92xx_spdif_labels;
3484 for (i = 0; i < num_cons; i++)
3485 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
3490 /* labels for dmic mux inputs */
3491 static const char * const stac92xx_dmic_labels[5] = {
3492 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3493 "Digital Mic 3", "Digital Mic 4"
3496 static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
3499 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3501 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3502 if (idx >= 0 && idx < nums)
3507 /* look for NID recursively */
3508 #define get_connection_index(codec, mux, nid) \
3509 snd_hda_get_conn_index(codec, mux, nid, 1)
3511 /* create a volume assigned to the given pin (only if supported) */
3512 /* return 1 if the volume control is created */
3513 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3514 const char *label, int idx, int direction)
3516 unsigned int caps, nums;
3520 if (direction == HDA_OUTPUT)
3521 caps = AC_WCAP_OUT_AMP;
3523 caps = AC_WCAP_IN_AMP;
3524 if (!(get_wcaps(codec, nid) & caps))
3526 caps = query_amp_caps(codec, nid, direction);
3527 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3530 snprintf(name, sizeof(name), "%s Capture Volume", label);
3531 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3532 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3538 /* create playback/capture controls for input pins on dmic capable codecs */
3539 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3540 const struct auto_pin_cfg *cfg)
3542 struct sigmatel_spec *spec = codec->spec;
3543 struct hda_input_mux *imux = &spec->private_imux;
3544 struct hda_input_mux *dimux = &spec->private_dimux;
3546 unsigned int def_conf;
3548 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
3550 for (i = 0; i < spec->num_dmics; i++) {
3552 int index, type_idx;
3555 nid = spec->dmic_nids[i];
3556 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3558 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3559 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3562 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3566 label = hda_get_input_pin_label(codec, nid, 1);
3567 snd_hda_add_imux_item(dimux, label, index, &type_idx);
3568 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3569 snd_hda_add_imux_item(imux, label, index, &type_idx);
3571 err = create_elem_capture_vol(codec, nid, label, type_idx,
3576 err = create_elem_capture_vol(codec, nid, label,
3577 type_idx, HDA_OUTPUT);
3581 nid = get_connected_node(codec,
3582 spec->dmux_nids[0], index);
3584 err = create_elem_capture_vol(codec,
3586 type_idx, HDA_INPUT);
3596 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3597 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
3604 cfg = snd_hda_codec_get_pincfg(codec, nid);
3605 type = get_defcfg_device(cfg);
3606 switch (snd_hda_get_input_pin_attr(cfg)) {
3607 case INPUT_PIN_ATTR_INT:
3609 return 1; /* already occupied */
3610 if (type != AC_JACK_MIC_IN)
3611 return 1; /* invalid type */
3614 case INPUT_PIN_ATTR_UNUSED:
3616 case INPUT_PIN_ATTR_DOCK:
3618 return 1; /* already occupied */
3619 if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
3620 return 1; /* invalid type */
3625 return 1; /* already occupied */
3626 if (type != AC_JACK_MIC_IN)
3627 return 1; /* invalid type */
3634 static int set_mic_route(struct hda_codec *codec,
3635 struct sigmatel_mic_route *mic,
3638 struct sigmatel_spec *spec = codec->spec;
3639 struct auto_pin_cfg *cfg = &spec->autocfg;
3645 for (i = 0; i < cfg->num_inputs; i++) {
3646 if (pin == cfg->inputs[i].pin)
3649 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
3651 i = get_connection_index(codec, spec->mux_nids[0], pin);
3656 if (spec->dmux_nids)
3657 mic->dmux_idx = get_connection_index(codec,
3660 } else if (spec->dmux_nids) {
3662 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3668 mic->mux_idx = get_connection_index(codec,
3670 spec->dmux_nids[0]);
3675 /* return non-zero if the device is for automatic mic switch */
3676 static int stac_check_auto_mic(struct hda_codec *codec)
3678 struct sigmatel_spec *spec = codec->spec;
3679 struct auto_pin_cfg *cfg = &spec->autocfg;
3680 hda_nid_t fixed, ext, dock;
3683 fixed = ext = dock = 0;
3684 for (i = 0; i < cfg->num_inputs; i++)
3685 if (check_mic_pin(codec, cfg->inputs[i].pin,
3686 &fixed, &ext, &dock))
3688 for (i = 0; i < spec->num_dmics; i++)
3689 if (check_mic_pin(codec, spec->dmic_nids[i],
3690 &fixed, &ext, &dock))
3692 if (!fixed || (!ext && !dock))
3693 return 0; /* no input to switch */
3694 if (!is_jack_detectable(codec, ext))
3695 return 0; /* no unsol support */
3696 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3697 set_mic_route(codec, &spec->int_mic, fixed) ||
3698 set_mic_route(codec, &spec->dock_mic, dock))
3699 return 0; /* something is wrong */
3703 /* create playback/capture controls for input pins */
3704 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3706 struct sigmatel_spec *spec = codec->spec;
3707 struct hda_input_mux *imux = &spec->private_imux;
3711 for (i = 0; i < cfg->num_inputs; i++) {
3712 hda_nid_t nid = cfg->inputs[i].pin;
3713 int index, err, type_idx;
3716 for (j = 0; j < spec->num_muxes; j++) {
3717 index = get_connection_index(codec, spec->mux_nids[j],
3725 label = hda_get_autocfg_input_label(codec, cfg, i);
3726 snd_hda_add_imux_item(imux, label, index, &type_idx);
3728 err = create_elem_capture_vol(codec, nid,
3734 spec->num_analog_muxes = imux->num_items;
3736 if (imux->num_items) {
3738 * Set the current input for the muxes.
3739 * The STAC9221 has two input muxes with identical source
3740 * NID lists. Hopefully this won't get confused.
3742 for (i = 0; i < spec->num_muxes; i++) {
3743 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3744 AC_VERB_SET_CONNECT_SEL,
3745 imux->items[0].index);
3752 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3754 struct sigmatel_spec *spec = codec->spec;
3757 for (i = 0; i < spec->autocfg.line_outs; i++) {
3758 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3759 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3763 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3765 struct sigmatel_spec *spec = codec->spec;
3768 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3770 pin = spec->autocfg.hp_pins[i];
3771 if (pin) /* connect to front */
3772 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3774 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3776 pin = spec->autocfg.speaker_pins[i];
3777 if (pin) /* connect to front */
3778 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3782 static int is_dual_headphones(struct hda_codec *codec)
3784 struct sigmatel_spec *spec = codec->spec;
3787 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3788 spec->autocfg.hp_outs <= 1)
3791 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3792 hda_nid_t nid = spec->autocfg.hp_pins[i];
3793 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3794 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3798 return (valid_hps > 1);
3802 static int stac92xx_parse_auto_config(struct hda_codec *codec)
3804 struct sigmatel_spec *spec = codec->spec;
3805 hda_nid_t dig_out = 0, dig_in = 0;
3809 if ((err = snd_hda_parse_pin_def_config(codec,
3811 spec->dmic_nids)) < 0)
3813 if (! spec->autocfg.line_outs)
3814 return 0; /* can't find valid pin config */
3816 /* If we have no real line-out pin and multiple hp-outs, HPs should
3817 * be set up as multi-channel outputs.
3819 if (is_dual_headphones(codec)) {
3820 /* Copy hp_outs to line_outs, backup line_outs in
3821 * speaker_outs so that the following routines can handle
3822 * HP pins as primary outputs.
3824 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3825 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3826 sizeof(spec->autocfg.line_out_pins));
3827 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3828 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3829 sizeof(spec->autocfg.hp_pins));
3830 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3831 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3832 spec->autocfg.hp_outs = 0;
3835 if (spec->autocfg.mono_out_pin) {
3836 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3837 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3838 u32 caps = query_amp_caps(codec,
3839 spec->autocfg.mono_out_pin, dir);
3840 hda_nid_t conn_list[1];
3842 /* get the mixer node and then the mono mux if it exists */
3843 if (snd_hda_get_connections(codec,
3844 spec->autocfg.mono_out_pin, conn_list, 1) &&
3845 snd_hda_get_connections(codec, conn_list[0],
3846 conn_list, 1) > 0) {
3848 int wcaps = get_wcaps(codec, conn_list[0]);
3849 int wid_type = get_wcaps_type(wcaps);
3850 /* LR swap check, some stac925x have a mux that
3851 * changes the DACs output path instead of the
3854 if (wid_type == AC_WID_AUD_SEL &&
3855 !(wcaps & AC_WCAP_LR_SWAP))
3856 spec->mono_nid = conn_list[0];
3859 hda_nid_t nid = spec->autocfg.mono_out_pin;
3861 /* most mono outs have a least a mute/unmute switch */
3862 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3863 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3864 "Mono Playback Switch",
3865 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3868 /* check for volume support for the amp */
3869 if ((caps & AC_AMPCAP_NUM_STEPS)
3870 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3871 err = stac92xx_add_control(spec,
3872 STAC_CTL_WIDGET_VOL,
3873 "Mono Playback Volume",
3874 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3880 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3884 if (!spec->multiout.num_dacs) {
3885 err = stac92xx_auto_fill_dac_nids(codec);
3888 err = stac92xx_auto_create_multi_out_ctls(codec,
3894 /* setup analog beep controls */
3895 if (spec->anabeep_nid > 0) {
3896 err = stac92xx_auto_create_beep_ctls(codec,
3902 /* setup digital beep controls and input device */
3903 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3904 if (spec->digbeep_nid > 0) {
3905 hda_nid_t nid = spec->digbeep_nid;
3908 err = stac92xx_auto_create_beep_ctls(codec, nid);
3911 err = snd_hda_attach_beep_device(codec, nid);
3915 /* IDT/STAC codecs have linear beep tone parameter */
3916 codec->beep->linear_tone = spec->linear_tone_beep;
3917 /* if no beep switch is available, make its own one */
3918 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3919 if (!(caps & AC_AMPCAP_MUTE)) {
3920 err = stac92xx_beep_switch_ctl(codec);
3928 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3932 /* All output parsing done, now restore the swapped hp pins */
3934 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3935 sizeof(spec->autocfg.hp_pins));
3936 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3937 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3938 spec->autocfg.line_outs = 0;
3941 if (stac_check_auto_mic(codec)) {
3943 /* only one capture for auto-mic */
3946 spec->num_muxes = 1;
3949 for (i = 0; i < spec->num_caps; i++) {
3950 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3951 spec->capsws[i], i);
3956 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3960 if (spec->mono_nid > 0) {
3961 err = stac92xx_auto_create_mono_output_ctls(codec);
3965 if (spec->num_dmics > 0 && !spec->dinput_mux)
3966 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3967 &spec->autocfg)) < 0)
3969 if (spec->num_muxes > 0) {
3970 err = stac92xx_auto_create_mux_input_ctls(codec);
3974 if (spec->num_smuxes > 0) {
3975 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3980 err = stac92xx_add_input_source(spec);
3984 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3985 if (spec->multiout.max_channels > 2)
3986 spec->surr_switch = 1;
3988 /* find digital out and in converters */
3989 for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
3990 unsigned int wid_caps = get_wcaps(codec, i);
3991 if (wid_caps & AC_WCAP_DIGITAL) {
3992 switch (get_wcaps_type(wid_caps)) {
3993 case AC_WID_AUD_OUT:
4004 if (spec->autocfg.dig_outs)
4005 spec->multiout.dig_out_nid = dig_out;
4006 if (dig_in && spec->autocfg.dig_in_pin)
4007 spec->dig_in_nid = dig_in;
4009 if (spec->kctls.list)
4010 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4012 spec->input_mux = &spec->private_imux;
4013 if (!spec->dinput_mux)
4014 spec->dinput_mux = &spec->private_dimux;
4015 spec->sinput_mux = &spec->private_smux;
4016 spec->mono_mux = &spec->private_mono_mux;
4020 /* add playback controls for HP output */
4021 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
4022 struct auto_pin_cfg *cfg)
4024 struct sigmatel_spec *spec = codec->spec;
4025 hda_nid_t pin = cfg->hp_pins[0];
4030 if (is_jack_detectable(codec, pin))
4031 spec->hp_detect = 1;
4036 /* add playback controls for LFE output */
4037 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
4038 struct auto_pin_cfg *cfg)
4040 struct sigmatel_spec *spec = codec->spec;
4042 hda_nid_t lfe_pin = 0x0;
4046 * search speaker outs and line outs for a mono speaker pin
4047 * with an amp. If one is found, add LFE controls
4050 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
4051 hda_nid_t pin = spec->autocfg.speaker_pins[i];
4052 unsigned int wcaps = get_wcaps(codec, pin);
4053 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4054 if (wcaps == AC_WCAP_OUT_AMP)
4055 /* found a mono speaker with an amp, must be lfe */
4059 /* if speaker_outs is 0, then speakers may be in line_outs */
4060 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
4061 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
4062 hda_nid_t pin = spec->autocfg.line_out_pins[i];
4063 unsigned int defcfg;
4064 defcfg = snd_hda_codec_get_pincfg(codec, pin);
4065 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
4066 unsigned int wcaps = get_wcaps(codec, pin);
4067 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
4068 if (wcaps == AC_WCAP_OUT_AMP)
4069 /* found a mono speaker with an amp,
4077 err = create_controls(codec, "LFE", lfe_pin, 1);
4085 static int stac9200_parse_auto_config(struct hda_codec *codec)
4087 struct sigmatel_spec *spec = codec->spec;
4090 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
4093 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
4096 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
4099 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4102 if (spec->num_muxes > 0) {
4103 err = stac92xx_auto_create_mux_input_ctls(codec);
4108 err = stac92xx_add_input_source(spec);
4112 if (spec->autocfg.dig_outs)
4113 spec->multiout.dig_out_nid = 0x05;
4114 if (spec->autocfg.dig_in_pin)
4115 spec->dig_in_nid = 0x04;
4117 if (spec->kctls.list)
4118 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4120 spec->input_mux = &spec->private_imux;
4121 spec->dinput_mux = &spec->private_dimux;
4127 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4128 * funky external mute control using GPIO pins.
4131 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4132 unsigned int dir_mask, unsigned int data)
4134 unsigned int gpiostate, gpiomask, gpiodir;
4136 snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
4138 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4139 AC_VERB_GET_GPIO_DATA, 0);
4140 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4142 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4143 AC_VERB_GET_GPIO_MASK, 0);
4146 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4147 AC_VERB_GET_GPIO_DIRECTION, 0);
4148 gpiodir |= dir_mask;
4150 /* Configure GPIOx as CMOS */
4151 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4153 snd_hda_codec_write(codec, codec->afg, 0,
4154 AC_VERB_SET_GPIO_MASK, gpiomask);
4155 snd_hda_codec_read(codec, codec->afg, 0,
4156 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4160 snd_hda_codec_read(codec, codec->afg, 0,
4161 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4164 static int stac92xx_add_jack(struct hda_codec *codec,
4165 hda_nid_t nid, int type)
4167 #ifdef CONFIG_SND_HDA_INPUT_JACK
4168 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4169 int connectivity = get_defcfg_connect(def_conf);
4171 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4174 return snd_hda_input_jack_add(codec, nid, type, NULL);
4177 #endif /* CONFIG_SND_HDA_INPUT_JACK */
4180 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4181 unsigned char type, int data)
4183 struct sigmatel_event *event;
4185 snd_array_init(&spec->events, sizeof(*event), 32);
4186 event = snd_array_new(&spec->events);
4191 event->tag = spec->events.used;
4197 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4200 struct sigmatel_spec *spec = codec->spec;
4201 struct sigmatel_event *event = spec->events.list;
4204 for (i = 0; i < spec->events.used; i++, event++) {
4205 if (event->nid == nid)
4211 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4214 struct sigmatel_spec *spec = codec->spec;
4215 struct sigmatel_event *event = spec->events.list;
4218 for (i = 0; i < spec->events.used; i++, event++) {
4219 if (event->tag == tag)
4225 /* check if given nid is a valid pin and no other events are assigned
4226 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4227 * Otherwise, returns zero.
4229 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4232 struct sigmatel_event *event;
4235 if (!is_jack_detectable(codec, nid))
4237 event = stac_get_event(codec, nid);
4239 if (event->type != type)
4243 tag = stac_add_event(codec->spec, nid, type, 0);
4247 snd_hda_codec_write_cache(codec, nid, 0,
4248 AC_VERB_SET_UNSOLICITED_ENABLE,
4253 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4256 for (i = 0; i < cfg->hp_outs; i++)
4257 if (cfg->hp_pins[i] == nid)
4258 return 1; /* nid is a HP-Out */
4260 return 0; /* nid is not a HP-Out */
4263 static void stac92xx_power_down(struct hda_codec *codec)
4265 struct sigmatel_spec *spec = codec->spec;
4267 /* power down inactive DACs */
4268 const hda_nid_t *dac;
4269 for (dac = spec->dac_list; *dac; dac++)
4270 if (!check_all_dac_nids(spec, *dac))
4271 snd_hda_codec_write(codec, *dac, 0,
4272 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4275 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4278 static inline int get_int_hint(struct hda_codec *codec, const char *key,
4282 p = snd_hda_get_hint(codec, key);
4285 if (!strict_strtoul(p, 0, &val)) {
4293 /* override some hints from the hwdep entry */
4294 static void stac_store_hints(struct hda_codec *codec)
4296 struct sigmatel_spec *spec = codec->spec;
4299 val = snd_hda_get_bool_hint(codec, "hp_detect");
4301 spec->hp_detect = val;
4302 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
4303 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4306 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4307 spec->gpio_mask &= spec->gpio_mask;
4308 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4309 spec->gpio_dir &= spec->gpio_mask;
4310 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4311 spec->eapd_mask &= spec->gpio_mask;
4312 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4313 spec->gpio_mute &= spec->gpio_mask;
4314 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4316 spec->eapd_switch = val;
4317 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4318 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4319 if (spec->gpio_led <= 8) {
4320 spec->gpio_mask |= spec->gpio_led;
4321 spec->gpio_dir |= spec->gpio_led;
4322 if (spec->gpio_led_polarity)
4323 spec->gpio_data |= spec->gpio_led;
4328 static int stac92xx_init(struct hda_codec *codec)
4330 struct sigmatel_spec *spec = codec->spec;
4331 struct auto_pin_cfg *cfg = &spec->autocfg;
4335 snd_hda_sequence_write(codec, spec->init);
4337 /* power down adcs initially */
4338 if (spec->powerdown_adcs)
4339 for (i = 0; i < spec->num_adcs; i++)
4340 snd_hda_codec_write(codec,
4341 spec->adc_nids[i], 0,
4342 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4344 /* override some hints */
4345 stac_store_hints(codec);
4348 gpio = spec->gpio_data;
4349 /* turn on EAPD statically when spec->eapd_switch isn't set.
4350 * otherwise, unsol event will turn it on/off dynamically
4352 if (!spec->eapd_switch)
4353 gpio |= spec->eapd_mask;
4354 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4357 if (spec->hp_detect) {
4358 /* Enable unsolicited responses on the HP widget */
4359 for (i = 0; i < cfg->hp_outs; i++) {
4360 hda_nid_t nid = cfg->hp_pins[i];
4361 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4363 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4364 cfg->speaker_outs > 0) {
4365 /* enable pin-detect for line-outs as well */
4366 for (i = 0; i < cfg->line_outs; i++) {
4367 hda_nid_t nid = cfg->line_out_pins[i];
4368 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4372 /* force to enable the first line-out; the others are set up
4375 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4377 /* fake event to set up pins */
4378 if (cfg->hp_pins[0])
4379 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4380 else if (cfg->line_out_pins[0])
4381 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4383 stac92xx_auto_init_multi_out(codec);
4384 stac92xx_auto_init_hp_out(codec);
4385 for (i = 0; i < cfg->hp_outs; i++)
4386 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4388 if (spec->auto_mic) {
4389 /* initialize connection to analog input */
4390 if (spec->dmux_nids)
4391 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4392 AC_VERB_SET_CONNECT_SEL, 0);
4393 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4394 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4395 if (enable_pin_detect(codec, spec->dock_mic.pin,
4397 stac_issue_unsol_event(codec, spec->dock_mic.pin);
4399 for (i = 0; i < cfg->num_inputs; i++) {
4400 hda_nid_t nid = cfg->inputs[i].pin;
4401 int type = cfg->inputs[i].type;
4402 unsigned int pinctl, conf;
4403 if (type == AUTO_PIN_MIC) {
4404 /* for mic pins, force to initialize */
4405 pinctl = stac92xx_get_default_vref(codec, nid);
4406 pinctl |= AC_PINCTL_IN_EN;
4407 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4409 pinctl = snd_hda_codec_read(codec, nid, 0,
4410 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4411 /* if PINCTL already set then skip */
4412 /* Also, if both INPUT and OUTPUT are set,
4413 * it must be a BIOS bug; need to override, too
4415 if (!(pinctl & AC_PINCTL_IN_EN) ||
4416 (pinctl & AC_PINCTL_OUT_EN)) {
4417 pinctl &= ~AC_PINCTL_OUT_EN;
4418 pinctl |= AC_PINCTL_IN_EN;
4419 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4422 conf = snd_hda_codec_get_pincfg(codec, nid);
4423 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4424 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4425 stac_issue_unsol_event(codec, nid);
4428 for (i = 0; i < spec->num_dmics; i++)
4429 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4431 if (cfg->dig_out_pins[0])
4432 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4434 if (cfg->dig_in_pin)
4435 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4437 for (i = 0; i < spec->num_pwrs; i++) {
4438 hda_nid_t nid = spec->pwr_nids[i];
4439 int pinctl, def_conf;
4441 /* power on when no jack detection is available */
4442 if (!spec->hp_detect) {
4443 stac_toggle_power_map(codec, nid, 1);
4447 if (is_nid_hp_pin(cfg, nid))
4448 continue; /* already has an unsol event */
4450 pinctl = snd_hda_codec_read(codec, nid, 0,
4451 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4452 /* outputs are only ports capable of power management
4453 * any attempts on powering down a input port cause the
4454 * referenced VREF to act quirky.
4456 if (pinctl & AC_PINCTL_IN_EN) {
4457 stac_toggle_power_map(codec, nid, 1);
4460 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4461 def_conf = get_defcfg_connect(def_conf);
4462 /* skip any ports that don't have jacks since presence
4463 * detection is useless */
4464 if (def_conf != AC_JACK_PORT_COMPLEX) {
4465 if (def_conf != AC_JACK_PORT_NONE)
4466 stac_toggle_power_map(codec, nid, 1);
4469 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
4470 stac_issue_unsol_event(codec, nid);
4473 /* none of the above, turn the port OFF */
4474 stac_toggle_power_map(codec, nid, 0);
4479 hda_call_check_power_status(codec, 0x01);
4481 stac92xx_power_down(codec);
4485 static void stac92xx_free_kctls(struct hda_codec *codec)
4487 struct sigmatel_spec *spec = codec->spec;
4489 if (spec->kctls.list) {
4490 struct snd_kcontrol_new *kctl = spec->kctls.list;
4492 for (i = 0; i < spec->kctls.used; i++)
4493 kfree(kctl[i].name);
4495 snd_array_free(&spec->kctls);
4498 static void stac92xx_shutup_pins(struct hda_codec *codec)
4500 unsigned int i, def_conf;
4502 if (codec->bus->shutdown)
4504 for (i = 0; i < codec->init_pins.used; i++) {
4505 struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
4506 def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
4507 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
4508 snd_hda_codec_write(codec, pin->nid, 0,
4509 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4513 static void stac92xx_shutup(struct hda_codec *codec)
4515 struct sigmatel_spec *spec = codec->spec;
4517 stac92xx_shutup_pins(codec);
4519 if (spec->eapd_mask)
4520 stac_gpio_set(codec, spec->gpio_mask,
4521 spec->gpio_dir, spec->gpio_data &
4525 static void stac92xx_free(struct hda_codec *codec)
4527 struct sigmatel_spec *spec = codec->spec;
4532 stac92xx_shutup(codec);
4533 snd_hda_input_jack_free(codec);
4534 snd_array_free(&spec->events);
4537 snd_hda_detach_beep_device(codec);
4540 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4543 unsigned int old_ctl, pin_ctl;
4545 pin_ctl = snd_hda_codec_read(codec, nid,
4546 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4548 if (pin_ctl & AC_PINCTL_IN_EN) {
4550 * we need to check the current set-up direction of
4551 * shared input pins since they can be switched via
4552 * "xxx as Output" mixer switch
4554 struct sigmatel_spec *spec = codec->spec;
4555 if (nid == spec->line_switch || nid == spec->mic_switch)
4560 /* if setting pin direction bits, clear the current
4561 direction bits first */
4562 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4563 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4566 if (old_ctl != pin_ctl)
4567 snd_hda_codec_write_cache(codec, nid, 0,
4568 AC_VERB_SET_PIN_WIDGET_CONTROL,
4572 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4575 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4576 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4578 snd_hda_codec_write_cache(codec, nid, 0,
4579 AC_VERB_SET_PIN_WIDGET_CONTROL,
4583 static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4587 return snd_hda_jack_detect(codec, nid);
4590 static void stac92xx_line_out_detect(struct hda_codec *codec,
4593 struct sigmatel_spec *spec = codec->spec;
4594 struct auto_pin_cfg *cfg = &spec->autocfg;
4597 for (i = 0; i < cfg->line_outs; i++) {
4600 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4602 unsigned int pinctl;
4603 pinctl = snd_hda_codec_read(codec,
4604 cfg->line_out_pins[i], 0,
4605 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4606 if (pinctl & AC_PINCTL_IN_EN)
4607 presence = 0; /* mic- or line-input */
4612 /* disable speakers */
4613 for (i = 0; i < cfg->speaker_outs; i++)
4614 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4616 if (spec->eapd_mask && spec->eapd_switch)
4617 stac_gpio_set(codec, spec->gpio_mask,
4618 spec->gpio_dir, spec->gpio_data &
4621 /* enable speakers */
4622 for (i = 0; i < cfg->speaker_outs; i++)
4623 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4625 if (spec->eapd_mask && spec->eapd_switch)
4626 stac_gpio_set(codec, spec->gpio_mask,
4627 spec->gpio_dir, spec->gpio_data |
4632 /* return non-zero if the hp-pin of the given array index isn't
4633 * a jack-detection target
4635 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4637 struct auto_pin_cfg *cfg = &spec->autocfg;
4639 /* ignore sensing of shared line and mic jacks */
4640 if (cfg->hp_pins[i] == spec->line_switch)
4642 if (cfg->hp_pins[i] == spec->mic_switch)
4644 /* ignore if the pin is set as line-out */
4645 if (cfg->hp_pins[i] == spec->hp_switch)
4650 static void stac92xx_hp_detect(struct hda_codec *codec)
4652 struct sigmatel_spec *spec = codec->spec;
4653 struct auto_pin_cfg *cfg = &spec->autocfg;
4657 if (spec->gpio_mute)
4658 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4659 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4661 for (i = 0; i < cfg->hp_outs; i++) {
4664 if (no_hp_sensing(spec, i))
4666 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4668 unsigned int pinctl;
4669 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4670 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4671 if (pinctl & AC_PINCTL_IN_EN)
4672 presence = 0; /* mic- or line-input */
4677 /* disable lineouts */
4678 if (spec->hp_switch)
4679 stac92xx_reset_pinctl(codec, spec->hp_switch,
4681 for (i = 0; i < cfg->line_outs; i++)
4682 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4685 /* enable lineouts */
4686 if (spec->hp_switch)
4687 stac92xx_set_pinctl(codec, spec->hp_switch,
4689 for (i = 0; i < cfg->line_outs; i++)
4690 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4693 stac92xx_line_out_detect(codec, presence);
4694 /* toggle hp outs */
4695 for (i = 0; i < cfg->hp_outs; i++) {
4696 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4697 if (no_hp_sensing(spec, i))
4700 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4702 /* Resetting the pinctl like below may lead to (a sort of) regressions
4703 * on some devices since they use the HP pin actually for line/speaker
4704 * outs although the default pin config shows a different pin (that is
4705 * wrong and useless).
4707 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4708 * But, disabling the code below just works around it, and I'm too tired of
4709 * bug reports with such devices...
4712 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4717 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4720 struct sigmatel_spec *spec = codec->spec;
4721 unsigned int idx, val;
4723 for (idx = 0; idx < spec->num_pwrs; idx++) {
4724 if (spec->pwr_nids[idx] == nid)
4727 if (idx >= spec->num_pwrs)
4732 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4738 /* power down unused output ports */
4739 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4742 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4744 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4747 /* get the pin connection (fixed, none, etc) */
4748 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4750 struct sigmatel_spec *spec = codec->spec;
4753 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4754 return get_defcfg_connect(cfg);
4757 static int stac92xx_connected_ports(struct hda_codec *codec,
4758 const hda_nid_t *nids, int num_nids)
4760 struct sigmatel_spec *spec = codec->spec;
4762 unsigned int def_conf;
4764 for (num = 0; num < num_nids; num++) {
4765 for (idx = 0; idx < spec->num_pins; idx++)
4766 if (spec->pin_nids[idx] == nids[num])
4768 if (idx >= spec->num_pins)
4770 def_conf = stac_get_defcfg_connect(codec, idx);
4771 if (def_conf == AC_JACK_PORT_NONE)
4777 static void stac92xx_mic_detect(struct hda_codec *codec)
4779 struct sigmatel_spec *spec = codec->spec;
4780 struct sigmatel_mic_route *mic;
4782 if (get_pin_presence(codec, spec->ext_mic.pin))
4783 mic = &spec->ext_mic;
4784 else if (get_pin_presence(codec, spec->dock_mic.pin))
4785 mic = &spec->dock_mic;
4787 mic = &spec->int_mic;
4788 if (mic->dmux_idx >= 0)
4789 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4790 AC_VERB_SET_CONNECT_SEL,
4792 if (mic->mux_idx >= 0)
4793 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4794 AC_VERB_SET_CONNECT_SEL,
4798 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4800 struct sigmatel_event *event = stac_get_event(codec, nid);
4803 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4806 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4808 struct sigmatel_spec *spec = codec->spec;
4809 struct sigmatel_event *event;
4812 tag = (res >> 26) & 0x7f;
4813 event = stac_get_event_from_tag(codec, tag);
4817 switch (event->type) {
4820 stac92xx_hp_detect(codec);
4822 case STAC_MIC_EVENT:
4823 stac92xx_mic_detect(codec);
4827 switch (event->type) {
4830 case STAC_MIC_EVENT:
4831 case STAC_INSERT_EVENT:
4832 case STAC_PWR_EVENT:
4833 if (spec->num_pwrs > 0)
4834 stac92xx_pin_sense(codec, event->nid);
4835 snd_hda_input_jack_report(codec, event->nid);
4837 switch (codec->subsystem_id) {
4839 if (event->nid == 0xb) {
4840 int pin = AC_PINCTL_IN_EN;
4842 if (get_pin_presence(codec, 0xa)
4843 && get_pin_presence(codec, 0xb))
4844 pin |= AC_PINCTL_VREF_80;
4845 if (!get_pin_presence(codec, 0xb))
4846 pin |= AC_PINCTL_VREF_80;
4848 /* toggle VREF state based on mic + hp pin
4851 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4855 case STAC_VREF_EVENT:
4856 data = snd_hda_codec_read(codec, codec->afg, 0,
4857 AC_VERB_GET_GPIO_DATA, 0);
4858 /* toggle VREF state based on GPIOx status */
4859 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4860 !!(data & (1 << event->data)));
4865 static int hp_blike_system(u32 subsystem_id);
4867 static void set_hp_led_gpio(struct hda_codec *codec)
4869 struct sigmatel_spec *spec = codec->spec;
4875 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4876 gpio &= AC_GPIO_IO_COUNT;
4878 spec->gpio_led = 0x08; /* GPIO 3 */
4880 spec->gpio_led = 0x01; /* GPIO 0 */
4884 * This method searches for the mute LED GPIO configuration
4885 * provided as OEM string in SMBIOS. The format of that string
4886 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4887 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4888 * that corresponds to the NOT muted state of the master volume
4889 * and G is the index of the GPIO to use as the mute LED control (0..9)
4890 * If _G portion is missing it is assigned based on the codec ID
4892 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4893 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4896 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4897 * SMBIOS - at least the ones I have seen do not have them - which include
4898 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4899 * HP Pavilion dv9500t CTO.
4900 * Need more information on whether it is true across the entire series.
4903 static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4905 struct sigmatel_spec *spec = codec->spec;
4906 const struct dmi_device *dev = NULL;
4908 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4909 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4911 if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
4912 &spec->gpio_led_polarity,
4913 &spec->gpio_led) == 2) {
4914 if (spec->gpio_led < 4)
4915 spec->gpio_led = 1 << spec->gpio_led;
4918 if (sscanf(dev->name, "HP_Mute_LED_%d",
4919 &spec->gpio_led_polarity) == 1) {
4920 set_hp_led_gpio(codec);
4926 * Fallback case - if we don't find the DMI strings,
4927 * we statically set the GPIO - if not a B-series system.
4929 if (!hp_blike_system(codec->subsystem_id)) {
4930 set_hp_led_gpio(codec);
4931 spec->gpio_led_polarity = default_polarity;
4938 static int hp_blike_system(u32 subsystem_id)
4940 switch (subsystem_id) {
4967 #ifdef CONFIG_PROC_FS
4968 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4969 struct hda_codec *codec, hda_nid_t nid)
4971 if (nid == codec->afg)
4972 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4973 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4976 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4977 struct hda_codec *codec,
4980 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4981 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4984 /* stac92hd71bxx, stac92hd73xx */
4985 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4986 struct hda_codec *codec, hda_nid_t nid)
4988 stac92hd_proc_hook(buffer, codec, nid);
4989 if (nid == codec->afg)
4990 analog_loop_proc_hook(buffer, codec, 0xfa0);
4993 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4994 struct hda_codec *codec, hda_nid_t nid)
4996 if (nid == codec->afg)
4997 analog_loop_proc_hook(buffer, codec, 0xfe0);
5000 static void stac927x_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, 0xfeb);
5007 #define stac92hd_proc_hook NULL
5008 #define stac92hd7x_proc_hook NULL
5009 #define stac9205_proc_hook NULL
5010 #define stac927x_proc_hook NULL
5014 static int stac92xx_resume(struct hda_codec *codec)
5016 struct sigmatel_spec *spec = codec->spec;
5018 stac92xx_init(codec);
5019 snd_hda_codec_resume_amp(codec);
5020 snd_hda_codec_resume_cache(codec);
5021 /* fake event to set up pins again to override cached values */
5022 if (spec->hp_detect) {
5023 if (spec->autocfg.hp_pins[0])
5024 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
5025 else if (spec->autocfg.line_out_pins[0])
5026 stac_issue_unsol_event(codec,
5027 spec->autocfg.line_out_pins[0]);
5032 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5034 stac92xx_shutup(codec);
5038 #ifdef CONFIG_SND_HDA_POWER_SAVE
5039 static int stac92xx_pre_resume(struct hda_codec *codec)
5041 struct sigmatel_spec *spec = codec->spec;
5044 if (spec->gpio_led) {
5045 if (spec->gpio_led <= 8) {
5046 stac_gpio_set(codec, spec->gpio_mask,
5047 spec->gpio_dir, spec->gpio_data);
5049 stac_vrefout_set(codec,
5050 spec->gpio_led, spec->vref_led);
5056 static int stac92xx_post_suspend(struct hda_codec *codec)
5058 struct sigmatel_spec *spec = codec->spec;
5059 if (spec->gpio_led > 8) {
5060 /* with vref-out pin used for mute led control
5061 * codec AFG is prevented from D3 state, but on
5062 * system suspend it can (and should) be used
5064 snd_hda_codec_read(codec, codec->afg, 0,
5065 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
5070 static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
5071 unsigned int power_state)
5073 unsigned int afg_power_state = power_state;
5074 struct sigmatel_spec *spec = codec->spec;
5076 if (power_state == AC_PWRST_D3) {
5077 if (spec->gpio_led > 8) {
5078 /* with vref-out pin used for mute led control
5079 * codec AFG is prevented from D3 state
5081 afg_power_state = AC_PWRST_D1;
5083 /* this delay seems necessary to avoid click noise at power-down */
5086 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
5088 snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
5092 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed
5093 * as mute LED state is updated in check_power_status hook
5095 static int stac92xx_update_led_status(struct hda_codec *codec)
5097 struct sigmatel_spec *spec = codec->spec;
5098 int i, num_ext_dacs, muted = 1;
5099 unsigned int muted_lvl, notmtd_lvl;
5102 if (!spec->gpio_led)
5105 for (i = 0; i < spec->multiout.num_dacs; i++) {
5106 nid = spec->multiout.dac_nids[i];
5107 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
5109 muted = 0; /* something heard */
5113 if (muted && spec->multiout.hp_nid)
5114 if (!(snd_hda_codec_amp_read(codec,
5115 spec->multiout.hp_nid, 0, HDA_OUTPUT, 0) &
5117 muted = 0; /* HP is not muted */
5119 num_ext_dacs = ARRAY_SIZE(spec->multiout.extra_out_nid);
5120 for (i = 0; muted && i < num_ext_dacs; i++) {
5121 nid = spec->multiout.extra_out_nid[i];
5124 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
5126 muted = 0; /* extra output is not muted */
5129 /*polarity defines *not* muted state level*/
5130 if (spec->gpio_led <= 8) {
5132 spec->gpio_data &= ~spec->gpio_led; /* orange */
5134 spec->gpio_data |= spec->gpio_led; /* white */
5136 if (!spec->gpio_led_polarity) {
5137 /* LED state is inverted on these systems */
5138 spec->gpio_data ^= spec->gpio_led;
5140 stac_gpio_set(codec, spec->gpio_mask,
5141 spec->gpio_dir, spec->gpio_data);
5143 notmtd_lvl = spec->gpio_led_polarity ?
5144 AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_GRD;
5145 muted_lvl = spec->gpio_led_polarity ?
5146 AC_PINCTL_VREF_GRD : AC_PINCTL_VREF_HIZ;
5147 spec->vref_led = muted ? muted_lvl : notmtd_lvl;
5148 stac_vrefout_set(codec, spec->gpio_led, spec->vref_led);
5154 * use power check for controlling mute led of HP notebooks
5156 static int stac92xx_check_power_status(struct hda_codec *codec,
5159 stac92xx_update_led_status(codec);
5163 #endif /* CONFIG_SND_HDA_POWER_SAVE */
5164 #endif /* CONFIG_PM */
5166 static const struct hda_codec_ops stac92xx_patch_ops = {
5167 .build_controls = stac92xx_build_controls,
5168 .build_pcms = stac92xx_build_pcms,
5169 .init = stac92xx_init,
5170 .free = stac92xx_free,
5171 .unsol_event = stac92xx_unsol_event,
5173 .suspend = stac92xx_suspend,
5174 .resume = stac92xx_resume,
5176 .reboot_notify = stac92xx_shutup,
5179 static int patch_stac9200(struct hda_codec *codec)
5181 struct sigmatel_spec *spec;
5184 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5188 codec->no_trigger_sense = 1;
5190 spec->linear_tone_beep = 1;
5191 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
5192 spec->pin_nids = stac9200_pin_nids;
5193 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5196 if (spec->board_config < 0)
5197 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5200 stac92xx_set_config_regs(codec,
5201 stac9200_brd_tbl[spec->board_config]);
5203 spec->multiout.max_channels = 2;
5204 spec->multiout.num_dacs = 1;
5205 spec->multiout.dac_nids = stac9200_dac_nids;
5206 spec->adc_nids = stac9200_adc_nids;
5207 spec->mux_nids = stac9200_mux_nids;
5208 spec->num_muxes = 1;
5209 spec->num_dmics = 0;
5213 if (spec->board_config == STAC_9200_M4 ||
5214 spec->board_config == STAC_9200_M4_2 ||
5215 spec->board_config == STAC_9200_OQO)
5216 spec->init = stac9200_eapd_init;
5218 spec->init = stac9200_core_init;
5219 spec->mixer = stac9200_mixer;
5221 if (spec->board_config == STAC_9200_PANASONIC) {
5222 spec->gpio_mask = spec->gpio_dir = 0x09;
5223 spec->gpio_data = 0x00;
5226 err = stac9200_parse_auto_config(codec);
5228 stac92xx_free(codec);
5232 /* CF-74 has no headphone detection, and the driver should *NOT*
5233 * do detection and HP/speaker toggle because the hardware does it.
5235 if (spec->board_config == STAC_9200_PANASONIC)
5236 spec->hp_detect = 0;
5238 codec->patch_ops = stac92xx_patch_ops;
5243 static int patch_stac925x(struct hda_codec *codec)
5245 struct sigmatel_spec *spec;
5248 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5252 codec->no_trigger_sense = 1;
5254 spec->linear_tone_beep = 1;
5255 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
5256 spec->pin_nids = stac925x_pin_nids;
5258 /* Check first for codec ID */
5259 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5262 stac925x_codec_id_cfg_tbl);
5264 /* Now checks for PCI ID, if codec ID is not found */
5265 if (spec->board_config < 0)
5266 spec->board_config = snd_hda_check_board_config(codec,
5271 if (spec->board_config < 0)
5272 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5275 stac92xx_set_config_regs(codec,
5276 stac925x_brd_tbl[spec->board_config]);
5278 spec->multiout.max_channels = 2;
5279 spec->multiout.num_dacs = 1;
5280 spec->multiout.dac_nids = stac925x_dac_nids;
5281 spec->adc_nids = stac925x_adc_nids;
5282 spec->mux_nids = stac925x_mux_nids;
5283 spec->num_muxes = 1;
5286 switch (codec->vendor_id) {
5287 case 0x83847632: /* STAC9202 */
5288 case 0x83847633: /* STAC9202D */
5289 case 0x83847636: /* STAC9251 */
5290 case 0x83847637: /* STAC9251D */
5291 spec->num_dmics = STAC925X_NUM_DMICS;
5292 spec->dmic_nids = stac925x_dmic_nids;
5293 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5294 spec->dmux_nids = stac925x_dmux_nids;
5297 spec->num_dmics = 0;
5301 spec->init = stac925x_core_init;
5302 spec->mixer = stac925x_mixer;
5304 spec->capvols = stac925x_capvols;
5305 spec->capsws = stac925x_capsws;
5307 err = stac92xx_parse_auto_config(codec);
5309 if (spec->board_config < 0) {
5310 printk(KERN_WARNING "hda_codec: No auto-config is "
5311 "available, default to model=ref\n");
5312 spec->board_config = STAC_925x_REF;
5318 stac92xx_free(codec);
5322 codec->patch_ops = stac92xx_patch_ops;
5327 static int patch_stac92hd73xx(struct hda_codec *codec)
5329 struct sigmatel_spec *spec;
5330 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5334 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5338 codec->no_trigger_sense = 1;
5340 spec->linear_tone_beep = 0;
5341 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5342 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5343 spec->pin_nids = stac92hd73xx_pin_nids;
5344 spec->board_config = snd_hda_check_board_config(codec,
5345 STAC_92HD73XX_MODELS,
5346 stac92hd73xx_models,
5347 stac92hd73xx_cfg_tbl);
5348 /* check codec subsystem id if not found */
5349 if (spec->board_config < 0)
5350 spec->board_config =
5351 snd_hda_check_board_codec_sid_config(codec,
5352 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5353 stac92hd73xx_codec_id_cfg_tbl);
5355 if (spec->board_config < 0)
5356 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5359 stac92xx_set_config_regs(codec,
5360 stac92hd73xx_brd_tbl[spec->board_config]);
5362 num_dacs = snd_hda_get_connections(codec, 0x0a,
5363 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5365 if (num_dacs < 3 || num_dacs > 5) {
5366 printk(KERN_WARNING "hda_codec: Could not determine "
5367 "number of channels defaulting to DAC count\n");
5368 num_dacs = STAC92HD73_DAC_COUNT;
5370 spec->init = stac92hd73xx_core_init;
5372 case 0x3: /* 6 Channel */
5373 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5375 case 0x4: /* 8 Channel */
5376 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5378 case 0x5: /* 10 Channel */
5379 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5382 spec->multiout.dac_nids = spec->dac_nids;
5384 spec->aloopback_mask = 0x01;
5385 spec->aloopback_shift = 8;
5387 spec->digbeep_nid = 0x1c;
5388 spec->mux_nids = stac92hd73xx_mux_nids;
5389 spec->adc_nids = stac92hd73xx_adc_nids;
5390 spec->dmic_nids = stac92hd73xx_dmic_nids;
5391 spec->dmux_nids = stac92hd73xx_dmux_nids;
5392 spec->smux_nids = stac92hd73xx_smux_nids;
5394 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5395 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5396 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5398 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5399 spec->capvols = stac92hd73xx_capvols;
5400 spec->capsws = stac92hd73xx_capsws;
5402 switch (spec->board_config) {
5404 spec->init = dell_eq_core_init;
5406 case STAC_DELL_M6_AMIC:
5407 case STAC_DELL_M6_DMIC:
5408 case STAC_DELL_M6_BOTH:
5409 spec->num_smuxes = 0;
5410 spec->eapd_switch = 0;
5412 switch (spec->board_config) {
5413 case STAC_DELL_M6_AMIC: /* Analog Mics */
5414 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5415 spec->num_dmics = 0;
5417 case STAC_DELL_M6_DMIC: /* Digital Mics */
5418 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5419 spec->num_dmics = 1;
5421 case STAC_DELL_M6_BOTH: /* Both */
5422 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5423 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5424 spec->num_dmics = 1;
5428 case STAC_ALIENWARE_M17X:
5429 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5430 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5431 spec->eapd_switch = 0;
5434 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5435 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5436 spec->eapd_switch = 1;
5439 if (spec->board_config != STAC_92HD73XX_REF) {
5440 /* GPIO0 High = Enable EAPD */
5441 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5442 spec->gpio_data = 0x01;
5445 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5446 spec->pwr_nids = stac92hd73xx_pwr_nids;
5448 err = stac92xx_parse_auto_config(codec);
5451 if (spec->board_config < 0) {
5452 printk(KERN_WARNING "hda_codec: No auto-config is "
5453 "available, default to model=ref\n");
5454 spec->board_config = STAC_92HD73XX_REF;
5461 stac92xx_free(codec);
5465 if (spec->board_config == STAC_92HD73XX_NO_JD)
5466 spec->hp_detect = 0;
5468 codec->patch_ops = stac92xx_patch_ops;
5470 codec->proc_widget_hook = stac92hd7x_proc_hook;
5475 static int hp_bnb2011_with_dock(struct hda_codec *codec)
5477 if (codec->vendor_id != 0x111d7605 &&
5478 codec->vendor_id != 0x111d76d1)
5481 switch (codec->subsystem_id) {
5515 static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
5517 struct sigmatel_spec *spec = codec->spec;
5518 unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
5521 spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
5522 spec->auto_pin_cnt++;
5524 if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
5525 get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
5526 for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
5527 if (nid == stac92hd83xxx_dmic_nids[i]) {
5528 spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
5529 spec->auto_dmic_cnt++;
5535 static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
5537 struct sigmatel_spec *spec = codec->spec;
5539 spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
5540 spec->auto_adc_cnt++;
5543 static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
5546 struct sigmatel_spec *spec = codec->spec;
5548 for (i = 0; i < spec->auto_adc_cnt; i++) {
5549 if (get_connection_index(codec,
5550 spec->auto_adc_nids[i], nid) >= 0) {
5551 /* mux and volume for adc_nids[i] */
5552 if (!spec->auto_mux_nids[i]) {
5553 spec->auto_mux_nids[i] = nid;
5554 /* 92hd codecs capture volume is in mux */
5555 spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
5558 for (j = 0; j < spec->auto_dmic_cnt; j++) {
5559 if (get_connection_index(codec, nid,
5560 spec->auto_dmic_nids[j]) >= 0) {
5561 /* dmux for adc_nids[i] */
5562 if (!spec->auto_dmux_nids[i])
5563 spec->auto_dmux_nids[i] = nid;
5572 static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
5574 hda_nid_t nid, end_nid;
5575 unsigned int wid_caps, wid_type;
5576 struct sigmatel_spec *spec = codec->spec;
5578 end_nid = codec->start_nid + codec->num_nodes;
5580 for (nid = codec->start_nid; nid < end_nid; nid++) {
5581 wid_caps = get_wcaps(codec, nid);
5582 wid_type = get_wcaps_type(wid_caps);
5584 if (wid_type == AC_WID_PIN)
5585 stac92hd8x_add_pin(codec, nid);
5587 if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
5588 stac92hd8x_add_adc(codec, nid);
5591 for (nid = codec->start_nid; nid < end_nid; nid++) {
5592 wid_caps = get_wcaps(codec, nid);
5593 wid_type = get_wcaps_type(wid_caps);
5595 if (wid_type == AC_WID_AUD_SEL)
5596 stac92hd8x_add_mux(codec, nid);
5599 spec->pin_nids = spec->auto_pin_nids;
5600 spec->num_pins = spec->auto_pin_cnt;
5601 spec->adc_nids = spec->auto_adc_nids;
5602 spec->num_adcs = spec->auto_adc_cnt;
5603 spec->capvols = spec->auto_capvols;
5604 spec->capsws = spec->auto_capvols;
5605 spec->num_caps = spec->auto_adc_cnt;
5606 spec->mux_nids = spec->auto_mux_nids;
5607 spec->num_muxes = spec->auto_adc_cnt;
5608 spec->dmux_nids = spec->auto_dmux_nids;
5609 spec->num_dmuxes = spec->auto_adc_cnt;
5610 spec->dmic_nids = spec->auto_dmic_nids;
5611 spec->num_dmics = spec->auto_dmic_cnt;
5614 static int patch_stac92hd83xxx(struct hda_codec *codec)
5616 struct sigmatel_spec *spec;
5619 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5623 if (hp_bnb2011_with_dock(codec)) {
5624 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5625 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5628 codec->no_trigger_sense = 1;
5631 stac92hd8x_fill_auto_spec(codec);
5633 spec->linear_tone_beep = 0;
5634 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5635 spec->digbeep_nid = 0x21;
5636 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5637 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5638 spec->multiout.dac_nids = spec->dac_nids;
5639 spec->init = stac92hd83xxx_core_init;
5641 spec->board_config = snd_hda_check_board_config(codec,
5642 STAC_92HD83XXX_MODELS,
5643 stac92hd83xxx_models,
5644 stac92hd83xxx_cfg_tbl);
5646 if (spec->board_config < 0)
5647 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5650 stac92xx_set_config_regs(codec,
5651 stac92hd83xxx_brd_tbl[spec->board_config]);
5653 codec->patch_ops = stac92xx_patch_ops;
5655 if (find_mute_led_gpio(codec, 0))
5656 snd_printd("mute LED gpio %d polarity %d\n",
5658 spec->gpio_led_polarity);
5660 #ifdef CONFIG_SND_HDA_POWER_SAVE
5661 if (spec->gpio_led) {
5662 if (spec->gpio_led <= 8) {
5663 spec->gpio_mask |= spec->gpio_led;
5664 spec->gpio_dir |= spec->gpio_led;
5665 spec->gpio_data |= spec->gpio_led;
5667 codec->patch_ops.set_power_state =
5668 stac92xx_set_power_state;
5669 codec->patch_ops.post_suspend =
5670 stac92xx_post_suspend;
5672 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5673 codec->patch_ops.check_power_status =
5674 stac92xx_check_power_status;
5678 err = stac92xx_parse_auto_config(codec);
5680 if (spec->board_config < 0) {
5681 printk(KERN_WARNING "hda_codec: No auto-config is "
5682 "available, default to model=ref\n");
5683 spec->board_config = STAC_92HD83XXX_REF;
5690 stac92xx_free(codec);
5694 codec->proc_widget_hook = stac92hd_proc_hook;
5699 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5702 struct sigmatel_spec *spec = codec->spec;
5705 for (idx = 0; idx < spec->num_pins; idx++)
5706 if (spec->pin_nids[idx] == dig0pin)
5708 if ((idx + 2) >= spec->num_pins)
5712 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5715 /* dig0pin + dig2pin case */
5716 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5718 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5724 /* HP dv7 bass switch - GPIO5 */
5725 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5726 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5727 struct snd_ctl_elem_value *ucontrol)
5729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5730 struct sigmatel_spec *spec = codec->spec;
5731 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5735 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5736 struct snd_ctl_elem_value *ucontrol)
5738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5739 struct sigmatel_spec *spec = codec->spec;
5740 unsigned int gpio_data;
5742 gpio_data = (spec->gpio_data & ~0x20) |
5743 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5744 if (gpio_data == spec->gpio_data)
5746 spec->gpio_data = gpio_data;
5747 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5751 static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
5752 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5753 .info = stac_hp_bass_gpio_info,
5754 .get = stac_hp_bass_gpio_get,
5755 .put = stac_hp_bass_gpio_put,
5758 static int stac_add_hp_bass_switch(struct hda_codec *codec)
5760 struct sigmatel_spec *spec = codec->spec;
5762 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5763 "Bass Speaker Playback Switch", 0))
5766 spec->gpio_mask |= 0x20;
5767 spec->gpio_dir |= 0x20;
5768 spec->gpio_data |= 0x20;
5772 static int patch_stac92hd71bxx(struct hda_codec *codec)
5774 struct sigmatel_spec *spec;
5775 const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5776 unsigned int pin_cfg;
5779 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5783 codec->no_trigger_sense = 1;
5785 spec->linear_tone_beep = 0;
5786 codec->patch_ops = stac92xx_patch_ops;
5787 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5788 switch (codec->vendor_id) {
5791 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5795 /* On 92HD75Bx 0x27 isn't a pin nid */
5799 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5801 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5802 spec->board_config = snd_hda_check_board_config(codec,
5803 STAC_92HD71BXX_MODELS,
5804 stac92hd71bxx_models,
5805 stac92hd71bxx_cfg_tbl);
5807 if (spec->board_config < 0)
5808 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5811 stac92xx_set_config_regs(codec,
5812 stac92hd71bxx_brd_tbl[spec->board_config]);
5814 if (spec->board_config != STAC_92HD71BXX_REF) {
5816 spec->gpio_mask = 0x01;
5817 spec->gpio_dir = 0x01;
5818 spec->gpio_data = 0x01;
5821 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5822 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5824 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5825 spec->capvols = stac92hd71bxx_capvols;
5826 spec->capsws = stac92hd71bxx_capsws;
5828 switch (codec->vendor_id) {
5829 case 0x111d76b6: /* 4 Port without Analog Mixer */
5833 case 0x111d76b4: /* 6 Port without Analog Mixer */
5835 spec->init = stac92hd71bxx_core_init;
5836 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5837 spec->num_dmics = stac92xx_connected_ports(codec,
5838 stac92hd71bxx_dmic_nids,
5839 STAC92HD71BXX_NUM_DMICS);
5841 case 0x111d7608: /* 5 Port with Analog Mixer */
5842 switch (spec->board_config) {
5844 /* Enable VREF power saving on GPIO1 detect */
5845 err = stac_add_event(spec, codec->afg,
5846 STAC_VREF_EVENT, 0x02);
5849 snd_hda_codec_write_cache(codec, codec->afg, 0,
5850 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5851 snd_hda_codec_write_cache(codec, codec->afg, 0,
5852 AC_VERB_SET_UNSOLICITED_ENABLE,
5854 spec->gpio_mask |= 0x02;
5857 if ((codec->revision_id & 0xf) == 0 ||
5858 (codec->revision_id & 0xf) == 1)
5859 spec->stream_delay = 40; /* 40 milliseconds */
5862 spec->init = stac92hd71bxx_core_init;
5864 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5865 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5866 spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
5867 spec->num_dmics = stac92xx_connected_ports(codec,
5868 stac92hd71bxx_dmic_5port_nids,
5869 STAC92HD71BXX_NUM_DMICS - 1);
5871 case 0x111d7603: /* 6 Port with Analog Mixer */
5872 if ((codec->revision_id & 0xf) == 1)
5873 spec->stream_delay = 40; /* 40 milliseconds */
5877 spec->init = stac92hd71bxx_core_init;
5878 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5879 spec->num_dmics = stac92xx_connected_ports(codec,
5880 stac92hd71bxx_dmic_nids,
5881 STAC92HD71BXX_NUM_DMICS);
5885 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5886 snd_hda_sequence_write_cache(codec, unmute_init);
5888 spec->aloopback_ctl = stac92hd71bxx_loopback;
5889 spec->aloopback_mask = 0x50;
5890 spec->aloopback_shift = 0;
5892 spec->powerdown_adcs = 1;
5893 spec->digbeep_nid = 0x26;
5894 spec->mux_nids = stac92hd71bxx_mux_nids;
5895 spec->adc_nids = stac92hd71bxx_adc_nids;
5896 spec->smux_nids = stac92hd71bxx_smux_nids;
5897 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5899 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5900 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5901 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5902 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5904 snd_printdd("Found board config: %d\n", spec->board_config);
5906 switch (spec->board_config) {
5908 /* enable internal microphone */
5909 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5910 stac92xx_auto_set_pinctl(codec, 0x0e,
5911 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5913 case STAC_DELL_M4_2:
5914 spec->num_dmics = 0;
5915 spec->num_smuxes = 0;
5916 spec->num_dmuxes = 0;
5918 case STAC_DELL_M4_1:
5919 case STAC_DELL_M4_3:
5920 spec->num_dmics = 1;
5921 spec->num_smuxes = 0;
5922 spec->num_dmuxes = 1;
5924 case STAC_HP_DV4_1222NR:
5925 spec->num_dmics = 1;
5926 /* I don't know if it needs 1 or 2 smuxes - will wait for
5927 * bug reports to fix if needed
5929 spec->num_smuxes = 1;
5930 spec->num_dmuxes = 1;
5933 spec->gpio_led = 0x01;
5936 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5937 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5938 /* HP dv6 gives the headphone pin as a line-out. Thus we
5939 * need to set hp_detect flag here to force to enable HP
5942 spec->hp_detect = 1;
5945 spec->num_dmics = 1;
5946 spec->num_dmuxes = 1;
5947 spec->num_smuxes = 1;
5948 spec->gpio_led = 0x08;
5952 if (hp_blike_system(codec->subsystem_id)) {
5953 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5954 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5955 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5956 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5957 /* It was changed in the BIOS to just satisfy MS DTM.
5958 * Lets turn it back into slaved HP
5960 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5961 | (AC_JACK_HP_OUT <<
5962 AC_DEFCFG_DEVICE_SHIFT);
5963 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5964 | AC_DEFCFG_SEQUENCE)))
5966 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5970 if (find_mute_led_gpio(codec, 1))
5971 snd_printd("mute LED gpio %d polarity %d\n",
5973 spec->gpio_led_polarity);
5975 #ifdef CONFIG_SND_HDA_POWER_SAVE
5976 if (spec->gpio_led) {
5977 if (spec->gpio_led <= 8) {
5978 spec->gpio_mask |= spec->gpio_led;
5979 spec->gpio_dir |= spec->gpio_led;
5980 spec->gpio_data |= spec->gpio_led;
5982 codec->patch_ops.set_power_state =
5983 stac92xx_set_power_state;
5984 codec->patch_ops.post_suspend =
5985 stac92xx_post_suspend;
5987 codec->patch_ops.pre_resume = stac92xx_pre_resume;
5988 codec->patch_ops.check_power_status =
5989 stac92xx_check_power_status;
5993 spec->multiout.dac_nids = spec->dac_nids;
5995 err = stac92xx_parse_auto_config(codec);
5997 if (spec->board_config < 0) {
5998 printk(KERN_WARNING "hda_codec: No auto-config is "
5999 "available, default to model=ref\n");
6000 spec->board_config = STAC_92HD71BXX_REF;
6007 stac92xx_free(codec);
6011 /* enable bass on HP dv7 */
6012 if (spec->board_config == STAC_HP_DV4 ||
6013 spec->board_config == STAC_HP_DV5) {
6015 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
6016 cap &= AC_GPIO_IO_COUNT;
6018 stac_add_hp_bass_switch(codec);
6021 codec->proc_widget_hook = stac92hd7x_proc_hook;
6026 static int patch_stac922x(struct hda_codec *codec)
6028 struct sigmatel_spec *spec;
6031 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6035 codec->no_trigger_sense = 1;
6037 spec->linear_tone_beep = 1;
6038 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
6039 spec->pin_nids = stac922x_pin_nids;
6040 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
6043 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
6044 spec->gpio_mask = spec->gpio_dir = 0x03;
6045 spec->gpio_data = 0x03;
6046 /* Intel Macs have all same PCI SSID, so we need to check
6047 * codec SSID to distinguish the exact models
6049 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
6050 switch (codec->subsystem_id) {
6053 spec->board_config = STAC_INTEL_MAC_V1;
6057 spec->board_config = STAC_INTEL_MAC_V2;
6065 spec->board_config = STAC_INTEL_MAC_V3;
6069 spec->board_config = STAC_INTEL_MAC_V4;
6073 spec->board_config = STAC_INTEL_MAC_V5;
6076 spec->board_config = STAC_INTEL_MAC_V3;
6082 if (spec->board_config < 0)
6083 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6086 stac92xx_set_config_regs(codec,
6087 stac922x_brd_tbl[spec->board_config]);
6089 spec->adc_nids = stac922x_adc_nids;
6090 spec->mux_nids = stac922x_mux_nids;
6091 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
6092 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
6093 spec->num_dmics = 0;
6096 spec->init = stac922x_core_init;
6098 spec->num_caps = STAC922X_NUM_CAPS;
6099 spec->capvols = stac922x_capvols;
6100 spec->capsws = stac922x_capsws;
6102 spec->multiout.dac_nids = spec->dac_nids;
6104 err = stac92xx_parse_auto_config(codec);
6106 if (spec->board_config < 0) {
6107 printk(KERN_WARNING "hda_codec: No auto-config is "
6108 "available, default to model=ref\n");
6109 spec->board_config = STAC_D945_REF;
6115 stac92xx_free(codec);
6119 codec->patch_ops = stac92xx_patch_ops;
6121 /* Fix Mux capture level; max to 2 */
6122 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
6123 (0 << AC_AMPCAP_OFFSET_SHIFT) |
6124 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
6125 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
6126 (0 << AC_AMPCAP_MUTE_SHIFT));
6131 static int patch_stac927x(struct hda_codec *codec)
6133 struct sigmatel_spec *spec;
6136 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6140 codec->no_trigger_sense = 1;
6142 spec->linear_tone_beep = 1;
6143 codec->slave_dig_outs = stac927x_slave_dig_outs;
6144 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
6145 spec->pin_nids = stac927x_pin_nids;
6146 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
6150 if (spec->board_config < 0)
6151 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6154 stac92xx_set_config_regs(codec,
6155 stac927x_brd_tbl[spec->board_config]);
6157 spec->digbeep_nid = 0x23;
6158 spec->adc_nids = stac927x_adc_nids;
6159 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
6160 spec->mux_nids = stac927x_mux_nids;
6161 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
6162 spec->smux_nids = stac927x_smux_nids;
6163 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
6164 spec->spdif_labels = stac927x_spdif_labels;
6165 spec->dac_list = stac927x_dac_nids;
6166 spec->multiout.dac_nids = spec->dac_nids;
6168 if (spec->board_config != STAC_D965_REF) {
6169 /* GPIO0 High = Enable EAPD */
6170 spec->eapd_mask = spec->gpio_mask = 0x01;
6171 spec->gpio_dir = spec->gpio_data = 0x01;
6174 switch (spec->board_config) {
6177 /* GPIO0 High = Enable EAPD */
6178 spec->num_dmics = 0;
6179 spec->init = d965_core_init;
6181 case STAC_DELL_BIOS:
6182 switch (codec->subsystem_id) {
6185 /* correct the device field to SPDIF out */
6186 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
6189 /* configure the analog microphone on some laptops */
6190 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
6191 /* correct the front output jack as a hp out */
6192 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
6193 /* correct the front input jack as a mic */
6194 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
6197 if (codec->subsystem_id != 0x1028022f) {
6198 /* GPIO2 High = Enable EAPD */
6199 spec->eapd_mask = spec->gpio_mask = 0x04;
6200 spec->gpio_dir = spec->gpio_data = 0x04;
6202 spec->dmic_nids = stac927x_dmic_nids;
6203 spec->num_dmics = STAC927X_NUM_DMICS;
6205 spec->init = dell_3st_core_init;
6206 spec->dmux_nids = stac927x_dmux_nids;
6207 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
6209 case STAC_927X_VOLKNOB:
6210 spec->num_dmics = 0;
6211 spec->init = stac927x_volknob_core_init;
6214 spec->num_dmics = 0;
6215 spec->init = stac927x_core_init;
6219 spec->num_caps = STAC927X_NUM_CAPS;
6220 spec->capvols = stac927x_capvols;
6221 spec->capsws = stac927x_capsws;
6224 spec->aloopback_ctl = stac927x_loopback;
6225 spec->aloopback_mask = 0x40;
6226 spec->aloopback_shift = 0;
6227 spec->eapd_switch = 1;
6229 err = stac92xx_parse_auto_config(codec);
6231 if (spec->board_config < 0) {
6232 printk(KERN_WARNING "hda_codec: No auto-config is "
6233 "available, default to model=ref\n");
6234 spec->board_config = STAC_D965_REF;
6240 stac92xx_free(codec);
6244 codec->patch_ops = stac92xx_patch_ops;
6246 codec->proc_widget_hook = stac927x_proc_hook;
6250 * The STAC927x seem to require fairly long delays for certain
6251 * command sequences. With too short delays (even if the answer
6252 * is set to RIRB properly), it results in the silence output
6253 * on some hardwares like Dell.
6255 * The below flag enables the longer delay (see get_response
6258 codec->bus->needs_damn_long_delay = 1;
6260 /* no jack detecion for ref-no-jd model */
6261 if (spec->board_config == STAC_D965_REF_NO_JD)
6262 spec->hp_detect = 0;
6267 static int patch_stac9205(struct hda_codec *codec)
6269 struct sigmatel_spec *spec;
6272 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6276 codec->no_trigger_sense = 1;
6278 spec->linear_tone_beep = 1;
6279 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
6280 spec->pin_nids = stac9205_pin_nids;
6281 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6285 if (spec->board_config < 0)
6286 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6289 stac92xx_set_config_regs(codec,
6290 stac9205_brd_tbl[spec->board_config]);
6292 spec->digbeep_nid = 0x23;
6293 spec->adc_nids = stac9205_adc_nids;
6294 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
6295 spec->mux_nids = stac9205_mux_nids;
6296 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
6297 spec->smux_nids = stac9205_smux_nids;
6298 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
6299 spec->dmic_nids = stac9205_dmic_nids;
6300 spec->num_dmics = STAC9205_NUM_DMICS;
6301 spec->dmux_nids = stac9205_dmux_nids;
6302 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
6305 spec->init = stac9205_core_init;
6306 spec->aloopback_ctl = stac9205_loopback;
6308 spec->num_caps = STAC9205_NUM_CAPS;
6309 spec->capvols = stac9205_capvols;
6310 spec->capsws = stac9205_capsws;
6312 spec->aloopback_mask = 0x40;
6313 spec->aloopback_shift = 0;
6314 /* Turn on/off EAPD per HP plugging */
6315 if (spec->board_config != STAC_9205_EAPD)
6316 spec->eapd_switch = 1;
6317 spec->multiout.dac_nids = spec->dac_nids;
6319 switch (spec->board_config){
6320 case STAC_9205_DELL_M43:
6321 /* Enable SPDIF in/out */
6322 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6323 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
6325 /* Enable unsol response for GPIO4/Dock HP connection */
6326 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6329 snd_hda_codec_write_cache(codec, codec->afg, 0,
6330 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6331 snd_hda_codec_write_cache(codec, codec->afg, 0,
6332 AC_VERB_SET_UNSOLICITED_ENABLE,
6335 spec->gpio_dir = 0x0b;
6336 spec->eapd_mask = 0x01;
6337 spec->gpio_mask = 0x1b;
6338 spec->gpio_mute = 0x10;
6339 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
6342 spec->gpio_data = 0x01;
6345 /* SPDIF-In enabled */
6348 /* GPIO0 High = EAPD */
6349 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6350 spec->gpio_data = 0x01;
6354 err = stac92xx_parse_auto_config(codec);
6356 if (spec->board_config < 0) {
6357 printk(KERN_WARNING "hda_codec: No auto-config is "
6358 "available, default to model=ref\n");
6359 spec->board_config = STAC_9205_REF;
6365 stac92xx_free(codec);
6369 codec->patch_ops = stac92xx_patch_ops;
6371 codec->proc_widget_hook = stac9205_proc_hook;
6380 static const struct hda_verb stac9872_core_init[] = {
6381 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
6382 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6386 static const hda_nid_t stac9872_pin_nids[] = {
6387 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6391 static const hda_nid_t stac9872_adc_nids[] = {
6395 static const hda_nid_t stac9872_mux_nids[] = {
6399 static const unsigned long stac9872_capvols[] = {
6400 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6402 #define stac9872_capsws stac9872_capvols
6404 static const unsigned int stac9872_vaio_pin_configs[9] = {
6405 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6406 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6410 static const char * const stac9872_models[STAC_9872_MODELS] = {
6411 [STAC_9872_AUTO] = "auto",
6412 [STAC_9872_VAIO] = "vaio",
6415 static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6416 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6419 static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
6420 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6421 "Sony VAIO F/S", STAC_9872_VAIO),
6425 static int patch_stac9872(struct hda_codec *codec)
6427 struct sigmatel_spec *spec;
6430 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6433 codec->no_trigger_sense = 1;
6435 spec->linear_tone_beep = 1;
6436 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6437 spec->pin_nids = stac9872_pin_nids;
6439 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6442 if (spec->board_config < 0)
6443 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6446 stac92xx_set_config_regs(codec,
6447 stac9872_brd_tbl[spec->board_config]);
6449 spec->multiout.dac_nids = spec->dac_nids;
6450 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6451 spec->adc_nids = stac9872_adc_nids;
6452 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6453 spec->mux_nids = stac9872_mux_nids;
6454 spec->init = stac9872_core_init;
6456 spec->capvols = stac9872_capvols;
6457 spec->capsws = stac9872_capsws;
6459 err = stac92xx_parse_auto_config(codec);
6461 stac92xx_free(codec);
6464 spec->input_mux = &spec->private_imux;
6465 codec->patch_ops = stac92xx_patch_ops;
6473 static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6474 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6475 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6476 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6477 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6478 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6479 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6480 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6481 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6482 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6483 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6484 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6485 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6486 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6487 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6488 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6489 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6490 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6491 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6492 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6493 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6494 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6495 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6496 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6497 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6498 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6499 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6500 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6501 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6502 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6503 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6504 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6505 /* The following does not take into account .id=0x83847661 when subsys =
6506 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6507 * currently not fully supported.
6509 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6510 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6511 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6512 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6513 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6514 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6515 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6516 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6517 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6518 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6519 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6520 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6521 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6522 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6523 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
6524 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6525 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6526 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6527 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
6528 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6529 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6530 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6531 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
6532 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6533 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6534 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6535 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6536 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6537 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6538 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6539 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6540 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6541 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6542 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6543 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6544 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6545 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6546 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6547 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6548 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6549 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6550 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6551 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6552 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6553 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6554 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6555 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6556 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6557 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6558 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
6559 { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
6560 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
6561 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6562 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
6563 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
6564 { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
6565 { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
6566 { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
6567 { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
6568 { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
6569 { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
6570 { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
6571 { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
6572 { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
6573 { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
6574 { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
6575 { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
6579 MODULE_ALIAS("snd-hda-codec-id:8384*");
6580 MODULE_ALIAS("snd-hda-codec-id:111d*");
6582 MODULE_LICENSE("GPL");
6583 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6585 static struct hda_codec_preset_list sigmatel_list = {
6586 .preset = snd_hda_preset_sigmatel,
6587 .owner = THIS_MODULE,
6590 static int __init patch_sigmatel_init(void)
6592 return snd_hda_add_codec_preset(&sigmatel_list);
6595 static void __exit patch_sigmatel_exit(void)
6597 snd_hda_delete_codec_preset(&sigmatel_list);
6600 module_init(patch_sigmatel_init)
6601 module_exit(patch_sigmatel_exit)