aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_sigmatel.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/patch_sigmatel.c')
-rw-r--r--sound/pci/hda/patch_sigmatel.c1291
1 files changed, 631 insertions, 660 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 14f3c3e0f62d..a9b26828a651 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -40,6 +40,8 @@ enum {
40 STAC_INSERT_EVENT, 40 STAC_INSERT_EVENT,
41 STAC_PWR_EVENT, 41 STAC_PWR_EVENT,
42 STAC_HP_EVENT, 42 STAC_HP_EVENT,
43 STAC_LO_EVENT,
44 STAC_MIC_EVENT,
43}; 45};
44 46
45enum { 47enum {
@@ -76,10 +78,12 @@ enum {
76 STAC_92HD73XX_AUTO, 78 STAC_92HD73XX_AUTO,
77 STAC_92HD73XX_NO_JD, /* no jack-detection */ 79 STAC_92HD73XX_NO_JD, /* no jack-detection */
78 STAC_92HD73XX_REF, 80 STAC_92HD73XX_REF,
81 STAC_92HD73XX_INTEL,
79 STAC_DELL_M6_AMIC, 82 STAC_DELL_M6_AMIC,
80 STAC_DELL_M6_DMIC, 83 STAC_DELL_M6_DMIC,
81 STAC_DELL_M6_BOTH, 84 STAC_DELL_M6_BOTH,
82 STAC_DELL_EQ, 85 STAC_DELL_EQ,
86 STAC_ALIENWARE_M17X,
83 STAC_92HD73XX_MODELS 87 STAC_92HD73XX_MODELS
84}; 88};
85 89
@@ -176,6 +180,12 @@ struct sigmatel_jack {
176 struct snd_jack *jack; 180 struct snd_jack *jack;
177}; 181};
178 182
183struct sigmatel_mic_route {
184 hda_nid_t pin;
185 signed char mux_idx;
186 signed char dmux_idx;
187};
188
179struct sigmatel_spec { 189struct sigmatel_spec {
180 struct snd_kcontrol_new *mixers[4]; 190 struct snd_kcontrol_new *mixers[4];
181 unsigned int num_mixers; 191 unsigned int num_mixers;
@@ -187,6 +197,7 @@ struct sigmatel_spec {
187 unsigned int hp_detect: 1; 197 unsigned int hp_detect: 1;
188 unsigned int spdif_mute: 1; 198 unsigned int spdif_mute: 1;
189 unsigned int check_volume_offset:1; 199 unsigned int check_volume_offset:1;
200 unsigned int auto_mic:1;
190 201
191 /* gpio lines */ 202 /* gpio lines */
192 unsigned int eapd_mask; 203 unsigned int eapd_mask;
@@ -218,7 +229,6 @@ struct sigmatel_spec {
218 229
219 /* playback */ 230 /* playback */
220 struct hda_input_mux *mono_mux; 231 struct hda_input_mux *mono_mux;
221 struct hda_input_mux *amp_mux;
222 unsigned int cur_mmux; 232 unsigned int cur_mmux;
223 struct hda_multi_out multiout; 233 struct hda_multi_out multiout;
224 hda_nid_t dac_nids[5]; 234 hda_nid_t dac_nids[5];
@@ -238,6 +248,15 @@ struct sigmatel_spec {
238 unsigned int num_dmuxes; 248 unsigned int num_dmuxes;
239 hda_nid_t *smux_nids; 249 hda_nid_t *smux_nids;
240 unsigned int num_smuxes; 250 unsigned int num_smuxes;
251 unsigned int num_analog_muxes;
252
253 unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
254 unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
255 unsigned int num_caps; /* number of capture volume/switch elements */
256
257 struct sigmatel_mic_route ext_mic;
258 struct sigmatel_mic_route int_mic;
259
241 const char **spdif_labels; 260 const char **spdif_labels;
242 261
243 hda_nid_t dig_in_nid; 262 hda_nid_t dig_in_nid;
@@ -262,7 +281,6 @@ struct sigmatel_spec {
262 unsigned int cur_smux[2]; 281 unsigned int cur_smux[2];
263 unsigned int cur_amux; 282 unsigned int cur_amux;
264 hda_nid_t *amp_nids; 283 hda_nid_t *amp_nids;
265 unsigned int num_amps;
266 unsigned int powerdown_adcs; 284 unsigned int powerdown_adcs;
267 285
268 /* i/o switches */ 286 /* i/o switches */
@@ -281,7 +299,6 @@ struct sigmatel_spec {
281 struct hda_input_mux private_dimux; 299 struct hda_input_mux private_dimux;
282 struct hda_input_mux private_imux; 300 struct hda_input_mux private_imux;
283 struct hda_input_mux private_smux; 301 struct hda_input_mux private_smux;
284 struct hda_input_mux private_amp_mux;
285 struct hda_input_mux private_mono_mux; 302 struct hda_input_mux private_mono_mux;
286}; 303};
287 304
@@ -310,11 +327,6 @@ static hda_nid_t stac92hd73xx_adc_nids[2] = {
310 0x1a, 0x1b 327 0x1a, 0x1b
311}; 328};
312 329
313#define DELL_M6_AMP 2
314static hda_nid_t stac92hd73xx_amp_nids[3] = {
315 0x0b, 0x0c, 0x0e
316};
317
318#define STAC92HD73XX_NUM_DMICS 2 330#define STAC92HD73XX_NUM_DMICS 2
319static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { 331static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
320 0x13, 0x14, 0 332 0x13, 0x14, 0
@@ -322,8 +334,8 @@ static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
322 334
323#define STAC92HD73_DAC_COUNT 5 335#define STAC92HD73_DAC_COUNT 5
324 336
325static hda_nid_t stac92hd73xx_mux_nids[4] = { 337static hda_nid_t stac92hd73xx_mux_nids[2] = {
326 0x28, 0x29, 0x2a, 0x2b, 338 0x20, 0x21,
327}; 339};
328 340
329static hda_nid_t stac92hd73xx_dmux_nids[2] = { 341static hda_nid_t stac92hd73xx_dmux_nids[2] = {
@@ -334,14 +346,16 @@ static hda_nid_t stac92hd73xx_smux_nids[2] = {
334 0x22, 0x23, 346 0x22, 0x23,
335}; 347};
336 348
337#define STAC92HD83XXX_NUM_DMICS 2 349#define STAC92HD73XX_NUM_CAPS 2
338static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { 350static unsigned long stac92hd73xx_capvols[] = {
339 0x11, 0x12, 0 351 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
352 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
340}; 353};
354#define stac92hd73xx_capsws stac92hd73xx_capvols
341 355
342#define STAC92HD83_DAC_COUNT 3 356#define STAC92HD83_DAC_COUNT 3
343 357
344static hda_nid_t stac92hd83xxx_dmux_nids[2] = { 358static hda_nid_t stac92hd83xxx_mux_nids[2] = {
345 0x17, 0x18, 359 0x17, 0x18,
346}; 360};
347 361
@@ -361,9 +375,12 @@ static unsigned int stac92hd83xxx_pwr_mapping[4] = {
361 0x03, 0x0c, 0x20, 0x40, 375 0x03, 0x0c, 0x20, 0x40,
362}; 376};
363 377
364static hda_nid_t stac92hd83xxx_amp_nids[1] = { 378#define STAC92HD83XXX_NUM_CAPS 2
365 0xc, 379static unsigned long stac92hd83xxx_capvols[] = {
380 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
381 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_OUTPUT),
366}; 382};
383#define stac92hd83xxx_capsws stac92hd83xxx_capvols
367 384
368static hda_nid_t stac92hd71bxx_pwr_nids[3] = { 385static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
369 0x0a, 0x0d, 0x0f 386 0x0a, 0x0d, 0x0f
@@ -394,6 +411,13 @@ static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
394 0x22, 0 411 0x22, 0
395}; 412};
396 413
414#define STAC92HD71BXX_NUM_CAPS 2
415static unsigned long stac92hd71bxx_capvols[] = {
416 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
417 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
418};
419#define stac92hd71bxx_capsws stac92hd71bxx_capvols
420
397static hda_nid_t stac925x_adc_nids[1] = { 421static hda_nid_t stac925x_adc_nids[1] = {
398 0x03, 422 0x03,
399}; 423};
@@ -415,6 +439,13 @@ static hda_nid_t stac925x_dmux_nids[1] = {
415 0x14, 439 0x14,
416}; 440};
417 441
442static unsigned long stac925x_capvols[] = {
443 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
444};
445static unsigned long stac925x_capsws[] = {
446 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
447};
448
418static hda_nid_t stac922x_adc_nids[2] = { 449static hda_nid_t stac922x_adc_nids[2] = {
419 0x06, 0x07, 450 0x06, 0x07,
420}; 451};
@@ -423,6 +454,13 @@ static hda_nid_t stac922x_mux_nids[2] = {
423 0x12, 0x13, 454 0x12, 0x13,
424}; 455};
425 456
457#define STAC922X_NUM_CAPS 2
458static unsigned long stac922x_capvols[] = {
459 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
460 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
461};
462#define stac922x_capsws stac922x_capvols
463
426static hda_nid_t stac927x_slave_dig_outs[2] = { 464static hda_nid_t stac927x_slave_dig_outs[2] = {
427 0x1f, 0, 465 0x1f, 0,
428}; 466};
@@ -452,6 +490,18 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
452 0x13, 0x14, 0 490 0x13, 0x14, 0
453}; 491};
454 492
493#define STAC927X_NUM_CAPS 3
494static unsigned long stac927x_capvols[] = {
495 HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
496 HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
497 HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
498};
499static unsigned long stac927x_capsws[] = {
500 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
501 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
502 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
503};
504
455static const char *stac927x_spdif_labels[5] = { 505static const char *stac927x_spdif_labels[5] = {
456 "Digital Playback", "ADAT", "Analog Mux 1", 506 "Digital Playback", "ADAT", "Analog Mux 1",
457 "Analog Mux 2", "Analog Mux 3" 507 "Analog Mux 2", "Analog Mux 3"
@@ -478,6 +528,16 @@ static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
478 0x17, 0x18, 0 528 0x17, 0x18, 0
479}; 529};
480 530
531#define STAC9205_NUM_CAPS 2
532static unsigned long stac9205_capvols[] = {
533 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
534 HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
535};
536static unsigned long stac9205_capsws[] = {
537 HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
538 HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
539};
540
481static hda_nid_t stac9200_pin_nids[8] = { 541static hda_nid_t stac9200_pin_nids[8] = {
482 0x08, 0x09, 0x0d, 0x0e, 542 0x08, 0x09, 0x0d, 0x0e,
483 0x0f, 0x10, 0x11, 0x12, 543 0x0f, 0x10, 0x11, 0x12,
@@ -528,34 +588,6 @@ static hda_nid_t stac9205_pin_nids[12] = {
528 0x21, 0x22, 588 0x21, 0x22,
529}; 589};
530 590
531#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
532
533static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct sigmatel_spec *spec = codec->spec;
538 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
539
540 kcontrol->private_value ^= get_amp_nid(kcontrol);
541 kcontrol->private_value |= nid;
542
543 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
544}
545
546static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
547 struct snd_ctl_elem_value *ucontrol)
548{
549 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct sigmatel_spec *spec = codec->spec;
551 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
552
553 kcontrol->private_value ^= get_amp_nid(kcontrol);
554 kcontrol->private_value |= nid;
555
556 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
557}
558
559static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, 591static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
560 struct snd_ctl_elem_info *uinfo) 592 struct snd_ctl_elem_info *uinfo)
561{ 593{
@@ -692,9 +724,35 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
692 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
693 struct sigmatel_spec *spec = codec->spec; 725 struct sigmatel_spec *spec = codec->spec;
694 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 726 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
695 727 const struct hda_input_mux *imux = spec->input_mux;
696 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 728 unsigned int idx, prev_idx;
697 spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]); 729
730 idx = ucontrol->value.enumerated.item[0];
731 if (idx >= imux->num_items)
732 idx = imux->num_items - 1;
733 prev_idx = spec->cur_mux[adc_idx];
734 if (prev_idx == idx)
735 return 0;
736 if (idx < spec->num_analog_muxes) {
737 snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
738 AC_VERB_SET_CONNECT_SEL,
739 imux->items[idx].index);
740 if (prev_idx >= spec->num_analog_muxes) {
741 imux = spec->dinput_mux;
742 /* 0 = analog */
743 snd_hda_codec_write_cache(codec,
744 spec->dmux_nids[adc_idx], 0,
745 AC_VERB_SET_CONNECT_SEL,
746 imux->items[0].index);
747 }
748 } else {
749 imux = spec->dinput_mux;
750 snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
751 AC_VERB_SET_CONNECT_SEL,
752 imux->items[idx - 1].index);
753 }
754 spec->cur_mux[adc_idx] = idx;
755 return 1;
698} 756}
699 757
700static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, 758static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
@@ -725,41 +783,6 @@ static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
725 spec->mono_nid, &spec->cur_mmux); 783 spec->mono_nid, &spec->cur_mmux);
726} 784}
727 785
728static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
729 struct snd_ctl_elem_info *uinfo)
730{
731 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
732 struct sigmatel_spec *spec = codec->spec;
733 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
734}
735
736static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
737 struct snd_ctl_elem_value *ucontrol)
738{
739 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
740 struct sigmatel_spec *spec = codec->spec;
741
742 ucontrol->value.enumerated.item[0] = spec->cur_amux;
743 return 0;
744}
745
746static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
747 struct snd_ctl_elem_value *ucontrol)
748{
749 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
750 struct sigmatel_spec *spec = codec->spec;
751 struct snd_kcontrol *ctl =
752 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
753 if (!ctl)
754 return -EINVAL;
755
756 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
757 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
758
759 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
760 0, &spec->cur_amux);
761}
762
763#define stac92xx_aloopback_info snd_ctl_boolean_mono_info 786#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
764 787
765static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, 788static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
@@ -827,92 +850,20 @@ static struct hda_verb stac9200_eapd_init[] = {
827 {} 850 {}
828}; 851};
829 852
830static struct hda_verb stac92hd73xx_6ch_core_init[] = {
831 /* set master volume and direct control */
832 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
833 /* setup adcs to point to mixer */
834 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
835 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
836 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
837 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 /* setup import muxs */
840 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
841 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
844 {}
845};
846
847static struct hda_verb dell_eq_core_init[] = { 853static struct hda_verb dell_eq_core_init[] = {
848 /* set master volume to max value without distortion 854 /* set master volume to max value without distortion
849 * and direct control */ 855 * and direct control */
850 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, 856 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
851 /* setup adcs to point to mixer */
852 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
853 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
854 /* setup import muxs */
855 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
856 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
857 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
858 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
859 {}
860};
861
862static struct hda_verb dell_m6_core_init[] = {
863 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
864 /* setup adcs to point to mixer */
865 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
866 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
867 /* setup import muxs */
868 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
869 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
870 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
871 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
872 {}
873};
874
875static struct hda_verb stac92hd73xx_8ch_core_init[] = {
876 /* set master volume and direct control */
877 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
878 /* setup adcs to point to mixer */
879 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
880 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
881 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
882 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
883 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
884 /* setup import muxs */
885 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
886 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
887 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
888 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
889 {} 857 {}
890}; 858};
891 859
892static struct hda_verb stac92hd73xx_10ch_core_init[] = { 860static struct hda_verb stac92hd73xx_core_init[] = {
893 /* set master volume and direct control */ 861 /* set master volume and direct control */
894 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 862 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
895 /* dac3 is connected to import3 mux */
896 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
897 /* setup adcs to point to mixer */
898 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
899 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
900 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
901 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
902 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
903 /* setup import muxs */
904 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
905 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
906 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
907 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
908 {} 863 {}
909}; 864};
910 865
911static struct hda_verb stac92hd83xxx_core_init[] = { 866static struct hda_verb stac92hd83xxx_core_init[] = {
912 { 0xa, AC_VERB_SET_CONNECT_SEL, 0x1},
913 { 0xb, AC_VERB_SET_CONNECT_SEL, 0x1},
914 { 0xd, AC_VERB_SET_CONNECT_SEL, 0x0},
915
916 /* power state controls amps */ 867 /* power state controls amps */
917 { 0x01, AC_VERB_SET_EAPD, 1 << 2}, 868 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
918 {} 869 {}
@@ -924,19 +875,6 @@ static struct hda_verb stac92hd71bxx_core_init[] = {
924 {} 875 {}
925}; 876};
926 877
927#define HD_DISABLE_PORTF 1
928static struct hda_verb stac92hd71bxx_analog_core_init[] = {
929 /* start of config #1 */
930
931 /* connect port 0f to audio mixer */
932 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
933 /* start of config #2 */
934
935 /* set master volume and direct control */
936 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
937 {}
938};
939
940static struct hda_verb stac92hd71bxx_unmute_core_init[] = { 878static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
941 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ 879 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
942 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 880 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -995,31 +933,6 @@ static struct hda_verb stac9205_core_init[] = {
995 .put = stac92xx_mono_mux_enum_put, \ 933 .put = stac92xx_mono_mux_enum_put, \
996 } 934 }
997 935
998#define STAC_AMP_MUX \
999 { \
1000 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1001 .name = "Amp Selector Capture Switch", \
1002 .count = 1, \
1003 .info = stac92xx_amp_mux_enum_info, \
1004 .get = stac92xx_amp_mux_enum_get, \
1005 .put = stac92xx_amp_mux_enum_put, \
1006 }
1007
1008#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1009 { \
1010 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1011 .name = xname, \
1012 .index = 0, \
1013 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1014 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1015 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1016 .info = stac92xx_amp_volume_info, \
1017 .get = stac92xx_amp_volume_get, \
1018 .put = stac92xx_amp_volume_put, \
1019 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1020 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1021 }
1022
1023#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ 936#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1024 { \ 937 { \
1025 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 938 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -1050,34 +963,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
1050 { } /* end */ 963 { } /* end */
1051}; 964};
1052 965
1053#define DELL_M6_MIXER 6
1054static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1055 /* start of config #1 */
1056 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1057 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1058
1059 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1060 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1061
1062 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1063 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1064
1065 /* start of config #2 */
1066 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1067 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1068
1069 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1070 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1071
1072 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1073 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1074
1075 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1076 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1077
1078 { } /* end */
1079};
1080
1081static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { 966static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1082 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), 967 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1083 {} 968 {}
@@ -1093,134 +978,14 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1093 {} 978 {}
1094}; 979};
1095 980
1096static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1097 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1098 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1099
1100 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1101 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1102
1103 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1104 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1105
1106 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1107 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1108
1109 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1110 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1111
1112 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1113 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1114
1115 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1116 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1117 { } /* end */
1118};
1119
1120static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1121 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1122 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1123
1124 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1125 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1126
1127 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1128 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1129
1130 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1131 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1132
1133 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1134 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1135
1136 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1137 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1138
1139 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1140 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1141 { } /* end */
1142};
1143
1144
1145static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1146 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1147 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1148
1149 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1150 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1151
1152 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1153 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1154
1155 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1156 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1157
1158 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1159 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1160
1161 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1162 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1163
1164 /*
1165 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1166 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1167 */
1168 { } /* end */
1169};
1170
1171static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1172 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1173 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1174
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1177 /* analog pc-beep replaced with digital beep support */
1178 /*
1179 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1180 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1181 */
1182
1183 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1184 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1185
1186 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1187 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1188
1189 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1190 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1191
1192 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1193 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1194 { } /* end */
1195};
1196 981
1197static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { 982static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1198 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) 983 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1199}; 984};
1200 985
1201static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1202 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1203 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1204
1205 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1206 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1207 { } /* end */
1208};
1209
1210static struct snd_kcontrol_new stac925x_mixer[] = { 986static struct snd_kcontrol_new stac925x_mixer[] = {
1211 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), 987 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1212 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), 988 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1213 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1214 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1215 { } /* end */
1216};
1217
1218static struct snd_kcontrol_new stac9205_mixer[] = {
1219 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1220 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1221
1222 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1223 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1224 { } /* end */ 989 { } /* end */
1225}; 990};
1226 991
@@ -1229,29 +994,6 @@ static struct snd_kcontrol_new stac9205_loopback[] = {
1229 {} 994 {}
1230}; 995};
1231 996
1232/* This needs to be generated dynamically based on sequence */
1233static struct snd_kcontrol_new stac922x_mixer[] = {
1234 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1235 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1236
1237 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1238 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1239 { } /* end */
1240};
1241
1242
1243static struct snd_kcontrol_new stac927x_mixer[] = {
1244 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1245 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1246
1247 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1248 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1249
1250 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1251 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1252 { } /* end */
1253};
1254
1255static struct snd_kcontrol_new stac927x_loopback[] = { 997static struct snd_kcontrol_new stac927x_loopback[] = {
1256 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), 998 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1257 {} 999 {}
@@ -1309,16 +1051,19 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1309 int err; 1051 int err;
1310 int i; 1052 int i;
1311 1053
1312 err = snd_hda_add_new_ctls(codec, spec->mixer); 1054 if (spec->mixer) {
1313 if (err < 0) 1055 err = snd_hda_add_new_ctls(codec, spec->mixer);
1314 return err; 1056 if (err < 0)
1057 return err;
1058 }
1315 1059
1316 for (i = 0; i < spec->num_mixers; i++) { 1060 for (i = 0; i < spec->num_mixers; i++) {
1317 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 1061 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1318 if (err < 0) 1062 if (err < 0)
1319 return err; 1063 return err;
1320 } 1064 }
1321 if (spec->num_dmuxes > 0) { 1065 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1066 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1322 stac_dmux_mixer.count = spec->num_dmuxes; 1067 stac_dmux_mixer.count = spec->num_dmuxes;
1323 err = snd_hda_ctl_add(codec, 1068 err = snd_hda_ctl_add(codec,
1324 snd_ctl_new1(&stac_dmux_mixer, codec)); 1069 snd_ctl_new1(&stac_dmux_mixer, codec));
@@ -1590,8 +1335,6 @@ static struct snd_pci_quirk stac9200_cfg_tbl[] = {
1590 /* SigmaTel reference board */ 1335 /* SigmaTel reference board */
1591 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1336 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1592 "DFI LanParty", STAC_REF), 1337 "DFI LanParty", STAC_REF),
1593 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
1594 "SigmaTel",STAC_9205_REF),
1595 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, 1338 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1596 "DFI LanParty", STAC_REF), 1339 "DFI LanParty", STAC_REF),
1597 /* Dell laptops have BIOS problem */ 1340 /* Dell laptops have BIOS problem */
@@ -1767,22 +1510,32 @@ static unsigned int dell_m6_pin_configs[13] = {
1767 0x4f0000f0, 1510 0x4f0000f0,
1768}; 1511};
1769 1512
1513static unsigned int alienware_m17x_pin_configs[13] = {
1514 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1515 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1516 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1517 0x904601b0,
1518};
1519
1770static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { 1520static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1771 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, 1521 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1772 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, 1522 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1773 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, 1523 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1774 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, 1524 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1775 [STAC_DELL_EQ] = dell_m6_pin_configs, 1525 [STAC_DELL_EQ] = dell_m6_pin_configs,
1526 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1776}; 1527};
1777 1528
1778static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1529static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1779 [STAC_92HD73XX_AUTO] = "auto", 1530 [STAC_92HD73XX_AUTO] = "auto",
1780 [STAC_92HD73XX_NO_JD] = "no-jd", 1531 [STAC_92HD73XX_NO_JD] = "no-jd",
1781 [STAC_92HD73XX_REF] = "ref", 1532 [STAC_92HD73XX_REF] = "ref",
1533 [STAC_92HD73XX_INTEL] = "intel",
1782 [STAC_DELL_M6_AMIC] = "dell-m6-amic", 1534 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1783 [STAC_DELL_M6_DMIC] = "dell-m6-dmic", 1535 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1784 [STAC_DELL_M6_BOTH] = "dell-m6", 1536 [STAC_DELL_M6_BOTH] = "dell-m6",
1785 [STAC_DELL_EQ] = "dell-eq", 1537 [STAC_DELL_EQ] = "dell-eq",
1538 [STAC_ALIENWARE_M17X] = "alienware",
1786}; 1539};
1787 1540
1788static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { 1541static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
@@ -1791,6 +1544,10 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1791 "DFI LanParty", STAC_92HD73XX_REF), 1544 "DFI LanParty", STAC_92HD73XX_REF),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, 1545 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1793 "DFI LanParty", STAC_92HD73XX_REF), 1546 "DFI LanParty", STAC_92HD73XX_REF),
1547 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1548 "Intel DG45ID", STAC_92HD73XX_INTEL),
1549 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1550 "Intel DG45FC", STAC_92HD73XX_INTEL),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, 1551 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1795 "Dell Studio 1535", STAC_DELL_M6_DMIC), 1552 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, 1553 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
@@ -1811,6 +1568,14 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1811 "Dell Studio 1537", STAC_DELL_M6_DMIC), 1568 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1812 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, 1569 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1813 "Dell Studio 17", STAC_DELL_M6_DMIC), 1570 "Dell Studio 17", STAC_DELL_M6_DMIC),
1571 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
1572 "Dell Studio 1555", STAC_DELL_M6_DMIC),
1573 {} /* terminator */
1574};
1575
1576static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1577 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1578 "Alienware M17x", STAC_ALIENWARE_M17X),
1814 {} /* terminator */ 1579 {} /* terminator */
1815}; 1580};
1816 1581
@@ -1821,8 +1586,8 @@ static unsigned int ref92hd83xxx_pin_configs[10] = {
1821}; 1586};
1822 1587
1823static unsigned int dell_s14_pin_configs[10] = { 1588static unsigned int dell_s14_pin_configs[10] = {
1824 0x02214030, 0x02211010, 0x02a19020, 0x01014050, 1589 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
1825 0x40f000f0, 0x01819040, 0x40f000f0, 0x90a60160, 1590 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
1826 0x40f000f0, 0x40f000f0, 1591 0x40f000f0, 0x40f000f0,
1827}; 1592};
1828 1593
@@ -1921,6 +1686,10 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1921 "HP mini 1000", STAC_HP_M4), 1686 "HP mini 1000", STAC_HP_M4),
1922 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, 1687 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1923 "HP HDX", STAC_HP_HDX), /* HDX16 */ 1688 "HP HDX", STAC_HP_HDX), /* HDX16 */
1689 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
1690 "HP dv6", STAC_HP_DV5),
1691 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1692 "HP", STAC_HP_DV5),
1924 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, 1693 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1925 "unknown Dell", STAC_DELL_M4_1), 1694 "unknown Dell", STAC_DELL_M4_1),
1926 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, 1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
@@ -2266,7 +2035,7 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), 2035 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), 2036 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), 2037 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), 2038 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), 2039 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), 2040 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), 2041 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
@@ -2344,6 +2113,8 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2344 /* SigmaTel reference board */ 2113 /* SigmaTel reference board */
2345 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 2114 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
2346 "DFI LanParty", STAC_9205_REF), 2115 "DFI LanParty", STAC_9205_REF),
2116 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
2117 "SigmaTel", STAC_9205_REF),
2347 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, 2118 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
2348 "DFI LanParty", STAC_9205_REF), 2119 "DFI LanParty", STAC_9205_REF),
2349 /* Dell */ 2120 /* Dell */
@@ -2378,6 +2149,7 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = {
2378 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228, 2149 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
2379 "Dell Vostro 1500", STAC_9205_DELL_M42), 2150 "Dell Vostro 1500", STAC_9205_DELL_M42),
2380 /* Gateway */ 2151 /* Gateway */
2152 SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
2381 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD), 2153 SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
2382 {} /* terminator */ 2154 {} /* terminator */
2383}; 2155};
@@ -2633,8 +2405,7 @@ static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2633 return 0; 2405 return 0;
2634} 2406}
2635 2407
2636static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, 2408static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2637 unsigned char type);
2638 2409
2639static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, 2410static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2640 struct snd_ctl_elem_value *ucontrol) 2411 struct snd_ctl_elem_value *ucontrol)
@@ -2648,7 +2419,7 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2648 /* check to be sure that the ports are upto date with 2419 /* check to be sure that the ports are upto date with
2649 * switch changes 2420 * switch changes
2650 */ 2421 */
2651 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); 2422 stac_issue_unsol_event(codec, nid);
2652 2423
2653 return 1; 2424 return 1;
2654} 2425}
@@ -2781,7 +2552,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
2781 * appropriately according to the pin direction 2552 * appropriately according to the pin direction
2782 */ 2553 */
2783 if (spec->hp_detect) 2554 if (spec->hp_detect)
2784 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); 2555 stac_issue_unsol_event(codec, nid);
2785 2556
2786 return 1; 2557 return 1;
2787} 2558}
@@ -2850,8 +2621,6 @@ enum {
2850 STAC_CTL_WIDGET_VOL, 2621 STAC_CTL_WIDGET_VOL,
2851 STAC_CTL_WIDGET_MUTE, 2622 STAC_CTL_WIDGET_MUTE,
2852 STAC_CTL_WIDGET_MONO_MUX, 2623 STAC_CTL_WIDGET_MONO_MUX,
2853 STAC_CTL_WIDGET_AMP_MUX,
2854 STAC_CTL_WIDGET_AMP_VOL,
2855 STAC_CTL_WIDGET_HP_SWITCH, 2624 STAC_CTL_WIDGET_HP_SWITCH,
2856 STAC_CTL_WIDGET_IO_SWITCH, 2625 STAC_CTL_WIDGET_IO_SWITCH,
2857 STAC_CTL_WIDGET_CLFE_SWITCH, 2626 STAC_CTL_WIDGET_CLFE_SWITCH,
@@ -2862,8 +2631,6 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2862 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 2631 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2863 HDA_CODEC_MUTE(NULL, 0, 0, 0), 2632 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2864 STAC_MONO_MUX, 2633 STAC_MONO_MUX,
2865 STAC_AMP_MUX,
2866 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2867 STAC_CODEC_HP_SWITCH(NULL), 2634 STAC_CODEC_HP_SWITCH(NULL),
2868 STAC_CODEC_IO_SWITCH(NULL, 0), 2635 STAC_CODEC_IO_SWITCH(NULL, 0),
2869 STAC_CODEC_CLFE_SWITCH(NULL, 0), 2636 STAC_CODEC_CLFE_SWITCH(NULL, 0),
@@ -2964,6 +2731,8 @@ static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2964 struct snd_kcontrol_new *knew; 2731 struct snd_kcontrol_new *knew;
2965 struct hda_input_mux *imux = &spec->private_imux; 2732 struct hda_input_mux *imux = &spec->private_imux;
2966 2733
2734 if (spec->auto_mic)
2735 return 0; /* no need for input source */
2967 if (!spec->num_adcs || imux->num_items <= 1) 2736 if (!spec->num_adcs || imux->num_items <= 1)
2968 return 0; /* no need for input source control */ 2737 return 0; /* no need for input source control */
2969 knew = stac_control_new(spec, &stac_input_src_temp, 2738 knew = stac_control_new(spec, &stac_input_src_temp,
@@ -3057,7 +2826,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3057 HDA_MAX_CONNECTIONS); 2826 HDA_MAX_CONNECTIONS);
3058 for (j = 0; j < conn_len; j++) { 2827 for (j = 0; j < conn_len; j++) {
3059 wcaps = get_wcaps(codec, conn[j]); 2828 wcaps = get_wcaps(codec, conn[j]);
3060 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2829 wtype = get_wcaps_type(wcaps);
3061 /* we check only analog outputs */ 2830 /* we check only analog outputs */
3062 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) 2831 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3063 continue; 2832 continue;
@@ -3316,6 +3085,21 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3316 return 0; 3085 return 0;
3317} 3086}
3318 3087
3088static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3089 unsigned long sw, int idx)
3090{
3091 int err;
3092 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3093 "Capture Volume", vol);
3094 if (err < 0)
3095 return err;
3096 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3097 "Capture Switch", sw);
3098 if (err < 0)
3099 return err;
3100 return 0;
3101}
3102
3319/* add playback controls from the parsed DAC table */ 3103/* add playback controls from the parsed DAC table */
3320static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, 3104static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3321 const struct auto_pin_cfg *cfg) 3105 const struct auto_pin_cfg *cfg)
@@ -3389,7 +3173,7 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3389 spec->mono_nid, 3173 spec->mono_nid,
3390 con_lst, 3174 con_lst,
3391 HDA_MAX_NUM_INPUTS); 3175 HDA_MAX_NUM_INPUTS);
3392 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) 3176 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3393 return -EINVAL; 3177 return -EINVAL;
3394 3178
3395 for (i = 0; i < num_cons; i++) { 3179 for (i = 0; i < num_cons; i++) {
@@ -3403,37 +3187,6 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3403 "Mono Mux", spec->mono_nid); 3187 "Mono Mux", spec->mono_nid);
3404} 3188}
3405 3189
3406/* labels for amp mux outputs */
3407static const char *stac92xx_amp_labels[3] = {
3408 "Front Microphone", "Microphone", "Line In",
3409};
3410
3411/* create amp out controls mux on capable codecs */
3412static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3413{
3414 struct sigmatel_spec *spec = codec->spec;
3415 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3416 int i, err;
3417
3418 for (i = 0; i < spec->num_amps; i++) {
3419 amp_mux->items[amp_mux->num_items].label =
3420 stac92xx_amp_labels[i];
3421 amp_mux->items[amp_mux->num_items].index = i;
3422 amp_mux->num_items++;
3423 }
3424
3425 if (spec->num_amps > 1) {
3426 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3427 "Amp Selector Capture Switch", 0);
3428 if (err < 0)
3429 return err;
3430 }
3431 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3432 "Amp Capture Volume",
3433 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3434}
3435
3436
3437/* create PC beep volume controls */ 3190/* create PC beep volume controls */
3438static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, 3191static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3439 hda_nid_t nid) 3192 hda_nid_t nid)
@@ -3502,19 +3255,33 @@ static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3502static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) 3255static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3503{ 3256{
3504 struct sigmatel_spec *spec = codec->spec; 3257 struct sigmatel_spec *spec = codec->spec;
3505 int wcaps, nid, i, err = 0; 3258 int i, j, err = 0;
3506 3259
3507 for (i = 0; i < spec->num_muxes; i++) { 3260 for (i = 0; i < spec->num_muxes; i++) {
3261 hda_nid_t nid;
3262 unsigned int wcaps;
3263 unsigned long val;
3264
3508 nid = spec->mux_nids[i]; 3265 nid = spec->mux_nids[i];
3509 wcaps = get_wcaps(codec, nid); 3266 wcaps = get_wcaps(codec, nid);
3267 if (!(wcaps & AC_WCAP_OUT_AMP))
3268 continue;
3510 3269
3511 if (wcaps & AC_WCAP_OUT_AMP) { 3270 /* check whether already the same control was created as
3512 err = stac92xx_add_control_idx(spec, 3271 * normal Capture Volume.
3513 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", 3272 */
3514 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 3273 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3515 if (err < 0) 3274 for (j = 0; j < spec->num_caps; j++) {
3516 return err; 3275 if (spec->capvols[j] == val)
3276 break;
3517 } 3277 }
3278 if (j < spec->num_caps)
3279 continue;
3280
3281 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3282 "Mux Capture Volume", val);
3283 if (err < 0)
3284 return err;
3518 } 3285 }
3519 return 0; 3286 return 0;
3520}; 3287};
@@ -3535,7 +3302,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3535 spec->smux_nids[0], 3302 spec->smux_nids[0],
3536 con_lst, 3303 con_lst,
3537 HDA_MAX_NUM_INPUTS); 3304 HDA_MAX_NUM_INPUTS);
3538 if (!num_cons) 3305 if (num_cons <= 0)
3539 return -EINVAL; 3306 return -EINVAL;
3540 3307
3541 if (!labels) 3308 if (!labels)
@@ -3556,101 +3323,239 @@ static const char *stac92xx_dmic_labels[5] = {
3556 "Digital Mic 3", "Digital Mic 4" 3323 "Digital Mic 3", "Digital Mic 4"
3557}; 3324};
3558 3325
3326static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3327 hda_nid_t nid)
3328{
3329 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3330 int i, nums;
3331
3332 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3333 for (i = 0; i < nums; i++)
3334 if (conn[i] == nid)
3335 return i;
3336 return -1;
3337}
3338
3339/* create a volume assigned to the given pin (only if supported) */
3340/* return 1 if the volume control is created */
3341static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3342 const char *label, int direction)
3343{
3344 unsigned int caps, nums;
3345 char name[32];
3346 int err;
3347
3348 if (direction == HDA_OUTPUT)
3349 caps = AC_WCAP_OUT_AMP;
3350 else
3351 caps = AC_WCAP_IN_AMP;
3352 if (!(get_wcaps(codec, nid) & caps))
3353 return 0;
3354 caps = query_amp_caps(codec, nid, direction);
3355 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3356 if (!nums)
3357 return 0;
3358 snprintf(name, sizeof(name), "%s Capture Volume", label);
3359 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3360 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3361 if (err < 0)
3362 return err;
3363 return 1;
3364}
3365
3559/* create playback/capture controls for input pins on dmic capable codecs */ 3366/* create playback/capture controls for input pins on dmic capable codecs */
3560static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, 3367static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3561 const struct auto_pin_cfg *cfg) 3368 const struct auto_pin_cfg *cfg)
3562{ 3369{
3563 struct sigmatel_spec *spec = codec->spec; 3370 struct sigmatel_spec *spec = codec->spec;
3371 struct hda_input_mux *imux = &spec->private_imux;
3564 struct hda_input_mux *dimux = &spec->private_dimux; 3372 struct hda_input_mux *dimux = &spec->private_dimux;
3565 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 3373 int err, i, active_mics;
3566 int err, i, j; 3374 unsigned int def_conf;
3567 char name[32];
3568 3375
3569 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; 3376 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3570 dimux->items[dimux->num_items].index = 0; 3377 dimux->items[dimux->num_items].index = 0;
3571 dimux->num_items++; 3378 dimux->num_items++;
3572 3379
3380 active_mics = 0;
3381 for (i = 0; i < spec->num_dmics; i++) {
3382 /* check the validity: sometimes it's a dead vendor-spec node */
3383 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3384 != AC_WID_PIN)
3385 continue;
3386 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3387 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3388 active_mics++;
3389 }
3390
3573 for (i = 0; i < spec->num_dmics; i++) { 3391 for (i = 0; i < spec->num_dmics; i++) {
3574 hda_nid_t nid; 3392 hda_nid_t nid;
3575 int index; 3393 int index;
3576 int num_cons; 3394 const char *label;
3577 unsigned int wcaps;
3578 unsigned int def_conf;
3579 3395
3580 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); 3396 nid = spec->dmic_nids[i];
3397 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3398 continue;
3399 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3581 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 3400 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3582 continue; 3401 continue;
3583 3402
3584 nid = spec->dmic_nids[i]; 3403 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3585 num_cons = snd_hda_get_connections(codec, 3404 if (index < 0)
3586 spec->dmux_nids[0], 3405 continue;
3587 con_lst,
3588 HDA_MAX_NUM_INPUTS);
3589 for (j = 0; j < num_cons; j++)
3590 if (con_lst[j] == nid) {
3591 index = j;
3592 goto found;
3593 }
3594 continue;
3595found:
3596 wcaps = get_wcaps(codec, nid) &
3597 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3598 3406
3599 if (wcaps) { 3407 if (active_mics == 1)
3600 sprintf(name, "%s Capture Volume", 3408 label = "Digital Mic";
3601 stac92xx_dmic_labels[dimux->num_items]); 3409 else
3410 label = stac92xx_dmic_labels[dimux->num_items];
3602 3411
3603 err = stac92xx_add_control(spec, 3412 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
3604 STAC_CTL_WIDGET_VOL, 3413 if (err < 0)
3605 name, 3414 return err;
3606 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 3415 if (!err) {
3607 (wcaps & AC_WCAP_OUT_AMP) ? 3416 err = create_elem_capture_vol(codec, nid, label,
3608 HDA_OUTPUT : HDA_INPUT)); 3417 HDA_OUTPUT);
3609 if (err < 0) 3418 if (err < 0)
3610 return err; 3419 return err;
3611 } 3420 }
3612 3421
3613 dimux->items[dimux->num_items].label = 3422 dimux->items[dimux->num_items].label = label;
3614 stac92xx_dmic_labels[dimux->num_items];
3615 dimux->items[dimux->num_items].index = index; 3423 dimux->items[dimux->num_items].index = index;
3616 dimux->num_items++; 3424 dimux->num_items++;
3425 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3426 imux->items[imux->num_items].label = label;
3427 imux->items[imux->num_items].index = index;
3428 imux->num_items++;
3429 }
3430 }
3431
3432 return 0;
3433}
3434
3435static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3436 hda_nid_t *fixed, hda_nid_t *ext)
3437{
3438 unsigned int cfg;
3439
3440 if (!nid)
3441 return 0;
3442 cfg = snd_hda_codec_get_pincfg(codec, nid);
3443 switch (get_defcfg_connect(cfg)) {
3444 case AC_JACK_PORT_FIXED:
3445 if (*fixed)
3446 return 1; /* already occupied */
3447 *fixed = nid;
3448 break;
3449 case AC_JACK_PORT_COMPLEX:
3450 if (*ext)
3451 return 1; /* already occupied */
3452 *ext = nid;
3453 break;
3617 } 3454 }
3455 return 0;
3456}
3618 3457
3458static int set_mic_route(struct hda_codec *codec,
3459 struct sigmatel_mic_route *mic,
3460 hda_nid_t pin)
3461{
3462 struct sigmatel_spec *spec = codec->spec;
3463 struct auto_pin_cfg *cfg = &spec->autocfg;
3464 int i;
3465
3466 mic->pin = pin;
3467 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3468 if (pin == cfg->input_pins[i])
3469 break;
3470 if (i <= AUTO_PIN_FRONT_MIC) {
3471 /* analog pin */
3472 i = get_connection_index(codec, spec->mux_nids[0], pin);
3473 if (i < 0)
3474 return -1;
3475 mic->mux_idx = i;
3476 mic->dmux_idx = -1;
3477 if (spec->dmux_nids)
3478 mic->dmux_idx = get_connection_index(codec,
3479 spec->dmux_nids[0],
3480 spec->mux_nids[0]);
3481 } else if (spec->dmux_nids) {
3482 /* digital pin */
3483 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3484 if (i < 0)
3485 return -1;
3486 mic->dmux_idx = i;
3487 mic->mux_idx = -1;
3488 if (spec->mux_nids)
3489 mic->mux_idx = get_connection_index(codec,
3490 spec->mux_nids[0],
3491 spec->dmux_nids[0]);
3492 }
3619 return 0; 3493 return 0;
3620} 3494}
3621 3495
3496/* return non-zero if the device is for automatic mic switch */
3497static int stac_check_auto_mic(struct hda_codec *codec)
3498{
3499 struct sigmatel_spec *spec = codec->spec;
3500 struct auto_pin_cfg *cfg = &spec->autocfg;
3501 hda_nid_t fixed, ext;
3502 int i;
3503
3504 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3505 if (cfg->input_pins[i])
3506 return 0; /* must be exclusively mics */
3507 }
3508 fixed = ext = 0;
3509 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3510 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3511 return 0;
3512 for (i = 0; i < spec->num_dmics; i++)
3513 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3514 return 0;
3515 if (!fixed || !ext)
3516 return 0;
3517 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3518 return 0; /* no unsol support */
3519 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3520 set_mic_route(codec, &spec->int_mic, fixed))
3521 return 0; /* something is wrong */
3522 return 1;
3523}
3524
3622/* create playback/capture controls for input pins */ 3525/* create playback/capture controls for input pins */
3623static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 3526static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3624{ 3527{
3625 struct sigmatel_spec *spec = codec->spec; 3528 struct sigmatel_spec *spec = codec->spec;
3626 struct hda_input_mux *imux = &spec->private_imux; 3529 struct hda_input_mux *imux = &spec->private_imux;
3627 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 3530 int i, j;
3628 int i, j, k;
3629 3531
3630 for (i = 0; i < AUTO_PIN_LAST; i++) { 3532 for (i = 0; i < AUTO_PIN_LAST; i++) {
3631 int index; 3533 hda_nid_t nid = cfg->input_pins[i];
3534 int index, err;
3632 3535
3633 if (!cfg->input_pins[i]) 3536 if (!nid)
3634 continue; 3537 continue;
3635 index = -1; 3538 index = -1;
3636 for (j = 0; j < spec->num_muxes; j++) { 3539 for (j = 0; j < spec->num_muxes; j++) {
3637 int num_cons; 3540 index = get_connection_index(codec, spec->mux_nids[j],
3638 num_cons = snd_hda_get_connections(codec, 3541 nid);
3639 spec->mux_nids[j], 3542 if (index >= 0)
3640 con_lst, 3543 break;
3641 HDA_MAX_NUM_INPUTS);
3642 for (k = 0; k < num_cons; k++)
3643 if (con_lst[k] == cfg->input_pins[i]) {
3644 index = k;
3645 goto found;
3646 }
3647 } 3544 }
3648 continue; 3545 if (index < 0)
3649 found: 3546 continue;
3547
3548 err = create_elem_capture_vol(codec, nid,
3549 auto_pin_cfg_labels[i],
3550 HDA_INPUT);
3551 if (err < 0)
3552 return err;
3553
3650 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3554 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3651 imux->items[imux->num_items].index = index; 3555 imux->items[imux->num_items].index = index;
3652 imux->num_items++; 3556 imux->num_items++;
3653 } 3557 }
3558 spec->num_analog_muxes = imux->num_items;
3654 3559
3655 if (imux->num_items) { 3560 if (imux->num_items) {
3656 /* 3561 /*
@@ -3702,7 +3607,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3702{ 3607{
3703 struct sigmatel_spec *spec = codec->spec; 3608 struct sigmatel_spec *spec = codec->spec;
3704 int hp_swap = 0; 3609 int hp_swap = 0;
3705 int err; 3610 int i, err;
3706 3611
3707 if ((err = snd_hda_parse_pin_def_config(codec, 3612 if ((err = snd_hda_parse_pin_def_config(codec,
3708 &spec->autocfg, 3613 &spec->autocfg,
@@ -3742,11 +3647,10 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3742 if (snd_hda_get_connections(codec, 3647 if (snd_hda_get_connections(codec,
3743 spec->autocfg.mono_out_pin, conn_list, 1) && 3648 spec->autocfg.mono_out_pin, conn_list, 1) &&
3744 snd_hda_get_connections(codec, conn_list[0], 3649 snd_hda_get_connections(codec, conn_list[0],
3745 conn_list, 1)) { 3650 conn_list, 1) > 0) {
3746 3651
3747 int wcaps = get_wcaps(codec, conn_list[0]); 3652 int wcaps = get_wcaps(codec, conn_list[0]);
3748 int wid_type = (wcaps & AC_WCAP_TYPE) 3653 int wid_type = get_wcaps_type(wcaps);
3749 >> AC_WCAP_TYPE_SHIFT;
3750 /* LR swap check, some stac925x have a mux that 3654 /* LR swap check, some stac925x have a mux that
3751 * changes the DACs output path instead of the 3655 * changes the DACs output path instead of the
3752 * mono-mux path. 3656 * mono-mux path.
@@ -3837,6 +3741,21 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3837 spec->autocfg.line_outs = 0; 3741 spec->autocfg.line_outs = 0;
3838 } 3742 }
3839 3743
3744 if (stac_check_auto_mic(codec)) {
3745 spec->auto_mic = 1;
3746 /* only one capture for auto-mic */
3747 spec->num_adcs = 1;
3748 spec->num_caps = 1;
3749 spec->num_muxes = 1;
3750 }
3751
3752 for (i = 0; i < spec->num_caps; i++) {
3753 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3754 spec->capsws[i], i);
3755 if (err < 0)
3756 return err;
3757 }
3758
3840 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); 3759 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3841 if (err < 0) 3760 if (err < 0)
3842 return err; 3761 return err;
@@ -3846,11 +3765,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3846 if (err < 0) 3765 if (err < 0)
3847 return err; 3766 return err;
3848 } 3767 }
3849 if (spec->num_amps > 0) {
3850 err = stac92xx_auto_create_amp_output_ctls(codec);
3851 if (err < 0)
3852 return err;
3853 }
3854 if (spec->num_dmics > 0 && !spec->dinput_mux) 3768 if (spec->num_dmics > 0 && !spec->dinput_mux)
3855 if ((err = stac92xx_auto_create_dmic_input_ctls(codec, 3769 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3856 &spec->autocfg)) < 0) 3770 &spec->autocfg)) < 0)
@@ -3887,7 +3801,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3887 spec->dinput_mux = &spec->private_dimux; 3801 spec->dinput_mux = &spec->private_dimux;
3888 spec->sinput_mux = &spec->private_smux; 3802 spec->sinput_mux = &spec->private_smux;
3889 spec->mono_mux = &spec->private_mono_mux; 3803 spec->mono_mux = &spec->private_mono_mux;
3890 spec->amp_mux = &spec->private_amp_mux;
3891 return 1; 3804 return 1;
3892} 3805}
3893 3806
@@ -4065,7 +3978,7 @@ static int stac92xx_add_jack(struct hda_codec *codec,
4065 jack->nid = nid; 3978 jack->nid = nid;
4066 jack->type = type; 3979 jack->type = type;
4067 3980
4068 sprintf(name, "%s at %s %s Jack", 3981 snprintf(name, sizeof(name), "%s at %s %s Jack",
4069 snd_hda_get_jack_type(def_conf), 3982 snd_hda_get_jack_type(def_conf),
4070 snd_hda_get_jack_connectivity(def_conf), 3983 snd_hda_get_jack_connectivity(def_conf),
4071 snd_hda_get_jack_location(def_conf)); 3984 snd_hda_get_jack_location(def_conf));
@@ -4099,14 +4012,14 @@ static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4099} 4012}
4100 4013
4101static struct sigmatel_event *stac_get_event(struct hda_codec *codec, 4014static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4102 hda_nid_t nid, unsigned char type) 4015 hda_nid_t nid)
4103{ 4016{
4104 struct sigmatel_spec *spec = codec->spec; 4017 struct sigmatel_spec *spec = codec->spec;
4105 struct sigmatel_event *event = spec->events.list; 4018 struct sigmatel_event *event = spec->events.list;
4106 int i; 4019 int i;
4107 4020
4108 for (i = 0; i < spec->events.used; i++, event++) { 4021 for (i = 0; i < spec->events.used; i++, event++) {
4109 if (event->nid == nid && event->type == type) 4022 if (event->nid == nid)
4110 return event; 4023 return event;
4111 } 4024 }
4112 return NULL; 4025 return NULL;
@@ -4126,24 +4039,32 @@ static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4126 return NULL; 4039 return NULL;
4127} 4040}
4128 4041
4129static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, 4042/* check if given nid is a valid pin and no other events are assigned
4130 unsigned int type) 4043 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4044 * Otherwise, returns zero.
4045 */
4046static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4047 unsigned int type)
4131{ 4048{
4132 struct sigmatel_event *event; 4049 struct sigmatel_event *event;
4133 int tag; 4050 int tag;
4134 4051
4135 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) 4052 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4136 return; 4053 return 0;
4137 event = stac_get_event(codec, nid, type); 4054 event = stac_get_event(codec, nid);
4138 if (event) 4055 if (event) {
4056 if (event->type != type)
4057 return 0;
4139 tag = event->tag; 4058 tag = event->tag;
4140 else 4059 } else {
4141 tag = stac_add_event(codec->spec, nid, type, 0); 4060 tag = stac_add_event(codec->spec, nid, type, 0);
4142 if (tag < 0) 4061 if (tag < 0)
4143 return; 4062 return 0;
4063 }
4144 snd_hda_codec_write_cache(codec, nid, 0, 4064 snd_hda_codec_write_cache(codec, nid, 0,
4145 AC_VERB_SET_UNSOLICITED_ENABLE, 4065 AC_VERB_SET_UNSOLICITED_ENABLE,
4146 AC_USRSP_EN | tag); 4066 AC_USRSP_EN | tag);
4067 return 1;
4147} 4068}
4148 4069
4149static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) 4070static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
@@ -4236,20 +4157,39 @@ static int stac92xx_init(struct hda_codec *codec)
4236 hda_nid_t nid = cfg->hp_pins[i]; 4157 hda_nid_t nid = cfg->hp_pins[i];
4237 enable_pin_detect(codec, nid, STAC_HP_EVENT); 4158 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4238 } 4159 }
4160 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4161 cfg->speaker_outs > 0) {
4162 /* enable pin-detect for line-outs as well */
4163 for (i = 0; i < cfg->line_outs; i++) {
4164 hda_nid_t nid = cfg->line_out_pins[i];
4165 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4166 }
4167 }
4168
4239 /* force to enable the first line-out; the others are set up 4169 /* force to enable the first line-out; the others are set up
4240 * in unsol_event 4170 * in unsol_event
4241 */ 4171 */
4242 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], 4172 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4243 AC_PINCTL_OUT_EN); 4173 AC_PINCTL_OUT_EN);
4244 /* fake event to set up pins */ 4174 /* fake event to set up pins */
4245 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], 4175 if (cfg->hp_pins[0])
4246 STAC_HP_EVENT); 4176 stac_issue_unsol_event(codec, cfg->hp_pins[0]);
4177 else if (cfg->line_out_pins[0])
4178 stac_issue_unsol_event(codec, cfg->line_out_pins[0]);
4247 } else { 4179 } else {
4248 stac92xx_auto_init_multi_out(codec); 4180 stac92xx_auto_init_multi_out(codec);
4249 stac92xx_auto_init_hp_out(codec); 4181 stac92xx_auto_init_hp_out(codec);
4250 for (i = 0; i < cfg->hp_outs; i++) 4182 for (i = 0; i < cfg->hp_outs; i++)
4251 stac_toggle_power_map(codec, cfg->hp_pins[i], 1); 4183 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4252 } 4184 }
4185 if (spec->auto_mic) {
4186 /* initialize connection to analog input */
4187 if (spec->dmux_nids)
4188 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4189 AC_VERB_SET_CONNECT_SEL, 0);
4190 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4191 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4192 }
4253 for (i = 0; i < AUTO_PIN_LAST; i++) { 4193 for (i = 0; i < AUTO_PIN_LAST; i++) {
4254 hda_nid_t nid = cfg->input_pins[i]; 4194 hda_nid_t nid = cfg->input_pins[i];
4255 if (nid) { 4195 if (nid) {
@@ -4276,10 +4216,9 @@ static int stac92xx_init(struct hda_codec *codec)
4276 } 4216 }
4277 conf = snd_hda_codec_get_pincfg(codec, nid); 4217 conf = snd_hda_codec_get_pincfg(codec, nid);
4278 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { 4218 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4279 enable_pin_detect(codec, nid, 4219 if (enable_pin_detect(codec, nid,
4280 STAC_INSERT_EVENT); 4220 STAC_INSERT_EVENT))
4281 stac_issue_unsol_event(codec, nid, 4221 stac_issue_unsol_event(codec, nid);
4282 STAC_INSERT_EVENT);
4283 } 4222 }
4284 } 4223 }
4285 } 4224 }
@@ -4324,10 +4263,8 @@ static int stac92xx_init(struct hda_codec *codec)
4324 stac_toggle_power_map(codec, nid, 1); 4263 stac_toggle_power_map(codec, nid, 1);
4325 continue; 4264 continue;
4326 } 4265 }
4327 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { 4266 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4328 enable_pin_detect(codec, nid, STAC_PWR_EVENT); 4267 stac_issue_unsol_event(codec, nid);
4329 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4330 }
4331 } 4268 }
4332 if (spec->dac_list) 4269 if (spec->dac_list)
4333 stac92xx_power_down(codec); 4270 stac92xx_power_down(codec);
@@ -4431,6 +4368,48 @@ static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4431 return 0; 4368 return 0;
4432} 4369}
4433 4370
4371static void stac92xx_line_out_detect(struct hda_codec *codec,
4372 int presence)
4373{
4374 struct sigmatel_spec *spec = codec->spec;
4375 struct auto_pin_cfg *cfg = &spec->autocfg;
4376 int i;
4377
4378 for (i = 0; i < cfg->line_outs; i++) {
4379 if (presence)
4380 break;
4381 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4382 if (presence) {
4383 unsigned int pinctl;
4384 pinctl = snd_hda_codec_read(codec,
4385 cfg->line_out_pins[i], 0,
4386 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4387 if (pinctl & AC_PINCTL_IN_EN)
4388 presence = 0; /* mic- or line-input */
4389 }
4390 }
4391
4392 if (presence) {
4393 /* disable speakers */
4394 for (i = 0; i < cfg->speaker_outs; i++)
4395 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4396 AC_PINCTL_OUT_EN);
4397 if (spec->eapd_mask && spec->eapd_switch)
4398 stac_gpio_set(codec, spec->gpio_mask,
4399 spec->gpio_dir, spec->gpio_data &
4400 ~spec->eapd_mask);
4401 } else {
4402 /* enable speakers */
4403 for (i = 0; i < cfg->speaker_outs; i++)
4404 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4405 AC_PINCTL_OUT_EN);
4406 if (spec->eapd_mask && spec->eapd_switch)
4407 stac_gpio_set(codec, spec->gpio_mask,
4408 spec->gpio_dir, spec->gpio_data |
4409 spec->eapd_mask);
4410 }
4411}
4412
4434/* return non-zero if the hp-pin of the given array index isn't 4413/* return non-zero if the hp-pin of the given array index isn't
4435 * a jack-detection target 4414 * a jack-detection target
4436 */ 4415 */
@@ -4483,13 +4462,6 @@ static void stac92xx_hp_detect(struct hda_codec *codec)
4483 for (i = 0; i < cfg->line_outs; i++) 4462 for (i = 0; i < cfg->line_outs; i++)
4484 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], 4463 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4485 AC_PINCTL_OUT_EN); 4464 AC_PINCTL_OUT_EN);
4486 for (i = 0; i < cfg->speaker_outs; i++)
4487 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4488 AC_PINCTL_OUT_EN);
4489 if (spec->eapd_mask && spec->eapd_switch)
4490 stac_gpio_set(codec, spec->gpio_mask,
4491 spec->gpio_dir, spec->gpio_data &
4492 ~spec->eapd_mask);
4493 } else { 4465 } else {
4494 /* enable lineouts */ 4466 /* enable lineouts */
4495 if (spec->hp_switch) 4467 if (spec->hp_switch)
@@ -4498,14 +4470,8 @@ static void stac92xx_hp_detect(struct hda_codec *codec)
4498 for (i = 0; i < cfg->line_outs; i++) 4470 for (i = 0; i < cfg->line_outs; i++)
4499 stac92xx_set_pinctl(codec, cfg->line_out_pins[i], 4471 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4500 AC_PINCTL_OUT_EN); 4472 AC_PINCTL_OUT_EN);
4501 for (i = 0; i < cfg->speaker_outs; i++)
4502 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4503 AC_PINCTL_OUT_EN);
4504 if (spec->eapd_mask && spec->eapd_switch)
4505 stac_gpio_set(codec, spec->gpio_mask,
4506 spec->gpio_dir, spec->gpio_data |
4507 spec->eapd_mask);
4508 } 4473 }
4474 stac92xx_line_out_detect(codec, presence);
4509 /* toggle hp outs */ 4475 /* toggle hp outs */
4510 for (i = 0; i < cfg->hp_outs; i++) { 4476 for (i = 0; i < cfg->hp_outs; i++) {
4511 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; 4477 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
@@ -4590,10 +4556,28 @@ static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4590 } 4556 }
4591} 4557}
4592 4558
4593static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, 4559static void stac92xx_mic_detect(struct hda_codec *codec)
4594 unsigned char type) 4560{
4561 struct sigmatel_spec *spec = codec->spec;
4562 struct sigmatel_mic_route *mic;
4563
4564 if (get_pin_presence(codec, spec->ext_mic.pin))
4565 mic = &spec->ext_mic;
4566 else
4567 mic = &spec->int_mic;
4568 if (mic->dmux_idx >= 0)
4569 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4570 AC_VERB_SET_CONNECT_SEL,
4571 mic->dmux_idx);
4572 if (mic->mux_idx >= 0)
4573 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4574 AC_VERB_SET_CONNECT_SEL,
4575 mic->mux_idx);
4576}
4577
4578static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4595{ 4579{
4596 struct sigmatel_event *event = stac_get_event(codec, nid, type); 4580 struct sigmatel_event *event = stac_get_event(codec, nid);
4597 if (!event) 4581 if (!event)
4598 return; 4582 return;
4599 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); 4583 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
@@ -4612,8 +4596,18 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4612 4596
4613 switch (event->type) { 4597 switch (event->type) {
4614 case STAC_HP_EVENT: 4598 case STAC_HP_EVENT:
4599 case STAC_LO_EVENT:
4615 stac92xx_hp_detect(codec); 4600 stac92xx_hp_detect(codec);
4616 /* fallthru */ 4601 break;
4602 case STAC_MIC_EVENT:
4603 stac92xx_mic_detect(codec);
4604 break;
4605 }
4606
4607 switch (event->type) {
4608 case STAC_HP_EVENT:
4609 case STAC_LO_EVENT:
4610 case STAC_MIC_EVENT:
4617 case STAC_INSERT_EVENT: 4611 case STAC_INSERT_EVENT:
4618 case STAC_PWR_EVENT: 4612 case STAC_PWR_EVENT:
4619 if (spec->num_pwrs > 0) 4613 if (spec->num_pwrs > 0)
@@ -4703,9 +4697,13 @@ static int stac92xx_resume(struct hda_codec *codec)
4703 snd_hda_codec_resume_amp(codec); 4697 snd_hda_codec_resume_amp(codec);
4704 snd_hda_codec_resume_cache(codec); 4698 snd_hda_codec_resume_cache(codec);
4705 /* fake event to set up pins again to override cached values */ 4699 /* fake event to set up pins again to override cached values */
4706 if (spec->hp_detect) 4700 if (spec->hp_detect) {
4707 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], 4701 if (spec->autocfg.hp_pins[0])
4708 STAC_HP_EVENT); 4702 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4703 else if (spec->autocfg.line_out_pins[0])
4704 stac_issue_unsol_event(codec,
4705 spec->autocfg.line_out_pins[0]);
4706 }
4709 return 0; 4707 return 0;
4710} 4708}
4711 4709
@@ -4745,6 +4743,19 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4745static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) 4743static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4746{ 4744{
4747 struct sigmatel_spec *spec = codec->spec; 4745 struct sigmatel_spec *spec = codec->spec;
4746 int i;
4747 hda_nid_t nid;
4748
4749 /* reset each pin before powering down DAC/ADC to avoid click noise */
4750 nid = codec->start_nid;
4751 for (i = 0; i < codec->num_nodes; i++, nid++) {
4752 unsigned int wcaps = get_wcaps(codec, nid);
4753 unsigned int wid_type = get_wcaps_type(wcaps);
4754 if (wid_type == AC_WID_PIN)
4755 snd_hda_codec_read(codec, nid, 0,
4756 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4757 }
4758
4748 if (spec->eapd_mask) 4759 if (spec->eapd_mask)
4749 stac_gpio_set(codec, spec->gpio_mask, 4760 stac_gpio_set(codec, spec->gpio_mask,
4750 spec->gpio_dir, spec->gpio_data & 4761 spec->gpio_dir, spec->gpio_data &
@@ -4781,7 +4792,8 @@ static int patch_stac9200(struct hda_codec *codec)
4781 stac9200_models, 4792 stac9200_models,
4782 stac9200_cfg_tbl); 4793 stac9200_cfg_tbl);
4783 if (spec->board_config < 0) 4794 if (spec->board_config < 0)
4784 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); 4795 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4796 codec->chip_name);
4785 else 4797 else
4786 stac92xx_set_config_regs(codec, 4798 stac92xx_set_config_regs(codec,
4787 stac9200_brd_tbl[spec->board_config]); 4799 stac9200_brd_tbl[spec->board_config]);
@@ -4853,8 +4865,8 @@ static int patch_stac925x(struct hda_codec *codec)
4853 stac925x_cfg_tbl); 4865 stac925x_cfg_tbl);
4854 again: 4866 again:
4855 if (spec->board_config < 0) 4867 if (spec->board_config < 0)
4856 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 4868 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4857 "using BIOS defaults\n"); 4869 codec->chip_name);
4858 else 4870 else
4859 stac92xx_set_config_regs(codec, 4871 stac92xx_set_config_regs(codec,
4860 stac925x_brd_tbl[spec->board_config]); 4872 stac925x_brd_tbl[spec->board_config]);
@@ -4884,6 +4896,9 @@ static int patch_stac925x(struct hda_codec *codec)
4884 4896
4885 spec->init = stac925x_core_init; 4897 spec->init = stac925x_core_init;
4886 spec->mixer = stac925x_mixer; 4898 spec->mixer = stac925x_mixer;
4899 spec->num_caps = 1;
4900 spec->capvols = stac925x_capvols;
4901 spec->capsws = stac925x_capsws;
4887 4902
4888 err = stac92xx_parse_auto_config(codec, 0x8, 0x7); 4903 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4889 if (!err) { 4904 if (!err) {
@@ -4905,16 +4920,6 @@ static int patch_stac925x(struct hda_codec *codec)
4905 return 0; 4920 return 0;
4906} 4921}
4907 4922
4908static struct hda_input_mux stac92hd73xx_dmux = {
4909 .num_items = 4,
4910 .items = {
4911 { "Analog Inputs", 0x0b },
4912 { "Digital Mic 1", 0x09 },
4913 { "Digital Mic 2", 0x0a },
4914 { "CD", 0x08 },
4915 }
4916};
4917
4918static int patch_stac92hd73xx(struct hda_codec *codec) 4923static int patch_stac92hd73xx(struct hda_codec *codec)
4919{ 4924{
4920 struct sigmatel_spec *spec; 4925 struct sigmatel_spec *spec;
@@ -4934,10 +4939,16 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
4934 STAC_92HD73XX_MODELS, 4939 STAC_92HD73XX_MODELS,
4935 stac92hd73xx_models, 4940 stac92hd73xx_models,
4936 stac92hd73xx_cfg_tbl); 4941 stac92hd73xx_cfg_tbl);
4942 /* check codec subsystem id if not found */
4943 if (spec->board_config < 0)
4944 spec->board_config =
4945 snd_hda_check_board_codec_sid_config(codec,
4946 STAC_92HD73XX_MODELS, stac92hd73xx_models,
4947 stac92hd73xx_codec_id_cfg_tbl);
4937again: 4948again:
4938 if (spec->board_config < 0) 4949 if (spec->board_config < 0)
4939 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4950 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4940 " STAC92HD73XX, using BIOS defaults\n"); 4951 codec->chip_name);
4941 else 4952 else
4942 stac92xx_set_config_regs(codec, 4953 stac92xx_set_config_regs(codec,
4943 stac92hd73xx_brd_tbl[spec->board_config]); 4954 stac92hd73xx_brd_tbl[spec->board_config]);
@@ -4950,20 +4961,15 @@ again:
4950 "number of channels defaulting to DAC count\n"); 4961 "number of channels defaulting to DAC count\n");
4951 num_dacs = STAC92HD73_DAC_COUNT; 4962 num_dacs = STAC92HD73_DAC_COUNT;
4952 } 4963 }
4964 spec->init = stac92hd73xx_core_init;
4953 switch (num_dacs) { 4965 switch (num_dacs) {
4954 case 0x3: /* 6 Channel */ 4966 case 0x3: /* 6 Channel */
4955 spec->mixer = stac92hd73xx_6ch_mixer;
4956 spec->init = stac92hd73xx_6ch_core_init;
4957 spec->aloopback_ctl = stac92hd73xx_6ch_loopback; 4967 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4958 break; 4968 break;
4959 case 0x4: /* 8 Channel */ 4969 case 0x4: /* 8 Channel */
4960 spec->mixer = stac92hd73xx_8ch_mixer;
4961 spec->init = stac92hd73xx_8ch_core_init;
4962 spec->aloopback_ctl = stac92hd73xx_8ch_loopback; 4970 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4963 break; 4971 break;
4964 case 0x5: /* 10 Channel */ 4972 case 0x5: /* 10 Channel */
4965 spec->mixer = stac92hd73xx_10ch_mixer;
4966 spec->init = stac92hd73xx_10ch_core_init;
4967 spec->aloopback_ctl = stac92hd73xx_10ch_loopback; 4973 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4968 break; 4974 break;
4969 } 4975 }
@@ -4978,14 +4984,14 @@ again:
4978 spec->dmic_nids = stac92hd73xx_dmic_nids; 4984 spec->dmic_nids = stac92hd73xx_dmic_nids;
4979 spec->dmux_nids = stac92hd73xx_dmux_nids; 4985 spec->dmux_nids = stac92hd73xx_dmux_nids;
4980 spec->smux_nids = stac92hd73xx_smux_nids; 4986 spec->smux_nids = stac92hd73xx_smux_nids;
4981 spec->amp_nids = stac92hd73xx_amp_nids;
4982 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4983 4987
4984 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); 4988 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4985 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); 4989 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4986 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); 4990 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4987 memcpy(&spec->private_dimux, &stac92hd73xx_dmux, 4991
4988 sizeof(stac92hd73xx_dmux)); 4992 spec->num_caps = STAC92HD73XX_NUM_CAPS;
4993 spec->capvols = stac92hd73xx_capvols;
4994 spec->capsws = stac92hd73xx_capsws;
4989 4995
4990 switch (spec->board_config) { 4996 switch (spec->board_config) {
4991 case STAC_DELL_EQ: 4997 case STAC_DELL_EQ:
@@ -4995,43 +5001,40 @@ again:
4995 case STAC_DELL_M6_DMIC: 5001 case STAC_DELL_M6_DMIC:
4996 case STAC_DELL_M6_BOTH: 5002 case STAC_DELL_M6_BOTH:
4997 spec->num_smuxes = 0; 5003 spec->num_smuxes = 0;
4998 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
4999 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
5000 spec->eapd_switch = 0; 5004 spec->eapd_switch = 0;
5001 spec->num_amps = 1;
5002 5005
5003 if (spec->board_config != STAC_DELL_EQ)
5004 spec->init = dell_m6_core_init;
5005 switch (spec->board_config) { 5006 switch (spec->board_config) {
5006 case STAC_DELL_M6_AMIC: /* Analog Mics */ 5007 case STAC_DELL_M6_AMIC: /* Analog Mics */
5007 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); 5008 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5008 spec->num_dmics = 0; 5009 spec->num_dmics = 0;
5009 spec->private_dimux.num_items = 1;
5010 break; 5010 break;
5011 case STAC_DELL_M6_DMIC: /* Digital Mics */ 5011 case STAC_DELL_M6_DMIC: /* Digital Mics */
5012 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); 5012 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5013 spec->num_dmics = 1; 5013 spec->num_dmics = 1;
5014 spec->private_dimux.num_items = 2;
5015 break; 5014 break;
5016 case STAC_DELL_M6_BOTH: /* Both */ 5015 case STAC_DELL_M6_BOTH: /* Both */
5017 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); 5016 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5018 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); 5017 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5019 spec->num_dmics = 1; 5018 spec->num_dmics = 1;
5020 spec->private_dimux.num_items = 2;
5021 break; 5019 break;
5022 } 5020 }
5023 break; 5021 break;
5022 case STAC_ALIENWARE_M17X:
5023 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5024 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5025 spec->eapd_switch = 0;
5026 break;
5024 default: 5027 default:
5025 spec->num_dmics = STAC92HD73XX_NUM_DMICS; 5028 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5026 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); 5029 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5027 spec->eapd_switch = 1; 5030 spec->eapd_switch = 1;
5031 break;
5028 } 5032 }
5029 if (spec->board_config > STAC_92HD73XX_REF) { 5033 if (spec->board_config != STAC_92HD73XX_REF) {
5030 /* GPIO0 High = Enable EAPD */ 5034 /* GPIO0 High = Enable EAPD */
5031 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; 5035 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5032 spec->gpio_data = 0x01; 5036 spec->gpio_data = 0x01;
5033 } 5037 }
5034 spec->dinput_mux = &spec->private_dimux;
5035 5038
5036 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); 5039 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5037 spec->pwr_nids = stac92hd73xx_pwr_nids; 5040 spec->pwr_nids = stac92hd73xx_pwr_nids;
@@ -5063,15 +5066,6 @@ again:
5063 return 0; 5066 return 0;
5064} 5067}
5065 5068
5066static struct hda_input_mux stac92hd83xxx_dmux = {
5067 .num_items = 3,
5068 .items = {
5069 { "Analog Inputs", 0x03 },
5070 { "Digital Mic 1", 0x04 },
5071 { "Digital Mic 2", 0x05 },
5072 }
5073};
5074
5075static int patch_stac92hd83xxx(struct hda_codec *codec) 5069static int patch_stac92hd83xxx(struct hda_codec *codec)
5076{ 5070{
5077 struct sigmatel_spec *spec; 5071 struct sigmatel_spec *spec;
@@ -5086,34 +5080,31 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
5086 5080
5087 codec->spec = spec; 5081 codec->spec = spec;
5088 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; 5082 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5089 spec->mono_nid = 0x19;
5090 spec->digbeep_nid = 0x21; 5083 spec->digbeep_nid = 0x21;
5091 spec->dmic_nids = stac92hd83xxx_dmic_nids; 5084 spec->mux_nids = stac92hd83xxx_mux_nids;
5092 spec->dmux_nids = stac92hd83xxx_dmux_nids; 5085 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5093 spec->adc_nids = stac92hd83xxx_adc_nids; 5086 spec->adc_nids = stac92hd83xxx_adc_nids;
5087 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5094 spec->pwr_nids = stac92hd83xxx_pwr_nids; 5088 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5095 spec->amp_nids = stac92hd83xxx_amp_nids;
5096 spec->pwr_mapping = stac92hd83xxx_pwr_mapping; 5089 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5097 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); 5090 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5098 spec->multiout.dac_nids = spec->dac_nids; 5091 spec->multiout.dac_nids = spec->dac_nids;
5099 5092
5100 spec->init = stac92hd83xxx_core_init; 5093 spec->init = stac92hd83xxx_core_init;
5101 spec->mixer = stac92hd83xxx_mixer;
5102 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); 5094 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5103 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5104 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5105 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
5106 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5107 spec->dinput_mux = &stac92hd83xxx_dmux;
5108 spec->pin_nids = stac92hd83xxx_pin_nids; 5095 spec->pin_nids = stac92hd83xxx_pin_nids;
5096 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5097 spec->capvols = stac92hd83xxx_capvols;
5098 spec->capsws = stac92hd83xxx_capsws;
5099
5109 spec->board_config = snd_hda_check_board_config(codec, 5100 spec->board_config = snd_hda_check_board_config(codec,
5110 STAC_92HD83XXX_MODELS, 5101 STAC_92HD83XXX_MODELS,
5111 stac92hd83xxx_models, 5102 stac92hd83xxx_models,
5112 stac92hd83xxx_cfg_tbl); 5103 stac92hd83xxx_cfg_tbl);
5113again: 5104again:
5114 if (spec->board_config < 0) 5105 if (spec->board_config < 0)
5115 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5106 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5116 " STAC92HD83XXX, using BIOS defaults\n"); 5107 codec->chip_name);
5117 else 5108 else
5118 stac92xx_set_config_regs(codec, 5109 stac92xx_set_config_regs(codec,
5119 stac92hd83xxx_brd_tbl[spec->board_config]); 5110 stac92hd83xxx_brd_tbl[spec->board_config]);
@@ -5155,6 +5146,8 @@ again:
5155 5146
5156 num_dacs = snd_hda_get_connections(codec, nid, 5147 num_dacs = snd_hda_get_connections(codec, nid,
5157 conn, STAC92HD83_DAC_COUNT + 1) - 1; 5148 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5149 if (num_dacs < 0)
5150 num_dacs = STAC92HD83_DAC_COUNT;
5158 5151
5159 /* set port X to select the last DAC 5152 /* set port X to select the last DAC
5160 */ 5153 */
@@ -5168,25 +5161,6 @@ again:
5168 return 0; 5161 return 0;
5169} 5162}
5170 5163
5171static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5172 .num_items = 3,
5173 .items = {
5174 { "Analog Inputs", 0x00 },
5175 { "Digital Mic 1", 0x02 },
5176 { "Digital Mic 2", 0x03 },
5177 }
5178};
5179
5180static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
5181 .num_items = 4,
5182 .items = {
5183 { "Analog Inputs", 0x00 },
5184 { "Mixer", 0x01 },
5185 { "Digital Mic 1", 0x02 },
5186 { "Digital Mic 2", 0x03 },
5187 }
5188};
5189
5190/* get the pin connection (fixed, none, etc) */ 5164/* get the pin connection (fixed, none, etc) */
5191static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) 5165static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5192{ 5166{
@@ -5247,7 +5221,6 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
5247 struct sigmatel_spec *spec; 5221 struct sigmatel_spec *spec;
5248 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; 5222 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5249 int err = 0; 5223 int err = 0;
5250 unsigned int ndmic_nids = 0;
5251 5224
5252 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5225 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5253 if (spec == NULL) 5226 if (spec == NULL)
@@ -5276,13 +5249,13 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
5276 stac92hd71bxx_cfg_tbl); 5249 stac92hd71bxx_cfg_tbl);
5277again: 5250again:
5278 if (spec->board_config < 0) 5251 if (spec->board_config < 0)
5279 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5252 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5280 " STAC92HD71BXX, using BIOS defaults\n"); 5253 codec->chip_name);
5281 else 5254 else
5282 stac92xx_set_config_regs(codec, 5255 stac92xx_set_config_regs(codec,
5283 stac92hd71bxx_brd_tbl[spec->board_config]); 5256 stac92hd71bxx_brd_tbl[spec->board_config]);
5284 5257
5285 if (spec->board_config > STAC_92HD71BXX_REF) { 5258 if (spec->board_config != STAC_92HD71BXX_REF) {
5286 /* GPIO0 = EAPD */ 5259 /* GPIO0 = EAPD */
5287 spec->gpio_mask = 0x01; 5260 spec->gpio_mask = 0x01;
5288 spec->gpio_dir = 0x01; 5261 spec->gpio_dir = 0x01;
@@ -5292,6 +5265,10 @@ again:
5292 spec->dmic_nids = stac92hd71bxx_dmic_nids; 5265 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5293 spec->dmux_nids = stac92hd71bxx_dmux_nids; 5266 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5294 5267
5268 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5269 spec->capvols = stac92hd71bxx_capvols;
5270 spec->capsws = stac92hd71bxx_capsws;
5271
5295 switch (codec->vendor_id) { 5272 switch (codec->vendor_id) {
5296 case 0x111d76b6: /* 4 Port without Analog Mixer */ 5273 case 0x111d76b6: /* 4 Port without Analog Mixer */
5297 case 0x111d76b7: 5274 case 0x111d76b7:
@@ -5299,24 +5276,13 @@ again:
5299 /* fallthru */ 5276 /* fallthru */
5300 case 0x111d76b4: /* 6 Port without Analog Mixer */ 5277 case 0x111d76b4: /* 6 Port without Analog Mixer */
5301 case 0x111d76b5: 5278 case 0x111d76b5:
5302 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5303 sizeof(stac92hd71bxx_dmux_nomixer));
5304 spec->mixer = stac92hd71bxx_mixer;
5305 spec->init = stac92hd71bxx_core_init; 5279 spec->init = stac92hd71bxx_core_init;
5306 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5280 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5307 spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5281 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5308 stac92hd71bxx_dmic_nids, 5282 stac92hd71bxx_dmic_nids,
5309 STAC92HD71BXX_NUM_DMICS); 5283 STAC92HD71BXX_NUM_DMICS);
5310 if (spec->num_dmics) {
5311 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5312 spec->dinput_mux = &spec->private_dimux;
5313 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5314 }
5315 break; 5284 break;
5316 case 0x111d7608: /* 5 Port with Analog Mixer */ 5285 case 0x111d7608: /* 5 Port with Analog Mixer */
5317 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5318 sizeof(stac92hd71bxx_dmux_amixer));
5319 spec->private_dimux.num_items--;
5320 switch (spec->board_config) { 5286 switch (spec->board_config) {
5321 case STAC_HP_M4: 5287 case STAC_HP_M4:
5322 /* Enable VREF power saving on GPIO1 detect */ 5288 /* Enable VREF power saving on GPIO1 detect */
@@ -5338,11 +5304,8 @@ again:
5338 5304
5339 /* no output amps */ 5305 /* no output amps */
5340 spec->num_pwrs = 0; 5306 spec->num_pwrs = 0;
5341 spec->mixer = stac92hd71bxx_analog_mixer;
5342 spec->dinput_mux = &spec->private_dimux;
5343
5344 /* disable VSW */ 5307 /* disable VSW */
5345 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; 5308 spec->init = stac92hd71bxx_core_init;
5346 unmute_init++; 5309 unmute_init++;
5347 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); 5310 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5348 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); 5311 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
@@ -5350,8 +5313,6 @@ again:
5350 spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5313 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5351 stac92hd71bxx_dmic_nids, 5314 stac92hd71bxx_dmic_nids,
5352 STAC92HD71BXX_NUM_DMICS - 1); 5315 STAC92HD71BXX_NUM_DMICS - 1);
5353 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5354 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5355 break; 5316 break;
5356 case 0x111d7603: /* 6 Port with Analog Mixer */ 5317 case 0x111d7603: /* 6 Port with Analog Mixer */
5357 if ((codec->revision_id & 0xf) == 1) 5318 if ((codec->revision_id & 0xf) == 1)
@@ -5361,17 +5322,12 @@ again:
5361 spec->num_pwrs = 0; 5322 spec->num_pwrs = 0;
5362 /* fallthru */ 5323 /* fallthru */
5363 default: 5324 default:
5364 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, 5325 spec->init = stac92hd71bxx_core_init;
5365 sizeof(stac92hd71bxx_dmux_amixer));
5366 spec->dinput_mux = &spec->private_dimux;
5367 spec->mixer = stac92hd71bxx_analog_mixer;
5368 spec->init = stac92hd71bxx_analog_core_init;
5369 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5326 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5370 spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5327 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5371 stac92hd71bxx_dmic_nids, 5328 stac92hd71bxx_dmic_nids,
5372 STAC92HD71BXX_NUM_DMICS); 5329 STAC92HD71BXX_NUM_DMICS);
5373 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); 5330 break;
5374 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5375 } 5331 }
5376 5332
5377 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) 5333 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
@@ -5399,6 +5355,7 @@ again:
5399 5355
5400 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); 5356 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5401 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); 5357 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5358 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5402 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); 5359 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5403 5360
5404 switch (spec->board_config) { 5361 switch (spec->board_config) {
@@ -5431,6 +5388,11 @@ again:
5431 case STAC_HP_DV5: 5388 case STAC_HP_DV5:
5432 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); 5389 snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
5433 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); 5390 stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
5391 /* HP dv6 gives the headphone pin as a line-out. Thus we
5392 * need to set hp_detect flag here to force to enable HP
5393 * detection.
5394 */
5395 spec->hp_detect = 1;
5434 break; 5396 break;
5435 case STAC_HP_HDX: 5397 case STAC_HP_HDX:
5436 spec->num_dmics = 1; 5398 spec->num_dmics = 1;
@@ -5453,8 +5415,6 @@ again:
5453#endif 5415#endif
5454 5416
5455 spec->multiout.dac_nids = spec->dac_nids; 5417 spec->multiout.dac_nids = spec->dac_nids;
5456 if (spec->dinput_mux)
5457 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5458 5418
5459 err = stac92xx_parse_auto_config(codec, 0x21, 0); 5419 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5460 if (!err) { 5420 if (!err) {
@@ -5532,8 +5492,8 @@ static int patch_stac922x(struct hda_codec *codec)
5532 5492
5533 again: 5493 again:
5534 if (spec->board_config < 0) 5494 if (spec->board_config < 0)
5535 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " 5495 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5536 "using BIOS defaults\n"); 5496 codec->chip_name);
5537 else 5497 else
5538 stac92xx_set_config_regs(codec, 5498 stac92xx_set_config_regs(codec,
5539 stac922x_brd_tbl[spec->board_config]); 5499 stac922x_brd_tbl[spec->board_config]);
@@ -5546,7 +5506,10 @@ static int patch_stac922x(struct hda_codec *codec)
5546 spec->num_pwrs = 0; 5506 spec->num_pwrs = 0;
5547 5507
5548 spec->init = stac922x_core_init; 5508 spec->init = stac922x_core_init;
5549 spec->mixer = stac922x_mixer; 5509
5510 spec->num_caps = STAC922X_NUM_CAPS;
5511 spec->capvols = stac922x_capvols;
5512 spec->capsws = stac922x_capsws;
5550 5513
5551 spec->multiout.dac_nids = spec->dac_nids; 5514 spec->multiout.dac_nids = spec->dac_nids;
5552 5515
@@ -5595,8 +5558,8 @@ static int patch_stac927x(struct hda_codec *codec)
5595 stac927x_cfg_tbl); 5558 stac927x_cfg_tbl);
5596 again: 5559 again:
5597 if (spec->board_config < 0) 5560 if (spec->board_config < 0)
5598 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5561 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5599 "STAC927x, using BIOS defaults\n"); 5562 codec->chip_name);
5600 else 5563 else
5601 stac92xx_set_config_regs(codec, 5564 stac92xx_set_config_regs(codec,
5602 stac927x_brd_tbl[spec->board_config]); 5565 stac927x_brd_tbl[spec->board_config]);
@@ -5612,16 +5575,18 @@ static int patch_stac927x(struct hda_codec *codec)
5612 spec->dac_list = stac927x_dac_nids; 5575 spec->dac_list = stac927x_dac_nids;
5613 spec->multiout.dac_nids = spec->dac_nids; 5576 spec->multiout.dac_nids = spec->dac_nids;
5614 5577
5578 if (spec->board_config != STAC_D965_REF) {
5579 /* GPIO0 High = Enable EAPD */
5580 spec->eapd_mask = spec->gpio_mask = 0x01;
5581 spec->gpio_dir = spec->gpio_data = 0x01;
5582 }
5583
5615 switch (spec->board_config) { 5584 switch (spec->board_config) {
5616 case STAC_D965_3ST: 5585 case STAC_D965_3ST:
5617 case STAC_D965_5ST: 5586 case STAC_D965_5ST:
5618 /* GPIO0 High = Enable EAPD */ 5587 /* GPIO0 High = Enable EAPD */
5619 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x01;
5620 spec->gpio_data = 0x01;
5621 spec->num_dmics = 0; 5588 spec->num_dmics = 0;
5622
5623 spec->init = d965_core_init; 5589 spec->init = d965_core_init;
5624 spec->mixer = stac927x_mixer;
5625 break; 5590 break;
5626 case STAC_DELL_BIOS: 5591 case STAC_DELL_BIOS:
5627 switch (codec->subsystem_id) { 5592 switch (codec->subsystem_id) {
@@ -5639,29 +5604,28 @@ static int patch_stac927x(struct hda_codec *codec)
5639 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); 5604 snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
5640 /* fallthru */ 5605 /* fallthru */
5641 case STAC_DELL_3ST: 5606 case STAC_DELL_3ST:
5642 /* GPIO2 High = Enable EAPD */ 5607 if (codec->subsystem_id != 0x1028022f) {
5643 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; 5608 /* GPIO2 High = Enable EAPD */
5644 spec->gpio_data = 0x04; 5609 spec->eapd_mask = spec->gpio_mask = 0x04;
5610 spec->gpio_dir = spec->gpio_data = 0x04;
5611 }
5645 spec->dmic_nids = stac927x_dmic_nids; 5612 spec->dmic_nids = stac927x_dmic_nids;
5646 spec->num_dmics = STAC927X_NUM_DMICS; 5613 spec->num_dmics = STAC927X_NUM_DMICS;
5647 5614
5648 spec->init = d965_core_init; 5615 spec->init = d965_core_init;
5649 spec->mixer = stac927x_mixer;
5650 spec->dmux_nids = stac927x_dmux_nids; 5616 spec->dmux_nids = stac927x_dmux_nids;
5651 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); 5617 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5652 break; 5618 break;
5653 default: 5619 default:
5654 if (spec->board_config > STAC_D965_REF) {
5655 /* GPIO0 High = Enable EAPD */
5656 spec->eapd_mask = spec->gpio_mask = 0x01;
5657 spec->gpio_dir = spec->gpio_data = 0x01;
5658 }
5659 spec->num_dmics = 0; 5620 spec->num_dmics = 0;
5660
5661 spec->init = stac927x_core_init; 5621 spec->init = stac927x_core_init;
5662 spec->mixer = stac927x_mixer; 5622 break;
5663 } 5623 }
5664 5624
5625 spec->num_caps = STAC927X_NUM_CAPS;
5626 spec->capvols = stac927x_capvols;
5627 spec->capsws = stac927x_capsws;
5628
5665 spec->num_pwrs = 0; 5629 spec->num_pwrs = 0;
5666 spec->aloopback_ctl = stac927x_loopback; 5630 spec->aloopback_ctl = stac927x_loopback;
5667 spec->aloopback_mask = 0x40; 5631 spec->aloopback_mask = 0x40;
@@ -5723,7 +5687,8 @@ static int patch_stac9205(struct hda_codec *codec)
5723 stac9205_cfg_tbl); 5687 stac9205_cfg_tbl);
5724 again: 5688 again:
5725 if (spec->board_config < 0) 5689 if (spec->board_config < 0)
5726 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); 5690 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5691 codec->chip_name);
5727 else 5692 else
5728 stac92xx_set_config_regs(codec, 5693 stac92xx_set_config_regs(codec,
5729 stac9205_brd_tbl[spec->board_config]); 5694 stac9205_brd_tbl[spec->board_config]);
@@ -5742,9 +5707,12 @@ static int patch_stac9205(struct hda_codec *codec)
5742 spec->num_pwrs = 0; 5707 spec->num_pwrs = 0;
5743 5708
5744 spec->init = stac9205_core_init; 5709 spec->init = stac9205_core_init;
5745 spec->mixer = stac9205_mixer;
5746 spec->aloopback_ctl = stac9205_loopback; 5710 spec->aloopback_ctl = stac9205_loopback;
5747 5711
5712 spec->num_caps = STAC9205_NUM_CAPS;
5713 spec->capvols = stac9205_capvols;
5714 spec->capsws = stac9205_capsws;
5715
5748 spec->aloopback_mask = 0x40; 5716 spec->aloopback_mask = 0x40;
5749 spec->aloopback_shift = 0; 5717 spec->aloopback_shift = 0;
5750 /* Turn on/off EAPD per HP plugging */ 5718 /* Turn on/off EAPD per HP plugging */
@@ -5819,12 +5787,6 @@ static struct hda_verb stac9872_core_init[] = {
5819 {} 5787 {}
5820}; 5788};
5821 5789
5822static struct snd_kcontrol_new stac9872_mixer[] = {
5823 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5824 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5825 { } /* end */
5826};
5827
5828static hda_nid_t stac9872_pin_nids[] = { 5790static hda_nid_t stac9872_pin_nids[] = {
5829 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 5791 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5830 0x11, 0x13, 0x14, 5792 0x11, 0x13, 0x14,
@@ -5838,6 +5800,11 @@ static hda_nid_t stac9872_mux_nids[] = {
5838 0x15 5800 0x15
5839}; 5801};
5840 5802
5803static unsigned long stac9872_capvols[] = {
5804 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5805};
5806#define stac9872_capsws stac9872_capvols
5807
5841static unsigned int stac9872_vaio_pin_configs[9] = { 5808static unsigned int stac9872_vaio_pin_configs[9] = {
5842 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, 5809 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5843 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, 5810 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
@@ -5854,6 +5821,8 @@ static unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
5854}; 5821};
5855 5822
5856static struct snd_pci_quirk stac9872_cfg_tbl[] = { 5823static struct snd_pci_quirk stac9872_cfg_tbl[] = {
5824 SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
5825 "Sony VAIO F/S", STAC_9872_VAIO),
5857 {} /* terminator */ 5826 {} /* terminator */
5858}; 5827};
5859 5828
@@ -5866,26 +5835,28 @@ static int patch_stac9872(struct hda_codec *codec)
5866 if (spec == NULL) 5835 if (spec == NULL)
5867 return -ENOMEM; 5836 return -ENOMEM;
5868 codec->spec = spec; 5837 codec->spec = spec;
5838 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5839 spec->pin_nids = stac9872_pin_nids;
5869 5840
5870 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, 5841 spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
5871 stac9872_models, 5842 stac9872_models,
5872 stac9872_cfg_tbl); 5843 stac9872_cfg_tbl);
5873 if (spec->board_config < 0) 5844 if (spec->board_config < 0)
5874 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, " 5845 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5875 "using BIOS defaults\n"); 5846 codec->chip_name);
5876 else 5847 else
5877 stac92xx_set_config_regs(codec, 5848 stac92xx_set_config_regs(codec,
5878 stac9872_brd_tbl[spec->board_config]); 5849 stac9872_brd_tbl[spec->board_config]);
5879 5850
5880 spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
5881 spec->pin_nids = stac9872_pin_nids;
5882 spec->multiout.dac_nids = spec->dac_nids; 5851 spec->multiout.dac_nids = spec->dac_nids;
5883 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids); 5852 spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
5884 spec->adc_nids = stac9872_adc_nids; 5853 spec->adc_nids = stac9872_adc_nids;
5885 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); 5854 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5886 spec->mux_nids = stac9872_mux_nids; 5855 spec->mux_nids = stac9872_mux_nids;
5887 spec->mixer = stac9872_mixer;
5888 spec->init = stac9872_core_init; 5856 spec->init = stac9872_core_init;
5857 spec->num_caps = 1;
5858 spec->capvols = stac9872_capvols;
5859 spec->capsws = stac9872_capsws;
5889 5860
5890 err = stac92xx_parse_auto_config(codec, 0x10, 0x12); 5861 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5891 if (err < 0) { 5862 if (err < 0) {