ASoC: add .of_xlate_dai_name on snd_soc_component_driver
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Wed, 11 Sep 2013 00:39:56 +0000 (17:39 -0700)
committerMark Brown <broonie@linaro.org>
Tue, 17 Sep 2013 12:07:13 +0000 (13:07 +0100)
ASoC sound driver requires CPU/CODEC drivers for probing,
and each CPU/CODEC has some DAI on it.
Then, "dai name matching" have been used to identify
CPU-CODEC DAI pair on ASoC.

But, the "dai port number matching" is now required from DeviceTree.
The solution of this issue is to replace
the dai port number into dai name.
Now, CPU/CODEC are based on struct snd_soc_component,
and it can care above as common issue.

This patch adds .of_xlate_dai_name callback interface
on struct snd_soc_component_driver,
and snd_soc_of_get_dai_name() which is using .of_xlate_dai_name.

Then, #sound-dai-cells which enables DAI specifier is required
on CPU/CODEC device tree properties.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
include/sound/soc.h
sound/soc/soc-core.c

index 9a81e2e7d6612a6c39489bc4dba939dc26d6331f..1dd7dc5f7d5230b30a19a51dff5c2a9577ed903d 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef __LINUX_SND_SOC_H
 #define __LINUX_SND_SOC_H
 
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
 #include <linux/notifier.h>
@@ -673,6 +674,11 @@ struct snd_soc_cache_ops {
 /* component interface */
 struct snd_soc_component_driver {
        const char *name;
+
+       /* DT */
+       int (*of_xlate_dai_name)(struct snd_soc_component *component,
+                                struct of_phandle_args *args,
+                                const char **dai_name);
 };
 
 struct snd_soc_component {
@@ -1206,6 +1212,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
                                   const char *propname);
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
                                     const char *prefix);
+int snd_soc_of_get_dai_name(struct device_node *of_node,
+                           const char **dai_name);
 
 #include <sound/soc-dai.h>
 
index 014ac10267da147200142817afbfe3c4b4b1d1af..711bd362028d29f0fad5ffcdb579ef56ed1a903a 100644 (file)
@@ -4590,6 +4590,41 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
+int snd_soc_of_get_dai_name(struct device_node *of_node,
+                           const char **dai_name)
+{
+       struct snd_soc_component *pos;
+       struct of_phandle_args args;
+       int ret;
+
+       ret = of_parse_phandle_with_args(of_node, "sound-dai",
+                                        "#sound-dai-cells", 0, &args);
+       if (ret)
+               return ret;
+
+       ret = -EPROBE_DEFER;
+
+       mutex_lock(&client_mutex);
+       list_for_each_entry(pos, &component_list, list) {
+               if (pos->dev->of_node != args.np)
+                       continue;
+
+               if (!pos->driver->of_xlate_dai_name) {
+                       ret = -ENOSYS;
+                       break;
+               }
+
+               ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
+               break;
+       }
+       mutex_unlock(&client_mutex);
+
+       of_node_put(args.np);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name);
+
 static int __init snd_soc_init(void)
 {
 #ifdef CONFIG_DEBUG_FS