ALSA: hda: Fix the control element identification for multiple codecs
[sfrench/cifs-2.6.git] / sound / pci / hda / hda_codec.c
index ac1cc7c5290e3d7a974b8618cd9772ee04d40b8f..dc4a042b3ac1182723bc971b497e274f73790dd2 100644 (file)
@@ -3389,7 +3389,12 @@ int snd_hda_add_new_ctls(struct hda_codec *codec,
                        kctl = snd_ctl_new1(knew, codec);
                        if (!kctl)
                                return -ENOMEM;
-                       if (addr > 0)
+                       /* Do not use the id.device field for MIXER elements.
+                        * This field is for real device numbers (like PCM) but codecs
+                        * are hidden components from the user space view (unrelated
+                        * to the mixer element identification).
+                        */
+                       if (addr > 0 && codec->ctl_dev_id)
                                kctl->id.device = addr;
                        if (idx > 0)
                                kctl->id.index = idx;
@@ -3400,9 +3405,11 @@ int snd_hda_add_new_ctls(struct hda_codec *codec,
                         * the codec addr; if it still fails (or it's the
                         * primary codec), then try another control index
                         */
-                       if (!addr && codec->core.addr)
+                       if (!addr && codec->core.addr) {
                                addr = codec->core.addr;
-                       else if (!idx && !knew->index) {
+                               if (!codec->ctl_dev_id)
+                                       idx += 10 * addr;
+                       } else if (!idx && !knew->index) {
                                idx = find_empty_mixer_ctl_idx(codec,
                                                               knew->name, 0);
                                if (idx <= 0)