From: Xiubo Li <Li.Xiubo@freescale.com>
To: <lgirdwood@gmail.com>, <broonie@kernel.org>,
<shawn.guo@linaro.org>, <kuninori.morimoto.gx@renesas.com>
Cc: <moinejf@free.fr>, <alsa-devel@alsa-project.org>,
<linux-kernel@vger.kernel.org>, Xiubo Li <Li.Xiubo@freescale.com>
Subject: [PATCH Resend 3/8] ASoC: simple-card: simplify the daifmt code
Date: Thu, 23 Jan 2014 13:02:45 +0800 [thread overview]
Message-ID: <1390453370-29194-4-git-send-email-Li.Xiubo@freescale.com> (raw)
In-Reply-To: <1390453370-29194-1-git-send-email-Li.Xiubo@freescale.com>
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: Xiubo Li <Li.Xiubo@freescale.com>
---
sound/soc/generic/simple-card.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 3b8c9a2..f38e56e 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -24,15 +24,12 @@ struct simple_card_data {
};
static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
- struct asoc_simple_dai *set,
- unsigned int daifmt)
+ struct asoc_simple_dai *set)
{
int ret = 0;
- daifmt |= set->fmt;
-
- if (daifmt) {
- ret = snd_soc_dai_set_fmt(dai, daifmt);
+ if (set->fmt) {
+ ret = snd_soc_dai_set_fmt(dai, set->fmt);
if (ret && ret != -ENOTSUPP) {
dev_err(dai->dev, "simple-card: set_fmt error\n");
return ret;
@@ -56,14 +53,13 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
snd_soc_card_get_drvdata(rtd->card);
struct snd_soc_dai *codec = rtd->codec_dai;
struct snd_soc_dai *cpu = rtd->cpu_dai;
- unsigned int daifmt = priv->daifmt;
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)
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)
return ret;
@@ -72,6 +68,7 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
static int
asoc_simple_card_sub_parse_of(struct device_node *np,
+ unsigned int daifmt,
struct asoc_simple_dai *dai,
const struct device_node **p_node,
const char **name)
@@ -100,6 +97,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
* and specific "format" if it has
*/
dai->fmt = snd_soc_of_parse_daifmt(np, NULL);
+ dai->fmt |= daifmt;
/*
* dai->sysclk come from
@@ -158,7 +156,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
ret = -EINVAL;
np = of_get_child_by_name(node, "simple-audio-card,cpu");
if (np)
- ret = asoc_simple_card_sub_parse_of(np,
+ ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
&priv->cpu_dai,
&dai_link->cpu_of_node,
&dai_link->cpu_dai_name);
@@ -169,7 +167,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
ret = -EINVAL;
np = of_get_child_by_name(node, "simple-audio-card,codec");
if (np)
- ret = asoc_simple_card_sub_parse_of(np,
+ ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
&priv->codec_dai,
&dai_link->codec_of_node,
&dai_link->codec_dai_name);
--
1.8.4
next prev parent reply other threads:[~2014-01-23 6:02 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-23 5:02 [PATCH 0/8] New and Resend the old patches Xiubo Li
2014-01-23 5:02 ` [PATCH 1/8] ASoC: fsl: Add VF610 soc audio card Kconfig Xiubo Li
2014-01-23 18:38 ` Mark Brown
2014-01-26 5:15 ` Li.Xiubo
2014-01-26 12:43 ` Mark Brown
2014-02-10 4:12 ` Li.Xiubo
2014-02-10 12:31 ` Mark Brown
2014-01-23 5:02 ` [PATCH Resend 2/8] ASoC: simple-card: fix __asoc_simple_card_dai_init Xiubo Li
2014-01-23 7:11 ` Jean-Francois Moine
2014-01-23 7:22 ` Li.Xiubo
2014-01-23 5:02 ` Xiubo Li [this message]
2014-01-23 19:20 ` [PATCH Resend 3/8] ASoC: simple-card: simplify the daifmt code Mark Brown
2014-01-24 7:26 ` Li.Xiubo
2014-01-23 5:02 ` [PATCH Resend 4/8] ASoC: simple-card: Add snd_card's name parsing from DT node support Xiubo Li
2014-01-23 19:24 ` Mark Brown
2014-01-23 5:02 ` [PATCH 5/8] ASoC: core: set_tdm_slot() will return -ENOTSUPP if no operation provided Xiubo Li
2014-01-23 19:29 ` Mark Brown
2014-01-23 5:02 ` [PATCH 6/8] ASoC: simple-card: add tdm slot supports Xiubo Li
2014-01-23 6:11 ` David Rientjes
2014-01-23 6:35 ` Li.Xiubo
2014-01-23 19:48 ` Mark Brown
2014-01-23 5:02 ` [PATCH Resend 7/8] ASoC: add snd_soc_of_parse_audio_simple_widgets for DeviceTree Xiubo Li
2014-01-23 19:39 ` Mark Brown
2014-01-24 2:46 ` Li.Xiubo
2014-01-24 13:05 ` Mark Brown
2014-01-23 5:02 ` [PATCH 8/8] ASoC: simple-card: add off-codec widgets supports Xiubo Li
2014-01-23 19:40 ` Mark Brown
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=1390453370-29194-4-git-send-email-Li.Xiubo@freescale.com \
--to=li.xiubo@freescale.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=moinejf@free.fr \
--cc=shawn.guo@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®