ASoC: audio-graph: add graph_link_init()
This patch adds graph_link_init() and share dai_link setting code. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87eef4i41k.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
8859f809c7
commit
e51237b8d3
1 changed files with 33 additions and 37 deletions
|
@ -247,6 +247,29 @@ static int graph_parse_node(struct asoc_simple_priv *priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int graph_link_init(struct asoc_simple_priv *priv,
|
||||||
|
struct device_node *cpu_ep,
|
||||||
|
struct device_node *codec_ep,
|
||||||
|
struct link_info *li,
|
||||||
|
char *name)
|
||||||
|
{
|
||||||
|
struct device *dev = simple_priv_to_dev(priv);
|
||||||
|
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep,
|
||||||
|
NULL, &dai_link->dai_fmt);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
dai_link->init = asoc_simple_dai_init;
|
||||||
|
dai_link->ops = &graph_ops;
|
||||||
|
if (priv->ops)
|
||||||
|
dai_link->ops = priv->ops;
|
||||||
|
|
||||||
|
return asoc_simple_set_dailink_name(dev, dai_link, name);
|
||||||
|
}
|
||||||
|
|
||||||
static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
|
static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
|
||||||
struct device_node *cpu_ep,
|
struct device_node *cpu_ep,
|
||||||
struct device_node *codec_ep,
|
struct device_node *codec_ep,
|
||||||
|
@ -262,6 +285,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
|
||||||
struct device_node *ports;
|
struct device_node *ports;
|
||||||
struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0);
|
struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0);
|
||||||
struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0);
|
struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0);
|
||||||
|
char dai_name[64];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
port = of_get_parent(ep);
|
port = of_get_parent(ep);
|
||||||
|
@ -280,13 +304,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_put_node;
|
goto out_put_node;
|
||||||
|
|
||||||
ret = asoc_simple_set_dailink_name(dev, dai_link,
|
snprintf(dai_name, sizeof(dai_name),
|
||||||
"fe.%pOFP.%s",
|
"fe.%pOFP.%s", cpus->of_node, cpus->dai_name);
|
||||||
cpus->of_node,
|
|
||||||
cpus->dai_name);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out_put_node;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In BE<->BE connections it is not required to create
|
* In BE<->BE connections it is not required to create
|
||||||
* PCM devices at CPU end of the dai link and thus 'no_pcm'
|
* PCM devices at CPU end of the dai link and thus 'no_pcm'
|
||||||
|
@ -314,12 +333,8 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out_put_node;
|
goto out_put_node;
|
||||||
|
|
||||||
ret = asoc_simple_set_dailink_name(dev, dai_link,
|
snprintf(dai_name, sizeof(dai_name),
|
||||||
"be.%pOFP.%s",
|
"be.%pOFP.%s", codecs->of_node, codecs->dai_name);
|
||||||
codecs->of_node,
|
|
||||||
codecs->dai_name);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out_put_node;
|
|
||||||
|
|
||||||
/* check "prefix" from top node */
|
/* check "prefix" from top node */
|
||||||
snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node,
|
snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node,
|
||||||
|
@ -332,20 +347,9 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
|
||||||
|
|
||||||
graph_parse_convert(dev, ep, &dai_props->adata);
|
graph_parse_convert(dev, ep, &dai_props->adata);
|
||||||
|
|
||||||
ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep,
|
|
||||||
NULL, &dai_link->dai_fmt);
|
|
||||||
if (ret < 0)
|
|
||||||
goto out_put_node;
|
|
||||||
|
|
||||||
snd_soc_dai_link_set_capabilities(dai_link);
|
snd_soc_dai_link_set_capabilities(dai_link);
|
||||||
|
|
||||||
dai_link->ops = &graph_ops;
|
ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name);
|
||||||
|
|
||||||
/* Use custom snd_soc_ops callbacks if available */
|
|
||||||
if (priv->ops)
|
|
||||||
dai_link->ops = priv->ops;
|
|
||||||
|
|
||||||
dai_link->init = asoc_simple_dai_init;
|
|
||||||
|
|
||||||
out_put_node:
|
out_put_node:
|
||||||
li->link++;
|
li->link++;
|
||||||
|
@ -364,15 +368,11 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
|
||||||
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
|
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
|
||||||
struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0);
|
struct snd_soc_dai_link_component *cpus = asoc_link_to_cpu(dai_link, 0);
|
||||||
struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0);
|
struct snd_soc_dai_link_component *codecs = asoc_link_to_codec(dai_link, 0);
|
||||||
|
char dai_name[64];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
dev_dbg(dev, "link_of (%pOF)\n", cpu_ep);
|
dev_dbg(dev, "link_of (%pOF)\n", cpu_ep);
|
||||||
|
|
||||||
ret = asoc_simple_parse_daifmt(dev, cpu_ep, codec_ep,
|
|
||||||
NULL, &dai_link->dai_fmt);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = graph_parse_node(priv, cpu_ep, li, 1);
|
ret = graph_parse_node(priv, cpu_ep, li, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -381,16 +381,12 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = asoc_simple_set_dailink_name(dev, dai_link,
|
snprintf(dai_name, sizeof(dai_name),
|
||||||
"%s-%s",
|
"%s-%s", cpus->dai_name, codecs->dai_name);
|
||||||
cpus->dai_name,
|
ret = graph_link_init(priv, cpu_ep, codec_ep, li, dai_name);
|
||||||
codecs->dai_name);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
dai_link->ops = &graph_ops;
|
|
||||||
dai_link->init = asoc_simple_dai_init;
|
|
||||||
|
|
||||||
li->link++;
|
li->link++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue