ALSA: hda/realtek - Add missing initialization of multi-io routes

The paths used for multi-io haven't been initialized properly, so
far.  It's usually no big matter because the pins are set to input as
default, but it's still cleaner to initialize the paths properly.

Now with the path active/inactive check, we can do it easily.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b6b929e..74251b9 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3952,9 +3952,6 @@
 {
 	int i;
 
-	if (path->active == enable)
-		return;
-
 	if (!enable)
 		path->active = false;
 
@@ -3984,6 +3981,8 @@
 	path = get_nid_path(codec, dac, pin);
 	if (!path)
 		return;
+	if (path->active)
+		return;
 	activate_path(codec, path, true);
 }
 
@@ -4193,10 +4192,8 @@
 	if (!path)
 		return -EINVAL;
 
-	if (!spec->multi_io[idx].ctl_in)
-		spec->multi_io[idx].ctl_in =
-			snd_hda_codec_update_cache(codec, nid, 0,
-					   AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+	if (path->active == output)
+		return 0;
 
 	if (output) {
 		snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT);
@@ -4251,6 +4248,25 @@
 	return 0;
 }
 
+static void alc_auto_init_multi_io(struct hda_codec *codec)
+{
+	struct alc_spec *spec = codec->spec;
+	int i;
+
+	for (i = 0; i < spec->multi_ios; i++) {
+		hda_nid_t pin = spec->multi_io[i].pin;
+		struct nid_path *path;
+		path = get_nid_path(codec, spec->multi_io[i].dac, pin);
+		if (!path)
+			continue;
+		if (!spec->multi_io[i].ctl_in)
+			spec->multi_io[i].ctl_in =
+				snd_hda_codec_update_cache(codec, pin, 0,
+					   AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
+		activate_path(codec, path, path->active);
+	}
+}
+
 /* filter out invalid adc_nids (and capsrc_nids) that don't give all
  * active input pins
  */
@@ -4489,6 +4505,7 @@
 {
 	alc_auto_init_multi_out(codec);
 	alc_auto_init_extra_out(codec);
+	alc_auto_init_multi_io(codec);
 	alc_auto_init_analog_input(codec);
 	alc_auto_init_input_src(codec);
 	alc_auto_init_digital(codec);