aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-07-06 10:38:42 -0400
committerTakashi Iwai <tiwai@suse.de>2011-07-07 03:34:46 -0400
commitd6cc9fabd58f33e829a3182aa856db0d57c726ef (patch)
tree05d804a5cc3c20af60bc9555f1c21946391f5bd0 /sound
parent0a7f532090f04093f8c11c4679e892f3a0fb63e5 (diff)
ALSA: hda - Parse ADCs and CAPSRCs dynamically for Realtek auto-parser
Now with the new code for looking for ADCs and MUXs, we can replace the whole ADC assignment with the parsed results. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/patch_realtek.c323
1 files changed, 131 insertions, 192 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index c70d3469ab29..cdd8561f5f4b 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -405,6 +405,7 @@ struct alc_spec {
405 unsigned int no_analog :1; /* digital I/O only */ 405 unsigned int no_analog :1; /* digital I/O only */
406 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */ 406 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
407 unsigned int single_input_src:1; 407 unsigned int single_input_src:1;
408 unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */
408 409
409 /* auto-mute control */ 410 /* auto-mute control */
410 int automute_mode; 411 int automute_mode;
@@ -2677,11 +2678,15 @@ static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2677{ 2678{
2678 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2679 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2679 struct alc_spec *spec = codec->spec; 2680 struct alc_spec *spec = codec->spec;
2681 unsigned long val;
2680 int err; 2682 int err;
2681 2683
2682 mutex_lock(&codec->control_mutex); 2684 mutex_lock(&codec->control_mutex);
2683 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, 2685 if (spec->vol_in_capsrc)
2684 HDA_INPUT); 2686 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
2687 else
2688 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
2689 kcontrol->private_value = val;
2685 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); 2690 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
2686 mutex_unlock(&codec->control_mutex); 2691 mutex_unlock(&codec->control_mutex);
2687 return err; 2692 return err;
@@ -2692,11 +2697,15 @@ static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2692{ 2697{
2693 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 2698 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2694 struct alc_spec *spec = codec->spec; 2699 struct alc_spec *spec = codec->spec;
2700 unsigned long val;
2695 int err; 2701 int err;
2696 2702
2697 mutex_lock(&codec->control_mutex); 2703 mutex_lock(&codec->control_mutex);
2698 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, 2704 if (spec->vol_in_capsrc)
2699 HDA_INPUT); 2705 val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT);
2706 else
2707 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT);
2708 kcontrol->private_value = val;
2700 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); 2709 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
2701 mutex_unlock(&codec->control_mutex); 2710 mutex_unlock(&codec->control_mutex);
2702 return err; 2711 return err;
@@ -2725,9 +2734,14 @@ static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2725 } 2734 }
2726 } else { 2735 } else {
2727 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 2736 i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2728 kcontrol->private_value = 2737 if (spec->vol_in_capsrc)
2729 HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], 2738 kcontrol->private_value =
2730 3, 0, HDA_INPUT); 2739 HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i],
2740 3, 0, HDA_OUTPUT);
2741 else
2742 kcontrol->private_value =
2743 val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[i],
2744 3, 0, HDA_INPUT);
2731 err = func(kcontrol, ucontrol); 2745 err = func(kcontrol, ucontrol);
2732 } 2746 }
2733 error: 2747 error:
@@ -5381,10 +5395,14 @@ static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
5381 return (pincap & AC_PINCAP_IN) != 0; 5395 return (pincap & AC_PINCAP_IN) != 0;
5382} 5396}
5383 5397
5384static int alc_auto_fill_adc_caps(struct hda_codec *codec, hda_nid_t *adc_nids, 5398static int alc_auto_fill_adc_caps(struct hda_codec *codec)
5385 hda_nid_t *cap_nids, int max_nums)
5386{ 5399{
5400 struct alc_spec *spec = codec->spec;
5387 hda_nid_t nid; 5401 hda_nid_t nid;
5402 hda_nid_t *adc_nids = spec->private_adc_nids;
5403 hda_nid_t *cap_nids = spec->private_capsrc_nids;
5404 int max_nums = ARRAY_SIZE(spec->private_adc_nids);
5405 bool indep_capsrc = false;
5388 int i, nums = 0; 5406 int i, nums = 0;
5389 5407
5390 nid = codec->start_nid; 5408 nid = codec->start_nid;
@@ -5406,11 +5424,13 @@ static int alc_auto_fill_adc_caps(struct hda_codec *codec, hda_nid_t *adc_nids,
5406 break; 5424 break;
5407 if (type == AC_WID_AUD_SEL) { 5425 if (type == AC_WID_AUD_SEL) {
5408 cap_nids[nums] = src; 5426 cap_nids[nums] = src;
5427 indep_capsrc = true;
5409 break; 5428 break;
5410 } 5429 }
5411 n = snd_hda_get_conn_list(codec, src, &list); 5430 n = snd_hda_get_conn_list(codec, src, &list);
5412 if (n > 1) { 5431 if (n > 1) {
5413 cap_nids[nums] = src; 5432 cap_nids[nums] = src;
5433 indep_capsrc = true;
5414 break; 5434 break;
5415 } else if (n != 1) 5435 } else if (n != 1)
5416 break; 5436 break;
@@ -5419,6 +5439,10 @@ static int alc_auto_fill_adc_caps(struct hda_codec *codec, hda_nid_t *adc_nids,
5419 if (++nums >= max_nums) 5439 if (++nums >= max_nums)
5420 break; 5440 break;
5421 } 5441 }
5442 spec->adc_nids = spec->private_adc_nids;
5443 if (indep_capsrc)
5444 spec->capsrc_nids = spec->private_capsrc_nids;
5445 spec->num_adc_nids = nums;
5422 return nums; 5446 return nums;
5423} 5447}
5424 5448
@@ -5430,11 +5454,10 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
5430 hda_nid_t mixer = spec->mixer_nid; 5454 hda_nid_t mixer = spec->mixer_nid;
5431 struct hda_input_mux *imux = &spec->private_imux[0]; 5455 struct hda_input_mux *imux = &spec->private_imux[0];
5432 int num_adcs; 5456 int num_adcs;
5433 hda_nid_t caps[5], adcs[5];
5434 int i, c, err, idx, type_idx = 0; 5457 int i, c, err, idx, type_idx = 0;
5435 const char *prev_label = NULL; 5458 const char *prev_label = NULL;
5436 5459
5437 num_adcs = alc_auto_fill_adc_caps(codec, adcs, caps, ARRAY_SIZE(adcs)); 5460 num_adcs = alc_auto_fill_adc_caps(codec);
5438 if (num_adcs < 0) 5461 if (num_adcs < 0)
5439 return 0; 5462 return 0;
5440 5463
@@ -5465,7 +5488,9 @@ static int alc_auto_create_input_ctls(struct hda_codec *codec)
5465 } 5488 }
5466 5489
5467 for (c = 0; c < num_adcs; c++) { 5490 for (c = 0; c < num_adcs; c++) {
5468 idx = get_connection_index(codec, caps[c], pin); 5491 hda_nid_t cap = spec->capsrc_nids ?
5492 spec->capsrc_nids[c] : spec->adc_nids[c];
5493 idx = get_connection_index(codec, cap, pin);
5469 if (idx >= 0) { 5494 if (idx >= 0) {
5470 snd_hda_add_imux_item(imux, label, idx, NULL); 5495 snd_hda_add_imux_item(imux, label, idx, NULL);
5471 break; 5496 break;
@@ -5552,6 +5577,7 @@ static void alc880_auto_init_input_src(struct hda_codec *codec)
5552 5577
5553static int alc_auto_add_multi_channel_mode(struct hda_codec *codec, 5578static int alc_auto_add_multi_channel_mode(struct hda_codec *codec,
5554 int (*fill_dac)(struct hda_codec *)); 5579 int (*fill_dac)(struct hda_codec *));
5580static void alc_remove_invalid_adc_nids(struct hda_codec *codec);
5555 5581
5556/* parse the BIOS configuration and set up the alc_spec */ 5582/* parse the BIOS configuration and set up the alc_spec */
5557/* return 1 if successful, 0 if the proper config is not found, 5583/* return 1 if successful, 0 if the proper config is not found,
@@ -5599,6 +5625,9 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
5599 spec->num_mux_defs = 1; 5625 spec->num_mux_defs = 1;
5600 spec->input_mux = &spec->private_imux[0]; 5626 spec->input_mux = &spec->private_imux[0];
5601 5627
5628 if (!spec->dual_adc_switch)
5629 alc_remove_invalid_adc_nids(codec);
5630
5602 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); 5631 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
5603 5632
5604 return 1; 5633 return 1;
@@ -5742,9 +5771,21 @@ static void set_capture_mixer(struct hda_codec *codec)
5742 alc_capture_mixer2, 5771 alc_capture_mixer2,
5743 alc_capture_mixer3 }, 5772 alc_capture_mixer3 },
5744 }; 5773 };
5745 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) { 5774
5775 /* check whether either of ADC or MUX has a volume control */
5776 if (!(query_amp_caps(codec, spec->adc_nids[0], HDA_INPUT) &
5777 AC_AMPCAP_NUM_STEPS)) {
5778 if (!spec->capsrc_nids)
5779 return; /* no volume */
5780 if (!(query_amp_caps(codec, spec->capsrc_nids[0], HDA_OUTPUT) &
5781 AC_AMPCAP_NUM_STEPS))
5782 return; /* no volume in capsrc, too */
5783 spec->vol_in_capsrc = 1;
5784 }
5785
5786 if (spec->num_adc_nids > 0) {
5746 int mux = 0; 5787 int mux = 0;
5747 int num_adcs = spec->num_adc_nids; 5788 int num_adcs = 0;
5748 if (spec->dual_adc_switch) 5789 if (spec->dual_adc_switch)
5749 num_adcs = 1; 5790 num_adcs = 1;
5750 else if (spec->auto_mic) 5791 else if (spec->auto_mic)
@@ -5755,70 +5796,52 @@ static void set_capture_mixer(struct hda_codec *codec)
5755 else if (spec->input_mux->num_items == 1) 5796 else if (spec->input_mux->num_items == 1)
5756 fixup_single_adc(codec); 5797 fixup_single_adc(codec);
5757 } 5798 }
5799 if (!num_adcs) {
5800 if (spec->num_adc_nids > 3)
5801 spec->num_adc_nids = 3;
5802 else if (!spec->num_adc_nids)
5803 return;
5804 num_adcs = spec->num_adc_nids;
5805 }
5758 spec->cap_mixer = caps[mux][num_adcs - 1]; 5806 spec->cap_mixer = caps[mux][num_adcs - 1];
5759 } 5807 }
5760} 5808}
5761 5809
5762/* fill adc_nids (and capsrc_nids) containing all active input pins */ 5810/* filter out invalid adc_nids (and capsrc_nids) that don't give all
5763static void fillup_priv_adc_nids(struct hda_codec *codec, const hda_nid_t *nids, 5811 * active input pins
5764 int num_nids) 5812 */
5813static void alc_remove_invalid_adc_nids(struct hda_codec *codec)
5765{ 5814{
5766 struct alc_spec *spec = codec->spec; 5815 struct alc_spec *spec = codec->spec;
5767 struct auto_pin_cfg *cfg = &spec->autocfg; 5816 struct auto_pin_cfg *cfg = &spec->autocfg;
5768 int n; 5817 hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)];
5769 hda_nid_t fallback_adc = 0, fallback_cap = 0; 5818 hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)];
5770 5819 int i, n, nums;
5771 for (n = 0; n < num_nids; n++) {
5772 hda_nid_t adc, cap;
5773 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5774 int nconns, i, j;
5775 5820
5776 adc = nids[n]; 5821 nums = 0;
5777 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN) 5822 for (n = 0; n < spec->num_adc_nids; n++) {
5778 continue; 5823 hda_nid_t cap = spec->private_capsrc_nids[n];
5779 cap = adc;
5780 nconns = snd_hda_get_connections(codec, cap, conn,
5781 ARRAY_SIZE(conn));
5782 if (nconns == 1) {
5783 cap = conn[0];
5784 nconns = snd_hda_get_connections(codec, cap, conn,
5785 ARRAY_SIZE(conn));
5786 }
5787 if (nconns <= 0)
5788 continue;
5789 if (!fallback_adc) {
5790 fallback_adc = adc;
5791 fallback_cap = cap;
5792 }
5793 for (i = 0; i < cfg->num_inputs; i++) { 5824 for (i = 0; i < cfg->num_inputs; i++) {
5794 hda_nid_t nid = cfg->inputs[i].pin; 5825 hda_nid_t pin = cfg->inputs[i].pin;
5795 for (j = 0; j < nconns; j++) { 5826 if (get_connection_index(codec, cap, pin) < 0)
5796 if (conn[j] == nid)
5797 break;
5798 }
5799 if (j >= nconns)
5800 break; 5827 break;
5801 } 5828 }
5802 if (i >= cfg->num_inputs) { 5829 if (i >= cfg->num_inputs) {
5803 int num_adcs = spec->num_adc_nids; 5830 adc_nids[nums] = spec->private_adc_nids[n];
5804 spec->private_adc_nids[num_adcs] = adc; 5831 capsrc_nids[nums++] = cap;
5805 spec->private_capsrc_nids[num_adcs] = cap;
5806 spec->num_adc_nids++;
5807 spec->adc_nids = spec->private_adc_nids;
5808 if (adc != cap)
5809 spec->capsrc_nids = spec->private_capsrc_nids;
5810 } 5832 }
5811 } 5833 }
5812 if (!spec->num_adc_nids) { 5834 if (!nums) {
5813 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" 5835 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
5814 " using fallback 0x%x\n", 5836 " using fallback 0x%x\n",
5815 codec->chip_name, fallback_adc); 5837 codec->chip_name, spec->private_adc_nids[0]);
5816 spec->private_adc_nids[0] = fallback_adc; 5838 spec->num_adc_nids = 1;
5817 spec->adc_nids = spec->private_adc_nids; 5839 } else if (nums != spec->num_adc_nids) {
5818 if (fallback_adc != fallback_cap) { 5840 memcpy(spec->private_adc_nids, adc_nids,
5819 spec->private_capsrc_nids[0] = fallback_cap; 5841 nums * sizeof(hda_nid_t));
5820 spec->capsrc_nids = spec->private_adc_nids; 5842 memcpy(spec->private_capsrc_nids, capsrc_nids,
5821 } 5843 nums * sizeof(hda_nid_t));
5844 spec->num_adc_nids = nums;
5822 } 5845 }
5823} 5846}
5824 5847
@@ -5907,17 +5930,8 @@ static int patch_alc880(struct hda_codec *codec)
5907 spec->stream_digital_capture = &alc880_pcm_digital_capture; 5930 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5908 5931
5909 if (!spec->adc_nids && spec->input_mux) { 5932 if (!spec->adc_nids && spec->input_mux) {
5910 /* check whether NID 0x07 is valid */ 5933 alc_auto_fill_adc_caps(codec);
5911 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]); 5934 alc_remove_invalid_adc_nids(codec);
5912 /* get type */
5913 wcap = get_wcaps_type(wcap);
5914 if (wcap != AC_WID_AUD_IN) {
5915 spec->adc_nids = alc880_adc_nids_alt;
5916 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
5917 } else {
5918 spec->adc_nids = alc880_adc_nids;
5919 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
5920 }
5921 } 5935 }
5922 set_capture_mixer(codec); 5936 set_capture_mixer(codec);
5923 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 5937 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
@@ -7173,6 +7187,9 @@ static int alc260_parse_auto_config(struct hda_codec *codec)
7173 spec->num_mux_defs = 1; 7187 spec->num_mux_defs = 1;
7174 spec->input_mux = &spec->private_imux[0]; 7188 spec->input_mux = &spec->private_imux[0];
7175 7189
7190 if (!spec->dual_adc_switch)
7191 alc_remove_invalid_adc_nids(codec);
7192
7176 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0); 7193 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
7177 7194
7178 return 1; 7195 return 1;
@@ -7463,17 +7480,8 @@ static int patch_alc260(struct hda_codec *codec)
7463 spec->stream_digital_capture = &alc260_pcm_digital_capture; 7480 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7464 7481
7465 if (!spec->adc_nids && spec->input_mux) { 7482 if (!spec->adc_nids && spec->input_mux) {
7466 /* check whether NID 0x04 is valid */ 7483 alc_auto_fill_adc_caps(codec);
7467 unsigned int wcap = get_wcaps(codec, 0x04); 7484 alc_remove_invalid_adc_nids(codec);
7468 wcap = get_wcaps_type(wcap);
7469 /* get type */
7470 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7471 spec->adc_nids = alc260_adc_nids_alt;
7472 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7473 } else {
7474 spec->adc_nids = alc260_adc_nids;
7475 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7476 }
7477 } 7485 }
7478 set_capture_mixer(codec); 7486 set_capture_mixer(codec);
7479 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); 7487 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
@@ -10947,6 +10955,9 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
10947 spec->num_mux_defs = 1; 10955 spec->num_mux_defs = 1;
10948 spec->input_mux = &spec->private_imux[0]; 10956 spec->input_mux = &spec->private_imux[0];
10949 10957
10958 if (!spec->dual_adc_switch)
10959 alc_remove_invalid_adc_nids(codec);
10960
10950 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0); 10961 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
10951 10962
10952 err = alc_auto_add_mic_boost(codec); 10963 err = alc_auto_add_mic_boost(codec);
@@ -11048,34 +11059,8 @@ static int patch_alc882(struct hda_codec *codec)
11048 spec->stream_digital_capture = &alc882_pcm_digital_capture; 11059 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11049 11060
11050 if (!spec->adc_nids && spec->input_mux) { 11061 if (!spec->adc_nids && spec->input_mux) {
11051 int i, j; 11062 alc_auto_fill_adc_caps(codec);
11052 spec->num_adc_nids = 0; 11063 alc_remove_invalid_adc_nids(codec);
11053 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
11054 const struct hda_input_mux *imux = spec->input_mux;
11055 hda_nid_t cap;
11056 hda_nid_t nid = alc882_adc_nids[i];
11057 unsigned int wcap = get_wcaps(codec, nid);
11058 /* get type */
11059 wcap = get_wcaps_type(wcap);
11060 if (wcap != AC_WID_AUD_IN)
11061 continue;
11062 spec->private_adc_nids[spec->num_adc_nids] = nid;
11063 err = snd_hda_get_connections(codec, nid, &cap, 1);
11064 if (err < 0)
11065 continue;
11066 err = snd_hda_get_conn_list(codec, cap, NULL);
11067 if (err < 0)
11068 continue;
11069 for (j = 0; j < imux->num_items; j++)
11070 if (imux->items[j].index >= err)
11071 break;
11072 if (j < imux->num_items)
11073 continue;
11074 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11075 spec->num_adc_nids++;
11076 }
11077 spec->adc_nids = spec->private_adc_nids;
11078 spec->capsrc_nids = spec->private_capsrc_nids;
11079 } 11064 }
11080 11065
11081 set_capture_mixer(codec); 11066 set_capture_mixer(codec);
@@ -12308,6 +12293,9 @@ static int alc262_parse_auto_config(struct hda_codec *codec)
12308 spec->num_mux_defs = 1; 12293 spec->num_mux_defs = 1;
12309 spec->input_mux = &spec->private_imux[0]; 12294 spec->input_mux = &spec->private_imux[0];
12310 12295
12296 if (!spec->dual_adc_switch)
12297 alc_remove_invalid_adc_nids(codec);
12298
12311 err = alc_auto_add_mic_boost(codec); 12299 err = alc_auto_add_mic_boost(codec);
12312 if (err < 0) 12300 if (err < 0)
12313 return err; 12301 return err;
@@ -12727,36 +12715,8 @@ static int patch_alc262(struct hda_codec *codec)
12727 spec->stream_digital_capture = &alc262_pcm_digital_capture; 12715 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12728 12716
12729 if (!spec->adc_nids && spec->input_mux) { 12717 if (!spec->adc_nids && spec->input_mux) {
12730 int i; 12718 alc_auto_fill_adc_caps(codec);
12731 /* check whether the digital-mic has to be supported */ 12719 alc_remove_invalid_adc_nids(codec);
12732 for (i = 0; i < spec->input_mux->num_items; i++) {
12733 if (spec->input_mux->items[i].index >= 9)
12734 break;
12735 }
12736 if (i < spec->input_mux->num_items) {
12737 /* use only ADC0 */
12738 spec->adc_nids = alc262_dmic_adc_nids;
12739 spec->num_adc_nids = 1;
12740 spec->capsrc_nids = alc262_dmic_capsrc_nids;
12741 } else {
12742 /* all analog inputs */
12743 /* check whether NID 0x07 is valid */
12744 unsigned int wcap = get_wcaps(codec, 0x07);
12745
12746 /* get type */
12747 wcap = get_wcaps_type(wcap);
12748 if (wcap != AC_WID_AUD_IN) {
12749 spec->adc_nids = alc262_adc_nids_alt;
12750 spec->num_adc_nids =
12751 ARRAY_SIZE(alc262_adc_nids_alt);
12752 spec->capsrc_nids = alc262_capsrc_nids_alt;
12753 } else {
12754 spec->adc_nids = alc262_adc_nids;
12755 spec->num_adc_nids =
12756 ARRAY_SIZE(alc262_adc_nids);
12757 spec->capsrc_nids = alc262_capsrc_nids;
12758 }
12759 }
12760 } 12720 }
12761 if (!spec->cap_mixer && !spec->no_analog) 12721 if (!spec->cap_mixer && !spec->no_analog)
12762 set_capture_mixer(codec); 12722 set_capture_mixer(codec);
@@ -13462,6 +13422,9 @@ static int alc268_parse_auto_config(struct hda_codec *codec)
13462 spec->num_mux_defs = 2; 13422 spec->num_mux_defs = 2;
13463 spec->input_mux = &spec->private_imux[0]; 13423 spec->input_mux = &spec->private_imux[0];
13464 13424
13425 if (!spec->dual_adc_switch)
13426 alc_remove_invalid_adc_nids(codec);
13427
13465 err = alc_auto_add_mic_boost(codec); 13428 err = alc_auto_add_mic_boost(codec);
13466 if (err < 0) 13429 if (err < 0)
13467 return err; 13430 return err;
@@ -13773,29 +13736,13 @@ static int patch_alc268(struct hda_codec *codec)
13773 } 13736 }
13774 13737
13775 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) { 13738 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
13776 /* check whether NID 0x07 is valid */ 13739 alc_auto_fill_adc_caps(codec);
13777 unsigned int wcap = get_wcaps(codec, 0x07); 13740 alc_remove_invalid_adc_nids(codec);
13778
13779 spec->capsrc_nids = alc268_capsrc_nids;
13780 /* get type */
13781 wcap = get_wcaps_type(wcap);
13782 if (spec->auto_mic ||
13783 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
13784 spec->adc_nids = alc268_adc_nids_alt;
13785 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
13786 if (spec->auto_mic)
13787 fixup_automic_adc(codec);
13788 if (spec->auto_mic || spec->input_mux->num_items == 1)
13789 add_mixer(spec, alc268_capture_nosrc_mixer);
13790 else
13791 add_mixer(spec, alc268_capture_alt_mixer);
13792 } else {
13793 spec->adc_nids = alc268_adc_nids;
13794 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
13795 add_mixer(spec, alc268_capture_mixer);
13796 }
13797 } 13741 }
13798 13742
13743 if (!spec->cap_mixer && !spec->no_analog)
13744 set_capture_mixer(codec);
13745
13799 spec->vmaster_nid = 0x02; 13746 spec->vmaster_nid = 0x02;
13800 13747
13801 codec->patch_ops = alc_patch_ops; 13748 codec->patch_ops = alc_patch_ops;
@@ -13833,10 +13780,6 @@ static const hda_nid_t alc269vb_capsrc_nids[1] = {
13833 0x22, 13780 0x22,
13834}; 13781};
13835 13782
13836static const hda_nid_t alc269_adc_candidates[] = {
13837 0x08, 0x09, 0x07, 0x11,
13838};
13839
13840#define alc269_modes alc260_modes 13783#define alc269_modes alc260_modes
13841#define alc269_capture_source alc880_lg_lw_capture_source 13784#define alc269_capture_source alc880_lg_lw_capture_source
13842 13785
@@ -14422,9 +14365,9 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
14422 spec->num_mux_defs = 1; 14365 spec->num_mux_defs = 1;
14423 spec->input_mux = &spec->private_imux[0]; 14366 spec->input_mux = &spec->private_imux[0];
14424 14367
14425 if (!alc275_setup_dual_adc(codec)) 14368 alc275_setup_dual_adc(codec);
14426 fillup_priv_adc_nids(codec, alc269_adc_candidates, 14369 if (!spec->dual_adc_switch)
14427 sizeof(alc269_adc_candidates)); 14370 alc_remove_invalid_adc_nids(codec);
14428 14371
14429 err = alc_auto_add_mic_boost(codec); 14372 err = alc_auto_add_mic_boost(codec);
14430 if (err < 0) 14373 if (err < 0)
@@ -14961,15 +14904,8 @@ static int patch_alc269(struct hda_codec *codec)
14961 spec->stream_digital_capture = &alc269_pcm_digital_capture; 14904 spec->stream_digital_capture = &alc269_pcm_digital_capture;
14962 14905
14963 if (!spec->adc_nids) { /* wasn't filled automatically? use default */ 14906 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
14964 if (spec->codec_variant == ALC269_TYPE_ALC269VA) { 14907 alc_auto_fill_adc_caps(codec);
14965 spec->adc_nids = alc269_adc_nids; 14908 alc_remove_invalid_adc_nids(codec);
14966 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
14967 spec->capsrc_nids = alc269_capsrc_nids;
14968 } else {
14969 spec->adc_nids = alc269vb_adc_nids;
14970 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
14971 spec->capsrc_nids = alc269vb_capsrc_nids;
14972 }
14973 } 14909 }
14974 14910
14975 if (!spec->cap_mixer) 14911 if (!spec->cap_mixer)
@@ -15776,12 +15712,13 @@ static int alc861_parse_auto_config(struct hda_codec *codec)
15776 spec->num_mux_defs = 1; 15712 spec->num_mux_defs = 1;
15777 spec->input_mux = &spec->private_imux[0]; 15713 spec->input_mux = &spec->private_imux[0];
15778 15714
15779 spec->adc_nids = alc861_adc_nids; 15715 if (!spec->dual_adc_switch)
15780 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); 15716 alc_remove_invalid_adc_nids(codec);
15781 set_capture_mixer(codec);
15782 15717
15783 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0); 15718 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
15784 15719
15720 set_capture_mixer(codec);
15721
15785 return 1; 15722 return 1;
15786} 15723}
15787 15724
@@ -16837,6 +16774,9 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec)
16837 spec->num_mux_defs = 1; 16774 spec->num_mux_defs = 1;
16838 spec->input_mux = &spec->private_imux[0]; 16775 spec->input_mux = &spec->private_imux[0];
16839 16776
16777 if (!spec->dual_adc_switch)
16778 alc_remove_invalid_adc_nids(codec);
16779
16840 err = alc_auto_add_mic_boost(codec); 16780 err = alc_auto_add_mic_boost(codec);
16841 if (err < 0) 16781 if (err < 0)
16842 return err; 16782 return err;
@@ -16944,11 +16884,9 @@ static int patch_alc861vd(struct hda_codec *codec)
16944 spec->stream_digital_capture = &alc861vd_pcm_digital_capture; 16884 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
16945 16885
16946 if (!spec->adc_nids) { 16886 if (!spec->adc_nids) {
16947 spec->adc_nids = alc861vd_adc_nids; 16887 alc_auto_fill_adc_caps(codec);
16948 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 16888 alc_remove_invalid_adc_nids(codec);
16949 } 16889 }
16950 if (!spec->capsrc_nids)
16951 spec->capsrc_nids = alc861vd_capsrc_nids;
16952 16890
16953 set_capture_mixer(codec); 16891 set_capture_mixer(codec);
16954 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 16892 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
@@ -18965,6 +18903,9 @@ static int alc662_parse_auto_config(struct hda_codec *codec)
18965 spec->num_mux_defs = 1; 18903 spec->num_mux_defs = 1;
18966 spec->input_mux = &spec->private_imux[0]; 18904 spec->input_mux = &spec->private_imux[0];
18967 18905
18906 if (!spec->dual_adc_switch)
18907 alc_remove_invalid_adc_nids(codec);
18908
18968 err = alc_auto_add_mic_boost(codec); 18909 err = alc_auto_add_mic_boost(codec);
18969 if (err < 0) 18910 if (err < 0)
18970 return err; 18911 return err;
@@ -19134,11 +19075,9 @@ static int patch_alc662(struct hda_codec *codec)
19134 spec->stream_digital_capture = &alc662_pcm_digital_capture; 19075 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19135 19076
19136 if (!spec->adc_nids) { 19077 if (!spec->adc_nids) {
19137 spec->adc_nids = alc662_adc_nids; 19078 alc_auto_fill_adc_caps(codec);
19138 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 19079 alc_remove_invalid_adc_nids(codec);
19139 } 19080 }
19140 if (!spec->capsrc_nids)
19141 spec->capsrc_nids = alc662_capsrc_nids;
19142 19081
19143 if (!spec->cap_mixer) 19082 if (!spec->cap_mixer)
19144 set_capture_mixer(codec); 19083 set_capture_mixer(codec);
@@ -19631,8 +19570,8 @@ static int patch_alc680(struct hda_codec *codec)
19631 spec->stream_digital_capture = &alc680_pcm_digital_capture; 19570 spec->stream_digital_capture = &alc680_pcm_digital_capture;
19632 19571
19633 if (!spec->adc_nids) { 19572 if (!spec->adc_nids) {
19634 spec->adc_nids = alc680_adc_nids; 19573 alc_auto_fill_adc_caps(codec);
19635 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids); 19574 alc_remove_invalid_adc_nids(codec);
19636 } 19575 }
19637 19576
19638 if (!spec->cap_mixer) 19577 if (!spec->cap_mixer)