Commit 30d0341e authored by Xiubo Li's avatar Xiubo Li Committed by Mark Brown

ASoC: simple-card: simplify the daifmt code

In the asoc_simple_card_parse_of() will parse the device node's CPU/CODEC
DAI commone fmts, and then in asoc_simple_card_sub_parse_of() will parse
the CPU/CODEC DAI's sub-node fmts, so we can combine the info->daifmt and
info->set.fmt in asoc_simple_card_sub_parse_of() not while just before
_set_fmt().

And this will be more easy to add new functions, such as supporting
_set_tdm_slot(), etc.
Signed-off-by: default avatarXiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 4763ebe2
...@@ -24,15 +24,12 @@ struct simple_card_data { ...@@ -24,15 +24,12 @@ struct simple_card_data {
}; };
static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
struct asoc_simple_dai *set, struct asoc_simple_dai *set)
unsigned int daifmt)
{ {
int ret; int ret;
daifmt |= set->fmt; if (set->fmt) {
ret = snd_soc_dai_set_fmt(dai, set->fmt);
if (daifmt) {
ret = snd_soc_dai_set_fmt(dai, daifmt);
if (ret && ret != -ENOTSUPP) { if (ret && ret != -ENOTSUPP) {
dev_err(dai->dev, "simple-card: set_fmt error\n"); dev_err(dai->dev, "simple-card: set_fmt error\n");
goto err; goto err;
...@@ -59,14 +56,13 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) ...@@ -59,14 +56,13 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
snd_soc_card_get_drvdata(rtd->card); snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *codec = rtd->codec_dai; struct snd_soc_dai *codec = rtd->codec_dai;
struct snd_soc_dai *cpu = rtd->cpu_dai; struct snd_soc_dai *cpu = rtd->cpu_dai;
unsigned int daifmt = priv->daifmt;
int ret; int ret;
ret = __asoc_simple_card_dai_init(codec, &priv->codec_dai, daifmt); ret = __asoc_simple_card_dai_init(codec, &priv->codec_dai);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = __asoc_simple_card_dai_init(cpu, &priv->cpu_dai, daifmt); ret = __asoc_simple_card_dai_init(cpu, &priv->cpu_dai);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -75,6 +71,7 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) ...@@ -75,6 +71,7 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
static int static int
asoc_simple_card_sub_parse_of(struct device_node *np, asoc_simple_card_sub_parse_of(struct device_node *np,
unsigned int daifmt,
struct asoc_simple_dai *dai, struct asoc_simple_dai *dai,
const struct device_node **p_node, const struct device_node **p_node,
const char **name) const char **name)
...@@ -103,6 +100,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, ...@@ -103,6 +100,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
* and specific "format" if it has * and specific "format" if it has
*/ */
dai->fmt = snd_soc_of_parse_daifmt(np, NULL); dai->fmt = snd_soc_of_parse_daifmt(np, NULL);
dai->fmt |= daifmt;
/* /*
* dai->sysclk come from * dai->sysclk come from
...@@ -161,7 +159,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, ...@@ -161,7 +159,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
ret = -EINVAL; ret = -EINVAL;
np = of_get_child_by_name(node, "simple-audio-card,cpu"); np = of_get_child_by_name(node, "simple-audio-card,cpu");
if (np) if (np)
ret = asoc_simple_card_sub_parse_of(np, ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
&priv->cpu_dai, &priv->cpu_dai,
&dai_link->cpu_of_node, &dai_link->cpu_of_node,
&dai_link->cpu_dai_name); &dai_link->cpu_dai_name);
...@@ -172,7 +170,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, ...@@ -172,7 +170,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
ret = -EINVAL; ret = -EINVAL;
np = of_get_child_by_name(node, "simple-audio-card,codec"); np = of_get_child_by_name(node, "simple-audio-card,codec");
if (np) if (np)
ret = asoc_simple_card_sub_parse_of(np, ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
&priv->codec_dai, &priv->codec_dai,
&dai_link->codec_of_node, &dai_link->codec_of_node,
&dai_link->codec_dai_name); &dai_link->codec_dai_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment