Commit 4d4b334b authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: rsnd: add support graph base DT phase 2

To enable OF-graph base DT on rsnd driver, and to keep compatible
previous normal sound card style, it need to support both
"rcar_sound,dai" and "ports" (or "port") on DT.

This patch parses both style.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 11d0f8ed
......@@ -810,45 +810,20 @@ static struct device_node *rsnd_dai_of_node(struct rsnd_priv *priv,
return ret;
}
static int rsnd_dai_probe(struct rsnd_priv *priv)
static void __rsnd_dai_probe(struct rsnd_priv *priv,
struct device_node *dai_np,
int dai_i, int is_graph)
{
struct device_node *dai_node;
struct device_node *dai_np;
struct device_node *playback, *capture;
struct rsnd_dai_stream *io_playback;
struct rsnd_dai_stream *io_capture;
struct snd_soc_dai_driver *rdrv, *drv;
struct snd_soc_dai_driver *drv;
struct rsnd_dai *rdai;
struct device *dev = rsnd_priv_to_dev(priv);
int nr, dai_i, io_i;
int is_graph;
int ret;
dai_node = rsnd_dai_of_node(priv, &is_graph);
nr = of_get_child_count(dai_node);
if (!nr) {
ret = -EINVAL;
goto rsnd_dai_probe_done;
}
rdrv = devm_kzalloc(dev, sizeof(*rdrv) * nr, GFP_KERNEL);
rdai = devm_kzalloc(dev, sizeof(*rdai) * nr, GFP_KERNEL);
if (!rdrv || !rdai) {
ret = -ENOMEM;
goto rsnd_dai_probe_done;
}
int io_i;
priv->rdai_nr = nr;
priv->daidrv = rdrv;
priv->rdai = rdai;
/*
* parse all dai
*/
dai_i = 0;
for_each_child_of_node(dai_node, dai_np) {
rdai = rsnd_rdai_get(priv, dai_i);
drv = rdrv + dai_i;
drv = priv->daidrv + dai_i;
io_playback = &rdai->playback;
io_capture = &rdai->capture;
......@@ -895,19 +870,53 @@ static int rsnd_dai_probe(struct rsnd_priv *priv)
of_node_put(capture);
}
dai_i++;
dev_dbg(dev, "%s (%s/%s)\n", rdai->name,
rsnd_io_to_mod_ssi(io_playback) ? "play" : " -- ",
rsnd_io_to_mod_ssi(io_capture) ? "capture" : " -- ");
}
}
ret = 0;
static int rsnd_dai_probe(struct rsnd_priv *priv)
{
struct device_node *dai_node;
struct device_node *dai_np;
struct snd_soc_dai_driver *rdrv;
struct device *dev = rsnd_priv_to_dev(priv);
struct rsnd_dai *rdai;
int nr;
int is_graph;
int dai_i;
rsnd_dai_probe_done:
of_node_put(dai_node);
dai_node = rsnd_dai_of_node(priv, &is_graph);
if (is_graph)
nr = of_graph_get_endpoint_count(dai_node);
else
nr = of_get_child_count(dai_node);
return ret;
if (!nr)
return -EINVAL;
rdrv = devm_kzalloc(dev, sizeof(*rdrv) * nr, GFP_KERNEL);
rdai = devm_kzalloc(dev, sizeof(*rdai) * nr, GFP_KERNEL);
if (!rdrv || !rdai)
return -ENOMEM;
priv->rdai_nr = nr;
priv->daidrv = rdrv;
priv->rdai = rdai;
/*
* parse all dai
*/
dai_i = 0;
if (is_graph) {
for_each_endpoint_of_node(dai_node, dai_np)
__rsnd_dai_probe(priv, dai_np, dai_i++, is_graph);
} else {
for_each_child_of_node(dai_node, dai_np)
__rsnd_dai_probe(priv, dai_np, dai_i++, is_graph);
}
return 0;
}
/*
......
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