[alsa-devel] [RFC 04/11] ASoC: core - Add API call to register dai kcontrols.
Peter Ujfalusi
peter.ujfalusi at ti.com
Wed Feb 15 16:37:53 CET 2012
Allow dai drivers to register kcontrols.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi at ti.com>
---
include/sound/soc.h | 2 ++
sound/soc/soc-core.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 2f687ed..f513758 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -372,6 +372,8 @@ int snd_soc_add_controls(struct snd_soc_codec *codec,
const struct snd_kcontrol_new *controls, int num_controls);
int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
const struct snd_kcontrol_new *controls, int num_controls);
+int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
+ const struct snd_kcontrol_new *controls, int num_controls);
int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo);
int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 35a1e63..d04a029 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2080,6 +2080,37 @@ int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls);
/**
+ * snd_soc_add_dai_controls - add an array of controls to a dai.
+ * Convienience function to add a list of controls.
+ *
+ * @dai: dai to add controls to
+ * @controls: array of controls to add
+ * @num_controls: number of elements in the array
+ *
+ * Return 0 for success, else error.
+ */
+int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
+ const struct snd_kcontrol_new *controls, int num_controls)
+{
+ struct snd_card *card = dai->card->snd_card;
+ int err, i;
+
+ for (i = 0; i < num_controls; i++) {
+ const struct snd_kcontrol_new *control = &controls[i];
+ err = snd_ctl_add(card, snd_soc_cnew(control, dai,
+ control->name, NULL));
+ if (err < 0) {
+ dev_err(dai->dev, "Failed to add %s %d\n",
+ control->name, err);
+ return err;
+ }
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_add_dai_controls);
+
+/**
* snd_soc_info_enum_double - enumerated double mixer info callback
* @kcontrol: mixer control
* @uinfo: control element information
--
1.7.8.4
More information about the Alsa-devel
mailing list