ALSA: hda - Fix capture source widgets on ALC codecs

On some Realtek codecs like ALC882 or ALC883, the capture source is
no mux but sum widget. We have to initialize all channels properly
for this type, otherwise noises may come in from the unused route.

The patch assures to mute unused routes, and unmute the currently
selected route.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Daniel J Blueman <daniel.blueman@gmail.com>

+45
+45
sound/pci/hda/patch_realtek.c
··· 6437 6437 } 6438 6438 } 6439 6439 6440 + static void alc882_auto_init_input_src(struct hda_codec *codec) 6441 + { 6442 + struct alc_spec *spec = codec->spec; 6443 + const struct hda_input_mux *imux = spec->input_mux; 6444 + int c; 6445 + 6446 + for (c = 0; c < spec->num_adc_nids; c++) { 6447 + hda_nid_t conn_list[HDA_MAX_NUM_INPUTS]; 6448 + hda_nid_t nid = spec->capsrc_nids[c]; 6449 + int conns, mute, idx, item; 6450 + 6451 + conns = snd_hda_get_connections(codec, nid, conn_list, 6452 + ARRAY_SIZE(conn_list)); 6453 + if (conns < 0) 6454 + continue; 6455 + for (idx = 0; idx < conns; idx++) { 6456 + /* if the current connection is the selected one, 6457 + * unmute it as default - otherwise mute it 6458 + */ 6459 + mute = AMP_IN_MUTE(idx); 6460 + for (item = 0; item < imux->num_items; item++) { 6461 + if (imux->items[item].index == idx) { 6462 + if (spec->cur_mux[c] == item) 6463 + mute = AMP_IN_UNMUTE(idx); 6464 + break; 6465 + } 6466 + } 6467 + snd_hda_codec_write(codec, nid, 0, 6468 + AC_VERB_SET_AMP_GAIN_MUTE, mute); 6469 + } 6470 + } 6471 + } 6472 + 6440 6473 /* add mic boosts if needed */ 6441 6474 static int alc_auto_add_mic_boost(struct hda_codec *codec) 6442 6475 { ··· 6524 6491 alc882_auto_init_multi_out(codec); 6525 6492 alc882_auto_init_hp_out(codec); 6526 6493 alc882_auto_init_analog_input(codec); 6494 + alc882_auto_init_input_src(codec); 6527 6495 if (spec->unsol_event) 6528 6496 alc_sku_automute(codec); 6529 6497 } ··· 8319 8285 } 8320 8286 } 8321 8287 8288 + #define alc883_auto_init_input_src alc882_auto_init_input_src 8289 + 8322 8290 /* almost identical with ALC880 parser... */ 8323 8291 static int alc883_parse_auto_config(struct hda_codec *codec) 8324 8292 { ··· 8351 8315 alc883_auto_init_multi_out(codec); 8352 8316 alc883_auto_init_hp_out(codec); 8353 8317 alc883_auto_init_analog_input(codec); 8318 + alc883_auto_init_input_src(codec); 8354 8319 if (spec->unsol_event) 8355 8320 alc_sku_automute(codec); 8356 8321 } ··· 9700 9663 #define alc262_auto_init_multi_out alc882_auto_init_multi_out 9701 9664 #define alc262_auto_init_hp_out alc882_auto_init_hp_out 9702 9665 #define alc262_auto_init_analog_input alc882_auto_init_analog_input 9666 + #define alc262_auto_init_input_src alc882_auto_init_input_src 9703 9667 9704 9668 9705 9669 /* init callback for auto-configuration model -- overriding the default init */ ··· 9710 9672 alc262_auto_init_multi_out(codec); 9711 9673 alc262_auto_init_hp_out(codec); 9712 9674 alc262_auto_init_analog_input(codec); 9675 + alc262_auto_init_input_src(codec); 9713 9676 if (spec->unsol_event) 9714 9677 alc_sku_automute(codec); 9715 9678 } ··· 13369 13330 } 13370 13331 } 13371 13332 13333 + #define alc861vd_auto_init_input_src alc882_auto_init_input_src 13334 + 13372 13335 #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02) 13373 13336 #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c) 13374 13337 ··· 13553 13512 alc861vd_auto_init_multi_out(codec); 13554 13513 alc861vd_auto_init_hp_out(codec); 13555 13514 alc861vd_auto_init_analog_input(codec); 13515 + alc861vd_auto_init_input_src(codec); 13556 13516 if (spec->unsol_event) 13557 13517 alc_sku_automute(codec); 13558 13518 } ··· 14719 14677 } 14720 14678 } 14721 14679 14680 + #define alc662_auto_init_input_src alc882_auto_init_input_src 14681 + 14722 14682 static int alc662_parse_auto_config(struct hda_codec *codec) 14723 14683 { 14724 14684 struct alc_spec *spec = codec->spec; ··· 14777 14733 alc662_auto_init_multi_out(codec); 14778 14734 alc662_auto_init_hp_out(codec); 14779 14735 alc662_auto_init_analog_input(codec); 14736 + alc662_auto_init_input_src(codec); 14780 14737 if (spec->unsol_event) 14781 14738 alc_sku_automute(codec); 14782 14739 }