[ALSA] soc - DAPM - Add bulk control registration
authorMark Brown <[email protected]>
Tue, 13 May 2008 12:51:19 +0000 (14:51 +0200)
committerJaroslav Kysela <[email protected]>
Mon, 19 May 2008 11:19:18 +0000 (13:19 +0200)
Most SoC drivers cut'n'paste a loop iterating over an array to register
their DAPM controls.  Provide a function they can call instead.

Signed-off-by: Mark Brown <[email protected]>
Cc: Graeme Gregory <[email protected]>
Cc: Frank Mandarino <[email protected]>
Cc: Jarkko Nikula <[email protected]>
Cc: Richard Purdie <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Jaroslav Kysela <[email protected]>
include/sound/soc-dapm.h
sound/soc/soc-dapm.c

index 40cc695b69b63fd07071b8a0f0e9a8ac9d8515ce..1f30616afe71cf8061a3c832ee790cf9d81c0700 100644 (file)
@@ -205,6 +205,9 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol);
 int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
        const struct snd_soc_dapm_widget *widget);
+int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
+       const struct snd_soc_dapm_widget *widget,
+       int num);
 
 /* dapm path setup */
 int snd_soc_dapm_connect_input(struct snd_soc_codec *codec,
index c60200ccde60f83013a4caf1bd70bb39ee4d70af..811d65271012768a33f67621b5611a750e5ddf5c 100644 (file)
@@ -1233,6 +1233,33 @@ int snd_soc_dapm_new_control(struct snd_soc_codec *codec,
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_control);
 
+/**
+ * snd_soc_dapm_new_controls - create new dapm controls
+ * @codec: audio codec
+ * @widget: widget array
+ * @num: number of widgets
+ *
+ * Creates new DAPM controls based upon the templates.
+ *
+ * Returns 0 for success else error.
+ */
+int snd_soc_dapm_new_controls(struct snd_soc_codec *codec,
+       const struct snd_soc_dapm_widget *widget,
+       int num)
+{
+       int i, ret;
+
+       for (i = 0; i < num; i++) {
+               ret = snd_soc_dapm_new_control(codec, widget);
+               if (ret < 0)
+                       return ret;
+               widget++;
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
+
+
 /**
  * snd_soc_dapm_stream_event - send a stream event to the dapm core
  * @codec: audio codec