2 * Universal Interface for Intel High Definition Audio Codec
4 * HD audio interface patch for SigmaTel STAC92xx
6 * Copyright (c) 2005 Embedded Alley Solutions, Inc.
7 * Matt Porter <mporter@embeddedalley.com>
9 * Based on patch_cmedia.c and patch_realtek.c
10 * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
12 * This driver is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This driver is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/slab.h>
30 #include <linux/pci.h>
31 #include <linux/dmi.h>
32 #include <sound/core.h>
33 #include <sound/asoundef.h>
34 #include <sound/jack.h>
35 #include <sound/tlv.h>
36 #include "hda_codec.h"
37 #include "hda_local.h"
81 STAC_92HD73XX_NO_JD, /* no jack-detection */
95 STAC_92HD83XXX_PWR_REF,
113 STAC_92HD71BXX_MODELS
139 STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
140 * is given, one of the above models will be
141 * chosen according to the subsystem id. */
142 /* for backward compatibility */
159 STAC_D965_REF_NO_JD, /* no jack-detection */
176 struct sigmatel_event {
183 struct sigmatel_jack {
186 struct snd_jack *jack;
189 struct sigmatel_mic_route {
192 signed char dmux_idx;
195 struct sigmatel_spec {
196 struct snd_kcontrol_new *mixers[4];
197 unsigned int num_mixers;
200 unsigned int eapd_switch: 1;
201 unsigned int surr_switch: 1;
202 unsigned int alt_switch: 1;
203 unsigned int hp_detect: 1;
204 unsigned int spdif_mute: 1;
205 unsigned int check_volume_offset:1;
206 unsigned int auto_mic:1;
207 unsigned int linear_tone_beep:1;
210 unsigned int eapd_mask;
211 unsigned int gpio_mask;
212 unsigned int gpio_dir;
213 unsigned int gpio_data;
214 unsigned int gpio_mute;
215 unsigned int gpio_led;
216 unsigned int gpio_led_polarity;
219 unsigned int stream_delay;
221 /* analog loopback */
222 struct snd_kcontrol_new *aloopback_ctl;
223 unsigned char aloopback_mask;
224 unsigned char aloopback_shift;
226 /* power management */
227 unsigned int num_pwrs;
228 unsigned int *pwr_mapping;
233 struct snd_array jacks;
236 struct snd_array events;
239 struct hda_input_mux *mono_mux;
240 unsigned int cur_mmux;
241 struct hda_multi_out multiout;
242 hda_nid_t dac_nids[5];
243 hda_nid_t hp_dacs[5];
244 hda_nid_t speaker_dacs[5];
250 unsigned int num_adcs;
252 unsigned int num_muxes;
253 hda_nid_t *dmic_nids;
254 unsigned int num_dmics;
255 hda_nid_t *dmux_nids;
256 unsigned int num_dmuxes;
257 hda_nid_t *smux_nids;
258 unsigned int num_smuxes;
259 unsigned int num_analog_muxes;
261 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
262 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
263 unsigned int num_caps; /* number of capture volume/switch elements */
265 struct sigmatel_mic_route ext_mic;
266 struct sigmatel_mic_route int_mic;
267 struct sigmatel_mic_route dock_mic;
269 const char * const *spdif_labels;
271 hda_nid_t dig_in_nid;
273 hda_nid_t anabeep_nid;
274 hda_nid_t digbeep_nid;
278 unsigned int num_pins;
280 /* codec specific stuff */
281 struct hda_verb *init;
282 struct snd_kcontrol_new *mixer;
285 struct hda_input_mux *dinput_mux;
286 unsigned int cur_dmux[2];
287 struct hda_input_mux *input_mux;
288 unsigned int cur_mux[3];
289 struct hda_input_mux *sinput_mux;
290 unsigned int cur_smux[2];
291 unsigned int cur_amux;
293 unsigned int powerdown_adcs;
296 unsigned int io_switch[2];
297 unsigned int clfe_swap;
298 hda_nid_t line_switch; /* shared line-in for input and output */
299 hda_nid_t mic_switch; /* shared mic-in for input and output */
300 hda_nid_t hp_switch; /* NID of HP as line-out */
301 unsigned int aloopback;
303 struct hda_pcm pcm_rec[2]; /* PCM information */
305 /* dynamic controls and input_mux */
306 struct auto_pin_cfg autocfg;
307 struct snd_array kctls;
308 struct hda_input_mux private_dimux;
309 struct hda_input_mux private_imux;
310 struct hda_input_mux private_smux;
311 struct hda_input_mux private_mono_mux;
314 static hda_nid_t stac9200_adc_nids[1] = {
318 static hda_nid_t stac9200_mux_nids[1] = {
322 static hda_nid_t stac9200_dac_nids[1] = {
326 static hda_nid_t stac92hd73xx_pwr_nids[8] = {
327 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
331 static hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
335 static hda_nid_t stac92hd73xx_adc_nids[2] = {
339 #define STAC92HD73XX_NUM_DMICS 2
340 static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
344 #define STAC92HD73_DAC_COUNT 5
346 static hda_nid_t stac92hd73xx_mux_nids[2] = {
350 static hda_nid_t stac92hd73xx_dmux_nids[2] = {
354 static hda_nid_t stac92hd73xx_smux_nids[2] = {
358 #define STAC92HD73XX_NUM_CAPS 2
359 static unsigned long stac92hd73xx_capvols[] = {
360 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
361 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
363 #define stac92hd73xx_capsws stac92hd73xx_capvols
365 #define STAC92HD83_DAC_COUNT 3
367 static hda_nid_t stac92hd83xxx_mux_nids[2] = {
371 static hda_nid_t stac92hd83xxx_adc_nids[2] = {
375 static hda_nid_t stac92hd83xxx_pwr_nids[4] = {
379 static hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
383 static unsigned int stac92hd83xxx_pwr_mapping[4] = {
384 0x03, 0x0c, 0x20, 0x40,
387 #define STAC92HD83XXX_NUM_DMICS 2
388 static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = {
392 #define STAC92HD88XXX_NUM_DMICS STAC92HD83XXX_NUM_DMICS
393 #define stac92hd88xxx_dmic_nids stac92hd83xxx_dmic_nids
395 #define STAC92HD87B_NUM_DMICS 1
396 static hda_nid_t stac92hd87b_dmic_nids[STAC92HD87B_NUM_DMICS + 1] = {
400 #define STAC92HD83XXX_NUM_CAPS 2
401 static unsigned long stac92hd83xxx_capvols[] = {
402 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
403 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
405 #define stac92hd83xxx_capsws stac92hd83xxx_capvols
407 static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
411 static hda_nid_t stac92hd71bxx_adc_nids[2] = {
415 static hda_nid_t stac92hd71bxx_mux_nids[2] = {
419 static hda_nid_t stac92hd71bxx_dmux_nids[2] = {
423 static hda_nid_t stac92hd71bxx_smux_nids[2] = {
427 #define STAC92HD71BXX_NUM_DMICS 2
428 static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
432 static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
436 #define STAC92HD71BXX_NUM_CAPS 2
437 static unsigned long stac92hd71bxx_capvols[] = {
438 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
439 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
441 #define stac92hd71bxx_capsws stac92hd71bxx_capvols
443 static hda_nid_t stac925x_adc_nids[1] = {
447 static hda_nid_t stac925x_mux_nids[1] = {
451 static hda_nid_t stac925x_dac_nids[1] = {
455 #define STAC925X_NUM_DMICS 1
456 static hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
460 static hda_nid_t stac925x_dmux_nids[1] = {
464 static unsigned long stac925x_capvols[] = {
465 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
467 static unsigned long stac925x_capsws[] = {
468 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
471 static hda_nid_t stac922x_adc_nids[2] = {
475 static hda_nid_t stac922x_mux_nids[2] = {
479 #define STAC922X_NUM_CAPS 2
480 static unsigned long stac922x_capvols[] = {
481 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
482 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
484 #define stac922x_capsws stac922x_capvols
486 static hda_nid_t stac927x_slave_dig_outs[2] = {
490 static hda_nid_t stac927x_adc_nids[3] = {
494 static hda_nid_t stac927x_mux_nids[3] = {
498 static hda_nid_t stac927x_smux_nids[1] = {
502 static hda_nid_t stac927x_dac_nids[6] = {
503 0x02, 0x03, 0x04, 0x05, 0x06, 0
506 static hda_nid_t stac927x_dmux_nids[1] = {
510 #define STAC927X_NUM_DMICS 2
511 static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
515 #define STAC927X_NUM_CAPS 3
516 static unsigned long stac927x_capvols[] = {
517 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
518 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
519 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
521 static unsigned long stac927x_capsws[] = {
522 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
523 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
524 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
527 static const char * const stac927x_spdif_labels[5] = {
528 "Digital Playback", "ADAT", "Analog Mux 1",
529 "Analog Mux 2", "Analog Mux 3"
532 static hda_nid_t stac9205_adc_nids[2] = {
536 static hda_nid_t stac9205_mux_nids[2] = {
540 static hda_nid_t stac9205_dmux_nids[1] = {
544 static hda_nid_t stac9205_smux_nids[1] = {
548 #define STAC9205_NUM_DMICS 2
549 static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
553 #define STAC9205_NUM_CAPS 2
554 static unsigned long stac9205_capvols[] = {
555 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
556 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
558 static unsigned long stac9205_capsws[] = {
559 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
560 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
563 static hda_nid_t stac9200_pin_nids[8] = {
564 0x08, 0x09, 0x0d, 0x0e,
565 0x0f, 0x10, 0x11, 0x12,
568 static hda_nid_t stac925x_pin_nids[8] = {
569 0x07, 0x08, 0x0a, 0x0b,
570 0x0c, 0x0d, 0x10, 0x11,
573 static hda_nid_t stac922x_pin_nids[10] = {
574 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
575 0x0f, 0x10, 0x11, 0x15, 0x1b,
578 static hda_nid_t stac92hd73xx_pin_nids[13] = {
579 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
580 0x0f, 0x10, 0x11, 0x12, 0x13,
584 static hda_nid_t stac92hd83xxx_pin_nids[10] = {
585 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
586 0x0f, 0x10, 0x11, 0x1f, 0x20,
589 static hda_nid_t stac92hd87xxx_pin_nids[6] = {
590 0x0a, 0x0b, 0x0c, 0x0d,
594 static hda_nid_t stac92hd88xxx_pin_nids[8] = {
595 0x0a, 0x0b, 0x0c, 0x0d,
596 0x0f, 0x11, 0x1f, 0x20,
599 #define STAC92HD71BXX_NUM_PINS 13
600 static hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
601 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
602 0x00, 0x14, 0x18, 0x19, 0x1e,
605 static hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
606 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
607 0x0f, 0x14, 0x18, 0x19, 0x1e,
611 static hda_nid_t stac927x_pin_nids[14] = {
612 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
613 0x0f, 0x10, 0x11, 0x12, 0x13,
614 0x14, 0x21, 0x22, 0x23,
617 static hda_nid_t stac9205_pin_nids[12] = {
618 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
619 0x0f, 0x14, 0x16, 0x17, 0x18,
623 static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
624 struct snd_ctl_elem_info *uinfo)
626 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
627 struct sigmatel_spec *spec = codec->spec;
628 return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
631 static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
632 struct snd_ctl_elem_value *ucontrol)
634 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
635 struct sigmatel_spec *spec = codec->spec;
636 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
638 ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
642 static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
643 struct snd_ctl_elem_value *ucontrol)
645 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
646 struct sigmatel_spec *spec = codec->spec;
647 unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
649 return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
650 spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
653 static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
654 struct snd_ctl_elem_info *uinfo)
656 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
657 struct sigmatel_spec *spec = codec->spec;
658 return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
661 static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
662 struct snd_ctl_elem_value *ucontrol)
664 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
665 struct sigmatel_spec *spec = codec->spec;
666 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
668 ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
672 static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
673 struct snd_ctl_elem_value *ucontrol)
675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
676 struct sigmatel_spec *spec = codec->spec;
677 struct hda_input_mux *smux = &spec->private_smux;
678 unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
682 err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
683 spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
687 if (spec->spdif_mute) {
689 nid = spec->multiout.dig_out_nid;
691 nid = codec->slave_dig_outs[smux_idx - 1];
692 if (spec->cur_smux[smux_idx] == smux->num_items - 1)
696 /* un/mute SPDIF out */
697 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
703 static unsigned int stac92xx_vref_set(struct hda_codec *codec,
704 hda_nid_t nid, unsigned int new_vref)
708 pincfg = snd_hda_codec_read(codec, nid, 0,
709 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
712 pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
715 if (new_vref == AC_PINCTL_VREF_HIZ)
716 pincfg |= AC_PINCTL_OUT_EN;
718 pincfg |= AC_PINCTL_IN_EN;
720 error = snd_hda_codec_write_cache(codec, nid, 0,
721 AC_VERB_SET_PIN_WIDGET_CONTROL, pincfg);
728 static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
731 vref = snd_hda_codec_read(codec, nid, 0,
732 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
733 vref &= AC_PINCTL_VREFEN;
737 static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
740 struct sigmatel_spec *spec = codec->spec;
741 return snd_hda_input_mux_info(spec->input_mux, uinfo);
744 static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
746 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
747 struct sigmatel_spec *spec = codec->spec;
748 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
750 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
754 static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
757 struct sigmatel_spec *spec = codec->spec;
758 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
759 const struct hda_input_mux *imux = spec->input_mux;
760 unsigned int idx, prev_idx;
762 idx = ucontrol->value.enumerated.item[0];
763 if (idx >= imux->num_items)
764 idx = imux->num_items - 1;
765 prev_idx = spec->cur_mux[adc_idx];
768 if (idx < spec->num_analog_muxes) {
769 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
770 AC_VERB_SET_CONNECT_SEL,
771 imux->items[idx].index);
772 if (prev_idx >= spec->num_analog_muxes) {
773 imux = spec->dinput_mux;
775 snd_hda_codec_write_cache(codec,
776 spec->dmux_nids[adc_idx], 0,
777 AC_VERB_SET_CONNECT_SEL,
778 imux->items[0].index);
781 imux = spec->dinput_mux;
782 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
783 AC_VERB_SET_CONNECT_SEL,
784 imux->items[idx - 1].index);
786 spec->cur_mux[adc_idx] = idx;
790 static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
791 struct snd_ctl_elem_info *uinfo)
793 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
794 struct sigmatel_spec *spec = codec->spec;
795 return snd_hda_input_mux_info(spec->mono_mux, uinfo);
798 static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
799 struct snd_ctl_elem_value *ucontrol)
801 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
802 struct sigmatel_spec *spec = codec->spec;
804 ucontrol->value.enumerated.item[0] = spec->cur_mmux;
808 static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
809 struct snd_ctl_elem_value *ucontrol)
811 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
812 struct sigmatel_spec *spec = codec->spec;
814 return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
815 spec->mono_nid, &spec->cur_mmux);
818 #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
820 static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
821 struct snd_ctl_elem_value *ucontrol)
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
825 struct sigmatel_spec *spec = codec->spec;
827 ucontrol->value.integer.value[0] = !!(spec->aloopback &
828 (spec->aloopback_mask << idx));
832 static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
833 struct snd_ctl_elem_value *ucontrol)
835 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
836 struct sigmatel_spec *spec = codec->spec;
837 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
838 unsigned int dac_mode;
839 unsigned int val, idx_val;
841 idx_val = spec->aloopback_mask << idx;
842 if (ucontrol->value.integer.value[0])
843 val = spec->aloopback | idx_val;
845 val = spec->aloopback & ~idx_val;
846 if (spec->aloopback == val)
849 spec->aloopback = val;
851 /* Only return the bits defined by the shift value of the
852 * first two bytes of the mask
854 dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
855 kcontrol->private_value & 0xFFFF, 0x0);
856 dac_mode >>= spec->aloopback_shift;
858 if (spec->aloopback & idx_val) {
859 snd_hda_power_up(codec);
862 snd_hda_power_down(codec);
863 dac_mode &= ~idx_val;
866 snd_hda_codec_write_cache(codec, codec->afg, 0,
867 kcontrol->private_value >> 16, dac_mode);
872 static struct hda_verb stac9200_core_init[] = {
873 /* set dac0mux for dac converter */
874 { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
878 static struct hda_verb stac9200_eapd_init[] = {
879 /* set dac0mux for dac converter */
880 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
881 {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
885 static struct hda_verb dell_eq_core_init[] = {
886 /* set master volume to max value without distortion
887 * and direct control */
888 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
892 static struct hda_verb stac92hd73xx_core_init[] = {
893 /* set master volume and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
898 static struct hda_verb stac92hd83xxx_core_init[] = {
899 /* power state controls amps */
900 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
904 static struct hda_verb stac92hd71bxx_core_init[] = {
905 /* set master volume and direct control */
906 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
910 static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
911 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
912 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
913 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
914 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
918 static struct hda_verb stac925x_core_init[] = {
919 /* set dac0mux for dac converter */
920 { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
921 /* mute the master volume */
922 { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
926 static struct hda_verb stac922x_core_init[] = {
927 /* set master volume and direct control */
928 { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
932 static struct hda_verb d965_core_init[] = {
933 /* set master volume and direct control */
934 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
935 /* unmute node 0x1b */
936 { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
937 /* select node 0x03 as DAC */
938 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
942 static struct hda_verb dell_3st_core_init[] = {
943 /* don't set delta bit */
944 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
945 /* unmute node 0x1b */
946 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
947 /* select node 0x03 as DAC */
948 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
952 static struct hda_verb stac927x_core_init[] = {
953 /* set master volume and direct control */
954 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
955 /* enable analog pc beep path */
956 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
960 static struct hda_verb stac927x_volknob_core_init[] = {
961 /* don't set delta bit */
962 {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
963 /* enable analog pc beep path */
964 {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
968 static struct hda_verb stac9205_core_init[] = {
969 /* set master volume and direct control */
970 { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
971 /* enable analog pc beep path */
972 { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
976 #define STAC_MONO_MUX \
978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
979 .name = "Mono Mux", \
981 .info = stac92xx_mono_mux_enum_info, \
982 .get = stac92xx_mono_mux_enum_get, \
983 .put = stac92xx_mono_mux_enum_put, \
986 #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
988 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
989 .name = "Analog Loopback", \
991 .info = stac92xx_aloopback_info, \
992 .get = stac92xx_aloopback_get, \
993 .put = stac92xx_aloopback_put, \
994 .private_value = verb_read | (verb_write << 16), \
997 #define DC_BIAS(xname, idx, nid) \
999 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1002 .info = stac92xx_dc_bias_info, \
1003 .get = stac92xx_dc_bias_get, \
1004 .put = stac92xx_dc_bias_put, \
1005 .private_value = nid, \
1008 static struct snd_kcontrol_new stac9200_mixer[] = {
1009 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
1010 HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
1011 HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
1012 HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
1016 static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1017 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1021 static struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
1022 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
1026 static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1027 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
1032 static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1033 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1036 static struct snd_kcontrol_new stac925x_mixer[] = {
1037 HDA_CODEC_VOLUME_MIN_MUTE("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
1038 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1042 static struct snd_kcontrol_new stac9205_loopback[] = {
1043 STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
1047 static struct snd_kcontrol_new stac927x_loopback[] = {
1048 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1052 static struct snd_kcontrol_new stac_dmux_mixer = {
1053 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1054 .name = "Digital Input Source",
1055 /* count set later */
1056 .info = stac92xx_dmux_enum_info,
1057 .get = stac92xx_dmux_enum_get,
1058 .put = stac92xx_dmux_enum_put,
1061 static struct snd_kcontrol_new stac_smux_mixer = {
1062 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1063 .name = "IEC958 Playback Source",
1064 /* count set later */
1065 .info = stac92xx_smux_enum_info,
1066 .get = stac92xx_smux_enum_get,
1067 .put = stac92xx_smux_enum_put,
1070 static const char * const slave_vols[] = {
1071 "Front Playback Volume",
1072 "Surround Playback Volume",
1073 "Center Playback Volume",
1074 "LFE Playback Volume",
1075 "Side Playback Volume",
1076 "Headphone Playback Volume",
1077 "Speaker Playback Volume",
1081 static const char * const slave_sws[] = {
1082 "Front Playback Switch",
1083 "Surround Playback Switch",
1084 "Center Playback Switch",
1085 "LFE Playback Switch",
1086 "Side Playback Switch",
1087 "Headphone Playback Switch",
1088 "Speaker Playback Switch",
1089 "IEC958 Playback Switch",
1093 static void stac92xx_free_kctls(struct hda_codec *codec);
1094 static int stac92xx_add_jack(struct hda_codec *codec, hda_nid_t nid, int type);
1096 static int stac92xx_build_controls(struct hda_codec *codec)
1098 struct sigmatel_spec *spec = codec->spec;
1099 struct auto_pin_cfg *cfg = &spec->autocfg;
1105 err = snd_hda_add_new_ctls(codec, spec->mixer);
1110 for (i = 0; i < spec->num_mixers; i++) {
1111 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1115 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1116 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1117 stac_dmux_mixer.count = spec->num_dmuxes;
1118 err = snd_hda_ctl_add(codec, 0,
1119 snd_ctl_new1(&stac_dmux_mixer, codec));
1123 if (spec->num_smuxes > 0) {
1124 int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
1125 struct hda_input_mux *smux = &spec->private_smux;
1126 /* check for mute support on SPDIF out */
1127 if (wcaps & AC_WCAP_OUT_AMP) {
1128 snd_hda_add_imux_item(smux, "Off", 0, NULL);
1129 spec->spdif_mute = 1;
1131 stac_smux_mixer.count = spec->num_smuxes;
1132 err = snd_hda_ctl_add(codec, 0,
1133 snd_ctl_new1(&stac_smux_mixer, codec));
1138 if (spec->multiout.dig_out_nid) {
1139 err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
1142 err = snd_hda_create_spdif_share_sw(codec,
1146 spec->multiout.share_spdif = 1;
1148 if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
1149 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1154 /* if we have no master control, let's create it */
1155 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
1156 unsigned int vmaster_tlv[4];
1157 snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
1158 HDA_OUTPUT, vmaster_tlv);
1159 /* correct volume offset */
1160 vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
1161 /* minimum value is actually mute */
1162 vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
1163 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
1164 vmaster_tlv, slave_vols);
1168 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1169 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1175 if (spec->aloopback_ctl &&
1176 snd_hda_get_bool_hint(codec, "loopback") == 1) {
1177 err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
1182 stac92xx_free_kctls(codec); /* no longer needed */
1184 /* create jack input elements */
1185 if (spec->hp_detect) {
1186 for (i = 0; i < cfg->hp_outs; i++) {
1187 int type = SND_JACK_HEADPHONE;
1188 nid = cfg->hp_pins[i];
1189 /* jack detection */
1190 if (cfg->hp_outs == i)
1191 type |= SND_JACK_LINEOUT;
1192 err = stac92xx_add_jack(codec, nid, type);
1197 for (i = 0; i < cfg->line_outs; i++) {
1198 err = stac92xx_add_jack(codec, cfg->line_out_pins[i],
1203 for (i = 0; i < cfg->num_inputs; i++) {
1204 nid = cfg->inputs[i].pin;
1205 err = stac92xx_add_jack(codec, nid, SND_JACK_MICROPHONE);
1213 static unsigned int ref9200_pin_configs[8] = {
1214 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
1215 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1218 static unsigned int gateway9200_m4_pin_configs[8] = {
1219 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1220 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1222 static unsigned int gateway9200_m4_2_pin_configs[8] = {
1223 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
1224 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
1228 STAC 9200 pin configs for
1233 static unsigned int dell9200_d21_pin_configs[8] = {
1234 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
1235 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
1239 STAC 9200 pin configs for
1243 static unsigned int dell9200_d22_pin_configs[8] = {
1244 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1245 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
1249 STAC 9200 pin configs for
1250 102801C4 (Dell Dimension E310)
1257 static unsigned int dell9200_d23_pin_configs[8] = {
1258 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
1259 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
1264 STAC 9200-32 pin configs for
1265 102801B5 (Dell Inspiron 630m)
1266 102801D8 (Dell Inspiron 640m)
1268 static unsigned int dell9200_m21_pin_configs[8] = {
1269 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
1270 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
1274 STAC 9200-32 pin configs for
1275 102801C2 (Dell Latitude D620)
1277 102801CC (Dell Latitude D820)
1281 static unsigned int dell9200_m22_pin_configs[8] = {
1282 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
1283 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
1287 STAC 9200-32 pin configs for
1288 102801CE (Dell XPS M1710)
1289 102801CF (Dell Precision M90)
1291 static unsigned int dell9200_m23_pin_configs[8] = {
1292 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
1293 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
1297 STAC 9200-32 pin configs for
1300 102801CB (Dell Latitude 120L)
1303 static unsigned int dell9200_m24_pin_configs[8] = {
1304 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
1305 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
1309 STAC 9200-32 pin configs for
1310 102801BD (Dell Inspiron E1505n)
1314 static unsigned int dell9200_m25_pin_configs[8] = {
1315 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1316 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
1320 STAC 9200-32 pin configs for
1321 102801F5 (Dell Inspiron 1501)
1324 static unsigned int dell9200_m26_pin_configs[8] = {
1325 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
1326 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
1331 102801CD (Dell Inspiron E1705/9400)
1333 static unsigned int dell9200_m27_pin_configs[8] = {
1334 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
1335 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
1338 static unsigned int oqo9200_pin_configs[8] = {
1339 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
1340 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
1344 static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
1345 [STAC_REF] = ref9200_pin_configs,
1346 [STAC_9200_OQO] = oqo9200_pin_configs,
1347 [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
1348 [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
1349 [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
1350 [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
1351 [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
1352 [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
1353 [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
1354 [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
1355 [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
1356 [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
1357 [STAC_9200_M4] = gateway9200_m4_pin_configs,
1358 [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
1359 [STAC_9200_PANASONIC] = ref9200_pin_configs,
1362 static const char * const stac9200_models[STAC_9200_MODELS] = {
1363 [STAC_AUTO] = "auto",
1365 [STAC_9200_OQO] = "oqo",
1366 [STAC_9200_DELL_D21] = "dell-d21",
1367 [STAC_9200_DELL_D22] = "dell-d22",
1368 [STAC_9200_DELL_D23] = "dell-d23",
1369 [STAC_9200_DELL_M21] = "dell-m21",
1370 [STAC_9200_DELL_M22] = "dell-m22",
1371 [STAC_9200_DELL_M23] = "dell-m23",
1372 [STAC_9200_DELL_M24] = "dell-m24",
1373 [STAC_9200_DELL_M25] = "dell-m25",
1374 [STAC_9200_DELL_M26] = "dell-m26",
1375 [STAC_9200_DELL_M27] = "dell-m27",
1376 [STAC_9200_M4] = "gateway-m4",
1377 [STAC_9200_M4_2] = "gateway-m4-2",
1378 [STAC_9200_PANASONIC] = "panasonic",
1381 static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1382 /* SigmaTel reference board */
1383 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1384 "DFI LanParty", STAC_REF),
1385 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1386 "DFI LanParty", STAC_REF),
1387 /* Dell laptops have BIOS problem */
1388 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
1389 "unknown Dell", STAC_9200_DELL_D21),
1390 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
1391 "Dell Inspiron 630m", STAC_9200_DELL_M21),
1392 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
1393 "Dell Inspiron E1505n", STAC_9200_DELL_M25),
1394 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
1395 "unknown Dell", STAC_9200_DELL_D22),
1396 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
1397 "unknown Dell", STAC_9200_DELL_D22),
1398 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
1399 "Dell Latitude D620", STAC_9200_DELL_M22),
1400 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
1401 "unknown Dell", STAC_9200_DELL_D23),
1402 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
1403 "unknown Dell", STAC_9200_DELL_D23),
1404 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
1405 "unknown Dell", STAC_9200_DELL_M22),
1406 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
1407 "unknown Dell", STAC_9200_DELL_M24),
1408 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
1409 "unknown Dell", STAC_9200_DELL_M24),
1410 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
1411 "Dell Latitude 120L", STAC_9200_DELL_M24),
1412 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
1413 "Dell Latitude D820", STAC_9200_DELL_M22),
1414 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
1415 "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
1416 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
1417 "Dell XPS M1710", STAC_9200_DELL_M23),
1418 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
1419 "Dell Precision M90", STAC_9200_DELL_M23),
1420 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
1421 "unknown Dell", STAC_9200_DELL_M22),
1422 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
1423 "unknown Dell", STAC_9200_DELL_M22),
1424 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
1425 "unknown Dell", STAC_9200_DELL_M22),
1426 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
1427 "Dell Inspiron 640m", STAC_9200_DELL_M21),
1428 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
1429 "unknown Dell", STAC_9200_DELL_D23),
1430 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
1431 "unknown Dell", STAC_9200_DELL_D23),
1432 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
1433 "unknown Dell", STAC_9200_DELL_D21),
1434 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
1435 "unknown Dell", STAC_9200_DELL_D23),
1436 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
1437 "unknown Dell", STAC_9200_DELL_D21),
1438 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
1439 "unknown Dell", STAC_9200_DELL_M25),
1440 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
1441 "unknown Dell", STAC_9200_DELL_M25),
1442 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
1443 "Dell Inspiron 1501", STAC_9200_DELL_M26),
1444 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
1445 "unknown Dell", STAC_9200_DELL_M26),
1447 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
1448 /* Gateway machines needs EAPD to be set on resume */
1449 SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
1450 SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
1451 SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
1453 SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
1457 static unsigned int ref925x_pin_configs[8] = {
1458 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
1459 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
1462 static unsigned int stac925xM1_pin_configs[8] = {
1463 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1464 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1467 static unsigned int stac925xM1_2_pin_configs[8] = {
1468 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1469 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1472 static unsigned int stac925xM2_pin_configs[8] = {
1473 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1474 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1477 static unsigned int stac925xM2_2_pin_configs[8] = {
1478 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1479 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1482 static unsigned int stac925xM3_pin_configs[8] = {
1483 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1484 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
1487 static unsigned int stac925xM5_pin_configs[8] = {
1488 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1489 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
1492 static unsigned int stac925xM6_pin_configs[8] = {
1493 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
1494 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
1497 static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
1498 [STAC_REF] = ref925x_pin_configs,
1499 [STAC_M1] = stac925xM1_pin_configs,
1500 [STAC_M1_2] = stac925xM1_2_pin_configs,
1501 [STAC_M2] = stac925xM2_pin_configs,
1502 [STAC_M2_2] = stac925xM2_2_pin_configs,
1503 [STAC_M3] = stac925xM3_pin_configs,
1504 [STAC_M5] = stac925xM5_pin_configs,
1505 [STAC_M6] = stac925xM6_pin_configs,
1508 static const char * const stac925x_models[STAC_925x_MODELS] = {
1509 [STAC_925x_AUTO] = "auto",
1512 [STAC_M1_2] = "m1-2",
1514 [STAC_M2_2] = "m2-2",
1520 static struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
1521 SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
1522 SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
1523 SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
1524 SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
1525 SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
1526 /* Not sure about the brand name for those */
1527 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
1528 SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
1529 SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
1530 SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
1534 static struct snd_pci_quirk stac925x_cfg_tbl[] = {
1535 /* SigmaTel reference board */
1536 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
1537 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
1538 SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
1540 /* Default table for unknown ID */
1541 SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
1546 static unsigned int ref92hd73xx_pin_configs[13] = {
1547 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
1548 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
1549 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
1553 static unsigned int dell_m6_pin_configs[13] = {
1554 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
1555 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
1556 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1560 static unsigned int alienware_m17x_pin_configs[13] = {
1561 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1562 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1563 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1567 static unsigned int intel_dg45id_pin_configs[13] = {
1568 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
1569 0x01A19250, 0x01011212, 0x01016211
1572 static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1573 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1574 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1575 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1576 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1577 [STAC_DELL_EQ] = dell_m6_pin_configs,
1578 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1579 [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
1582 static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1583 [STAC_92HD73XX_AUTO] = "auto",
1584 [STAC_92HD73XX_NO_JD] = "no-jd",
1585 [STAC_92HD73XX_REF] = "ref",
1586 [STAC_92HD73XX_INTEL] = "intel",
1587 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1588 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1589 [STAC_DELL_M6_BOTH] = "dell-m6",
1590 [STAC_DELL_EQ] = "dell-eq",
1591 [STAC_ALIENWARE_M17X] = "alienware",
1594 static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1595 /* SigmaTel reference board */
1596 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1597 "DFI LanParty", STAC_92HD73XX_REF),
1598 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1599 "DFI LanParty", STAC_92HD73XX_REF),
1600 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1601 "Intel DG45ID", STAC_92HD73XX_INTEL),
1602 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1603 "Intel DG45FC", STAC_92HD73XX_INTEL),
1604 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1605 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1606 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
1607 "unknown Dell", STAC_DELL_M6_DMIC),
1608 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
1609 "unknown Dell", STAC_DELL_M6_BOTH),
1610 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
1611 "unknown Dell", STAC_DELL_M6_BOTH),
1612 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
1613 "unknown Dell", STAC_DELL_M6_AMIC),
1614 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
1615 "unknown Dell", STAC_DELL_M6_AMIC),
1616 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
1617 "unknown Dell", STAC_DELL_M6_DMIC),
1618 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
1619 "unknown Dell", STAC_DELL_M6_DMIC),
1620 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1621 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1622 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1623 "Dell Studio 17", STAC_DELL_M6_DMIC),
1624 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1625 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1626 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
1627 "Dell Studio 1557", STAC_DELL_M6_DMIC),
1628 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
1629 "Dell Studio XPS 1645", STAC_DELL_M6_BOTH),
1630 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
1631 "Dell Studio 1558", STAC_DELL_M6_BOTH),
1635 static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1636 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1637 "Alienware M17x", STAC_ALIENWARE_M17X),
1638 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
1639 "Alienware M17x", STAC_ALIENWARE_M17X),
1643 static unsigned int ref92hd83xxx_pin_configs[10] = {
1644 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1645 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
1646 0x01451160, 0x98560170,
1649 static unsigned int dell_s14_pin_configs[10] = {
1650 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1651 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1652 0x40f000f0, 0x40f000f0,
1655 static unsigned int hp_dv7_4000_pin_configs[10] = {
1656 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
1657 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
1658 0x40f000f0, 0x40f000f0,
1661 static unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
1662 [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
1663 [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
1664 [STAC_DELL_S14] = dell_s14_pin_configs,
1665 [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
1668 static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
1669 [STAC_92HD83XXX_AUTO] = "auto",
1670 [STAC_92HD83XXX_REF] = "ref",
1671 [STAC_92HD83XXX_PWR_REF] = "mic-ref",
1672 [STAC_DELL_S14] = "dell-s14",
1673 [STAC_92HD83XXX_HP] = "hp",
1674 [STAC_HP_DV7_4000] = "hp-dv7-4000",
1677 static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1678 /* SigmaTel reference board */
1679 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1680 "DFI LanParty", STAC_92HD83XXX_REF),
1681 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1682 "DFI LanParty", STAC_92HD83XXX_REF),
1683 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
1684 "unknown Dell", STAC_DELL_S14),
1685 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x3600,
1686 "HP", STAC_92HD83XXX_HP),
1690 static unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1691 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
1692 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
1693 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
1697 static unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1698 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
1699 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
1700 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
1704 static unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1705 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1706 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
1707 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1711 static unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
1712 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
1713 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
1714 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
1718 static unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
1719 [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
1720 [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
1721 [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
1722 [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
1723 [STAC_HP_M4] = NULL,
1724 [STAC_HP_DV4] = NULL,
1725 [STAC_HP_DV5] = NULL,
1726 [STAC_HP_HDX] = NULL,
1727 [STAC_HP_DV4_1222NR] = NULL,
1730 static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
1731 [STAC_92HD71BXX_AUTO] = "auto",
1732 [STAC_92HD71BXX_REF] = "ref",
1733 [STAC_DELL_M4_1] = "dell-m4-1",
1734 [STAC_DELL_M4_2] = "dell-m4-2",
1735 [STAC_DELL_M4_3] = "dell-m4-3",
1736 [STAC_HP_M4] = "hp-m4",
1737 [STAC_HP_DV4] = "hp-dv4",
1738 [STAC_HP_DV5] = "hp-dv5",
1739 [STAC_HP_HDX] = "hp-hdx",
1740 [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
1743 static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1744 /* SigmaTel reference board */
1745 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1746 "DFI LanParty", STAC_92HD71BXX_REF),
1747 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1748 "DFI LanParty", STAC_92HD71BXX_REF),
1749 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
1750 "HP dv4-1222nr", STAC_HP_DV4_1222NR),
1751 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
1753 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
1755 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
1756 "HP dv4-7", STAC_HP_DV4),
1757 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
1758 "HP dv4-7", STAC_HP_DV5),
1759 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
1760 "HP HDX", STAC_HP_HDX), /* HDX18 */
1761 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
1762 "HP mini 1000", STAC_HP_M4),
1763 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1764 "HP HDX", STAC_HP_HDX), /* HDX16 */
1765 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1766 "HP dv6", STAC_HP_DV5),
1767 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
1768 "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
1769 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
1770 "HP DV6", STAC_HP_DV5),
1771 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1773 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1774 "unknown Dell", STAC_DELL_M4_1),
1775 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
1776 "unknown Dell", STAC_DELL_M4_1),
1777 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
1778 "unknown Dell", STAC_DELL_M4_1),
1779 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
1780 "unknown Dell", STAC_DELL_M4_1),
1781 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
1782 "unknown Dell", STAC_DELL_M4_1),
1783 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
1784 "unknown Dell", STAC_DELL_M4_1),
1785 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
1786 "unknown Dell", STAC_DELL_M4_1),
1787 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
1788 "unknown Dell", STAC_DELL_M4_2),
1789 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
1790 "unknown Dell", STAC_DELL_M4_2),
1791 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
1792 "unknown Dell", STAC_DELL_M4_2),
1793 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
1794 "unknown Dell", STAC_DELL_M4_2),
1795 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
1796 "unknown Dell", STAC_DELL_M4_3),
1800 static unsigned int ref922x_pin_configs[10] = {
1801 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
1802 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
1803 0x40000100, 0x40000100,
1807 STAC 922X pin configs for
1814 static unsigned int dell_922x_d81_pin_configs[10] = {
1815 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1816 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
1817 0x01813122, 0x400001f2,
1821 STAC 922X pin configs for
1825 static unsigned int dell_922x_d82_pin_configs[10] = {
1826 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
1827 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
1828 0x01813122, 0x400001f1,
1832 STAC 922X pin configs for
1835 static unsigned int dell_922x_m81_pin_configs[10] = {
1836 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
1837 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
1838 0x40C003f1, 0x405003f0,
1842 STAC 9221 A1 pin configs for
1843 102801D7 (Dell XPS M1210)
1845 static unsigned int dell_922x_m82_pin_configs[10] = {
1846 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
1847 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
1848 0x508003f3, 0x405003f4,
1851 static unsigned int d945gtp3_pin_configs[10] = {
1852 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
1853 0x40000100, 0x40000100, 0x40000100, 0x40000100,
1854 0x02a19120, 0x40000100,
1857 static unsigned int d945gtp5_pin_configs[10] = {
1858 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
1859 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
1860 0x02a19320, 0x40000100,
1863 static unsigned int intel_mac_v1_pin_configs[10] = {
1864 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
1865 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
1866 0x400000fc, 0x400000fb,
1869 static unsigned int intel_mac_v2_pin_configs[10] = {
1870 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1871 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
1872 0x400000fc, 0x400000fb,
1875 static unsigned int intel_mac_v3_pin_configs[10] = {
1876 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
1877 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
1878 0x400000fc, 0x400000fb,
1881 static unsigned int intel_mac_v4_pin_configs[10] = {
1882 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1883 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1884 0x400000fc, 0x400000fb,
1887 static unsigned int intel_mac_v5_pin_configs[10] = {
1888 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
1889 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
1890 0x400000fc, 0x400000fb,
1893 static unsigned int ecs202_pin_configs[10] = {
1894 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
1895 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
1896 0x9037012e, 0x40e000f2,
1899 static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
1900 [STAC_D945_REF] = ref922x_pin_configs,
1901 [STAC_D945GTP3] = d945gtp3_pin_configs,
1902 [STAC_D945GTP5] = d945gtp5_pin_configs,
1903 [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
1904 [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
1905 [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
1906 [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
1907 [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
1908 [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
1909 /* for backward compatibility */
1910 [STAC_MACMINI] = intel_mac_v3_pin_configs,
1911 [STAC_MACBOOK] = intel_mac_v5_pin_configs,
1912 [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
1913 [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
1914 [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
1915 [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
1916 [STAC_ECS_202] = ecs202_pin_configs,
1917 [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
1918 [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
1919 [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
1920 [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
1923 static const char * const stac922x_models[STAC_922X_MODELS] = {
1924 [STAC_922X_AUTO] = "auto",
1925 [STAC_D945_REF] = "ref",
1926 [STAC_D945GTP5] = "5stack",
1927 [STAC_D945GTP3] = "3stack",
1928 [STAC_INTEL_MAC_V1] = "intel-mac-v1",
1929 [STAC_INTEL_MAC_V2] = "intel-mac-v2",
1930 [STAC_INTEL_MAC_V3] = "intel-mac-v3",
1931 [STAC_INTEL_MAC_V4] = "intel-mac-v4",
1932 [STAC_INTEL_MAC_V5] = "intel-mac-v5",
1933 [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
1934 /* for backward compatibility */
1935 [STAC_MACMINI] = "macmini",
1936 [STAC_MACBOOK] = "macbook",
1937 [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
1938 [STAC_MACBOOK_PRO_V2] = "macbook-pro",
1939 [STAC_IMAC_INTEL] = "imac-intel",
1940 [STAC_IMAC_INTEL_20] = "imac-intel-20",
1941 [STAC_ECS_202] = "ecs202",
1942 [STAC_922X_DELL_D81] = "dell-d81",
1943 [STAC_922X_DELL_D82] = "dell-d82",
1944 [STAC_922X_DELL_M81] = "dell-m81",
1945 [STAC_922X_DELL_M82] = "dell-m82",
1948 static struct snd_pci_quirk stac922x_cfg_tbl[] = {
1949 /* SigmaTel reference board */
1950 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1951 "DFI LanParty", STAC_D945_REF),
1952 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1953 "DFI LanParty", STAC_D945_REF),
1954 /* Intel 945G based systems */
1955 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
1956 "Intel D945G", STAC_D945GTP3),
1957 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
1958 "Intel D945G", STAC_D945GTP3),
1959 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
1960 "Intel D945G", STAC_D945GTP3),
1961 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
1962 "Intel D945G", STAC_D945GTP3),
1963 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
1964 "Intel D945G", STAC_D945GTP3),
1965 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
1966 "Intel D945G", STAC_D945GTP3),
1967 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
1968 "Intel D945G", STAC_D945GTP3),
1969 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
1970 "Intel D945G", STAC_D945GTP3),
1971 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
1972 "Intel D945G", STAC_D945GTP3),
1973 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
1974 "Intel D945G", STAC_D945GTP3),
1975 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
1976 "Intel D945G", STAC_D945GTP3),
1977 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
1978 "Intel D945G", STAC_D945GTP3),
1979 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
1980 "Intel D945G", STAC_D945GTP3),
1981 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
1982 "Intel D945G", STAC_D945GTP3),
1983 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
1984 "Intel D945G", STAC_D945GTP3),
1985 /* Intel D945G 5-stack systems */
1986 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
1987 "Intel D945G", STAC_D945GTP5),
1988 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
1989 "Intel D945G", STAC_D945GTP5),
1990 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
1991 "Intel D945G", STAC_D945GTP5),
1992 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
1993 "Intel D945G", STAC_D945GTP5),
1994 /* Intel 945P based systems */
1995 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
1996 "Intel D945P", STAC_D945GTP3),
1997 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
1998 "Intel D945P", STAC_D945GTP3),
1999 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
2000 "Intel D945P", STAC_D945GTP3),
2001 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
2002 "Intel D945P", STAC_D945GTP3),
2003 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
2004 "Intel D945P", STAC_D945GTP3),
2005 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
2006 "Intel D945P", STAC_D945GTP5),
2008 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
2009 "Intel D945", STAC_D945_REF),
2011 /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
2012 SND_PCI_QUIRK(0x8384, 0x7680,
2013 "Mac", STAC_INTEL_MAC_AUTO),
2015 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
2016 "unknown Dell", STAC_922X_DELL_D81),
2017 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
2018 "unknown Dell", STAC_922X_DELL_D81),
2019 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
2020 "unknown Dell", STAC_922X_DELL_D81),
2021 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
2022 "unknown Dell", STAC_922X_DELL_D82),
2023 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
2024 "unknown Dell", STAC_922X_DELL_M81),
2025 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
2026 "unknown Dell", STAC_922X_DELL_D82),
2027 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
2028 "unknown Dell", STAC_922X_DELL_D81),
2029 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
2030 "unknown Dell", STAC_922X_DELL_D81),
2031 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
2032 "Dell XPS M1210", STAC_922X_DELL_M82),
2033 /* ECS/PC Chips boards */
2034 SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
2035 "ECS/PC chips", STAC_ECS_202),
2039 static unsigned int ref927x_pin_configs[14] = {
2040 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2041 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
2042 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
2043 0x01c42190, 0x40000100,
2046 static unsigned int d965_3st_pin_configs[14] = {
2047 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
2048 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
2049 0x40000100, 0x40000100, 0x40000100, 0x40000100,
2050 0x40000100, 0x40000100
2053 static unsigned int d965_5st_pin_configs[14] = {
2054 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
2055 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2056 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2057 0x40000100, 0x40000100
2060 static unsigned int d965_5st_no_fp_pin_configs[14] = {
2061 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
2062 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
2063 0x40000100, 0x40000100, 0x40000100, 0x01442070,
2064 0x40000100, 0x40000100
2067 static unsigned int dell_3st_pin_configs[14] = {
2068 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
2069 0x01111212, 0x01116211, 0x01813050, 0x01112214,
2070 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
2071 0x40c003fc, 0x40000100
2074 static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2075 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2076 [STAC_D965_REF] = ref927x_pin_configs,
2077 [STAC_D965_3ST] = d965_3st_pin_configs,
2078 [STAC_D965_5ST] = d965_5st_pin_configs,
2079 [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
2080 [STAC_DELL_3ST] = dell_3st_pin_configs,
2081 [STAC_DELL_BIOS] = NULL,
2082 [STAC_927X_VOLKNOB] = NULL,
2085 static const char * const stac927x_models[STAC_927X_MODELS] = {
2086 [STAC_927X_AUTO] = "auto",
2087 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2088 [STAC_D965_REF] = "ref",
2089 [STAC_D965_3ST] = "3stack",
2090 [STAC_D965_5ST] = "5stack",
2091 [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
2092 [STAC_DELL_3ST] = "dell-3stack",
2093 [STAC_DELL_BIOS] = "dell-bios",
2094 [STAC_927X_VOLKNOB] = "volknob",
2097 static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2098 /* SigmaTel reference board */
2099 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2100 "DFI LanParty", STAC_D965_REF),
2101 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2102 "DFI LanParty", STAC_D965_REF),
2103 /* Intel 946 based systems */
2104 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
2105 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
2106 /* 965 based 3 stack systems */
2107 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
2108 "Intel D965", STAC_D965_3ST),
2109 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
2110 "Intel D965", STAC_D965_3ST),
2111 /* Dell 3 stack systems */
2112 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
2113 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
2114 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
2115 /* Dell 3 stack systems with verb table in BIOS */
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2117 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2119 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2120 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2121 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2122 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2123 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
2124 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
2125 /* 965 based 5 stack systems */
2126 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
2127 "Intel D965", STAC_D965_5ST),
2128 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
2129 "Intel D965", STAC_D965_5ST),
2130 /* volume-knob fixes */
2131 SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
2135 static unsigned int ref9205_pin_configs[12] = {
2136 0x40000100, 0x40000100, 0x01016011, 0x01014010,
2137 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
2138 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
2142 STAC 9205 pin configs for
2149 10280228 (Dell Vostro 1500)
2150 10280229 (Dell Vostro 1700)
2152 static unsigned int dell_9205_m42_pin_configs[12] = {
2153 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
2154 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
2155 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
2159 STAC 9205 pin configs for
2163 102801FF (Dell Precision M4300)
2168 static unsigned int dell_9205_m43_pin_configs[12] = {
2169 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
2170 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
2171 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
2174 static unsigned int dell_9205_m44_pin_configs[12] = {
2175 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
2176 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
2177 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
2180 static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
2181 [STAC_9205_REF] = ref9205_pin_configs,
2182 [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
2183 [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
2184 [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
2185 [STAC_9205_EAPD] = NULL,
2188 static const char * const stac9205_models[STAC_9205_MODELS] = {
2189 [STAC_9205_AUTO] = "auto",
2190 [STAC_9205_REF] = "ref",
2191 [STAC_9205_DELL_M42] = "dell-m42",
2192 [STAC_9205_DELL_M43] = "dell-m43",
2193 [STAC_9205_DELL_M44] = "dell-m44",
2194 [STAC_9205_EAPD] = "eapd",
2197 static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2198 /* SigmaTel reference board */
2199 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2200 "DFI LanParty", STAC_9205_REF),
2201 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2202 "SigmaTel", STAC_9205_REF),
2203 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2204 "DFI LanParty", STAC_9205_REF),
2206 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
2207 "unknown Dell", STAC_9205_DELL_M42),
2208 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
2209 "unknown Dell", STAC_9205_DELL_M42),
2210 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
2211 "Dell Precision", STAC_9205_DELL_M43),
2212 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
2213 "Dell Precision", STAC_9205_DELL_M43),
2214 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
2215 "Dell Precision", STAC_9205_DELL_M43),
2216 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
2217 "unknown Dell", STAC_9205_DELL_M42),
2218 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
2219 "unknown Dell", STAC_9205_DELL_M42),
2220 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
2221 "Dell Precision", STAC_9205_DELL_M43),
2222 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
2223 "Dell Precision M4300", STAC_9205_DELL_M43),
2224 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
2225 "unknown Dell", STAC_9205_DELL_M42),
2226 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
2227 "Dell Precision", STAC_9205_DELL_M43),
2228 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
2229 "Dell Precision", STAC_9205_DELL_M43),
2230 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
2231 "Dell Precision", STAC_9205_DELL_M43),
2232 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
2233 "Dell Inspiron", STAC_9205_DELL_M44),
2234 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2235 "Dell Vostro 1500", STAC_9205_DELL_M42),
2236 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
2237 "Dell Vostro 1700", STAC_9205_DELL_M42),
2239 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2240 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2244 static void stac92xx_set_config_regs(struct hda_codec *codec,
2245 unsigned int *pincfgs)
2248 struct sigmatel_spec *spec = codec->spec;
2253 for (i = 0; i < spec->num_pins; i++)
2254 if (spec->pin_nids[i] && pincfgs[i])
2255 snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
2260 * Analog playback callbacks
2262 static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
2263 struct hda_codec *codec,
2264 struct snd_pcm_substream *substream)
2266 struct sigmatel_spec *spec = codec->spec;
2267 if (spec->stream_delay)
2268 msleep(spec->stream_delay);
2269 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2273 static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2274 struct hda_codec *codec,
2275 unsigned int stream_tag,
2276 unsigned int format,
2277 struct snd_pcm_substream *substream)
2279 struct sigmatel_spec *spec = codec->spec;
2280 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
2283 static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2284 struct hda_codec *codec,
2285 struct snd_pcm_substream *substream)
2287 struct sigmatel_spec *spec = codec->spec;
2288 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2292 * Digital playback callbacks
2294 static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2295 struct hda_codec *codec,
2296 struct snd_pcm_substream *substream)
2298 struct sigmatel_spec *spec = codec->spec;
2299 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2302 static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2303 struct hda_codec *codec,
2304 struct snd_pcm_substream *substream)
2306 struct sigmatel_spec *spec = codec->spec;
2307 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2310 static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2311 struct hda_codec *codec,
2312 unsigned int stream_tag,
2313 unsigned int format,
2314 struct snd_pcm_substream *substream)
2316 struct sigmatel_spec *spec = codec->spec;
2317 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2318 stream_tag, format, substream);
2321 static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2322 struct hda_codec *codec,
2323 struct snd_pcm_substream *substream)
2325 struct sigmatel_spec *spec = codec->spec;
2326 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
2331 * Analog capture callbacks
2333 static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
2334 struct hda_codec *codec,
2335 unsigned int stream_tag,
2336 unsigned int format,
2337 struct snd_pcm_substream *substream)
2339 struct sigmatel_spec *spec = codec->spec;
2340 hda_nid_t nid = spec->adc_nids[substream->number];
2342 if (spec->powerdown_adcs) {
2344 snd_hda_codec_write(codec, nid, 0,
2345 AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
2347 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
2351 static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
2352 struct hda_codec *codec,
2353 struct snd_pcm_substream *substream)
2355 struct sigmatel_spec *spec = codec->spec;
2356 hda_nid_t nid = spec->adc_nids[substream->number];
2358 snd_hda_codec_cleanup_stream(codec, nid);
2359 if (spec->powerdown_adcs)
2360 snd_hda_codec_write(codec, nid, 0,
2361 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
2365 static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
2369 /* NID is set in stac92xx_build_pcms */
2371 .open = stac92xx_dig_playback_pcm_open,
2372 .close = stac92xx_dig_playback_pcm_close,
2373 .prepare = stac92xx_dig_playback_pcm_prepare,
2374 .cleanup = stac92xx_dig_playback_pcm_cleanup
2378 static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
2382 /* NID is set in stac92xx_build_pcms */
2385 static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
2389 .nid = 0x02, /* NID to query formats and rates */
2391 .open = stac92xx_playback_pcm_open,
2392 .prepare = stac92xx_playback_pcm_prepare,
2393 .cleanup = stac92xx_playback_pcm_cleanup
2397 static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
2401 .nid = 0x06, /* NID to query formats and rates */
2403 .open = stac92xx_playback_pcm_open,
2404 .prepare = stac92xx_playback_pcm_prepare,
2405 .cleanup = stac92xx_playback_pcm_cleanup
2409 static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
2412 /* NID + .substreams is set in stac92xx_build_pcms */
2414 .prepare = stac92xx_capture_pcm_prepare,
2415 .cleanup = stac92xx_capture_pcm_cleanup
2419 static int stac92xx_build_pcms(struct hda_codec *codec)
2421 struct sigmatel_spec *spec = codec->spec;
2422 struct hda_pcm *info = spec->pcm_rec;
2424 codec->num_pcms = 1;
2425 codec->pcm_info = info;
2427 info->name = "STAC92xx Analog";
2428 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
2429 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2430 spec->multiout.dac_nids[0];
2431 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
2432 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2433 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
2435 if (spec->alt_switch) {
2438 info->name = "STAC92xx Analog Alt";
2439 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
2442 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
2445 info->name = "STAC92xx Digital";
2446 info->pcm_type = spec->autocfg.dig_out_type[0];
2447 if (spec->multiout.dig_out_nid) {
2448 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
2449 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2451 if (spec->dig_in_nid) {
2452 info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
2453 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2460 static unsigned int stac92xx_get_default_vref(struct hda_codec *codec,
2463 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
2464 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
2465 if (pincap & AC_PINCAP_VREF_100)
2466 return AC_PINCTL_VREF_100;
2467 if (pincap & AC_PINCAP_VREF_80)
2468 return AC_PINCTL_VREF_80;
2469 if (pincap & AC_PINCAP_VREF_50)
2470 return AC_PINCTL_VREF_50;
2471 if (pincap & AC_PINCAP_VREF_GRD)
2472 return AC_PINCTL_VREF_GRD;
2476 static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
2479 snd_hda_codec_write_cache(codec, nid, 0,
2480 AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
2483 #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
2485 static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2486 struct snd_ctl_elem_value *ucontrol)
2488 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2489 struct sigmatel_spec *spec = codec->spec;
2491 ucontrol->value.integer.value[0] = !!spec->hp_switch;
2495 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2497 static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2498 struct snd_ctl_elem_value *ucontrol)
2500 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2501 struct sigmatel_spec *spec = codec->spec;
2502 int nid = kcontrol->private_value;
2504 spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
2506 /* check to be sure that the ports are upto date with
2509 stac_issue_unsol_event(codec, nid);
2514 static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
2515 struct snd_ctl_elem_info *uinfo)
2518 static char *texts[] = {
2519 "Mic In", "Line In", "Line Out"
2522 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2523 struct sigmatel_spec *spec = codec->spec;
2524 hda_nid_t nid = kcontrol->private_value;
2526 if (nid == spec->mic_switch || nid == spec->line_switch)
2531 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2532 uinfo->value.enumerated.items = i;
2534 if (uinfo->value.enumerated.item >= i)
2535 uinfo->value.enumerated.item = i-1;
2536 strcpy(uinfo->value.enumerated.name,
2537 texts[uinfo->value.enumerated.item]);
2542 static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
2543 struct snd_ctl_elem_value *ucontrol)
2545 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2546 hda_nid_t nid = kcontrol->private_value;
2547 unsigned int vref = stac92xx_vref_get(codec, nid);
2549 if (vref == stac92xx_get_default_vref(codec, nid))
2550 ucontrol->value.enumerated.item[0] = 0;
2551 else if (vref == AC_PINCTL_VREF_GRD)
2552 ucontrol->value.enumerated.item[0] = 1;
2553 else if (vref == AC_PINCTL_VREF_HIZ)
2554 ucontrol->value.enumerated.item[0] = 2;
2559 static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
2560 struct snd_ctl_elem_value *ucontrol)
2562 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2563 unsigned int new_vref = 0;
2565 hda_nid_t nid = kcontrol->private_value;
2567 if (ucontrol->value.enumerated.item[0] == 0)
2568 new_vref = stac92xx_get_default_vref(codec, nid);
2569 else if (ucontrol->value.enumerated.item[0] == 1)
2570 new_vref = AC_PINCTL_VREF_GRD;
2571 else if (ucontrol->value.enumerated.item[0] == 2)
2572 new_vref = AC_PINCTL_VREF_HIZ;
2576 if (new_vref != stac92xx_vref_get(codec, nid)) {
2577 error = stac92xx_vref_set(codec, nid, new_vref);
2584 static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
2585 struct snd_ctl_elem_info *uinfo)
2587 static char *texts[2];
2588 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2589 struct sigmatel_spec *spec = codec->spec;
2591 if (kcontrol->private_value == spec->line_switch)
2592 texts[0] = "Line In";
2594 texts[0] = "Mic In";
2595 texts[1] = "Line Out";
2596 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2597 uinfo->value.enumerated.items = 2;
2600 if (uinfo->value.enumerated.item >= 2)
2601 uinfo->value.enumerated.item = 1;
2602 strcpy(uinfo->value.enumerated.name,
2603 texts[uinfo->value.enumerated.item]);
2608 static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2610 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2611 struct sigmatel_spec *spec = codec->spec;
2612 hda_nid_t nid = kcontrol->private_value;
2613 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2615 ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
2619 static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
2621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2622 struct sigmatel_spec *spec = codec->spec;
2623 hda_nid_t nid = kcontrol->private_value;
2624 int io_idx = (nid == spec->mic_switch) ? 1 : 0;
2625 unsigned short val = !!ucontrol->value.enumerated.item[0];
2627 spec->io_switch[io_idx] = val;
2630 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
2632 unsigned int pinctl = AC_PINCTL_IN_EN;
2633 if (io_idx) /* set VREF for mic */
2634 pinctl |= stac92xx_get_default_vref(codec, nid);
2635 stac92xx_auto_set_pinctl(codec, nid, pinctl);
2638 /* check the auto-mute again: we need to mute/unmute the speaker
2639 * appropriately according to the pin direction
2641 if (spec->hp_detect)
2642 stac_issue_unsol_event(codec, nid);
2647 #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
2649 static int stac92xx_clfe_switch_get(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;
2655 ucontrol->value.integer.value[0] = spec->clfe_swap;
2659 static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
2660 struct snd_ctl_elem_value *ucontrol)
2662 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2663 struct sigmatel_spec *spec = codec->spec;
2664 hda_nid_t nid = kcontrol->private_value & 0xff;
2665 unsigned int val = !!ucontrol->value.integer.value[0];
2667 if (spec->clfe_swap == val)
2670 spec->clfe_swap = val;
2672 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
2673 spec->clfe_swap ? 0x4 : 0x0);
2678 #define STAC_CODEC_HP_SWITCH(xname) \
2679 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2682 .info = stac92xx_hp_switch_info, \
2683 .get = stac92xx_hp_switch_get, \
2684 .put = stac92xx_hp_switch_put, \
2687 #define STAC_CODEC_IO_SWITCH(xname, xpval) \
2688 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2691 .info = stac92xx_io_switch_info, \
2692 .get = stac92xx_io_switch_get, \
2693 .put = stac92xx_io_switch_put, \
2694 .private_value = xpval, \
2697 #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
2698 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2701 .info = stac92xx_clfe_switch_info, \
2702 .get = stac92xx_clfe_switch_get, \
2703 .put = stac92xx_clfe_switch_put, \
2704 .private_value = xpval, \
2708 STAC_CTL_WIDGET_VOL,
2709 STAC_CTL_WIDGET_MUTE,
2710 STAC_CTL_WIDGET_MUTE_BEEP,
2711 STAC_CTL_WIDGET_MONO_MUX,
2712 STAC_CTL_WIDGET_HP_SWITCH,
2713 STAC_CTL_WIDGET_IO_SWITCH,
2714 STAC_CTL_WIDGET_CLFE_SWITCH,
2715 STAC_CTL_WIDGET_DC_BIAS
2718 static struct snd_kcontrol_new stac92xx_control_templates[] = {
2719 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2720 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2721 HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
2723 STAC_CODEC_HP_SWITCH(NULL),
2724 STAC_CODEC_IO_SWITCH(NULL, 0),
2725 STAC_CODEC_CLFE_SWITCH(NULL, 0),
2726 DC_BIAS(NULL, 0, 0),
2729 /* add dynamic controls */
2730 static struct snd_kcontrol_new *
2731 stac_control_new(struct sigmatel_spec *spec,
2732 struct snd_kcontrol_new *ktemp,
2734 unsigned int subdev)
2736 struct snd_kcontrol_new *knew;
2738 snd_array_init(&spec->kctls, sizeof(*knew), 32);
2739 knew = snd_array_new(&spec->kctls);
2743 knew->name = kstrdup(name, GFP_KERNEL);
2746 memset(knew, 0, sizeof(*knew));
2747 spec->kctls.alloced--;
2750 knew->subdevice = subdev;
2754 static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
2755 struct snd_kcontrol_new *ktemp,
2756 int idx, const char *name,
2759 struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
2760 HDA_SUBDEV_AMP_FLAG);
2764 knew->private_value = val;
2768 static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
2769 int type, int idx, const char *name,
2772 return stac92xx_add_control_temp(spec,
2773 &stac92xx_control_templates[type],
2778 /* add dynamic controls */
2779 static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
2780 const char *name, unsigned long val)
2782 return stac92xx_add_control_idx(spec, type, 0, name, val);
2785 static struct snd_kcontrol_new stac_input_src_temp = {
2786 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2787 .name = "Input Source",
2788 .info = stac92xx_mux_enum_info,
2789 .get = stac92xx_mux_enum_get,
2790 .put = stac92xx_mux_enum_put,
2793 static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
2794 hda_nid_t nid, int idx)
2796 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
2798 struct sigmatel_spec *spec = codec->spec;
2801 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2802 if (stac92xx_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
2803 && nid == spec->line_switch)
2804 control = STAC_CTL_WIDGET_IO_SWITCH;
2805 else if (snd_hda_query_pin_caps(codec, nid)
2806 & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
2807 control = STAC_CTL_WIDGET_DC_BIAS;
2808 else if (nid == spec->mic_switch)
2809 control = STAC_CTL_WIDGET_IO_SWITCH;
2813 strcpy(name, hda_get_input_pin_label(codec, nid, 1));
2814 return stac92xx_add_control(codec->spec, control,
2815 strcat(name, " Jack Mode"), nid);
2821 static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2823 struct snd_kcontrol_new *knew;
2824 struct hda_input_mux *imux = &spec->private_imux;
2827 return 0; /* no need for input source */
2828 if (!spec->num_adcs || imux->num_items <= 1)
2829 return 0; /* no need for input source control */
2830 knew = stac_control_new(spec, &stac_input_src_temp,
2831 stac_input_src_temp.name, 0);
2834 knew->count = spec->num_adcs;
2838 /* check whether the line-input can be used as line-out */
2839 static hda_nid_t check_line_out_switch(struct hda_codec *codec)
2841 struct sigmatel_spec *spec = codec->spec;
2842 struct auto_pin_cfg *cfg = &spec->autocfg;
2844 unsigned int pincap;
2847 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2849 for (i = 0; i < cfg->num_inputs; i++) {
2850 if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
2851 nid = cfg->inputs[i].pin;
2852 pincap = snd_hda_query_pin_caps(codec, nid);
2853 if (pincap & AC_PINCAP_OUT)
2860 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
2862 /* check whether the mic-input can be used as line-out */
2863 static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
2865 struct sigmatel_spec *spec = codec->spec;
2866 struct auto_pin_cfg *cfg = &spec->autocfg;
2867 unsigned int def_conf, pincap;
2871 if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
2873 for (i = 0; i < cfg->num_inputs; i++) {
2874 hda_nid_t nid = cfg->inputs[i].pin;
2875 if (cfg->inputs[i].type != AUTO_PIN_MIC)
2877 def_conf = snd_hda_codec_get_pincfg(codec, nid);
2878 /* some laptops have an internal analog microphone
2879 * which can't be used as a output */
2880 if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
2881 pincap = snd_hda_query_pin_caps(codec, nid);
2882 if (pincap & AC_PINCAP_OUT) {
2883 *dac = get_unassigned_dac(codec, nid);
2892 static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2896 for (i = 0; i < spec->multiout.num_dacs; i++) {
2897 if (spec->multiout.dac_nids[i] == nid)
2904 static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
2907 if (is_in_dac_nids(spec, nid))
2909 for (i = 0; i < spec->autocfg.hp_outs; i++)
2910 if (spec->hp_dacs[i] == nid)
2912 for (i = 0; i < spec->autocfg.speaker_outs; i++)
2913 if (spec->speaker_dacs[i] == nid)
2918 static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
2920 struct sigmatel_spec *spec = codec->spec;
2922 hda_nid_t conn[HDA_MAX_CONNECTIONS];
2923 unsigned int wcaps, wtype;
2925 conn_len = snd_hda_get_connections(codec, nid, conn,
2926 HDA_MAX_CONNECTIONS);
2927 /* 92HD88: trace back up the link of nids to find the DAC */
2928 while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
2929 != AC_WID_AUD_OUT)) {
2931 conn_len = snd_hda_get_connections(codec, nid, conn,
2932 HDA_MAX_CONNECTIONS);
2934 for (j = 0; j < conn_len; j++) {
2935 wcaps = get_wcaps(codec, conn[j]);
2936 wtype = get_wcaps_type(wcaps);
2937 /* we check only analog outputs */
2938 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
2940 /* if this route has a free DAC, assign it */
2941 if (!check_all_dac_nids(spec, conn[j])) {
2943 /* select this DAC in the pin's input mux */
2944 snd_hda_codec_write_cache(codec, nid, 0,
2945 AC_VERB_SET_CONNECT_SEL, j);
2950 /* if all DACs are already assigned, connect to the primary DAC */
2952 for (j = 0; j < conn_len; j++) {
2953 if (conn[j] == spec->multiout.dac_nids[0]) {
2954 snd_hda_codec_write_cache(codec, nid, 0,
2955 AC_VERB_SET_CONNECT_SEL, j);
2963 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2964 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
2967 * Fill in the dac_nids table from the parsed pin configuration
2968 * This function only works when every pin in line_out_pins[]
2969 * contains atleast one DAC in its connection list. Some 92xx
2970 * codecs are not connected directly to a DAC, such as the 9200
2971 * and 9202/925x. For those, dac_nids[] must be hard-coded.
2973 static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
2975 struct sigmatel_spec *spec = codec->spec;
2976 struct auto_pin_cfg *cfg = &spec->autocfg;
2980 for (i = 0; i < cfg->line_outs; i++) {
2981 nid = cfg->line_out_pins[i];
2982 dac = get_unassigned_dac(codec, nid);
2984 if (spec->multiout.num_dacs > 0) {
2985 /* we have already working output pins,
2986 * so let's drop the broken ones again
2988 cfg->line_outs = spec->multiout.num_dacs;
2991 /* error out, no available DAC found */
2993 "%s: No available DAC for pin 0x%x\n",
2997 add_spec_dacs(spec, dac);
3000 for (i = 0; i < cfg->hp_outs; i++) {
3001 nid = cfg->hp_pins[i];
3002 dac = get_unassigned_dac(codec, nid);
3004 if (!spec->multiout.hp_nid)
3005 spec->multiout.hp_nid = dac;
3007 add_spec_extra_dacs(spec, dac);
3009 spec->hp_dacs[i] = dac;
3012 for (i = 0; i < cfg->speaker_outs; i++) {
3013 nid = cfg->speaker_pins[i];
3014 dac = get_unassigned_dac(codec, nid);
3016 add_spec_extra_dacs(spec, dac);
3017 spec->speaker_dacs[i] = dac;
3020 /* add line-in as output */
3021 nid = check_line_out_switch(codec);
3023 dac = get_unassigned_dac(codec, nid);
3025 snd_printdd("STAC: Add line-in 0x%x as output %d\n",
3026 nid, cfg->line_outs);
3027 cfg->line_out_pins[cfg->line_outs] = nid;
3029 spec->line_switch = nid;
3030 add_spec_dacs(spec, dac);
3033 /* add mic as output */
3034 nid = check_mic_out_switch(codec, &dac);
3036 snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
3037 nid, cfg->line_outs);
3038 cfg->line_out_pins[cfg->line_outs] = nid;
3040 spec->mic_switch = nid;
3041 add_spec_dacs(spec, dac);
3044 snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
3045 spec->multiout.num_dacs,
3046 spec->multiout.dac_nids[0],
3047 spec->multiout.dac_nids[1],
3048 spec->multiout.dac_nids[2],
3049 spec->multiout.dac_nids[3],
3050 spec->multiout.dac_nids[4]);
3055 /* create volume control/switch for the given prefx type */
3056 static int create_controls_idx(struct hda_codec *codec, const char *pfx,
3057 int idx, hda_nid_t nid, int chs)
3059 struct sigmatel_spec *spec = codec->spec;
3063 if (!spec->check_volume_offset) {
3064 unsigned int caps, step, nums, db_scale;
3065 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3066 step = (caps & AC_AMPCAP_STEP_SIZE) >>
3067 AC_AMPCAP_STEP_SIZE_SHIFT;
3068 step = (step + 1) * 25; /* in .01dB unit */
3069 nums = (caps & AC_AMPCAP_NUM_STEPS) >>
3070 AC_AMPCAP_NUM_STEPS_SHIFT;
3071 db_scale = nums * step;
3072 /* if dB scale is over -64dB, and finer enough,
3073 * let's reduce it to half
3075 if (db_scale > 6400 && nums >= 0x1f)
3076 spec->volume_offset = nums / 2;
3077 spec->check_volume_offset = 1;
3080 sprintf(name, "%s Playback Volume", pfx);
3081 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
3082 HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
3083 spec->volume_offset));
3086 sprintf(name, "%s Playback Switch", pfx);
3087 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
3088 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
3094 #define create_controls(codec, pfx, nid, chs) \
3095 create_controls_idx(codec, pfx, 0, nid, chs)
3097 static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3099 if (spec->multiout.num_dacs > 4) {
3100 printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
3103 spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
3104 spec->multiout.num_dacs++;
3109 static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
3112 for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
3113 if (!spec->multiout.extra_out_nid[i]) {
3114 spec->multiout.extra_out_nid[i] = nid;
3118 printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
3122 /* Create output controls
3123 * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
3125 static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3126 const hda_nid_t *pins,
3127 const hda_nid_t *dac_nids,
3130 struct sigmatel_spec *spec = codec->spec;
3131 static const char * const chname[4] = {
3132 "Front", "Surround", NULL /*CLFE*/, "Side"
3136 unsigned int wid_caps;
3138 for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
3139 if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
3140 wid_caps = get_wcaps(codec, pins[i]);
3141 if (wid_caps & AC_WCAP_UNSOL_CAP)
3142 spec->hp_detect = 1;
3147 if (type != AUTO_PIN_HP_OUT && i == 2) {
3149 err = create_controls(codec, "Center", nid, 1);
3152 err = create_controls(codec, "LFE", nid, 2);
3156 wid_caps = get_wcaps(codec, nid);
3158 if (wid_caps & AC_WCAP_LR_SWAP) {
3159 err = stac92xx_add_control(spec,
3160 STAC_CTL_WIDGET_CLFE_SWITCH,
3161 "Swap Center/LFE Playback Switch", nid);
3171 case AUTO_PIN_HP_OUT:
3175 case AUTO_PIN_SPEAKER_OUT:
3184 err = create_controls_idx(codec, name, idx, nid, 3);
3192 static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3193 unsigned long sw, int idx)
3196 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3197 "Capture Volume", vol);
3200 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3201 "Capture Switch", sw);
3207 /* add playback controls from the parsed DAC table */
3208 static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3209 const struct auto_pin_cfg *cfg)
3211 struct sigmatel_spec *spec = codec->spec;
3216 err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
3217 spec->multiout.dac_nids,
3218 cfg->line_out_type);
3222 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
3223 err = stac92xx_add_control(spec,
3224 STAC_CTL_WIDGET_HP_SWITCH,
3225 "Headphone as Line Out Switch",
3226 cfg->hp_pins[cfg->hp_outs - 1]);
3231 for (idx = 0; idx < cfg->num_inputs; idx++) {
3232 if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
3234 nid = cfg->inputs[idx].pin;
3235 err = stac92xx_add_jack_mode_control(codec, nid, idx);
3243 /* add playback controls for Speaker and HP outputs */
3244 static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
3245 struct auto_pin_cfg *cfg)
3247 struct sigmatel_spec *spec = codec->spec;
3250 err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
3251 spec->hp_dacs, AUTO_PIN_HP_OUT);
3255 err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
3256 spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
3263 /* labels for mono mux outputs */
3264 static const char * const stac92xx_mono_labels[4] = {
3265 "DAC0", "DAC1", "Mixer", "DAC2"
3268 /* create mono mux for mono out on capable codecs */
3269 static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3271 struct sigmatel_spec *spec = codec->spec;
3272 struct hda_input_mux *mono_mux = &spec->private_mono_mux;
3274 hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
3276 num_cons = snd_hda_get_connections(codec,
3279 HDA_MAX_NUM_INPUTS);
3280 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3283 for (i = 0; i < num_cons; i++)
3284 snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
3287 return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
3288 "Mono Mux", spec->mono_nid);
3291 /* create PC beep volume controls */
3292 static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3295 struct sigmatel_spec *spec = codec->spec;
3296 u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3297 int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
3299 if (spec->anabeep_nid == nid)
3300 type = STAC_CTL_WIDGET_MUTE;
3302 /* check for mute support for the the amp */
3303 if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
3304 err = stac92xx_add_control(spec, type,
3305 "Beep Playback Switch",
3306 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3311 /* check to see if there is volume support for the amp */
3312 if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3313 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
3314 "Beep Playback Volume",
3315 HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
3322 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3323 #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
3325 static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
3326 struct snd_ctl_elem_value *ucontrol)
3328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3329 ucontrol->value.integer.value[0] = codec->beep->enabled;
3333 static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
3334 struct snd_ctl_elem_value *ucontrol)
3336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3337 return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
3340 static struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
3341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3342 .info = stac92xx_dig_beep_switch_info,
3343 .get = stac92xx_dig_beep_switch_get,
3344 .put = stac92xx_dig_beep_switch_put,
3347 static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3349 return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
3350 0, "Beep Playback Switch", 0);
3354 static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3356 struct sigmatel_spec *spec = codec->spec;
3359 for (i = 0; i < spec->num_muxes; i++) {
3364 nid = spec->mux_nids[i];
3365 wcaps = get_wcaps(codec, nid);
3366 if (!(wcaps & AC_WCAP_OUT_AMP))
3369 /* check whether already the same control was created as
3370 * normal Capture Volume.
3372 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3373 for (j = 0; j < spec->num_caps; j++) {
3374 if (spec->capvols[j] == val)
3377 if (j < spec->num_caps)
3380 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3381 "Mux Capture Volume", val);
3388 static const char * const stac92xx_spdif_labels[3] = {
3389 "Digital Playback", "Analog Mux 1", "Analog Mux 2",
3392 static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3394 struct sigmatel_spec *spec = codec->spec;
3395 struct hda_input_mux *spdif_mux = &spec->private_smux;
3396 const char * const *labels = spec->spdif_labels;
3398 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
3400 num_cons = snd_hda_get_connections(codec,
3403 HDA_MAX_NUM_INPUTS);
3408 labels = stac92xx_spdif_labels;
3410 for (i = 0; i < num_cons; i++)
3411 snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
3416 /* labels for dmic mux inputs */
3417 static const char * const stac92xx_dmic_labels[5] = {
3418 "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
3419 "Digital Mic 3", "Digital Mic 4"
3422 static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3425 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3428 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3429 for (i = 0; i < nums; i++)
3435 /* create a volume assigned to the given pin (only if supported) */
3436 /* return 1 if the volume control is created */
3437 static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3438 const char *label, int idx, int direction)
3440 unsigned int caps, nums;
3444 if (direction == HDA_OUTPUT)
3445 caps = AC_WCAP_OUT_AMP;
3447 caps = AC_WCAP_IN_AMP;
3448 if (!(get_wcaps(codec, nid) & caps))
3450 caps = query_amp_caps(codec, nid, direction);
3451 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3454 snprintf(name, sizeof(name), "%s Capture Volume", label);
3455 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
3456 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3462 /* create playback/capture controls for input pins on dmic capable codecs */
3463 static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3464 const struct auto_pin_cfg *cfg)
3466 struct sigmatel_spec *spec = codec->spec;
3467 struct hda_input_mux *imux = &spec->private_imux;
3468 struct hda_input_mux *dimux = &spec->private_dimux;
3470 unsigned int def_conf;
3472 snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
3474 for (i = 0; i < spec->num_dmics; i++) {
3476 int index, type_idx;
3479 nid = spec->dmic_nids[i];
3480 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3482 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3483 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3486 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3490 label = hda_get_input_pin_label(codec, nid, 1);
3491 snd_hda_add_imux_item(dimux, label, index, &type_idx);
3492 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
3493 snd_hda_add_imux_item(imux, label, index, &type_idx);
3495 err = create_elem_capture_vol(codec, nid, label, type_idx,
3500 err = create_elem_capture_vol(codec, nid, label,
3501 type_idx, HDA_OUTPUT);
3510 static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3511 hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
3517 cfg = snd_hda_codec_get_pincfg(codec, nid);
3518 switch (snd_hda_get_input_pin_attr(cfg)) {
3519 case INPUT_PIN_ATTR_INT:
3521 return 1; /* already occupied */
3524 case INPUT_PIN_ATTR_UNUSED:
3526 case INPUT_PIN_ATTR_DOCK:
3528 return 1; /* already occupied */
3533 return 1; /* already occupied */
3540 static int set_mic_route(struct hda_codec *codec,
3541 struct sigmatel_mic_route *mic,
3544 struct sigmatel_spec *spec = codec->spec;
3545 struct auto_pin_cfg *cfg = &spec->autocfg;
3551 for (i = 0; i < cfg->num_inputs; i++) {
3552 if (pin == cfg->inputs[i].pin)
3555 if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
3557 i = get_connection_index(codec, spec->mux_nids[0], pin);
3562 if (spec->dmux_nids)
3563 mic->dmux_idx = get_connection_index(codec,
3566 } else if (spec->dmux_nids) {
3568 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3574 mic->mux_idx = get_connection_index(codec,
3576 spec->dmux_nids[0]);
3581 /* return non-zero if the device is for automatic mic switch */
3582 static int stac_check_auto_mic(struct hda_codec *codec)
3584 struct sigmatel_spec *spec = codec->spec;
3585 struct auto_pin_cfg *cfg = &spec->autocfg;
3586 hda_nid_t fixed, ext, dock;
3589 for (i = 0; i < cfg->num_inputs; i++) {
3590 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
3591 return 0; /* must be exclusively mics */
3593 fixed = ext = dock = 0;
3594 for (i = 0; i < cfg->num_inputs; i++)
3595 if (check_mic_pin(codec, cfg->inputs[i].pin,
3596 &fixed, &ext, &dock))
3598 for (i = 0; i < spec->num_dmics; i++)
3599 if (check_mic_pin(codec, spec->dmic_nids[i],
3600 &fixed, &ext, &dock))
3602 if (!fixed || (!ext && !dock))
3603 return 0; /* no input to switch */
3604 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3605 return 0; /* no unsol support */
3606 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3607 set_mic_route(codec, &spec->int_mic, fixed) ||
3608 set_mic_route(codec, &spec->dock_mic, dock))
3609 return 0; /* something is wrong */
3613 /* create playback/capture controls for input pins */
3614 static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3616 struct sigmatel_spec *spec = codec->spec;
3617 struct hda_input_mux *imux = &spec->private_imux;
3621 for (i = 0; i < cfg->num_inputs; i++) {
3622 hda_nid_t nid = cfg->inputs[i].pin;
3623 int index, err, type_idx;
3626 for (j = 0; j < spec->num_muxes; j++) {
3627 index = get_connection_index(codec, spec->mux_nids[j],
3635 label = hda_get_autocfg_input_label(codec, cfg, i);
3636 snd_hda_add_imux_item(imux, label, index, &type_idx);
3638 err = create_elem_capture_vol(codec, nid,
3644 spec->num_analog_muxes = imux->num_items;
3646 if (imux->num_items) {
3648 * Set the current input for the muxes.
3649 * The STAC9221 has two input muxes with identical source
3650 * NID lists. Hopefully this won't get confused.
3652 for (i = 0; i < spec->num_muxes; i++) {
3653 snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
3654 AC_VERB_SET_CONNECT_SEL,
3655 imux->items[0].index);
3662 static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
3664 struct sigmatel_spec *spec = codec->spec;
3667 for (i = 0; i < spec->autocfg.line_outs; i++) {
3668 hda_nid_t nid = spec->autocfg.line_out_pins[i];
3669 stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
3673 static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
3675 struct sigmatel_spec *spec = codec->spec;
3678 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3680 pin = spec->autocfg.hp_pins[i];
3681 if (pin) /* connect to front */
3682 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
3684 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
3686 pin = spec->autocfg.speaker_pins[i];
3687 if (pin) /* connect to front */
3688 stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
3692 static int is_dual_headphones(struct hda_codec *codec)
3694 struct sigmatel_spec *spec = codec->spec;
3697 if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
3698 spec->autocfg.hp_outs <= 1)
3701 for (i = 0; i < spec->autocfg.hp_outs; i++) {
3702 hda_nid_t nid = spec->autocfg.hp_pins[i];
3703 unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
3704 if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
3708 return (valid_hps > 1);
3712 static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
3714 struct sigmatel_spec *spec = codec->spec;
3718 if ((err = snd_hda_parse_pin_def_config(codec,
3720 spec->dmic_nids)) < 0)
3722 if (! spec->autocfg.line_outs)
3723 return 0; /* can't find valid pin config */
3725 /* If we have no real line-out pin and multiple hp-outs, HPs should
3726 * be set up as multi-channel outputs.
3728 if (is_dual_headphones(codec)) {
3729 /* Copy hp_outs to line_outs, backup line_outs in
3730 * speaker_outs so that the following routines can handle
3731 * HP pins as primary outputs.
3733 snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
3734 memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
3735 sizeof(spec->autocfg.line_out_pins));
3736 spec->autocfg.speaker_outs = spec->autocfg.line_outs;
3737 memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
3738 sizeof(spec->autocfg.hp_pins));
3739 spec->autocfg.line_outs = spec->autocfg.hp_outs;
3740 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3741 spec->autocfg.hp_outs = 0;
3744 if (spec->autocfg.mono_out_pin) {
3745 int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
3746 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3747 u32 caps = query_amp_caps(codec,
3748 spec->autocfg.mono_out_pin, dir);
3749 hda_nid_t conn_list[1];
3751 /* get the mixer node and then the mono mux if it exists */
3752 if (snd_hda_get_connections(codec,
3753 spec->autocfg.mono_out_pin, conn_list, 1) &&
3754 snd_hda_get_connections(codec, conn_list[0],
3755 conn_list, 1) > 0) {
3757 int wcaps = get_wcaps(codec, conn_list[0]);
3758 int wid_type = get_wcaps_type(wcaps);
3759 /* LR swap check, some stac925x have a mux that
3760 * changes the DACs output path instead of the
3763 if (wid_type == AC_WID_AUD_SEL &&
3764 !(wcaps & AC_WCAP_LR_SWAP))
3765 spec->mono_nid = conn_list[0];
3768 hda_nid_t nid = spec->autocfg.mono_out_pin;
3770 /* most mono outs have a least a mute/unmute switch */
3771 dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
3772 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
3773 "Mono Playback Switch",
3774 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3777 /* check for volume support for the amp */
3778 if ((caps & AC_AMPCAP_NUM_STEPS)
3779 >> AC_AMPCAP_NUM_STEPS_SHIFT) {
3780 err = stac92xx_add_control(spec,
3781 STAC_CTL_WIDGET_VOL,
3782 "Mono Playback Volume",
3783 HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
3789 stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
3793 if (!spec->multiout.num_dacs) {
3794 err = stac92xx_auto_fill_dac_nids(codec);
3797 err = stac92xx_auto_create_multi_out_ctls(codec,
3803 /* setup analog beep controls */
3804 if (spec->anabeep_nid > 0) {
3805 err = stac92xx_auto_create_beep_ctls(codec,
3811 /* setup digital beep controls and input device */
3812 #ifdef CONFIG_SND_HDA_INPUT_BEEP
3813 if (spec->digbeep_nid > 0) {
3814 hda_nid_t nid = spec->digbeep_nid;
3817 err = stac92xx_auto_create_beep_ctls(codec, nid);
3820 err = snd_hda_attach_beep_device(codec, nid);
3824 /* IDT/STAC codecs have linear beep tone parameter */
3825 codec->beep->linear_tone = spec->linear_tone_beep;
3826 /* if no beep switch is available, make its own one */
3827 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
3828 if (!(caps & AC_AMPCAP_MUTE)) {
3829 err = stac92xx_beep_switch_ctl(codec);
3837 err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
3841 /* All output parsing done, now restore the swapped hp pins */
3843 memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
3844 sizeof(spec->autocfg.hp_pins));
3845 spec->autocfg.hp_outs = spec->autocfg.line_outs;
3846 spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
3847 spec->autocfg.line_outs = 0;
3850 if (stac_check_auto_mic(codec)) {
3852 /* only one capture for auto-mic */
3855 spec->num_muxes = 1;
3858 for (i = 0; i < spec->num_caps; i++) {
3859 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3860 spec->capsws[i], i);
3865 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3869 if (spec->mono_nid > 0) {
3870 err = stac92xx_auto_create_mono_output_ctls(codec);
3874 if (spec->num_dmics > 0 && !spec->dinput_mux)
3875 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3876 &spec->autocfg)) < 0)
3878 if (spec->num_muxes > 0) {
3879 err = stac92xx_auto_create_mux_input_ctls(codec);
3883 if (spec->num_smuxes > 0) {
3884 err = stac92xx_auto_create_spdif_mux_ctls(codec);
3889 err = stac92xx_add_input_source(spec);
3893 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3894 if (spec->multiout.max_channels > 2)
3895 spec->surr_switch = 1;
3897 if (spec->autocfg.dig_outs)
3898 spec->multiout.dig_out_nid = dig_out;
3899 if (dig_in && spec->autocfg.dig_in_pin)
3900 spec->dig_in_nid = dig_in;
3902 if (spec->kctls.list)
3903 spec->mixers[spec->num_mixers++] = spec->kctls.list;
3905 spec->input_mux = &spec->private_imux;
3906 if (!spec->dinput_mux)
3907 spec->dinput_mux = &spec->private_dimux;
3908 spec->sinput_mux = &spec->private_smux;
3909 spec->mono_mux = &spec->private_mono_mux;
3913 /* add playback controls for HP output */
3914 static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
3915 struct auto_pin_cfg *cfg)
3917 struct sigmatel_spec *spec = codec->spec;
3918 hda_nid_t pin = cfg->hp_pins[0];
3919 unsigned int wid_caps;
3924 wid_caps = get_wcaps(codec, pin);
3925 if (wid_caps & AC_WCAP_UNSOL_CAP)
3926 spec->hp_detect = 1;
3931 /* add playback controls for LFE output */
3932 static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
3933 struct auto_pin_cfg *cfg)
3935 struct sigmatel_spec *spec = codec->spec;
3937 hda_nid_t lfe_pin = 0x0;
3941 * search speaker outs and line outs for a mono speaker pin
3942 * with an amp. If one is found, add LFE controls
3945 for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
3946 hda_nid_t pin = spec->autocfg.speaker_pins[i];
3947 unsigned int wcaps = get_wcaps(codec, pin);
3948 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3949 if (wcaps == AC_WCAP_OUT_AMP)
3950 /* found a mono speaker with an amp, must be lfe */
3954 /* if speaker_outs is 0, then speakers may be in line_outs */
3955 if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
3956 for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
3957 hda_nid_t pin = spec->autocfg.line_out_pins[i];
3958 unsigned int defcfg;
3959 defcfg = snd_hda_codec_get_pincfg(codec, pin);
3960 if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
3961 unsigned int wcaps = get_wcaps(codec, pin);
3962 wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
3963 if (wcaps == AC_WCAP_OUT_AMP)
3964 /* found a mono speaker with an amp,
3972 err = create_controls(codec, "LFE", lfe_pin, 1);
3980 static int stac9200_parse_auto_config(struct hda_codec *codec)
3982 struct sigmatel_spec *spec = codec->spec;
3985 if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
3988 if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
3991 if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
3994 if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
3997 if (spec->num_muxes > 0) {
3998 err = stac92xx_auto_create_mux_input_ctls(codec);
4003 err = stac92xx_add_input_source(spec);
4007 if (spec->autocfg.dig_outs)
4008 spec->multiout.dig_out_nid = 0x05;
4009 if (spec->autocfg.dig_in_pin)
4010 spec->dig_in_nid = 0x04;
4012 if (spec->kctls.list)
4013 spec->mixers[spec->num_mixers++] = spec->kctls.list;
4015 spec->input_mux = &spec->private_imux;
4016 spec->dinput_mux = &spec->private_dimux;
4022 * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
4023 * funky external mute control using GPIO pins.
4026 static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
4027 unsigned int dir_mask, unsigned int data)
4029 unsigned int gpiostate, gpiomask, gpiodir;
4031 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
4032 AC_VERB_GET_GPIO_DATA, 0);
4033 gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
4035 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
4036 AC_VERB_GET_GPIO_MASK, 0);
4039 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
4040 AC_VERB_GET_GPIO_DIRECTION, 0);
4041 gpiodir |= dir_mask;
4043 /* Configure GPIOx as CMOS */
4044 snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
4046 snd_hda_codec_write(codec, codec->afg, 0,
4047 AC_VERB_SET_GPIO_MASK, gpiomask);
4048 snd_hda_codec_read(codec, codec->afg, 0,
4049 AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
4053 snd_hda_codec_read(codec, codec->afg, 0,
4054 AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
4057 #ifdef CONFIG_SND_HDA_INPUT_JACK
4058 static void stac92xx_free_jack_priv(struct snd_jack *jack)
4060 struct sigmatel_jack *jacks = jack->private_data;
4066 static int stac92xx_add_jack(struct hda_codec *codec,
4067 hda_nid_t nid, int type)
4069 #ifdef CONFIG_SND_HDA_INPUT_JACK
4070 struct sigmatel_spec *spec = codec->spec;
4071 struct sigmatel_jack *jack;
4072 int def_conf = snd_hda_codec_get_pincfg(codec, nid);
4073 int connectivity = get_defcfg_connect(def_conf);
4077 if (connectivity && connectivity != AC_JACK_PORT_FIXED)
4080 snd_array_init(&spec->jacks, sizeof(*jack), 32);
4081 jack = snd_array_new(&spec->jacks);
4087 snprintf(name, sizeof(name), "%s at %s %s Jack",
4088 snd_hda_get_jack_type(def_conf),
4089 snd_hda_get_jack_connectivity(def_conf),
4090 snd_hda_get_jack_location(def_conf));
4092 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
4097 jack->jack->private_data = jack;
4098 jack->jack->private_free = stac92xx_free_jack_priv;
4103 static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4104 unsigned char type, int data)
4106 struct sigmatel_event *event;
4108 snd_array_init(&spec->events, sizeof(*event), 32);
4109 event = snd_array_new(&spec->events);
4114 event->tag = spec->events.used;
4120 static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4123 struct sigmatel_spec *spec = codec->spec;
4124 struct sigmatel_event *event = spec->events.list;
4127 for (i = 0; i < spec->events.used; i++, event++) {
4128 if (event->nid == nid)
4134 static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4137 struct sigmatel_spec *spec = codec->spec;
4138 struct sigmatel_event *event = spec->events.list;
4141 for (i = 0; i < spec->events.used; i++, event++) {
4142 if (event->tag == tag)
4148 /* check if given nid is a valid pin and no other events are assigned
4149 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4150 * Otherwise, returns zero.
4152 static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4155 struct sigmatel_event *event;
4158 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4160 event = stac_get_event(codec, nid);
4162 if (event->type != type)
4166 tag = stac_add_event(codec->spec, nid, type, 0);
4170 snd_hda_codec_write_cache(codec, nid, 0,
4171 AC_VERB_SET_UNSOLICITED_ENABLE,
4176 static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
4179 for (i = 0; i < cfg->hp_outs; i++)
4180 if (cfg->hp_pins[i] == nid)
4181 return 1; /* nid is a HP-Out */
4183 return 0; /* nid is not a HP-Out */
4186 static void stac92xx_power_down(struct hda_codec *codec)
4188 struct sigmatel_spec *spec = codec->spec;
4190 /* power down inactive DACs */
4192 for (dac = spec->dac_list; *dac; dac++)
4193 if (!check_all_dac_nids(spec, *dac))
4194 snd_hda_codec_write(codec, *dac, 0,
4195 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4198 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4201 static inline int get_int_hint(struct hda_codec *codec, const char *key,
4205 p = snd_hda_get_hint(codec, key);
4208 if (!strict_strtoul(p, 0, &val)) {
4216 /* override some hints from the hwdep entry */
4217 static void stac_store_hints(struct hda_codec *codec)
4219 struct sigmatel_spec *spec = codec->spec;
4222 val = snd_hda_get_bool_hint(codec, "hp_detect");
4224 spec->hp_detect = val;
4225 if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
4226 spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
4229 if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
4230 spec->gpio_mask &= spec->gpio_mask;
4231 if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
4232 spec->gpio_dir &= spec->gpio_mask;
4233 if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
4234 spec->eapd_mask &= spec->gpio_mask;
4235 if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
4236 spec->gpio_mute &= spec->gpio_mask;
4237 val = snd_hda_get_bool_hint(codec, "eapd_switch");
4239 spec->eapd_switch = val;
4240 get_int_hint(codec, "gpio_led_polarity", &spec->gpio_led_polarity);
4241 if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
4242 spec->gpio_mask |= spec->gpio_led;
4243 spec->gpio_dir |= spec->gpio_led;
4244 if (spec->gpio_led_polarity)
4245 spec->gpio_data |= spec->gpio_led;
4249 static int stac92xx_init(struct hda_codec *codec)
4251 struct sigmatel_spec *spec = codec->spec;
4252 struct auto_pin_cfg *cfg = &spec->autocfg;
4256 snd_hda_sequence_write(codec, spec->init);
4258 /* power down adcs initially */
4259 if (spec->powerdown_adcs)
4260 for (i = 0; i < spec->num_adcs; i++)
4261 snd_hda_codec_write(codec,
4262 spec->adc_nids[i], 0,
4263 AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
4265 /* override some hints */
4266 stac_store_hints(codec);
4269 gpio = spec->gpio_data;
4270 /* turn on EAPD statically when spec->eapd_switch isn't set.
4271 * otherwise, unsol event will turn it on/off dynamically
4273 if (!spec->eapd_switch)
4274 gpio |= spec->eapd_mask;
4275 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
4278 if (spec->hp_detect) {
4279 /* Enable unsolicited responses on the HP widget */
4280 for (i = 0; i < cfg->hp_outs; i++) {
4281 hda_nid_t nid = cfg->hp_pins[i];
4282 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4284 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4285 cfg->speaker_outs > 0) {
4286 /* enable pin-detect for line-outs as well */
4287 for (i = 0; i < cfg->line_outs; i++) {
4288 hda_nid_t nid = cfg->line_out_pins[i];
4289 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4293 /* force to enable the first line-out; the others are set up
4296 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4298 /* fake event to set up pins */
4299 if (cfg->hp_pins[0])
4300 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4301 else if (cfg->line_out_pins[0])
4302 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4304 stac92xx_auto_init_multi_out(codec);
4305 stac92xx_auto_init_hp_out(codec);
4306 for (i = 0; i < cfg->hp_outs; i++)
4307 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4309 if (spec->auto_mic) {
4310 /* initialize connection to analog input */
4311 if (spec->dmux_nids)
4312 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4313 AC_VERB_SET_CONNECT_SEL, 0);
4314 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4315 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4316 if (enable_pin_detect(codec, spec->dock_mic.pin,
4318 stac_issue_unsol_event(codec, spec->dock_mic.pin);
4320 for (i = 0; i < cfg->num_inputs; i++) {
4321 hda_nid_t nid = cfg->inputs[i].pin;
4322 int type = cfg->inputs[i].type;
4323 unsigned int pinctl, conf;
4324 if (type == AUTO_PIN_MIC) {
4325 /* for mic pins, force to initialize */
4326 pinctl = stac92xx_get_default_vref(codec, nid);
4327 pinctl |= AC_PINCTL_IN_EN;
4328 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4330 pinctl = snd_hda_codec_read(codec, nid, 0,
4331 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4332 /* if PINCTL already set then skip */
4333 /* Also, if both INPUT and OUTPUT are set,
4334 * it must be a BIOS bug; need to override, too
4336 if (!(pinctl & AC_PINCTL_IN_EN) ||
4337 (pinctl & AC_PINCTL_OUT_EN)) {
4338 pinctl &= ~AC_PINCTL_OUT_EN;
4339 pinctl |= AC_PINCTL_IN_EN;
4340 stac92xx_auto_set_pinctl(codec, nid, pinctl);
4343 conf = snd_hda_codec_get_pincfg(codec, nid);
4344 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4345 if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
4346 stac_issue_unsol_event(codec, nid);
4349 for (i = 0; i < spec->num_dmics; i++)
4350 stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
4352 if (cfg->dig_out_pins[0])
4353 stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
4355 if (cfg->dig_in_pin)
4356 stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
4358 for (i = 0; i < spec->num_pwrs; i++) {
4359 hda_nid_t nid = spec->pwr_nids[i];
4360 int pinctl, def_conf;
4362 /* power on when no jack detection is available */
4363 if (!spec->hp_detect) {
4364 stac_toggle_power_map(codec, nid, 1);
4368 if (is_nid_hp_pin(cfg, nid))
4369 continue; /* already has an unsol event */
4371 pinctl = snd_hda_codec_read(codec, nid, 0,
4372 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4373 /* outputs are only ports capable of power management
4374 * any attempts on powering down a input port cause the
4375 * referenced VREF to act quirky.
4377 if (pinctl & AC_PINCTL_IN_EN) {
4378 stac_toggle_power_map(codec, nid, 1);
4381 def_conf = snd_hda_codec_get_pincfg(codec, nid);
4382 def_conf = get_defcfg_connect(def_conf);
4383 /* skip any ports that don't have jacks since presence
4384 * detection is useless */
4385 if (def_conf != AC_JACK_PORT_COMPLEX) {
4386 if (def_conf != AC_JACK_PORT_NONE)
4387 stac_toggle_power_map(codec, nid, 1);
4390 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4391 stac_issue_unsol_event(codec, nid);
4396 hda_call_check_power_status(codec, 0x01);
4398 stac92xx_power_down(codec);
4402 static void stac92xx_free_jacks(struct hda_codec *codec)
4404 #ifdef CONFIG_SND_HDA_INPUT_JACK
4405 /* free jack instances manually when clearing/reconfiguring */
4406 struct sigmatel_spec *spec = codec->spec;
4407 if (!codec->bus->shutdown && spec->jacks.list) {
4408 struct sigmatel_jack *jacks = spec->jacks.list;
4410 for (i = 0; i < spec->jacks.used; i++, jacks++) {
4412 snd_device_free(codec->bus->card, jacks->jack);
4415 snd_array_free(&spec->jacks);
4419 static void stac92xx_free_kctls(struct hda_codec *codec)
4421 struct sigmatel_spec *spec = codec->spec;
4423 if (spec->kctls.list) {
4424 struct snd_kcontrol_new *kctl = spec->kctls.list;
4426 for (i = 0; i < spec->kctls.used; i++)
4427 kfree(kctl[i].name);
4429 snd_array_free(&spec->kctls);
4432 static void stac92xx_shutup(struct hda_codec *codec)
4434 struct sigmatel_spec *spec = codec->spec;
4436 snd_hda_shutup_pins(codec);
4438 if (spec->eapd_mask)
4439 stac_gpio_set(codec, spec->gpio_mask,
4440 spec->gpio_dir, spec->gpio_data &
4444 static void stac92xx_free(struct hda_codec *codec)
4446 struct sigmatel_spec *spec = codec->spec;
4451 stac92xx_shutup(codec);
4452 stac92xx_free_jacks(codec);
4453 snd_array_free(&spec->events);
4456 snd_hda_detach_beep_device(codec);
4459 static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
4462 unsigned int old_ctl, pin_ctl;
4464 pin_ctl = snd_hda_codec_read(codec, nid,
4465 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4467 if (pin_ctl & AC_PINCTL_IN_EN) {
4469 * we need to check the current set-up direction of
4470 * shared input pins since they can be switched via
4471 * "xxx as Output" mixer switch
4473 struct sigmatel_spec *spec = codec->spec;
4474 if (nid == spec->line_switch || nid == spec->mic_switch)
4479 /* if setting pin direction bits, clear the current
4480 direction bits first */
4481 if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
4482 pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
4485 if (old_ctl != pin_ctl)
4486 snd_hda_codec_write_cache(codec, nid, 0,
4487 AC_VERB_SET_PIN_WIDGET_CONTROL,
4491 static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
4494 unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
4495 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
4497 snd_hda_codec_write_cache(codec, nid, 0,
4498 AC_VERB_SET_PIN_WIDGET_CONTROL,
4502 static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4506 return snd_hda_jack_detect(codec, nid);
4509 static void stac92xx_line_out_detect(struct hda_codec *codec,
4512 struct sigmatel_spec *spec = codec->spec;
4513 struct auto_pin_cfg *cfg = &spec->autocfg;
4516 for (i = 0; i < cfg->line_outs; i++) {
4519 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4521 unsigned int pinctl;
4522 pinctl = snd_hda_codec_read(codec,
4523 cfg->line_out_pins[i], 0,
4524 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4525 if (pinctl & AC_PINCTL_IN_EN)
4526 presence = 0; /* mic- or line-input */
4531 /* disable speakers */
4532 for (i = 0; i < cfg->speaker_outs; i++)
4533 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4535 if (spec->eapd_mask && spec->eapd_switch)
4536 stac_gpio_set(codec, spec->gpio_mask,
4537 spec->gpio_dir, spec->gpio_data &
4540 /* enable speakers */
4541 for (i = 0; i < cfg->speaker_outs; i++)
4542 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4544 if (spec->eapd_mask && spec->eapd_switch)
4545 stac_gpio_set(codec, spec->gpio_mask,
4546 spec->gpio_dir, spec->gpio_data |
4551 /* return non-zero if the hp-pin of the given array index isn't
4552 * a jack-detection target
4554 static int no_hp_sensing(struct sigmatel_spec *spec, int i)
4556 struct auto_pin_cfg *cfg = &spec->autocfg;
4558 /* ignore sensing of shared line and mic jacks */
4559 if (cfg->hp_pins[i] == spec->line_switch)
4561 if (cfg->hp_pins[i] == spec->mic_switch)
4563 /* ignore if the pin is set as line-out */
4564 if (cfg->hp_pins[i] == spec->hp_switch)
4569 static void stac92xx_hp_detect(struct hda_codec *codec)
4571 struct sigmatel_spec *spec = codec->spec;
4572 struct auto_pin_cfg *cfg = &spec->autocfg;
4576 if (spec->gpio_mute)
4577 presence = !(snd_hda_codec_read(codec, codec->afg, 0,
4578 AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
4580 for (i = 0; i < cfg->hp_outs; i++) {
4583 if (no_hp_sensing(spec, i))
4585 presence = get_pin_presence(codec, cfg->hp_pins[i]);
4587 unsigned int pinctl;
4588 pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
4589 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4590 if (pinctl & AC_PINCTL_IN_EN)
4591 presence = 0; /* mic- or line-input */
4596 /* disable lineouts */
4597 if (spec->hp_switch)
4598 stac92xx_reset_pinctl(codec, spec->hp_switch,
4600 for (i = 0; i < cfg->line_outs; i++)
4601 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4604 /* enable lineouts */
4605 if (spec->hp_switch)
4606 stac92xx_set_pinctl(codec, spec->hp_switch,
4608 for (i = 0; i < cfg->line_outs; i++)
4609 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4612 stac92xx_line_out_detect(codec, presence);
4613 /* toggle hp outs */
4614 for (i = 0; i < cfg->hp_outs; i++) {
4615 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
4616 if (no_hp_sensing(spec, i))
4619 stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
4621 /* Resetting the pinctl like below may lead to (a sort of) regressions
4622 * on some devices since they use the HP pin actually for line/speaker
4623 * outs although the default pin config shows a different pin (that is
4624 * wrong and useless).
4626 * So, it's basically a problem of default pin configs, likely a BIOS issue.
4627 * But, disabling the code below just works around it, and I'm too tired of
4628 * bug reports with such devices...
4631 stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
4636 static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
4639 struct sigmatel_spec *spec = codec->spec;
4640 unsigned int idx, val;
4642 for (idx = 0; idx < spec->num_pwrs; idx++) {
4643 if (spec->pwr_nids[idx] == nid)
4646 if (idx >= spec->num_pwrs)
4649 /* several codecs have two power down bits */
4650 if (spec->pwr_mapping)
4651 idx = spec->pwr_mapping[idx];
4655 val = snd_hda_codec_read(codec, codec->afg, 0, 0x0fec, 0x0) & 0xff;
4661 /* power down unused output ports */
4662 snd_hda_codec_write(codec, codec->afg, 0, 0x7ec, val);
4665 static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
4667 stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
4670 static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4672 struct sigmatel_spec *spec = codec->spec;
4673 struct sigmatel_jack *jacks = spec->jacks.list;
4677 for (i = 0; i < spec->jacks.used; i++) {
4678 if (jacks->nid == nid) {
4679 unsigned int pin_ctl =
4680 snd_hda_codec_read(codec, nid,
4681 0, AC_VERB_GET_PIN_WIDGET_CONTROL,
4683 int type = jacks->type;
4684 if (type == (SND_JACK_LINEOUT
4685 | SND_JACK_HEADPHONE))
4686 type = (pin_ctl & AC_PINCTL_HP_EN)
4687 ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT;
4688 snd_jack_report(jacks->jack,
4689 get_pin_presence(codec, nid)
4697 /* get the pin connection (fixed, none, etc) */
4698 static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
4700 struct sigmatel_spec *spec = codec->spec;
4703 cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
4704 return get_defcfg_connect(cfg);
4707 static int stac92xx_connected_ports(struct hda_codec *codec,
4708 hda_nid_t *nids, int num_nids)
4710 struct sigmatel_spec *spec = codec->spec;
4712 unsigned int def_conf;
4714 for (num = 0; num < num_nids; num++) {
4715 for (idx = 0; idx < spec->num_pins; idx++)
4716 if (spec->pin_nids[idx] == nids[num])
4718 if (idx >= spec->num_pins)
4720 def_conf = stac_get_defcfg_connect(codec, idx);
4721 if (def_conf == AC_JACK_PORT_NONE)
4727 static void stac92xx_mic_detect(struct hda_codec *codec)
4729 struct sigmatel_spec *spec = codec->spec;
4730 struct sigmatel_mic_route *mic;
4732 if (get_pin_presence(codec, spec->ext_mic.pin))
4733 mic = &spec->ext_mic;
4734 else if (get_pin_presence(codec, spec->dock_mic.pin))
4735 mic = &spec->dock_mic;
4737 mic = &spec->int_mic;
4738 if (mic->dmux_idx >= 0)
4739 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4740 AC_VERB_SET_CONNECT_SEL,
4742 if (mic->mux_idx >= 0)
4743 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4744 AC_VERB_SET_CONNECT_SEL,
4748 static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4750 struct sigmatel_event *event = stac_get_event(codec, nid);
4753 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
4756 static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4758 struct sigmatel_spec *spec = codec->spec;
4759 struct sigmatel_event *event;
4762 tag = (res >> 26) & 0x7f;
4763 event = stac_get_event_from_tag(codec, tag);
4767 switch (event->type) {
4770 stac92xx_hp_detect(codec);
4772 case STAC_MIC_EVENT:
4773 stac92xx_mic_detect(codec);
4777 switch (event->type) {
4780 case STAC_MIC_EVENT:
4781 case STAC_INSERT_EVENT:
4782 case STAC_PWR_EVENT:
4783 if (spec->num_pwrs > 0)
4784 stac92xx_pin_sense(codec, event->nid);
4785 stac92xx_report_jack(codec, event->nid);
4787 switch (codec->subsystem_id) {
4789 if (event->nid == 0xb) {
4790 int pin = AC_PINCTL_IN_EN;
4792 if (get_pin_presence(codec, 0xa)
4793 && get_pin_presence(codec, 0xb))
4794 pin |= AC_PINCTL_VREF_80;
4795 if (!get_pin_presence(codec, 0xb))
4796 pin |= AC_PINCTL_VREF_80;
4798 /* toggle VREF state based on mic + hp pin
4801 stac92xx_auto_set_pinctl(codec, 0x0a, pin);
4805 case STAC_VREF_EVENT:
4806 data = snd_hda_codec_read(codec, codec->afg, 0,
4807 AC_VERB_GET_GPIO_DATA, 0);
4808 /* toggle VREF state based on GPIOx status */
4809 snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
4810 !!(data & (1 << event->data)));
4815 static int hp_blike_system(u32 subsystem_id);
4817 static void set_hp_led_gpio(struct hda_codec *codec)
4819 struct sigmatel_spec *spec = codec->spec;
4825 gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
4826 gpio &= AC_GPIO_IO_COUNT;
4828 spec->gpio_led = 0x08; /* GPIO 3 */
4830 spec->gpio_led = 0x01; /* GPIO 0 */
4834 * This method searches for the mute LED GPIO configuration
4835 * provided as OEM string in SMBIOS. The format of that string
4836 * is HP_Mute_LED_P_G or HP_Mute_LED_P
4837 * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
4838 * that corresponds to the NOT muted state of the master volume
4839 * and G is the index of the GPIO to use as the mute LED control (0..9)
4840 * If _G portion is missing it is assigned based on the codec ID
4842 * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
4843 * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
4846 * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
4847 * SMBIOS - at least the ones I have seen do not have them - which include
4848 * my own system (HP Pavilion dv6-1110ax) and my cousin's
4849 * HP Pavilion dv9500t CTO.
4850 * Need more information on whether it is true across the entire series.
4853 static int find_mute_led_gpio(struct hda_codec *codec, int default_polarity)
4855 struct sigmatel_spec *spec = codec->spec;
4856 const struct dmi_device *dev = NULL;
4858 if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
4859 while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
4861 if (sscanf(dev->name, "HP_Mute_LED_%d_%d",
4862 &spec->gpio_led_polarity,
4863 &spec->gpio_led) == 2) {
4864 spec->gpio_led = 1 << spec->gpio_led;
4867 if (sscanf(dev->name, "HP_Mute_LED_%d",
4868 &spec->gpio_led_polarity) == 1) {
4869 set_hp_led_gpio(codec);
4875 * Fallback case - if we don't find the DMI strings,
4876 * we statically set the GPIO - if not a B-series system.
4878 if (!hp_blike_system(codec->subsystem_id)) {
4879 set_hp_led_gpio(codec);
4880 spec->gpio_led_polarity = default_polarity;
4887 static int hp_blike_system(u32 subsystem_id)
4889 switch (subsystem_id) {
4916 #ifdef CONFIG_PROC_FS
4917 static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
4918 struct hda_codec *codec, hda_nid_t nid)
4920 if (nid == codec->afg)
4921 snd_iprintf(buffer, "Power-Map: 0x%02x\n",
4922 snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0));
4925 static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
4926 struct hda_codec *codec,
4929 snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
4930 snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
4933 /* stac92hd71bxx, stac92hd73xx */
4934 static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
4935 struct hda_codec *codec, hda_nid_t nid)
4937 stac92hd_proc_hook(buffer, codec, nid);
4938 if (nid == codec->afg)
4939 analog_loop_proc_hook(buffer, codec, 0xfa0);
4942 static void stac9205_proc_hook(struct snd_info_buffer *buffer,
4943 struct hda_codec *codec, hda_nid_t nid)
4945 if (nid == codec->afg)
4946 analog_loop_proc_hook(buffer, codec, 0xfe0);
4949 static void stac927x_proc_hook(struct snd_info_buffer *buffer,
4950 struct hda_codec *codec, hda_nid_t nid)
4952 if (nid == codec->afg)
4953 analog_loop_proc_hook(buffer, codec, 0xfeb);
4956 #define stac92hd_proc_hook NULL
4957 #define stac92hd7x_proc_hook NULL
4958 #define stac9205_proc_hook NULL
4959 #define stac927x_proc_hook NULL
4962 #ifdef SND_HDA_NEEDS_RESUME
4963 static int stac92xx_resume(struct hda_codec *codec)
4965 struct sigmatel_spec *spec = codec->spec;
4967 stac92xx_init(codec);
4968 snd_hda_codec_resume_amp(codec);
4969 snd_hda_codec_resume_cache(codec);
4970 /* fake event to set up pins again to override cached values */
4971 if (spec->hp_detect) {
4972 if (spec->autocfg.hp_pins[0])
4973 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4974 else if (spec->autocfg.line_out_pins[0])
4975 stac_issue_unsol_event(codec,
4976 spec->autocfg.line_out_pins[0]);
4980 hda_call_check_power_status(codec, 0x01);
4985 * using power check for controlling mute led of HP notebooks
4986 * check for mute state only on Speakers (nid = 0x10)
4988 * For this feature CONFIG_SND_HDA_POWER_SAVE is needed, otherwise
4989 * the LED is NOT working properly !
4991 * Changed name to reflect that it now works for any designated
4992 * model, not just HP HDX.
4995 #ifdef CONFIG_SND_HDA_POWER_SAVE
4996 static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4999 struct sigmatel_spec *spec = codec->spec;
5002 for (i = 0; i < spec->multiout.num_dacs; i++) {
5003 nid = spec->multiout.dac_nids[i];
5004 if (!(snd_hda_codec_amp_read(codec, nid, 0, HDA_OUTPUT, 0) &
5006 muted = 0; /* something heard */
5011 spec->gpio_data &= ~spec->gpio_led; /* orange */
5013 spec->gpio_data |= spec->gpio_led; /* white */
5015 if (!spec->gpio_led_polarity) {
5016 /* LED state is inverted on these systems */
5017 spec->gpio_data ^= spec->gpio_led;
5020 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5025 static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
5027 stac92xx_shutup(codec);
5032 static struct hda_codec_ops stac92xx_patch_ops = {
5033 .build_controls = stac92xx_build_controls,
5034 .build_pcms = stac92xx_build_pcms,
5035 .init = stac92xx_init,
5036 .free = stac92xx_free,
5037 .unsol_event = stac92xx_unsol_event,
5038 #ifdef SND_HDA_NEEDS_RESUME
5039 .suspend = stac92xx_suspend,
5040 .resume = stac92xx_resume,
5042 .reboot_notify = stac92xx_shutup,
5045 static int patch_stac9200(struct hda_codec *codec)
5047 struct sigmatel_spec *spec;
5050 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5054 codec->no_trigger_sense = 1;
5056 spec->linear_tone_beep = 1;
5057 spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
5058 spec->pin_nids = stac9200_pin_nids;
5059 spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
5062 if (spec->board_config < 0)
5063 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5066 stac92xx_set_config_regs(codec,
5067 stac9200_brd_tbl[spec->board_config]);
5069 spec->multiout.max_channels = 2;
5070 spec->multiout.num_dacs = 1;
5071 spec->multiout.dac_nids = stac9200_dac_nids;
5072 spec->adc_nids = stac9200_adc_nids;
5073 spec->mux_nids = stac9200_mux_nids;
5074 spec->num_muxes = 1;
5075 spec->num_dmics = 0;
5079 if (spec->board_config == STAC_9200_M4 ||
5080 spec->board_config == STAC_9200_M4_2 ||
5081 spec->board_config == STAC_9200_OQO)
5082 spec->init = stac9200_eapd_init;
5084 spec->init = stac9200_core_init;
5085 spec->mixer = stac9200_mixer;
5087 if (spec->board_config == STAC_9200_PANASONIC) {
5088 spec->gpio_mask = spec->gpio_dir = 0x09;
5089 spec->gpio_data = 0x00;
5092 err = stac9200_parse_auto_config(codec);
5094 stac92xx_free(codec);
5098 /* CF-74 has no headphone detection, and the driver should *NOT*
5099 * do detection and HP/speaker toggle because the hardware does it.
5101 if (spec->board_config == STAC_9200_PANASONIC)
5102 spec->hp_detect = 0;
5104 codec->patch_ops = stac92xx_patch_ops;
5109 static int patch_stac925x(struct hda_codec *codec)
5111 struct sigmatel_spec *spec;
5114 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5118 codec->no_trigger_sense = 1;
5120 spec->linear_tone_beep = 1;
5121 spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
5122 spec->pin_nids = stac925x_pin_nids;
5124 /* Check first for codec ID */
5125 spec->board_config = snd_hda_check_board_codec_sid_config(codec,
5128 stac925x_codec_id_cfg_tbl);
5130 /* Now checks for PCI ID, if codec ID is not found */
5131 if (spec->board_config < 0)
5132 spec->board_config = snd_hda_check_board_config(codec,
5137 if (spec->board_config < 0)
5138 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5141 stac92xx_set_config_regs(codec,
5142 stac925x_brd_tbl[spec->board_config]);
5144 spec->multiout.max_channels = 2;
5145 spec->multiout.num_dacs = 1;
5146 spec->multiout.dac_nids = stac925x_dac_nids;
5147 spec->adc_nids = stac925x_adc_nids;
5148 spec->mux_nids = stac925x_mux_nids;
5149 spec->num_muxes = 1;
5152 switch (codec->vendor_id) {
5153 case 0x83847632: /* STAC9202 */
5154 case 0x83847633: /* STAC9202D */
5155 case 0x83847636: /* STAC9251 */
5156 case 0x83847637: /* STAC9251D */
5157 spec->num_dmics = STAC925X_NUM_DMICS;
5158 spec->dmic_nids = stac925x_dmic_nids;
5159 spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
5160 spec->dmux_nids = stac925x_dmux_nids;
5163 spec->num_dmics = 0;
5167 spec->init = stac925x_core_init;
5168 spec->mixer = stac925x_mixer;
5170 spec->capvols = stac925x_capvols;
5171 spec->capsws = stac925x_capsws;
5173 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
5175 if (spec->board_config < 0) {
5176 printk(KERN_WARNING "hda_codec: No auto-config is "
5177 "available, default to model=ref\n");
5178 spec->board_config = STAC_925x_REF;
5184 stac92xx_free(codec);
5188 codec->patch_ops = stac92xx_patch_ops;
5193 static int patch_stac92hd73xx(struct hda_codec *codec)
5195 struct sigmatel_spec *spec;
5196 hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
5200 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5204 codec->no_trigger_sense = 1;
5206 spec->linear_tone_beep = 0;
5207 codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
5208 spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
5209 spec->pin_nids = stac92hd73xx_pin_nids;
5210 spec->board_config = snd_hda_check_board_config(codec,
5211 STAC_92HD73XX_MODELS,
5212 stac92hd73xx_models,
5213 stac92hd73xx_cfg_tbl);
5214 /* check codec subsystem id if not found */
5215 if (spec->board_config < 0)
5216 spec->board_config =
5217 snd_hda_check_board_codec_sid_config(codec,
5218 STAC_92HD73XX_MODELS, stac92hd73xx_models,
5219 stac92hd73xx_codec_id_cfg_tbl);
5221 if (spec->board_config < 0)
5222 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5225 stac92xx_set_config_regs(codec,
5226 stac92hd73xx_brd_tbl[spec->board_config]);
5228 num_dacs = snd_hda_get_connections(codec, 0x0a,
5229 conn, STAC92HD73_DAC_COUNT + 2) - 1;
5231 if (num_dacs < 3 || num_dacs > 5) {
5232 printk(KERN_WARNING "hda_codec: Could not determine "
5233 "number of channels defaulting to DAC count\n");
5234 num_dacs = STAC92HD73_DAC_COUNT;
5236 spec->init = stac92hd73xx_core_init;
5238 case 0x3: /* 6 Channel */
5239 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
5241 case 0x4: /* 8 Channel */
5242 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
5244 case 0x5: /* 10 Channel */
5245 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
5248 spec->multiout.dac_nids = spec->dac_nids;
5250 spec->aloopback_mask = 0x01;
5251 spec->aloopback_shift = 8;
5253 spec->digbeep_nid = 0x1c;
5254 spec->mux_nids = stac92hd73xx_mux_nids;
5255 spec->adc_nids = stac92hd73xx_adc_nids;
5256 spec->dmic_nids = stac92hd73xx_dmic_nids;
5257 spec->dmux_nids = stac92hd73xx_dmux_nids;
5258 spec->smux_nids = stac92hd73xx_smux_nids;
5260 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
5261 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
5262 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
5264 spec->num_caps = STAC92HD73XX_NUM_CAPS;
5265 spec->capvols = stac92hd73xx_capvols;
5266 spec->capsws = stac92hd73xx_capsws;
5268 switch (spec->board_config) {
5270 spec->init = dell_eq_core_init;
5272 case STAC_DELL_M6_AMIC:
5273 case STAC_DELL_M6_DMIC:
5274 case STAC_DELL_M6_BOTH:
5275 spec->num_smuxes = 0;
5276 spec->eapd_switch = 0;
5278 switch (spec->board_config) {
5279 case STAC_DELL_M6_AMIC: /* Analog Mics */
5280 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5281 spec->num_dmics = 0;
5283 case STAC_DELL_M6_DMIC: /* Digital Mics */
5284 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5285 spec->num_dmics = 1;
5287 case STAC_DELL_M6_BOTH: /* Both */
5288 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5289 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5290 spec->num_dmics = 1;
5294 case STAC_ALIENWARE_M17X:
5295 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5296 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5297 spec->eapd_switch = 0;
5300 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5301 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5302 spec->eapd_switch = 1;
5305 if (spec->board_config != STAC_92HD73XX_REF) {
5306 /* GPIO0 High = Enable EAPD */
5307 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5308 spec->gpio_data = 0x01;
5311 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5312 spec->pwr_nids = stac92hd73xx_pwr_nids;
5314 err = stac92xx_parse_auto_config(codec, 0x25, 0x27);
5317 if (spec->board_config < 0) {
5318 printk(KERN_WARNING "hda_codec: No auto-config is "
5319 "available, default to model=ref\n");
5320 spec->board_config = STAC_92HD73XX_REF;
5327 stac92xx_free(codec);
5331 if (spec->board_config == STAC_92HD73XX_NO_JD)
5332 spec->hp_detect = 0;
5334 codec->patch_ops = stac92xx_patch_ops;
5336 codec->proc_widget_hook = stac92hd7x_proc_hook;
5341 static int hp_bnb2011_with_dock(struct hda_codec *codec)
5343 if (codec->vendor_id != 0x111d7605 &&
5344 codec->vendor_id != 0x111d76d1)
5347 switch (codec->subsystem_id) {
5381 static int patch_stac92hd83xxx(struct hda_codec *codec)
5383 struct sigmatel_spec *spec;
5384 hda_nid_t conn[STAC92HD83_DAC_COUNT + 1];
5388 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5392 if (hp_bnb2011_with_dock(codec)) {
5393 snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
5394 snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
5397 /* reset pin power-down; Windows may leave these bits after reboot */
5398 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7EC, 0);
5399 snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7ED, 0);
5400 codec->no_trigger_sense = 1;
5402 spec->linear_tone_beep = 0;
5403 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5404 spec->digbeep_nid = 0x21;
5405 spec->dmic_nids = stac92hd83xxx_dmic_nids;
5406 spec->dmux_nids = stac92hd83xxx_mux_nids;
5407 spec->mux_nids = stac92hd83xxx_mux_nids;
5408 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5409 spec->adc_nids = stac92hd83xxx_adc_nids;
5410 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5411 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5412 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5413 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5414 spec->multiout.dac_nids = spec->dac_nids;
5416 spec->init = stac92hd83xxx_core_init;
5417 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5418 spec->pin_nids = stac92hd83xxx_pin_nids;
5419 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5420 spec->capvols = stac92hd83xxx_capvols;
5421 spec->capsws = stac92hd83xxx_capsws;
5423 spec->board_config = snd_hda_check_board_config(codec,
5424 STAC_92HD83XXX_MODELS,
5425 stac92hd83xxx_models,
5426 stac92hd83xxx_cfg_tbl);
5428 if (spec->board_config < 0)
5429 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5432 stac92xx_set_config_regs(codec,
5433 stac92hd83xxx_brd_tbl[spec->board_config]);
5435 switch (codec->vendor_id) {
5439 spec->dmic_nids = stac92hd87b_dmic_nids;
5440 spec->num_dmics = stac92xx_connected_ports(codec,
5441 stac92hd87b_dmic_nids,
5442 STAC92HD87B_NUM_DMICS);
5443 spec->num_pins = ARRAY_SIZE(stac92hd87xxx_pin_nids);
5444 spec->pin_nids = stac92hd87xxx_pin_nids;
5453 spec->num_dmics = stac92xx_connected_ports(codec,
5454 stac92hd88xxx_dmic_nids,
5455 STAC92HD88XXX_NUM_DMICS);
5456 spec->num_pins = ARRAY_SIZE(stac92hd88xxx_pin_nids);
5457 spec->pin_nids = stac92hd88xxx_pin_nids;
5466 if (spec->board_config == STAC_92HD83XXX_PWR_REF)
5469 spec->num_dmics = stac92xx_connected_ports(codec,
5470 stac92hd83xxx_dmic_nids,
5471 STAC92HD83XXX_NUM_DMICS);
5475 codec->patch_ops = stac92xx_patch_ops;
5477 if (find_mute_led_gpio(codec, 0))
5478 snd_printd("mute LED gpio %d polarity %d\n",
5480 spec->gpio_led_polarity);
5482 #ifdef CONFIG_SND_HDA_POWER_SAVE
5483 if (spec->gpio_led) {
5484 spec->gpio_mask |= spec->gpio_led;
5485 spec->gpio_dir |= spec->gpio_led;
5486 spec->gpio_data |= spec->gpio_led;
5487 /* register check_power_status callback. */
5488 codec->patch_ops.check_power_status =
5489 stac92xx_hp_check_power_status;
5493 err = stac92xx_parse_auto_config(codec, 0x1d, 0);
5495 if (spec->board_config < 0) {
5496 printk(KERN_WARNING "hda_codec: No auto-config is "
5497 "available, default to model=ref\n");
5498 spec->board_config = STAC_92HD83XXX_REF;
5505 stac92xx_free(codec);
5509 /* docking output support */
5510 num_dacs = snd_hda_get_connections(codec, 0xF,
5511 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5512 /* skip non-DAC connections */
5513 while (num_dacs >= 0 &&
5514 (get_wcaps_type(get_wcaps(codec, conn[num_dacs]))
5517 /* set port E and F to select the last DAC */
5518 if (num_dacs >= 0) {
5519 snd_hda_codec_write_cache(codec, 0xE, 0,
5520 AC_VERB_SET_CONNECT_SEL, num_dacs);
5521 snd_hda_codec_write_cache(codec, 0xF, 0,
5522 AC_VERB_SET_CONNECT_SEL, num_dacs);
5525 codec->proc_widget_hook = stac92hd_proc_hook;
5530 static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
5533 struct sigmatel_spec *spec = codec->spec;
5536 for (idx = 0; idx < spec->num_pins; idx++)
5537 if (spec->pin_nids[idx] == dig0pin)
5539 if ((idx + 2) >= spec->num_pins)
5543 if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
5546 /* dig0pin + dig2pin case */
5547 if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
5549 if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
5555 /* HP dv7 bass switch - GPIO5 */
5556 #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
5557 static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
5558 struct snd_ctl_elem_value *ucontrol)
5560 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5561 struct sigmatel_spec *spec = codec->spec;
5562 ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
5566 static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
5567 struct snd_ctl_elem_value *ucontrol)
5569 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5570 struct sigmatel_spec *spec = codec->spec;
5571 unsigned int gpio_data;
5573 gpio_data = (spec->gpio_data & ~0x20) |
5574 (ucontrol->value.integer.value[0] ? 0x20 : 0);
5575 if (gpio_data == spec->gpio_data)
5577 spec->gpio_data = gpio_data;
5578 stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
5582 static struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
5583 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5584 .info = stac_hp_bass_gpio_info,
5585 .get = stac_hp_bass_gpio_get,
5586 .put = stac_hp_bass_gpio_put,
5589 static int stac_add_hp_bass_switch(struct hda_codec *codec)
5591 struct sigmatel_spec *spec = codec->spec;
5593 if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
5594 "Bass Speaker Playback Switch", 0))
5597 spec->gpio_mask |= 0x20;
5598 spec->gpio_dir |= 0x20;
5599 spec->gpio_data |= 0x20;
5603 static int patch_stac92hd71bxx(struct hda_codec *codec)
5605 struct sigmatel_spec *spec;
5606 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5607 unsigned int pin_cfg;
5610 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5614 codec->no_trigger_sense = 1;
5616 spec->linear_tone_beep = 0;
5617 codec->patch_ops = stac92xx_patch_ops;
5618 spec->num_pins = STAC92HD71BXX_NUM_PINS;
5619 switch (codec->vendor_id) {
5622 spec->pin_nids = stac92hd71bxx_pin_nids_4port;
5626 /* On 92HD75Bx 0x27 isn't a pin nid */
5630 spec->pin_nids = stac92hd71bxx_pin_nids_6port;
5632 spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
5633 spec->board_config = snd_hda_check_board_config(codec,
5634 STAC_92HD71BXX_MODELS,
5635 stac92hd71bxx_models,
5636 stac92hd71bxx_cfg_tbl);
5638 if (spec->board_config < 0)
5639 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5642 stac92xx_set_config_regs(codec,
5643 stac92hd71bxx_brd_tbl[spec->board_config]);
5645 if (spec->board_config != STAC_92HD71BXX_REF) {
5647 spec->gpio_mask = 0x01;
5648 spec->gpio_dir = 0x01;
5649 spec->gpio_data = 0x01;
5652 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5653 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5655 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5656 spec->capvols = stac92hd71bxx_capvols;
5657 spec->capsws = stac92hd71bxx_capsws;
5659 switch (codec->vendor_id) {
5660 case 0x111d76b6: /* 4 Port without Analog Mixer */
5664 case 0x111d76b4: /* 6 Port without Analog Mixer */
5666 spec->init = stac92hd71bxx_core_init;
5667 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5668 spec->num_dmics = stac92xx_connected_ports(codec,
5669 stac92hd71bxx_dmic_nids,
5670 STAC92HD71BXX_NUM_DMICS);
5672 case 0x111d7608: /* 5 Port with Analog Mixer */
5673 switch (spec->board_config) {
5675 /* Enable VREF power saving on GPIO1 detect */
5676 err = stac_add_event(spec, codec->afg,
5677 STAC_VREF_EVENT, 0x02);
5680 snd_hda_codec_write_cache(codec, codec->afg, 0,
5681 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
5682 snd_hda_codec_write_cache(codec, codec->afg, 0,
5683 AC_VERB_SET_UNSOLICITED_ENABLE,
5685 spec->gpio_mask |= 0x02;
5688 if ((codec->revision_id & 0xf) == 0 ||
5689 (codec->revision_id & 0xf) == 1)
5690 spec->stream_delay = 40; /* 40 milliseconds */
5692 /* no output amps */
5695 spec->init = stac92hd71bxx_core_init;
5697 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5698 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
5699 stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0;
5700 spec->num_dmics = stac92xx_connected_ports(codec,
5701 stac92hd71bxx_dmic_nids,
5702 STAC92HD71BXX_NUM_DMICS - 1);
5704 case 0x111d7603: /* 6 Port with Analog Mixer */
5705 if ((codec->revision_id & 0xf) == 1)
5706 spec->stream_delay = 40; /* 40 milliseconds */
5708 /* no output amps */
5712 spec->init = stac92hd71bxx_core_init;
5713 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5714 spec->num_dmics = stac92xx_connected_ports(codec,
5715 stac92hd71bxx_dmic_nids,
5716 STAC92HD71BXX_NUM_DMICS);
5720 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
5721 snd_hda_sequence_write_cache(codec, unmute_init);
5723 /* Some HP machines seem to have unstable codec communications
5724 * especially with ATI fglrx driver. For recovering from the
5725 * CORB/RIRB stall, allow the BUS reset and keep always sync
5727 if (spec->board_config == STAC_HP_DV5) {
5728 codec->bus->sync_write = 1;
5729 codec->bus->allow_bus_reset = 1;
5732 spec->aloopback_ctl = stac92hd71bxx_loopback;
5733 spec->aloopback_mask = 0x50;
5734 spec->aloopback_shift = 0;
5736 spec->powerdown_adcs = 1;
5737 spec->digbeep_nid = 0x26;
5738 spec->mux_nids = stac92hd71bxx_mux_nids;
5739 spec->adc_nids = stac92hd71bxx_adc_nids;
5740 spec->smux_nids = stac92hd71bxx_smux_nids;
5741 spec->pwr_nids = stac92hd71bxx_pwr_nids;
5743 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5744 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5745 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5746 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5748 snd_printdd("Found board config: %d\n", spec->board_config);
5750 switch (spec->board_config) {
5752 /* enable internal microphone */
5753 snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
5754 stac92xx_auto_set_pinctl(codec, 0x0e,
5755 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
5757 case STAC_DELL_M4_2:
5758 spec->num_dmics = 0;
5759 spec->num_smuxes = 0;
5760 spec->num_dmuxes = 0;
5762 case STAC_DELL_M4_1:
5763 case STAC_DELL_M4_3:
5764 spec->num_dmics = 1;
5765 spec->num_smuxes = 0;
5766 spec->num_dmuxes = 1;
5768 case STAC_HP_DV4_1222NR:
5769 spec->num_dmics = 1;
5770 /* I don't know if it needs 1 or 2 smuxes - will wait for
5771 * bug reports to fix if needed
5773 spec->num_smuxes = 1;
5774 spec->num_dmuxes = 1;
5777 spec->gpio_led = 0x01;
5780 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5781 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5782 /* HP dv6 gives the headphone pin as a line-out. Thus we
5783 * need to set hp_detect flag here to force to enable HP
5786 spec->hp_detect = 1;
5789 spec->num_dmics = 1;
5790 spec->num_dmuxes = 1;
5791 spec->num_smuxes = 1;
5792 spec->gpio_led = 0x08;
5796 if (hp_blike_system(codec->subsystem_id)) {
5797 pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
5798 if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
5799 get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
5800 get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
5801 /* It was changed in the BIOS to just satisfy MS DTM.
5802 * Lets turn it back into slaved HP
5804 pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
5805 | (AC_JACK_HP_OUT <<
5806 AC_DEFCFG_DEVICE_SHIFT);
5807 pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
5808 | AC_DEFCFG_SEQUENCE)))
5810 snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
5814 if (find_mute_led_gpio(codec, 1))
5815 snd_printd("mute LED gpio %d polarity %d\n",
5817 spec->gpio_led_polarity);
5819 #ifdef CONFIG_SND_HDA_POWER_SAVE
5820 if (spec->gpio_led) {
5821 spec->gpio_mask |= spec->gpio_led;
5822 spec->gpio_dir |= spec->gpio_led;
5823 spec->gpio_data |= spec->gpio_led;
5824 /* register check_power_status callback. */
5825 codec->patch_ops.check_power_status =
5826 stac92xx_hp_check_power_status;
5830 spec->multiout.dac_nids = spec->dac_nids;
5832 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5834 if (spec->board_config < 0) {
5835 printk(KERN_WARNING "hda_codec: No auto-config is "
5836 "available, default to model=ref\n");
5837 spec->board_config = STAC_92HD71BXX_REF;
5844 stac92xx_free(codec);
5848 /* enable bass on HP dv7 */
5849 if (spec->board_config == STAC_HP_DV4 ||
5850 spec->board_config == STAC_HP_DV5) {
5852 cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
5853 cap &= AC_GPIO_IO_COUNT;
5855 stac_add_hp_bass_switch(codec);
5858 codec->proc_widget_hook = stac92hd7x_proc_hook;
5863 static int patch_stac922x(struct hda_codec *codec)
5865 struct sigmatel_spec *spec;
5868 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5872 codec->no_trigger_sense = 1;
5874 spec->linear_tone_beep = 1;
5875 spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
5876 spec->pin_nids = stac922x_pin_nids;
5877 spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
5880 if (spec->board_config == STAC_INTEL_MAC_AUTO) {
5881 spec->gpio_mask = spec->gpio_dir = 0x03;
5882 spec->gpio_data = 0x03;
5883 /* Intel Macs have all same PCI SSID, so we need to check
5884 * codec SSID to distinguish the exact models
5886 printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
5887 switch (codec->subsystem_id) {
5890 spec->board_config = STAC_INTEL_MAC_V1;
5894 spec->board_config = STAC_INTEL_MAC_V2;
5902 spec->board_config = STAC_INTEL_MAC_V3;
5906 spec->board_config = STAC_INTEL_MAC_V4;
5910 spec->board_config = STAC_INTEL_MAC_V5;
5913 spec->board_config = STAC_INTEL_MAC_V3;
5919 if (spec->board_config < 0)
5920 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5923 stac92xx_set_config_regs(codec,
5924 stac922x_brd_tbl[spec->board_config]);
5926 spec->adc_nids = stac922x_adc_nids;
5927 spec->mux_nids = stac922x_mux_nids;
5928 spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
5929 spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
5930 spec->num_dmics = 0;
5933 spec->init = stac922x_core_init;
5935 spec->num_caps = STAC922X_NUM_CAPS;
5936 spec->capvols = stac922x_capvols;
5937 spec->capsws = stac922x_capsws;
5939 spec->multiout.dac_nids = spec->dac_nids;
5941 err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
5943 if (spec->board_config < 0) {
5944 printk(KERN_WARNING "hda_codec: No auto-config is "
5945 "available, default to model=ref\n");
5946 spec->board_config = STAC_D945_REF;
5952 stac92xx_free(codec);
5956 codec->patch_ops = stac92xx_patch_ops;
5958 /* Fix Mux capture level; max to 2 */
5959 snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
5960 (0 << AC_AMPCAP_OFFSET_SHIFT) |
5961 (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
5962 (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
5963 (0 << AC_AMPCAP_MUTE_SHIFT));
5968 static int patch_stac927x(struct hda_codec *codec)
5970 struct sigmatel_spec *spec;
5973 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5977 codec->no_trigger_sense = 1;
5979 spec->linear_tone_beep = 1;
5980 codec->slave_dig_outs = stac927x_slave_dig_outs;
5981 spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
5982 spec->pin_nids = stac927x_pin_nids;
5983 spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
5987 if (spec->board_config < 0)
5988 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5991 stac92xx_set_config_regs(codec,
5992 stac927x_brd_tbl[spec->board_config]);
5994 spec->digbeep_nid = 0x23;
5995 spec->adc_nids = stac927x_adc_nids;
5996 spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
5997 spec->mux_nids = stac927x_mux_nids;
5998 spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
5999 spec->smux_nids = stac927x_smux_nids;
6000 spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
6001 spec->spdif_labels = stac927x_spdif_labels;
6002 spec->dac_list = stac927x_dac_nids;
6003 spec->multiout.dac_nids = spec->dac_nids;
6005 if (spec->board_config != STAC_D965_REF) {
6006 /* GPIO0 High = Enable EAPD */
6007 spec->eapd_mask = spec->gpio_mask = 0x01;
6008 spec->gpio_dir = spec->gpio_data = 0x01;
6011 switch (spec->board_config) {
6014 /* GPIO0 High = Enable EAPD */
6015 spec->num_dmics = 0;
6016 spec->init = d965_core_init;
6018 case STAC_DELL_BIOS:
6019 switch (codec->subsystem_id) {
6022 /* correct the device field to SPDIF out */
6023 snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
6026 /* configure the analog microphone on some laptops */
6027 snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
6028 /* correct the front output jack as a hp out */
6029 snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
6030 /* correct the front input jack as a mic */
6031 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
6034 if (codec->subsystem_id != 0x1028022f) {
6035 /* GPIO2 High = Enable EAPD */
6036 spec->eapd_mask = spec->gpio_mask = 0x04;
6037 spec->gpio_dir = spec->gpio_data = 0x04;
6039 spec->dmic_nids = stac927x_dmic_nids;
6040 spec->num_dmics = STAC927X_NUM_DMICS;
6042 spec->init = dell_3st_core_init;
6043 spec->dmux_nids = stac927x_dmux_nids;
6044 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
6046 case STAC_927X_VOLKNOB:
6047 spec->num_dmics = 0;
6048 spec->init = stac927x_volknob_core_init;
6051 spec->num_dmics = 0;
6052 spec->init = stac927x_core_init;
6056 spec->num_caps = STAC927X_NUM_CAPS;
6057 spec->capvols = stac927x_capvols;
6058 spec->capsws = stac927x_capsws;
6061 spec->aloopback_ctl = stac927x_loopback;
6062 spec->aloopback_mask = 0x40;
6063 spec->aloopback_shift = 0;
6064 spec->eapd_switch = 1;
6066 err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
6068 if (spec->board_config < 0) {
6069 printk(KERN_WARNING "hda_codec: No auto-config is "
6070 "available, default to model=ref\n");
6071 spec->board_config = STAC_D965_REF;
6077 stac92xx_free(codec);
6081 codec->patch_ops = stac92xx_patch_ops;
6083 codec->proc_widget_hook = stac927x_proc_hook;
6087 * The STAC927x seem to require fairly long delays for certain
6088 * command sequences. With too short delays (even if the answer
6089 * is set to RIRB properly), it results in the silence output
6090 * on some hardwares like Dell.
6092 * The below flag enables the longer delay (see get_response
6095 codec->bus->needs_damn_long_delay = 1;
6097 /* no jack detecion for ref-no-jd model */
6098 if (spec->board_config == STAC_D965_REF_NO_JD)
6099 spec->hp_detect = 0;
6104 static int patch_stac9205(struct hda_codec *codec)
6106 struct sigmatel_spec *spec;
6109 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6113 codec->no_trigger_sense = 1;
6115 spec->linear_tone_beep = 1;
6116 spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
6117 spec->pin_nids = stac9205_pin_nids;
6118 spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
6122 if (spec->board_config < 0)
6123 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6126 stac92xx_set_config_regs(codec,
6127 stac9205_brd_tbl[spec->board_config]);
6129 spec->digbeep_nid = 0x23;
6130 spec->adc_nids = stac9205_adc_nids;
6131 spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
6132 spec->mux_nids = stac9205_mux_nids;
6133 spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
6134 spec->smux_nids = stac9205_smux_nids;
6135 spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
6136 spec->dmic_nids = stac9205_dmic_nids;
6137 spec->num_dmics = STAC9205_NUM_DMICS;
6138 spec->dmux_nids = stac9205_dmux_nids;
6139 spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
6142 spec->init = stac9205_core_init;
6143 spec->aloopback_ctl = stac9205_loopback;
6145 spec->num_caps = STAC9205_NUM_CAPS;
6146 spec->capvols = stac9205_capvols;
6147 spec->capsws = stac9205_capsws;
6149 spec->aloopback_mask = 0x40;
6150 spec->aloopback_shift = 0;
6151 /* Turn on/off EAPD per HP plugging */
6152 if (spec->board_config != STAC_9205_EAPD)
6153 spec->eapd_switch = 1;
6154 spec->multiout.dac_nids = spec->dac_nids;
6156 switch (spec->board_config){
6157 case STAC_9205_DELL_M43:
6158 /* Enable SPDIF in/out */
6159 snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
6160 snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
6162 /* Enable unsol response for GPIO4/Dock HP connection */
6163 err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01);
6166 snd_hda_codec_write_cache(codec, codec->afg, 0,
6167 AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
6168 snd_hda_codec_write_cache(codec, codec->afg, 0,
6169 AC_VERB_SET_UNSOLICITED_ENABLE,
6172 spec->gpio_dir = 0x0b;
6173 spec->eapd_mask = 0x01;
6174 spec->gpio_mask = 0x1b;
6175 spec->gpio_mute = 0x10;
6176 /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
6179 spec->gpio_data = 0x01;
6182 /* SPDIF-In enabled */
6185 /* GPIO0 High = EAPD */
6186 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
6187 spec->gpio_data = 0x01;
6191 err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
6193 if (spec->board_config < 0) {
6194 printk(KERN_WARNING "hda_codec: No auto-config is "
6195 "available, default to model=ref\n");
6196 spec->board_config = STAC_9205_REF;
6202 stac92xx_free(codec);
6206 codec->patch_ops = stac92xx_patch_ops;
6208 codec->proc_widget_hook = stac9205_proc_hook;
6217 static struct hda_verb stac9872_core_init[] = {
6218 {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
6219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
6223 static hda_nid_t stac9872_pin_nids[] = {
6224 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
6228 static hda_nid_t stac9872_adc_nids[] = {
6232 static hda_nid_t stac9872_mux_nids[] = {
6236 static unsigned long stac9872_capvols[] = {
6237 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
6239 #define stac9872_capsws stac9872_capvols
6241 static unsigned int stac9872_vaio_pin_configs[9] = {
6242 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
6243 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
6247 static const char * const stac9872_models[STAC_9872_MODELS] = {
6248 [STAC_9872_AUTO] = "auto",
6249 [STAC_9872_VAIO] = "vaio",
6252 static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
6253 [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
6256 static struct snd_pci_quirk stac9872_cfg_tbl[] = {
6257 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
6258 "Sony VAIO F/S", STAC_9872_VAIO),
6262 static int patch_stac9872(struct hda_codec *codec)
6264 struct sigmatel_spec *spec;
6267 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
6270 codec->no_trigger_sense = 1;
6272 spec->linear_tone_beep = 1;
6273 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
6274 spec->pin_nids = stac9872_pin_nids;
6276 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
6279 if (spec->board_config < 0)
6280 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
6283 stac92xx_set_config_regs(codec,
6284 stac9872_brd_tbl[spec->board_config]);
6286 spec->multiout.dac_nids = spec->dac_nids;
6287 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
6288 spec->adc_nids = stac9872_adc_nids;
6289 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
6290 spec->mux_nids = stac9872_mux_nids;
6291 spec->init = stac9872_core_init;
6293 spec->capvols = stac9872_capvols;
6294 spec->capsws = stac9872_capsws;
6296 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
6298 stac92xx_free(codec);
6301 spec->input_mux = &spec->private_imux;
6302 codec->patch_ops = stac92xx_patch_ops;
6310 static struct hda_codec_preset snd_hda_preset_sigmatel[] = {
6311 { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
6312 { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
6313 { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
6314 { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
6315 { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
6316 { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
6317 { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
6318 { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
6319 { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
6320 { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
6321 { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
6322 { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
6323 { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
6324 { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
6325 { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
6326 { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
6327 { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
6328 { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
6329 { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
6330 { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
6331 { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
6332 { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
6333 { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
6334 { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
6335 { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
6336 { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
6337 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
6338 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
6339 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
6340 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
6341 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
6342 /* The following does not take into account .id=0x83847661 when subsys =
6343 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
6344 * currently not fully supported.
6346 { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
6347 { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
6348 { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
6349 { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
6350 { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
6351 { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
6352 { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
6353 { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
6354 { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
6355 { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
6356 { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
6357 { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
6358 { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
6359 { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
6360 { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
6361 { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
6362 { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
6363 { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
6364 { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
6365 { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
6366 { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
6367 { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
6368 { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
6369 { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
6370 { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
6371 { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
6372 { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
6373 { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6374 { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
6375 { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6376 { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
6377 { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6378 { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
6379 { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6380 { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
6381 { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
6382 { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
6383 { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
6384 { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
6385 { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
6386 { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
6387 { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
6388 { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
6389 { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
6390 { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
6391 { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
6392 { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
6393 { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
6394 { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
6395 { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
6396 { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
6397 { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
6398 { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
6399 { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
6403 MODULE_ALIAS("snd-hda-codec-id:8384*");
6404 MODULE_ALIAS("snd-hda-codec-id:111d*");
6406 MODULE_LICENSE("GPL");
6407 MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
6409 static struct hda_codec_preset_list sigmatel_list = {
6410 .preset = snd_hda_preset_sigmatel,
6411 .owner = THIS_MODULE,
6414 static int __init patch_sigmatel_init(void)
6416 return snd_hda_add_codec_preset(&sigmatel_list);
6419 static void __exit patch_sigmatel_exit(void)
6421 snd_hda_delete_codec_preset(&sigmatel_list);
6424 module_init(patch_sigmatel_init)
6425 module_exit(patch_sigmatel_exit)