diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-06-17 03:01:29 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-06-20 10:23:55 -0400 |
commit | a766d0d763bf9d64ff622db2c9c620d45a4ead96 (patch) | |
tree | 543f0de900c7ca2c44c7397d96b1e11d06fdb3ca /sound/pci/hda/patch_via.c | |
parent | 24088a58d694ca5acc31ba67f966f60385789235 (diff) |
ALSA: hda - Fill ADCs dynamically for VIA codecs
Instead of giving the fixed ADC list, parse the widgets and fill in
ADCs dynamically.
Also, probe the stereo-mixer input more dynamically, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_via.c')
-rw-r--r-- | sound/pci/hda/patch_via.c | 244 |
1 files changed, 80 insertions, 164 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 8a9791ab43c0..3a3df946661c 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -129,7 +129,7 @@ struct via_spec { | |||
129 | 129 | ||
130 | /* capture */ | 130 | /* capture */ |
131 | unsigned int num_adc_nids; | 131 | unsigned int num_adc_nids; |
132 | const hda_nid_t *adc_nids; | 132 | hda_nid_t adc_nids[3]; |
133 | hda_nid_t mux_nids[3]; | 133 | hda_nid_t mux_nids[3]; |
134 | hda_nid_t dig_in_nid; | 134 | hda_nid_t dig_in_nid; |
135 | hda_nid_t dig_in_pin; | 135 | hda_nid_t dig_in_pin; |
@@ -418,51 +418,6 @@ static const struct snd_kcontrol_new via_control_templates[] = { | |||
418 | BIND_PIN_MUTE, | 418 | BIND_PIN_MUTE, |
419 | }; | 419 | }; |
420 | 420 | ||
421 | static const hda_nid_t vt1708_adc_nids[2] = { | ||
422 | /* ADC1-2 */ | ||
423 | 0x15, 0x27 | ||
424 | }; | ||
425 | |||
426 | static const hda_nid_t vt1709_adc_nids[3] = { | ||
427 | /* ADC1-2 */ | ||
428 | 0x14, 0x15, 0x16 | ||
429 | }; | ||
430 | |||
431 | static const hda_nid_t vt1708B_adc_nids[2] = { | ||
432 | /* ADC1-2 */ | ||
433 | 0x13, 0x14 | ||
434 | }; | ||
435 | |||
436 | static const hda_nid_t vt1708S_adc_nids[2] = { | ||
437 | /* ADC1-2 */ | ||
438 | 0x13, 0x14 | ||
439 | }; | ||
440 | |||
441 | static const hda_nid_t vt1702_adc_nids[3] = { | ||
442 | /* ADC1-2 */ | ||
443 | 0x12, 0x20, 0x1F | ||
444 | }; | ||
445 | |||
446 | static const hda_nid_t vt1718S_adc_nids[2] = { | ||
447 | /* ADC1-2 */ | ||
448 | 0x10, 0x11 | ||
449 | }; | ||
450 | |||
451 | static const hda_nid_t vt1716S_adc_nids[2] = { | ||
452 | /* ADC1-2 */ | ||
453 | 0x13, 0x14 | ||
454 | }; | ||
455 | |||
456 | static const hda_nid_t vt2002P_adc_nids[2] = { | ||
457 | /* ADC1-2 */ | ||
458 | 0x10, 0x11 | ||
459 | }; | ||
460 | |||
461 | static const hda_nid_t vt1812_adc_nids[2] = { | ||
462 | /* ADC1-2 */ | ||
463 | 0x10, 0x11 | ||
464 | }; | ||
465 | |||
466 | 421 | ||
467 | /* add dynamic controls */ | 422 | /* add dynamic controls */ |
468 | static int __via_add_control(struct via_spec *spec, int type, const char *name, | 423 | static int __via_add_control(struct via_spec *spec, int type, const char *name, |
@@ -2050,20 +2005,71 @@ static int vt1708_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
2050 | return 0; | 2005 | return 0; |
2051 | } | 2006 | } |
2052 | 2007 | ||
2008 | static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, | ||
2009 | hda_nid_t nid) | ||
2010 | { | ||
2011 | hda_nid_t conn[HDA_MAX_NUM_INPUTS]; | ||
2012 | int i, nums; | ||
2013 | |||
2014 | nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn)); | ||
2015 | for (i = 0; i < nums; i++) | ||
2016 | if (conn[i] == nid) | ||
2017 | return i; | ||
2018 | return -1; | ||
2019 | } | ||
2020 | |||
2021 | /* look for ADCs */ | ||
2022 | static int via_fill_adcs(struct hda_codec *codec) | ||
2023 | { | ||
2024 | struct via_spec *spec = codec->spec; | ||
2025 | hda_nid_t nid = codec->start_nid; | ||
2026 | int i; | ||
2027 | |||
2028 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
2029 | unsigned int wcaps = get_wcaps(codec, nid); | ||
2030 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) | ||
2031 | continue; | ||
2032 | if (wcaps & AC_WCAP_DIGITAL) | ||
2033 | continue; | ||
2034 | if (!(wcaps & AC_WCAP_CONN_LIST)) | ||
2035 | continue; | ||
2036 | if (spec->num_adc_nids >= ARRAY_SIZE(spec->adc_nids)) | ||
2037 | return -ENOMEM; | ||
2038 | spec->adc_nids[spec->num_adc_nids++] = nid; | ||
2039 | } | ||
2040 | return 0; | ||
2041 | } | ||
2042 | |||
2043 | static int get_mux_nids(struct hda_codec *codec); | ||
2044 | |||
2053 | /* create playback/capture controls for input pins */ | 2045 | /* create playback/capture controls for input pins */ |
2054 | static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, | 2046 | static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, |
2055 | const struct auto_pin_cfg *cfg, | 2047 | const struct auto_pin_cfg *cfg, |
2056 | hda_nid_t cap_nid, | 2048 | hda_nid_t mix_nid) |
2057 | const hda_nid_t pin_idxs[], | ||
2058 | int num_idxs) | ||
2059 | { | 2049 | { |
2060 | struct via_spec *spec = codec->spec; | 2050 | struct via_spec *spec = codec->spec; |
2061 | struct hda_input_mux *imux = &spec->private_imux[0]; | 2051 | struct hda_input_mux *imux = &spec->private_imux[0]; |
2062 | int i, err, idx, type, type_idx = 0; | 2052 | int i, err, idx, idx2, type, type_idx = 0; |
2053 | hda_nid_t cap_nid; | ||
2054 | hda_nid_t pin_idxs[8]; | ||
2055 | int num_idxs; | ||
2056 | |||
2057 | err = via_fill_adcs(codec); | ||
2058 | if (err < 0) | ||
2059 | return err; | ||
2060 | err = get_mux_nids(codec); | ||
2061 | if (err < 0) | ||
2062 | return err; | ||
2063 | cap_nid = spec->mux_nids[0]; | ||
2064 | |||
2065 | num_idxs = snd_hda_get_connections(codec, cap_nid, pin_idxs, | ||
2066 | ARRAY_SIZE(pin_idxs)); | ||
2067 | if (num_idxs <= 0) | ||
2068 | return 0; | ||
2063 | 2069 | ||
2064 | /* for internal loopback recording select */ | 2070 | /* for internal loopback recording select */ |
2065 | for (idx = 0; idx < num_idxs; idx++) { | 2071 | for (idx = 0; idx < num_idxs; idx++) { |
2066 | if (pin_idxs[idx] == 0xff) { | 2072 | if (pin_idxs[idx] == mix_nid) { |
2067 | snd_hda_add_imux_item(imux, "Stereo Mixer", idx, NULL); | 2073 | snd_hda_add_imux_item(imux, "Stereo Mixer", idx, NULL); |
2068 | break; | 2074 | break; |
2069 | } | 2075 | } |
@@ -2082,14 +2088,10 @@ static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, | |||
2082 | else | 2088 | else |
2083 | type_idx = 0; | 2089 | type_idx = 0; |
2084 | label = hda_get_autocfg_input_label(codec, cfg, i); | 2090 | label = hda_get_autocfg_input_label(codec, cfg, i); |
2085 | if (spec->codec_type == VT1708S || | 2091 | idx2 = get_connection_index(codec, mix_nid, pin_idxs[idx]); |
2086 | spec->codec_type == VT1702 || | 2092 | if (idx2 >= 0) |
2087 | spec->codec_type == VT1716S) | ||
2088 | err = via_new_analog_input(spec, label, type_idx, | ||
2089 | idx+1, cap_nid); | ||
2090 | else | ||
2091 | err = via_new_analog_input(spec, label, type_idx, | 2093 | err = via_new_analog_input(spec, label, type_idx, |
2092 | idx, cap_nid); | 2094 | idx2, mix_nid); |
2093 | if (err < 0) | 2095 | if (err < 0) |
2094 | return err; | 2096 | return err; |
2095 | snd_hda_add_imux_item(imux, label, idx, NULL); | 2097 | snd_hda_add_imux_item(imux, label, idx, NULL); |
@@ -2101,9 +2103,7 @@ static int vt_auto_create_analog_input_ctls(struct hda_codec *codec, | |||
2101 | static int vt1708_auto_create_analog_input_ctls(struct hda_codec *codec, | 2103 | static int vt1708_auto_create_analog_input_ctls(struct hda_codec *codec, |
2102 | const struct auto_pin_cfg *cfg) | 2104 | const struct auto_pin_cfg *cfg) |
2103 | { | 2105 | { |
2104 | static const hda_nid_t pin_idxs[] = { 0xff, 0x24, 0x1d, 0x1e, 0x21 }; | 2106 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x17); |
2105 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x17, pin_idxs, | ||
2106 | ARRAY_SIZE(pin_idxs)); | ||
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 2109 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
@@ -2326,11 +2326,7 @@ static int patch_vt1708(struct hda_codec *codec) | |||
2326 | spec->stream_digital_playback = &vt1708_pcm_digital_playback; | 2326 | spec->stream_digital_playback = &vt1708_pcm_digital_playback; |
2327 | spec->stream_digital_capture = &vt1708_pcm_digital_capture; | 2327 | spec->stream_digital_capture = &vt1708_pcm_digital_capture; |
2328 | 2328 | ||
2329 | 2329 | if (spec->adc_nids && spec->input_mux) { | |
2330 | if (!spec->adc_nids && spec->input_mux) { | ||
2331 | spec->adc_nids = vt1708_adc_nids; | ||
2332 | spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); | ||
2333 | get_mux_nids(codec); | ||
2334 | spec->mixers[spec->num_mixers] = vt1708_capture_mixer; | 2330 | spec->mixers[spec->num_mixers] = vt1708_capture_mixer; |
2335 | spec->num_mixers++; | 2331 | spec->num_mixers++; |
2336 | } | 2332 | } |
@@ -2675,9 +2671,7 @@ static int vt1709_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
2675 | static int vt1709_auto_create_analog_input_ctls(struct hda_codec *codec, | 2671 | static int vt1709_auto_create_analog_input_ctls(struct hda_codec *codec, |
2676 | const struct auto_pin_cfg *cfg) | 2672 | const struct auto_pin_cfg *cfg) |
2677 | { | 2673 | { |
2678 | static const hda_nid_t pin_idxs[] = { 0xff, 0x23, 0x1d, 0x1e, 0x21 }; | 2674 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x18); |
2679 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x18, pin_idxs, | ||
2680 | ARRAY_SIZE(pin_idxs)); | ||
2681 | } | 2675 | } |
2682 | 2676 | ||
2683 | static int vt1709_parse_auto_config(struct hda_codec *codec) | 2677 | static int vt1709_parse_auto_config(struct hda_codec *codec) |
@@ -2764,11 +2758,7 @@ static int patch_vt1709_10ch(struct hda_codec *codec) | |||
2764 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; | 2758 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; |
2765 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; | 2759 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; |
2766 | 2760 | ||
2767 | 2761 | if (spec->adc_nids && spec->input_mux) { | |
2768 | if (!spec->adc_nids && spec->input_mux) { | ||
2769 | spec->adc_nids = vt1709_adc_nids; | ||
2770 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); | ||
2771 | get_mux_nids(codec); | ||
2772 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; | 2762 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; |
2773 | spec->num_mixers++; | 2763 | spec->num_mixers++; |
2774 | } | 2764 | } |
@@ -2856,11 +2846,7 @@ static int patch_vt1709_6ch(struct hda_codec *codec) | |||
2856 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; | 2846 | spec->stream_digital_playback = &vt1709_pcm_digital_playback; |
2857 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; | 2847 | spec->stream_digital_capture = &vt1709_pcm_digital_capture; |
2858 | 2848 | ||
2859 | 2849 | if (spec->adc_nids && spec->input_mux) { | |
2860 | if (!spec->adc_nids && spec->input_mux) { | ||
2861 | spec->adc_nids = vt1709_adc_nids; | ||
2862 | spec->num_adc_nids = ARRAY_SIZE(vt1709_adc_nids); | ||
2863 | get_mux_nids(codec); | ||
2864 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; | 2850 | spec->mixers[spec->num_mixers] = vt1709_capture_mixer; |
2865 | spec->num_mixers++; | 2851 | spec->num_mixers++; |
2866 | } | 2852 | } |
@@ -3207,9 +3193,7 @@ static int vt1708B_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
3207 | static int vt1708B_auto_create_analog_input_ctls(struct hda_codec *codec, | 3193 | static int vt1708B_auto_create_analog_input_ctls(struct hda_codec *codec, |
3208 | const struct auto_pin_cfg *cfg) | 3194 | const struct auto_pin_cfg *cfg) |
3209 | { | 3195 | { |
3210 | static const hda_nid_t pin_idxs[] = { 0xff, 0x1f, 0x1a, 0x1b, 0x1e }; | 3196 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x16); |
3211 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, | ||
3212 | ARRAY_SIZE(pin_idxs)); | ||
3213 | } | 3197 | } |
3214 | 3198 | ||
3215 | static int vt1708B_parse_auto_config(struct hda_codec *codec) | 3199 | static int vt1708B_parse_auto_config(struct hda_codec *codec) |
@@ -3380,10 +3364,7 @@ static int patch_vt1708B_8ch(struct hda_codec *codec) | |||
3380 | spec->stream_digital_playback = &vt1708B_pcm_digital_playback; | 3364 | spec->stream_digital_playback = &vt1708B_pcm_digital_playback; |
3381 | spec->stream_digital_capture = &vt1708B_pcm_digital_capture; | 3365 | spec->stream_digital_capture = &vt1708B_pcm_digital_capture; |
3382 | 3366 | ||
3383 | if (!spec->adc_nids && spec->input_mux) { | 3367 | if (spec->adc_nids && spec->input_mux) { |
3384 | spec->adc_nids = vt1708B_adc_nids; | ||
3385 | spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); | ||
3386 | get_mux_nids(codec); | ||
3387 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; | 3368 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; |
3388 | spec->num_mixers++; | 3369 | spec->num_mixers++; |
3389 | } | 3370 | } |
@@ -3432,10 +3413,7 @@ static int patch_vt1708B_4ch(struct hda_codec *codec) | |||
3432 | spec->stream_digital_playback = &vt1708B_pcm_digital_playback; | 3413 | spec->stream_digital_playback = &vt1708B_pcm_digital_playback; |
3433 | spec->stream_digital_capture = &vt1708B_pcm_digital_capture; | 3414 | spec->stream_digital_capture = &vt1708B_pcm_digital_capture; |
3434 | 3415 | ||
3435 | if (!spec->adc_nids && spec->input_mux) { | 3416 | if (spec->adc_nids && spec->input_mux) { |
3436 | spec->adc_nids = vt1708B_adc_nids; | ||
3437 | spec->num_adc_nids = ARRAY_SIZE(vt1708B_adc_nids); | ||
3438 | get_mux_nids(codec); | ||
3439 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; | 3417 | spec->mixers[spec->num_mixers] = vt1708B_capture_mixer; |
3440 | spec->num_mixers++; | 3418 | spec->num_mixers++; |
3441 | } | 3419 | } |
@@ -3771,9 +3749,7 @@ static int vt1708S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
3771 | static int vt1708S_auto_create_analog_input_ctls(struct hda_codec *codec, | 3749 | static int vt1708S_auto_create_analog_input_ctls(struct hda_codec *codec, |
3772 | const struct auto_pin_cfg *cfg) | 3750 | const struct auto_pin_cfg *cfg) |
3773 | { | 3751 | { |
3774 | static const hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; | 3752 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x16); |
3775 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, | ||
3776 | ARRAY_SIZE(pin_idxs)); | ||
3777 | } | 3753 | } |
3778 | 3754 | ||
3779 | /* fill out digital output widgets; one for master and one for slave outputs */ | 3755 | /* fill out digital output widgets; one for master and one for slave outputs */ |
@@ -3909,10 +3885,7 @@ static int patch_vt1708S(struct hda_codec *codec) | |||
3909 | spec->stream_name_digital = "VT1708S Digital"; | 3885 | spec->stream_name_digital = "VT1708S Digital"; |
3910 | spec->stream_digital_playback = &vt1708S_pcm_digital_playback; | 3886 | spec->stream_digital_playback = &vt1708S_pcm_digital_playback; |
3911 | 3887 | ||
3912 | if (!spec->adc_nids && spec->input_mux) { | 3888 | if (spec->adc_nids && spec->input_mux) { |
3913 | spec->adc_nids = vt1708S_adc_nids; | ||
3914 | spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); | ||
3915 | get_mux_nids(codec); | ||
3916 | override_mic_boost(codec, 0x1a, 0, 3, 40); | 3889 | override_mic_boost(codec, 0x1a, 0, 3, 40); |
3917 | override_mic_boost(codec, 0x1e, 0, 3, 40); | 3890 | override_mic_boost(codec, 0x1e, 0, 3, 40); |
3918 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; | 3891 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; |
@@ -4148,9 +4121,7 @@ static int vt1702_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
4148 | static int vt1702_auto_create_analog_input_ctls(struct hda_codec *codec, | 4121 | static int vt1702_auto_create_analog_input_ctls(struct hda_codec *codec, |
4149 | const struct auto_pin_cfg *cfg) | 4122 | const struct auto_pin_cfg *cfg) |
4150 | { | 4123 | { |
4151 | static const hda_nid_t pin_idxs[] = { 0x14, 0x15, 0x18, 0xff }; | 4124 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x1a); |
4152 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x1a, pin_idxs, | ||
4153 | ARRAY_SIZE(pin_idxs)); | ||
4154 | } | 4125 | } |
4155 | 4126 | ||
4156 | static int vt1702_parse_auto_config(struct hda_codec *codec) | 4127 | static int vt1702_parse_auto_config(struct hda_codec *codec) |
@@ -4269,10 +4240,7 @@ static int patch_vt1702(struct hda_codec *codec) | |||
4269 | spec->stream_name_digital = "VT1702 Digital"; | 4240 | spec->stream_name_digital = "VT1702 Digital"; |
4270 | spec->stream_digital_playback = &vt1702_pcm_digital_playback; | 4241 | spec->stream_digital_playback = &vt1702_pcm_digital_playback; |
4271 | 4242 | ||
4272 | if (!spec->adc_nids && spec->input_mux) { | 4243 | if (spec->adc_nids && spec->input_mux) { |
4273 | spec->adc_nids = vt1702_adc_nids; | ||
4274 | spec->num_adc_nids = ARRAY_SIZE(vt1702_adc_nids); | ||
4275 | get_mux_nids(codec); | ||
4276 | spec->mixers[spec->num_mixers] = vt1702_capture_mixer; | 4244 | spec->mixers[spec->num_mixers] = vt1702_capture_mixer; |
4277 | spec->num_mixers++; | 4245 | spec->num_mixers++; |
4278 | } | 4246 | } |
@@ -4568,9 +4536,7 @@ static int vt1718S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
4568 | static int vt1718S_auto_create_analog_input_ctls(struct hda_codec *codec, | 4536 | static int vt1718S_auto_create_analog_input_ctls(struct hda_codec *codec, |
4569 | const struct auto_pin_cfg *cfg) | 4537 | const struct auto_pin_cfg *cfg) |
4570 | { | 4538 | { |
4571 | static const hda_nid_t pin_idxs[] = { 0x2c, 0x2b, 0x2a, 0x29, 0, 0xff }; | 4539 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x21); |
4572 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, | ||
4573 | ARRAY_SIZE(pin_idxs)); | ||
4574 | } | 4540 | } |
4575 | 4541 | ||
4576 | static int vt1718S_parse_auto_config(struct hda_codec *codec) | 4542 | static int vt1718S_parse_auto_config(struct hda_codec *codec) |
@@ -4736,10 +4702,7 @@ static int patch_vt1718S(struct hda_codec *codec) | |||
4736 | if (codec->vendor_id == 0x11060428 || codec->vendor_id == 0x11060441) | 4702 | if (codec->vendor_id == 0x11060428 || codec->vendor_id == 0x11060441) |
4737 | spec->stream_digital_capture = &vt1718S_pcm_digital_capture; | 4703 | spec->stream_digital_capture = &vt1718S_pcm_digital_capture; |
4738 | 4704 | ||
4739 | if (!spec->adc_nids && spec->input_mux) { | 4705 | if (spec->adc_nids && spec->input_mux) { |
4740 | spec->adc_nids = vt1718S_adc_nids; | ||
4741 | spec->num_adc_nids = ARRAY_SIZE(vt1718S_adc_nids); | ||
4742 | get_mux_nids(codec); | ||
4743 | override_mic_boost(codec, 0x2b, 0, 3, 40); | 4706 | override_mic_boost(codec, 0x2b, 0, 3, 40); |
4744 | override_mic_boost(codec, 0x29, 0, 3, 40); | 4707 | override_mic_boost(codec, 0x29, 0, 3, 40); |
4745 | spec->mixers[spec->num_mixers] = vt1718S_capture_mixer; | 4708 | spec->mixers[spec->num_mixers] = vt1718S_capture_mixer; |
@@ -5099,9 +5062,7 @@ static int vt1716S_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
5099 | static int vt1716S_auto_create_analog_input_ctls(struct hda_codec *codec, | 5062 | static int vt1716S_auto_create_analog_input_ctls(struct hda_codec *codec, |
5100 | const struct auto_pin_cfg *cfg) | 5063 | const struct auto_pin_cfg *cfg) |
5101 | { | 5064 | { |
5102 | static const hda_nid_t pin_idxs[] = { 0x1f, 0x1a, 0x1b, 0x1e, 0, 0xff }; | 5065 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x16); |
5103 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x16, pin_idxs, | ||
5104 | ARRAY_SIZE(pin_idxs)); | ||
5105 | } | 5066 | } |
5106 | 5067 | ||
5107 | static int vt1716S_parse_auto_config(struct hda_codec *codec) | 5068 | static int vt1716S_parse_auto_config(struct hda_codec *codec) |
@@ -5278,10 +5239,7 @@ static int patch_vt1716S(struct hda_codec *codec) | |||
5278 | spec->stream_name_digital = "VT1716S Digital"; | 5239 | spec->stream_name_digital = "VT1716S Digital"; |
5279 | spec->stream_digital_playback = &vt1716S_pcm_digital_playback; | 5240 | spec->stream_digital_playback = &vt1716S_pcm_digital_playback; |
5280 | 5241 | ||
5281 | if (!spec->adc_nids && spec->input_mux) { | 5242 | if (spec->adc_nids && spec->input_mux) { |
5282 | spec->adc_nids = vt1716S_adc_nids; | ||
5283 | spec->num_adc_nids = ARRAY_SIZE(vt1716S_adc_nids); | ||
5284 | get_mux_nids(codec); | ||
5285 | override_mic_boost(codec, 0x1a, 0, 3, 40); | 5243 | override_mic_boost(codec, 0x1a, 0, 3, 40); |
5286 | override_mic_boost(codec, 0x1e, 0, 3, 40); | 5244 | override_mic_boost(codec, 0x1e, 0, 3, 40); |
5287 | spec->mixers[spec->num_mixers] = vt1716S_capture_mixer; | 5245 | spec->mixers[spec->num_mixers] = vt1716S_capture_mixer; |
@@ -5572,24 +5530,7 @@ static int vt2002P_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
5572 | static int vt2002P_auto_create_analog_input_ctls(struct hda_codec *codec, | 5530 | static int vt2002P_auto_create_analog_input_ctls(struct hda_codec *codec, |
5573 | const struct auto_pin_cfg *cfg) | 5531 | const struct auto_pin_cfg *cfg) |
5574 | { | 5532 | { |
5575 | struct via_spec *spec = codec->spec; | 5533 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x21); |
5576 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
5577 | static const hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0xff }; | ||
5578 | int err; | ||
5579 | |||
5580 | err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, | ||
5581 | ARRAY_SIZE(pin_idxs)); | ||
5582 | if (err < 0) | ||
5583 | return err; | ||
5584 | /* build volume/mute control of loopback */ | ||
5585 | err = via_new_analog_input(spec, "Stereo Mixer", 0, 3, 0x21); | ||
5586 | if (err < 0) | ||
5587 | return err; | ||
5588 | |||
5589 | /* for digital mic select */ | ||
5590 | snd_hda_add_imux_item(imux, "Digital Mic", 4, NULL); | ||
5591 | |||
5592 | return 0; | ||
5593 | } | 5534 | } |
5594 | 5535 | ||
5595 | static int vt2002P_parse_auto_config(struct hda_codec *codec) | 5536 | static int vt2002P_parse_auto_config(struct hda_codec *codec) |
@@ -5802,10 +5743,7 @@ static int patch_vt2002P(struct hda_codec *codec) | |||
5802 | spec->stream_name_digital = "VT2002P Digital"; | 5743 | spec->stream_name_digital = "VT2002P Digital"; |
5803 | spec->stream_digital_playback = &vt2002P_pcm_digital_playback; | 5744 | spec->stream_digital_playback = &vt2002P_pcm_digital_playback; |
5804 | 5745 | ||
5805 | if (!spec->adc_nids && spec->input_mux) { | 5746 | if (spec->adc_nids && spec->input_mux) { |
5806 | spec->adc_nids = vt2002P_adc_nids; | ||
5807 | spec->num_adc_nids = ARRAY_SIZE(vt2002P_adc_nids); | ||
5808 | get_mux_nids(codec); | ||
5809 | override_mic_boost(codec, 0x2b, 0, 3, 40); | 5747 | override_mic_boost(codec, 0x2b, 0, 3, 40); |
5810 | override_mic_boost(codec, 0x29, 0, 3, 40); | 5748 | override_mic_boost(codec, 0x29, 0, 3, 40); |
5811 | spec->mixers[spec->num_mixers] = vt2002P_capture_mixer; | 5749 | spec->mixers[spec->num_mixers] = vt2002P_capture_mixer; |
@@ -6021,25 +5959,7 @@ static int vt1812_auto_create_hp_ctls(struct via_spec *spec, hda_nid_t pin) | |||
6021 | static int vt1812_auto_create_analog_input_ctls(struct hda_codec *codec, | 5959 | static int vt1812_auto_create_analog_input_ctls(struct hda_codec *codec, |
6022 | const struct auto_pin_cfg *cfg) | 5960 | const struct auto_pin_cfg *cfg) |
6023 | { | 5961 | { |
6024 | struct via_spec *spec = codec->spec; | 5962 | return vt_auto_create_analog_input_ctls(codec, cfg, 0x21); |
6025 | struct hda_input_mux *imux = &spec->private_imux[0]; | ||
6026 | static const hda_nid_t pin_idxs[] = { 0x2b, 0x2a, 0x29, 0, 0, 0xff }; | ||
6027 | int err; | ||
6028 | |||
6029 | err = vt_auto_create_analog_input_ctls(codec, cfg, 0x21, pin_idxs, | ||
6030 | ARRAY_SIZE(pin_idxs)); | ||
6031 | if (err < 0) | ||
6032 | return err; | ||
6033 | |||
6034 | /* build volume/mute control of loopback */ | ||
6035 | err = via_new_analog_input(spec, "Stereo Mixer", 0, 5, 0x21); | ||
6036 | if (err < 0) | ||
6037 | return err; | ||
6038 | |||
6039 | /* for digital mic select */ | ||
6040 | snd_hda_add_imux_item(imux, "Digital Mic", 6, NULL); | ||
6041 | |||
6042 | return 0; | ||
6043 | } | 5963 | } |
6044 | 5964 | ||
6045 | static int vt1812_parse_auto_config(struct hda_codec *codec) | 5965 | static int vt1812_parse_auto_config(struct hda_codec *codec) |
@@ -6217,11 +6137,7 @@ static int patch_vt1812(struct hda_codec *codec) | |||
6217 | spec->stream_name_digital = "VT1812 Digital"; | 6137 | spec->stream_name_digital = "VT1812 Digital"; |
6218 | spec->stream_digital_playback = &vt1812_pcm_digital_playback; | 6138 | spec->stream_digital_playback = &vt1812_pcm_digital_playback; |
6219 | 6139 | ||
6220 | 6140 | if (spec->adc_nids && spec->input_mux) { | |
6221 | if (!spec->adc_nids && spec->input_mux) { | ||
6222 | spec->adc_nids = vt1812_adc_nids; | ||
6223 | spec->num_adc_nids = ARRAY_SIZE(vt1812_adc_nids); | ||
6224 | get_mux_nids(codec); | ||
6225 | override_mic_boost(codec, 0x2b, 0, 3, 40); | 6141 | override_mic_boost(codec, 0x2b, 0, 3, 40); |
6226 | override_mic_boost(codec, 0x29, 0, 3, 40); | 6142 | override_mic_boost(codec, 0x29, 0, 3, 40); |
6227 | spec->mixers[spec->num_mixers] = vt1812_capture_mixer; | 6143 | spec->mixers[spec->num_mixers] = vt1812_capture_mixer; |