aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-01-10 10:25:44 -0500
committerTakashi Iwai <tiwai@suse.de>2011-01-10 10:46:53 -0500
commit9600732b6caba595f34acf2abd930098ec9a0b2b (patch)
tree7474e1b11894623186a2acd47a388aa87fdd002e /sound/core
parentb532d6b8d3aa163e1dc143bc729e9ee92f75baf5 (diff)
ALSA: core, oxygen, virtuoso: add an enum control info helper
Introduce the helper function snd_ctl_enum_info() to fill out the elem_info fields for an enumerated control. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/control.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 45a818002d99..9ce00ed20fba 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -1488,7 +1488,7 @@ int snd_ctl_create(struct snd_card *card)
1488} 1488}
1489 1489
1490/* 1490/*
1491 * Frequently used control callbacks 1491 * Frequently used control callbacks/helpers
1492 */ 1492 */
1493int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol, 1493int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
1494 struct snd_ctl_elem_info *uinfo) 1494 struct snd_ctl_elem_info *uinfo)
@@ -1513,3 +1513,29 @@ int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
1513} 1513}
1514 1514
1515EXPORT_SYMBOL(snd_ctl_boolean_stereo_info); 1515EXPORT_SYMBOL(snd_ctl_boolean_stereo_info);
1516
1517/**
1518 * snd_ctl_enum_info - fills the info structure for an enumerated control
1519 * @info: the structure to be filled
1520 * @channels: the number of the control's channels; often one
1521 * @items: the number of control values; also the size of @names
1522 * @names: an array containing the names of all control values
1523 *
1524 * Sets all required fields in @info to their appropriate values.
1525 * If the control's accessibility is not the default (readable and writable),
1526 * the caller has to fill @info->access.
1527 */
1528int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
1529 unsigned int items, const char *const names[])
1530{
1531 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1532 info->count = channels;
1533 info->value.enumerated.items = items;
1534 if (info->value.enumerated.item >= items)
1535 info->value.enumerated.item = items - 1;
1536 strlcpy(info->value.enumerated.name,
1537 names[info->value.enumerated.item],
1538 sizeof(info->value.enumerated.name));
1539 return 0;
1540}
1541EXPORT_SYMBOL(snd_ctl_enum_info);