[PATCH 3/4] ASoC: audio-graph-card2: parse symmetric-clock-roles property

From: Alvin Šipraga
Date: Fri Jun 02 2023 - 05:05:15 EST


From: Alvin Šipraga <alsi@xxxxxxxxxxxxxxx>

The property, when set, specifies that both ends of the dai-link should
have the same clock consumer/provider roles. Like with parsing of DAI
format, the property can be specified in multiple places:

ports {
(A)
port {
(B)
endpoint {
(C)
};
};
};

So each place has to be checked. In case the clock roles are symmetric,
there is then no need to flip the role when parsing the DAI format on
the CPU side, as it should then be the same on the Codec side.

Signed-off-by: Alvin Šipraga <alsi@xxxxxxxxxxxxxxx>
---
sound/soc/generic/audio-graph-card2.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c
index 25aa79dd55b3..9b4ebfd0c0b6 100644
--- a/sound/soc/generic/audio-graph-card2.c
+++ b/sound/soc/generic/audio-graph-card2.c
@@ -721,13 +721,18 @@ static void graph_link_init(struct asoc_simple_priv *priv,
if (of_node_name_eq(ports, "ports"))
graph_parse_daifmt(ports, &daifmt, &bit_frame); /* (A) */

+ if (of_property_read_bool(ep, "symmetric-clock-roles") ||
+ of_property_read_bool(port, "symmetric-clock-roles") ||
+ of_property_read_bool(ports, "symmetric-clock-roles"))
+ dai_link->symmetric_clock_roles = 1;
+
/*
* convert bit_frame
* We need to flip clock_provider if it was CPU node,
* because it is Codec base.
*/
daiclk = snd_soc_daifmt_clock_provider_from_bitmap(bit_frame);
- if (is_cpu_node)
+ if (is_cpu_node && !dai_link->symmetric_clock_roles)
daiclk = snd_soc_daifmt_clock_provider_flipped(daiclk);

dai_link->dai_fmt = daifmt | daiclk;
--
2.40.0