aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc.h5
-rw-r--r--sound/soc/soc-core.c43
2 files changed, 48 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index ce3661d07c24..f86e455d3828 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -161,6 +161,8 @@ extern struct snd_ac97_bus_ops soc_ac97_ops;
161 161
162int snd_soc_register_platform(struct snd_soc_platform *platform); 162int snd_soc_register_platform(struct snd_soc_platform *platform);
163void snd_soc_unregister_platform(struct snd_soc_platform *platform); 163void snd_soc_unregister_platform(struct snd_soc_platform *platform);
164int snd_soc_register_codec(struct snd_soc_codec *codec);
165void snd_soc_unregister_codec(struct snd_soc_codec *codec);
164 166
165/* pcm <-> DAI connect */ 167/* pcm <-> DAI connect */
166void snd_soc_free_pcms(struct snd_soc_device *socdev); 168void snd_soc_free_pcms(struct snd_soc_device *socdev);
@@ -247,6 +249,9 @@ struct snd_soc_codec {
247 char *name; 249 char *name;
248 struct module *owner; 250 struct module *owner;
249 struct mutex mutex; 251 struct mutex mutex;
252 struct device *dev;
253
254 struct list_head list;
250 255
251 /* callbacks */ 256 /* callbacks */
252 int (*set_bias_level)(struct snd_soc_codec *, 257 int (*set_bias_level)(struct snd_soc_codec *,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 4d2db7cfaf4c..b098c0b4c584 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -47,6 +47,7 @@ static DEFINE_MUTEX(client_mutex);
47static LIST_HEAD(card_list); 47static LIST_HEAD(card_list);
48static LIST_HEAD(dai_list); 48static LIST_HEAD(dai_list);
49static LIST_HEAD(platform_list); 49static LIST_HEAD(platform_list);
50static LIST_HEAD(codec_list);
50 51
51static int snd_soc_register_card(struct snd_soc_card *card); 52static int snd_soc_register_card(struct snd_soc_card *card);
52static int snd_soc_unregister_card(struct snd_soc_card *card); 53static int snd_soc_unregister_card(struct snd_soc_card *card);
@@ -2224,6 +2225,48 @@ void snd_soc_unregister_platform(struct snd_soc_platform *platform)
2224} 2225}
2225EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); 2226EXPORT_SYMBOL_GPL(snd_soc_unregister_platform);
2226 2227
2228/**
2229 * snd_soc_register_codec - Register a codec with the ASoC core
2230 *
2231 * @param codec codec to register
2232 */
2233int snd_soc_register_codec(struct snd_soc_codec *codec)
2234{
2235 if (!codec->name)
2236 return -EINVAL;
2237
2238 /* The device should become mandatory over time */
2239 if (!codec->dev)
2240 printk(KERN_WARNING "No device for codec %s\n", codec->name);
2241
2242 INIT_LIST_HEAD(&codec->list);
2243
2244 mutex_lock(&client_mutex);
2245 list_add(&codec->list, &codec_list);
2246 snd_soc_instantiate_cards();
2247 mutex_unlock(&client_mutex);
2248
2249 pr_debug("Registered codec '%s'\n", codec->name);
2250
2251 return 0;
2252}
2253EXPORT_SYMBOL_GPL(snd_soc_register_codec);
2254
2255/**
2256 * snd_soc_unregister_codec - Unregister a codec from the ASoC core
2257 *
2258 * @param codec codec to unregister
2259 */
2260void snd_soc_unregister_codec(struct snd_soc_codec *codec)
2261{
2262 mutex_lock(&client_mutex);
2263 list_del(&codec->list);
2264 mutex_unlock(&client_mutex);
2265
2266 pr_debug("Unregistered codec '%s'\n", codec->name);
2267}
2268EXPORT_SYMBOL_GPL(snd_soc_unregister_codec);
2269
2227static int __init snd_soc_init(void) 2270static int __init snd_soc_init(void)
2228{ 2271{
2229#ifdef CONFIG_DEBUG_FS 2272#ifdef CONFIG_DEBUG_FS