diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-02-03 17:28:01 +0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-02-03 17:28:01 +0400 |
commit | 9322ca549771f2e84a93ac3f509ade1e4c3cdb35 (patch) | |
tree | 464dd5828486ccedd5342a21a6607392b560af29 /sound/pci/hda/hda_codec.c | |
parent | 1299d3302000c8277b063d3b84c6d866c93597f9 (diff) | |
download | linux-9322ca549771f2e84a93ac3f509ade1e4c3cdb35.tar.xz |
ALSA: hda - Add suffix argument to snd_hda_add_vmaster()
In most cases, the slave strings for vmaster are identical between
volumes and switches except for "xxx Volume" and "xxx Switch" suffix.
Now snd_hda_add_vmaster() takes the optional suffix argument so that
each string can be composed with the given suffix, and we can share the
slave name strings in both volume and switch calls nicely.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index c2c65f63bf06..8a2f9dddbf0a 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2300,7 +2300,7 @@ typedef int (*map_slave_func_t)(void *, struct snd_kcontrol *); /* apply the function to all matching slave ctls in the mixer list */ static int map_slaves(struct hda_codec *codec, const char * const *slaves, - map_slave_func_t func, void *data) + const char *suffix, map_slave_func_t func, void *data) { struct hda_nid_item *items; const char * const *s; @@ -2313,7 +2313,15 @@ static int map_slaves(struct hda_codec *codec, const char * const *slaves, sctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER) continue; for (s = slaves; *s; s++) { - if (!strcmp(sctl->id.name, *s)) { + char tmpname[sizeof(sctl->id.name)]; + const char *name = *s; + if (suffix) { + snprintf(tmpname, sizeof(tmpname), "%s %s", + name, suffix); + name = tmpname; + } + printk("XXX comparing %s vs %s\n", sctl->id.name, name); + if (!strcmp(sctl->id.name, name)) { err = func(data, sctl); if (err) return err; @@ -2335,6 +2343,7 @@ static int check_slave_present(void *data, struct snd_kcontrol *sctl) * @name: vmaster control name * @tlv: TLV data (optional) * @slaves: slave control names (optional) + * @suffix: suffix string to each slave name (optional) * * Create a virtual master control with the given name. The TLV data * must be either NULL or a valid data. @@ -2346,12 +2355,13 @@ static int check_slave_present(void *data, struct snd_kcontrol *sctl) * This function returns zero if successful or a negative error code. */ int snd_hda_add_vmaster(struct hda_codec *codec, char *name, - unsigned int *tlv, const char * const *slaves) + unsigned int *tlv, const char * const *slaves, + const char *suffix) { struct snd_kcontrol *kctl; int err; - err = map_slaves(codec, slaves, check_slave_present, NULL); + err = map_slaves(codec, slaves, suffix, check_slave_present, NULL); if (err != 1) { snd_printdd("No slave found for %s\n", name); return 0; @@ -2363,8 +2373,8 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name, if (err < 0) return err; - err = map_slaves(codec, slaves, (map_slave_func_t)snd_ctl_add_slave, - kctl); + err = map_slaves(codec, slaves, suffix, + (map_slave_func_t)snd_ctl_add_slave, kctl); if (err < 0) return err; return 0; |