diff options
author | Takashi Iwai <tiwai@suse.de> | 2023-07-20 10:20:58 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2023-07-21 09:10:38 +0200 |
commit | 68fa05d4a82b8f4ca6fa85be85833e35bd6ebef9 (patch) | |
tree | 341a6294a583280f2bc05c2a56aff73192996519 /include/sound/control.h | |
parent | f056f2fef31e5662e3f995fc23ae0eea27db5a01 (diff) |
ALSA: control: Introduce snd_ctl_find_id_mixer()
A commonly seen pattern is to run snd_ctl_find_id() for a mixer
control element with a given string. Let's provide a standard helper
for achieving that for simplifying the code.
Link: https://lore.kernel.org/r/20230720082108.31346-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound/control.h')
-rw-r--r-- | include/sound/control.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/sound/control.h b/include/sound/control.h index 42e8dbb22d8e..69d950a34ca3 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -145,6 +145,28 @@ struct snd_kcontrol *snd_ctl_find_numid(struct snd_card *card, unsigned int numi struct snd_kcontrol *snd_ctl_find_id_locked(struct snd_card *card, const struct snd_ctl_elem_id *id); struct snd_kcontrol *snd_ctl_find_id(struct snd_card *card, const struct snd_ctl_elem_id *id); +/** + * snd_ctl_find_id_mixer - find the control instance with the given name string + * @card: the card instance + * @name: the name string + * + * Finds the control instance with the given name and + * @SNDRV_CTL_ELEM_IFACE_MIXER. Other fields are set to zero. + * + * This is merely a wrapper to snd_ctl_find_id(). + * + * Return: The pointer of the instance if found, or %NULL if not. + */ +static inline struct snd_kcontrol * +snd_ctl_find_id_mixer(struct snd_card *card, const char *name) +{ + struct snd_ctl_elem_id id = {}; + + id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + strscpy(id.name, name, sizeof(id.name)); + return snd_ctl_find_id(card, &id); +} + int snd_ctl_create(struct snd_card *card); int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn); |