[alsa-devel] [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Tue Oct 15 05:32:28 CEST 2013
Current snd_soc_of_get_dai_name() needs .of_xlate_dai_name()
callback on each component drivers.
But required behavior on almost all these drivers is
just returns its indexed dai driver's name.
This patch adds this feature as default behavior.
.of_xlate_dai_name() can overwrite it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
This is RFC patch.
On ML discussed that snd_soc_of_get_dai_name() needs .of_xlate_dai_name
to get/exchange device name from device node ID.
But, almost all driver's .of_xlate_dai_name will
be same implementation. (return name of indexed dai driver)
So, this patch adds it as default behavior.
.of_xlate_dai_name() can over write it.
This patch is based on mark/topic/component
include/sound/soc.h | 4 +++-
sound/soc/soc-core.c | 16 ++++++++++++----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 1dd7dc5..ae715ca 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -684,10 +684,12 @@ struct snd_soc_component_driver {
struct snd_soc_component {
const char *name;
int id;
- int num_dai;
struct device *dev;
struct list_head list;
+ struct snd_soc_dai_driver *dai_drv;
+ int num_dai;
+
const struct snd_soc_component_driver *driver;
};
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 711bd36..51ea2c3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -4048,6 +4048,7 @@ __snd_soc_register_component(struct device *dev,
cmpnt->dev = dev;
cmpnt->driver = cmpnt_drv;
+ cmpnt->dai_drv = dai_drv;
cmpnt->num_dai = num_dai;
/*
@@ -4609,12 +4610,19 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
if (pos->dev->of_node != args.np)
continue;
- if (!pos->driver->of_xlate_dai_name) {
- ret = -ENOSYS;
- break;
+ if (pos->driver->of_xlate_dai_name) {
+ ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
+ } else {
+ int id = args.args[0];
+
+ if (id < 0 || id >= pos->num_dai) {
+ ret = -EINVAL;
+ } else {
+ *dai_name = pos->dai_drv[id].name;
+ ret = 0;
+ }
}
- ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
break;
}
mutex_unlock(&client_mutex);
--
1.7.9.5
More information about the Alsa-devel
mailing list