From: Troy Mitchell <troy.mitchell@linux.spacemit.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Yixun Lan <dlan@kernel.org>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, spacemit@lists.linux.dev,
jinmei.wei@spacemit.com,
Troy Mitchell <troy.mitchell@linux.spacemit.com>
Subject: [PATCH v4 1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints
Date: Fri, 22 May 2026 21:33:57 +0800 [thread overview]
Message-ID: <20260522-i2s-same-blk-v4-1-a71a86faaa20@linux.spacemit.com> (raw)
In-Reply-To: <20260522-i2s-same-blk-v4-0-a71a86faaa20@linux.spacemit.com>
Add a bclk field to struct snd_soc_dai and a helper function
snd_soc_dai_set_bclk_clk() that platform drivers can use to declare
which clock is their BCLK.
Also cache the bclk_ratio in snd_soc_dai_set_bclk_ratio() so that
the framework can use it later in hw_rule evaluation for TDM
configurations where BCLK = rate * slots * slot_width.
When multiple DAIs on the same card share the same physical BCLK
(detected via clk_is_match()), the ASoC core can automatically
constrain their hw_params so that the resulting BCLK rates are
compatible. This commit adds the data structure support; the actual
constraint logic follows in the next patch.
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
---
include/sound/soc-dai.h | 7 +++++++
sound/soc/soc-dai.c | 18 ++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 6a42812bba8c..df010a91b350 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -17,6 +17,7 @@
struct snd_pcm_substream;
struct snd_soc_dapm_widget;
struct snd_compr_stream;
+struct clk;
/*
* DAI hardware audio formats.
@@ -188,6 +189,8 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio);
+void snd_soc_dai_set_bclk_clk(struct snd_soc_dai *dai, struct clk *bclk);
+
/* Digital Audio interface formatting */
int snd_soc_dai_get_fmt_max_priority(const struct snd_soc_pcm_runtime *rtd);
u64 snd_soc_dai_get_fmt(const struct snd_soc_dai *dai, int priority);
@@ -473,6 +476,10 @@ struct snd_soc_dai {
unsigned int symmetric_channels;
unsigned int symmetric_sample_bits;
+ /* shared BCLK clock for cross-DAI rate constraints */
+ struct clk *bclk;
+ unsigned int bclk_ratio; /* BCLK = rate * bclk_ratio (0 = use channels * sample_bits) */
+
/* parent platform/codec */
struct snd_soc_component *component;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 2f370fda1266..1719ddcefa4b 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -116,10 +116,28 @@ int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
dai->driver->ops->set_bclk_ratio)
ret = dai->driver->ops->set_bclk_ratio(dai, ratio);
+ if (!ret)
+ dai->bclk_ratio = ratio;
+
return soc_dai_ret(dai, ret);
}
EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
+/**
+ * snd_soc_dai_set_bclk_clk - set the BCLK clock for shared clock detection
+ * @dai: DAI
+ * @bclk: BCLK clock pointer (or NULL to clear)
+ *
+ * When multiple DAIs share the same physical BCLK (detected via
+ * clk_is_match()), the ASoC core will automatically constrain their
+ * hw_params so that the resulting BCLK rates are compatible.
+ */
+void snd_soc_dai_set_bclk_clk(struct snd_soc_dai *dai, struct clk *bclk)
+{
+ dai->bclk = bclk;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_clk);
+
int snd_soc_dai_get_fmt_max_priority(const struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai *dai;
--
2.54.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Troy Mitchell <troy.mitchell@linux.spacemit.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Yixun Lan <dlan@kernel.org>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, spacemit@lists.linux.dev,
jinmei.wei@spacemit.com,
Troy Mitchell <troy.mitchell@linux.spacemit.com>
Subject: [PATCH v4 1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints
Date: Fri, 22 May 2026 21:33:57 +0800 [thread overview]
Message-ID: <20260522-i2s-same-blk-v4-1-a71a86faaa20@linux.spacemit.com> (raw)
In-Reply-To: <20260522-i2s-same-blk-v4-0-a71a86faaa20@linux.spacemit.com>
Add a bclk field to struct snd_soc_dai and a helper function
snd_soc_dai_set_bclk_clk() that platform drivers can use to declare
which clock is their BCLK.
Also cache the bclk_ratio in snd_soc_dai_set_bclk_ratio() so that
the framework can use it later in hw_rule evaluation for TDM
configurations where BCLK = rate * slots * slot_width.
When multiple DAIs on the same card share the same physical BCLK
(detected via clk_is_match()), the ASoC core can automatically
constrain their hw_params so that the resulting BCLK rates are
compatible. This commit adds the data structure support; the actual
constraint logic follows in the next patch.
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
---
include/sound/soc-dai.h | 7 +++++++
sound/soc/soc-dai.c | 18 ++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 6a42812bba8c..df010a91b350 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -17,6 +17,7 @@
struct snd_pcm_substream;
struct snd_soc_dapm_widget;
struct snd_compr_stream;
+struct clk;
/*
* DAI hardware audio formats.
@@ -188,6 +189,8 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio);
+void snd_soc_dai_set_bclk_clk(struct snd_soc_dai *dai, struct clk *bclk);
+
/* Digital Audio interface formatting */
int snd_soc_dai_get_fmt_max_priority(const struct snd_soc_pcm_runtime *rtd);
u64 snd_soc_dai_get_fmt(const struct snd_soc_dai *dai, int priority);
@@ -473,6 +476,10 @@ struct snd_soc_dai {
unsigned int symmetric_channels;
unsigned int symmetric_sample_bits;
+ /* shared BCLK clock for cross-DAI rate constraints */
+ struct clk *bclk;
+ unsigned int bclk_ratio; /* BCLK = rate * bclk_ratio (0 = use channels * sample_bits) */
+
/* parent platform/codec */
struct snd_soc_component *component;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 2f370fda1266..1719ddcefa4b 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -116,10 +116,28 @@ int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
dai->driver->ops->set_bclk_ratio)
ret = dai->driver->ops->set_bclk_ratio(dai, ratio);
+ if (!ret)
+ dai->bclk_ratio = ratio;
+
return soc_dai_ret(dai, ret);
}
EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
+/**
+ * snd_soc_dai_set_bclk_clk - set the BCLK clock for shared clock detection
+ * @dai: DAI
+ * @bclk: BCLK clock pointer (or NULL to clear)
+ *
+ * When multiple DAIs share the same physical BCLK (detected via
+ * clk_is_match()), the ASoC core will automatically constrain their
+ * hw_params so that the resulting BCLK rates are compatible.
+ */
+void snd_soc_dai_set_bclk_clk(struct snd_soc_dai *dai, struct clk *bclk)
+{
+ dai->bclk = bclk;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_clk);
+
int snd_soc_dai_get_fmt_max_priority(const struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_dai *dai;
--
2.54.0
next prev parent reply other threads:[~2026-05-22 13:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 13:33 [PATCH v4 0/3] ASoC: add shared BCLK rate constraint for cross-DAI coordination Troy Mitchell
2026-05-22 13:33 ` Troy Mitchell
2026-05-22 13:33 ` Troy Mitchell [this message]
2026-05-22 13:33 ` [PATCH v4 1/3] ASoC: soc-dai: add shared BCLK clock for cross-DAI rate constraints Troy Mitchell
2026-05-22 13:33 ` [PATCH v4 2/3] ASoC: soc-pcm: add DEFINE_GUARD for snd_soc_card_mutex Troy Mitchell
2026-05-22 13:33 ` Troy Mitchell
2026-05-22 13:33 ` [PATCH v4 3/3] ASoC: soc-pcm: constrain hw_params when DAIs share the same BCLK Troy Mitchell
2026-05-22 13:33 ` Troy Mitchell
2026-05-25 10:42 ` [PATCH v4 0/3] ASoC: add shared BCLK rate constraint for cross-DAI coordination Mark Brown
2026-05-25 10:42 ` Mark Brown
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=20260522-i2s-same-blk-v4-1-a71a86faaa20@linux.spacemit.com \
--to=troy.mitchell@linux.spacemit.com \
--cc=broonie@kernel.org \
--cc=dlan@kernel.org \
--cc=jinmei.wei@spacemit.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=spacemit@lists.linux.dev \
--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.