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: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Kuninori Morimoto 2017-05-18 01:28:06 +00:00 коммит произвёл Mark Brown
Родитель 11d0f8ed6d
Коммит 4d4b334bda
1 изменённых файлов: 85 добавлений и 76 удалений

Просмотреть файл

@ -810,45 +810,20 @@ of_node_compatible:
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;
int io_i;
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;
}
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" : " -- ");
}
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;
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);
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);
}
ret = 0;
rsnd_dai_probe_done:
of_node_put(dai_node);
return ret;
return 0;
}
/*