diff mbox

[02/13] ASoC: core: add snd_soc_get_dai_info() to get driver infomation

Message ID 871tktsnea.wl%kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kuninori Morimoto March 13, 2015, 1:21 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Sometimes sound card driver want to get cpu/codec driver information.
This patch adds snd_soc_get_dai_info() and enable it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc.h  |  3 +++
 sound/soc/soc-core.c | 29 ++++++++++++++++++++++++-----
 2 files changed, 27 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 235db71..709f058 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1505,6 +1505,9 @@  unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 				     const char *prefix,
 				     struct device_node **bitclkmaster,
 				     struct device_node **framemaster);
+int snd_soc_get_dai_info(struct of_phandle_args *args,
+			 struct snd_soc_component **cmpnt,
+			 struct snd_soc_dai_driver **dai_drv);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name);
 int snd_soc_of_get_dai_link_codecs(struct device *dev,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 3a68f13..5b01505 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3454,8 +3454,9 @@  unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt);
 
-static int snd_soc_get_dai_name(struct of_phandle_args *args,
-				const char **dai_name)
+int snd_soc_get_dai_info(struct of_phandle_args *args,
+			 struct snd_soc_component **cmpnt,
+			 struct snd_soc_dai_driver **dai_drv)
 {
 	struct snd_soc_component *pos;
 	int ret = -EPROBE_DEFER;
@@ -3486,15 +3487,33 @@  static int snd_soc_get_dai_name(struct of_phandle_args *args,
 
 		ret = 0;
 
-		*dai_name = pos->dai_drv[id].name;
-		if (!*dai_name)
-			*dai_name = pos->name;
+		*cmpnt = pos;
+		*dai_drv = pos->dai_drv + id;
 
 		break;
 	}
 	mutex_unlock(&client_mutex);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(snd_soc_get_dai_info);
+
+static int snd_soc_get_dai_name(struct of_phandle_args *args,
+				const char **dai_name)
+{
+	struct snd_soc_component *cmpnt;
+	struct snd_soc_dai_driver *dai_drv;
+	int ret;
+
+	ret = snd_soc_get_dai_info(args, &cmpnt, &dai_drv);
+	if (ret)
+		return ret;
+
+	*dai_name = dai_drv->name;
+	if (!*dai_name)
+		*dai_name = cmpnt->name;
+
+	return ret;
+}
 
 int snd_soc_of_get_dai_name(struct device_node *of_node,
 			    const char **dai_name)