summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-11-30 18:34:38 +0100
committerTakashi Iwai <tiwai@suse.de>2012-11-30 18:34:38 +0100
commitdda415d41882449f841f88d829dd65b6ee1c374c (patch)
treedde9f520ddf3466235bf60d610f54383a4d76f9c /sound/pci/hda/hda_codec.c
parent475c3d21e8e1fe7cbec76b0f3e8d9f4dea66acd8 (diff)
downloadlinux-dda415d41882449f841f88d829dd65b6ee1c374c.tar.bz2
ALSA: hda - Add a helper function for simple enum kcontrols
The same type of code is being used in multiple places in various codec drivers, so put it as a core library. 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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 3634bfebc008..d05bcbb61077 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -4792,6 +4792,34 @@ EXPORT_SYMBOL_HDA(snd_hda_input_mux_put);
/*
+ * process kcontrol info callback of a simple string enum array
+ * when @num_items is 0 or @texts is NULL, assume a boolean enum array
+ */
+int snd_hda_enum_helper_info(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_info *uinfo,
+ int num_items, const char * const *texts)
+{
+ static const char * const texts_default[] = {
+ "Disabled", "Enabled"
+ };
+
+ if (!texts || !num_items) {
+ num_items = 2;
+ texts = texts_default;
+ }
+
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
+ uinfo->count = 1;
+ uinfo->value.enumerated.items = num_items;
+ if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
+ uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
+ strcpy(uinfo->value.enumerated.name,
+ texts[uinfo->value.enumerated.item]);
+ return 0;
+}
+EXPORT_SYMBOL_HDA(snd_hda_enum_helper_info);
+
+/*
* Multi-channel / digital-out PCM helper functions
*/