All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alvin Šipraga" <alvin@pqrs.dk>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Cc: "Alvin Šipraga" <alsi@bang-olufsen.dk>,
	alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/4] ASoC: core: add support for dai-links with symmetric clock roles
Date: Fri,  2 Jun 2023 11:03:19 +0200	[thread overview]
Message-ID: <20230602090322.1876359-3-alvin@pqrs.dk> (raw)
In-Reply-To: <20230602090322.1876359-1-alvin@pqrs.dk>

From: Alvin Šipraga <alsi@bang-olufsen.dk>

The snd_soc_dai_link::dai_fmt field contains the nominal bit- and
frame-clock consumer/provider role from the point of view of the codec.
The ASoC core then assumes that it should flip the roles when
initializing the format on the CPU. But in cases where both the CPU and
codec are clock consumers, e.g. because of an external clock source,
this assumption breaks down.

To allow for proper configuration of the backing CPU/codec drivers for
consumer roles, introduce support for a symmetric_clock_roles flag. The
role flipping will be skipped when this flag is set.

Signed-off-by: Alvin Šipraga <alsi@bang-olufsen.dk>
---
 include/sound/soc.h  | 3 +++
 sound/soc/soc-core.c | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 533e553a343f..87f4fb3d4b20 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -718,6 +718,9 @@ struct snd_soc_dai_link {
 	/* Keep DAI active over suspend */
 	unsigned int ignore_suspend:1;
 
+	/* Assume CPU/Codec have the same clock consumer/provider role */
+	unsigned int symmetric_clock_roles:1;
+
 	/* Symmetry requirements */
 	unsigned int symmetric_rate:1;
 	unsigned int symmetric_channels:1;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b48efc3a08d2..7817b86dd93d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1216,6 +1216,7 @@ static void snd_soc_runtime_get_dai_fmt(struct snd_soc_pcm_runtime *rtd)
 int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 				unsigned int dai_fmt)
 {
+	struct snd_soc_dai_link *dai_link = rtd->dai_link;
 	struct snd_soc_dai *cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	unsigned int i;
@@ -1231,7 +1232,8 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 	}
 
 	/* Flip the polarity for the "CPU" end of link */
-	dai_fmt = snd_soc_daifmt_clock_provider_flipped(dai_fmt);
+	if (!dai_link->symmetric_clock_roles)
+		dai_fmt = snd_soc_daifmt_clock_provider_flipped(dai_fmt);
 
 	for_each_rtd_cpu_dais(rtd, i, cpu_dai) {
 		ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt);
-- 
2.40.0


  parent reply	other threads:[~2023-06-02  9:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02  9:03 [PATCH 0/4] ASoC: support dai-links with symmetric clock roles Alvin Šipraga
2023-06-02  9:03 ` [PATCH 1/4] ASoC: dt-bindings: document new symmetric-clock-role flag Alvin Šipraga
2023-06-02 10:13   ` Rob Herring
2023-06-02 11:43   ` Mark Brown
2023-06-02 12:12     ` Alvin Šipraga
2023-06-02 12:19       ` Mark Brown
2023-06-02 12:42         ` Alvin Šipraga
2023-06-06 14:39           ` Mark Brown
2023-06-05 11:42         ` Alvin Šipraga
2023-06-02  9:03 ` Alvin Šipraga [this message]
2023-06-02  9:03 ` [PATCH 3/4] ASoC: audio-graph-card2: parse symmetric-clock-roles property Alvin Šipraga
2023-06-05  0:35   ` Kuninori Morimoto
2023-06-05 10:58     ` Alvin Šipraga
2023-06-02  9:03 ` [PATCH 4/4] ASoC: simple-card: " Alvin Šipraga
2023-06-05  0:28   ` Kuninori Morimoto
2023-06-05 11:12     ` Alvin Šipraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230602090322.1876359-3-alvin@pqrs.dk \
    --to=alvin@pqrs.dk \
    --cc=alsa-devel@alsa-project.org \
    --cc=alsi@bang-olufsen.dk \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.