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.c1206
1 files changed, 574 insertions, 632 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 6990cfcb6a38..e31e53dc6962 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 {
@@ -81,6 +83,7 @@ enum {
81 STAC_DELL_M6_DMIC, 83 STAC_DELL_M6_DMIC,
82 STAC_DELL_M6_BOTH, 84 STAC_DELL_M6_BOTH,
83 STAC_DELL_EQ, 85 STAC_DELL_EQ,
86 STAC_ALIENWARE_M17X,
84 STAC_92HD73XX_MODELS 87 STAC_92HD73XX_MODELS
85}; 88};
86 89
@@ -177,6 +180,12 @@ struct sigmatel_jack {
177 struct snd_jack *jack; 180 struct snd_jack *jack;
178}; 181};
179 182
183struct sigmatel_mic_route {
184 hda_nid_t pin;
185 unsigned char mux_idx;
186 unsigned char dmux_idx;
187};
188
180struct sigmatel_spec { 189struct sigmatel_spec {
181 struct snd_kcontrol_new *mixers[4]; 190 struct snd_kcontrol_new *mixers[4];
182 unsigned int num_mixers; 191 unsigned int num_mixers;
@@ -188,6 +197,7 @@ struct sigmatel_spec {
188 unsigned int hp_detect: 1; 197 unsigned int hp_detect: 1;
189 unsigned int spdif_mute: 1; 198 unsigned int spdif_mute: 1;
190 unsigned int check_volume_offset:1; 199 unsigned int check_volume_offset:1;
200 unsigned int auto_mic:1;
191 201
192 /* gpio lines */ 202 /* gpio lines */
193 unsigned int eapd_mask; 203 unsigned int eapd_mask;
@@ -219,7 +229,6 @@ struct sigmatel_spec {
219 229
220 /* playback */ 230 /* playback */
221 struct hda_input_mux *mono_mux; 231 struct hda_input_mux *mono_mux;
222 struct hda_input_mux *amp_mux;
223 unsigned int cur_mmux; 232 unsigned int cur_mmux;
224 struct hda_multi_out multiout; 233 struct hda_multi_out multiout;
225 hda_nid_t dac_nids[5]; 234 hda_nid_t dac_nids[5];
@@ -239,6 +248,15 @@ struct sigmatel_spec {
239 unsigned int num_dmuxes; 248 unsigned int num_dmuxes;
240 hda_nid_t *smux_nids; 249 hda_nid_t *smux_nids;
241 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
242 const char **spdif_labels; 260 const char **spdif_labels;
243 261
244 hda_nid_t dig_in_nid; 262 hda_nid_t dig_in_nid;
@@ -263,7 +281,6 @@ struct sigmatel_spec {
263 unsigned int cur_smux[2]; 281 unsigned int cur_smux[2];
264 unsigned int cur_amux; 282 unsigned int cur_amux;
265 hda_nid_t *amp_nids; 283 hda_nid_t *amp_nids;
266 unsigned int num_amps;
267 unsigned int powerdown_adcs; 284 unsigned int powerdown_adcs;
268 285
269 /* i/o switches */ 286 /* i/o switches */
@@ -282,7 +299,6 @@ struct sigmatel_spec {
282 struct hda_input_mux private_dimux; 299 struct hda_input_mux private_dimux;
283 struct hda_input_mux private_imux; 300 struct hda_input_mux private_imux;
284 struct hda_input_mux private_smux; 301 struct hda_input_mux private_smux;
285 struct hda_input_mux private_amp_mux;
286 struct hda_input_mux private_mono_mux; 302 struct hda_input_mux private_mono_mux;
287}; 303};
288 304
@@ -311,11 +327,6 @@ static hda_nid_t stac92hd73xx_adc_nids[2] = {
311 0x1a, 0x1b 327 0x1a, 0x1b
312}; 328};
313 329
314#define DELL_M6_AMP 2
315static hda_nid_t stac92hd73xx_amp_nids[3] = {
316 0x0b, 0x0c, 0x0e
317};
318
319#define STAC92HD73XX_NUM_DMICS 2 330#define STAC92HD73XX_NUM_DMICS 2
320static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { 331static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
321 0x13, 0x14, 0 332 0x13, 0x14, 0
@@ -323,8 +334,8 @@ static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
323 334
324#define STAC92HD73_DAC_COUNT 5 335#define STAC92HD73_DAC_COUNT 5
325 336
326static hda_nid_t stac92hd73xx_mux_nids[4] = { 337static hda_nid_t stac92hd73xx_mux_nids[2] = {
327 0x28, 0x29, 0x2a, 0x2b, 338 0x20, 0x21,
328}; 339};
329 340
330static hda_nid_t stac92hd73xx_dmux_nids[2] = { 341static hda_nid_t stac92hd73xx_dmux_nids[2] = {
@@ -335,14 +346,16 @@ static hda_nid_t stac92hd73xx_smux_nids[2] = {
335 0x22, 0x23, 346 0x22, 0x23,
336}; 347};
337 348
338#define STAC92HD83XXX_NUM_DMICS 2 349#define STAC92HD73XX_NUM_CAPS 2
339static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { 350static unsigned long stac92hd73xx_capvols[] = {
340 0x11, 0x12, 0 351 HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
352 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
341}; 353};
354#define stac92hd73xx_capsws stac92hd73xx_capvols
342 355
343#define STAC92HD83_DAC_COUNT 3 356#define STAC92HD83_DAC_COUNT 3
344 357
345static hda_nid_t stac92hd83xxx_dmux_nids[2] = { 358static hda_nid_t stac92hd83xxx_mux_nids[2] = {
346 0x17, 0x18, 359 0x17, 0x18,
347}; 360};
348 361
@@ -362,9 +375,12 @@ static unsigned int stac92hd83xxx_pwr_mapping[4] = {
362 0x03, 0x0c, 0x20, 0x40, 375 0x03, 0x0c, 0x20, 0x40,
363}; 376};
364 377
365static hda_nid_t stac92hd83xxx_amp_nids[1] = { 378#define STAC92HD83XXX_NUM_CAPS 2
366 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),
367}; 382};
383#define stac92hd83xxx_capsws stac92hd83xxx_capvols
368 384
369static hda_nid_t stac92hd71bxx_pwr_nids[3] = { 385static hda_nid_t stac92hd71bxx_pwr_nids[3] = {
370 0x0a, 0x0d, 0x0f 386 0x0a, 0x0d, 0x0f
@@ -395,6 +411,13 @@ static hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
395 0x22, 0 411 0x22, 0
396}; 412};
397 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
398static hda_nid_t stac925x_adc_nids[1] = { 421static hda_nid_t stac925x_adc_nids[1] = {
399 0x03, 422 0x03,
400}; 423};
@@ -416,6 +439,13 @@ static hda_nid_t stac925x_dmux_nids[1] = {
416 0x14, 439 0x14,
417}; 440};
418 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
419static hda_nid_t stac922x_adc_nids[2] = { 449static hda_nid_t stac922x_adc_nids[2] = {
420 0x06, 0x07, 450 0x06, 0x07,
421}; 451};
@@ -424,6 +454,13 @@ static hda_nid_t stac922x_mux_nids[2] = {
424 0x12, 0x13, 454 0x12, 0x13,
425}; 455};
426 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
427static hda_nid_t stac927x_slave_dig_outs[2] = { 464static hda_nid_t stac927x_slave_dig_outs[2] = {
428 0x1f, 0, 465 0x1f, 0,
429}; 466};
@@ -453,6 +490,18 @@ static hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
453 0x13, 0x14, 0 490 0x13, 0x14, 0
454}; 491};
455 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
456static const char *stac927x_spdif_labels[5] = { 505static const char *stac927x_spdif_labels[5] = {
457 "Digital Playback", "ADAT", "Analog Mux 1", 506 "Digital Playback", "ADAT", "Analog Mux 1",
458 "Analog Mux 2", "Analog Mux 3" 507 "Analog Mux 2", "Analog Mux 3"
@@ -479,6 +528,16 @@ static hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
479 0x17, 0x18, 0 528 0x17, 0x18, 0
480}; 529};
481 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
482static hda_nid_t stac9200_pin_nids[8] = { 541static hda_nid_t stac9200_pin_nids[8] = {
483 0x08, 0x09, 0x0d, 0x0e, 542 0x08, 0x09, 0x0d, 0x0e,
484 0x0f, 0x10, 0x11, 0x12, 543 0x0f, 0x10, 0x11, 0x12,
@@ -529,34 +588,6 @@ static hda_nid_t stac9205_pin_nids[12] = {
529 0x21, 0x22, 588 0x21, 0x22,
530}; 589};
531 590
532#define stac92xx_amp_volume_info snd_hda_mixer_amp_volume_info
533
534static int stac92xx_amp_volume_get(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
536{
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct sigmatel_spec *spec = codec->spec;
539 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
540
541 kcontrol->private_value ^= get_amp_nid(kcontrol);
542 kcontrol->private_value |= nid;
543
544 return snd_hda_mixer_amp_volume_get(kcontrol, ucontrol);
545}
546
547static int stac92xx_amp_volume_put(struct snd_kcontrol *kcontrol,
548 struct snd_ctl_elem_value *ucontrol)
549{
550 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
551 struct sigmatel_spec *spec = codec->spec;
552 hda_nid_t nid = spec->amp_nids[spec->cur_amux];
553
554 kcontrol->private_value ^= get_amp_nid(kcontrol);
555 kcontrol->private_value |= nid;
556
557 return snd_hda_mixer_amp_volume_put(kcontrol, ucontrol);
558}
559
560static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol, 591static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
561 struct snd_ctl_elem_info *uinfo) 592 struct snd_ctl_elem_info *uinfo)
562{ 593{
@@ -693,9 +724,35 @@ static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
694 struct sigmatel_spec *spec = codec->spec; 725 struct sigmatel_spec *spec = codec->spec;
695 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 726 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
696 727 const struct hda_input_mux *imux = spec->input_mux;
697 return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol, 728 unsigned int idx, prev_idx;
698 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;
699} 756}
700 757
701static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol, 758static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
@@ -726,41 +783,6 @@ static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
726 spec->mono_nid, &spec->cur_mmux); 783 spec->mono_nid, &spec->cur_mmux);
727} 784}
728 785
729static int stac92xx_amp_mux_enum_info(struct snd_kcontrol *kcontrol,
730 struct snd_ctl_elem_info *uinfo)
731{
732 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
733 struct sigmatel_spec *spec = codec->spec;
734 return snd_hda_input_mux_info(spec->amp_mux, uinfo);
735}
736
737static int stac92xx_amp_mux_enum_get(struct snd_kcontrol *kcontrol,
738 struct snd_ctl_elem_value *ucontrol)
739{
740 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
741 struct sigmatel_spec *spec = codec->spec;
742
743 ucontrol->value.enumerated.item[0] = spec->cur_amux;
744 return 0;
745}
746
747static int stac92xx_amp_mux_enum_put(struct snd_kcontrol *kcontrol,
748 struct snd_ctl_elem_value *ucontrol)
749{
750 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
751 struct sigmatel_spec *spec = codec->spec;
752 struct snd_kcontrol *ctl =
753 snd_hda_find_mixer_ctl(codec, "Amp Capture Volume");
754 if (!ctl)
755 return -EINVAL;
756
757 snd_ctl_notify(codec->bus->card, SNDRV_CTL_EVENT_MASK_VALUE |
758 SNDRV_CTL_EVENT_MASK_INFO, &ctl->id);
759
760 return snd_hda_input_mux_put(codec, spec->amp_mux, ucontrol,
761 0, &spec->cur_amux);
762}
763
764#define stac92xx_aloopback_info snd_ctl_boolean_mono_info 786#define stac92xx_aloopback_info snd_ctl_boolean_mono_info
765 787
766static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol, 788static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
@@ -828,84 +850,16 @@ static struct hda_verb stac9200_eapd_init[] = {
828 {} 850 {}
829}; 851};
830 852
831static struct hda_verb stac92hd73xx_6ch_core_init[] = {
832 /* set master volume and direct control */
833 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
834 /* setup adcs to point to mixer */
835 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
836 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
837 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
838 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
839 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
840 /* setup import muxs */
841 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
842 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
843 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
844 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
845 {}
846};
847
848static struct hda_verb dell_eq_core_init[] = { 853static struct hda_verb dell_eq_core_init[] = {
849 /* set master volume to max value without distortion 854 /* set master volume to max value without distortion
850 * and direct control */ 855 * and direct control */
851 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, 856 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
852 /* setup adcs to point to mixer */
853 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
854 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
855 /* setup import muxs */
856 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
857 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
858 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
859 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
860 {}
861};
862
863static struct hda_verb dell_m6_core_init[] = {
864 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
865 /* setup adcs to point to mixer */
866 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
867 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
868 /* setup import muxs */
869 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
870 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
871 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
872 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x00},
873 {}
874};
875
876static struct hda_verb stac92hd73xx_8ch_core_init[] = {
877 /* set master volume and direct control */
878 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
879 /* setup adcs to point to mixer */
880 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
881 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
882 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
883 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
884 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
885 /* setup import muxs */
886 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
887 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
888 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
889 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
890 {} 857 {}
891}; 858};
892 859
893static struct hda_verb stac92hd73xx_10ch_core_init[] = { 860static struct hda_verb stac92hd73xx_core_init[] = {
894 /* set master volume and direct control */ 861 /* set master volume and direct control */
895 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, 862 { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
896 /* dac3 is connected to import3 mux */
897 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f},
898 /* setup adcs to point to mixer */
899 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b},
900 { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b},
901 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
902 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
903 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
904 /* setup import muxs */
905 { 0x28, AC_VERB_SET_CONNECT_SEL, 0x01},
906 { 0x29, AC_VERB_SET_CONNECT_SEL, 0x01},
907 { 0x2a, AC_VERB_SET_CONNECT_SEL, 0x01},
908 { 0x2b, AC_VERB_SET_CONNECT_SEL, 0x03},
909 {} 863 {}
910}; 864};
911 865
@@ -925,19 +879,6 @@ static struct hda_verb stac92hd71bxx_core_init[] = {
925 {} 879 {}
926}; 880};
927 881
928#define HD_DISABLE_PORTF 1
929static struct hda_verb stac92hd71bxx_analog_core_init[] = {
930 /* start of config #1 */
931
932 /* connect port 0f to audio mixer */
933 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x2},
934 /* start of config #2 */
935
936 /* set master volume and direct control */
937 { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
938 {}
939};
940
941static struct hda_verb stac92hd71bxx_unmute_core_init[] = { 882static struct hda_verb stac92hd71bxx_unmute_core_init[] = {
942 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */ 883 /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
943 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 884 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
@@ -996,31 +937,6 @@ static struct hda_verb stac9205_core_init[] = {
996 .put = stac92xx_mono_mux_enum_put, \ 937 .put = stac92xx_mono_mux_enum_put, \
997 } 938 }
998 939
999#define STAC_AMP_MUX \
1000 { \
1001 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1002 .name = "Amp Selector Capture Switch", \
1003 .count = 1, \
1004 .info = stac92xx_amp_mux_enum_info, \
1005 .get = stac92xx_amp_mux_enum_get, \
1006 .put = stac92xx_amp_mux_enum_put, \
1007 }
1008
1009#define STAC_AMP_VOL(xname, nid, chs, idx, dir) \
1010 { \
1011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1012 .name = xname, \
1013 .index = 0, \
1014 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1015 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1016 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
1017 .info = stac92xx_amp_volume_info, \
1018 .get = stac92xx_amp_volume_get, \
1019 .put = stac92xx_amp_volume_put, \
1020 .tlv = { .c = snd_hda_mixer_amp_tlv }, \
1021 .private_value = HDA_COMPOSE_AMP_VAL(nid, chs, idx, dir) \
1022 }
1023
1024#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \ 940#define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
1025 { \ 941 { \
1026 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 942 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
@@ -1051,34 +967,6 @@ static struct snd_kcontrol_new stac9200_mixer[] = {
1051 { } /* end */ 967 { } /* end */
1052}; 968};
1053 969
1054#define DELL_M6_MIXER 6
1055static struct snd_kcontrol_new stac92hd73xx_6ch_mixer[] = {
1056 /* start of config #1 */
1057 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1058 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1059
1060 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1061 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1062
1063 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1064 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1065
1066 /* start of config #2 */
1067 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1068 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1069
1070 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1071 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1072
1073 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1074 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1075
1076 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1077 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1078
1079 { } /* end */
1080};
1081
1082static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = { 970static struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
1083 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3), 971 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
1084 {} 972 {}
@@ -1094,134 +982,14 @@ static struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
1094 {} 982 {}
1095}; 983};
1096 984
1097static struct snd_kcontrol_new stac92hd73xx_8ch_mixer[] = {
1098 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1099 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1100
1101 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1102 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1103
1104 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1105 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1106
1107 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1108 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1109
1110 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1111 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1112
1113 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1114 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1115
1116 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1117 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1118 { } /* end */
1119};
1120
1121static struct snd_kcontrol_new stac92hd73xx_10ch_mixer[] = {
1122 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x20, 0x0, HDA_OUTPUT),
1123 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x20, 0x0, HDA_OUTPUT),
1124
1125 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x21, 0x0, HDA_OUTPUT),
1126 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x21, 0x0, HDA_OUTPUT),
1127
1128 HDA_CODEC_VOLUME("Front Mic Mixer Capture Volume", 0x1d, 0, HDA_INPUT),
1129 HDA_CODEC_MUTE("Front Mic Mixer Capture Switch", 0x1d, 0, HDA_INPUT),
1130
1131 HDA_CODEC_VOLUME("Mic Mixer Capture Volume", 0x1d, 0x1, HDA_INPUT),
1132 HDA_CODEC_MUTE("Mic Mixer Capture Switch", 0x1d, 0x1, HDA_INPUT),
1133
1134 HDA_CODEC_VOLUME("Line In Mixer Capture Volume", 0x1d, 0x2, HDA_INPUT),
1135 HDA_CODEC_MUTE("Line In Mixer Capture Switch", 0x1d, 0x2, HDA_INPUT),
1136
1137 HDA_CODEC_VOLUME("DAC Mixer Capture Volume", 0x1d, 0x3, HDA_INPUT),
1138 HDA_CODEC_MUTE("DAC Mixer Capture Switch", 0x1d, 0x3, HDA_INPUT),
1139
1140 HDA_CODEC_VOLUME("CD Mixer Capture Volume", 0x1d, 0x4, HDA_INPUT),
1141 HDA_CODEC_MUTE("CD Mixer Capture Switch", 0x1d, 0x4, HDA_INPUT),
1142 { } /* end */
1143};
1144
1145
1146static struct snd_kcontrol_new stac92hd83xxx_mixer[] = {
1147 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_OUTPUT),
1148 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_OUTPUT),
1149
1150 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT),
1151 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT),
1152
1153 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT),
1154 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT),
1155
1156 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT),
1157 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT),
1158
1159 HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT),
1160 HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT),
1161
1162 HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT),
1163 HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT),
1164
1165 /*
1166 HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT),
1167 HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT),
1168 */
1169 { } /* end */
1170};
1171
1172static struct snd_kcontrol_new stac92hd71bxx_analog_mixer[] = {
1173 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1174 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1175
1176 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1177 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1178 /* analog pc-beep replaced with digital beep support */
1179 /*
1180 HDA_CODEC_VOLUME("PC Beep Volume", 0x17, 0x2, HDA_INPUT),
1181 HDA_CODEC_MUTE("PC Beep Switch", 0x17, 0x2, HDA_INPUT),
1182 */
1183
1184 HDA_CODEC_MUTE("Import0 Mux Capture Switch", 0x17, 0x0, HDA_INPUT),
1185 HDA_CODEC_VOLUME("Import0 Mux Capture Volume", 0x17, 0x0, HDA_INPUT),
1186
1187 HDA_CODEC_MUTE("Import1 Mux Capture Switch", 0x17, 0x1, HDA_INPUT),
1188 HDA_CODEC_VOLUME("Import1 Mux Capture Volume", 0x17, 0x1, HDA_INPUT),
1189
1190 HDA_CODEC_MUTE("DAC0 Capture Switch", 0x17, 0x3, HDA_INPUT),
1191 HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x17, 0x3, HDA_INPUT),
1192
1193 HDA_CODEC_MUTE("DAC1 Capture Switch", 0x17, 0x4, HDA_INPUT),
1194 HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x17, 0x4, HDA_INPUT),
1195 { } /* end */
1196};
1197 985
1198static struct snd_kcontrol_new stac92hd71bxx_loopback[] = { 986static struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
1199 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2) 987 STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
1200}; 988};
1201 989
1202static struct snd_kcontrol_new stac92hd71bxx_mixer[] = {
1203 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1204 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1c, 0x0, HDA_OUTPUT),
1205
1206 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1207 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1d, 0x0, HDA_OUTPUT),
1208 { } /* end */
1209};
1210
1211static struct snd_kcontrol_new stac925x_mixer[] = { 990static struct snd_kcontrol_new stac925x_mixer[] = {
1212 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT), 991 HDA_CODEC_VOLUME("Master Playback Volume", 0x0e, 0, HDA_OUTPUT),
1213 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT), 992 HDA_CODEC_MUTE("Master Playback Switch", 0x0e, 0, HDA_OUTPUT),
1214 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
1215 HDA_CODEC_MUTE("Capture Switch", 0x14, 0, HDA_OUTPUT),
1216 { } /* end */
1217};
1218
1219static struct snd_kcontrol_new stac9205_mixer[] = {
1220 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x1b, 0x0, HDA_INPUT),
1221 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1d, 0x0, HDA_OUTPUT),
1222
1223 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x1c, 0x0, HDA_INPUT),
1224 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1e, 0x0, HDA_OUTPUT),
1225 { } /* end */ 993 { } /* end */
1226}; 994};
1227 995
@@ -1230,29 +998,6 @@ static struct snd_kcontrol_new stac9205_loopback[] = {
1230 {} 998 {}
1231}; 999};
1232 1000
1233/* This needs to be generated dynamically based on sequence */
1234static struct snd_kcontrol_new stac922x_mixer[] = {
1235 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x17, 0x0, HDA_INPUT),
1236 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x17, 0x0, HDA_INPUT),
1237
1238 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_INPUT),
1239 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_INPUT),
1240 { } /* end */
1241};
1242
1243
1244static struct snd_kcontrol_new stac927x_mixer[] = {
1245 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x0, 0x18, 0x0, HDA_INPUT),
1246 HDA_CODEC_MUTE_IDX("Capture Switch", 0x0, 0x1b, 0x0, HDA_OUTPUT),
1247
1248 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x19, 0x0, HDA_INPUT),
1249 HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x1c, 0x0, HDA_OUTPUT),
1250
1251 HDA_CODEC_VOLUME_IDX("Capture Volume", 0x2, 0x1A, 0x0, HDA_INPUT),
1252 HDA_CODEC_MUTE_IDX("Capture Switch", 0x2, 0x1d, 0x0, HDA_OUTPUT),
1253 { } /* end */
1254};
1255
1256static struct snd_kcontrol_new stac927x_loopback[] = { 1001static struct snd_kcontrol_new stac927x_loopback[] = {
1257 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1), 1002 STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
1258 {} 1003 {}
@@ -1310,16 +1055,19 @@ static int stac92xx_build_controls(struct hda_codec *codec)
1310 int err; 1055 int err;
1311 int i; 1056 int i;
1312 1057
1313 err = snd_hda_add_new_ctls(codec, spec->mixer); 1058 if (spec->mixer) {
1314 if (err < 0) 1059 err = snd_hda_add_new_ctls(codec, spec->mixer);
1315 return err; 1060 if (err < 0)
1061 return err;
1062 }
1316 1063
1317 for (i = 0; i < spec->num_mixers; i++) { 1064 for (i = 0; i < spec->num_mixers; i++) {
1318 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 1065 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1319 if (err < 0) 1066 if (err < 0)
1320 return err; 1067 return err;
1321 } 1068 }
1322 if (spec->num_dmuxes > 0) { 1069 if (!spec->auto_mic && spec->num_dmuxes > 0 &&
1070 snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
1323 stac_dmux_mixer.count = spec->num_dmuxes; 1071 stac_dmux_mixer.count = spec->num_dmuxes;
1324 err = snd_hda_ctl_add(codec, 1072 err = snd_hda_ctl_add(codec,
1325 snd_ctl_new1(&stac_dmux_mixer, codec)); 1073 snd_ctl_new1(&stac_dmux_mixer, codec));
@@ -1766,12 +1514,20 @@ static unsigned int dell_m6_pin_configs[13] = {
1766 0x4f0000f0, 1514 0x4f0000f0,
1767}; 1515};
1768 1516
1517static unsigned int alienware_m17x_pin_configs[13] = {
1518 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
1519 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
1520 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
1521 0x904601b0,
1522};
1523
1769static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { 1524static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1770 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs, 1525 [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
1771 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs, 1526 [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
1772 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs, 1527 [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
1773 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs, 1528 [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
1774 [STAC_DELL_EQ] = dell_m6_pin_configs, 1529 [STAC_DELL_EQ] = dell_m6_pin_configs,
1530 [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
1775}; 1531};
1776 1532
1777static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1533static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
@@ -1783,6 +1539,7 @@ static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1783 [STAC_DELL_M6_DMIC] = "dell-m6-dmic", 1539 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1784 [STAC_DELL_M6_BOTH] = "dell-m6", 1540 [STAC_DELL_M6_BOTH] = "dell-m6",
1785 [STAC_DELL_EQ] = "dell-eq", 1541 [STAC_DELL_EQ] = "dell-eq",
1542 [STAC_ALIENWARE_M17X] = "alienware",
1786}; 1543};
1787 1544
1788static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { 1545static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
@@ -1820,6 +1577,12 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1820 {} /* terminator */ 1577 {} /* terminator */
1821}; 1578};
1822 1579
1580static struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
1581 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
1582 "Alienware M17x", STAC_ALIENWARE_M17X),
1583 {} /* terminator */
1584};
1585
1823static unsigned int ref92hd83xxx_pin_configs[10] = { 1586static unsigned int ref92hd83xxx_pin_configs[10] = {
1824 0x02214030, 0x02211010, 0x02a19020, 0x02170130, 1587 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
1825 0x01014050, 0x01819040, 0x01014020, 0x90a3014e, 1588 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
@@ -1927,6 +1690,8 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
1927 "HP mini 1000", STAC_HP_M4), 1690 "HP mini 1000", STAC_HP_M4),
1928 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b, 1691 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
1929 "HP HDX", STAC_HP_HDX), /* HDX16 */ 1692 "HP HDX", STAC_HP_HDX), /* HDX16 */
1693 SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
1694 "HP", STAC_HP_DV5),
1930 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, 1695 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
1931 "unknown Dell", STAC_DELL_M4_1), 1696 "unknown Dell", STAC_DELL_M4_1),
1932 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234, 1697 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
@@ -2642,8 +2407,7 @@ static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
2642 return 0; 2407 return 0;
2643} 2408}
2644 2409
2645static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, 2410static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
2646 unsigned char type);
2647 2411
2648static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol, 2412static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2649 struct snd_ctl_elem_value *ucontrol) 2413 struct snd_ctl_elem_value *ucontrol)
@@ -2657,7 +2421,7 @@ static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
2657 /* check to be sure that the ports are upto date with 2421 /* check to be sure that the ports are upto date with
2658 * switch changes 2422 * switch changes
2659 */ 2423 */
2660 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); 2424 stac_issue_unsol_event(codec, nid);
2661 2425
2662 return 1; 2426 return 1;
2663} 2427}
@@ -2790,7 +2554,7 @@ static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_
2790 * appropriately according to the pin direction 2554 * appropriately according to the pin direction
2791 */ 2555 */
2792 if (spec->hp_detect) 2556 if (spec->hp_detect)
2793 stac_issue_unsol_event(codec, nid, STAC_HP_EVENT); 2557 stac_issue_unsol_event(codec, nid);
2794 2558
2795 return 1; 2559 return 1;
2796} 2560}
@@ -2859,8 +2623,6 @@ enum {
2859 STAC_CTL_WIDGET_VOL, 2623 STAC_CTL_WIDGET_VOL,
2860 STAC_CTL_WIDGET_MUTE, 2624 STAC_CTL_WIDGET_MUTE,
2861 STAC_CTL_WIDGET_MONO_MUX, 2625 STAC_CTL_WIDGET_MONO_MUX,
2862 STAC_CTL_WIDGET_AMP_MUX,
2863 STAC_CTL_WIDGET_AMP_VOL,
2864 STAC_CTL_WIDGET_HP_SWITCH, 2626 STAC_CTL_WIDGET_HP_SWITCH,
2865 STAC_CTL_WIDGET_IO_SWITCH, 2627 STAC_CTL_WIDGET_IO_SWITCH,
2866 STAC_CTL_WIDGET_CLFE_SWITCH, 2628 STAC_CTL_WIDGET_CLFE_SWITCH,
@@ -2871,8 +2633,6 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
2871 HDA_CODEC_VOLUME(NULL, 0, 0, 0), 2633 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
2872 HDA_CODEC_MUTE(NULL, 0, 0, 0), 2634 HDA_CODEC_MUTE(NULL, 0, 0, 0),
2873 STAC_MONO_MUX, 2635 STAC_MONO_MUX,
2874 STAC_AMP_MUX,
2875 STAC_AMP_VOL(NULL, 0, 0, 0, 0),
2876 STAC_CODEC_HP_SWITCH(NULL), 2636 STAC_CODEC_HP_SWITCH(NULL),
2877 STAC_CODEC_IO_SWITCH(NULL, 0), 2637 STAC_CODEC_IO_SWITCH(NULL, 0),
2878 STAC_CODEC_CLFE_SWITCH(NULL, 0), 2638 STAC_CODEC_CLFE_SWITCH(NULL, 0),
@@ -2973,6 +2733,8 @@ static int stac92xx_add_input_source(struct sigmatel_spec *spec)
2973 struct snd_kcontrol_new *knew; 2733 struct snd_kcontrol_new *knew;
2974 struct hda_input_mux *imux = &spec->private_imux; 2734 struct hda_input_mux *imux = &spec->private_imux;
2975 2735
2736 if (spec->auto_mic)
2737 return 0; /* no need for input source */
2976 if (!spec->num_adcs || imux->num_items <= 1) 2738 if (!spec->num_adcs || imux->num_items <= 1)
2977 return 0; /* no need for input source control */ 2739 return 0; /* no need for input source control */
2978 knew = stac_control_new(spec, &stac_input_src_temp, 2740 knew = stac_control_new(spec, &stac_input_src_temp,
@@ -3066,7 +2828,7 @@ static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
3066 HDA_MAX_CONNECTIONS); 2828 HDA_MAX_CONNECTIONS);
3067 for (j = 0; j < conn_len; j++) { 2829 for (j = 0; j < conn_len; j++) {
3068 wcaps = get_wcaps(codec, conn[j]); 2830 wcaps = get_wcaps(codec, conn[j]);
3069 wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; 2831 wtype = get_wcaps_type(wcaps);
3070 /* we check only analog outputs */ 2832 /* we check only analog outputs */
3071 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) 2833 if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
3072 continue; 2834 continue;
@@ -3325,6 +3087,21 @@ static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
3325 return 0; 3087 return 0;
3326} 3088}
3327 3089
3090static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
3091 unsigned long sw, int idx)
3092{
3093 int err;
3094 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
3095 "Capture Volume", vol);
3096 if (err < 0)
3097 return err;
3098 err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
3099 "Capture Switch", sw);
3100 if (err < 0)
3101 return err;
3102 return 0;
3103}
3104
3328/* add playback controls from the parsed DAC table */ 3105/* add playback controls from the parsed DAC table */
3329static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, 3106static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
3330 const struct auto_pin_cfg *cfg) 3107 const struct auto_pin_cfg *cfg)
@@ -3398,7 +3175,7 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3398 spec->mono_nid, 3175 spec->mono_nid,
3399 con_lst, 3176 con_lst,
3400 HDA_MAX_NUM_INPUTS); 3177 HDA_MAX_NUM_INPUTS);
3401 if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels)) 3178 if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
3402 return -EINVAL; 3179 return -EINVAL;
3403 3180
3404 for (i = 0; i < num_cons; i++) { 3181 for (i = 0; i < num_cons; i++) {
@@ -3412,37 +3189,6 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
3412 "Mono Mux", spec->mono_nid); 3189 "Mono Mux", spec->mono_nid);
3413} 3190}
3414 3191
3415/* labels for amp mux outputs */
3416static const char *stac92xx_amp_labels[3] = {
3417 "Front Microphone", "Microphone", "Line In",
3418};
3419
3420/* create amp out controls mux on capable codecs */
3421static int stac92xx_auto_create_amp_output_ctls(struct hda_codec *codec)
3422{
3423 struct sigmatel_spec *spec = codec->spec;
3424 struct hda_input_mux *amp_mux = &spec->private_amp_mux;
3425 int i, err;
3426
3427 for (i = 0; i < spec->num_amps; i++) {
3428 amp_mux->items[amp_mux->num_items].label =
3429 stac92xx_amp_labels[i];
3430 amp_mux->items[amp_mux->num_items].index = i;
3431 amp_mux->num_items++;
3432 }
3433
3434 if (spec->num_amps > 1) {
3435 err = stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_MUX,
3436 "Amp Selector Capture Switch", 0);
3437 if (err < 0)
3438 return err;
3439 }
3440 return stac92xx_add_control(spec, STAC_CTL_WIDGET_AMP_VOL,
3441 "Amp Capture Volume",
3442 HDA_COMPOSE_AMP_VAL(spec->amp_nids[0], 3, 0, HDA_INPUT));
3443}
3444
3445
3446/* create PC beep volume controls */ 3192/* create PC beep volume controls */
3447static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec, 3193static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
3448 hda_nid_t nid) 3194 hda_nid_t nid)
@@ -3511,19 +3257,33 @@ static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
3511static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec) 3257static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
3512{ 3258{
3513 struct sigmatel_spec *spec = codec->spec; 3259 struct sigmatel_spec *spec = codec->spec;
3514 int wcaps, nid, i, err = 0; 3260 int i, j, err = 0;
3515 3261
3516 for (i = 0; i < spec->num_muxes; i++) { 3262 for (i = 0; i < spec->num_muxes; i++) {
3263 hda_nid_t nid;
3264 unsigned int wcaps;
3265 unsigned long val;
3266
3517 nid = spec->mux_nids[i]; 3267 nid = spec->mux_nids[i];
3518 wcaps = get_wcaps(codec, nid); 3268 wcaps = get_wcaps(codec, nid);
3269 if (!(wcaps & AC_WCAP_OUT_AMP))
3270 continue;
3519 3271
3520 if (wcaps & AC_WCAP_OUT_AMP) { 3272 /* check whether already the same control was created as
3521 err = stac92xx_add_control_idx(spec, 3273 * normal Capture Volume.
3522 STAC_CTL_WIDGET_VOL, i, "Mux Capture Volume", 3274 */
3523 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT)); 3275 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
3524 if (err < 0) 3276 for (j = 0; j < spec->num_caps; j++) {
3525 return err; 3277 if (spec->capvols[j] == val)
3278 break;
3526 } 3279 }
3280 if (j < spec->num_caps)
3281 continue;
3282
3283 err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
3284 "Mux Capture Volume", val);
3285 if (err < 0)
3286 return err;
3527 } 3287 }
3528 return 0; 3288 return 0;
3529}; 3289};
@@ -3544,7 +3304,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
3544 spec->smux_nids[0], 3304 spec->smux_nids[0],
3545 con_lst, 3305 con_lst,
3546 HDA_MAX_NUM_INPUTS); 3306 HDA_MAX_NUM_INPUTS);
3547 if (!num_cons) 3307 if (num_cons <= 0)
3548 return -EINVAL; 3308 return -EINVAL;
3549 3309
3550 if (!labels) 3310 if (!labels)
@@ -3565,101 +3325,231 @@ static const char *stac92xx_dmic_labels[5] = {
3565 "Digital Mic 3", "Digital Mic 4" 3325 "Digital Mic 3", "Digital Mic 4"
3566}; 3326};
3567 3327
3328static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
3329 hda_nid_t nid)
3330{
3331 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
3332 int i, nums;
3333
3334 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
3335 for (i = 0; i < nums; i++)
3336 if (conn[i] == nid)
3337 return i;
3338 return -1;
3339}
3340
3341/* create a volume assigned to the given pin (only if supported) */
3342/* return 1 if the volume control is created */
3343static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
3344 const char *label, int direction)
3345{
3346 unsigned int caps, nums;
3347 char name[32];
3348 int err;
3349
3350 if (direction == HDA_OUTPUT)
3351 caps = AC_WCAP_OUT_AMP;
3352 else
3353 caps = AC_WCAP_IN_AMP;
3354 if (!(get_wcaps(codec, nid) & caps))
3355 return 0;
3356 caps = query_amp_caps(codec, nid, direction);
3357 nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
3358 if (!nums)
3359 return 0;
3360 snprintf(name, sizeof(name), "%s Capture Volume", label);
3361 err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
3362 HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
3363 if (err < 0)
3364 return err;
3365 return 1;
3366}
3367
3568/* create playback/capture controls for input pins on dmic capable codecs */ 3368/* create playback/capture controls for input pins on dmic capable codecs */
3569static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, 3369static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
3570 const struct auto_pin_cfg *cfg) 3370 const struct auto_pin_cfg *cfg)
3571{ 3371{
3572 struct sigmatel_spec *spec = codec->spec; 3372 struct sigmatel_spec *spec = codec->spec;
3373 struct hda_input_mux *imux = &spec->private_imux;
3573 struct hda_input_mux *dimux = &spec->private_dimux; 3374 struct hda_input_mux *dimux = &spec->private_dimux;
3574 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 3375 int err, i, active_mics;
3575 int err, i, j; 3376 unsigned int def_conf;
3576 char name[32];
3577 3377
3578 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0]; 3378 dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
3579 dimux->items[dimux->num_items].index = 0; 3379 dimux->items[dimux->num_items].index = 0;
3580 dimux->num_items++; 3380 dimux->num_items++;
3581 3381
3382 active_mics = 0;
3383 for (i = 0; i < spec->num_dmics; i++) {
3384 /* check the validity: sometimes it's a dead vendor-spec node */
3385 if (get_wcaps_type(get_wcaps(codec, spec->dmic_nids[i]))
3386 != AC_WID_PIN)
3387 continue;
3388 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]);
3389 if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
3390 active_mics++;
3391 }
3392
3582 for (i = 0; i < spec->num_dmics; i++) { 3393 for (i = 0; i < spec->num_dmics; i++) {
3583 hda_nid_t nid; 3394 hda_nid_t nid;
3584 int index; 3395 int index;
3585 int num_cons; 3396 const char *label;
3586 unsigned int wcaps;
3587 unsigned int def_conf;
3588 3397
3589 def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); 3398 nid = spec->dmic_nids[i];
3399 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
3400 continue;
3401 def_conf = snd_hda_codec_get_pincfg(codec, nid);
3590 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) 3402 if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
3591 continue; 3403 continue;
3592 3404
3593 nid = spec->dmic_nids[i]; 3405 index = get_connection_index(codec, spec->dmux_nids[0], nid);
3594 num_cons = snd_hda_get_connections(codec, 3406 if (index < 0)
3595 spec->dmux_nids[0], 3407 continue;
3596 con_lst,
3597 HDA_MAX_NUM_INPUTS);
3598 for (j = 0; j < num_cons; j++)
3599 if (con_lst[j] == nid) {
3600 index = j;
3601 goto found;
3602 }
3603 continue;
3604found:
3605 wcaps = get_wcaps(codec, nid) &
3606 (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
3607 3408
3608 if (wcaps) { 3409 if (active_mics == 1)
3609 sprintf(name, "%s Capture Volume", 3410 label = "Digital Mic";
3610 stac92xx_dmic_labels[dimux->num_items]); 3411 else
3412 label = stac92xx_dmic_labels[dimux->num_items];
3611 3413
3612 err = stac92xx_add_control(spec, 3414 err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
3613 STAC_CTL_WIDGET_VOL, 3415 if (err < 0)
3614 name, 3416 return err;
3615 HDA_COMPOSE_AMP_VAL(nid, 3, 0, 3417 if (!err) {
3616 (wcaps & AC_WCAP_OUT_AMP) ? 3418 err = create_elem_capture_vol(codec, nid, label,
3617 HDA_OUTPUT : HDA_INPUT)); 3419 HDA_OUTPUT);
3618 if (err < 0) 3420 if (err < 0)
3619 return err; 3421 return err;
3620 } 3422 }
3621 3423
3622 dimux->items[dimux->num_items].label = 3424 dimux->items[dimux->num_items].label = label;
3623 stac92xx_dmic_labels[dimux->num_items];
3624 dimux->items[dimux->num_items].index = index; 3425 dimux->items[dimux->num_items].index = index;
3625 dimux->num_items++; 3426 dimux->num_items++;
3427 if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1) {
3428 imux->items[imux->num_items].label = label;
3429 imux->items[imux->num_items].index = index;
3430 imux->num_items++;
3431 }
3626 } 3432 }
3627 3433
3628 return 0; 3434 return 0;
3629} 3435}
3630 3436
3437static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
3438 hda_nid_t *fixed, hda_nid_t *ext)
3439{
3440 unsigned int cfg;
3441
3442 if (!nid)
3443 return 0;
3444 cfg = snd_hda_codec_get_pincfg(codec, nid);
3445 switch (get_defcfg_connect(cfg)) {
3446 case AC_JACK_PORT_FIXED:
3447 if (*fixed)
3448 return 1; /* already occupied */
3449 *fixed = nid;
3450 break;
3451 case AC_JACK_PORT_COMPLEX:
3452 if (*ext)
3453 return 1; /* already occupied */
3454 *ext = nid;
3455 break;
3456 }
3457 return 0;
3458}
3459
3460static int set_mic_route(struct hda_codec *codec,
3461 struct sigmatel_mic_route *mic,
3462 hda_nid_t pin)
3463{
3464 struct sigmatel_spec *spec = codec->spec;
3465 struct auto_pin_cfg *cfg = &spec->autocfg;
3466 int i;
3467
3468 mic->pin = pin;
3469 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3470 if (pin == cfg->input_pins[i])
3471 break;
3472 if (i <= AUTO_PIN_FRONT_MIC) {
3473 /* analog pin */
3474 mic->dmux_idx = 0;
3475 i = get_connection_index(codec, spec->mux_nids[0], pin);
3476 if (i < 0)
3477 return -1;
3478 mic->mux_idx = i;
3479 } else if (spec->dmux_nids) {
3480 /* digital pin */
3481 mic->mux_idx = 0;
3482 i = get_connection_index(codec, spec->dmux_nids[0], pin);
3483 if (i < 0)
3484 return -1;
3485 mic->dmux_idx = i;
3486 }
3487 return 0;
3488}
3489
3490/* return non-zero if the device is for automatic mic switch */
3491static int stac_check_auto_mic(struct hda_codec *codec)
3492{
3493 struct sigmatel_spec *spec = codec->spec;
3494 struct auto_pin_cfg *cfg = &spec->autocfg;
3495 hda_nid_t fixed, ext;
3496 int i;
3497
3498 for (i = AUTO_PIN_LINE; i < AUTO_PIN_LAST; i++) {
3499 if (cfg->input_pins[i])
3500 return 0; /* must be exclusively mics */
3501 }
3502 fixed = ext = 0;
3503 for (i = AUTO_PIN_MIC; i <= AUTO_PIN_FRONT_MIC; i++)
3504 if (check_mic_pin(codec, cfg->input_pins[i], &fixed, &ext))
3505 return 0;
3506 for (i = 0; i < spec->num_dmics; i++)
3507 if (check_mic_pin(codec, spec->dmic_nids[i], &fixed, &ext))
3508 return 0;
3509 if (!fixed || !ext)
3510 return 0;
3511 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
3512 return 0; /* no unsol support */
3513 if (set_mic_route(codec, &spec->ext_mic, ext) ||
3514 set_mic_route(codec, &spec->int_mic, fixed))
3515 return 0; /* something is wrong */
3516 return 1;
3517}
3518
3631/* create playback/capture controls for input pins */ 3519/* create playback/capture controls for input pins */
3632static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg) 3520static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
3633{ 3521{
3634 struct sigmatel_spec *spec = codec->spec; 3522 struct sigmatel_spec *spec = codec->spec;
3635 struct hda_input_mux *imux = &spec->private_imux; 3523 struct hda_input_mux *imux = &spec->private_imux;
3636 hda_nid_t con_lst[HDA_MAX_NUM_INPUTS]; 3524 int i, j;
3637 int i, j, k;
3638 3525
3639 for (i = 0; i < AUTO_PIN_LAST; i++) { 3526 for (i = 0; i < AUTO_PIN_LAST; i++) {
3640 int index; 3527 hda_nid_t nid = cfg->input_pins[i];
3528 int index, err;
3641 3529
3642 if (!cfg->input_pins[i]) 3530 if (!nid)
3643 continue; 3531 continue;
3644 index = -1; 3532 index = -1;
3645 for (j = 0; j < spec->num_muxes; j++) { 3533 for (j = 0; j < spec->num_muxes; j++) {
3646 int num_cons; 3534 index = get_connection_index(codec, spec->mux_nids[j],
3647 num_cons = snd_hda_get_connections(codec, 3535 nid);
3648 spec->mux_nids[j], 3536 if (index >= 0)
3649 con_lst, 3537 break;
3650 HDA_MAX_NUM_INPUTS);
3651 for (k = 0; k < num_cons; k++)
3652 if (con_lst[k] == cfg->input_pins[i]) {
3653 index = k;
3654 goto found;
3655 }
3656 } 3538 }
3657 continue; 3539 if (index < 0)
3658 found: 3540 continue;
3541
3542 err = create_elem_capture_vol(codec, nid,
3543 auto_pin_cfg_labels[i],
3544 HDA_INPUT);
3545 if (err < 0)
3546 return err;
3547
3659 imux->items[imux->num_items].label = auto_pin_cfg_labels[i]; 3548 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
3660 imux->items[imux->num_items].index = index; 3549 imux->items[imux->num_items].index = index;
3661 imux->num_items++; 3550 imux->num_items++;
3662 } 3551 }
3552 spec->num_analog_muxes = imux->num_items;
3663 3553
3664 if (imux->num_items) { 3554 if (imux->num_items) {
3665 /* 3555 /*
@@ -3711,7 +3601,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3711{ 3601{
3712 struct sigmatel_spec *spec = codec->spec; 3602 struct sigmatel_spec *spec = codec->spec;
3713 int hp_swap = 0; 3603 int hp_swap = 0;
3714 int err; 3604 int i, err;
3715 3605
3716 if ((err = snd_hda_parse_pin_def_config(codec, 3606 if ((err = snd_hda_parse_pin_def_config(codec,
3717 &spec->autocfg, 3607 &spec->autocfg,
@@ -3751,11 +3641,10 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3751 if (snd_hda_get_connections(codec, 3641 if (snd_hda_get_connections(codec,
3752 spec->autocfg.mono_out_pin, conn_list, 1) && 3642 spec->autocfg.mono_out_pin, conn_list, 1) &&
3753 snd_hda_get_connections(codec, conn_list[0], 3643 snd_hda_get_connections(codec, conn_list[0],
3754 conn_list, 1)) { 3644 conn_list, 1) > 0) {
3755 3645
3756 int wcaps = get_wcaps(codec, conn_list[0]); 3646 int wcaps = get_wcaps(codec, conn_list[0]);
3757 int wid_type = (wcaps & AC_WCAP_TYPE) 3647 int wid_type = get_wcaps_type(wcaps);
3758 >> AC_WCAP_TYPE_SHIFT;
3759 /* LR swap check, some stac925x have a mux that 3648 /* LR swap check, some stac925x have a mux that
3760 * changes the DACs output path instead of the 3649 * changes the DACs output path instead of the
3761 * mono-mux path. 3650 * mono-mux path.
@@ -3846,6 +3735,21 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3846 spec->autocfg.line_outs = 0; 3735 spec->autocfg.line_outs = 0;
3847 } 3736 }
3848 3737
3738 if (stac_check_auto_mic(codec)) {
3739 spec->auto_mic = 1;
3740 /* only one capture for auto-mic */
3741 spec->num_adcs = 1;
3742 spec->num_caps = 1;
3743 spec->num_muxes = 1;
3744 }
3745
3746 for (i = 0; i < spec->num_caps; i++) {
3747 err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
3748 spec->capsws[i], i);
3749 if (err < 0)
3750 return err;
3751 }
3752
3849 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg); 3753 err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
3850 if (err < 0) 3754 if (err < 0)
3851 return err; 3755 return err;
@@ -3855,11 +3759,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3855 if (err < 0) 3759 if (err < 0)
3856 return err; 3760 return err;
3857 } 3761 }
3858 if (spec->num_amps > 0) {
3859 err = stac92xx_auto_create_amp_output_ctls(codec);
3860 if (err < 0)
3861 return err;
3862 }
3863 if (spec->num_dmics > 0 && !spec->dinput_mux) 3762 if (spec->num_dmics > 0 && !spec->dinput_mux)
3864 if ((err = stac92xx_auto_create_dmic_input_ctls(codec, 3763 if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
3865 &spec->autocfg)) < 0) 3764 &spec->autocfg)) < 0)
@@ -3896,7 +3795,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
3896 spec->dinput_mux = &spec->private_dimux; 3795 spec->dinput_mux = &spec->private_dimux;
3897 spec->sinput_mux = &spec->private_smux; 3796 spec->sinput_mux = &spec->private_smux;
3898 spec->mono_mux = &spec->private_mono_mux; 3797 spec->mono_mux = &spec->private_mono_mux;
3899 spec->amp_mux = &spec->private_amp_mux;
3900 return 1; 3798 return 1;
3901} 3799}
3902 3800
@@ -4108,14 +4006,14 @@ static int stac_add_event(struct sigmatel_spec *spec, hda_nid_t nid,
4108} 4006}
4109 4007
4110static struct sigmatel_event *stac_get_event(struct hda_codec *codec, 4008static struct sigmatel_event *stac_get_event(struct hda_codec *codec,
4111 hda_nid_t nid, unsigned char type) 4009 hda_nid_t nid)
4112{ 4010{
4113 struct sigmatel_spec *spec = codec->spec; 4011 struct sigmatel_spec *spec = codec->spec;
4114 struct sigmatel_event *event = spec->events.list; 4012 struct sigmatel_event *event = spec->events.list;
4115 int i; 4013 int i;
4116 4014
4117 for (i = 0; i < spec->events.used; i++, event++) { 4015 for (i = 0; i < spec->events.used; i++, event++) {
4118 if (event->nid == nid && event->type == type) 4016 if (event->nid == nid)
4119 return event; 4017 return event;
4120 } 4018 }
4121 return NULL; 4019 return NULL;
@@ -4135,24 +4033,32 @@ static struct sigmatel_event *stac_get_event_from_tag(struct hda_codec *codec,
4135 return NULL; 4033 return NULL;
4136} 4034}
4137 4035
4138static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, 4036/* check if given nid is a valid pin and no other events are assigned
4139 unsigned int type) 4037 * to it. If OK, assign the event, set the unsol flag, and returns 1.
4038 * Otherwise, returns zero.
4039 */
4040static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
4041 unsigned int type)
4140{ 4042{
4141 struct sigmatel_event *event; 4043 struct sigmatel_event *event;
4142 int tag; 4044 int tag;
4143 4045
4144 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)) 4046 if (!(get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP))
4145 return; 4047 return 0;
4146 event = stac_get_event(codec, nid, type); 4048 event = stac_get_event(codec, nid);
4147 if (event) 4049 if (event) {
4050 if (event->type != type)
4051 return 0;
4148 tag = event->tag; 4052 tag = event->tag;
4149 else 4053 } else {
4150 tag = stac_add_event(codec->spec, nid, type, 0); 4054 tag = stac_add_event(codec->spec, nid, type, 0);
4151 if (tag < 0) 4055 if (tag < 0)
4152 return; 4056 return 0;
4057 }
4153 snd_hda_codec_write_cache(codec, nid, 0, 4058 snd_hda_codec_write_cache(codec, nid, 0,
4154 AC_VERB_SET_UNSOLICITED_ENABLE, 4059 AC_VERB_SET_UNSOLICITED_ENABLE,
4155 AC_USRSP_EN | tag); 4060 AC_USRSP_EN | tag);
4061 return 1;
4156} 4062}
4157 4063
4158static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid) 4064static int is_nid_hp_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
@@ -4245,20 +4151,36 @@ static int stac92xx_init(struct hda_codec *codec)
4245 hda_nid_t nid = cfg->hp_pins[i]; 4151 hda_nid_t nid = cfg->hp_pins[i];
4246 enable_pin_detect(codec, nid, STAC_HP_EVENT); 4152 enable_pin_detect(codec, nid, STAC_HP_EVENT);
4247 } 4153 }
4154 if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
4155 cfg->speaker_outs > 0) {
4156 /* enable pin-detect for line-outs as well */
4157 for (i = 0; i < cfg->line_outs; i++) {
4158 hda_nid_t nid = cfg->line_out_pins[i];
4159 enable_pin_detect(codec, nid, STAC_LO_EVENT);
4160 }
4161 }
4162
4248 /* force to enable the first line-out; the others are set up 4163 /* force to enable the first line-out; the others are set up
4249 * in unsol_event 4164 * in unsol_event
4250 */ 4165 */
4251 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0], 4166 stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
4252 AC_PINCTL_OUT_EN); 4167 AC_PINCTL_OUT_EN);
4253 /* fake event to set up pins */ 4168 /* fake event to set up pins */
4254 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], 4169 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4255 STAC_HP_EVENT);
4256 } else { 4170 } else {
4257 stac92xx_auto_init_multi_out(codec); 4171 stac92xx_auto_init_multi_out(codec);
4258 stac92xx_auto_init_hp_out(codec); 4172 stac92xx_auto_init_hp_out(codec);
4259 for (i = 0; i < cfg->hp_outs; i++) 4173 for (i = 0; i < cfg->hp_outs; i++)
4260 stac_toggle_power_map(codec, cfg->hp_pins[i], 1); 4174 stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
4261 } 4175 }
4176 if (spec->auto_mic) {
4177 /* initialize connection to analog input */
4178 if (spec->dmux_nids)
4179 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4180 AC_VERB_SET_CONNECT_SEL, 0);
4181 if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
4182 stac_issue_unsol_event(codec, spec->ext_mic.pin);
4183 }
4262 for (i = 0; i < AUTO_PIN_LAST; i++) { 4184 for (i = 0; i < AUTO_PIN_LAST; i++) {
4263 hda_nid_t nid = cfg->input_pins[i]; 4185 hda_nid_t nid = cfg->input_pins[i];
4264 if (nid) { 4186 if (nid) {
@@ -4285,10 +4207,9 @@ static int stac92xx_init(struct hda_codec *codec)
4285 } 4207 }
4286 conf = snd_hda_codec_get_pincfg(codec, nid); 4208 conf = snd_hda_codec_get_pincfg(codec, nid);
4287 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { 4209 if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
4288 enable_pin_detect(codec, nid, 4210 if (enable_pin_detect(codec, nid,
4289 STAC_INSERT_EVENT); 4211 STAC_INSERT_EVENT))
4290 stac_issue_unsol_event(codec, nid, 4212 stac_issue_unsol_event(codec, nid);
4291 STAC_INSERT_EVENT);
4292 } 4213 }
4293 } 4214 }
4294 } 4215 }
@@ -4333,10 +4254,8 @@ static int stac92xx_init(struct hda_codec *codec)
4333 stac_toggle_power_map(codec, nid, 1); 4254 stac_toggle_power_map(codec, nid, 1);
4334 continue; 4255 continue;
4335 } 4256 }
4336 if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { 4257 if (enable_pin_detect(codec, nid, STAC_PWR_EVENT))
4337 enable_pin_detect(codec, nid, STAC_PWR_EVENT); 4258 stac_issue_unsol_event(codec, nid);
4338 stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT);
4339 }
4340 } 4259 }
4341 if (spec->dac_list) 4260 if (spec->dac_list)
4342 stac92xx_power_down(codec); 4261 stac92xx_power_down(codec);
@@ -4440,6 +4359,48 @@ static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
4440 return 0; 4359 return 0;
4441} 4360}
4442 4361
4362static void stac92xx_line_out_detect(struct hda_codec *codec,
4363 int presence)
4364{
4365 struct sigmatel_spec *spec = codec->spec;
4366 struct auto_pin_cfg *cfg = &spec->autocfg;
4367 int i;
4368
4369 for (i = 0; i < cfg->line_outs; i++) {
4370 if (presence)
4371 break;
4372 presence = get_pin_presence(codec, cfg->line_out_pins[i]);
4373 if (presence) {
4374 unsigned int pinctl;
4375 pinctl = snd_hda_codec_read(codec,
4376 cfg->line_out_pins[i], 0,
4377 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4378 if (pinctl & AC_PINCTL_IN_EN)
4379 presence = 0; /* mic- or line-input */
4380 }
4381 }
4382
4383 if (presence) {
4384 /* disable speakers */
4385 for (i = 0; i < cfg->speaker_outs; i++)
4386 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4387 AC_PINCTL_OUT_EN);
4388 if (spec->eapd_mask && spec->eapd_switch)
4389 stac_gpio_set(codec, spec->gpio_mask,
4390 spec->gpio_dir, spec->gpio_data &
4391 ~spec->eapd_mask);
4392 } else {
4393 /* enable speakers */
4394 for (i = 0; i < cfg->speaker_outs; i++)
4395 stac92xx_set_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 }
4402}
4403
4443/* return non-zero if the hp-pin of the given array index isn't 4404/* return non-zero if the hp-pin of the given array index isn't
4444 * a jack-detection target 4405 * a jack-detection target
4445 */ 4406 */
@@ -4492,13 +4453,6 @@ static void stac92xx_hp_detect(struct hda_codec *codec)
4492 for (i = 0; i < cfg->line_outs; i++) 4453 for (i = 0; i < cfg->line_outs; i++)
4493 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i], 4454 stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
4494 AC_PINCTL_OUT_EN); 4455 AC_PINCTL_OUT_EN);
4495 for (i = 0; i < cfg->speaker_outs; i++)
4496 stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
4497 AC_PINCTL_OUT_EN);
4498 if (spec->eapd_mask && spec->eapd_switch)
4499 stac_gpio_set(codec, spec->gpio_mask,
4500 spec->gpio_dir, spec->gpio_data &
4501 ~spec->eapd_mask);
4502 } else { 4456 } else {
4503 /* enable lineouts */ 4457 /* enable lineouts */
4504 if (spec->hp_switch) 4458 if (spec->hp_switch)
@@ -4507,14 +4461,8 @@ static void stac92xx_hp_detect(struct hda_codec *codec)
4507 for (i = 0; i < cfg->line_outs; i++) 4461 for (i = 0; i < cfg->line_outs; i++)
4508 stac92xx_set_pinctl(codec, cfg->line_out_pins[i], 4462 stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
4509 AC_PINCTL_OUT_EN); 4463 AC_PINCTL_OUT_EN);
4510 for (i = 0; i < cfg->speaker_outs; i++)
4511 stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
4512 AC_PINCTL_OUT_EN);
4513 if (spec->eapd_mask && spec->eapd_switch)
4514 stac_gpio_set(codec, spec->gpio_mask,
4515 spec->gpio_dir, spec->gpio_data |
4516 spec->eapd_mask);
4517 } 4464 }
4465 stac92xx_line_out_detect(codec, presence);
4518 /* toggle hp outs */ 4466 /* toggle hp outs */
4519 for (i = 0; i < cfg->hp_outs; i++) { 4467 for (i = 0; i < cfg->hp_outs; i++) {
4520 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN; 4468 unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
@@ -4599,10 +4547,28 @@ static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid)
4599 } 4547 }
4600} 4548}
4601 4549
4602static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid, 4550static void stac92xx_mic_detect(struct hda_codec *codec)
4603 unsigned char type)
4604{ 4551{
4605 struct sigmatel_event *event = stac_get_event(codec, nid, type); 4552 struct sigmatel_spec *spec = codec->spec;
4553 struct sigmatel_mic_route *mic;
4554
4555 if (get_pin_presence(codec, spec->ext_mic.pin))
4556 mic = &spec->ext_mic;
4557 else
4558 mic = &spec->int_mic;
4559 if (mic->dmux_idx)
4560 snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
4561 AC_VERB_SET_CONNECT_SEL,
4562 mic->dmux_idx);
4563 else
4564 snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
4565 AC_VERB_SET_CONNECT_SEL,
4566 mic->mux_idx);
4567}
4568
4569static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
4570{
4571 struct sigmatel_event *event = stac_get_event(codec, nid);
4606 if (!event) 4572 if (!event)
4607 return; 4573 return;
4608 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); 4574 codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26);
@@ -4621,8 +4587,18 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
4621 4587
4622 switch (event->type) { 4588 switch (event->type) {
4623 case STAC_HP_EVENT: 4589 case STAC_HP_EVENT:
4590 case STAC_LO_EVENT:
4624 stac92xx_hp_detect(codec); 4591 stac92xx_hp_detect(codec);
4625 /* fallthru */ 4592 break;
4593 case STAC_MIC_EVENT:
4594 stac92xx_mic_detect(codec);
4595 break;
4596 }
4597
4598 switch (event->type) {
4599 case STAC_HP_EVENT:
4600 case STAC_LO_EVENT:
4601 case STAC_MIC_EVENT:
4626 case STAC_INSERT_EVENT: 4602 case STAC_INSERT_EVENT:
4627 case STAC_PWR_EVENT: 4603 case STAC_PWR_EVENT:
4628 if (spec->num_pwrs > 0) 4604 if (spec->num_pwrs > 0)
@@ -4713,8 +4689,7 @@ static int stac92xx_resume(struct hda_codec *codec)
4713 snd_hda_codec_resume_cache(codec); 4689 snd_hda_codec_resume_cache(codec);
4714 /* fake event to set up pins again to override cached values */ 4690 /* fake event to set up pins again to override cached values */
4715 if (spec->hp_detect) 4691 if (spec->hp_detect)
4716 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0], 4692 stac_issue_unsol_event(codec, spec->autocfg.hp_pins[0]);
4717 STAC_HP_EVENT);
4718 return 0; 4693 return 0;
4719} 4694}
4720 4695
@@ -4754,6 +4729,19 @@ static int stac92xx_hp_check_power_status(struct hda_codec *codec,
4754static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state) 4729static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
4755{ 4730{
4756 struct sigmatel_spec *spec = codec->spec; 4731 struct sigmatel_spec *spec = codec->spec;
4732 int i;
4733 hda_nid_t nid;
4734
4735 /* reset each pin before powering down DAC/ADC to avoid click noise */
4736 nid = codec->start_nid;
4737 for (i = 0; i < codec->num_nodes; i++, nid++) {
4738 unsigned int wcaps = get_wcaps(codec, nid);
4739 unsigned int wid_type = get_wcaps_type(wcaps);
4740 if (wid_type == AC_WID_PIN)
4741 snd_hda_codec_read(codec, nid, 0,
4742 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
4743 }
4744
4757 if (spec->eapd_mask) 4745 if (spec->eapd_mask)
4758 stac_gpio_set(codec, spec->gpio_mask, 4746 stac_gpio_set(codec, spec->gpio_mask,
4759 spec->gpio_dir, spec->gpio_data & 4747 spec->gpio_dir, spec->gpio_data &
@@ -4790,7 +4778,8 @@ static int patch_stac9200(struct hda_codec *codec)
4790 stac9200_models, 4778 stac9200_models,
4791 stac9200_cfg_tbl); 4779 stac9200_cfg_tbl);
4792 if (spec->board_config < 0) 4780 if (spec->board_config < 0)
4793 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); 4781 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4782 codec->chip_name);
4794 else 4783 else
4795 stac92xx_set_config_regs(codec, 4784 stac92xx_set_config_regs(codec,
4796 stac9200_brd_tbl[spec->board_config]); 4785 stac9200_brd_tbl[spec->board_config]);
@@ -4862,8 +4851,8 @@ static int patch_stac925x(struct hda_codec *codec)
4862 stac925x_cfg_tbl); 4851 stac925x_cfg_tbl);
4863 again: 4852 again:
4864 if (spec->board_config < 0) 4853 if (spec->board_config < 0)
4865 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," 4854 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4866 "using BIOS defaults\n"); 4855 codec->chip_name);
4867 else 4856 else
4868 stac92xx_set_config_regs(codec, 4857 stac92xx_set_config_regs(codec,
4869 stac925x_brd_tbl[spec->board_config]); 4858 stac925x_brd_tbl[spec->board_config]);
@@ -4893,6 +4882,9 @@ static int patch_stac925x(struct hda_codec *codec)
4893 4882
4894 spec->init = stac925x_core_init; 4883 spec->init = stac925x_core_init;
4895 spec->mixer = stac925x_mixer; 4884 spec->mixer = stac925x_mixer;
4885 spec->num_caps = 1;
4886 spec->capvols = stac925x_capvols;
4887 spec->capsws = stac925x_capsws;
4896 4888
4897 err = stac92xx_parse_auto_config(codec, 0x8, 0x7); 4889 err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
4898 if (!err) { 4890 if (!err) {
@@ -4914,16 +4906,6 @@ static int patch_stac925x(struct hda_codec *codec)
4914 return 0; 4906 return 0;
4915} 4907}
4916 4908
4917static struct hda_input_mux stac92hd73xx_dmux = {
4918 .num_items = 4,
4919 .items = {
4920 { "Analog Inputs", 0x0b },
4921 { "Digital Mic 1", 0x09 },
4922 { "Digital Mic 2", 0x0a },
4923 { "CD", 0x08 },
4924 }
4925};
4926
4927static int patch_stac92hd73xx(struct hda_codec *codec) 4909static int patch_stac92hd73xx(struct hda_codec *codec)
4928{ 4910{
4929 struct sigmatel_spec *spec; 4911 struct sigmatel_spec *spec;
@@ -4943,10 +4925,16 @@ static int patch_stac92hd73xx(struct hda_codec *codec)
4943 STAC_92HD73XX_MODELS, 4925 STAC_92HD73XX_MODELS,
4944 stac92hd73xx_models, 4926 stac92hd73xx_models,
4945 stac92hd73xx_cfg_tbl); 4927 stac92hd73xx_cfg_tbl);
4928 /* check codec subsystem id if not found */
4929 if (spec->board_config < 0)
4930 spec->board_config =
4931 snd_hda_check_board_codec_sid_config(codec,
4932 STAC_92HD73XX_MODELS, stac92hd73xx_models,
4933 stac92hd73xx_codec_id_cfg_tbl);
4946again: 4934again:
4947 if (spec->board_config < 0) 4935 if (spec->board_config < 0)
4948 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 4936 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
4949 " STAC92HD73XX, using BIOS defaults\n"); 4937 codec->chip_name);
4950 else 4938 else
4951 stac92xx_set_config_regs(codec, 4939 stac92xx_set_config_regs(codec,
4952 stac92hd73xx_brd_tbl[spec->board_config]); 4940 stac92hd73xx_brd_tbl[spec->board_config]);
@@ -4959,20 +4947,15 @@ again:
4959 "number of channels defaulting to DAC count\n"); 4947 "number of channels defaulting to DAC count\n");
4960 num_dacs = STAC92HD73_DAC_COUNT; 4948 num_dacs = STAC92HD73_DAC_COUNT;
4961 } 4949 }
4950 spec->init = stac92hd73xx_core_init;
4962 switch (num_dacs) { 4951 switch (num_dacs) {
4963 case 0x3: /* 6 Channel */ 4952 case 0x3: /* 6 Channel */
4964 spec->mixer = stac92hd73xx_6ch_mixer;
4965 spec->init = stac92hd73xx_6ch_core_init;
4966 spec->aloopback_ctl = stac92hd73xx_6ch_loopback; 4953 spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
4967 break; 4954 break;
4968 case 0x4: /* 8 Channel */ 4955 case 0x4: /* 8 Channel */
4969 spec->mixer = stac92hd73xx_8ch_mixer;
4970 spec->init = stac92hd73xx_8ch_core_init;
4971 spec->aloopback_ctl = stac92hd73xx_8ch_loopback; 4956 spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
4972 break; 4957 break;
4973 case 0x5: /* 10 Channel */ 4958 case 0x5: /* 10 Channel */
4974 spec->mixer = stac92hd73xx_10ch_mixer;
4975 spec->init = stac92hd73xx_10ch_core_init;
4976 spec->aloopback_ctl = stac92hd73xx_10ch_loopback; 4959 spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
4977 break; 4960 break;
4978 } 4961 }
@@ -4987,14 +4970,14 @@ again:
4987 spec->dmic_nids = stac92hd73xx_dmic_nids; 4970 spec->dmic_nids = stac92hd73xx_dmic_nids;
4988 spec->dmux_nids = stac92hd73xx_dmux_nids; 4971 spec->dmux_nids = stac92hd73xx_dmux_nids;
4989 spec->smux_nids = stac92hd73xx_smux_nids; 4972 spec->smux_nids = stac92hd73xx_smux_nids;
4990 spec->amp_nids = stac92hd73xx_amp_nids;
4991 spec->num_amps = ARRAY_SIZE(stac92hd73xx_amp_nids);
4992 4973
4993 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids); 4974 spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
4994 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids); 4975 spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
4995 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids); 4976 spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
4996 memcpy(&spec->private_dimux, &stac92hd73xx_dmux, 4977
4997 sizeof(stac92hd73xx_dmux)); 4978 spec->num_caps = STAC92HD73XX_NUM_CAPS;
4979 spec->capvols = stac92hd73xx_capvols;
4980 spec->capsws = stac92hd73xx_capsws;
4998 4981
4999 switch (spec->board_config) { 4982 switch (spec->board_config) {
5000 case STAC_DELL_EQ: 4983 case STAC_DELL_EQ:
@@ -5004,43 +4987,40 @@ again:
5004 case STAC_DELL_M6_DMIC: 4987 case STAC_DELL_M6_DMIC:
5005 case STAC_DELL_M6_BOTH: 4988 case STAC_DELL_M6_BOTH:
5006 spec->num_smuxes = 0; 4989 spec->num_smuxes = 0;
5007 spec->mixer = &stac92hd73xx_6ch_mixer[DELL_M6_MIXER];
5008 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
5009 spec->eapd_switch = 0; 4990 spec->eapd_switch = 0;
5010 spec->num_amps = 1;
5011 4991
5012 if (spec->board_config != STAC_DELL_EQ)
5013 spec->init = dell_m6_core_init;
5014 switch (spec->board_config) { 4992 switch (spec->board_config) {
5015 case STAC_DELL_M6_AMIC: /* Analog Mics */ 4993 case STAC_DELL_M6_AMIC: /* Analog Mics */
5016 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); 4994 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5017 spec->num_dmics = 0; 4995 spec->num_dmics = 0;
5018 spec->private_dimux.num_items = 1;
5019 break; 4996 break;
5020 case STAC_DELL_M6_DMIC: /* Digital Mics */ 4997 case STAC_DELL_M6_DMIC: /* Digital Mics */
5021 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); 4998 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5022 spec->num_dmics = 1; 4999 spec->num_dmics = 1;
5023 spec->private_dimux.num_items = 2;
5024 break; 5000 break;
5025 case STAC_DELL_M6_BOTH: /* Both */ 5001 case STAC_DELL_M6_BOTH: /* Both */
5026 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); 5002 snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
5027 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); 5003 snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
5028 spec->num_dmics = 1; 5004 spec->num_dmics = 1;
5029 spec->private_dimux.num_items = 2;
5030 break; 5005 break;
5031 } 5006 }
5032 break; 5007 break;
5008 case STAC_ALIENWARE_M17X:
5009 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5010 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5011 spec->eapd_switch = 0;
5012 break;
5033 default: 5013 default:
5034 spec->num_dmics = STAC92HD73XX_NUM_DMICS; 5014 spec->num_dmics = STAC92HD73XX_NUM_DMICS;
5035 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids); 5015 spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
5036 spec->eapd_switch = 1; 5016 spec->eapd_switch = 1;
5017 break;
5037 } 5018 }
5038 if (spec->board_config > STAC_92HD73XX_REF) { 5019 if (spec->board_config > STAC_92HD73XX_REF) {
5039 /* GPIO0 High = Enable EAPD */ 5020 /* GPIO0 High = Enable EAPD */
5040 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1; 5021 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
5041 spec->gpio_data = 0x01; 5022 spec->gpio_data = 0x01;
5042 } 5023 }
5043 spec->dinput_mux = &spec->private_dimux;
5044 5024
5045 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids); 5025 spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
5046 spec->pwr_nids = stac92hd73xx_pwr_nids; 5026 spec->pwr_nids = stac92hd73xx_pwr_nids;
@@ -5072,15 +5052,6 @@ again:
5072 return 0; 5052 return 0;
5073} 5053}
5074 5054
5075static struct hda_input_mux stac92hd83xxx_dmux = {
5076 .num_items = 3,
5077 .items = {
5078 { "Analog Inputs", 0x03 },
5079 { "Digital Mic 1", 0x04 },
5080 { "Digital Mic 2", 0x05 },
5081 }
5082};
5083
5084static int patch_stac92hd83xxx(struct hda_codec *codec) 5055static int patch_stac92hd83xxx(struct hda_codec *codec)
5085{ 5056{
5086 struct sigmatel_spec *spec; 5057 struct sigmatel_spec *spec;
@@ -5097,32 +5068,30 @@ static int patch_stac92hd83xxx(struct hda_codec *codec)
5097 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; 5068 codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
5098 spec->mono_nid = 0x19; 5069 spec->mono_nid = 0x19;
5099 spec->digbeep_nid = 0x21; 5070 spec->digbeep_nid = 0x21;
5100 spec->dmic_nids = stac92hd83xxx_dmic_nids; 5071 spec->mux_nids = stac92hd83xxx_mux_nids;
5101 spec->dmux_nids = stac92hd83xxx_dmux_nids; 5072 spec->num_muxes = ARRAY_SIZE(stac92hd83xxx_mux_nids);
5102 spec->adc_nids = stac92hd83xxx_adc_nids; 5073 spec->adc_nids = stac92hd83xxx_adc_nids;
5074 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5103 spec->pwr_nids = stac92hd83xxx_pwr_nids; 5075 spec->pwr_nids = stac92hd83xxx_pwr_nids;
5104 spec->amp_nids = stac92hd83xxx_amp_nids;
5105 spec->pwr_mapping = stac92hd83xxx_pwr_mapping; 5076 spec->pwr_mapping = stac92hd83xxx_pwr_mapping;
5106 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); 5077 spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
5107 spec->multiout.dac_nids = spec->dac_nids; 5078 spec->multiout.dac_nids = spec->dac_nids;
5108 5079
5109 spec->init = stac92hd83xxx_core_init; 5080 spec->init = stac92hd83xxx_core_init;
5110 spec->mixer = stac92hd83xxx_mixer;
5111 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids); 5081 spec->num_pins = ARRAY_SIZE(stac92hd83xxx_pin_nids);
5112 spec->num_dmuxes = ARRAY_SIZE(stac92hd83xxx_dmux_nids);
5113 spec->num_adcs = ARRAY_SIZE(stac92hd83xxx_adc_nids);
5114 spec->num_amps = ARRAY_SIZE(stac92hd83xxx_amp_nids);
5115 spec->num_dmics = STAC92HD83XXX_NUM_DMICS;
5116 spec->dinput_mux = &stac92hd83xxx_dmux;
5117 spec->pin_nids = stac92hd83xxx_pin_nids; 5082 spec->pin_nids = stac92hd83xxx_pin_nids;
5083 spec->num_caps = STAC92HD83XXX_NUM_CAPS;
5084 spec->capvols = stac92hd83xxx_capvols;
5085 spec->capsws = stac92hd83xxx_capsws;
5086
5118 spec->board_config = snd_hda_check_board_config(codec, 5087 spec->board_config = snd_hda_check_board_config(codec,
5119 STAC_92HD83XXX_MODELS, 5088 STAC_92HD83XXX_MODELS,
5120 stac92hd83xxx_models, 5089 stac92hd83xxx_models,
5121 stac92hd83xxx_cfg_tbl); 5090 stac92hd83xxx_cfg_tbl);
5122again: 5091again:
5123 if (spec->board_config < 0) 5092 if (spec->board_config < 0)
5124 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5093 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5125 " STAC92HD83XXX, using BIOS defaults\n"); 5094 codec->chip_name);
5126 else 5095 else
5127 stac92xx_set_config_regs(codec, 5096 stac92xx_set_config_regs(codec,
5128 stac92hd83xxx_brd_tbl[spec->board_config]); 5097 stac92hd83xxx_brd_tbl[spec->board_config]);
@@ -5164,6 +5133,8 @@ again:
5164 5133
5165 num_dacs = snd_hda_get_connections(codec, nid, 5134 num_dacs = snd_hda_get_connections(codec, nid,
5166 conn, STAC92HD83_DAC_COUNT + 1) - 1; 5135 conn, STAC92HD83_DAC_COUNT + 1) - 1;
5136 if (num_dacs < 0)
5137 num_dacs = STAC92HD83_DAC_COUNT;
5167 5138
5168 /* set port X to select the last DAC 5139 /* set port X to select the last DAC
5169 */ 5140 */
@@ -5177,25 +5148,6 @@ again:
5177 return 0; 5148 return 0;
5178} 5149}
5179 5150
5180static struct hda_input_mux stac92hd71bxx_dmux_nomixer = {
5181 .num_items = 3,
5182 .items = {
5183 { "Analog Inputs", 0x00 },
5184 { "Digital Mic 1", 0x02 },
5185 { "Digital Mic 2", 0x03 },
5186 }
5187};
5188
5189static struct hda_input_mux stac92hd71bxx_dmux_amixer = {
5190 .num_items = 4,
5191 .items = {
5192 { "Analog Inputs", 0x00 },
5193 { "Mixer", 0x01 },
5194 { "Digital Mic 1", 0x02 },
5195 { "Digital Mic 2", 0x03 },
5196 }
5197};
5198
5199/* get the pin connection (fixed, none, etc) */ 5151/* get the pin connection (fixed, none, etc) */
5200static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) 5152static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
5201{ 5153{
@@ -5256,7 +5208,6 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
5256 struct sigmatel_spec *spec; 5208 struct sigmatel_spec *spec;
5257 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; 5209 struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
5258 int err = 0; 5210 int err = 0;
5259 unsigned int ndmic_nids = 0;
5260 5211
5261 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5212 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
5262 if (spec == NULL) 5213 if (spec == NULL)
@@ -5285,8 +5236,8 @@ static int patch_stac92hd71bxx(struct hda_codec *codec)
5285 stac92hd71bxx_cfg_tbl); 5236 stac92hd71bxx_cfg_tbl);
5286again: 5237again:
5287 if (spec->board_config < 0) 5238 if (spec->board_config < 0)
5288 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5239 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5289 " STAC92HD71BXX, using BIOS defaults\n"); 5240 codec->chip_name);
5290 else 5241 else
5291 stac92xx_set_config_regs(codec, 5242 stac92xx_set_config_regs(codec,
5292 stac92hd71bxx_brd_tbl[spec->board_config]); 5243 stac92hd71bxx_brd_tbl[spec->board_config]);
@@ -5301,6 +5252,10 @@ again:
5301 spec->dmic_nids = stac92hd71bxx_dmic_nids; 5252 spec->dmic_nids = stac92hd71bxx_dmic_nids;
5302 spec->dmux_nids = stac92hd71bxx_dmux_nids; 5253 spec->dmux_nids = stac92hd71bxx_dmux_nids;
5303 5254
5255 spec->num_caps = STAC92HD71BXX_NUM_CAPS;
5256 spec->capvols = stac92hd71bxx_capvols;
5257 spec->capsws = stac92hd71bxx_capsws;
5258
5304 switch (codec->vendor_id) { 5259 switch (codec->vendor_id) {
5305 case 0x111d76b6: /* 4 Port without Analog Mixer */ 5260 case 0x111d76b6: /* 4 Port without Analog Mixer */
5306 case 0x111d76b7: 5261 case 0x111d76b7:
@@ -5308,24 +5263,13 @@ again:
5308 /* fallthru */ 5263 /* fallthru */
5309 case 0x111d76b4: /* 6 Port without Analog Mixer */ 5264 case 0x111d76b4: /* 6 Port without Analog Mixer */
5310 case 0x111d76b5: 5265 case 0x111d76b5:
5311 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_nomixer,
5312 sizeof(stac92hd71bxx_dmux_nomixer));
5313 spec->mixer = stac92hd71bxx_mixer;
5314 spec->init = stac92hd71bxx_core_init; 5266 spec->init = stac92hd71bxx_core_init;
5315 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5267 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5316 spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5268 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5317 stac92hd71bxx_dmic_nids, 5269 stac92hd71bxx_dmic_nids,
5318 STAC92HD71BXX_NUM_DMICS); 5270 STAC92HD71BXX_NUM_DMICS);
5319 if (spec->num_dmics) {
5320 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5321 spec->dinput_mux = &spec->private_dimux;
5322 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5323 }
5324 break; 5271 break;
5325 case 0x111d7608: /* 5 Port with Analog Mixer */ 5272 case 0x111d7608: /* 5 Port with Analog Mixer */
5326 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer,
5327 sizeof(stac92hd71bxx_dmux_amixer));
5328 spec->private_dimux.num_items--;
5329 switch (spec->board_config) { 5273 switch (spec->board_config) {
5330 case STAC_HP_M4: 5274 case STAC_HP_M4:
5331 /* Enable VREF power saving on GPIO1 detect */ 5275 /* Enable VREF power saving on GPIO1 detect */
@@ -5347,11 +5291,8 @@ again:
5347 5291
5348 /* no output amps */ 5292 /* no output amps */
5349 spec->num_pwrs = 0; 5293 spec->num_pwrs = 0;
5350 spec->mixer = stac92hd71bxx_analog_mixer;
5351 spec->dinput_mux = &spec->private_dimux;
5352
5353 /* disable VSW */ 5294 /* disable VSW */
5354 spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; 5295 spec->init = stac92hd71bxx_core_init;
5355 unmute_init++; 5296 unmute_init++;
5356 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); 5297 snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
5357 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); 5298 snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
@@ -5359,8 +5300,6 @@ again:
5359 spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5300 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5360 stac92hd71bxx_dmic_nids, 5301 stac92hd71bxx_dmic_nids,
5361 STAC92HD71BXX_NUM_DMICS - 1); 5302 STAC92HD71BXX_NUM_DMICS - 1);
5362 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5363 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 2;
5364 break; 5303 break;
5365 case 0x111d7603: /* 6 Port with Analog Mixer */ 5304 case 0x111d7603: /* 6 Port with Analog Mixer */
5366 if ((codec->revision_id & 0xf) == 1) 5305 if ((codec->revision_id & 0xf) == 1)
@@ -5370,17 +5309,12 @@ again:
5370 spec->num_pwrs = 0; 5309 spec->num_pwrs = 0;
5371 /* fallthru */ 5310 /* fallthru */
5372 default: 5311 default:
5373 memcpy(&spec->private_dimux, &stac92hd71bxx_dmux_amixer, 5312 spec->init = stac92hd71bxx_core_init;
5374 sizeof(stac92hd71bxx_dmux_amixer));
5375 spec->dinput_mux = &spec->private_dimux;
5376 spec->mixer = stac92hd71bxx_analog_mixer;
5377 spec->init = stac92hd71bxx_analog_core_init;
5378 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs; 5313 codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
5379 spec->num_dmics = stac92hd71bxx_connected_ports(codec, 5314 spec->num_dmics = stac92hd71bxx_connected_ports(codec,
5380 stac92hd71bxx_dmic_nids, 5315 stac92hd71bxx_dmic_nids,
5381 STAC92HD71BXX_NUM_DMICS); 5316 STAC92HD71BXX_NUM_DMICS);
5382 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); 5317 break;
5383 ndmic_nids = ARRAY_SIZE(stac92hd71bxx_dmic_nids) - 1;
5384 } 5318 }
5385 5319
5386 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP) 5320 if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
@@ -5408,6 +5342,7 @@ again:
5408 5342
5409 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids); 5343 spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
5410 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids); 5344 spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
5345 spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
5411 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e); 5346 spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
5412 5347
5413 switch (spec->board_config) { 5348 switch (spec->board_config) {
@@ -5462,8 +5397,6 @@ again:
5462#endif 5397#endif
5463 5398
5464 spec->multiout.dac_nids = spec->dac_nids; 5399 spec->multiout.dac_nids = spec->dac_nids;
5465 if (spec->dinput_mux)
5466 spec->private_dimux.num_items += spec->num_dmics - ndmic_nids;
5467 5400
5468 err = stac92xx_parse_auto_config(codec, 0x21, 0); 5401 err = stac92xx_parse_auto_config(codec, 0x21, 0);
5469 if (!err) { 5402 if (!err) {
@@ -5541,8 +5474,8 @@ static int patch_stac922x(struct hda_codec *codec)
5541 5474
5542 again: 5475 again:
5543 if (spec->board_config < 0) 5476 if (spec->board_config < 0)
5544 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " 5477 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5545 "using BIOS defaults\n"); 5478 codec->chip_name);
5546 else 5479 else
5547 stac92xx_set_config_regs(codec, 5480 stac92xx_set_config_regs(codec,
5548 stac922x_brd_tbl[spec->board_config]); 5481 stac922x_brd_tbl[spec->board_config]);
@@ -5555,7 +5488,10 @@ static int patch_stac922x(struct hda_codec *codec)
5555 spec->num_pwrs = 0; 5488 spec->num_pwrs = 0;
5556 5489
5557 spec->init = stac922x_core_init; 5490 spec->init = stac922x_core_init;
5558 spec->mixer = stac922x_mixer; 5491
5492 spec->num_caps = STAC922X_NUM_CAPS;
5493 spec->capvols = stac922x_capvols;
5494 spec->capsws = stac922x_capsws;
5559 5495
5560 spec->multiout.dac_nids = spec->dac_nids; 5496 spec->multiout.dac_nids = spec->dac_nids;
5561 5497
@@ -5604,8 +5540,8 @@ static int patch_stac927x(struct hda_codec *codec)
5604 stac927x_cfg_tbl); 5540 stac927x_cfg_tbl);
5605 again: 5541 again:
5606 if (spec->board_config < 0) 5542 if (spec->board_config < 0)
5607 snd_printdd(KERN_INFO "hda_codec: Unknown model for" 5543 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5608 "STAC927x, using BIOS defaults\n"); 5544 codec->chip_name);
5609 else 5545 else
5610 stac92xx_set_config_regs(codec, 5546 stac92xx_set_config_regs(codec,
5611 stac927x_brd_tbl[spec->board_config]); 5547 stac927x_brd_tbl[spec->board_config]);
@@ -5630,7 +5566,6 @@ static int patch_stac927x(struct hda_codec *codec)
5630 spec->num_dmics = 0; 5566 spec->num_dmics = 0;
5631 5567
5632 spec->init = d965_core_init; 5568 spec->init = d965_core_init;
5633 spec->mixer = stac927x_mixer;
5634 break; 5569 break;
5635 case STAC_DELL_BIOS: 5570 case STAC_DELL_BIOS:
5636 switch (codec->subsystem_id) { 5571 switch (codec->subsystem_id) {
@@ -5662,7 +5597,6 @@ static int patch_stac927x(struct hda_codec *codec)
5662 spec->num_dmics = STAC927X_NUM_DMICS; 5597 spec->num_dmics = STAC927X_NUM_DMICS;
5663 5598
5664 spec->init = d965_core_init; 5599 spec->init = d965_core_init;
5665 spec->mixer = stac927x_mixer;
5666 spec->dmux_nids = stac927x_dmux_nids; 5600 spec->dmux_nids = stac927x_dmux_nids;
5667 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids); 5601 spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
5668 break; 5602 break;
@@ -5675,9 +5609,12 @@ static int patch_stac927x(struct hda_codec *codec)
5675 spec->num_dmics = 0; 5609 spec->num_dmics = 0;
5676 5610
5677 spec->init = stac927x_core_init; 5611 spec->init = stac927x_core_init;
5678 spec->mixer = stac927x_mixer;
5679 } 5612 }
5680 5613
5614 spec->num_caps = STAC927X_NUM_CAPS;
5615 spec->capvols = stac927x_capvols;
5616 spec->capsws = stac927x_capsws;
5617
5681 spec->num_pwrs = 0; 5618 spec->num_pwrs = 0;
5682 spec->aloopback_ctl = stac927x_loopback; 5619 spec->aloopback_ctl = stac927x_loopback;
5683 spec->aloopback_mask = 0x40; 5620 spec->aloopback_mask = 0x40;
@@ -5739,7 +5676,8 @@ static int patch_stac9205(struct hda_codec *codec)
5739 stac9205_cfg_tbl); 5676 stac9205_cfg_tbl);
5740 again: 5677 again:
5741 if (spec->board_config < 0) 5678 if (spec->board_config < 0)
5742 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); 5679 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5680 codec->chip_name);
5743 else 5681 else
5744 stac92xx_set_config_regs(codec, 5682 stac92xx_set_config_regs(codec,
5745 stac9205_brd_tbl[spec->board_config]); 5683 stac9205_brd_tbl[spec->board_config]);
@@ -5758,9 +5696,12 @@ static int patch_stac9205(struct hda_codec *codec)
5758 spec->num_pwrs = 0; 5696 spec->num_pwrs = 0;
5759 5697
5760 spec->init = stac9205_core_init; 5698 spec->init = stac9205_core_init;
5761 spec->mixer = stac9205_mixer;
5762 spec->aloopback_ctl = stac9205_loopback; 5699 spec->aloopback_ctl = stac9205_loopback;
5763 5700
5701 spec->num_caps = STAC9205_NUM_CAPS;
5702 spec->capvols = stac9205_capvols;
5703 spec->capsws = stac9205_capsws;
5704
5764 spec->aloopback_mask = 0x40; 5705 spec->aloopback_mask = 0x40;
5765 spec->aloopback_shift = 0; 5706 spec->aloopback_shift = 0;
5766 /* Turn on/off EAPD per HP plugging */ 5707 /* Turn on/off EAPD per HP plugging */
@@ -5835,12 +5776,6 @@ static struct hda_verb stac9872_core_init[] = {
5835 {} 5776 {}
5836}; 5777};
5837 5778
5838static struct snd_kcontrol_new stac9872_mixer[] = {
5839 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
5840 HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
5841 { } /* end */
5842};
5843
5844static hda_nid_t stac9872_pin_nids[] = { 5779static hda_nid_t stac9872_pin_nids[] = {
5845 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 5780 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
5846 0x11, 0x13, 0x14, 5781 0x11, 0x13, 0x14,
@@ -5854,6 +5789,11 @@ static hda_nid_t stac9872_mux_nids[] = {
5854 0x15 5789 0x15
5855}; 5790};
5856 5791
5792static unsigned long stac9872_capvols[] = {
5793 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
5794};
5795#define stac9872_capsws stac9872_capvols
5796
5857static unsigned int stac9872_vaio_pin_configs[9] = { 5797static unsigned int stac9872_vaio_pin_configs[9] = {
5858 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030, 5798 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
5859 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0, 5799 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
@@ -5891,8 +5831,8 @@ static int patch_stac9872(struct hda_codec *codec)
5891 stac9872_models, 5831 stac9872_models,
5892 stac9872_cfg_tbl); 5832 stac9872_cfg_tbl);
5893 if (spec->board_config < 0) 5833 if (spec->board_config < 0)
5894 snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9872, " 5834 snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5895 "using BIOS defaults\n"); 5835 codec->chip_name);
5896 else 5836 else
5897 stac92xx_set_config_regs(codec, 5837 stac92xx_set_config_regs(codec,
5898 stac9872_brd_tbl[spec->board_config]); 5838 stac9872_brd_tbl[spec->board_config]);
@@ -5902,8 +5842,10 @@ static int patch_stac9872(struct hda_codec *codec)
5902 spec->adc_nids = stac9872_adc_nids; 5842 spec->adc_nids = stac9872_adc_nids;
5903 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids); 5843 spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
5904 spec->mux_nids = stac9872_mux_nids; 5844 spec->mux_nids = stac9872_mux_nids;
5905 spec->mixer = stac9872_mixer;
5906 spec->init = stac9872_core_init; 5845 spec->init = stac9872_core_init;
5846 spec->num_caps = 1;
5847 spec->capvols = stac9872_capvols;
5848 spec->capsws = stac9872_capsws;
5907 5849
5908 err = stac92xx_parse_auto_config(codec, 0x10, 0x12); 5850 err = stac92xx_parse_auto_config(codec, 0x10, 0x12);
5909 if (err < 0) { 5851 if (err < 0) {