All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: Kuninori Morimoto
	<kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
Cc: Linux-ALSA <alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org>,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Mark Brown
	<broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>,
	Liam Girdwood <lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Simon <horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org>,
	Kuninori Morimoto
	<kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 1/4 v6] ASoC: add .of_xlate_dai_name callback on struct snd_soc_dai_driver
Date: Tue, 19 Feb 2013 13:53:56 -0700	[thread overview]
Message-ID: <5123E664.7090107@wwwdotorg.org> (raw)
In-Reply-To: <871ucjuu7g.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>

On 02/14/2013 02:21 AM, Kuninori Morimoto wrote:
> 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,
> and it needs some kind of .of_xlate function on each driver.
> 
> This patch adds .of_xlate_dai_name callback interface
> on struct snd_soc_dai_driver,
> very basic/common snd_soc_common_of_xlate_dai_name()
> which replace the dai port number into dai name,
> and snd_soc_of_get_port_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.

> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c

> +const char *snd_soc_common_of_xlate_dai_name(struct snd_soc_dai *dai,
> +					const struct of_phandle_args *args)

I assume you expect this to be the standard implementation that many/all
CODECS will use as their of_xlate_dai_name function?

> +	if (dai->id != args->args[0])
> +		return NULL;

This rather assumes that drivers with multiple DAIs will order the list
of DAIs passed to snd_soc_register_dais() in the same order as the
numbering in their device tree binding document. That seems a little
optimistic.

The whole reason for adding an .of_xlate_dai_name function to the DAI
driver was to allow drivers to implement their own translation without
any dependency on ASoC internals, orders of lists of DAIs registered
with ASoC, etc.

As such, I'm not sure that having a standardized implementation of
.of_xlate_dai_name actually even makes sense.

> +	return dai->driver->name;

Surely this should return the DAI name not the DAI driver name?

> +const char *snd_soc_of_get_port_dai_name(struct device_node *of_node,
> +					 const char *prop)
> +{
> +	struct snd_soc_dai *dai;
> +	struct of_phandle_args args;
> +	const char *name;
> +	int ret;
> +
> +	ret = of_parse_phandle_with_args(of_node, prop,
> +					 "#sound-dai-cells", 0, &args);
> +	if (ret)
> +		return NULL;

I suspect returning an int error code would be better. That would allow
you to "return ret" here, which would allow propagating details such as
-EPROBE_DEFERRED.

> +	of_node_put(args.np);
> +
> +	list_for_each_entry(dai, &dai_list, list) {

I think this should iterate over the list of CODEC drivers that are
registered, and then ask the driver to translate from the args to the
DAI name. Here, you're iterating over the list of registered DAIs, which
is something entirely different.

> +		if (dai->dev->of_node != args.np)
> +			continue;
> +
> +		if (dai->driver->of_xlate_dai_name) {
> +			name = dai->driver->of_xlate_dai_name(dai, &args);
> +			if (name)
> +				return name;

This probably also wants to return an integer to differentiate between
e.g. "invalid value" and "no driver found yet".

> +		}
> +	}
> +
> +	return NULL;

If no driver has been registered for the phandle yet, you probably want
to return -EPROBE_DEFERRED here too.

> +}
> +EXPORT_SYMBOL_GPL(snd_soc_of_get_port_dai_name);

  parent reply	other threads:[~2013-02-19 20:53 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-26  6:51 [PATCH 0/5] ASoC: add simple-card DT support Kuninori Morimoto
2012-12-26  6:52 ` [PATCH 1/5] ASoC: add snd_soc_of_parse_daifmt() Kuninori Morimoto
2012-12-26  6:52 ` [PATCH 2/5] ASoC: simple-card: use struct device pointer for dev_xxx() Kuninori Morimoto
2012-12-27 16:51   ` Mark Brown
2012-12-26  6:52 ` [PATCH 3/5] ASoC: simple-card: add asoc_simple_dai_set for initializing Kuninori Morimoto
2012-12-26  6:52 ` [PATCH 4/5] ASoC: simple-card: remove pointless struct asoc_simple_dai_init_info Kuninori Morimoto
2012-12-26  6:53 ` [PATCH 5/5] ASoC: simple-card: add Device Tree support Kuninori Morimoto
2013-01-04 17:49   ` Stephen Warren
2013-01-04 19:37     ` Mark Brown
2013-01-08  0:13       ` Kuninori Morimoto
2013-01-15  2:34       ` [RFC][PATCH 0/2 v2] " Kuninori Morimoto
2013-01-15  2:36         ` [RFC][PATCH 1/2] ASoC: add snd_soc_of_parse_daifmt() for DeviceTree Kuninori Morimoto
     [not found]           ` <87wqvfyxym.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-01-27  3:42             ` Mark Brown
2013-01-29  3:25               ` Kuninori Morimoto
2013-01-28 12:57             ` [alsa-devel] " Bard Shen
2013-01-15  2:40         ` [RFC][PATCH 2/2 v2] ASoC: simple-card: add Device Tree support Kuninori Morimoto
     [not found]           ` <87vcazyxr1.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-01-27  3:59             ` Mark Brown
2013-01-29  1:31               ` Kuninori Morimoto
     [not found]                 ` <87vcag3hcj.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-01-29  1:48                   ` Mark Brown
2013-01-29  2:17                     ` Kuninori Morimoto
2013-01-29 10:00                       ` Kuninori Morimoto
     [not found]                         ` <87obg8z4u4.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-01-29 16:57                           ` Stephen Warren
2013-01-30  5:02                             ` [PATCH 0/2] ASoC: fixup SND_SOC_DAIFMT_GATED/CONT Kuninori Morimoto
2013-01-30  5:03                               ` [PATCH 1/2] ASoC: SND_SOC_DAIFMT_GATED become 0 as default settings Kuninori Morimoto
2013-01-30  5:03                               ` [PATCH 2/2] ASoC: clock gating is decided by bool on snd_soc_of_parse_daifmt() Kuninori Morimoto
2013-01-30 16:39                                 ` Stephen Warren
2013-01-30  8:42                               ` [PATCH 0/2] ASoC: fixup SND_SOC_DAIFMT_GATED/CONT Mark Brown
2013-01-30  9:09                             ` [RFC][PATCH 2/2 v3] ASoC: simple-card: add Device Tree support Kuninori Morimoto
2013-01-30 20:14                               ` Stephen Warren
2013-01-31  0:49                                 ` Kuninori Morimoto
     [not found]                                   ` <877gmuqir2.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-01-31 17:15                                     ` Stephen Warren
     [not found]                                       ` <510AA6CB.3050809-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-01-31 17:20                                         ` Mark Brown
2013-01-31  1:35                                 ` Mark Brown
     [not found]                                   ` <20130131013500.GA4759-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2013-01-31 17:09                                     ` Stephen Warren
     [not found]                                       ` <510AA551.30400-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-01-31 17:11                                         ` Mark Brown
     [not found]                                           ` <20130131171158.GA15376-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2013-01-31 17:17                                             ` Stephen Warren
     [not found]                                               ` <510AA720.9000904-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-01-31 17:21                                                 ` Mark Brown
2013-02-01  1:54                                                   ` Kuninori Morimoto
2013-02-04 22:23                                                     ` Stephen Warren
2013-02-05 15:23                                                       ` Mark Brown
2013-02-01  1:05                                 ` Kuninori Morimoto
2013-02-01  5:19                                   ` [RFC][PATCH 1/2] ASoC: codec_dai_name become option Kuninori Morimoto, Kuninori Morimoto
     [not found]                                     ` <87lib8d31v.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-04 22:26                                       ` Stephen Warren
     [not found]                                         ` <511035A1.6060402-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-05  0:30                                           ` Kuninori Morimoto
2013-02-01  5:20                                   ` [RFC][PATCH 2/2 v4] ASoC: simple-card: add Device Tree support Kuninori Morimoto, Kuninori Morimoto
     [not found]                                   ` <87halw7sij.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-04 22:22                                     ` [RFC][PATCH 2/2 v3] " Stephen Warren
2013-02-05  0:31                                       ` Kuninori Morimoto
     [not found]                                       ` <5110349D.3050308-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-05 10:09                                         ` [RFC][PATCH 0/3 v4] " Kuninori Morimoto
     [not found]                                           ` <87ehgvrs1h.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-05 10:11                                             ` [PATCH 1/3] ASoC: use list_add_tail() instead of list_add() for platform/codec/dai list Kuninori Morimoto
     [not found]                                               ` <87d2wfrryg.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-11 21:26                                                 ` Stephen Warren
2013-02-05 10:11                                             ` [PATCH 2/3] ASoC: add snd_soc_of_get_port_dai_name() Kuninori Morimoto
     [not found]                                               ` <87bobzrry6.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-11 21:34                                                 ` Stephen Warren
2013-02-12  5:37                                                   ` Kuninori Morimoto
     [not found]                                                     ` <87bobqf5yq.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-13 23:33                                                       ` Stephen Warren
     [not found]                                                         ` <511C22E2.60701-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-14  1:16                                                           ` Kuninori Morimoto
2013-02-14  4:37                                                             ` Stephen Warren
2013-02-14  5:14                                                               ` Kuninori Morimoto
     [not found]                                                                 ` <874nhfv5mb.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-14  9:20                                                                   ` [PATCH 0/4 v6] " Kuninori Morimoto
2013-02-14  9:21                                                                     ` [PATCH 1/4 v6] ASoC: add .of_xlate_dai_name callback on struct snd_soc_dai_driver Kuninori Morimoto
2013-02-18  1:45                                                                       ` Kuninori Morimoto
2013-02-19 15:50                                                                       ` Lars-Peter Clausen
2013-02-20  0:50                                                                         ` Kuninori Morimoto
     [not found]                                                                     ` <8738wzuu9g.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-14  9:22                                                                       ` [PATCH 2/4 v6] ASoC: ak4642: enable .of_xlate_dai_name " Kuninori Morimoto
2013-02-14  9:22                                                                       ` [PATCH 3/4 v6] ASoC: fsi: " Kuninori Morimoto
2013-02-14  9:24                                                                       ` [PATCH 4/4 v6] ASoC: simple-card: add Device Tree support Kuninori Morimoto
2013-02-19 15:57                                                                         ` Lars-Peter Clausen
2013-02-20  0:48                                                                           ` Kuninori Morimoto
     [not found]                                                                             ` <87r4kb95f3.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-20 12:17                                                                               ` [alsa-devel] " Lars-Peter Clausen
     [not found]                                                                                 ` <5124BEF5.4040703-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-20 18:02                                                                                   ` Stephen Warren
2013-02-22  2:41                                                                                     ` Kuninori Morimoto
     [not found]                                                                     ` <871ucjuu7g.wl%kuninori.morimoto.gx@renes as.com>
     [not found]                                                                       ` <871ucjuu7g.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-19 20:53                                                                         ` Stephen Warren [this message]
     [not found]                                                                           ` <5123E664.7090107-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-19 21:06                                                                             ` [PATCH 1/4 v6] ASoC: add .of_xlate_dai_name callback on struct snd_soc_dai_driver Stephen Warren
     [not found]                                                                               ` <5123E972.40307-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-20  0:59                                                                                 ` Kuninori Morimoto
2013-02-20 18:13                                                                                   ` Stephen Warren
2013-02-20  0:52                                                                             ` Kuninori Morimoto
     [not found]                                                                     ` <87y5ertfl7.wl%kuninori.morimoto.gx@renes as.com>
     [not found]                                                                       ` <87y5ertfl7.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-19 21:00                                                                         ` [PATCH 3/4 v6] ASoC: fsi: enable .of_xlate_dai_name " Stephen Warren
2013-02-20  1:04                                                                           ` Kuninori Morimoto
2013-02-20 12:03                                                                             ` Lars-Peter Clausen
2013-02-25  8:49                                                                     ` [PATCH 0/5 v7][RFC] ASoC: simple-card DT support Kuninori Morimoto
     [not found]                                                                       ` <87a9qsg4lp.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-25  8:51                                                                         ` [PATCH 1/5 v7][RFC] ASoC: add snd_soc_register_cpu() Kuninori Morimoto
2013-02-27 22:45                                                                           ` Stephen Warren
2013-02-25  8:53                                                                         ` [PATCH 2/5 v7][RFC] ASoC: add .of_xlate_dai_name on snd_soc_cpu_cpu/codec_driver Kuninori Morimoto
2013-02-25  8:56                                                                         ` [PATCH 3/5 v7][RFC] ASoC: simple-card: add Device Tree support Kuninori Morimoto
2013-02-27 23:17                                                                           ` Stephen Warren
2013-02-28  0:53                                                                             ` Kuninori Morimoto
2013-02-25  8:57                                                                         ` [PATCH 4/5 v7][RFC] ASoC: ak4642: add .of_xlate_dai_name support Kuninori Morimoto
2013-02-25  8:57                                                                         ` [PATCH 5/5 v7][RFC] ASoC: fsi: " Kuninori Morimoto
2013-02-27 23:28                                                                           ` Stephen Warren
     [not found]                                                                       ` <877glwg4fb.wl%kuninori.morimoto.gx@renes as.com>
     [not found]                                                                         ` <877glwg4fb.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-27 22:56                                                                           ` [PATCH 2/5 v7][RFC] ASoC: add .of_xlate_dai_name on snd_soc_cpu_cpu/codec_driver Stephen Warren
     [not found]                                                                       ` <874nh0g49j.wl%kuninori.morimoto.gx@renes as.com>
     [not found]                                                                         ` <874nh0g49j.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-27 23:27                                                                           ` [PATCH 4/5 v7][RFC] ASoC: ak4642: add .of_xlate_dai_name support Stephen Warren
     [not found]                                                                       ` <87mwuptgju.wl%kuninori.morimoto.gx@renes as.com>
     [not found]                                                                         ` <87mwuptgju.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-28 19:14                                                                           ` [PATCH 1/5 v7][RFC] ASoC: add snd_soc_register_cpu() Stephen Warren
2013-03-01 20:50                                                                             ` Lars-Peter Clausen
     [not found]                                                                               ` <1362174130.4439.61.camel@loki>
2013-03-02  3:25                                                                                 ` Mark Brown
     [not found]                                                                                   ` <1362426516.4448.68.camel@loki>
2013-03-05  3:05                                                                                     ` Mark Brown
     [not found]                                                                       ` <87lia9tg1r.wl%kuninori.morimoto.gx@renes as.com>
     [not found]                                                                         ` <87lia9tg1r.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-28 19:16                                                                           ` [PATCH 3/5 v7][RFC] ASoC: simple-card: add Device Tree support Stephen Warren
     [not found]                                                                       ` <512E8C99.2040708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-28  0:42                                                                         ` [PATCH 1/5 v7][RFC] ASoC: add snd_soc_register_cpu() Kuninori Morimoto
2013-03-01  9:44                                                                         ` Mark Brown
2013-07-11 14:57                                                                       ` [PATCH 0/5 v7][RFC] ASoC: simple-card DT support Daniel Mack
2013-07-12  0:04                                                                         ` Kuninori Morimoto
2013-02-05 10:12                                             ` [PATCH 3/3 v4] ASoC: simple-card: add Device Tree support Kuninori Morimoto
     [not found]                                               ` <87a9rjrrwt.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-07  0:55                                                 ` [PATCH 3/3 v5] " Kuninori Morimoto
     [not found]                                                   ` <87zjzhymbs.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-11 21:40                                                     ` Stephen Warren
2013-02-12  4:48                                                       ` Kuninori Morimoto
     [not found]                                                         ` <87d2w6f88p.wl%kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org>
2013-02-13 23:30                                                           ` Stephen Warren
     [not found]                                                       ` <51196541.8010207-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-02-13  1:13                                                         ` Kuninori Morimoto
2013-02-13 23:36                                                           ` Stephen Warren
2013-02-06  8:44                                             ` [RFC][PATCH 0/3 v4] " Kuninori Morimoto
2013-01-28 21:11             ` [RFC][PATCH 2/2 v2] " Stephen Warren
     [not found]               ` <5106E98A.6070103-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2013-01-29  1:45                 ` Mark Brown
2013-01-29  2:14               ` Kuninori Morimoto
2013-01-29 16:53                 ` Stephen Warren
2013-01-30  1:09                   ` Kuninori Morimoto
2013-01-25  1:03         ` [RFC][PATCH 0/2 " Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5123E664.7090107@wwwdotorg.org \
    --to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=broonie-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=horms-/R6kz+dDXgpPR4JQBCEnsQ@public.gmane.org \
    --cc=kuninori.morimoto.gx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ@public.gmane.org \
    --cc=lgirdwood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.