aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc-dai.h8
-rw-r--r--sound/soc/soc-core.c83
2 files changed, 91 insertions, 0 deletions
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index e2d5f76838c6..24247f763608 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -100,6 +100,12 @@ struct snd_soc_dai_ops;
100struct snd_soc_dai; 100struct snd_soc_dai;
101struct snd_ac97_bus_ops; 101struct snd_ac97_bus_ops;
102 102
103/* Digital Audio Interface registration */
104int snd_soc_register_dai(struct snd_soc_dai *dai);
105void snd_soc_unregister_dai(struct snd_soc_dai *dai);
106int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count);
107void snd_soc_unregister_dais(struct snd_soc_dai *dai, size_t count);
108
103/* Digital Audio Interface clocking API.*/ 109/* Digital Audio Interface clocking API.*/
104int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, 110int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
105 unsigned int freq, int dir); 111 unsigned int freq, int dir);
@@ -186,6 +192,8 @@ struct snd_soc_dai {
186 unsigned int id; 192 unsigned int id;
187 int ac97_control; 193 int ac97_control;
188 194
195 struct device *dev;
196
189 /* DAI callbacks */ 197 /* DAI callbacks */
190 int (*probe)(struct platform_device *pdev, 198 int (*probe)(struct platform_device *pdev,
191 struct snd_soc_dai *dai); 199 struct snd_soc_dai *dai);
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