aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-04-27 13:16:32 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-04-27 17:33:11 -0400
commit848dd8beef44df18f2eb61e00981b0692adb801b (patch)
treec860d13902c98fab86390e7b29027c063ffc3af5
parent8842c72afe9f954d9462da577a25d4a32bfe0a2b (diff)
ASoC: Add more natural support for no-DMA DAIs
Since we can now support multiple platforms allow machines to not specify a platform in a DAI link. Since the rest of the code requires that we have a struct device for all objects we do this by substituting in a dummy device that we register automatically. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Jassi Brar <jassisinghbrar@gmail.com> Acked-by: Liam Girdwood <lrg@ti.com>
-rw-r--r--sound/soc/soc-core.c16
-rw-r--r--sound/soc/soc-utils.c55
2 files changed, 66 insertions, 5 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 9dc13113fa26..16be3e5cf9e7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1299,6 +1299,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
1299 struct snd_soc_codec *codec; 1299 struct snd_soc_codec *codec;
1300 struct snd_soc_platform *platform; 1300 struct snd_soc_platform *platform;
1301 struct snd_soc_dai *codec_dai, *cpu_dai; 1301 struct snd_soc_dai *codec_dai, *cpu_dai;
1302 const char *platform_name;
1302 1303
1303 if (rtd->complete) 1304 if (rtd->complete)
1304 return 1; 1305 return 1;
@@ -1351,13 +1352,18 @@ find_codec:
1351 dai_link->codec_name); 1352 dai_link->codec_name);
1352 1353
1353find_platform: 1354find_platform:
1354 /* do we already have the CODEC DAI for this link ? */ 1355 /* do we need a platform? */
1355 if (rtd->platform) { 1356 if (rtd->platform)
1356 goto out; 1357 goto out;
1357 } 1358
1358 /* no, then find CPU DAI from registered DAIs*/ 1359 /* if there's no platform we match on the empty platform */
1360 platform_name = dai_link->platform_name;
1361 if (!platform_name)
1362 platform_name = "snd-soc-dummy";
1363
1364 /* no, then find one from the set of registered platforms */
1359 list_for_each_entry(platform, &platform_list, list) { 1365 list_for_each_entry(platform, &platform_list, list) {
1360 if (!strcmp(platform->name, dai_link->platform_name)) { 1366 if (!strcmp(platform->name, platform_name)) {
1361 rtd->platform = platform; 1367 rtd->platform = platform;
1362 goto out; 1368 goto out;
1363 } 1369 }
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
index 3f45e6a439bf..286579140882 100644
--- a/sound/soc/soc-utils.c
+++ b/sound/soc/soc-utils.c
@@ -13,6 +13,7 @@
13 * option) any later version. 13 * option) any later version.
14 */ 14 */
15 15
16#include <linux/platform_device.h>
16#include <sound/core.h> 17#include <sound/core.h>
17#include <sound/pcm.h> 18#include <sound/pcm.h>
18#include <sound/pcm_params.h> 19#include <sound/pcm_params.h>
@@ -55,3 +56,57 @@ int snd_soc_params_to_bclk(struct snd_pcm_hw_params *params)
55 return ret; 56 return ret;
56} 57}
57EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk); 58EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk);
59
60static struct snd_soc_platform_driver dummy_platform;
61
62static __devinit int snd_soc_dummy_probe(struct platform_device *pdev)
63{
64 return snd_soc_register_platform(&pdev->dev, &dummy_platform);
65}
66
67static __devexit int snd_soc_dummy_remove(struct platform_device *pdev)
68{
69 snd_soc_unregister_platform(&pdev->dev);
70
71 return 0;
72}
73
74static struct platform_driver soc_dummy_driver = {
75 .driver = {
76 .name = "snd-soc-dummy",
77 .owner = THIS_MODULE,
78 },
79 .probe = snd_soc_dummy_probe,
80 .remove = __devexit_p(snd_soc_dummy_remove),
81};
82
83static struct platform_device *soc_dummy_dev;
84
85static int __init snd_soc_util_init(void)
86{
87 int ret;
88
89 soc_dummy_dev = platform_device_alloc("snd-soc-dummy", -1);
90 if (!soc_dummy_dev)
91 return -ENOMEM;
92
93 ret = platform_device_add(soc_dummy_dev);
94 if (ret != 0) {
95 platform_device_put(soc_dummy_dev);
96 return ret;
97 }
98
99 ret = platform_driver_register(&soc_dummy_driver);
100 if (ret != 0)
101 platform_device_unregister(soc_dummy_dev);
102
103 return ret;
104}
105module_init(snd_soc_util_init);
106
107static void __exit snd_soc_util_exit(void)
108{
109 platform_device_unregister(soc_dummy_dev);
110 platform_driver_unregister(&soc_dummy_driver);
111}
112module_exit(snd_soc_util_exit);