* [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name()
@ 2013-10-15 3:32 Kuninori Morimoto
2013-10-16 9:09 ` Lars-Peter Clausen
0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2013-10-15 3:32 UTC (permalink / raw)
To: Mark Brown, Lars-Peter Clausen
Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto
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@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name()
2013-10-15 3:32 [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name() Kuninori Morimoto
@ 2013-10-16 9:09 ` Lars-Peter Clausen
2013-10-17 3:12 ` Kuninori Morimoto
0 siblings, 1 reply; 5+ messages in thread
From: Lars-Peter Clausen @ 2013-10-16 9:09 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Linux-ALSA, Mark Brown, Liam Girdwood, Simon, Kuninori Morimoto
On 10/15/2013 05:32 AM, Kuninori Morimoto wrote:
> 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@renesas.com>
I'm not exactly sure if adding the dai_drv field to the component struct is
the right approach. But it doesn't look to intrusive and could be removed
again at some point, if it turns out there is a better way to do this.
[...]
> 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];
You should check that args.args_count is 1. And maybe also allow args_count
to be 0 if the number of DAIs is 1.
> +
> + 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);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name()
2013-10-16 9:09 ` Lars-Peter Clausen
@ 2013-10-17 3:12 ` Kuninori Morimoto
2013-10-17 5:05 ` [PATCH v2] ASoC: add snd_soc_of_get_dai_name() default of_xlate Kuninori Morimoto
0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2013-10-17 3:12 UTC (permalink / raw)
To: Lars-Peter Clausen
Cc: Linux-ALSA, Mark Brown, Liam Girdwood, Simon, Kuninori Morimoto
Hi Lars
Thank you for checking patch
> > 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@renesas.com>
>
> I'm not exactly sure if adding the dai_drv field to the component struct is
> the right approach. But it doesn't look to intrusive and could be removed
> again at some point, if it turns out there is a better way to do this.
Thank you
> > @@ -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];
>
> You should check that args.args_count is 1. And maybe also allow args_count
> to be 0 if the number of DAIs is 1.
I see
I will send v2 patch soon
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] ASoC: add snd_soc_of_get_dai_name() default of_xlate
2013-10-17 3:12 ` Kuninori Morimoto
@ 2013-10-17 5:05 ` Kuninori Morimoto
2013-10-17 23:43 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Kuninori Morimoto @ 2013-10-17 5:05 UTC (permalink / raw)
To: Lars-Peter Clausen, Mark Brown
Cc: Linux-ALSA, Simon, Liam Girdwood, Kuninori Morimoto
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 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@renesas.com>
---
v1 -> v2
- added args.args_count check
include/sound/soc.h | 4 +++-
sound/soc/soc-core.c | 28 ++++++++++++++++++++++++----
2 files changed, 27 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..07c7436 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,31 @@ 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 = -1;
+
+ switch (args.args_count) {
+ case 0:
+ id = 0; /* same as dai_drv[0] */
+ break;
+ case 1:
+ id = args.args[0];
+ break;
+ default:
+ /* not supported */
+ break;
+ }
+
+ 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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] ASoC: add snd_soc_of_get_dai_name() default of_xlate
2013-10-17 5:05 ` [PATCH v2] ASoC: add snd_soc_of_get_dai_name() default of_xlate Kuninori Morimoto
@ 2013-10-17 23:43 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-10-17 23:43 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Linux-ALSA, Lars-Peter Clausen, Liam Girdwood, Simon,
Kuninori Morimoto
[-- Attachment #1.1: Type: text/plain, Size: 283 bytes --]
On Wed, Oct 16, 2013 at 10:05:26PM -0700, Kuninori Morimoto wrote:
> 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 driver's name.
Applied, thanks.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-17 23:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15 3:32 [PATCH][RFC] ASoC: add default xlate on snd_soc_of_get_dai_name() Kuninori Morimoto
2013-10-16 9:09 ` Lars-Peter Clausen
2013-10-17 3:12 ` Kuninori Morimoto
2013-10-17 5:05 ` [PATCH v2] ASoC: add snd_soc_of_get_dai_name() default of_xlate Kuninori Morimoto
2013-10-17 23:43 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).