aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiubo Li <Li.Xiubo@freescale.com>2014-01-24 02:43:01 -0500
committerMark Brown <broonie@linaro.org>2014-02-03 07:45:34 -0500
commit30d0341e7da0c012f64fb290dd1153360fb49a8d (patch)
tree98e7803eff28a2853262dec730ebde0ca55e27ba
parent4763ebe226156db985fe75bfe930c4069d1f4207 (diff)
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: Xiubo Li <Li.Xiubo@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--sound/soc/generic/simple-card.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 6366f3fa6a37..65833feb995f 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -24,15 +24,12 @@ struct simple_card_data {
24}; 24};
25 25
26static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, 26static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
27 struct asoc_simple_dai *set, 27 struct asoc_simple_dai *set)
28 unsigned int daifmt)
29{ 28{
30 int ret; 29 int ret;
31 30
32 daifmt |= set->fmt; 31 if (set->fmt) {
33 32 ret = snd_soc_dai_set_fmt(dai, set->fmt);
34 if (daifmt) {
35 ret = snd_soc_dai_set_fmt(dai, daifmt);
36 if (ret && ret != -ENOTSUPP) { 33 if (ret && ret != -ENOTSUPP) {
37 dev_err(dai->dev, "simple-card: set_fmt error\n"); 34 dev_err(dai->dev, "simple-card: set_fmt error\n");
38 goto err; 35 goto err;
@@ -59,14 +56,13 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
59 snd_soc_card_get_drvdata(rtd->card); 56 snd_soc_card_get_drvdata(rtd->card);
60 struct snd_soc_dai *codec = rtd->codec_dai; 57 struct snd_soc_dai *codec = rtd->codec_dai;
61 struct snd_soc_dai *cpu = rtd->cpu_dai; 58 struct snd_soc_dai *cpu = rtd->cpu_dai;
62 unsigned int daifmt = priv->daifmt;
63 int ret; 59 int ret;
64 60
65 ret = __asoc_simple_card_dai_init(codec, &priv->codec_dai, daifmt); 61 ret = __asoc_simple_card_dai_init(codec, &priv->codec_dai);
66 if (ret < 0) 62 if (ret < 0)
67 return ret; 63 return ret;
68 64
69 ret = __asoc_simple_card_dai_init(cpu, &priv->cpu_dai, daifmt); 65 ret = __asoc_simple_card_dai_init(cpu, &priv->cpu_dai);
70 if (ret < 0) 66 if (ret < 0)
71 return ret; 67 return ret;
72 68
@@ -75,6 +71,7 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
75 71
76static int 72static int
77asoc_simple_card_sub_parse_of(struct device_node *np, 73asoc_simple_card_sub_parse_of(struct device_node *np,
74 unsigned int daifmt,
78 struct asoc_simple_dai *dai, 75 struct asoc_simple_dai *dai,
79 const struct device_node **p_node, 76 const struct device_node **p_node,
80 const char **name) 77 const char **name)
@@ -103,6 +100,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
103 * and specific "format" if it has 100 * and specific "format" if it has
104 */ 101 */
105 dai->fmt = snd_soc_of_parse_daifmt(np, NULL); 102 dai->fmt = snd_soc_of_parse_daifmt(np, NULL);
103 dai->fmt |= daifmt;
106 104
107 /* 105 /*
108 * dai->sysclk come from 106 * dai->sysclk come from
@@ -161,7 +159,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
161 ret = -EINVAL; 159 ret = -EINVAL;
162 np = of_get_child_by_name(node, "simple-audio-card,cpu"); 160 np = of_get_child_by_name(node, "simple-audio-card,cpu");
163 if (np) 161 if (np)
164 ret = asoc_simple_card_sub_parse_of(np, 162 ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
165 &priv->cpu_dai, 163 &priv->cpu_dai,
166 &dai_link->cpu_of_node, 164 &dai_link->cpu_of_node,
167 &dai_link->cpu_dai_name); 165 &dai_link->cpu_dai_name);
@@ -172,7 +170,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
172 ret = -EINVAL; 170 ret = -EINVAL;
173 np = of_get_child_by_name(node, "simple-audio-card,codec"); 171 np = of_get_child_by_name(node, "simple-audio-card,codec");
174 if (np) 172 if (np)
175 ret = asoc_simple_card_sub_parse_of(np, 173 ret = asoc_simple_card_sub_parse_of(np, priv->daifmt,
176 &priv->codec_dai, 174 &priv->codec_dai,
177 &dai_link->codec_of_node, 175 &dai_link->codec_of_node,
178 &dai_link->codec_dai_name); 176 &dai_link->codec_dai_name);