ASoC: core - Add API call to register platform kcontrols.
authorLiam Girdwood <lrg@ti.com>
Mon, 4 Jul 2011 21:10:51 +0000 (22:10 +0100)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 5 Jul 2011 18:07:34 +0000 (11:07 -0700)
In preparation for Dynamic PCM (AKA DSP) support.

Allow platform drivers to register kcontrols.

Signed-off-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
include/sound/soc.h
sound/soc/soc-core.c

index f30f3fe4a41bed42369b71d3f4c67d2b1799c0e6..c421501532db9ef40ae2f8eb2e4a022d60edcab5 100644 (file)
@@ -368,6 +368,8 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
                                  const char *prefix);
 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_info_enum_double(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_info *uinfo);
 int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
index d08abf4e3eb35a0a5ed7da19145c3e0504f65efc..16651814ecba3480779519d575cb7deeeab56b22 100644 (file)
@@ -1948,6 +1948,36 @@ int snd_soc_add_controls(struct snd_soc_codec *codec,
 }
 EXPORT_SYMBOL_GPL(snd_soc_add_controls);
 
+/**
+ * snd_soc_add_platform_controls - add an array of controls to a platform.
+ * Convienience function to add a list of controls.
+ *
+ * @platform: platform 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_platform_controls(struct snd_soc_platform *platform,
+       const struct snd_kcontrol_new *controls, int num_controls)
+{
+       struct snd_card *card = platform->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, platform,
+                               control->name, NULL));
+               if (err < 0) {
+                       dev_err(platform->dev, "Failed to add %s %d\n",control->name, err);
+                       return err;
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls);
+
 /**
  * snd_soc_info_enum_double - enumerated double mixer info callback
  * @kcontrol: mixer control