From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 5/8] ASoC: Add codec registration API
Date: Wed, 10 Dec 2008 20:01:12 +0000 [thread overview]
Message-ID: <1228939275-7768-5-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1228939275-7768-4-git-send-email-broonie@opensource.wolfsonmicro.com>
Another part of the backporting of Liam's ASoC v2 work. Using this is
more complicated than the other registration types since currently the
codec is instantiated during the probe of the ASoC device so we can't
currently readily wait for the codec to register.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 5 +++++
sound/soc/soc-core.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index ce3661d..f86e455 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -161,6 +161,8 @@ extern struct snd_ac97_bus_ops soc_ac97_ops;
int snd_soc_register_platform(struct snd_soc_platform *platform);
void snd_soc_unregister_platform(struct snd_soc_platform *platform);
+int snd_soc_register_codec(struct snd_soc_codec *codec);
+void snd_soc_unregister_codec(struct snd_soc_codec *codec);
/* pcm <-> DAI connect */
void snd_soc_free_pcms(struct snd_soc_device *socdev);
@@ -247,6 +249,9 @@ struct snd_soc_codec {
char *name;
struct module *owner;
struct mutex mutex;
+ struct device *dev;
+
+ struct list_head list;
/* callbacks */
int (*set_bias_level)(struct snd_soc_codec *,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4d2db7c..b098c0b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -47,6 +47,7 @@ static DEFINE_MUTEX(client_mutex);
static LIST_HEAD(card_list);
static LIST_HEAD(dai_list);
static LIST_HEAD(platform_list);
+static LIST_HEAD(codec_list);
static int snd_soc_register_card(struct snd_soc_card *card);
static int snd_soc_unregister_card(struct snd_soc_card *card);
@@ -2224,6 +2225,48 @@ void snd_soc_unregister_platform(struct snd_soc_platform *platform)
}
EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
+/**
+ * snd_soc_register_codec - Register a codec with the ASoC core
+ *
+ * @param codec codec to register
+ */
+int snd_soc_register_codec(struct snd_soc_codec *codec)
+{
+ if (!codec->name)
+ return -EINVAL;
+
+ /* The device should become mandatory over time */
+ if (!codec->dev)
+ printk(KERN_WARNING "No device for codec %s\n", codec->name);
+
+ INIT_LIST_HEAD(&codec->list);
+
+ mutex_lock(&client_mutex);
+ list_add(&codec->list, &codec_list);
+ snd_soc_instantiate_cards();
+ mutex_unlock(&client_mutex);
+
+ pr_debug("Registered codec '%s'\n", codec->name);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_register_codec);
+
+/**
+ * snd_soc_unregister_codec - Unregister a codec from the ASoC core
+ *
+ * @param codec codec to unregister
+ */
+void snd_soc_unregister_codec(struct snd_soc_codec *codec)
+{
+ mutex_lock(&client_mutex);
+ list_del(&codec->list);
+ mutex_unlock(&client_mutex);
+
+ pr_debug("Unregistered codec '%s'\n", codec->name);
+}
+EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
+
static int __init snd_soc_init(void)
{
#ifdef CONFIG_DEBUG_FS
--
1.5.6.5
next prev parent reply other threads:[~2008-12-10 20:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-10 19:58 [PATCH 0/8] ASoC updates Mark Brown
2008-12-10 20:01 ` [PATCH 1/8] ASoC: Work around warnings from some build environments Mark Brown
2008-12-10 20:01 ` [PATCH 2/8] ASoC: TWL4030: Add missing Carkit output Mark Brown
2008-12-10 20:01 ` [PATCH 3/8] ASoC: TWL4030: Small cleanup Mark Brown
2008-12-10 20:01 ` [PATCH 4/8] ASoC: TWL4030: Change the name for the DACs Mark Brown
2008-12-10 20:01 ` Mark Brown [this message]
2008-12-10 20:01 ` [PATCH 6/8] ASoC: Convert WM8900 to do more work at I2C probe time Mark Brown
2008-12-10 20:01 ` [PATCH 7/8] ASoC: Convert WM8903 driver to register " Mark Brown
2008-12-10 20:01 ` [PATCH 8/8] ASoC: Stop WM8903 SYSCLK when suspending Mark Brown
2008-12-10 20:34 ` [PATCH 0/8] ASoC updates Takashi Iwai
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=1228939275-7768-5-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox