aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2013-09-10 20:39:56 -0400
committerMark Brown <broonie@linaro.org>2013-09-17 08:07:13 -0400
commitcb470087669a3fab1958fec79dd7db280b33f178 (patch)
tree695f7c4d498fcff11d28285c1f5ea1642d903a81
parentd191bd8de8c61619563f2b19f1fdcc0944ff1a72 (diff)
ASoC: add .of_xlate_dai_name on snd_soc_component_driver
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>
-rw-r--r--include/sound/soc.h8
-rw-r--r--sound/soc/soc-core.c35
2 files changed, 43 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9a81e2e7d661..1dd7dc5f7d52 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -13,6 +13,7 @@
13#ifndef __LINUX_SND_SOC_H 13#ifndef __LINUX_SND_SOC_H
14#define __LINUX_SND_SOC_H 14#define __LINUX_SND_SOC_H
15 15
16#include <linux/of.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/types.h> 18#include <linux/types.h>
18#include <linux/notifier.h> 19#include <linux/notifier.h>
@@ -673,6 +674,11 @@ struct snd_soc_cache_ops {
673/* component interface */ 674/* component interface */
674struct snd_soc_component_driver { 675struct snd_soc_component_driver {
675 const char *name; 676 const char *name;
677
678 /* DT */
679 int (*of_xlate_dai_name)(struct snd_soc_component *component,
680 struct of_phandle_args *args,
681 const char **dai_name);
676}; 682};
677 683
678struct snd_soc_component { 684struct snd_soc_component {
@@ -1206,6 +1212,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
1206 const char *propname); 1212 const char *propname);
1207unsigned int snd_soc_of_parse_daifmt(struct device_node *np, 1213unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
1208 const char *prefix); 1214 const char *prefix);
1215int snd_soc_of_get_dai_name(struct device_node *of_node,
1216 const char **dai_name);
1209 1217
1210#include <sound/soc-dai.h> 1218#include <sound/soc-dai.h>
1211 1219
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 014ac10267da..711bd362028d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4590,6 +4590,41 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
4590} 4590}
4591EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); 4591EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
4592 4592
4593int snd_soc_of_get_dai_name(struct device_node *of_node,
4594 const char **dai_name)
4595{
4596 struct snd_soc_component *pos;
4597 struct of_phandle_args args;
4598 int ret;
4599
4600 ret = of_parse_phandle_with_args(of_node, "sound-dai",
4601 "#sound-dai-cells", 0, &args);
4602 if (ret)
4603 return ret;
4604
4605 ret = -EPROBE_DEFER;
4606
4607 mutex_lock(&client_mutex);
4608 list_for_each_entry(pos, &component_list, list) {
4609 if (pos->dev->of_node != args.np)
4610 continue;
4611
4612 if (!pos->driver->of_xlate_dai_name) {
4613 ret = -ENOSYS;
4614 break;
4615 }
4616
4617 ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
4618 break;
4619 }
4620 mutex_unlock(&client_mutex);
4621
4622 of_node_put(args.np);
4623
4624 return ret;
4625}
4626EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name);
4627
4593static int __init snd_soc_init(void) 4628static int __init snd_soc_init(void)
4594{ 4629{
4595#ifdef CONFIG_DEBUG_FS 4630#ifdef CONFIG_DEBUG_FS