Commit d4c22094 authored by Xiubo Li's avatar Xiubo Li Committed by Mark Brown

ASoC: simple-card: Add DAPM routes parse from device tree

Parses a simple DAPM route table from device tree.
Signed-off-by: default avatarXiubo Li <Li.Xiubo@freescale.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent e1acb40a
...@@ -9,8 +9,13 @@ Required properties: ...@@ -9,8 +9,13 @@ Required properties:
Optional properties: Optional properties:
- simple-audio-card,format : CPU/CODEC common audio format. - simple-audio-card,format : CPU/CODEC common audio format.
"i2s", "right_j", "left_j" , "dsp_a" "i2s", "right_j", "left_j" , "dsp_a"
"dsp_b", "ac97", "pdm", "msb", "lsb" "dsp_b", "ac97", "pdm", "msb", "lsb"
- simple-audio-routing : A list of the connections between audio components.
Each entry is a pair of strings, the first being the
connection's sink, the second being the connection's
source.
Required subnodes: Required subnodes:
- simple-audio-card,cpu : CPU sub-node - simple-audio-card,cpu : CPU sub-node
...@@ -38,6 +43,10 @@ Example: ...@@ -38,6 +43,10 @@ Example:
sound { sound {
compatible = "simple-audio-card"; compatible = "simple-audio-card";
simple-audio-card,format = "left_j"; simple-audio-card,format = "left_j";
simple-audio-routing =
"MIC_IN", "Mic Jack",
"Headphone Jack", "HP_OUT",
"Ext Spk", "LINE_OUT";
simple-audio-card,cpu { simple-audio-card,cpu {
sound-dai = <&sh_fsi2 0>; sound-dai = <&sh_fsi2 0>;
......
...@@ -116,12 +116,18 @@ static int asoc_simple_card_parse_of(struct device_node *node, ...@@ -116,12 +116,18 @@ static int asoc_simple_card_parse_of(struct device_node *node,
{ {
struct device_node *np; struct device_node *np;
char *name; char *name;
int ret = 0; int ret;
/* get CPU/CODEC common format via simple-audio-card,format */ /* get CPU/CODEC common format via simple-audio-card,format */
info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") & info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
(SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK); (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK);
/* DAPM routes */
ret = snd_soc_of_parse_audio_routing(&info->snd_card,
"simple-audio-routing");
if (ret)
return ret;
/* CPU sub-node */ /* CPU sub-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");
...@@ -182,6 +188,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) ...@@ -182,6 +188,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
if (cinfo) { if (cinfo) {
int ret; int ret;
cinfo->snd_card.dev = &pdev->dev;
ret = asoc_simple_card_parse_of(np, cinfo, dev, ret = asoc_simple_card_parse_of(np, cinfo, dev,
&of_cpu, &of_cpu,
&of_codec, &of_codec,
...@@ -193,6 +200,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev) ...@@ -193,6 +200,7 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
} }
} }
} else { } else {
cinfo->snd_card.dev = &pdev->dev;
cinfo = pdev->dev.platform_data; cinfo = pdev->dev.platform_data;
} }
...@@ -232,7 +240,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev) ...@@ -232,7 +240,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
cinfo->snd_card.owner = THIS_MODULE; cinfo->snd_card.owner = THIS_MODULE;
cinfo->snd_card.dai_link = &cinfo->snd_link; cinfo->snd_card.dai_link = &cinfo->snd_link;
cinfo->snd_card.num_links = 1; cinfo->snd_card.num_links = 1;
cinfo->snd_card.dev = &pdev->dev;
return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card); return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card);
} }
......
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