aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2008-11-30 18:31:24 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2008-12-09 05:49:26 -0500
commit9115171a6b79b6b4d5c6697f123556b6efc37f1f (patch)
tree0889dc28a991c27947c5b65f611e2e8f600deb69 /sound/soc
parentc5af3a2e192d333997d1e191f3eba7fd2f869681 (diff)
ASoC: Add DAI registration API
Add API calls to register and unregister DAIs with the core. Currently these APIs are ineffective. Since multiple DAIs for a given device are a common case bulk variants are provided. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/soc-core.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 44fbd71ce80f..03460b068f1e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -45,6 +45,7 @@ static struct dentry *debugfs_root;
45 45
46static DEFINE_MUTEX(client_mutex); 46static DEFINE_MUTEX(client_mutex);
47static LIST_HEAD(card_list); 47static LIST_HEAD(card_list);
48static LIST_HEAD(dai_list);
48 49
49static int snd_soc_register_card(struct snd_soc_card *card); 50static int snd_soc_register_card(struct snd_soc_card *card);
50static int snd_soc_unregister_card(struct snd_soc_card *card); 51static int snd_soc_unregister_card(struct snd_soc_card *card);
@@ -2019,6 +2020,88 @@ static int snd_soc_unregister_card(struct snd_soc_card *card)
2019 return 0; 2020 return 0;
2020} 2021}
2021 2022
2023/**
2024 * snd_soc_register_dai - Register a DAI with the ASoC core
2025 *
2026 * @param dai DAI to register
2027 */
2028int snd_soc_register_dai(struct snd_soc_dai *dai)
2029{
2030 if (!dai->name)
2031 return -EINVAL;
2032
2033 /* The device should become mandatory over time */
2034 if (!dai->dev)
2035 printk(KERN_WARNING "No device for DAI %s\n", dai->name);
2036
2037 INIT_LIST_HEAD(&dai->list);
2038
2039 mutex_lock(&client_mutex);
2040 list_add(&dai->list, &dai_list);
2041 mutex_unlock(&client_mutex);
2042
2043 pr_debug("Registered DAI '%s'\n", dai->name);
2044
2045 return 0;
2046}
2047EXPORT_SYMBOL_GPL(snd_soc_register_dai);
2048
2049/**
2050 * snd_soc_unregister_dai - Unregister a DAI from the ASoC core
2051 *
2052 * @param dai DAI to unregister
2053 */
2054void snd_soc_unregister_dai(struct snd_soc_dai *dai)
2055{
2056 mutex_lock(&client_mutex);
2057 list_del(&dai->list);
2058 mutex_unlock(&client_mutex);
2059
2060 pr_debug("Unregistered DAI '%s'\n", dai->name);
2061}
2062EXPORT_SYMBOL_GPL(snd_soc_unregister_dai);
2063
2064/**
2065 * snd_soc_register_dais - Register multiple DAIs with the ASoC core
2066 *
2067 * @param dai Array of DAIs to register
2068 * @param count Number of DAIs
2069 */
2070int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count)
2071{
2072 int i, ret;
2073
2074 for (i = 0; i < count; i++) {
2075 ret = snd_soc_register_dai(&dai[i]);
2076 if (ret != 0)
2077 goto err;
2078 }
2079
2080 return 0;
2081
2082err:
2083 for (i--; i >= 0; i--)
2084 snd_soc_unregister_dai(&dai[i]);
2085
2086 return ret;
2087}
2088EXPORT_SYMBOL_GPL(snd_soc_register_dais);
2089
2090/**
2091 * snd_soc_unregister_dais - Unregister multiple DAIs from the ASoC core
2092 *
2093 * @param dai Array of DAIs to unregister
2094 * @param count Number of DAIs
2095 */
2096void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count)
2097{
2098 int i;
2099
2100 for (i = 0; i < count; i++)
2101 snd_soc_unregister_dai(&dai[i]);
2102}
2103EXPORT_SYMBOL_GPL(snd_soc_unregister_dais);
2104
2022static int __devinit snd_soc_init(void) 2105static int __devinit snd_soc_init(void)
2023{ 2106{
2024#ifdef CONFIG_DEBUG_FS 2107#ifdef CONFIG_DEBUG_FS