From: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>,
lrg@ti.com, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.de>,
Clemens Ladisch <clemens@ladisch.de>
Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com,
lrg@slimlogic.co.uk
Subject: [PATCH 2/2 v2] ASoC: soc-core: Add helper function to handle dynamic update of controls
Date: Tue, 15 Mar 2011 12:31:09 +0000 [thread overview]
Message-ID: <1300192269-20435-2-git-send-email-dp@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1300192269-20435-1-git-send-email-dp@opensource.wolfsonmicro.com>
This function can be used to update or add controls at runtime. It will
always try to add a given control if it does not already exist.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 2 ++
sound/soc/soc-core.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index bfa4836..509c1ea 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -344,6 +344,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_update_controls(struct snd_soc_codec *codec,
+ 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 17efacd..815103a 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2420,6 +2420,39 @@ int snd_soc_add_controls(struct snd_soc_codec *codec,
EXPORT_SYMBOL_GPL(snd_soc_add_controls);
/**
+ * snd_soc_update_controls - update an array of controls
+ * Convienience function to update a list of controls.
+ *
+ * @codec: codec to update controls of
+ * @controls: array of controls to update
+ * @num_controls: number of elements in the array
+ *
+ * Return 0 for success, else error.
+ */
+int snd_soc_update_controls(struct snd_soc_codec *codec,
+ const struct snd_kcontrol_new *controls, int num_controls)
+{
+ struct snd_card *card = codec->card->snd_card;
+ int err, i;
+
+ for (i = 0; i < num_controls; i++) {
+ const struct snd_kcontrol_new *control = &controls[i];
+ /* always add on update if not already added */
+ err = snd_ctl_update(card, snd_soc_cnew(control, codec,
+ control->name,
+ codec->name_prefix), 1);
+ if (err < 0) {
+ dev_err(codec->dev, "%s: Failed to update %s: %d\n",
+ codec->name, control->name, err);
+ return err;
+ }
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_update_controls);
+
+/**
* snd_soc_info_enum_double - enumerated double mixer info callback
* @kcontrol: mixer control
* @uinfo: control element information
--
1.7.4.1
next prev parent reply other threads:[~2011-03-15 12:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-15 12:31 [PATCH 1/2 v2] ALSA: Add snd_ctl_update() to dynamically update a control Dimitris Papastamos
2011-03-15 12:31 ` Dimitris Papastamos [this message]
2011-03-15 14:17 ` Clemens Ladisch
2011-03-15 14:25 ` Takashi Iwai
2011-03-16 0:56 ` Raymond Yau
2011-03-16 7:01 ` Takashi Iwai
2011-03-15 16:27 ` Dimitris Papastamos
2011-03-16 8:05 ` Raymond Yau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1300192269-20435-2-git-send-email-dp@opensource.wolfsonmicro.com \
--to=dp@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=clemens@ladisch.de \
--cc=lrg@slimlogic.co.uk \
--cc=lrg@ti.com \
--cc=patches@opensource.wolfsonmicro.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.