ALSA: hda - proc - add support for dynamic controls to mixer<->NID mapping
authorJaroslav Kysela <perex@perex.cz>
Thu, 12 Nov 2009 09:15:48 +0000 (10:15 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 16 Nov 2009 10:35:19 +0000 (11:35 +0100)
This patch adds support for dynamically created controls to proc codec file
(Control: lines).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_local.h
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/hda/patch_via.c

index 1ed1d88e18347cbe2d0e524cde52410a28f77ae7..d71e651046eb34c04ff74f12e889c7cacc2578b0 100644 (file)
@@ -1523,6 +1523,11 @@ int snd_hda_ctl_add(struct hda_codec *codec, hda_nid_t nid,
        int err;
        struct hda_nid_item *item;
 
+       if (kctl->id.subdevice & (1<<31)) {
+               if (nid == 0)
+                       nid = kctl->id.subdevice & 0xffff;
+               kctl->id.subdevice = 0;
+       }
        err = snd_ctl_add(codec->bus->card, kctl);
        if (err < 0)
                return err;
@@ -3160,7 +3165,7 @@ EXPORT_SYMBOL_HDA(snd_hda_check_board_codec_sid_config);
  */
 int snd_hda_add_new_ctls(struct hda_codec *codec, struct snd_kcontrol_new *knew)
 {
-       int err;
+       int err;
 
        for (; knew->name; knew++) {
                struct snd_kcontrol *kctl;
index e6a0918f70d3b572213c210afcecccc9864a217d..3bfcf42ff6cf106d350b9c1ece6525e73eabda10 100644 (file)
@@ -33,6 +33,7 @@
 /* mono volume with index (index=0,1,...) (channel=1,2) */
 #define HDA_CODEC_VOLUME_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx,  \
+         .subdevice = (1<<31)|(nid), \
          .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
                    SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
                    SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
@@ -53,6 +54,7 @@
 /* mono mute switch with index (index=0,1,...) (channel=1,2) */
 #define HDA_CODEC_MUTE_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
+         .subdevice = (1<<31)|(nid), \
          .info = snd_hda_mixer_amp_switch_info, \
          .get = snd_hda_mixer_amp_switch_get, \
          .put = snd_hda_mixer_amp_switch_put, \
@@ -69,6 +71,7 @@
 /* special beep mono mute switch with index (index=0,1,...) (channel=1,2) */
 #define HDA_CODEC_MUTE_BEEP_MONO_IDX(xname, xcidx, nid, channel, xindex, direction) \
        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
+         .subdevice = (1<<31)|(nid), \
          .info = snd_hda_mixer_amp_switch_info, \
          .get = snd_hda_mixer_amp_switch_get, \
          .put = snd_hda_mixer_amp_switch_put_beep, \
index ef3383912b6ec3bda6b160c61955faf1fe01ef89..2d345606265b22e83270af2ccc77aefc89bc3cad 100644 (file)
@@ -2571,6 +2571,8 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name,
        knew->name = kstrdup(name, GFP_KERNEL);
        if (! knew->name)
                return -ENOMEM;
+       if (get_amp_nid_(val))
+               knew->subdevice = (1<<31)|get_amp_nid_(val);
        knew->private_value = val;
        return 0;
 }
index fff9de2456461eff029110d08d5c04ddb6801fe4..c0a98e724a25fd3647ca55b768bc9336457a8fd0 100644 (file)
@@ -4323,6 +4323,8 @@ static int add_control(struct alc_spec *spec, int type, const char *name,
        knew->name = kstrdup(name, GFP_KERNEL);
        if (!knew->name)
                return -ENOMEM;
+       if (get_amp_nid_(val))
+               knew->subdevice = (1<<31)|get_amp_nid_(val);
        knew->private_value = val;
        return 0;
 }
index a3872b90d6ed8054367892d665bfc15b1ce1d160..d2ddb959c29025f0b2523a88aca3797844a3cd2e 100644 (file)
@@ -2671,7 +2671,8 @@ static struct snd_kcontrol_new stac92xx_control_templates[] = {
 static struct snd_kcontrol_new *
 stac_control_new(struct sigmatel_spec *spec,
                 struct snd_kcontrol_new *ktemp,
-                const char *name)
+                const char *name,
+                hda_nid_t nid)
 {
        struct snd_kcontrol_new *knew;
 
@@ -2687,6 +2688,8 @@ stac_control_new(struct sigmatel_spec *spec,
                spec->kctls.alloced--;
                return NULL;
        }
+       if (nid)
+               knew->subdevice = (1<<31)|nid;
        return knew;
 }
 
@@ -2695,7 +2698,8 @@ static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
                                     int idx, const char *name,
                                     unsigned long val)
 {
-       struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name);
+       struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
+                                                        get_amp_nid_(val));
        if (!knew)
                return -ENOMEM;
        knew->index = idx;
@@ -2766,7 +2770,7 @@ static int stac92xx_add_input_source(struct sigmatel_spec *spec)
        if (!spec->num_adcs || imux->num_items <= 1)
                return 0; /* no need for input source control */
        knew = stac_control_new(spec, &stac_input_src_temp,
-                               stac_input_src_temp.name);
+                               stac_input_src_temp.name, 0);
        if (!knew)
                return -ENOMEM;
        knew->count = spec->num_adcs;
index 5a856009c916b8f466931d5029456ece0ed82f41..14219d898b2e4433e1310ac859058a14e63e8750 100644 (file)
@@ -442,6 +442,8 @@ static int via_add_control(struct via_spec *spec, int type, const char *name,
        knew->name = kstrdup(name, GFP_KERNEL);
        if (!knew->name)
                return -ENOMEM;
+       if (get_amp_nid_(val))
+               knew->subdevice = (1<<31)|get_amp_nid_(val);
        knew->private_value = val;
        return 0;
 }