Skip to content

Commit

Permalink
ASoC: simple-card: overwrite cpu_dai->fmt with codec_dai->fmt
Browse files Browse the repository at this point in the history
The current simple-card driver separates the daimft for cpu_dai and codec_dai.
So we might get different values for them (0x4003 and 0x1003 for example):

asoc-simple-card sound-cs42888.12: cpu : 2024000.esai / 4003 / 132000000
asoc-simple-card sound-cs42888.12: codec : cs42888 / 1003 / 24576000
asoc-simple-card sound-cs42888.12: cs42888 <-> 2024000.esai mapping ok

This is not allowed at all as we need to keep the DAIFMT settings identical
for both the ends of the link.

Thus this patch fixes it by overwriting the cpu_dai->fmt with codec_dai->fmt
since we defined the DAIFMT_MASTER basing on CODEC at the first place while
the other bits are same.

Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Nicolin Chen authored and Mark Brown committed Mar 18, 2014
1 parent c56c4d7 commit 46c39ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Documentation/devicetree/bindings/sound/simple-card.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ Optional CPU/CODEC subnodes properties:
clock node (= common clock), or "system-clock-frequency"
(if system doens't support common clock)

Note:
* For 'format', 'frame-master', 'bitclock-master', 'bitclock-inversion' and
'frame-inversion', the simple card will use the settings of CODEC for both
CPU and CODEC sides as we need to keep the settings identical for both ends
of the link.

Example:

sound {
Expand Down
20 changes: 14 additions & 6 deletions sound/soc/generic/simple-card.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ static int asoc_simple_card_parse_of(struct device_node *node,
struct device *dev)
{
struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link;
struct asoc_simple_dai *codec_dai = &priv->codec_dai;
struct asoc_simple_dai *cpu_dai = &priv->cpu_dai;
struct device_node *np;
char *name;
unsigned int daifmt;
Expand Down Expand Up @@ -184,7 +186,7 @@ static int asoc_simple_card_parse_of(struct device_node *node,
np = of_get_child_by_name(node, "simple-audio-card,cpu");
if (np) {
ret = asoc_simple_card_sub_parse_of(np, daifmt,
&priv->cpu_dai,
cpu_dai,
&dai_link->cpu_of_node,
&dai_link->cpu_dai_name);
of_node_put(np);
Expand All @@ -197,14 +199,20 @@ static int asoc_simple_card_parse_of(struct device_node *node,
np = of_get_child_by_name(node, "simple-audio-card,codec");
if (np) {
ret = asoc_simple_card_sub_parse_of(np, daifmt,
&priv->codec_dai,
codec_dai,
&dai_link->codec_of_node,
&dai_link->codec_dai_name);
of_node_put(np);
}
if (ret < 0)
return ret;

/*
* overwrite cpu_dai->fmt as its DAIFMT_MASTER bit is based on CODEC
* while the other bits should be identical unless buggy SW/HW design.
*/
cpu_dai->fmt = codec_dai->fmt;

if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name)
return -EINVAL;

Expand All @@ -226,12 +234,12 @@ static int asoc_simple_card_parse_of(struct device_node *node,
dev_dbg(dev, "platform : %04x\n", daifmt);
dev_dbg(dev, "cpu : %s / %04x / %d\n",
dai_link->cpu_dai_name,
priv->cpu_dai.fmt,
priv->cpu_dai.sysclk);
cpu_dai->fmt,
cpu_dai->sysclk);
dev_dbg(dev, "codec : %s / %04x / %d\n",
dai_link->codec_dai_name,
priv->codec_dai.fmt,
priv->codec_dai.sysclk);
codec_dai->fmt,
codec_dai->sysclk);

/*
* soc_bind_dai_link() will check cpu name
Expand Down

0 comments on commit 46c39ca

Please sign in to comment.