diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-12-03 14:40:30 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-12-09 05:49:27 -0500 |
commit | 12a48a8c0087ba39d926cf1d63938ccbdb9752c3 (patch) | |
tree | 4fc400e27b9f524a908ec24b854131c435be2722 | |
parent | 3f4b783cfdebb559814690572041a17bc9744cf3 (diff) |
ASoC: Add platform registration API
ASoC v2 allows platform drivers to instantiate independantly of the
overall ASoC card. This API allows drivers to notify the core when
they are registered.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | include/sound/soc.h | 5 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 38 |
2 files changed, 43 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 4a578b5d855c..ce3661d07c24 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -149,6 +149,7 @@ struct snd_soc_ops; | |||
149 | struct snd_soc_dai_mode; | 149 | struct snd_soc_dai_mode; |
150 | struct snd_soc_pcm_runtime; | 150 | struct snd_soc_pcm_runtime; |
151 | struct snd_soc_dai; | 151 | struct snd_soc_dai; |
152 | struct snd_soc_platform; | ||
152 | struct snd_soc_codec; | 153 | struct snd_soc_codec; |
153 | struct soc_enum; | 154 | struct soc_enum; |
154 | struct snd_soc_ac97_ops; | 155 | struct snd_soc_ac97_ops; |
@@ -158,6 +159,9 @@ typedef int (*hw_read_t)(void *,char* ,int); | |||
158 | 159 | ||
159 | extern struct snd_ac97_bus_ops soc_ac97_ops; | 160 | extern struct snd_ac97_bus_ops soc_ac97_ops; |
160 | 161 | ||
162 | int snd_soc_register_platform(struct snd_soc_platform *platform); | ||
163 | void snd_soc_unregister_platform(struct snd_soc_platform *platform); | ||
164 | |||
161 | /* pcm <-> DAI connect */ | 165 | /* pcm <-> DAI connect */ |
162 | void snd_soc_free_pcms(struct snd_soc_device *socdev); | 166 | void snd_soc_free_pcms(struct snd_soc_device *socdev); |
163 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); | 167 | int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid); |
@@ -296,6 +300,7 @@ struct snd_soc_codec_device { | |||
296 | /* SoC platform interface */ | 300 | /* SoC platform interface */ |
297 | struct snd_soc_platform { | 301 | struct snd_soc_platform { |
298 | char *name; | 302 | char *name; |
303 | struct list_head list; | ||
299 | 304 | ||
300 | int (*probe)(struct platform_device *pdev); | 305 | int (*probe)(struct platform_device *pdev); |
301 | int (*remove)(struct platform_device *pdev); | 306 | int (*remove)(struct platform_device *pdev); |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 03460b068f1e..ffae370b45df 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -46,6 +46,7 @@ static struct dentry *debugfs_root; | |||
46 | static DEFINE_MUTEX(client_mutex); | 46 | static DEFINE_MUTEX(client_mutex); |
47 | static LIST_HEAD(card_list); | 47 | static LIST_HEAD(card_list); |
48 | static LIST_HEAD(dai_list); | 48 | static LIST_HEAD(dai_list); |
49 | static LIST_HEAD(platform_list); | ||
49 | 50 | ||
50 | static int snd_soc_register_card(struct snd_soc_card *card); | 51 | static int snd_soc_register_card(struct snd_soc_card *card); |
51 | static int snd_soc_unregister_card(struct snd_soc_card *card); | 52 | static int snd_soc_unregister_card(struct snd_soc_card *card); |
@@ -2102,6 +2103,43 @@ void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count) | |||
2102 | } | 2103 | } |
2103 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); | 2104 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); |
2104 | 2105 | ||
2106 | /** | ||
2107 | * snd_soc_register_platform - Register a platform with the ASoC core | ||
2108 | * | ||
2109 | * @param platform platform to register | ||
2110 | */ | ||
2111 | int snd_soc_register_platform(struct snd_soc_platform *platform) | ||
2112 | { | ||
2113 | if (!platform->name) | ||
2114 | return -EINVAL; | ||
2115 | |||
2116 | INIT_LIST_HEAD(&platform->list); | ||
2117 | |||
2118 | mutex_lock(&client_mutex); | ||
2119 | list_add(&platform->list, &platform_list); | ||
2120 | mutex_unlock(&client_mutex); | ||
2121 | |||
2122 | pr_debug("Registered platform '%s'\n", platform->name); | ||
2123 | |||
2124 | return 0; | ||
2125 | } | ||
2126 | EXPORT_SYMBOL_GPL(snd_soc_register_platform); | ||
2127 | |||
2128 | /** | ||
2129 | * snd_soc_unregister_platform - Unregister a platform from the ASoC core | ||
2130 | * | ||
2131 | * @param platform platform to unregister | ||
2132 | */ | ||
2133 | void snd_soc_unregister_platform(struct snd_soc_platform *platform) | ||
2134 | { | ||
2135 | mutex_lock(&client_mutex); | ||
2136 | list_del(&platform->list); | ||
2137 | mutex_unlock(&client_mutex); | ||
2138 | |||
2139 | pr_debug("Unregistered platform '%s'\n", platform->name); | ||
2140 | } | ||
2141 | EXPORT_SYMBOL_GPL(snd_soc_unregister_platform); | ||
2142 | |||
2105 | static int __devinit snd_soc_init(void) | 2143 | static int __devinit snd_soc_init(void) |
2106 | { | 2144 | { |
2107 | #ifdef CONFIG_DEBUG_FS | 2145 | #ifdef CONFIG_DEBUG_FS |