]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
ALSA: hda: hdmi: Hint matching between input devices and pcm devices
authorDavid Henningsson <david.henningsson@canonical.com>
Tue, 23 Aug 2011 14:56:03 +0000 (16:56 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 21 Sep 2011 08:31:00 +0000 (10:31 +0200)
Since modern HDMI cards often have more than one output pin and thus
input device, we need to know which one has actually been plugged in.

This patch adds a name hint that indicates which PCM device is connected
to which pin.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/patch_hdmi.c

index 19cb72db9c38df1261f3ded1fe1c0471bd906aef..3f1f6ac8e6432fe5fc49d8ec533e6722e57f8e74 100644 (file)
@@ -967,19 +967,12 @@ static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
 
        per_pin->pin_nid = pin_nid;
 
-       err = snd_hda_input_jack_add(codec, pin_nid,
-                                    SND_JACK_VIDEOOUT, NULL);
-       if (err < 0)
-               return err;
-
        err = hdmi_read_pin_conn(codec, pin_idx);
        if (err < 0)
                return err;
 
        spec->num_pins++;
 
-       hdmi_present_sense(codec, pin_nid, eld);
-
        return 0;
 }
 
@@ -1162,6 +1155,25 @@ static int generic_hdmi_build_pcms(struct hda_codec *codec)
        return 0;
 }
 
+static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
+{
+       int err;
+       char hdmi_str[32];
+       struct hdmi_spec *spec = codec->spec;
+       struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
+       int pcmdev = spec->pcm_rec[pin_idx].device;
+
+       snprintf(hdmi_str, sizeof(hdmi_str), "HDMI/DP,pcm=%d", pcmdev);
+
+       err = snd_hda_input_jack_add(codec, per_pin->pin_nid,
+                            SND_JACK_VIDEOOUT, pcmdev > 0 ? hdmi_str : NULL);
+       if (err < 0)
+               return err;
+
+       hdmi_present_sense(codec, per_pin->pin_nid, &per_pin->sink_eld);
+       return 0;
+}
+
 static int generic_hdmi_build_controls(struct hda_codec *codec)
 {
        struct hdmi_spec *spec = codec->spec;
@@ -1170,6 +1182,11 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)
 
        for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
                struct hdmi_spec_per_pin *per_pin = &spec->pins[pin_idx];
+
+               err = generic_hdmi_build_jack(codec, pin_idx);
+               if (err < 0)
+                       return err;
+
                err = snd_hda_create_spdif_out_ctls(codec,
                                                    per_pin->pin_nid,
                                                    per_pin->mux_nids[0]);