2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <sound/core.h>
32 #include <sound/asoundef.h>
33 #include <sound/jack.h>
34 #include "hda_codec.h"
35 #include "hda_local.h"
79 STAC_92HD73XX_NO_JD, /* no jack-detection */
92 STAC_92HD83XXX_PWR_REF,
107 STAC_92HD71BXX_MODELS
133 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
134 * is given, one of the above models will be
135 * chosen according to the subsystem id. */
136 /* for backward compatibility */
153 STAC_D965_REF_NO_JD, /* no jack-detection */
169 struct sigmatel_event {
176 struct sigmatel_jack {
179 struct snd_jack *jack;
182 struct sigmatel_mic_route {
184 unsigned char mux_idx;
185 unsigned char dmux_idx;
188 struct sigmatel_spec {
189 struct snd_kcontrol_new *mixers[4];
190 unsigned int num_mixers;
193 unsigned int eapd_switch: 1;
194 unsigned int surr_switch: 1;
195 unsigned int alt_switch: 1;
196 unsigned int hp_detect: 1;
197 unsigned int spdif_mute: 1;
198 unsigned int check_volume_offset:1;
199 unsigned int auto_mic:1;
202 unsigned int eapd_mask;
203 unsigned int gpio_mask;
204 unsigned int gpio_dir;
205 unsigned int gpio_data;
206 unsigned int gpio_mute;
207 unsigned int gpio_led;
210 unsigned int stream_delay;
212 /* analog loopback */
213 struct snd_kcontrol_new *aloopback_ctl;
214 unsigned char aloopback_mask;
215 unsigned char aloopback_shift;
217 /* power management */
218 unsigned int num_pwrs;
219 unsigned int *pwr_mapping;
224 struct snd_array jacks;
227 struct snd_array events;
230 struct hda_input_mux *mono_mux;
231 struct hda_input_mux *amp_mux;
232 unsigned int cur_mmux;
233 struct hda_multi_out multiout;
234 hda_nid_t dac_nids[5];
235 hda_nid_t hp_dacs[5];
236 hda_nid_t speaker_dacs[5];
242 unsigned int num_adcs;
244 unsigned int num_muxes;
245 hda_nid_t *dmic_nids;
246 unsigned int num_dmics;
247 hda_nid_t *dmux_nids;
248 unsigned int num_dmuxes;
249 hda_nid_t *smux_nids;
250 unsigned int num_smuxes;
251 unsigned int num_analog_muxes;
253 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
255 unsigned int num_caps; /* number of capture volume/switch elements */
257 struct sigmatel_mic_route ext_mic;
258 struct sigmatel_mic_route int_mic;
260 const char **spdif_labels;
262 hda_nid_t dig_in_nid;
264 hda_nid_t anabeep_nid;
265 hda_nid_t digbeep_nid;
269 unsigned int num_pins;
271 /* codec specific stuff */
272 struct hda_verb *init;
273 struct snd_kcontrol_new *mixer;
276 struct hda_input_mux *dinput_mux;
277 unsigned int cur_dmux[2];
278 struct hda_input_mux *input_mux;
279 unsigned int cur_mux[3];
280 struct hda_input_mux *sinput_mux;
281 unsigned int cur_smux[2];
282 unsigned int cur_amux;
284 unsigned int num_amps;
285 unsigned int powerdown_adcs;
288 unsigned int io_switch[2];
289 unsigned int clfe_swap;
290 hda_nid_t line_switch; /* shared line-in for input and output */
291 hda_nid_t mic_switch; /* shared mic-in for input and output */
292 hda_nid_t hp_switch; /* NID of HP as line-out */
293 unsigned int aloopback;
295 struct hda_pcm pcm_rec[2]; /* PCM information */
297 /* dynamic controls and input_mux */
298 struct auto_pin_cfg autocfg;
299 struct snd_array kctls;
300 struct hda_input_mux private_dimux;
301 struct hda_input_mux private_imux;
302 struct hda_input_mux private_smux;
303 struct hda_input_mux private_amp_mux;
304 struct hda_input_mux private_mono_mux;
307 static hda_nid_t stac9200_adc_nids[1] = {
311 static hda_nid_t stac9200_mux_nids[1] = {
315 static hda_nid_t stac9200_dac_nids[1] = {
319 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
320 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
324 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
328 static hda_nid_t stac92hd73xx_adc_nids[2] = {
332 #define STAC92HD73XX_NUM_DMICS 2
333 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
337 #define STAC92HD73_DAC_COUNT 5
339 static hda_nid_t stac92hd73xx_mux_nids[2] = {
343 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
347 static hda_nid_t stac92hd73xx_smux_nids[2] = {
351 #define STAC92HD73XX_NUM_CAPS 2
352 static unsigned long stac92hd73xx_capvols[] = {
353 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
354 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
356 #define stac92hd73xx_capsws stac92hd73xx_capvols
358 #define STAC92HD83_DAC_COUNT 3
360 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
364 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
368 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
372 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
376 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
377 0x03, 0x0c, 0x20, 0x40,
380 #define STAC92HD83XXX_NUM_CAPS 2
381 static unsigned long stac92hd83xxx_capvols[] = {
382 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
383 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
385 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
387 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
391 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
395 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
399 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
403 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
407 #define STAC92HD71BXX_NUM_DMICS 2
408 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
412 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
416 #define STAC92HD71BXX_NUM_CAPS 2
417 static unsigned long stac92hd71bxx_capvols[] = {
418 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
419 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
421 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
423 static hda_nid_t stac925x_adc_nids[1] = {
427 static hda_nid_t stac925x_mux_nids[1] = {
431 static hda_nid_t stac925x_dac_nids[1] = {
435 #define STAC925X_NUM_DMICS 1
436 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
440 static hda_nid_t stac925x_dmux_nids[1] = {
444 static unsigned long stac925x_capvols[] = {
445 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
447 static unsigned long stac925x_capsws[] = {
448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
451 static hda_nid_t stac922x_adc_nids[2] = {
455 static hda_nid_t stac922x_mux_nids[2] = {
459 #define STAC922X_NUM_CAPS 2
460 static unsigned long stac922x_capvols[] = {
461 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
462 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
464 #define stac922x_capsws stac922x_capvols
466 static hda_nid_t stac927x_slave_dig_outs[2] = {
470 static hda_nid_t stac927x_adc_nids[3] = {
474 static hda_nid_t stac927x_mux_nids[3] = {
478 static hda_nid_t stac927x_smux_nids[1] = {
482 static hda_nid_t stac927x_dac_nids[6] = {
483 0x02, 0x03, 0x04, 0x05, 0x06, 0
486 static hda_nid_t stac927x_dmux_nids[1] = {
490 #define STAC927X_NUM_DMICS 2
491 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
495 #define STAC927X_NUM_CAPS 3
496 static unsigned long stac927x_capvols[] = {
497 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
498 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
499 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
501 static unsigned long stac927x_capsws[] = {
502 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
503 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
504 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
507 static const char *stac927x_spdif_labels[5] = {
508 "Digital Playback", "ADAT", "Analog Mux 1",
509 "Analog Mux 2", "Analog Mux 3"
512 static hda_nid_t stac9205_adc_nids[2] = {
516 static hda_nid_t stac9205_mux_nids[2] = {
520 static hda_nid_t stac9205_dmux_nids[1] = {
524 static hda_nid_t stac9205_smux_nids[1] = {
528 #define STAC9205_NUM_DMICS 2
529 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
533 #define STAC9205_NUM_CAPS 2
534 static unsigned long stac9205_capvols[] = {
535 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
536 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
538 static unsigned long stac9205_capsws[] = {
539 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
540 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
543 static hda_nid_t stac9200_pin_nids[8] = {
544 0x08, 0x09, 0x0d, 0x0e,
545 0x0f, 0x10, 0x11, 0x12,
548 static hda_nid_t stac925x_pin_nids[8] = {
549 0x07, 0x08, 0x0a, 0x0b,
550 0x0c, 0x0d, 0x10, 0x11,
553 static hda_nid_t stac922x_pin_nids[10] = {
554 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
555 0x0f, 0x10, 0x11, 0x15, 0x1b,
558 static hda_nid_t stac92hd73xx_pin_nids[13] = {
559 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
560 0x0f, 0x10, 0x11, 0x12, 0x13,
564 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
565 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
566 0x0f, 0x10, 0x11, 0x1f, 0x20,
569 #define STAC92HD71BXX_NUM_PINS 13
570 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
571 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
572 0x00, 0x14, 0x18, 0x19, 0x1e,
575 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
576 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
577 0x0f, 0x14, 0x18, 0x19, 0x1e,
581 static hda_nid_t stac927x_pin_nids[14] = {
582 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
583 0x0f, 0x10, 0x11, 0x12, 0x13,
584 0x14, 0x21, 0x22, 0x23,
587 static hda_nid_t stac9205_pin_nids[12] = {
588 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
589 0x0f, 0x14, 0x16, 0x17, 0x18,
593 #define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
595 static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
596 struct snd_ctl_elem_value *ucontrol)
598 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
599 struct sigmatel_spec *spec = codec->spec;
600 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
602 kcontrol->private_value ^= get_amp_nid(kcontrol);
603 kcontrol->private_value |= nid;
605 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
608 static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
609 struct snd_ctl_elem_value *ucontrol)
611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
612 struct sigmatel_spec *spec = codec->spec;
613 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
615 kcontrol->private_value ^= get_amp_nid(kcontrol);
616 kcontrol->private_value |= nid;
618 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
621 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
622 struct snd_ctl_elem_info *uinfo)
624 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
625 struct sigmatel_spec *spec = codec->spec;
626 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
629 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
630 struct snd_ctl_elem_value *ucontrol)
632 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
633 struct sigmatel_spec *spec = codec->spec;
634 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
636 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
640 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
641 struct snd_ctl_elem_value *ucontrol)
643 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
644 struct sigmatel_spec *spec = codec->spec;
645 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
647 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
648 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
651 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
652 struct snd_ctl_elem_info *uinfo)
654 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
655 struct sigmatel_spec *spec = codec->spec;
656 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
659 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
660 struct snd_ctl_elem_value *ucontrol)
662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
663 struct sigmatel_spec *spec = codec->spec;
664 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
666 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
670 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
671 struct snd_ctl_elem_value *ucontrol)
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 struct sigmatel_spec *spec = codec->spec;
675 struct hda_input_mux *smux = &spec->private_smux;
676 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
680 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
681 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
685 if (spec->spdif_mute) {
687 nid = spec->multiout.dig_out_nid;
689 nid = codec->slave_dig_outs[smux_idx - 1];
690 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
694 /* un/mute SPDIF out */
695 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
701 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
702 hda_nid_t nid, unsigned int new_vref)
706 pincfg = snd_hda_codec_read(codec, nid, 0,
707 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
710 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
713 if (new_vref == AC_PINCTL_VREF_HIZ)
714 pincfg |= AC_PINCTL_OUT_EN;
716 pincfg |= AC_PINCTL_IN_EN;
718 error = snd_hda_codec_write_cache(codec, nid, 0,
719 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
726 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
729 vref = snd_hda_codec_read(codec, nid, 0,
730 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
731 vref &= AC_PINCTL_VREFEN;
735 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
737 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
738 struct sigmatel_spec *spec = codec->spec;
739 return snd_hda_input_mux_info(spec->input_mux, uinfo);
742 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
744 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
745 struct sigmatel_spec *spec = codec->spec;
746 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
748 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
752 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 struct sigmatel_spec *spec = codec->spec;
756 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
757 const struct hda_input_mux *imux = spec->input_mux;
758 unsigned int idx, prev_idx;
760 idx = ucontrol->value.enumerated.item[0];
761 if (idx >= imux->num_items)
762 idx = imux->num_items - 1;
763 prev_idx = spec->cur_mux[adc_idx];
766 if (idx < spec->num_analog_muxes) {
767 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
768 AC_VERB_SET_CONNECT_SEL,
769 imux->items[idx].index);
770 if (prev_idx >= spec->num_analog_muxes) {
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 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
781 AC_VERB_SET_CONNECT_SEL,
782 imux->items[idx - 1].index);
784 spec->cur_mux[adc_idx] = idx;
788 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
789 struct snd_ctl_elem_info *uinfo)
791 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
792 struct sigmatel_spec *spec = codec->spec;
793 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
796 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
797 struct snd_ctl_elem_value *ucontrol)
799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
800 struct sigmatel_spec *spec = codec->spec;
802 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
806 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
807 struct snd_ctl_elem_value *ucontrol)
809 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
810 struct sigmatel_spec *spec = codec->spec;
812 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
813 spec->mono_nid, &spec->cur_mmux);
816 static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
817 struct snd_ctl_elem_info *uinfo)
819 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
820 struct sigmatel_spec *spec = codec->spec;
821 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
824 static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
825 struct snd_ctl_elem_value *ucontrol)
827 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
828 struct sigmatel_spec *spec = codec->spec;
830 ucontrol->value.enumerated.item[0] = spec->cur_amux;
834 static int stac92xx_amp_mux_enum_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 struct snd_kcontrol *ctl =
840 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
844 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
845 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
847 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
851 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
853 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
854 struct snd_ctl_elem_value *ucontrol)
856 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
857 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
858 struct sigmatel_spec *spec = codec->spec;
860 ucontrol->value.integer.value[0] = !!(spec->aloopback &
861 (spec->aloopback_mask << idx));
865 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
866 struct snd_ctl_elem_value *ucontrol)
868 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
869 struct sigmatel_spec *spec = codec->spec;
870 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
871 unsigned int dac_mode;
872 unsigned int val, idx_val;
874 idx_val = spec->aloopback_mask << idx;
875 if (ucontrol->value.integer.value[0])
876 val = spec->aloopback | idx_val;
878 val = spec->aloopback & ~idx_val;
879 if (spec->aloopback == val)
882 spec->aloopback = val;
884 /* Only return the bits defined by the shift value of the
885 * first two bytes of the mask
887 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
888 kcontrol->private_value & 0xFFFF, 0x0);
889 dac_mode >>= spec->aloopback_shift;
891 if (spec->aloopback & idx_val) {
892 snd_hda_power_up(codec);
895 snd_hda_power_down(codec);
896 dac_mode &= ~idx_val;
899 snd_hda_codec_write_cache(codec, codec->afg, 0,
900 kcontrol->private_value >> 16, dac_mode);
905 static struct hda_verb stac9200_core_init[] = {
906 /* set dac0mux for dac converter */
907 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
911 static struct hda_verb stac9200_eapd_init[] = {
912 /* set dac0mux for dac converter */
913 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
914 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
918 static struct hda_verb dell_eq_core_init[] = {
919 /* set master volume to max value without distortion
920 * and direct control */
921 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
925 static struct hda_verb stac92hd73xx_core_init[] = {
926 /* set master volume and direct control */
927 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
931 static struct hda_verb stac92hd83xxx_core_init[] = {
932 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
933 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
934 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
936 /* power state controls amps */
937 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
941 static struct hda_verb stac92hd71bxx_core_init[] = {
942 /* set master volume and direct control */
943 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
947 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
948 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
949 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
950 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
951 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
955 static struct hda_verb stac925x_core_init[] = {
956 /* set dac0mux for dac converter */
957 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
958 /* mute the master volume */
959 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
963 static struct hda_verb stac922x_core_init[] = {
964 /* set master volume and direct control */
965 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
969 static struct hda_verb d965_core_init[] = {
970 /* set master volume and direct control */
971 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
972 /* unmute node 0x1b */
973 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
974 /* select node 0x03 as DAC */
975 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
979 static struct hda_verb stac927x_core_init[] = {
980 /* set master volume and direct control */
981 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
982 /* enable analog pc beep path */
983 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
987 static struct hda_verb stac9205_core_init[] = {
988 /* set master volume and direct control */
989 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
990 /* enable analog pc beep path */
991 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
995 #define STAC_MONO_MUX \
997 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
998 .name = "Mono Mux", \
1000 .info = stac92xx_mono_mux_enum_info, \
1001 .get = stac92xx_mono_mux_enum_get, \
1002 .put = stac92xx_mono_mux_enum_put, \
1005 #define STAC_AMP_MUX \
1007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1008 .name = "Amp Selector Capture Switch", \
1010 .info = stac92xx_amp_mux_enum_info, \
1011 .get = stac92xx_amp_mux_enum_get, \
1012 .put = stac92xx_amp_mux_enum_put, \
1015 #define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1017 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1020 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1021 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1022 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1023 .info = stac92xx_amp_volume_info, \
1024 .get = stac92xx_amp_volume_get, \
1025 .put = stac92xx_amp_volume_put, \
1026 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1027 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1030 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1032 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1033 .name = "Analog Loopback", \
1035 .info = stac92xx_aloopback_info, \
1036 .get = stac92xx_aloopback_get, \
1037 .put = stac92xx_aloopback_put, \
1038 .private_value = verb_read | (verb_write << 16), \
1041 #define DC_BIAS(xname, idx, nid) \
1043 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1046 .info = stac92xx_dc_bias_info, \
1047 .get = stac92xx_dc_bias_get, \
1048 .put = stac92xx_dc_bias_put, \
1049 .private_value = nid, \
1052 static struct snd_kcontrol_new stac9200_mixer[] = {
1053 HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1054 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1055 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1056 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1060 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1061 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1065 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1066 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1070 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1071 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1076 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1077 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1080 static struct snd_kcontrol_new stac925x_mixer[] = {
1081 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1082 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1086 static struct snd_kcontrol_new stac9205_loopback[] = {
1087 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1091 static struct snd_kcontrol_new stac927x_loopback[] = {
1092 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1096 static struct snd_kcontrol_new stac_dmux_mixer = {
1097 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1098 .name = "Digital Input Source",
1099 /* count set later */
1100 .info = stac92xx_dmux_enum_info,
1101 .get = stac92xx_dmux_enum_get,
1102 .put = stac92xx_dmux_enum_put,
1105 static struct snd_kcontrol_new stac_smux_mixer = {
1106 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1107 .name = "IEC958 Playback Source",
1108 /* count set later */
1109 .info = stac92xx_smux_enum_info,
1110 .get = stac92xx_smux_enum_get,
1111 .put = stac92xx_smux_enum_put,
1114 static const char *slave_vols[] = {
1115 "Front Playback Volume",
1116 "Surround Playback Volume",
1117 "Center Playback Volume",
1118 "LFE Playback Volume",
1119 "Side Playback Volume",
1120 "Headphone Playback Volume",
1121 "Speaker Playback Volume",
1125 static const char *slave_sws[] = {
1126 "Front Playback Switch",
1127 "Surround Playback Switch",
1128 "Center Playback Switch",
1129 "LFE Playback Switch",
1130 "Side Playback Switch",
1131 "Headphone Playback Switch",
1132 "Speaker Playback Switch",
1133 "IEC958 Playback Switch",
1137 static void stac92xx_free_kctls(struct hda_codec *codec);
1138 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1140 static int stac92xx_build_controls(struct hda_codec *codec)
1142 struct sigmatel_spec *spec = codec->spec;
1143 struct auto_pin_cfg *cfg = &spec->autocfg;
1149 err = snd_hda_add_new_ctls(codec, spec->mixer);
1154 for (i = 0; i < spec->num_mixers; i++) {
1155 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1159 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1160 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1161 stac_dmux_mixer.count = spec->num_dmuxes;
1162 err = snd_hda_ctl_add(codec,
1163 snd_ctl_new1(&stac_dmux_mixer, codec));
1167 if (spec->num_smuxes > 0) {
1168 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1169 struct hda_input_mux *smux = &spec->private_smux;
1170 /* check for mute support on SPDIF out */
1171 if (wcaps & AC_WCAP_OUT_AMP) {
1172 smux->items[smux->num_items].label = "Off";
1173 smux->items[smux->num_items].index = 0;
1175 spec->spdif_mute = 1;
1177 stac_smux_mixer.count = spec->num_smuxes;
1178 err = snd_hda_ctl_add(codec,
1179 snd_ctl_new1(&stac_smux_mixer, codec));
1184 if (spec->multiout.dig_out_nid) {
1185 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1188 err = snd_hda_create_spdif_share_sw(codec,
1192 spec->multiout.share_spdif = 1;
1194 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1195 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1200 /* if we have no master control, let's create it */
1201 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1202 unsigned int vmaster_tlv[4];
1203 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1204 HDA_OUTPUT, vmaster_tlv);
1205 /* correct volume offset */
1206 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1207 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1208 vmaster_tlv, slave_vols);
1212 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1213 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1219 if (spec->aloopback_ctl &&
1220 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1221 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1226 stac92xx_free_kctls(codec); /* no longer needed */
1228 /* create jack input elements */
1229 if (spec->hp_detect) {
1230 for (i = 0; i < cfg->hp_outs; i++) {
1231 int type = SND_JACK_HEADPHONE;
1232 nid = cfg->hp_pins[i];
1233 /* jack detection */
1234 if (cfg->hp_outs == i)
1235 type |= SND_JACK_LINEOUT;
1236 err = stac92xx_add_jack(codec, nid, type);
1241 for (i = 0; i < cfg->line_outs; i++) {
1242 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1247 for (i = 0; i < AUTO_PIN_LAST; i++) {
1248 nid = cfg->input_pins[i];
1250 err = stac92xx_add_jack(codec, nid,
1251 SND_JACK_MICROPHONE);
1260 static unsigned int ref9200_pin_configs[8] = {
1261 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1262 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1265 static unsigned int gateway9200_m4_pin_configs[8] = {
1266 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1267 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1269 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1270 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1271 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1275 STAC 9200 pin configs for
1280 static unsigned int dell9200_d21_pin_configs[8] = {
1281 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1282 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1286 STAC 9200 pin configs for
1290 static unsigned int dell9200_d22_pin_configs[8] = {
1291 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1292 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1296 STAC 9200 pin configs for
1297 102801C4 (Dell Dimension E310)
1304 static unsigned int dell9200_d23_pin_configs[8] = {
1305 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1306 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1311 STAC 9200-32 pin configs for
1312 102801B5 (Dell Inspiron 630m)
1313 102801D8 (Dell Inspiron 640m)
1315 static unsigned int dell9200_m21_pin_configs[8] = {
1316 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1317 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1321 STAC 9200-32 pin configs for
1322 102801C2 (Dell Latitude D620)
1324 102801CC (Dell Latitude D820)
1328 static unsigned int dell9200_m22_pin_configs[8] = {
1329 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1330 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1334 STAC 9200-32 pin configs for
1335 102801CE (Dell XPS M1710)
1336 102801CF (Dell Precision M90)
1338 static unsigned int dell9200_m23_pin_configs[8] = {
1339 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1340 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1344 STAC 9200-32 pin configs for
1347 102801CB (Dell Latitude 120L)
1350 static unsigned int dell9200_m24_pin_configs[8] = {
1351 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1352 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1356 STAC 9200-32 pin configs for
1357 102801BD (Dell Inspiron E1505n)
1361 static unsigned int dell9200_m25_pin_configs[8] = {
1362 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1363 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1367 STAC 9200-32 pin configs for
1368 102801F5 (Dell Inspiron 1501)
1371 static unsigned int dell9200_m26_pin_configs[8] = {
1372 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1373 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1378 102801CD (Dell Inspiron E1705/9400)
1380 static unsigned int dell9200_m27_pin_configs[8] = {
1381 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1382 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1385 static unsigned int oqo9200_pin_configs[8] = {
1386 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1387 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1391 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1392 [STAC_REF] = ref9200_pin_configs,
1393 [STAC_9200_OQO] = oqo9200_pin_configs,
1394 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1395 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1396 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1397 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1398 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1399 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1400 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1401 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1402 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1403 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1404 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1405 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1406 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1409 static const char *stac9200_models[STAC_9200_MODELS] = {
1410 [STAC_AUTO] = "auto",
1412 [STAC_9200_OQO] = "oqo",
1413 [STAC_9200_DELL_D21] = "dell-d21",
1414 [STAC_9200_DELL_D22] = "dell-d22",
1415 [STAC_9200_DELL_D23] = "dell-d23",
1416 [STAC_9200_DELL_M21] = "dell-m21",
1417 [STAC_9200_DELL_M22] = "dell-m22",
1418 [STAC_9200_DELL_M23] = "dell-m23",
1419 [STAC_9200_DELL_M24] = "dell-m24",
1420 [STAC_9200_DELL_M25] = "dell-m25",
1421 [STAC_9200_DELL_M26] = "dell-m26",
1422 [STAC_9200_DELL_M27] = "dell-m27",
1423 [STAC_9200_M4] = "gateway-m4",
1424 [STAC_9200_M4_2] = "gateway-m4-2",
1425 [STAC_9200_PANASONIC] = "panasonic",
1428 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1429 /* SigmaTel reference board */
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1431 "DFI LanParty", STAC_REF),
1432 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1433 "DFI LanParty", STAC_REF),
1434 /* Dell laptops have BIOS problem */
1435 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1436 "unknown Dell", STAC_9200_DELL_D21),
1437 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1438 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1439 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1440 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1441 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1442 "unknown Dell", STAC_9200_DELL_D22),
1443 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1444 "unknown Dell", STAC_9200_DELL_D22),
1445 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1446 "Dell Latitude D620", STAC_9200_DELL_M22),
1447 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1448 "unknown Dell", STAC_9200_DELL_D23),
1449 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1450 "unknown Dell", STAC_9200_DELL_D23),
1451 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1452 "unknown Dell", STAC_9200_DELL_M22),
1453 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1454 "unknown Dell", STAC_9200_DELL_M24),
1455 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1456 "unknown Dell", STAC_9200_DELL_M24),
1457 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1458 "Dell Latitude 120L", STAC_9200_DELL_M24),
1459 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1460 "Dell Latitude D820", STAC_9200_DELL_M22),
1461 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1462 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1463 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1464 "Dell XPS M1710", STAC_9200_DELL_M23),
1465 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1466 "Dell Precision M90", STAC_9200_DELL_M23),
1467 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1468 "unknown Dell", STAC_9200_DELL_M22),
1469 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1470 "unknown Dell", STAC_9200_DELL_M22),
1471 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1472 "unknown Dell", STAC_9200_DELL_M22),
1473 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1474 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1475 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1476 "unknown Dell", STAC_9200_DELL_D23),
1477 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1478 "unknown Dell", STAC_9200_DELL_D23),
1479 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1480 "unknown Dell", STAC_9200_DELL_D21),
1481 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1482 "unknown Dell", STAC_9200_DELL_D23),
1483 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1484 "unknown Dell", STAC_9200_DELL_D21),
1485 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1486 "unknown Dell", STAC_9200_DELL_M25),
1487 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1488 "unknown Dell", STAC_9200_DELL_M25),
1489 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1490 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1491 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1492 "unknown Dell", STAC_9200_DELL_M26),
1494 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1495 /* Gateway machines needs EAPD to be set on resume */
1496 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1497 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1498 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1500 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1504 static unsigned int ref925x_pin_configs[8] = {
1505 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1506 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1509 static unsigned int stac925xM1_pin_configs[8] = {
1510 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1511 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1514 static unsigned int stac925xM1_2_pin_configs[8] = {
1515 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1516 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1519 static unsigned int stac925xM2_pin_configs[8] = {
1520 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1521 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1524 static unsigned int stac925xM2_2_pin_configs[8] = {
1525 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1526 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1529 static unsigned int stac925xM3_pin_configs[8] = {
1530 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1531 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1534 static unsigned int stac925xM5_pin_configs[8] = {
1535 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1536 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1539 static unsigned int stac925xM6_pin_configs[8] = {
1540 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1541 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1544 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1545 [STAC_REF] = ref925x_pin_configs,
1546 [STAC_M1] = stac925xM1_pin_configs,
1547 [STAC_M1_2] = stac925xM1_2_pin_configs,
1548 [STAC_M2] = stac925xM2_pin_configs,
1549 [STAC_M2_2] = stac925xM2_2_pin_configs,
1550 [STAC_M3] = stac925xM3_pin_configs,
1551 [STAC_M5] = stac925xM5_pin_configs,
1552 [STAC_M6] = stac925xM6_pin_configs,
1555 static const char *stac925x_models[STAC_925x_MODELS] = {
1556 [STAC_925x_AUTO] = "auto",
1559 [STAC_M1_2] = "m1-2",
1561 [STAC_M2_2] = "m2-2",
1567 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1568 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1569 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1570 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1571 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1572 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1573 /* Not sure about the brand name for those */
1574 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1575 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1576 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1577 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1581 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1582 /* SigmaTel reference board */
1583 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1584 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1585 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1587 /* Default table for unknown ID */
1588 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1593 static unsigned int ref92hd73xx_pin_configs[13] = {
1594 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1595 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1596 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1600 static unsigned int dell_m6_pin_configs[13] = {
1601 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1602 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1603 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1607 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1608 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1609 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1610 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1611 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1612 [STAC_DELL_EQ] = dell_m6_pin_configs,
1615 static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1616 [STAC_92HD73XX_AUTO] = "auto",
1617 [STAC_92HD73XX_NO_JD] = "no-jd",
1618 [STAC_92HD73XX_REF] = "ref",
1619 [STAC_92HD73XX_INTEL] = "intel",
1620 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1621 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1622 [STAC_DELL_M6_BOTH] = "dell-m6",
1623 [STAC_DELL_EQ] = "dell-eq",
1626 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1627 /* SigmaTel reference board */
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1629 "DFI LanParty", STAC_92HD73XX_REF),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1631 "DFI LanParty", STAC_92HD73XX_REF),
1632 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1633 "Intel DG45ID", STAC_92HD73XX_INTEL),
1634 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1635 "Intel DG45FC", STAC_92HD73XX_INTEL),
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1637 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1639 "unknown Dell", STAC_DELL_M6_DMIC),
1640 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1641 "unknown Dell", STAC_DELL_M6_BOTH),
1642 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1643 "unknown Dell", STAC_DELL_M6_BOTH),
1644 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1645 "unknown Dell", STAC_DELL_M6_AMIC),
1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1647 "unknown Dell", STAC_DELL_M6_AMIC),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1649 "unknown Dell", STAC_DELL_M6_DMIC),
1650 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1651 "unknown Dell", STAC_DELL_M6_DMIC),
1652 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1653 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1654 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1655 "Dell Studio 17", STAC_DELL_M6_DMIC),
1656 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1657 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1661 static unsigned int ref92hd83xxx_pin_configs[10] = {
1662 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1663 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1664 0x01451160, 0x98560170,
1667 static unsigned int dell_s14_pin_configs[10] = {
1668 0x02214030, 0x02211010, 0x02a19020, 0x01014050,
1669 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160,
1670 0x40f000f0, 0x40f000f0,
1673 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1674 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1675 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1676 [STAC_DELL_S14] = dell_s14_pin_configs,
1679 static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1680 [STAC_92HD83XXX_AUTO] = "auto",
1681 [STAC_92HD83XXX_REF] = "ref",
1682 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1683 [STAC_DELL_S14] = "dell-s14",
1686 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1687 /* SigmaTel reference board */
1688 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1689 "DFI LanParty", STAC_92HD83XXX_REF),
1690 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1691 "DFI LanParty", STAC_92HD83XXX_REF),
1692 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1693 "unknown Dell", STAC_DELL_S14),
1697 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1698 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1699 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1700 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1704 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1705 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1706 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1707 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1711 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1712 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1713 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1714 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1718 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1719 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1720 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1721 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1725 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1726 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1727 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1728 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1729 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1730 [STAC_HP_M4] = NULL,
1731 [STAC_HP_DV5] = NULL,
1732 [STAC_HP_HDX] = NULL,
1733 [STAC_HP_DV4_1222NR] = NULL,
1736 static const char *stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1737 [STAC_92HD71BXX_AUTO] = "auto",
1738 [STAC_92HD71BXX_REF] = "ref",
1739 [STAC_DELL_M4_1] = "dell-m4-1",
1740 [STAC_DELL_M4_2] = "dell-m4-2",
1741 [STAC_DELL_M4_3] = "dell-m4-3",
1742 [STAC_HP_M4] = "hp-m4",
1743 [STAC_HP_DV5] = "hp-dv5",
1744 [STAC_HP_HDX] = "hp-hdx",
1745 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1748 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1749 /* SigmaTel reference board */
1750 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1751 "DFI LanParty", STAC_92HD71BXX_REF),
1752 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1753 "DFI LanParty", STAC_92HD71BXX_REF),
1754 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1755 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1756 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1758 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1759 "HP dv4-7", STAC_HP_DV5),
1760 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1761 "HP dv4-7", STAC_HP_DV5),
1762 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1763 "HP HDX", STAC_HP_HDX), /* HDX18 */
1764 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1765 "HP mini 1000", STAC_HP_M4),
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1767 "HP HDX", STAC_HP_HDX), /* HDX16 */
1768 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1770 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1771 "unknown Dell", STAC_DELL_M4_1),
1772 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1773 "unknown Dell", STAC_DELL_M4_1),
1774 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1775 "unknown Dell", STAC_DELL_M4_1),
1776 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1777 "unknown Dell", STAC_DELL_M4_1),
1778 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1779 "unknown Dell", STAC_DELL_M4_1),
1780 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1781 "unknown Dell", STAC_DELL_M4_1),
1782 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1783 "unknown Dell", STAC_DELL_M4_1),
1784 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1785 "unknown Dell", STAC_DELL_M4_2),
1786 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1787 "unknown Dell", STAC_DELL_M4_2),
1788 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1789 "unknown Dell", STAC_DELL_M4_2),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1791 "unknown Dell", STAC_DELL_M4_2),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1793 "unknown Dell", STAC_DELL_M4_3),
1797 static unsigned int ref922x_pin_configs[10] = {
1798 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1799 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1800 0x40000100, 0x40000100,
1804 STAC 922X pin configs for
1811 static unsigned int dell_922x_d81_pin_configs[10] = {
1812 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1813 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1814 0x01813122, 0x400001f2,
1818 STAC 922X pin configs for
1822 static unsigned int dell_922x_d82_pin_configs[10] = {
1823 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1824 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1825 0x01813122, 0x400001f1,
1829 STAC 922X pin configs for
1832 static unsigned int dell_922x_m81_pin_configs[10] = {
1833 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1834 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1835 0x40C003f1, 0x405003f0,
1839 STAC 9221 A1 pin configs for
1840 102801D7 (Dell XPS M1210)
1842 static unsigned int dell_922x_m82_pin_configs[10] = {
1843 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1844 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1845 0x508003f3, 0x405003f4,
1848 static unsigned int d945gtp3_pin_configs[10] = {
1849 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1850 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1851 0x02a19120, 0x40000100,
1854 static unsigned int d945gtp5_pin_configs[10] = {
1855 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1856 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1857 0x02a19320, 0x40000100,
1860 static unsigned int intel_mac_v1_pin_configs[10] = {
1861 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1862 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1863 0x400000fc, 0x400000fb,
1866 static unsigned int intel_mac_v2_pin_configs[10] = {
1867 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1868 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1869 0x400000fc, 0x400000fb,
1872 static unsigned int intel_mac_v3_pin_configs[10] = {
1873 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1874 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1875 0x400000fc, 0x400000fb,
1878 static unsigned int intel_mac_v4_pin_configs[10] = {
1879 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1880 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1881 0x400000fc, 0x400000fb,
1884 static unsigned int intel_mac_v5_pin_configs[10] = {
1885 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1886 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1887 0x400000fc, 0x400000fb,
1890 static unsigned int ecs202_pin_configs[10] = {
1891 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1892 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1893 0x9037012e, 0x40e000f2,
1896 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1897 [STAC_D945_REF] = ref922x_pin_configs,
1898 [STAC_D945GTP3] = d945gtp3_pin_configs,
1899 [STAC_D945GTP5] = d945gtp5_pin_configs,
1900 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1901 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1902 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1903 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1904 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1905 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1906 /* for backward compatibility */
1907 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1908 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1909 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1910 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1911 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1912 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1913 [STAC_ECS_202] = ecs202_pin_configs,
1914 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1915 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1916 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1917 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1920 static const char *stac922x_models[STAC_922X_MODELS] = {
1921 [STAC_922X_AUTO] = "auto",
1922 [STAC_D945_REF] = "ref",
1923 [STAC_D945GTP5] = "5stack",
1924 [STAC_D945GTP3] = "3stack",
1925 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1926 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1927 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1928 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1929 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1930 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1931 /* for backward compatibility */
1932 [STAC_MACMINI] = "macmini",
1933 [STAC_MACBOOK] = "macbook",
1934 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1935 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1936 [STAC_IMAC_INTEL] = "imac-intel",
1937 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1938 [STAC_ECS_202] = "ecs202",
1939 [STAC_922X_DELL_D81] = "dell-d81",
1940 [STAC_922X_DELL_D82] = "dell-d82",
1941 [STAC_922X_DELL_M81] = "dell-m81",
1942 [STAC_922X_DELL_M82] = "dell-m82",
1945 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1946 /* SigmaTel reference board */
1947 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1948 "DFI LanParty", STAC_D945_REF),
1949 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1950 "DFI LanParty", STAC_D945_REF),
1951 /* Intel 945G based systems */
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1953 "Intel D945G", STAC_D945GTP3),
1954 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1955 "Intel D945G", STAC_D945GTP3),
1956 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1957 "Intel D945G", STAC_D945GTP3),
1958 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1959 "Intel D945G", STAC_D945GTP3),
1960 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1961 "Intel D945G", STAC_D945GTP3),
1962 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1963 "Intel D945G", STAC_D945GTP3),
1964 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1965 "Intel D945G", STAC_D945GTP3),
1966 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1967 "Intel D945G", STAC_D945GTP3),
1968 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1969 "Intel D945G", STAC_D945GTP3),
1970 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1971 "Intel D945G", STAC_D945GTP3),
1972 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1973 "Intel D945G", STAC_D945GTP3),
1974 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1975 "Intel D945G", STAC_D945GTP3),
1976 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1977 "Intel D945G", STAC_D945GTP3),
1978 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1979 "Intel D945G", STAC_D945GTP3),
1980 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1981 "Intel D945G", STAC_D945GTP3),
1982 /* Intel D945G 5-stack systems */
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1984 "Intel D945G", STAC_D945GTP5),
1985 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1986 "Intel D945G", STAC_D945GTP5),
1987 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1988 "Intel D945G", STAC_D945GTP5),
1989 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1990 "Intel D945G", STAC_D945GTP5),
1991 /* Intel 945P based systems */
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1993 "Intel D945P", STAC_D945GTP3),
1994 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1995 "Intel D945P", STAC_D945GTP3),
1996 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
1997 "Intel D945P", STAC_D945GTP3),
1998 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
1999 "Intel D945P", STAC_D945GTP3),
2000 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2001 "Intel D945P", STAC_D945GTP3),
2002 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2003 "Intel D945P", STAC_D945GTP5),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2006 "Intel D945", STAC_D945_REF),
2008 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2009 SND_PCI_QUIRK(0x8384, 0x7680,
2010 "Mac", STAC_INTEL_MAC_AUTO),
2012 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2013 "unknown Dell", STAC_922X_DELL_D81),
2014 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2015 "unknown Dell", STAC_922X_DELL_D81),
2016 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2017 "unknown Dell", STAC_922X_DELL_D81),
2018 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2019 "unknown Dell", STAC_922X_DELL_D82),
2020 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2021 "unknown Dell", STAC_922X_DELL_M81),
2022 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2023 "unknown Dell", STAC_922X_DELL_D82),
2024 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2025 "unknown Dell", STAC_922X_DELL_D81),
2026 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2027 "unknown Dell", STAC_922X_DELL_D81),
2028 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2029 "Dell XPS M1210", STAC_922X_DELL_M82),
2030 /* ECS/PC Chips boards */
2031 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2032 "ECS/PC chips", STAC_ECS_202),
2036 static unsigned int ref927x_pin_configs[14] = {
2037 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2038 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2039 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2040 0x01c42190, 0x40000100,
2043 static unsigned int d965_3st_pin_configs[14] = {
2044 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2045 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2046 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2047 0x40000100, 0x40000100
2050 static unsigned int d965_5st_pin_configs[14] = {
2051 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2052 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2053 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2054 0x40000100, 0x40000100
2057 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2058 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2059 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2060 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2061 0x40000100, 0x40000100
2064 static unsigned int dell_3st_pin_configs[14] = {
2065 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2066 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2067 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2068 0x40c003fc, 0x40000100
2071 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2072 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2073 [STAC_D965_REF] = ref927x_pin_configs,
2074 [STAC_D965_3ST] = d965_3st_pin_configs,
2075 [STAC_D965_5ST] = d965_5st_pin_configs,
2076 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2077 [STAC_DELL_3ST] = dell_3st_pin_configs,
2078 [STAC_DELL_BIOS] = NULL,
2081 static const char *stac927x_models[STAC_927X_MODELS] = {
2082 [STAC_927X_AUTO] = "auto",
2083 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2084 [STAC_D965_REF] = "ref",
2085 [STAC_D965_3ST] = "3stack",
2086 [STAC_D965_5ST] = "5stack",
2087 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2088 [STAC_DELL_3ST] = "dell-3stack",
2089 [STAC_DELL_BIOS] = "dell-bios",
2092 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2093 /* SigmaTel reference board */
2094 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2095 "DFI LanParty", STAC_D965_REF),
2096 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2097 "DFI LanParty", STAC_D965_REF),
2098 /* Intel 946 based systems */
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2100 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2101 /* 965 based 3 stack systems */
2102 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2103 "Intel D965", STAC_D965_3ST),
2104 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2105 "Intel D965", STAC_D965_3ST),
2106 /* Dell 3 stack systems */
2107 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_3ST),
2108 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2109 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2110 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2111 /* Dell 3 stack systems with verb table in BIOS */
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2115 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2120 /* 965 based 5 stack systems */
2121 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2122 "Intel D965", STAC_D965_5ST),
2123 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2124 "Intel D965", STAC_D965_5ST),
2128 static unsigned int ref9205_pin_configs[12] = {
2129 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2130 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2131 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2135 STAC 9205 pin configs for
2142 10280228 (Dell Vostro 1500)
2144 static unsigned int dell_9205_m42_pin_configs[12] = {
2145 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2146 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2147 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2151 STAC 9205 pin configs for
2155 102801FF (Dell Precision M4300)
2160 static unsigned int dell_9205_m43_pin_configs[12] = {
2161 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2162 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2163 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2166 static unsigned int dell_9205_m44_pin_configs[12] = {
2167 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2168 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2169 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2172 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2173 [STAC_9205_REF] = ref9205_pin_configs,
2174 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2175 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2176 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2177 [STAC_9205_EAPD] = NULL,
2180 static const char *stac9205_models[STAC_9205_MODELS] = {
2181 [STAC_9205_AUTO] = "auto",
2182 [STAC_9205_REF] = "ref",
2183 [STAC_9205_DELL_M42] = "dell-m42",
2184 [STAC_9205_DELL_M43] = "dell-m43",
2185 [STAC_9205_DELL_M44] = "dell-m44",
2186 [STAC_9205_EAPD] = "eapd",
2189 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2190 /* SigmaTel reference board */
2191 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2192 "DFI LanParty", STAC_9205_REF),
2193 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2194 "SigmaTel", STAC_9205_REF),
2195 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2196 "DFI LanParty", STAC_9205_REF),
2198 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2199 "unknown Dell", STAC_9205_DELL_M42),
2200 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2201 "unknown Dell", STAC_9205_DELL_M42),
2202 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2203 "Dell Precision", STAC_9205_DELL_M43),
2204 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2205 "Dell Precision", STAC_9205_DELL_M43),
2206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2207 "Dell Precision", STAC_9205_DELL_M43),
2208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2209 "unknown Dell", STAC_9205_DELL_M42),
2210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2211 "unknown Dell", STAC_9205_DELL_M42),
2212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2213 "Dell Precision", STAC_9205_DELL_M43),
2214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2215 "Dell Precision M4300", STAC_9205_DELL_M43),
2216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2217 "unknown Dell", STAC_9205_DELL_M42),
2218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2219 "Dell Precision", STAC_9205_DELL_M43),
2220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2221 "Dell Precision", STAC_9205_DELL_M43),
2222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2223 "Dell Precision", STAC_9205_DELL_M43),
2224 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2225 "Dell Inspiron", STAC_9205_DELL_M44),
2226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2227 "Dell Vostro 1500", STAC_9205_DELL_M42),
2229 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2230 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2234 static void stac92xx_set_config_regs(struct hda_codec *codec,
2235 unsigned int *pincfgs)
2238 struct sigmatel_spec *spec = codec->spec;
2243 for (i = 0; i < spec->num_pins; i++)
2244 if (spec->pin_nids[i] && pincfgs[i])
2245 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2250 * Analog playback callbacks
2252 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2253 struct hda_codec *codec,
2254 struct snd_pcm_substream *substream)
2256 struct sigmatel_spec *spec = codec->spec;
2257 if (spec->stream_delay)
2258 msleep(spec->stream_delay);
2259 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2263 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2264 struct hda_codec *codec,
2265 unsigned int stream_tag,
2266 unsigned int format,
2267 struct snd_pcm_substream *substream)
2269 struct sigmatel_spec *spec = codec->spec;
2270 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2273 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2274 struct hda_codec *codec,
2275 struct snd_pcm_substream *substream)
2277 struct sigmatel_spec *spec = codec->spec;
2278 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2282 * Digital playback callbacks
2284 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2285 struct hda_codec *codec,
2286 struct snd_pcm_substream *substream)
2288 struct sigmatel_spec *spec = codec->spec;
2289 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2292 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2293 struct hda_codec *codec,
2294 struct snd_pcm_substream *substream)
2296 struct sigmatel_spec *spec = codec->spec;
2297 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2300 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2301 struct hda_codec *codec,
2302 unsigned int stream_tag,
2303 unsigned int format,
2304 struct snd_pcm_substream *substream)
2306 struct sigmatel_spec *spec = codec->spec;
2307 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2308 stream_tag, format, substream);
2311 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2312 struct hda_codec *codec,
2313 struct snd_pcm_substream *substream)
2315 struct sigmatel_spec *spec = codec->spec;
2316 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2321 * Analog capture callbacks
2323 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2324 struct hda_codec *codec,
2325 unsigned int stream_tag,
2326 unsigned int format,
2327 struct snd_pcm_substream *substream)
2329 struct sigmatel_spec *spec = codec->spec;
2330 hda_nid_t nid = spec->adc_nids[substream->number];
2332 if (spec->powerdown_adcs) {
2334 snd_hda_codec_write(codec, nid, 0,
2335 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2337 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2341 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2342 struct hda_codec *codec,
2343 struct snd_pcm_substream *substream)
2345 struct sigmatel_spec *spec = codec->spec;
2346 hda_nid_t nid = spec->adc_nids[substream->number];
2348 snd_hda_codec_cleanup_stream(codec, nid);
2349 if (spec->powerdown_adcs)
2350 snd_hda_codec_write(codec, nid, 0,
2351 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2355 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2359 /* NID is set in stac92xx_build_pcms */
2361 .open = stac92xx_dig_playback_pcm_open,
2362 .close = stac92xx_dig_playback_pcm_close,
2363 .prepare = stac92xx_dig_playback_pcm_prepare,
2364 .cleanup = stac92xx_dig_playback_pcm_cleanup
2368 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2372 /* NID is set in stac92xx_build_pcms */
2375 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2379 .nid = 0x02, /* NID to query formats and rates */
2381 .open = stac92xx_playback_pcm_open,
2382 .prepare = stac92xx_playback_pcm_prepare,
2383 .cleanup = stac92xx_playback_pcm_cleanup
2387 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2391 .nid = 0x06, /* NID to query formats and rates */
2393 .open = stac92xx_playback_pcm_open,
2394 .prepare = stac92xx_playback_pcm_prepare,
2395 .cleanup = stac92xx_playback_pcm_cleanup
2399 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2402 /* NID + .substreams is set in stac92xx_build_pcms */
2404 .prepare = stac92xx_capture_pcm_prepare,
2405 .cleanup = stac92xx_capture_pcm_cleanup
2409 static int stac92xx_build_pcms(struct hda_codec *codec)
2411 struct sigmatel_spec *spec = codec->spec;
2412 struct hda_pcm *info = spec->pcm_rec;
2414 codec->num_pcms = 1;
2415 codec->pcm_info = info;
2417 info->name = "STAC92xx Analog";
2418 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2419 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2420 spec->multiout.dac_nids[0];
2421 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2422 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2423 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2425 if (spec->alt_switch) {
2428 info->name = "STAC92xx Analog Alt";
2429 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2432 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2435 info->name = "STAC92xx Digital";
2436 info->pcm_type = spec->autocfg.dig_out_type[0];
2437 if (spec->multiout.dig_out_nid) {
2438 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2439 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2441 if (spec->dig_in_nid) {
2442 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2443 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2450 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2453 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2454 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2455 if (pincap & AC_PINCAP_VREF_100)
2456 return AC_PINCTL_VREF_100;
2457 if (pincap & AC_PINCAP_VREF_80)
2458 return AC_PINCTL_VREF_80;
2459 if (pincap & AC_PINCAP_VREF_50)
2460 return AC_PINCTL_VREF_50;
2461 if (pincap & AC_PINCAP_VREF_GRD)
2462 return AC_PINCTL_VREF_GRD;
2466 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2469 snd_hda_codec_write_cache(codec, nid, 0,
2470 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2473 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2475 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2476 struct snd_ctl_elem_value *ucontrol)
2478 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2479 struct sigmatel_spec *spec = codec->spec;
2481 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2485 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2487 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2488 struct snd_ctl_elem_value *ucontrol)
2490 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2491 struct sigmatel_spec *spec = codec->spec;
2492 int nid = kcontrol->private_value;
2494 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2496 /* check to be sure that the ports are upto date with
2499 stac_issue_unsol_event(codec, nid);
2504 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2505 struct snd_ctl_elem_info *uinfo)
2508 static char *texts[] = {
2509 "Mic In", "Line In", "Line Out"
2512 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2513 struct sigmatel_spec *spec = codec->spec;
2514 hda_nid_t nid = kcontrol->private_value;
2516 if (nid == spec->mic_switch || nid == spec->line_switch)
2521 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2522 uinfo->value.enumerated.items = i;
2524 if (uinfo->value.enumerated.item >= i)
2525 uinfo->value.enumerated.item = i-1;
2526 strcpy(uinfo->value.enumerated.name,
2527 texts[uinfo->value.enumerated.item]);
2532 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2533 struct snd_ctl_elem_value *ucontrol)
2535 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2536 hda_nid_t nid = kcontrol->private_value;
2537 unsigned int vref = stac92xx_vref_get(codec, nid);
2539 if (vref == stac92xx_get_default_vref(codec, nid))
2540 ucontrol->value.enumerated.item[0] = 0;
2541 else if (vref == AC_PINCTL_VREF_GRD)
2542 ucontrol->value.enumerated.item[0] = 1;
2543 else if (vref == AC_PINCTL_VREF_HIZ)
2544 ucontrol->value.enumerated.item[0] = 2;
2549 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2550 struct snd_ctl_elem_value *ucontrol)
2552 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2553 unsigned int new_vref = 0;
2555 hda_nid_t nid = kcontrol->private_value;
2557 if (ucontrol->value.enumerated.item[0] == 0)
2558 new_vref = stac92xx_get_default_vref(codec, nid);
2559 else if (ucontrol->value.enumerated.item[0] == 1)
2560 new_vref = AC_PINCTL_VREF_GRD;
2561 else if (ucontrol->value.enumerated.item[0] == 2)
2562 new_vref = AC_PINCTL_VREF_HIZ;
2566 if (new_vref != stac92xx_vref_get(codec, nid)) {
2567 error = stac92xx_vref_set(codec, nid, new_vref);
2574 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2575 struct snd_ctl_elem_info *uinfo)
2577 static char *texts[2];
2578 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2579 struct sigmatel_spec *spec = codec->spec;
2581 if (kcontrol->private_value == spec->line_switch)
2582 texts[0] = "Line In";
2584 texts[0] = "Mic In";
2585 texts[1] = "Line Out";
2586 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2587 uinfo->value.enumerated.items = 2;
2590 if (uinfo->value.enumerated.item >= 2)
2591 uinfo->value.enumerated.item = 1;
2592 strcpy(uinfo->value.enumerated.name,
2593 texts[uinfo->value.enumerated.item]);
2598 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2600 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2601 struct sigmatel_spec *spec = codec->spec;
2602 hda_nid_t nid = kcontrol->private_value;
2603 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2605 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2609 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2611 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2612 struct sigmatel_spec *spec = codec->spec;
2613 hda_nid_t nid = kcontrol->private_value;
2614 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2615 unsigned short val = !!ucontrol->value.enumerated.item[0];
2617 spec->io_switch[io_idx] = val;
2620 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2622 unsigned int pinctl = AC_PINCTL_IN_EN;
2623 if (io_idx) /* set VREF for mic */
2624 pinctl |= stac92xx_get_default_vref(codec, nid);
2625 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2628 /* check the auto-mute again: we need to mute/unmute the speaker
2629 * appropriately according to the pin direction
2631 if (spec->hp_detect)
2632 stac_issue_unsol_event(codec, nid);
2637 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2639 static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
2640 struct snd_ctl_elem_value *ucontrol)
2642 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2643 struct sigmatel_spec *spec = codec->spec;
2645 ucontrol->value.integer.value[0] = spec->clfe_swap;
2649 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2650 struct snd_ctl_elem_value *ucontrol)
2652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2653 struct sigmatel_spec *spec = codec->spec;
2654 hda_nid_t nid = kcontrol->private_value & 0xff;
2655 unsigned int val = !!ucontrol->value.integer.value[0];
2657 if (spec->clfe_swap == val)
2660 spec->clfe_swap = val;
2662 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2663 spec->clfe_swap ? 0x4 : 0x0);
2668 #define STAC_CODEC_HP_SWITCH(xname) \
2669 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2672 .info = stac92xx_hp_switch_info, \
2673 .get = stac92xx_hp_switch_get, \
2674 .put = stac92xx_hp_switch_put, \
2677 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2678 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2681 .info = stac92xx_io_switch_info, \
2682 .get = stac92xx_io_switch_get, \
2683 .put = stac92xx_io_switch_put, \
2684 .private_value = xpval, \
2687 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2688 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2691 .info = stac92xx_clfe_switch_info, \
2692 .get = stac92xx_clfe_switch_get, \
2693 .put = stac92xx_clfe_switch_put, \
2694 .private_value = xpval, \
2698 STAC_CTL_WIDGET_VOL,
2699 STAC_CTL_WIDGET_MUTE,
2700 STAC_CTL_WIDGET_MONO_MUX,
2701 STAC_CTL_WIDGET_AMP_MUX,
2702 STAC_CTL_WIDGET_AMP_VOL,
2703 STAC_CTL_WIDGET_HP_SWITCH,
2704 STAC_CTL_WIDGET_IO_SWITCH,
2705 STAC_CTL_WIDGET_CLFE_SWITCH,
2706 STAC_CTL_WIDGET_DC_BIAS
2709 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2710 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2711 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2714 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2715 STAC_CODEC_HP_SWITCH(NULL),
2716 STAC_CODEC_IO_SWITCH(NULL, 0),
2717 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2718 DC_BIAS(NULL, 0, 0),
2721 /* add dynamic controls */
2722 static struct snd_kcontrol_new *
2723 stac_control_new(struct sigmatel_spec *spec,
2724 struct snd_kcontrol_new *ktemp,
2727 struct snd_kcontrol_new *knew;
2729 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2730 knew = snd_array_new(&spec->kctls);
2734 knew->name = kstrdup(name, GFP_KERNEL);
2737 memset(knew, 0, sizeof(*knew));
2738 spec->kctls.alloced--;
2744 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2745 struct snd_kcontrol_new *ktemp,
2746 int idx, const char *name,
2749 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
2753 knew->private_value = val;
2757 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2758 int type, int idx, const char *name,
2761 return stac92xx_add_control_temp(spec,
2762 &stac92xx_control_templates[type],
2767 /* add dynamic controls */
2768 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2769 const char *name, unsigned long val)
2771 return stac92xx_add_control_idx(spec, type, 0, name, val);
2774 static struct snd_kcontrol_new stac_input_src_temp = {
2775 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2776 .name = "Input Source",
2777 .info = stac92xx_mux_enum_info,
2778 .get = stac92xx_mux_enum_get,
2779 .put = stac92xx_mux_enum_put,
2782 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2783 hda_nid_t nid, int idx)
2785 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2787 struct sigmatel_spec *spec = codec->spec;
2790 if (!((get_defcfg_connect(def_conf)) & AC_JACK_PORT_FIXED)) {
2791 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2792 && nid == spec->line_switch)
2793 control = STAC_CTL_WIDGET_IO_SWITCH;
2794 else if (snd_hda_query_pin_caps(codec, nid)
2795 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2796 control = STAC_CTL_WIDGET_DC_BIAS;
2797 else if (nid == spec->mic_switch)
2798 control = STAC_CTL_WIDGET_IO_SWITCH;
2802 strcpy(name, auto_pin_cfg_labels[idx]);
2803 return stac92xx_add_control(codec->spec, control,
2804 strcat(name, " Jack Mode"), nid);
2810 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2812 struct snd_kcontrol_new *knew;
2813 struct hda_input_mux *imux = &spec->private_imux;
2816 return 0; /* no need for input source */
2817 if (!spec->num_adcs || imux->num_items <= 1)
2818 return 0; /* no need for input source control */
2819 knew = stac_control_new(spec, &stac_input_src_temp,
2820 stac_input_src_temp.name);
2823 knew->count = spec->num_adcs;
2827 /* check whether the line-input can be used as line-out */
2828 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2830 struct sigmatel_spec *spec = codec->spec;
2831 struct auto_pin_cfg *cfg = &spec->autocfg;
2833 unsigned int pincap;
2835 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2837 nid = cfg->input_pins[AUTO_PIN_LINE];
2838 pincap = snd_hda_query_pin_caps(codec, nid);
2839 if (pincap & AC_PINCAP_OUT)
2844 /* check whether the mic-input can be used as line-out */
2845 static hda_nid_t check_mic_out_switch(struct hda_codec *codec)
2847 struct sigmatel_spec *spec = codec->spec;
2848 struct auto_pin_cfg *cfg = &spec->autocfg;
2849 unsigned int def_conf, pincap;
2850 unsigned int mic_pin;
2852 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2854 mic_pin = AUTO_PIN_MIC;
2856 hda_nid_t nid = cfg->input_pins[mic_pin];
2857 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2858 /* some laptops have an internal analog microphone
2859 * which can't be used as a output */
2860 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) {
2861 pincap = snd_hda_query_pin_caps(codec, nid);
2862 if (pincap & AC_PINCAP_OUT)
2865 if (mic_pin == AUTO_PIN_MIC)
2866 mic_pin = AUTO_PIN_FRONT_MIC;
2873 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2877 for (i = 0; i < spec->multiout.num_dacs; i++) {
2878 if (spec->multiout.dac_nids[i] == nid)
2885 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2888 if (is_in_dac_nids(spec, nid))
2890 for (i = 0; i < spec->autocfg.hp_outs; i++)
2891 if (spec->hp_dacs[i] == nid)
2893 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2894 if (spec->speaker_dacs[i] == nid)
2899 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2901 struct sigmatel_spec *spec = codec->spec;
2903 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2904 unsigned int wcaps, wtype;
2906 conn_len = snd_hda_get_connections(codec, nid, conn,
2907 HDA_MAX_CONNECTIONS);
2908 for (j = 0; j < conn_len; j++) {
2909 wcaps = get_wcaps(codec, conn[j]);
2910 wtype = get_wcaps_type(wcaps);
2911 /* we check only analog outputs */
2912 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2914 /* if this route has a free DAC, assign it */
2915 if (!check_all_dac_nids(spec, conn[j])) {
2917 /* select this DAC in the pin's input mux */
2918 snd_hda_codec_write_cache(codec, nid, 0,
2919 AC_VERB_SET_CONNECT_SEL, j);
2924 /* if all DACs are already assigned, connect to the primary DAC */
2926 for (j = 0; j < conn_len; j++) {
2927 if (conn[j] == spec->multiout.dac_nids[0]) {
2928 snd_hda_codec_write_cache(codec, nid, 0,
2929 AC_VERB_SET_CONNECT_SEL, j);
2937 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2938 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2941 * Fill in the dac_nids table from the parsed pin configuration
2942 * This function only works when every pin in line_out_pins[]
2943 * contains atleast one DAC in its connection list. Some 92xx
2944 * codecs are not connected directly to a DAC, such as the 9200
2945 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2947 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2949 struct sigmatel_spec *spec = codec->spec;
2950 struct auto_pin_cfg *cfg = &spec->autocfg;
2954 for (i = 0; i < cfg->line_outs; i++) {
2955 nid = cfg->line_out_pins[i];
2956 dac = get_unassigned_dac(codec, nid);
2958 if (spec->multiout.num_dacs > 0) {
2959 /* we have already working output pins,
2960 * so let's drop the broken ones again
2962 cfg->line_outs = spec->multiout.num_dacs;
2965 /* error out, no available DAC found */
2967 "%s: No available DAC for pin 0x%x\n",
2971 add_spec_dacs(spec, dac);
2974 for (i = 0; i < cfg->hp_outs; i++) {
2975 nid = cfg->hp_pins[i];
2976 dac = get_unassigned_dac(codec, nid);
2978 if (!spec->multiout.hp_nid)
2979 spec->multiout.hp_nid = dac;
2981 add_spec_extra_dacs(spec, dac);
2983 spec->hp_dacs[i] = dac;
2986 for (i = 0; i < cfg->speaker_outs; i++) {
2987 nid = cfg->speaker_pins[i];
2988 dac = get_unassigned_dac(codec, nid);
2990 add_spec_extra_dacs(spec, dac);
2991 spec->speaker_dacs[i] = dac;
2994 /* add line-in as output */
2995 nid = check_line_out_switch(codec);
2997 dac = get_unassigned_dac(codec, nid);
2999 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3000 nid, cfg->line_outs);
3001 cfg->line_out_pins[cfg->line_outs] = nid;
3003 spec->line_switch = nid;
3004 add_spec_dacs(spec, dac);
3007 /* add mic as output */
3008 nid = check_mic_out_switch(codec);
3010 dac = get_unassigned_dac(codec, nid);
3012 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3013 nid, cfg->line_outs);
3014 cfg->line_out_pins[cfg->line_outs] = nid;
3016 spec->mic_switch = nid;
3017 add_spec_dacs(spec, dac);
3021 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3022 spec->multiout.num_dacs,
3023 spec->multiout.dac_nids[0],
3024 spec->multiout.dac_nids[1],
3025 spec->multiout.dac_nids[2],
3026 spec->multiout.dac_nids[3],
3027 spec->multiout.dac_nids[4]);
3032 /* create volume control/switch for the given prefx type */
3033 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3034 int idx, hda_nid_t nid, int chs)
3036 struct sigmatel_spec *spec = codec->spec;
3040 if (!spec->check_volume_offset) {
3041 unsigned int caps, step, nums, db_scale;
3042 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3043 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3044 AC_AMPCAP_STEP_SIZE_SHIFT;
3045 step = (step + 1) * 25; /* in .01dB unit */
3046 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3047 AC_AMPCAP_NUM_STEPS_SHIFT;
3048 db_scale = nums * step;
3049 /* if dB scale is over -64dB, and finer enough,
3050 * let's reduce it to half
3052 if (db_scale > 6400 && nums >= 0x1f)
3053 spec->volume_offset = nums / 2;
3054 spec->check_volume_offset = 1;
3057 sprintf(name, "%s Playback Volume", pfx);
3058 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3059 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3060 spec->volume_offset));
3063 sprintf(name, "%s Playback Switch", pfx);
3064 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3065 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3071 #define create_controls(codec, pfx, nid, chs) \
3072 create_controls_idx(codec, pfx, 0, nid, chs)
3074 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3076 if (spec->multiout.num_dacs > 4) {
3077 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3080 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3081 spec->multiout.num_dacs++;
3086 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3089 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3090 if (!spec->multiout.extra_out_nid[i]) {
3091 spec->multiout.extra_out_nid[i] = nid;
3095 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3099 /* Create output controls
3100 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3102 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3103 const hda_nid_t *pins,
3104 const hda_nid_t *dac_nids,
3107 struct sigmatel_spec *spec = codec->spec;
3108 static const char *chname[4] = {
3109 "Front", "Surround", NULL /*CLFE*/, "Side"
3113 unsigned int wid_caps;
3115 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3116 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3117 wid_caps = get_wcaps(codec, pins[i]);
3118 if (wid_caps & AC_WCAP_UNSOL_CAP)
3119 spec->hp_detect = 1;
3124 if (type != AUTO_PIN_HP_OUT && i == 2) {
3126 err = create_controls(codec, "Center", nid, 1);
3129 err = create_controls(codec, "LFE", nid, 2);
3133 wid_caps = get_wcaps(codec, nid);
3135 if (wid_caps & AC_WCAP_LR_SWAP) {
3136 err = stac92xx_add_control(spec,
3137 STAC_CTL_WIDGET_CLFE_SWITCH,
3138 "Swap Center/LFE Playback Switch", nid);
3148 case AUTO_PIN_HP_OUT:
3152 case AUTO_PIN_SPEAKER_OUT:
3161 err = create_controls_idx(codec, name, idx, nid, 3);
3169 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3170 unsigned long sw, int idx)
3173 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3174 "Capture Volume", vol);
3177 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3178 "Capture Switch", sw);
3184 /* add playback controls from the parsed DAC table */
3185 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3186 const struct auto_pin_cfg *cfg)
3188 struct sigmatel_spec *spec = codec->spec;
3193 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3194 spec->multiout.dac_nids,
3195 cfg->line_out_type);
3199 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3200 err = stac92xx_add_control(spec,
3201 STAC_CTL_WIDGET_HP_SWITCH,
3202 "Headphone as Line Out Switch",
3203 cfg->hp_pins[cfg->hp_outs - 1]);
3208 for (idx = AUTO_PIN_MIC; idx <= AUTO_PIN_FRONT_LINE; idx++) {
3209 nid = cfg->input_pins[idx];
3211 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3220 /* add playback controls for Speaker and HP outputs */
3221 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3222 struct auto_pin_cfg *cfg)
3224 struct sigmatel_spec *spec = codec->spec;
3227 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3228 spec->hp_dacs, AUTO_PIN_HP_OUT);
3232 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3233 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3240 /* labels for mono mux outputs */
3241 static const char *stac92xx_mono_labels[4] = {
3242 "DAC0", "DAC1", "Mixer", "DAC2"
3245 /* create mono mux for mono out on capable codecs */
3246 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3248 struct sigmatel_spec *spec = codec->spec;
3249 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3251 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3253 num_cons = snd_hda_get_connections(codec,
3256 HDA_MAX_NUM_INPUTS);
3257 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3260 for (i = 0; i < num_cons; i++) {
3261 mono_mux->items[mono_mux->num_items].label =
3262 stac92xx_mono_labels[i];
3263 mono_mux->items[mono_mux->num_items].index = i;
3264 mono_mux->num_items++;
3267 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3268 "Mono Mux", spec->mono_nid);
3271 /* labels for amp mux outputs */
3272 static const char *stac92xx_amp_labels[3] = {
3273 "Front Microphone", "Microphone", "Line In",
3276 /* create amp out controls mux on capable codecs */
3277 static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3279 struct sigmatel_spec *spec = codec->spec;
3280 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3283 for (i = 0; i < spec->num_amps; i++) {
3284 amp_mux->items[amp_mux->num_items].label =
3285 stac92xx_amp_labels[i];
3286 amp_mux->items[amp_mux->num_items].index = i;
3287 amp_mux->num_items++;
3290 if (spec->num_amps > 1) {
3291 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3292 "Amp Selector Capture Switch", 0);
3296 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3297 "Amp Capture Volume",
3298 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3302 /* create PC beep volume controls */
3303 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3306 struct sigmatel_spec *spec = codec->spec;
3307 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3310 /* check for mute support for the the amp */
3311 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3312 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3313 "PC Beep Playback Switch",
3314 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3319 /* check to see if there is volume support for the amp */
3320 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3321 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3322 "PC Beep Playback Volume",
3323 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3330 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3331 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3333 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3334 struct snd_ctl_elem_value *ucontrol)
3336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3337 ucontrol->value.integer.value[0] = codec->beep->enabled;
3341 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3342 struct snd_ctl_elem_value *ucontrol)
3344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3345 int enabled = !!ucontrol->value.integer.value[0];
3346 if (codec->beep->enabled != enabled) {
3347 codec->beep->enabled = enabled;
3353 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3354 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3355 .info = stac92xx_dig_beep_switch_info,
3356 .get = stac92xx_dig_beep_switch_get,
3357 .put = stac92xx_dig_beep_switch_put,
3360 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3362 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3363 0, "PC Beep Playback Switch", 0);
3367 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3369 struct sigmatel_spec *spec = codec->spec;
3372 for (i = 0; i < spec->num_muxes; i++) {
3377 nid = spec->mux_nids[i];
3378 wcaps = get_wcaps(codec, nid);
3379 if (!(wcaps & AC_WCAP_OUT_AMP))
3382 /* check whether already the same control was created as
3383 * normal Capture Volume.
3385 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3386 for (j = 0; j < spec->num_caps; j++) {
3387 if (spec->capvols[j] == val)
3390 if (j < spec->num_caps)
3393 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3394 "Mux Capture Volume", val);
3401 static const char *stac92xx_spdif_labels[3] = {
3402 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3405 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3407 struct sigmatel_spec *spec = codec->spec;
3408 struct hda_input_mux *spdif_mux = &spec->private_smux;
3409 const char **labels = spec->spdif_labels;
3411 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3413 num_cons = snd_hda_get_connections(codec,
3416 HDA_MAX_NUM_INPUTS);
3421 labels = stac92xx_spdif_labels;
3423 for (i = 0; i < num_cons; i++) {
3424 spdif_mux->items[spdif_mux->num_items].label = labels[i];
3425 spdif_mux->items[spdif_mux->num_items].index = i;
3426 spdif_mux->num_items++;
3432 /* labels for dmic mux inputs */
3433 static const char *stac92xx_dmic_labels[5] = {
3434 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3435 "Digital Mic 3", "Digital Mic 4"
3438 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3441 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3444 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3445 for (i = 0; i < nums; i++)
3451 /* create a volume assigned to the given pin (only if supported) */
3452 /* return 1 if the volume control is created */
3453 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3454 const char *label, int direction)
3456 unsigned int caps, nums;
3460 if (direction == HDA_OUTPUT)
3461 caps = AC_WCAP_OUT_AMP;
3463 caps = AC_WCAP_IN_AMP;
3464 if (!(get_wcaps(codec, nid) & caps))
3466 caps = query_amp_caps(codec, nid, direction);
3467 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3470 snprintf(name, sizeof(name), "%s Capture Volume", label);
3471 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3472 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3478 /* create playback/capture controls for input pins on dmic capable codecs */
3479 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3480 const struct auto_pin_cfg *cfg)
3482 struct sigmatel_spec *spec = codec->spec;
3483 struct hda_input_mux *imux = &spec->private_imux;
3484 struct hda_input_mux *dimux = &spec->private_dimux;
3485 int err, i, active_mics;
3486 unsigned int def_conf;
3488 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3489 dimux->items[dimux->num_items].index = 0;
3493 for (i = 0; i < spec->num_dmics; i++) {
3494 /* check the validity: sometimes it's a dead vendor-spec node */
3495 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3498 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3499 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3503 for (i = 0; i < spec->num_dmics; i++) {
3508 nid = spec->dmic_nids[i];
3509 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3511 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3512 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3515 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3519 if (active_mics == 1)
3520 label = "Digital Mic";
3522 label = stac92xx_dmic_labels[dimux->num_items];
3524 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
3528 err = create_elem_capture_vol(codec, nid, label,
3534 dimux->items[dimux->num_items].label = label;
3535 dimux->items[dimux->num_items].index = index;
3537 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3538 imux->items[imux->num_items].label = label;
3539 imux->items[imux->num_items].index = index;
3547 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3548 hda_nid_t *fixed, hda_nid_t *ext)
3554 cfg = snd_hda_codec_get_pincfg(codec, nid);
3555 switch (get_defcfg_connect(cfg)) {
3556 case AC_JACK_PORT_FIXED:
3558 return 1; /* already occupied */
3561 case AC_JACK_PORT_COMPLEX:
3563 return 1; /* already occupied */
3570 static int set_mic_route(struct hda_codec *codec,
3571 struct sigmatel_mic_route *mic,
3574 struct sigmatel_spec *spec = codec->spec;
3575 struct auto_pin_cfg *cfg = &spec->autocfg;
3579 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3580 if (pin == cfg->input_pins[i])
3582 if (i <= AUTO_PIN_FRONT_MIC) {
3585 i = get_connection_index(codec, spec->mux_nids[0], pin);
3589 } else if (spec->dmux_nids) {
3592 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3600 /* return non-zero if the device is for automatic mic switch */
3601 static int stac_check_auto_mic(struct hda_codec *codec)
3603 struct sigmatel_spec *spec = codec->spec;
3604 struct auto_pin_cfg *cfg = &spec->autocfg;
3605 hda_nid_t fixed, ext;
3608 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3609 if (cfg->input_pins[i])
3610 return 0; /* must be exclusively mics */
3613 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3614 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3616 for (i = 0; i < spec->num_dmics; i++)
3617 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3621 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3622 return 0; /* no unsol support */
3623 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3624 set_mic_route(codec, &spec->int_mic, fixed))
3625 return 0; /* something is wrong */
3629 /* create playback/capture controls for input pins */
3630 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3632 struct sigmatel_spec *spec = codec->spec;
3633 struct hda_input_mux *imux = &spec->private_imux;
3636 for (i = 0; i < AUTO_PIN_LAST; i++) {
3637 hda_nid_t nid = cfg->input_pins[i];
3643 for (j = 0; j < spec->num_muxes; j++) {
3644 index = get_connection_index(codec, spec->mux_nids[j],
3652 err = create_elem_capture_vol(codec, nid,
3653 auto_pin_cfg_labels[i],
3658 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3659 imux->items[imux->num_items].index = index;
3662 spec->num_analog_muxes = imux->num_items;
3664 if (imux->num_items) {
3666 * Set the current input for the muxes.
3667 * The STAC9221 has two input muxes with identical source
3668 * NID lists. Hopefully this won't get confused.
3670 for (i = 0; i < spec->num_muxes; i++) {
3671 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3672 AC_VERB_SET_CONNECT_SEL,
3673 imux->items[0].index);
3680 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3682 struct sigmatel_spec *spec = codec->spec;
3685 for (i = 0; i < spec->autocfg.line_outs; i++) {
3686 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3687 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3691 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3693 struct sigmatel_spec *spec = codec->spec;
3696 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3698 pin = spec->autocfg.hp_pins[i];
3699 if (pin) /* connect to front */
3700 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3702 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3704 pin = spec->autocfg.speaker_pins[i];
3705 if (pin) /* connect to front */
3706 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3710 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3712 struct sigmatel_spec *spec = codec->spec;
3716 if ((err = snd_hda_parse_pin_def_config(codec,
3718 spec->dmic_nids)) < 0)
3720 if (! spec->autocfg.line_outs)
3721 return 0; /* can't find valid pin config */
3723 /* If we have no real line-out pin and multiple hp-outs, HPs should
3724 * be set up as multi-channel outputs.
3726 if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT &&
3727 spec->autocfg.hp_outs > 1) {
3728 /* Copy hp_outs to line_outs, backup line_outs in
3729 * speaker_outs so that the following routines can handle
3730 * HP pins as primary outputs.
3732 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3733 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3734 sizeof(spec->autocfg.line_out_pins));
3735 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3736 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3737 sizeof(spec->autocfg.hp_pins));
3738 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3739 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3740 spec->autocfg.hp_outs = 0;
3743 if (spec->autocfg.mono_out_pin) {
3744 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3745 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3746 u32 caps = query_amp_caps(codec,
3747 spec->autocfg.mono_out_pin, dir);
3748 hda_nid_t conn_list[1];
3750 /* get the mixer node and then the mono mux if it exists */
3751 if (snd_hda_get_connections(codec,
3752 spec->autocfg.mono_out_pin, conn_list, 1) &&
3753 snd_hda_get_connections(codec, conn_list[0],
3754 conn_list, 1) > 0) {
3756 int wcaps = get_wcaps(codec, conn_list[0]);
3757 int wid_type = get_wcaps_type(wcaps);
3758 /* LR swap check, some stac925x have a mux that
3759 * changes the DACs output path instead of the
3762 if (wid_type == AC_WID_AUD_SEL &&
3763 !(wcaps & AC_WCAP_LR_SWAP))
3764 spec->mono_nid = conn_list[0];
3767 hda_nid_t nid = spec->autocfg.mono_out_pin;
3769 /* most mono outs have a least a mute/unmute switch */
3770 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3771 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3772 "Mono Playback Switch",
3773 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3776 /* check for volume support for the amp */
3777 if ((caps & AC_AMPCAP_NUM_STEPS)
3778 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3779 err = stac92xx_add_control(spec,
3780 STAC_CTL_WIDGET_VOL,
3781 "Mono Playback Volume",
3782 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3788 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3792 if (!spec->multiout.num_dacs) {
3793 err = stac92xx_auto_fill_dac_nids(codec);
3796 err = stac92xx_auto_create_multi_out_ctls(codec,
3802 /* setup analog beep controls */
3803 if (spec->anabeep_nid > 0) {
3804 err = stac92xx_auto_create_beep_ctls(codec,
3810 /* setup digital beep controls and input device */
3811 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3812 if (spec->digbeep_nid > 0) {
3813 hda_nid_t nid = spec->digbeep_nid;
3816 err = stac92xx_auto_create_beep_ctls(codec, nid);
3819 err = snd_hda_attach_beep_device(codec, nid);
3822 /* IDT/STAC codecs have linear beep tone parameter */
3823 codec->beep->linear_tone = 1;
3824 /* if no beep switch is available, make its own one */
3825 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3827 !((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT)) {
3828 err = stac92xx_beep_switch_ctl(codec);
3835 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3839 /* All output parsing done, now restore the swapped hp pins */
3841 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3842 sizeof(spec->autocfg.hp_pins));
3843 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3844 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3845 spec->autocfg.line_outs = 0;
3848 if (stac_check_auto_mic(codec)) {
3850 /* only one capture for auto-mic */
3853 spec->num_muxes = 1;
3856 for (i = 0; i < spec->num_caps; i++) {
3857 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3858 spec->capsws[i], i);
3863 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3867 if (spec->mono_nid > 0) {
3868 err = stac92xx_auto_create_mono_output_ctls(codec);
3872 if (spec->num_amps > 0) {
3873 err = stac92xx_auto_create_amp_output_ctls(codec);
3877 if (spec->num_dmics > 0 && !spec->dinput_mux)
3878 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3879 &spec->autocfg)) < 0)
3881 if (spec->num_muxes > 0) {
3882 err = stac92xx_auto_create_mux_input_ctls(codec);
3886 if (spec->num_smuxes > 0) {
3887 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3892 err = stac92xx_add_input_source(spec);
3896 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3897 if (spec->multiout.max_channels > 2)
3898 spec->surr_switch = 1;
3900 if (spec->autocfg.dig_outs)
3901 spec->multiout.dig_out_nid = dig_out;
3902 if (dig_in && spec->autocfg.dig_in_pin)
3903 spec->dig_in_nid = dig_in;
3905 if (spec->kctls.list)
3906 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3908 spec->input_mux = &spec->private_imux;
3909 if (!spec->dinput_mux)
3910 spec->dinput_mux = &spec->private_dimux;
3911 spec->sinput_mux = &spec->private_smux;
3912 spec->mono_mux = &spec->private_mono_mux;
3913 spec->amp_mux = &spec->private_amp_mux;
3917 /* add playback controls for HP output */
3918 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3919 struct auto_pin_cfg *cfg)
3921 struct sigmatel_spec *spec = codec->spec;
3922 hda_nid_t pin = cfg->hp_pins[0];
3923 unsigned int wid_caps;
3928 wid_caps = get_wcaps(codec, pin);
3929 if (wid_caps & AC_WCAP_UNSOL_CAP)
3930 spec->hp_detect = 1;
3935 /* add playback controls for LFE output */
3936 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3937 struct auto_pin_cfg *cfg)
3939 struct sigmatel_spec *spec = codec->spec;
3941 hda_nid_t lfe_pin = 0x0;
3945 * search speaker outs and line outs for a mono speaker pin
3946 * with an amp. If one is found, add LFE controls
3949 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3950 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3951 unsigned int wcaps = get_wcaps(codec, pin);
3952 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3953 if (wcaps == AC_WCAP_OUT_AMP)
3954 /* found a mono speaker with an amp, must be lfe */
3958 /* if speaker_outs is 0, then speakers may be in line_outs */
3959 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3960 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3961 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3962 unsigned int defcfg;
3963 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3964 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3965 unsigned int wcaps = get_wcaps(codec, pin);
3966 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3967 if (wcaps == AC_WCAP_OUT_AMP)
3968 /* found a mono speaker with an amp,
3976 err = create_controls(codec, "LFE", lfe_pin, 1);
3984 static int stac9200_parse_auto_config(struct hda_codec *codec)
3986 struct sigmatel_spec *spec = codec->spec;
3989 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3992 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3995 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3998 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
4001 if (spec->num_muxes > 0) {
4002 err = stac92xx_auto_create_mux_input_ctls(codec);
4007 err = stac92xx_add_input_source(spec);
4011 if (spec->autocfg.dig_outs)
4012 spec->multiout.dig_out_nid = 0x05;
4013 if (spec->autocfg.dig_in_pin)
4014 spec->dig_in_nid = 0x04;
4016 if (spec->kctls.list)
4017 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4019 spec->input_mux = &spec->private_imux;
4020 spec->dinput_mux = &spec->private_dimux;
4026 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4027 * funky external mute control using GPIO pins.
4030 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4031 unsigned int dir_mask, unsigned int data)
4033 unsigned int gpiostate, gpiomask, gpiodir;
4035 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4036 AC_VERB_GET_GPIO_DATA, 0);
4037 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4039 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4040 AC_VERB_GET_GPIO_MASK, 0);
4043 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4044 AC_VERB_GET_GPIO_DIRECTION, 0);
4045 gpiodir |= dir_mask;
4047 /* Configure GPIOx as CMOS */
4048 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4050 snd_hda_codec_write(codec, codec->afg, 0,
4051 AC_VERB_SET_GPIO_MASK, gpiomask);
4052 snd_hda_codec_read(codec, codec->afg, 0,
4053 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4057 snd_hda_codec_read(codec, codec->afg, 0,
4058 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4061 #ifdef CONFIG_SND_HDA_INPUT_JACK
4062 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4064 struct sigmatel_jack *jacks = jack->private_data;
4070 static int stac92xx_add_jack(struct hda_codec *codec,
4071 hda_nid_t nid, int type)
4073 #ifdef CONFIG_SND_HDA_INPUT_JACK
4074 struct sigmatel_spec *spec = codec->spec;
4075 struct sigmatel_jack *jack;
4076 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4077 int connectivity = get_defcfg_connect(def_conf);
4081 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4084 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4085 jack = snd_array_new(&spec->jacks);
4091 snprintf(name, sizeof(name), "%s at %s %s Jack",
4092 snd_hda_get_jack_type(def_conf),
4093 snd_hda_get_jack_connectivity(def_conf),
4094 snd_hda_get_jack_location(def_conf));
4096 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4101 jack->jack->private_data = jack;
4102 jack->jack->private_free = stac92xx_free_jack_priv;
4107 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4108 unsigned char type, int data)
4110 struct sigmatel_event *event;
4112 snd_array_init(&spec->events, sizeof(*event), 32);
4113 event = snd_array_new(&spec->events);
4118 event->tag = spec->events.used;
4124 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4127 struct sigmatel_spec *spec = codec->spec;
4128 struct sigmatel_event *event = spec->events.list;
4131 for (i = 0; i < spec->events.used; i++, event++) {
4132 if (event->nid == nid)
4138 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4141 struct sigmatel_spec *spec = codec->spec;
4142 struct sigmatel_event *event = spec->events.list;
4145 for (i = 0; i < spec->events.used; i++, event++) {
4146 if (event->tag == tag)
4152 /* check if given nid is a valid pin and no other events are assigned
4153 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4154 * Otherwise, returns zero.
4156 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4159 struct sigmatel_event *event;
4162 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4164 event = stac_get_event(codec, nid);
4166 if (event->type != type)
4170 tag = stac_add_event(codec->spec, nid, type, 0);
4174 snd_hda_codec_write_cache(codec, nid, 0,
4175 AC_VERB_SET_UNSOLICITED_ENABLE,
4180 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4183 for (i = 0; i < cfg->hp_outs; i++)
4184 if (cfg->hp_pins[i] == nid)
4185 return 1; /* nid is a HP-Out */
4187 return 0; /* nid is not a HP-Out */
4190 static void stac92xx_power_down(struct hda_codec *codec)
4192 struct sigmatel_spec *spec = codec->spec;
4194 /* power down inactive DACs */
4196 for (dac = spec->dac_list; *dac; dac++)
4197 if (!check_all_dac_nids(spec, *dac))
4198 snd_hda_codec_write(codec, *dac, 0,
4199 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4202 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4205 /* override some hints from the hwdep entry */
4206 static void stac_store_hints(struct hda_codec *codec)
4208 struct sigmatel_spec *spec = codec->spec;
4212 val = snd_hda_get_bool_hint(codec, "hp_detect");
4214 spec->hp_detect = val;
4215 p = snd_hda_get_hint(codec, "gpio_mask");
4217 spec->gpio_mask = simple_strtoul(p, NULL, 0);
4218 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4221 p = snd_hda_get_hint(codec, "gpio_dir");
4223 spec->gpio_dir = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4224 p = snd_hda_get_hint(codec, "gpio_data");
4226 spec->gpio_data = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4227 p = snd_hda_get_hint(codec, "eapd_mask");
4229 spec->eapd_mask = simple_strtoul(p, NULL, 0) & spec->gpio_mask;
4230 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4232 spec->eapd_switch = val;
4235 static int stac92xx_init(struct hda_codec *codec)
4237 struct sigmatel_spec *spec = codec->spec;
4238 struct auto_pin_cfg *cfg = &spec->autocfg;
4242 snd_hda_sequence_write(codec, spec->init);
4244 /* power down adcs initially */
4245 if (spec->powerdown_adcs)
4246 for (i = 0; i < spec->num_adcs; i++)
4247 snd_hda_codec_write(codec,
4248 spec->adc_nids[i], 0,
4249 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4251 /* override some hints */
4252 stac_store_hints(codec);
4255 gpio = spec->gpio_data;
4256 /* turn on EAPD statically when spec->eapd_switch isn't set.
4257 * otherwise, unsol event will turn it on/off dynamically
4259 if (!spec->eapd_switch)
4260 gpio |= spec->eapd_mask;
4261 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4264 if (spec->hp_detect) {
4265 /* Enable unsolicited responses on the HP widget */
4266 for (i = 0; i < cfg->hp_outs; i++) {
4267 hda_nid_t nid = cfg->hp_pins[i];
4268 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4270 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4271 cfg->speaker_outs > 0) {
4272 /* enable pin-detect for line-outs as well */
4273 for (i = 0; i < cfg->line_outs; i++) {
4274 hda_nid_t nid = cfg->line_out_pins[i];
4275 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4279 /* force to enable the first line-out; the others are set up
4282 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4284 /* fake event to set up pins */
4285 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4287 stac92xx_auto_init_multi_out(codec);
4288 stac92xx_auto_init_hp_out(codec);
4289 for (i = 0; i < cfg->hp_outs; i++)
4290 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4292 if (spec->auto_mic) {
4293 /* initialize connection to analog input */
4294 if (spec->dmux_nids)
4295 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4296 AC_VERB_SET_CONNECT_SEL, 0);
4297 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4298 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4300 for (i = 0; i < AUTO_PIN_LAST; i++) {
4301 hda_nid_t nid = cfg->input_pins[i];
4303 unsigned int pinctl, conf;
4304 if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) {
4305 /* for mic pins, force to initialize */
4306 pinctl = stac92xx_get_default_vref(codec, nid);
4307 pinctl |= AC_PINCTL_IN_EN;
4308 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4310 pinctl = snd_hda_codec_read(codec, nid, 0,
4311 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4312 /* if PINCTL already set then skip */
4313 /* Also, if both INPUT and OUTPUT are set,
4314 * it must be a BIOS bug; need to override, too
4316 if (!(pinctl & AC_PINCTL_IN_EN) ||
4317 (pinctl & AC_PINCTL_OUT_EN)) {
4318 pinctl &= ~AC_PINCTL_OUT_EN;
4319 pinctl |= AC_PINCTL_IN_EN;
4320 stac92xx_auto_set_pinctl(codec, nid,
4324 conf = snd_hda_codec_get_pincfg(codec, nid);
4325 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4326 if (enable_pin_detect(codec, nid,
4328 stac_issue_unsol_event(codec, nid);
4332 for (i = 0; i < spec->num_dmics; i++)
4333 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4335 if (cfg->dig_out_pins[0])
4336 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4338 if (cfg->dig_in_pin)
4339 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4341 for (i = 0; i < spec->num_pwrs; i++) {
4342 hda_nid_t nid = spec->pwr_nids[i];
4343 int pinctl, def_conf;
4345 /* power on when no jack detection is available */
4346 if (!spec->hp_detect) {
4347 stac_toggle_power_map(codec, nid, 1);
4351 if (is_nid_hp_pin(cfg, nid))
4352 continue; /* already has an unsol event */
4354 pinctl = snd_hda_codec_read(codec, nid, 0,
4355 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4356 /* outputs are only ports capable of power management
4357 * any attempts on powering down a input port cause the
4358 * referenced VREF to act quirky.
4360 if (pinctl & AC_PINCTL_IN_EN) {
4361 stac_toggle_power_map(codec, nid, 1);
4364 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4365 def_conf = get_defcfg_connect(def_conf);
4366 /* skip any ports that don't have jacks since presence
4367 * detection is useless */
4368 if (def_conf != AC_JACK_PORT_COMPLEX) {
4369 if (def_conf != AC_JACK_PORT_NONE)
4370 stac_toggle_power_map(codec, nid, 1);
4373 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4374 stac_issue_unsol_event(codec, nid);
4377 stac92xx_power_down(codec);
4381 static void stac92xx_free_jacks(struct hda_codec *codec)
4383 #ifdef CONFIG_SND_HDA_INPUT_JACK
4384 /* free jack instances manually when clearing/reconfiguring */
4385 struct sigmatel_spec *spec = codec->spec;
4386 if (!codec->bus->shutdown && spec->jacks.list) {
4387 struct sigmatel_jack *jacks = spec->jacks.list;
4389 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4391 snd_device_free(codec->bus->card, jacks->jack);
4394 snd_array_free(&spec->jacks);
4398 static void stac92xx_free_kctls(struct hda_codec *codec)
4400 struct sigmatel_spec *spec = codec->spec;
4402 if (spec->kctls.list) {
4403 struct snd_kcontrol_new *kctl = spec->kctls.list;
4405 for (i = 0; i < spec->kctls.used; i++)
4406 kfree(kctl[i].name);
4408 snd_array_free(&spec->kctls);
4411 static void stac92xx_free(struct hda_codec *codec)
4413 struct sigmatel_spec *spec = codec->spec;
4418 stac92xx_free_jacks(codec);
4419 snd_array_free(&spec->events);
4422 snd_hda_detach_beep_device(codec);
4425 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4428 unsigned int old_ctl, pin_ctl;
4430 pin_ctl = snd_hda_codec_read(codec, nid,
4431 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4433 if (pin_ctl & AC_PINCTL_IN_EN) {
4435 * we need to check the current set-up direction of
4436 * shared input pins since they can be switched via
4437 * "xxx as Output" mixer switch
4439 struct sigmatel_spec *spec = codec->spec;
4440 if (nid == spec->line_switch || nid == spec->mic_switch)
4445 /* if setting pin direction bits, clear the current
4446 direction bits first */
4447 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4448 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4451 if (old_ctl != pin_ctl)
4452 snd_hda_codec_write_cache(codec, nid, 0,
4453 AC_VERB_SET_PIN_WIDGET_CONTROL,
4457 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4460 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4461 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4463 snd_hda_codec_write_cache(codec, nid, 0,
4464 AC_VERB_SET_PIN_WIDGET_CONTROL,
4468 static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4472 if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
4478 static void stac92xx_line_out_detect(struct hda_codec *codec,
4481 struct sigmatel_spec *spec = codec->spec;
4482 struct auto_pin_cfg *cfg = &spec->autocfg;
4485 for (i = 0; i < cfg->line_outs; i++) {
4488 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4490 unsigned int pinctl;
4491 pinctl = snd_hda_codec_read(codec,
4492 cfg->line_out_pins[i], 0,
4493 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4494 if (pinctl & AC_PINCTL_IN_EN)
4495 presence = 0; /* mic- or line-input */
4500 /* disable speakers */
4501 for (i = 0; i < cfg->speaker_outs; i++)
4502 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4504 if (spec->eapd_mask && spec->eapd_switch)
4505 stac_gpio_set(codec, spec->gpio_mask,
4506 spec->gpio_dir, spec->gpio_data &
4509 /* enable speakers */
4510 for (i = 0; i < cfg->speaker_outs; i++)
4511 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4513 if (spec->eapd_mask && spec->eapd_switch)
4514 stac_gpio_set(codec, spec->gpio_mask,
4515 spec->gpio_dir, spec->gpio_data |
4520 /* return non-zero if the hp-pin of the given array index isn't
4521 * a jack-detection target
4523 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4525 struct auto_pin_cfg *cfg = &spec->autocfg;
4527 /* ignore sensing of shared line and mic jacks */
4528 if (cfg->hp_pins[i] == spec->line_switch)
4530 if (cfg->hp_pins[i] == spec->mic_switch)
4532 /* ignore if the pin is set as line-out */
4533 if (cfg->hp_pins[i] == spec->hp_switch)
4538 static void stac92xx_hp_detect(struct hda_codec *codec)
4540 struct sigmatel_spec *spec = codec->spec;
4541 struct auto_pin_cfg *cfg = &spec->autocfg;
4545 if (spec->gpio_mute)
4546 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4547 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4549 for (i = 0; i < cfg->hp_outs; i++) {
4552 if (no_hp_sensing(spec, i))
4554 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4556 unsigned int pinctl;
4557 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4558 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4559 if (pinctl & AC_PINCTL_IN_EN)
4560 presence = 0; /* mic- or line-input */
4565 /* disable lineouts */
4566 if (spec->hp_switch)
4567 stac92xx_reset_pinctl(codec, spec->hp_switch,
4569 for (i = 0; i < cfg->line_outs; i++)
4570 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4573 /* enable lineouts */
4574 if (spec->hp_switch)
4575 stac92xx_set_pinctl(codec, spec->hp_switch,
4577 for (i = 0; i < cfg->line_outs; i++)
4578 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4581 stac92xx_line_out_detect(codec, presence);
4582 /* toggle hp outs */
4583 for (i = 0; i < cfg->hp_outs; i++) {
4584 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4585 if (no_hp_sensing(spec, i))
4588 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4590 /* Resetting the pinctl like below may lead to (a sort of) regressions
4591 * on some devices since they use the HP pin actually for line/speaker
4592 * outs although the default pin config shows a different pin (that is
4593 * wrong and useless).
4595 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4596 * But, disabling the code below just works around it, and I'm too tired of
4597 * bug reports with such devices...
4600 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4605 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4608 struct sigmatel_spec *spec = codec->spec;
4609 unsigned int idx, val;
4611 for (idx = 0; idx < spec->num_pwrs; idx++) {
4612 if (spec->pwr_nids[idx] == nid)
4615 if (idx >= spec->num_pwrs)
4618 /* several codecs have two power down bits */
4619 if (spec->pwr_mapping)
4620 idx = spec->pwr_mapping[idx];
4624 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4630 /* power down unused output ports */
4631 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4634 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4636 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4639 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4641 struct sigmatel_spec *spec = codec->spec;
4642 struct sigmatel_jack *jacks = spec->jacks.list;
4646 for (i = 0; i < spec->jacks.used; i++) {
4647 if (jacks->nid == nid) {
4648 unsigned int pin_ctl =
4649 snd_hda_codec_read(codec, nid,
4650 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4652 int type = jacks->type;
4653 if (type == (SND_JACK_LINEOUT
4654 | SND_JACK_HEADPHONE))
4655 type = (pin_ctl & AC_PINCTL_HP_EN)
4656 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4657 snd_jack_report(jacks->jack,
4658 get_pin_presence(codec, nid)
4666 static void stac92xx_mic_detect(struct hda_codec *codec)
4668 struct sigmatel_spec *spec = codec->spec;
4669 struct sigmatel_mic_route *mic;
4671 if (get_pin_presence(codec, spec->ext_mic.pin))
4672 mic = &spec->ext_mic;
4674 mic = &spec->int_mic;
4676 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4677 AC_VERB_SET_CONNECT_SEL,
4680 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4681 AC_VERB_SET_CONNECT_SEL,
4685 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4687 struct sigmatel_event *event = stac_get_event(codec, nid);
4690 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4693 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4695 struct sigmatel_spec *spec = codec->spec;
4696 struct sigmatel_event *event;
4699 tag = (res >> 26) & 0x7f;
4700 event = stac_get_event_from_tag(codec, tag);
4704 switch (event->type) {
4707 stac92xx_hp_detect(codec);
4709 case STAC_MIC_EVENT:
4710 stac92xx_mic_detect(codec);
4714 switch (event->type) {
4717 case STAC_MIC_EVENT:
4718 case STAC_INSERT_EVENT:
4719 case STAC_PWR_EVENT:
4720 if (spec->num_pwrs > 0)
4721 stac92xx_pin_sense(codec, event->nid);
4722 stac92xx_report_jack(codec, event->nid);
4724 switch (codec->subsystem_id) {
4726 if (event->nid == 0xb) {
4727 int pin = AC_PINCTL_IN_EN;
4729 if (get_pin_presence(codec, 0xa)
4730 && get_pin_presence(codec, 0xb))
4731 pin |= AC_PINCTL_VREF_80;
4732 if (!get_pin_presence(codec, 0xb))
4733 pin |= AC_PINCTL_VREF_80;
4735 /* toggle VREF state based on mic + hp pin
4738 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4742 case STAC_VREF_EVENT:
4743 data = snd_hda_codec_read(codec, codec->afg, 0,
4744 AC_VERB_GET_GPIO_DATA, 0);
4745 /* toggle VREF state based on GPIOx status */
4746 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4747 !!(data & (1 << event->data)));
4752 #ifdef CONFIG_PROC_FS
4753 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4754 struct hda_codec *codec, hda_nid_t nid)
4756 if (nid == codec->afg)
4757 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4758 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4761 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4762 struct hda_codec *codec,
4765 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4766 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4769 /* stac92hd71bxx, stac92hd73xx */
4770 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4771 struct hda_codec *codec, hda_nid_t nid)
4773 stac92hd_proc_hook(buffer, codec, nid);
4774 if (nid == codec->afg)
4775 analog_loop_proc_hook(buffer, codec, 0xfa0);
4778 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4779 struct hda_codec *codec, hda_nid_t nid)
4781 if (nid == codec->afg)
4782 analog_loop_proc_hook(buffer, codec, 0xfe0);
4785 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4786 struct hda_codec *codec, hda_nid_t nid)
4788 if (nid == codec->afg)
4789 analog_loop_proc_hook(buffer, codec, 0xfeb);
4792 #define stac92hd_proc_hook NULL
4793 #define stac92hd7x_proc_hook NULL
4794 #define stac9205_proc_hook NULL
4795 #define stac927x_proc_hook NULL
4798 #ifdef SND_HDA_NEEDS_RESUME
4799 static int stac92xx_resume(struct hda_codec *codec)
4801 struct sigmatel_spec *spec = codec->spec;
4803 stac92xx_init(codec);
4804 snd_hda_codec_resume_amp(codec);
4805 snd_hda_codec_resume_cache(codec);
4806 /* fake event to set up pins again to override cached values */
4807 if (spec->hp_detect)
4808 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4813 * using power check for controlling mute led of HP notebooks
4814 * check for mute state only on Speakers (nid = 0x10)
4816 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4817 * the LED is NOT working properly !
4819 * Changed name to reflect that it now works for any designated
4820 * model, not just HP HDX.
4823 #ifdef CONFIG_SND_HDA_POWER_SAVE
4824 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4827 struct sigmatel_spec *spec = codec->spec;
4830 if (snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
4832 spec->gpio_data &= ~spec->gpio_led; /* orange */
4834 spec->gpio_data |= spec->gpio_led; /* white */
4836 stac_gpio_set(codec, spec->gpio_mask,
4845 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4847 struct sigmatel_spec *spec = codec->spec;
4851 /* reset each pin before powering down DAC/ADC to avoid click noise */
4852 nid = codec->start_nid;
4853 for (i = 0; i < codec->num_nodes; i++, nid++) {
4854 unsigned int wcaps = get_wcaps(codec, nid);
4855 unsigned int wid_type = get_wcaps_type(wcaps);
4856 if (wid_type == AC_WID_PIN)
4857 snd_hda_codec_read(codec, nid, 0,
4858 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4861 if (spec->eapd_mask)
4862 stac_gpio_set(codec, spec->gpio_mask,
4863 spec->gpio_dir, spec->gpio_data &
4869 static struct hda_codec_ops stac92xx_patch_ops = {
4870 .build_controls = stac92xx_build_controls,
4871 .build_pcms = stac92xx_build_pcms,
4872 .init = stac92xx_init,
4873 .free = stac92xx_free,
4874 .unsol_event = stac92xx_unsol_event,
4875 #ifdef SND_HDA_NEEDS_RESUME
4876 .suspend = stac92xx_suspend,
4877 .resume = stac92xx_resume,
4881 static int patch_stac9200(struct hda_codec *codec)
4883 struct sigmatel_spec *spec;
4886 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4891 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
4892 spec->pin_nids = stac9200_pin_nids;
4893 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
4896 if (spec->board_config < 0)
4897 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4900 stac92xx_set_config_regs(codec,
4901 stac9200_brd_tbl[spec->board_config]);
4903 spec->multiout.max_channels = 2;
4904 spec->multiout.num_dacs = 1;
4905 spec->multiout.dac_nids = stac9200_dac_nids;
4906 spec->adc_nids = stac9200_adc_nids;
4907 spec->mux_nids = stac9200_mux_nids;
4908 spec->num_muxes = 1;
4909 spec->num_dmics = 0;
4913 if (spec->board_config == STAC_9200_M4 ||
4914 spec->board_config == STAC_9200_M4_2 ||
4915 spec->board_config == STAC_9200_OQO)
4916 spec->init = stac9200_eapd_init;
4918 spec->init = stac9200_core_init;
4919 spec->mixer = stac9200_mixer;
4921 if (spec->board_config == STAC_9200_PANASONIC) {
4922 spec->gpio_mask = spec->gpio_dir = 0x09;
4923 spec->gpio_data = 0x00;
4926 err = stac9200_parse_auto_config(codec);
4928 stac92xx_free(codec);
4932 /* CF-74 has no headphone detection, and the driver should *NOT*
4933 * do detection and HP/speaker toggle because the hardware does it.
4935 if (spec->board_config == STAC_9200_PANASONIC)
4936 spec->hp_detect = 0;
4938 codec->patch_ops = stac92xx_patch_ops;
4943 static int patch_stac925x(struct hda_codec *codec)
4945 struct sigmatel_spec *spec;
4948 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
4953 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
4954 spec->pin_nids = stac925x_pin_nids;
4956 /* Check first for codec ID */
4957 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
4960 stac925x_codec_id_cfg_tbl);
4962 /* Now checks for PCI ID, if codec ID is not found */
4963 if (spec->board_config < 0)
4964 spec->board_config = snd_hda_check_board_config(codec,
4969 if (spec->board_config < 0)
4970 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4973 stac92xx_set_config_regs(codec,
4974 stac925x_brd_tbl[spec->board_config]);
4976 spec->multiout.max_channels = 2;
4977 spec->multiout.num_dacs = 1;
4978 spec->multiout.dac_nids = stac925x_dac_nids;
4979 spec->adc_nids = stac925x_adc_nids;
4980 spec->mux_nids = stac925x_mux_nids;
4981 spec->num_muxes = 1;
4984 switch (codec->vendor_id) {
4985 case 0x83847632: /* STAC9202 */
4986 case 0x83847633: /* STAC9202D */
4987 case 0x83847636: /* STAC9251 */
4988 case 0x83847637: /* STAC9251D */
4989 spec->num_dmics = STAC925X_NUM_DMICS;
4990 spec->dmic_nids = stac925x_dmic_nids;
4991 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
4992 spec->dmux_nids = stac925x_dmux_nids;
4995 spec->num_dmics = 0;
4999 spec->init = stac925x_core_init;
5000 spec->mixer = stac925x_mixer;
5002 spec->capvols = stac925x_capvols;
5003 spec->capsws = stac925x_capsws;
5005 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
5007 if (spec->board_config < 0) {
5008 printk(KERN_WARNING "hda_codec: No auto-config is "
5009 "available, default to model=ref\n");
5010 spec->board_config = STAC_925x_REF;
5016 stac92xx_free(codec);
5020 codec->patch_ops = stac92xx_patch_ops;
5025 static int patch_stac92hd73xx(struct hda_codec *codec)
5027 struct sigmatel_spec *spec;
5028 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5032 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5037 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5038 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5039 spec->pin_nids = stac92hd73xx_pin_nids;
5040 spec->board_config = snd_hda_check_board_config(codec,
5041 STAC_92HD73XX_MODELS,
5042 stac92hd73xx_models,
5043 stac92hd73xx_cfg_tbl);
5045 if (spec->board_config < 0)
5046 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5049 stac92xx_set_config_regs(codec,
5050 stac92hd73xx_brd_tbl[spec->board_config]);
5052 num_dacs = snd_hda_get_connections(codec, 0x0a,
5053 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5055 if (num_dacs < 3 || num_dacs > 5) {
5056 printk(KERN_WARNING "hda_codec: Could not determine "
5057 "number of channels defaulting to DAC count\n");
5058 num_dacs = STAC92HD73_DAC_COUNT;
5060 spec->init = stac92hd73xx_core_init;
5062 case 0x3: /* 6 Channel */
5063 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5065 case 0x4: /* 8 Channel */
5066 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5068 case 0x5: /* 10 Channel */
5069 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5072 spec->multiout.dac_nids = spec->dac_nids;
5074 spec->aloopback_mask = 0x01;
5075 spec->aloopback_shift = 8;
5077 spec->digbeep_nid = 0x1c;
5078 spec->mux_nids = stac92hd73xx_mux_nids;
5079 spec->adc_nids = stac92hd73xx_adc_nids;
5080 spec->dmic_nids = stac92hd73xx_dmic_nids;
5081 spec->dmux_nids = stac92hd73xx_dmux_nids;
5082 spec->smux_nids = stac92hd73xx_smux_nids;
5084 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5085 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5086 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5088 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5089 spec->capvols = stac92hd73xx_capvols;
5090 spec->capsws = stac92hd73xx_capsws;
5092 switch (spec->board_config) {
5094 spec->init = dell_eq_core_init;
5096 case STAC_DELL_M6_AMIC:
5097 case STAC_DELL_M6_DMIC:
5098 case STAC_DELL_M6_BOTH:
5099 spec->num_smuxes = 0;
5100 spec->eapd_switch = 0;
5102 switch (spec->board_config) {
5103 case STAC_DELL_M6_AMIC: /* Analog Mics */
5104 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5105 spec->num_dmics = 0;
5107 case STAC_DELL_M6_DMIC: /* Digital Mics */
5108 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5109 spec->num_dmics = 1;
5111 case STAC_DELL_M6_BOTH: /* Both */
5112 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5113 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5114 spec->num_dmics = 1;
5119 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5120 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5121 spec->eapd_switch = 1;
5124 if (spec->board_config > STAC_92HD73XX_REF) {
5125 /* GPIO0 High = Enable EAPD */
5126 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5127 spec->gpio_data = 0x01;
5130 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5131 spec->pwr_nids = stac92hd73xx_pwr_nids;
5133 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5136 if (spec->board_config < 0) {
5137 printk(KERN_WARNING "hda_codec: No auto-config is "
5138 "available, default to model=ref\n");
5139 spec->board_config = STAC_92HD73XX_REF;
5146 stac92xx_free(codec);
5150 if (spec->board_config == STAC_92HD73XX_NO_JD)
5151 spec->hp_detect = 0;
5153 codec->patch_ops = stac92xx_patch_ops;
5155 codec->proc_widget_hook = stac92hd7x_proc_hook;
5160 static int patch_stac92hd83xxx(struct hda_codec *codec)
5162 struct sigmatel_spec *spec;
5163 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5168 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5173 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5174 spec->mono_nid = 0x19;
5175 spec->digbeep_nid = 0x21;
5176 spec->mux_nids = stac92hd83xxx_mux_nids;
5177 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5178 spec->adc_nids = stac92hd83xxx_adc_nids;
5179 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5180 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5181 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5182 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5183 spec->multiout.dac_nids = spec->dac_nids;
5185 spec->init = stac92hd83xxx_core_init;
5186 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5187 spec->pin_nids = stac92hd83xxx_pin_nids;
5188 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5189 spec->capvols = stac92hd83xxx_capvols;
5190 spec->capsws = stac92hd83xxx_capsws;
5192 spec->board_config = snd_hda_check_board_config(codec,
5193 STAC_92HD83XXX_MODELS,
5194 stac92hd83xxx_models,
5195 stac92hd83xxx_cfg_tbl);
5197 if (spec->board_config < 0)
5198 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5201 stac92xx_set_config_regs(codec,
5202 stac92hd83xxx_brd_tbl[spec->board_config]);
5204 switch (codec->vendor_id) {
5208 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5214 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5216 if (spec->board_config < 0) {
5217 printk(KERN_WARNING "hda_codec: No auto-config is "
5218 "available, default to model=ref\n");
5219 spec->board_config = STAC_92HD83XXX_REF;
5226 stac92xx_free(codec);
5230 switch (spec->board_config) {
5239 num_dacs = snd_hda_get_connections(codec, nid,
5240 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5242 num_dacs = STAC92HD83_DAC_COUNT;
5244 /* set port X to select the last DAC
5246 snd_hda_codec_write_cache(codec, nid, 0,
5247 AC_VERB_SET_CONNECT_SEL, num_dacs);
5249 codec->patch_ops = stac92xx_patch_ops;
5251 codec->proc_widget_hook = stac92hd_proc_hook;
5256 /* get the pin connection (fixed, none, etc) */
5257 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5259 struct sigmatel_spec *spec = codec->spec;
5262 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
5263 return get_defcfg_connect(cfg);
5266 static int stac92hd71bxx_connected_ports(struct hda_codec *codec,
5267 hda_nid_t *nids, int num_nids)
5269 struct sigmatel_spec *spec = codec->spec;
5271 unsigned int def_conf;
5273 for (num = 0; num < num_nids; num++) {
5274 for (idx = 0; idx < spec->num_pins; idx++)
5275 if (spec->pin_nids[idx] == nids[num])
5277 if (idx >= spec->num_pins)
5279 def_conf = stac_get_defcfg_connect(codec, idx);
5280 if (def_conf == AC_JACK_PORT_NONE)
5286 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5289 struct sigmatel_spec *spec = codec->spec;
5292 for (idx = 0; idx < spec->num_pins; idx++)
5293 if (spec->pin_nids[idx] == dig0pin)
5295 if ((idx + 2) >= spec->num_pins)
5299 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5302 /* dig0pin + dig2pin case */
5303 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5305 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5311 static int patch_stac92hd71bxx(struct hda_codec *codec)
5313 struct sigmatel_spec *spec;
5314 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5317 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5322 codec->patch_ops = stac92xx_patch_ops;
5323 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5324 switch (codec->vendor_id) {
5327 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5331 /* On 92HD75Bx 0x27 isn't a pin nid */
5335 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5337 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5338 spec->board_config = snd_hda_check_board_config(codec,
5339 STAC_92HD71BXX_MODELS,
5340 stac92hd71bxx_models,
5341 stac92hd71bxx_cfg_tbl);
5343 if (spec->board_config < 0)
5344 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5347 stac92xx_set_config_regs(codec,
5348 stac92hd71bxx_brd_tbl[spec->board_config]);
5350 if (spec->board_config > STAC_92HD71BXX_REF) {
5352 spec->gpio_mask = 0x01;
5353 spec->gpio_dir = 0x01;
5354 spec->gpio_data = 0x01;
5357 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5358 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5360 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5361 spec->capvols = stac92hd71bxx_capvols;
5362 spec->capsws = stac92hd71bxx_capsws;
5364 switch (codec->vendor_id) {
5365 case 0x111d76b6: /* 4 Port without Analog Mixer */
5369 case 0x111d76b4: /* 6 Port without Analog Mixer */
5371 spec->init = stac92hd71bxx_core_init;
5372 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5373 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5374 stac92hd71bxx_dmic_nids,
5375 STAC92HD71BXX_NUM_DMICS);
5377 case 0x111d7608: /* 5 Port with Analog Mixer */
5378 switch (spec->board_config) {
5380 /* Enable VREF power saving on GPIO1 detect */
5381 err = stac_add_event(spec, codec->afg,
5382 STAC_VREF_EVENT, 0x02);
5385 snd_hda_codec_write_cache(codec, codec->afg, 0,
5386 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5387 snd_hda_codec_write_cache(codec, codec->afg, 0,
5388 AC_VERB_SET_UNSOLICITED_ENABLE,
5390 spec->gpio_mask |= 0x02;
5393 if ((codec->revision_id & 0xf) == 0 ||
5394 (codec->revision_id & 0xf) == 1)
5395 spec->stream_delay = 40; /* 40 milliseconds */
5397 /* no output amps */
5400 spec->init = stac92hd71bxx_core_init;
5402 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5403 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5404 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5405 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5406 stac92hd71bxx_dmic_nids,
5407 STAC92HD71BXX_NUM_DMICS - 1);
5409 case 0x111d7603: /* 6 Port with Analog Mixer */
5410 if ((codec->revision_id & 0xf) == 1)
5411 spec->stream_delay = 40; /* 40 milliseconds */
5413 /* no output amps */
5417 spec->init = stac92hd71bxx_core_init;
5418 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5419 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5420 stac92hd71bxx_dmic_nids,
5421 STAC92HD71BXX_NUM_DMICS);
5425 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5426 snd_hda_sequence_write_cache(codec, unmute_init);
5428 /* Some HP machines seem to have unstable codec communications
5429 * especially with ATI fglrx driver. For recovering from the
5430 * CORB/RIRB stall, allow the BUS reset and keep always sync
5432 if (spec->board_config == STAC_HP_DV5) {
5433 codec->bus->sync_write = 1;
5434 codec->bus->allow_bus_reset = 1;
5437 spec->aloopback_ctl = stac92hd71bxx_loopback;
5438 spec->aloopback_mask = 0x50;
5439 spec->aloopback_shift = 0;
5441 spec->powerdown_adcs = 1;
5442 spec->digbeep_nid = 0x26;
5443 spec->mux_nids = stac92hd71bxx_mux_nids;
5444 spec->adc_nids = stac92hd71bxx_adc_nids;
5445 spec->smux_nids = stac92hd71bxx_smux_nids;
5446 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5448 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5449 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5450 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5451 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5453 switch (spec->board_config) {
5455 /* enable internal microphone */
5456 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5457 stac92xx_auto_set_pinctl(codec, 0x0e,
5458 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5460 case STAC_DELL_M4_2:
5461 spec->num_dmics = 0;
5462 spec->num_smuxes = 0;
5463 spec->num_dmuxes = 0;
5465 case STAC_DELL_M4_1:
5466 case STAC_DELL_M4_3:
5467 spec->num_dmics = 1;
5468 spec->num_smuxes = 0;
5469 spec->num_dmuxes = 1;
5471 case STAC_HP_DV4_1222NR:
5472 spec->num_dmics = 1;
5473 /* I don't know if it needs 1 or 2 smuxes - will wait for
5474 * bug reports to fix if needed
5476 spec->num_smuxes = 1;
5477 spec->num_dmuxes = 1;
5478 spec->gpio_led = 0x01;
5481 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5482 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5485 spec->num_dmics = 1;
5486 spec->num_dmuxes = 1;
5487 spec->num_smuxes = 1;
5488 /* orange/white mute led on GPIO3, orange=0, white=1 */
5489 spec->gpio_led = 0x08;
5493 #ifdef CONFIG_SND_HDA_POWER_SAVE
5494 if (spec->gpio_led) {
5495 spec->gpio_mask |= spec->gpio_led;
5496 spec->gpio_dir |= spec->gpio_led;
5497 spec->gpio_data |= spec->gpio_led;
5498 /* register check_power_status callback. */
5499 codec->patch_ops.check_power_status =
5500 stac92xx_hp_check_power_status;
5504 spec->multiout.dac_nids = spec->dac_nids;
5506 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5508 if (spec->board_config < 0) {
5509 printk(KERN_WARNING "hda_codec: No auto-config is "
5510 "available, default to model=ref\n");
5511 spec->board_config = STAC_92HD71BXX_REF;
5518 stac92xx_free(codec);
5522 codec->proc_widget_hook = stac92hd7x_proc_hook;
5527 static int patch_stac922x(struct hda_codec *codec)
5529 struct sigmatel_spec *spec;
5532 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5537 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5538 spec->pin_nids = stac922x_pin_nids;
5539 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5542 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5543 spec->gpio_mask = spec->gpio_dir = 0x03;
5544 spec->gpio_data = 0x03;
5545 /* Intel Macs have all same PCI SSID, so we need to check
5546 * codec SSID to distinguish the exact models
5548 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5549 switch (codec->subsystem_id) {
5552 spec->board_config = STAC_INTEL_MAC_V1;
5556 spec->board_config = STAC_INTEL_MAC_V2;
5564 spec->board_config = STAC_INTEL_MAC_V3;
5568 spec->board_config = STAC_INTEL_MAC_V4;
5572 spec->board_config = STAC_INTEL_MAC_V5;
5575 spec->board_config = STAC_INTEL_MAC_V3;
5581 if (spec->board_config < 0)
5582 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5585 stac92xx_set_config_regs(codec,
5586 stac922x_brd_tbl[spec->board_config]);
5588 spec->adc_nids = stac922x_adc_nids;
5589 spec->mux_nids = stac922x_mux_nids;
5590 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5591 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5592 spec->num_dmics = 0;
5595 spec->init = stac922x_core_init;
5597 spec->num_caps = STAC922X_NUM_CAPS;
5598 spec->capvols = stac922x_capvols;
5599 spec->capsws = stac922x_capsws;
5601 spec->multiout.dac_nids = spec->dac_nids;
5603 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5605 if (spec->board_config < 0) {
5606 printk(KERN_WARNING "hda_codec: No auto-config is "
5607 "available, default to model=ref\n");
5608 spec->board_config = STAC_D945_REF;
5614 stac92xx_free(codec);
5618 codec->patch_ops = stac92xx_patch_ops;
5620 /* Fix Mux capture level; max to 2 */
5621 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5622 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5623 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5624 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5625 (0 << AC_AMPCAP_MUTE_SHIFT));
5630 static int patch_stac927x(struct hda_codec *codec)
5632 struct sigmatel_spec *spec;
5635 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5640 codec->slave_dig_outs = stac927x_slave_dig_outs;
5641 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5642 spec->pin_nids = stac927x_pin_nids;
5643 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5647 if (spec->board_config < 0)
5648 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5651 stac92xx_set_config_regs(codec,
5652 stac927x_brd_tbl[spec->board_config]);
5654 spec->digbeep_nid = 0x23;
5655 spec->adc_nids = stac927x_adc_nids;
5656 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5657 spec->mux_nids = stac927x_mux_nids;
5658 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5659 spec->smux_nids = stac927x_smux_nids;
5660 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
5661 spec->spdif_labels = stac927x_spdif_labels;
5662 spec->dac_list = stac927x_dac_nids;
5663 spec->multiout.dac_nids = spec->dac_nids;
5665 switch (spec->board_config) {
5668 /* GPIO0 High = Enable EAPD */
5669 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5670 spec->gpio_data = 0x01;
5671 spec->num_dmics = 0;
5673 spec->init = d965_core_init;
5675 case STAC_DELL_BIOS:
5676 switch (codec->subsystem_id) {
5679 /* correct the device field to SPDIF out */
5680 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
5683 /* configure the analog microphone on some laptops */
5684 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
5685 /* correct the front output jack as a hp out */
5686 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
5687 /* correct the front input jack as a mic */
5688 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5691 /* GPIO2 High = Enable EAPD */
5692 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5693 spec->gpio_data = 0x04;
5694 switch (codec->subsystem_id) {
5696 /* correct EAPD to be GPIO0 */
5697 spec->eapd_mask = spec->gpio_mask = 0x01;
5698 spec->gpio_dir = spec->gpio_data = 0x01;
5701 spec->dmic_nids = stac927x_dmic_nids;
5702 spec->num_dmics = STAC927X_NUM_DMICS;
5704 spec->init = d965_core_init;
5705 spec->dmux_nids = stac927x_dmux_nids;
5706 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5709 if (spec->board_config > STAC_D965_REF) {
5710 /* GPIO0 High = Enable EAPD */
5711 spec->eapd_mask = spec->gpio_mask = 0x01;
5712 spec->gpio_dir = spec->gpio_data = 0x01;
5714 spec->num_dmics = 0;
5716 spec->init = stac927x_core_init;
5719 spec->num_caps = STAC927X_NUM_CAPS;
5720 spec->capvols = stac927x_capvols;
5721 spec->capsws = stac927x_capsws;
5724 spec->aloopback_ctl = stac927x_loopback;
5725 spec->aloopback_mask = 0x40;
5726 spec->aloopback_shift = 0;
5727 spec->eapd_switch = 1;
5729 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
5731 if (spec->board_config < 0) {
5732 printk(KERN_WARNING "hda_codec: No auto-config is "
5733 "available, default to model=ref\n");
5734 spec->board_config = STAC_D965_REF;
5740 stac92xx_free(codec);
5744 codec->patch_ops = stac92xx_patch_ops;
5746 codec->proc_widget_hook = stac927x_proc_hook;
5750 * The STAC927x seem to require fairly long delays for certain
5751 * command sequences. With too short delays (even if the answer
5752 * is set to RIRB properly), it results in the silence output
5753 * on some hardwares like Dell.
5755 * The below flag enables the longer delay (see get_response
5758 codec->bus->needs_damn_long_delay = 1;
5760 /* no jack detecion for ref-no-jd model */
5761 if (spec->board_config == STAC_D965_REF_NO_JD)
5762 spec->hp_detect = 0;
5767 static int patch_stac9205(struct hda_codec *codec)
5769 struct sigmatel_spec *spec;
5772 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5777 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
5778 spec->pin_nids = stac9205_pin_nids;
5779 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
5783 if (spec->board_config < 0)
5784 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5787 stac92xx_set_config_regs(codec,
5788 stac9205_brd_tbl[spec->board_config]);
5790 spec->digbeep_nid = 0x23;
5791 spec->adc_nids = stac9205_adc_nids;
5792 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
5793 spec->mux_nids = stac9205_mux_nids;
5794 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
5795 spec->smux_nids = stac9205_smux_nids;
5796 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
5797 spec->dmic_nids = stac9205_dmic_nids;
5798 spec->num_dmics = STAC9205_NUM_DMICS;
5799 spec->dmux_nids = stac9205_dmux_nids;
5800 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
5803 spec->init = stac9205_core_init;
5804 spec->aloopback_ctl = stac9205_loopback;
5806 spec->num_caps = STAC9205_NUM_CAPS;
5807 spec->capvols = stac9205_capvols;
5808 spec->capsws = stac9205_capsws;
5810 spec->aloopback_mask = 0x40;
5811 spec->aloopback_shift = 0;
5812 /* Turn on/off EAPD per HP plugging */
5813 if (spec->board_config != STAC_9205_EAPD)
5814 spec->eapd_switch = 1;
5815 spec->multiout.dac_nids = spec->dac_nids;
5817 switch (spec->board_config){
5818 case STAC_9205_DELL_M43:
5819 /* Enable SPDIF in/out */
5820 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
5821 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
5823 /* Enable unsol response for GPIO4/Dock HP connection */
5824 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
5827 snd_hda_codec_write_cache(codec, codec->afg, 0,
5828 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
5829 snd_hda_codec_write_cache(codec, codec->afg, 0,
5830 AC_VERB_SET_UNSOLICITED_ENABLE,
5833 spec->gpio_dir = 0x0b;
5834 spec->eapd_mask = 0x01;
5835 spec->gpio_mask = 0x1b;
5836 spec->gpio_mute = 0x10;
5837 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
5840 spec->gpio_data = 0x01;
5843 /* SPDIF-In enabled */
5846 /* GPIO0 High = EAPD */
5847 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5848 spec->gpio_data = 0x01;
5852 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
5854 if (spec->board_config < 0) {
5855 printk(KERN_WARNING "hda_codec: No auto-config is "
5856 "available, default to model=ref\n");
5857 spec->board_config = STAC_9205_REF;
5863 stac92xx_free(codec);
5867 codec->patch_ops = stac92xx_patch_ops;
5869 codec->proc_widget_hook = stac9205_proc_hook;
5878 static struct hda_verb stac9872_core_init[] = {
5879 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
5880 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
5884 static hda_nid_t stac9872_pin_nids[] = {
5885 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5889 static hda_nid_t stac9872_adc_nids[] = {
5893 static hda_nid_t stac9872_mux_nids[] = {
5897 static unsigned long stac9872_capvols[] = {
5898 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5900 #define stac9872_capsws stac9872_capvols
5902 static unsigned int stac9872_vaio_pin_configs[9] = {
5903 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5904 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
5908 static const char *stac9872_models[STAC_9872_MODELS] = {
5909 [STAC_9872_AUTO] = "auto",
5910 [STAC_9872_VAIO] = "vaio",
5913 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5914 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
5917 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5918 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5919 "Sony VAIO F/S", STAC_9872_VAIO),
5923 static int patch_stac9872(struct hda_codec *codec)
5925 struct sigmatel_spec *spec;
5928 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5932 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5933 spec->pin_nids = stac9872_pin_nids;
5935 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5938 if (spec->board_config < 0)
5939 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5942 stac92xx_set_config_regs(codec,
5943 stac9872_brd_tbl[spec->board_config]);
5945 spec->multiout.dac_nids = spec->dac_nids;
5946 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5947 spec->adc_nids = stac9872_adc_nids;
5948 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5949 spec->mux_nids = stac9872_mux_nids;
5950 spec->init = stac9872_core_init;
5952 spec->capvols = stac9872_capvols;
5953 spec->capsws = stac9872_capsws;
5955 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5957 stac92xx_free(codec);
5960 spec->input_mux = &spec->private_imux;
5961 codec->patch_ops = stac92xx_patch_ops;
5969 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
5970 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
5971 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
5972 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
5973 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
5974 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
5975 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
5976 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
5977 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
5978 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
5979 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
5980 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
5981 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
5982 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
5983 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
5984 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
5985 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
5986 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
5987 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
5988 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
5989 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
5990 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
5991 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
5992 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
5993 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
5994 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
5995 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
5996 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
5997 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
5998 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
5999 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6000 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6001 /* The following does not take into account .id=0x83847661 when subsys =
6002 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6003 * currently not fully supported.
6005 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6006 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6007 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6008 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6009 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6010 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6011 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6012 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6013 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6014 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6015 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6016 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6017 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6018 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6019 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6020 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6021 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6022 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6023 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6024 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6025 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6026 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6027 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6028 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6029 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6030 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6031 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6032 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6036 MODULE_ALIAS("snd-hda-codec-id:8384*");
6037 MODULE_ALIAS("snd-hda-codec-id:111d*");
6039 MODULE_LICENSE("GPL");
6040 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6042 static struct hda_codec_preset_list sigmatel_list = {
6043 .preset = snd_hda_preset_sigmatel,
6044 .owner = THIS_MODULE,
6047 static int __init patch_sigmatel_init(void)
6049 return snd_hda_add_codec_preset(&sigmatel_list);
6052 static void __exit patch_sigmatel_exit(void)
6054 snd_hda_delete_codec_preset(&sigmatel_list);
6057 module_init(patch_sigmatel_init)
6058 module_exit(patch_sigmatel_exit)