[alsa-devel] [RFC][PATCH 1/2] ASoC: add snd_soc_of_parse_daifmt()
Stephen Warren
swarren at wwwdotorg.org
Thu Nov 29 06:21:59 CET 2012
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?
More information about the Alsa-devel
mailing list