Commit f1f94049 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: audio-graph-scu-card: support 2nd codec endpoint on DT

audio-graph-scu-card can handle below connection which is mainly
for sound mixing purpose.

	+----------+   +-------+
	| CPU0--+--|-->| Codec |
	|       |  |   +-------+
	| CPU1--+  |
	+----------+

>From OF-graph point of view, it should have
CPU0 <-> Codec, and CPU1 <-> Codec on DT.
But current driver doesn't care about 2nd connection
of Codec, because it is dummy from DPCM point of view.

This patch can care 2nd Codec connection, and it should be
supported from OF-graph point of view.
It still have backward compatibility.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 32f2bcce
...@@ -90,9 +90,12 @@ Example 2. 2 CPU 1 Codec (Mixing) ...@@ -90,9 +90,12 @@ Example 2. 2 CPU 1 Codec (Mixing)
... ...
port { port {
codec_endpoint: endpoint { codec_endpoint0: endpoint {
remote-endpoint = <&cpu_endpoint0>; remote-endpoint = <&cpu_endpoint0>;
}; };
codec_endpoint1: endpoint {
remote-endpoint = <&cpu_endpoint1>;
};
}; };
}; };
...@@ -101,7 +104,7 @@ Example 2. 2 CPU 1 Codec (Mixing) ...@@ -101,7 +104,7 @@ Example 2. 2 CPU 1 Codec (Mixing)
ports { ports {
cpu_port0: port { cpu_port0: port {
cpu_endpoint0: endpoint { cpu_endpoint0: endpoint {
remote-endpoint = <&codec_endpoint>; remote-endpoint = <&codec_endpoint0>;
dai-format = "left_j"; dai-format = "left_j";
... ...
...@@ -109,6 +112,8 @@ Example 2. 2 CPU 1 Codec (Mixing) ...@@ -109,6 +112,8 @@ Example 2. 2 CPU 1 Codec (Mixing)
}; };
cpu_port1: port { cpu_port1: port {
cpu_endpoint1: endpoint { cpu_endpoint1: endpoint {
remote-endpoint = <&codec_endpoint1>;
dai-format = "left_j"; dai-format = "left_j";
... ...
}; };
......
...@@ -183,6 +183,8 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) ...@@ -183,6 +183,8 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv)
struct device_node *cpu_ep; struct device_node *cpu_ep;
struct device_node *codec_ep; struct device_node *codec_ep;
struct device_node *rcpu_ep; struct device_node *rcpu_ep;
struct device_node *codec_port;
struct device_node *codec_port_old;
unsigned int daifmt = 0; unsigned int daifmt = 0;
int dai_idx, ret; int dai_idx, ret;
int rc, codec; int rc, codec;
...@@ -235,6 +237,7 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) ...@@ -235,6 +237,7 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv)
} }
dai_idx = 0; dai_idx = 0;
codec_port_old = NULL;
for (codec = 0; codec < 2; codec++) { for (codec = 0; codec < 2; codec++) {
/* /*
* To listup valid sounds continuously, * To listup valid sounds continuously,
...@@ -245,15 +248,22 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv) ...@@ -245,15 +248,22 @@ static int asoc_graph_card_parse_of(struct graph_card_data *priv)
cpu_port = it.node; cpu_port = it.node;
cpu_ep = of_get_next_child(cpu_port, NULL); cpu_ep = of_get_next_child(cpu_port, NULL);
codec_ep = of_graph_get_remote_endpoint(cpu_ep); codec_ep = of_graph_get_remote_endpoint(cpu_ep);
codec_port = of_graph_get_port_parent(codec_ep);
of_node_put(cpu_port); of_node_put(cpu_port);
of_node_put(cpu_ep); of_node_put(cpu_ep);
of_node_put(codec_ep); of_node_put(codec_ep);
of_node_put(codec_port);
if (codec) { if (codec) {
if (!codec_ep) if (!codec_port)
continue;
if (codec_port_old == codec_port)
continue; continue;
codec_port_old = codec_port;
/* Back-End (= Codec) */ /* Back-End (= Codec) */
ret = asoc_graph_card_dai_link_of(codec_ep, priv, daifmt, dai_idx++, 0); ret = asoc_graph_card_dai_link_of(codec_ep, priv, daifmt, dai_idx++, 0);
if (ret < 0) if (ret < 0)
...@@ -284,22 +294,34 @@ static int asoc_graph_get_dais_count(struct device *dev) ...@@ -284,22 +294,34 @@ static int asoc_graph_get_dais_count(struct device *dev)
struct device_node *cpu_port; struct device_node *cpu_port;
struct device_node *cpu_ep; struct device_node *cpu_ep;
struct device_node *codec_ep; struct device_node *codec_ep;
struct device_node *codec_port;
struct device_node *codec_port_old;
int count = 0; int count = 0;
int rc; int rc;
codec_port_old = NULL;
of_for_each_phandle(&it, rc, node, "dais", NULL, 0) { of_for_each_phandle(&it, rc, node, "dais", NULL, 0) {
cpu_port = it.node; cpu_port = it.node;
cpu_ep = of_get_next_child(cpu_port, NULL); cpu_ep = of_get_next_child(cpu_port, NULL);
codec_ep = of_graph_get_remote_endpoint(cpu_ep); codec_ep = of_graph_get_remote_endpoint(cpu_ep);
codec_port = of_graph_get_port_parent(codec_ep);
of_node_put(cpu_port); of_node_put(cpu_port);
of_node_put(cpu_ep); of_node_put(cpu_ep);
of_node_put(codec_ep); of_node_put(codec_ep);
of_node_put(codec_port);
if (cpu_ep) if (cpu_ep)
count++; count++;
if (codec_ep)
if (!codec_port)
continue;
if (codec_port_old == codec_port)
continue;
count++; count++;
codec_port_old = codec_port;
} }
return count; return count;
......
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