diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-11-30 18:31:24 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2008-12-09 05:49:26 -0500 |
commit | 9115171a6b79b6b4d5c6697f123556b6efc37f1f (patch) | |
tree | 0889dc28a991c27947c5b65f611e2e8f600deb69 | |
parent | c5af3a2e192d333997d1e191f3eba7fd2f869681 (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>
-rw-r--r-- | include/sound/soc-dai.h | 8 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 83 |
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; | |||
100 | struct snd_soc_dai; | 100 | struct snd_soc_dai; |
101 | struct snd_ac97_bus_ops; | 101 | struct snd_ac97_bus_ops; |
102 | 102 | ||
103 | /* Digital Audio Interface registration */ | ||
104 | int snd_soc_register_dai(struct snd_soc_dai *dai); | ||
105 | void snd_soc_unregister_dai(struct snd_soc_dai *dai); | ||
106 | int snd_soc_register_dais(struct snd_soc_dai *dai, size_t count); | ||
107 | void 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.*/ |
104 | int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, | 110 | int 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 | ||
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 | 49 | ||
49 | static int snd_soc_register_card(struct snd_soc_card *card); | 50 | static int snd_soc_register_card(struct snd_soc_card *card); |
50 | static int snd_soc_unregister_card(struct snd_soc_card *card); | 51 | static 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 | */ | ||
2028 | int 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 | } | ||
2047 | EXPORT_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 | */ | ||
2054 | void 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 | } | ||
2062 | EXPORT_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 | */ | ||
2070 | int 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 | |||
2082 | err: | ||
2083 | for (i--; i >= 0; i--) | ||
2084 | snd_soc_unregister_dai(&dai[i]); | ||
2085 | |||
2086 | return ret; | ||
2087 | } | ||
2088 | EXPORT_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 | */ | ||
2096 | void 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 | } | ||
2103 | EXPORT_SYMBOL_GPL(snd_soc_unregister_dais); | ||
2104 | |||
2022 | static int __devinit snd_soc_init(void) | 2105 | static int __devinit snd_soc_init(void) |
2023 | { | 2106 | { |
2024 | #ifdef CONFIG_DEBUG_FS | 2107 | #ifdef CONFIG_DEBUG_FS |