Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Liam Girdwood <lrg@ti.com>, Simon <horms@verge.net.au>,
	Kuninori Morimoto <kuninori.morimoto.gx@gmail.com>
Subject: Re: [RFC][PATCH 1/2] ASoC: add snd_soc_of_parse_daifmt()
Date: Wed, 28 Nov 2012 22:21:59 -0700	[thread overview]
Message-ID: <50B6F0F7.1050902@wwwdotorg.org> (raw)
In-Reply-To: <87sj7thvwy.wl%kuninori.morimoto.gx@renesas.com>

On 11/28/2012 09:31 PM, Kuninori Morimoto wrote:
> ALSA SoC system is using SND_SOC_DAIFMT_xxx flags on each platform,
> and its value might be updated for some reason.
> This means that if platform is using Device Tree
> and if it gets parameter value directly,
> it is difficult to keep compatible on each platform Device Tree.
> This patch adds snd_soc_of_parse_daifmt() to solve this issue.
> Each platform can use [prefix]snd,soc,daifmt,xxx to set
> SND_SOC_DAIFMT_XXX on Device Tree.

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

> +static int __snd_soc_of_parse_daifmt(struct device_node *np,
> +				     const char *prefix, unsigned int *fmt,
> +				     const char *propname, unsigned int val)
> +{
> +	char str[128];
> +	int ret;
> +
> +	snprintf(str, 128, "%ssnd,soc,daifmt,%s", prefix, propname);
> +	ret = of_property_read_bool(np, str);
> +	if (ret)
> +		*fmt |= val;
> +
> +	return ret;
> +}
> +
> +int snd_soc_of_parse_daifmt(struct device_node *np,
> +			    const char *prefix, unsigned int *fmt)
> +{
> +	int ret = 0;
> +	char pre[] = "";
> +
> +	if (!prefix)
> +		prefix = pre;
> +
> +	/*
> +	 * it will find "[prefix]snd,soc,daifmt,xxx" from device_node,
> +	 * and set SND_SOC_DAIFMT_XXX
> +	 */
> +	ret |= __snd_soc_of_parse_daifmt(np, prefix, fmt,
> +					 "i2s", SND_SOC_DAIFMT_I2S);
> +	ret |= __snd_soc_of_parse_daifmt(np, prefix, fmt,
> +					 "right_j", SND_SOC_DAIFMT_RIGHT_J);
> +	ret |= __snd_soc_of_parse_daifmt(np, prefix, fmt,
> +					 "left_j", SND_SOC_DAIFMT_LEFT_J);
...

I think it'd be more typical to represent as a single integer property,
where the value is an enumeration indicating the type.

But isn't there a lot more to the DAI format than just the format enum
itself?

  reply	other threads:[~2012-11-29  5:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-29  4:31 [RFC][PATCH 0/2] ASoC: add DT support on simple-card Kuninori Morimoto
2012-11-29  4:31 ` [RFC][PATCH 1/2] ASoC: add snd_soc_of_parse_daifmt() Kuninori Morimoto
2012-11-29  5:21   ` Stephen Warren [this message]
2012-11-29 15:12     ` Mark Brown
2012-11-30  0:35     ` Kuninori Morimoto
2012-12-04 20:18       ` Stephen Warren
2012-12-05  7:55         ` Kuninori Morimoto
2012-12-05 20:42           ` Stephen Warren
2012-12-06  9:02             ` Kuninori Morimoto
2012-11-29  4:32 ` [RFC][PATCH 2/2] ASoC: simple-card: add DT support Kuninori Morimoto
2012-11-29  5:20   ` Stephen Warren
2012-11-29  6:05     ` Kuninori Morimoto
2012-11-30 10:38   ` Daniel Mack
2012-12-03  0:18     ` 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=50B6F0F7.1050902@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=horms@verge.net.au \
    --cc=kuninori.morimoto.gx@gmail.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lrg@ti.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox