linux-sound.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] ASoC: add new DAI functions
@ 2026-09-14  1:43 Kuninori Morimoto
  2026-09-14  1:43 ` [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id() Kuninori Morimoto
                   ` (10 more replies)
  0 siblings, 11 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound


Hi Mark

I'm now posting ASoC Capsuling patches.
Current status, and this patch-set postion is below.

x: done
o: This patch-set

[x] move DAI functions
[o] add new DAI functions
[ ] move Component functions
[ ] move Card functions
[ ] add new Component functions
[ ] rename DAI/Component list
[ ] move Card functions
[ ] add new Card functions
[ ] adjust Test
[ ] use new Card register
[ ] use new functions on all drivers  -- (A)
[ ] Capsule DAI/Component/Card

This patch-set adds new DAI functions to get dai->xxx, because each
driver will not be access to them directly when capsuling has done.
This patch-set just adds new functions, but no user for now.
All user will use them at (A) timing.

Kuninori Morimoto (10):
  ASoC: soc-dai: add snd_soc_dai_id()
  ASoC: soc-dai: add snd_soc_dai_to_component()
  ASoC: soc-dai: add snd_soc_dai_to_driver()
  ASoC: soc-dai: add snd_soc_dai_{to/from}_list()
  ASoC: soc-dai: add snd_soc_dai_symmetric_get_params()
  ASoC: soc-dai: add snd_soc_dai_priv_{set/get}()
  ASoC: soc-dai: rename snd_soc_dai_stream_active()
  ASoC: soc-dai: rename snd_soc_dai_action()
  ASoC: soc-dai: move snd_soc_dai_active_action() to soc-internal.h
  ASoC: soc-dai: add snd_soc_dai_get_bclk()

 include/sound/soc-component.h               | 14 +++-
 include/sound/soc-dai.h                     | 28 +++----
 sound/soc/mediatek/mt8188/mt8188-dai-pcm.c  |  5 +-
 sound/soc/mediatek/mt8195/mt8195-dai-pcm.c  |  5 +-
 sound/soc/mediatek/mt8365/mt8365-dai-dmic.c | 10 ++-
 sound/soc/mediatek/mt8365/mt8365-dai-pcm.c  |  4 +-
 sound/soc/sdca/sdca_asoc.c                  |  4 +-
 sound/soc/soc-dai.c                         | 84 ++++++++++++++++++---
 sound/soc/soc-dapm.c                        |  9 ++-
 sound/soc/soc-internal.h                    |  2 +
 sound/soc/soc-pcm.c                         | 30 ++++++--
 11 files changed, 146 insertions(+), 49 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
@ 2026-09-14  1:43 ` Kuninori Morimoto
  2026-09-15 13:43   ` Alvin Šipraga
  2026-09-14  1:43 ` [PATCH 02/10] ASoC: soc-dai: add snd_soc_dai_to_component() Kuninori Morimoto
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

DAI parameter will be capsuled soon, will be not enable to access from
each drivers. add snd_soc_dai_id() to get ID from DAI.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h | 1 +
 sound/soc/soc-dai.c     | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 7e64e049d71d5..02b52fed97c9e 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -283,6 +283,7 @@ int snd_soc_dai_matches_args(const struct snd_soc_dai *dai,
 int snd_soc_dai_matches_dlc(struct snd_soc_dai *dai,
 			    const struct snd_soc_dai_link_component *dlc);
 const char *snd_soc_dai_name(const struct snd_soc_dai *dai);
+int snd_soc_dai_id(const struct snd_soc_dai *dai);
 
 struct snd_soc_dai_ops {
 	/* DAI driver callbacks */
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 83d030e14bb0b..d4c47da75fd27 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -1073,6 +1073,12 @@ const char *snd_soc_dai_name(const struct snd_soc_dai *dai)
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_name);
 
+int snd_soc_dai_id(const struct snd_soc_dai *dai)
+{
+	return dai->id;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_id);
+
 const struct snd_soc_pcm_stream *
 snd_soc_dai_pcm_stream_get_i(const struct snd_soc_dai *dai, int stream)
 {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/10] ASoC: soc-dai: add snd_soc_dai_to_component()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
  2026-09-14  1:43 ` [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id() Kuninori Morimoto
@ 2026-09-14  1:43 ` Kuninori Morimoto
  2026-09-15 13:44   ` Alvin Šipraga
  2026-09-14  1:43 ` [PATCH 03/10] ASoC: soc-dai: add snd_soc_dai_to_driver() Kuninori Morimoto
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

DAI parameter will be capsuled soon, will be not enable to access from
each drivers. add snd_soc_dai_to_component() to get component from DAI.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h | 1 +
 sound/soc/soc-dai.c     | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 02b52fed97c9e..7f8a64db0dc7f 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -212,6 +212,7 @@ int snd_soc_dai_get_channel_map(const struct snd_soc_dai *dai,
 		unsigned int *tx_num, unsigned int *tx_slot,
 		unsigned int *rx_num, unsigned int *rx_slot);
 
+struct snd_soc_component *snd_soc_dai_to_component(const struct snd_soc_dai *dai);
 int snd_soc_dai_is_dummy(const struct snd_soc_dai *dai);
 int snd_soc_dai_add_controls(struct snd_soc_dai *dai,
 			     const struct snd_kcontrol_new *controls, int num_controls);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index d4c47da75fd27..2027e6b6aca18 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -20,6 +20,12 @@ static inline int _soc_dai_ret(const struct snd_soc_dai *dai,
 			   "at %s() on %s\n", func, dai->name);
 }
 
+struct snd_soc_component *snd_soc_dai_to_component(const struct snd_soc_dai *dai)
+{
+	return dai->component;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_to_component);
+
 /*
  * We might want to check substream by using list.
  * In such case, we can update these macros.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/10] ASoC: soc-dai: add snd_soc_dai_to_driver()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
  2026-09-14  1:43 ` [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id() Kuninori Morimoto
  2026-09-14  1:43 ` [PATCH 02/10] ASoC: soc-dai: add snd_soc_dai_to_component() Kuninori Morimoto
@ 2026-09-14  1:43 ` Kuninori Morimoto
  2026-09-15 13:44   ` Alvin Šipraga
  2026-09-14  1:43 ` [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list() Kuninori Morimoto
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

DAI parameter will be capsuled soon, will be not enable to access from
each drivers. add snd_soc_dai_to_driver() to get driver from DAI.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h | 1 +
 sound/soc/soc-dai.c     | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 7f8a64db0dc7f..375a8674d1452 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -213,6 +213,7 @@ int snd_soc_dai_get_channel_map(const struct snd_soc_dai *dai,
 		unsigned int *rx_num, unsigned int *rx_slot);
 
 struct snd_soc_component *snd_soc_dai_to_component(const struct snd_soc_dai *dai);
+struct snd_soc_dai_driver *snd_soc_dai_to_driver(const struct snd_soc_dai *dai);
 int snd_soc_dai_is_dummy(const struct snd_soc_dai *dai);
 int snd_soc_dai_add_controls(struct snd_soc_dai *dai,
 			     const struct snd_kcontrol_new *controls, int num_controls);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 2027e6b6aca18..3254b14c1eb76 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -26,6 +26,12 @@ struct snd_soc_component *snd_soc_dai_to_component(const struct snd_soc_dai *dai
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_to_component);
 
+struct snd_soc_dai_driver *snd_soc_dai_to_driver(const struct snd_soc_dai *dai)
+{
+	return dai->driver;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_to_driver);
+
 /*
  * We might want to check substream by using list.
  * In such case, we can update these macros.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (2 preceding siblings ...)
  2026-09-14  1:43 ` [PATCH 03/10] ASoC: soc-dai: add snd_soc_dai_to_driver() Kuninori Morimoto
@ 2026-09-14  1:43 ` Kuninori Morimoto
  2026-09-15 15:03   ` Alvin Šipraga
  2026-09-14  1:45 ` [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params() Kuninori Morimoto
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:43 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

DAI parameter will be capsuled soon, will be not enable to access from
each drivers. add snd_soc_dai_{to/from}_list() to use for_each macro.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-component.h | 14 ++++++++++----
 include/sound/soc-dai.h       |  2 ++
 sound/soc/soc-dai.c           | 12 ++++++++++++
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index c49b59630101f..6c1acc984ecb0 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -258,10 +258,16 @@ struct snd_soc_component {
 	void *priv;
 };
 
-#define for_each_component_dais(component, dai)\
-	list_for_each_entry(dai, &(component)->dai_list, list)
-#define for_each_component_dais_safe(component, dai, _dai)\
-	list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
+#define for_each_component_dais(component, dai)				\
+	for (dai = snd_soc_dai_from_list((component)->dai_list.next);	\
+	     snd_soc_dai_to_list(dai) != &(component)->dai_list;	\
+	     dai = snd_soc_dai_from_list(snd_soc_dai_to_list(dai)->next))
+
+#define for_each_component_dais_safe(component, dai, _dai)			\
+	for (dai = snd_soc_dai_from_list((component)->dai_list.next),		\
+	     _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(dai)->next);	\
+	     snd_soc_dai_to_list(dai) != &(component)->dai_list;		\
+	     dai = _dai, _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(_dai)->next))
 
 /**
  * snd_soc_component_to_dapm() - Returns the DAPM context associated with a
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 375a8674d1452..bd714c3bbf3df 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -561,6 +561,8 @@ struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component,
 					 struct snd_soc_dai_driver *dai_drv,
 					 bool legacy_dai_naming);
 void snd_soc_dai_unregister(struct snd_soc_dai *dai);
+struct snd_soc_dai *snd_soc_dai_from_list(struct list_head *list);
+struct list_head *snd_soc_dai_to_list(struct snd_soc_dai *dai);
 
 /* REMOVE ME */
 #define snd_soc_dai_get_pcm_stream			snd_soc_dai_pcm_stream_get
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 3254b14c1eb76..dba8a5a63aad6 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -32,6 +32,18 @@ struct snd_soc_dai_driver *snd_soc_dai_to_driver(const struct snd_soc_dai *dai)
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_to_driver);
 
+struct snd_soc_dai *snd_soc_dai_from_list(struct list_head *list)
+{
+	return list_entry(list, typeof(struct snd_soc_dai), list);
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_from_list);
+
+struct list_head *snd_soc_dai_to_list(struct snd_soc_dai *dai)
+{
+	return &dai->list;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_to_list);
+
 /*
  * We might want to check substream by using list.
  * In such case, we can update these macros.
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (3 preceding siblings ...)
  2026-09-14  1:43 ` [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list() Kuninori Morimoto
@ 2026-09-14  1:45 ` Kuninori Morimoto
  2026-09-15  1:51   ` Alvin Šipraga
  2026-09-14  1:46 ` [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv() Kuninori Morimoto
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:45 UTC (permalink / raw)
  To: Mark Brown, Matthias Brugger, AngeloGioacchino Del Regno; +Cc: linux-sound

DAI parameter will be capsuled soon, will be not enable to access from
each drivers. DAI symmetric_xxx has been mainly referred from Mediatek
drivers. Let's add snd_soc_dai_symmetric_get_params() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h                     |  4 ++++
 sound/soc/mediatek/mt8188/mt8188-dai-pcm.c  |  5 ++++-
 sound/soc/mediatek/mt8195/mt8195-dai-pcm.c  |  5 ++++-
 sound/soc/mediatek/mt8365/mt8365-dai-dmic.c | 10 +++++++---
 sound/soc/mediatek/mt8365/mt8365-dai-pcm.c  |  4 +++-
 sound/soc/soc-dai.c                         | 14 ++++++++++++++
 sound/soc/soc-pcm.c                         |  5 ++++-
 7 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index bd714c3bbf3df..c5544f1789425 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -563,6 +563,10 @@ struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component,
 void snd_soc_dai_unregister(struct snd_soc_dai *dai);
 struct snd_soc_dai *snd_soc_dai_from_list(struct list_head *list);
 struct list_head *snd_soc_dai_to_list(struct snd_soc_dai *dai);
+void snd_soc_dai_symmetric_get_params(struct snd_soc_dai *dai,
+				      unsigned int *symmetric_rate,
+				      unsigned int *symmetric_channels,
+				      unsigned int *symmetric_sample_bits);
 
 /* REMOVE ME */
 #define snd_soc_dai_get_pcm_stream			snd_soc_dai_pcm_stream_get
diff --git a/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c b/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c
index 8ca7cc75e21dc..766893ca56d45 100644
--- a/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c
+++ b/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c
@@ -128,7 +128,7 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
 	unsigned int lrck_inv;
 	unsigned int bck_inv;
 	unsigned int fmt;
-	unsigned int bit_width = dai->symmetric_sample_bits;
+	unsigned int bit_width;
 	unsigned int val = 0;
 	unsigned int mask = 0;
 	int fs = 0;
@@ -137,7 +137,10 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
 	if (dai->id < 0)
 		return -EINVAL;
 
+	snd_soc_dai_symmetric_get_params(dai, NULL, NULL, &bit_width);
+
 	pcmif_priv = afe_priv->dai_priv[dai->id];
+
 	slave_mode = pcmif_priv->slave_mode;
 	lrck_inv = pcmif_priv->lrck_inv;
 	bck_inv = pcmif_priv->bck_inv;
diff --git a/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c b/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c
index cdc16057d50e2..a090995ac9a7f 100644
--- a/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c
+++ b/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c
@@ -127,7 +127,7 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
 	unsigned int lrck_inv;
 	unsigned int bck_inv;
 	unsigned int fmt;
-	unsigned int bit_width = dai->symmetric_sample_bits;
+	unsigned int bit_width;
 	unsigned int val = 0;
 	unsigned int mask = 0;
 	int fs = 0;
@@ -136,7 +136,10 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
 	if (dai->id != MT8195_AFE_IO_PCM)
 		return -EINVAL;
 
+	snd_soc_dai_symmetric_get_params(dai, NULL, NULL, &bit_width);
+
 	pcmif_priv = afe_priv->dai_priv[dai->id];
+
 	slave_mode = pcmif_priv->slave_mode;
 	lrck_inv = pcmif_priv->lrck_inv;
 	bck_inv = pcmif_priv->bck_inv;
diff --git a/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c b/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
index 0bac143b48bfb..6e1d48f757d22 100644
--- a/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
+++ b/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
@@ -118,13 +118,17 @@ static int mt8365_dai_configure_dmic(struct mtk_base_afe *afe,
 	unsigned int clk_phase_sel_ch1 = dmic_data->clk_phase_sel_ch1;
 	unsigned int clk_phase_sel_ch2 = dmic_data->clk_phase_sel_ch2;
 	unsigned int val = 0;
-	unsigned int rate = dai->symmetric_rate;
-	int reg = get_chan_reg(dai->symmetric_channels);
+	unsigned int rate;
+	unsigned int channel;
+	int reg;
 
+	snd_soc_dai_symmetric_get_params(dai, &rate, &channel, NULL);
+
+	reg = get_chan_reg(channel);
 	if (reg < 0)
 		return -EINVAL;
 
-	dmic_data->dmic_channel = dai->symmetric_channels;
+	dmic_data->dmic_channel = channel;
 
 	val |= DMIC_TOP_CON_SDM3_LEVEL_MODE;
 
diff --git a/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c b/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c
index 0ec114a566ad1..62bac8f387963 100644
--- a/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c
+++ b/sound/soc/mediatek/mt8365/mt8365-dai-pcm.c
@@ -44,9 +44,11 @@ static int mt8365_dai_configure_pcm1(struct snd_pcm_substream *substream,
 	bool lrck_inv = pcm_priv->lrck_inv;
 	bool bck_inv = pcm_priv->bck_inv;
 	unsigned int fmt = pcm_priv->format;
-	unsigned int bit_width = dai->symmetric_sample_bits;
+	unsigned int bit_width;
 	unsigned int val = 0;
 
+	snd_soc_dai_symmetric_get_params(dai, NULL, NULL, &bit_width);
+
 	if (!slave_mode) {
 		val |= PCM_INTF_CON1_MASTER_MODE |
 		       PCM_INTF_CON1_BYPASS_ASRC;
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index dba8a5a63aad6..b9a3d29d60914 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -1263,6 +1263,20 @@ struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component,
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_register);
 
+void snd_soc_dai_symmetric_get_params(struct snd_soc_dai *dai,
+				      unsigned int *symmetric_rate,
+				      unsigned int *symmetric_channels,
+				      unsigned int *symmetric_sample_bits)
+{
+	if (symmetric_rate)
+		*symmetric_rate		= dai->symmetric_rate;
+	if (symmetric_channels)
+		*symmetric_channels	= dai->symmetric_channels;
+	if (symmetric_sample_bits)
+		*symmetric_sample_bits	= dai->symmetric_sample_bits;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_symmetric_get_params);
+
 void snd_soc_dai_symmetric_set_params(struct snd_soc_dai *dai,
 				      struct snd_pcm_hw_params *params)
 {
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index a446e9c1c9887..aaba9ca724e61 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -453,6 +453,8 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
 	/* Scan all DAIs on the card for an active peer sharing the same BCLK */
 	for_each_card_rtds(card, rtd) {
 		for_each_rtd_cpu_dais(rtd, i, other_dai) {
+			unsigned int symmetric_rate;
+
 			if (other_dai == dai)
 				continue;
 			if (!other_dai->bclk)
@@ -465,7 +467,8 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
 			 * after snd_soc_dai_hw_params(), so non-zero means
 			 * the DAI's clk_set_rate() has already executed.
 			 */
-			if (!other_dai->symmetric_rate)
+			snd_soc_dai_symmetric_get_params(other_dai, &symmetric_rate, NULL, NULL);
+			if (!symmetric_rate)
 				continue;
 			if (!clk_is_match(dai->bclk, other_dai->bclk))
 				continue;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (4 preceding siblings ...)
  2026-09-14  1:45 ` [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params() Kuninori Morimoto
@ 2026-09-14  1:46 ` Kuninori Morimoto
  2026-09-14  8:38   ` Charles Keepax
  2026-09-15 15:05   ` Alvin Šipraga
  2026-09-14  1:46 ` [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active() Kuninori Morimoto
                   ` (4 subsequent siblings)
  10 siblings, 2 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:46 UTC (permalink / raw)
  To: Mark Brown, Charles Keepax, Maciej Strozek, Bard Liao,
	Pierre-Louis Bossart
  Cc: linux-sound

DAI parameter will be capsuled soon, will be not enable to access from
each drivers. DAI priv has been mainly referred from SoundWire driver.
Let's add snd_soc_dai_{set/to}_priv() for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h    |  2 ++
 sound/soc/sdca/sdca_asoc.c |  4 ++--
 sound/soc/soc-dai.c        | 12 ++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index c5544f1789425..e91f87ca57689 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -567,6 +567,8 @@ void snd_soc_dai_symmetric_get_params(struct snd_soc_dai *dai,
 				      unsigned int *symmetric_rate,
 				      unsigned int *symmetric_channels,
 				      unsigned int *symmetric_sample_bits);
+void snd_soc_dai_set_priv(struct snd_soc_dai *dai, void *priv);
+void *snd_soc_dai_to_priv(struct snd_soc_dai *dai);
 
 /* REMOVE ME */
 #define snd_soc_dai_get_pcm_stream			snd_soc_dai_pcm_stream_get
diff --git a/sound/soc/sdca/sdca_asoc.c b/sound/soc/sdca/sdca_asoc.c
index ce2e7c2707657..ccc579f878ff1 100644
--- a/sound/soc/sdca/sdca_asoc.c
+++ b/sound/soc/sdca/sdca_asoc.c
@@ -1507,7 +1507,7 @@ int sdca_asoc_set_constraints(struct device *dev, struct regmap *regmap,
 		return ret;
 	}
 
-	dai->priv = constraint;
+	snd_soc_dai_set_priv(dai, constraint);
 
 	return 0;
 }
@@ -1523,7 +1523,7 @@ EXPORT_SYMBOL_NS(sdca_asoc_set_constraints, "SND_SOC_SDCA");
 void sdca_asoc_free_constraints(struct snd_pcm_substream *substream,
 				struct snd_soc_dai *dai)
 {
-	struct snd_pcm_hw_constraint_list *constraint = dai->priv;
+	struct snd_pcm_hw_constraint_list *constraint = snd_soc_dai_to_priv(dai);
 
 	kfree(constraint);
 }
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index b9a3d29d60914..1df58861c8388 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -32,6 +32,18 @@ struct snd_soc_dai_driver *snd_soc_dai_to_driver(const struct snd_soc_dai *dai)
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_to_driver);
 
+void snd_soc_dai_set_priv(struct snd_soc_dai *dai, void *priv)
+{
+	dai->priv = priv;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_set_priv);
+
+void *snd_soc_dai_to_priv(struct snd_soc_dai *dai)
+{
+	return dai->priv;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_to_priv);
+
 struct snd_soc_dai *snd_soc_dai_from_list(struct list_head *list)
 {
 	return list_entry(list, typeof(struct snd_soc_dai), list);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (5 preceding siblings ...)
  2026-09-14  1:46 ` [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv() Kuninori Morimoto
@ 2026-09-14  1:46 ` Kuninori Morimoto
  2026-09-15  1:00   ` Alvin Šipraga
  2026-09-14  1:46 ` [PATCH 08/10] ASoC: soc-dai: rename snd_soc_dai_action() Kuninori Morimoto
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

snd_soc_dai_stream_active() (A) and snd_soc_dai_active() (B) are almost
same function, but implemented different place with different naming.

Let's move snd_soc_dai_stream_active() (A) prev to snd_soc_dai_active()
(B), and rename it (C).

(C)+	snd_soc_dai_active_stream()
(B)	snd_soc_dai_active()
	...
(A)-	snd_soc_dai_stream_active()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h |  4 ++--
 sound/soc/soc-dai.c     | 16 ++++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index e91f87ca57689..52c7f4282ef55 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -244,6 +244,7 @@ static inline void snd_soc_dai_deactivate(struct snd_soc_dai *dai,
 	snd_soc_dai_action(dai, stream, -1);
 }
 int snd_soc_dai_active(const struct snd_soc_dai *dai);
+unsigned int snd_soc_dai_active_stream(const struct snd_soc_dai *dai, int stream);
 
 int snd_soc_pcm_dai_probe(struct snd_soc_pcm_runtime *rtd, int order);
 int snd_soc_pcm_dai_remove(struct snd_soc_pcm_runtime *rtd, int order);
@@ -541,8 +542,6 @@ static inline void snd_soc_dai_stream_dma_data_set_s(struct snd_soc_dai *dai, st
 unsigned int snd_soc_dai_stream_tdm_mask_get(const struct snd_soc_dai *dai, int stream);
 void snd_soc_dai_stream_tdm_mask_set(struct snd_soc_dai *dai, int stream, unsigned int tdm_mask);
 
-unsigned int snd_soc_dai_stream_active(const struct snd_soc_dai *dai, int stream);
-
 static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai,
 		void *data)
 {
@@ -588,6 +587,7 @@ void *snd_soc_dai_to_priv(struct snd_soc_dai *dai);
 #define snd_soc_dai_dma_data_set			snd_soc_dai_stream_dma_data_set
 #define snd_soc_dai_tdm_mask_get			snd_soc_dai_stream_tdm_mask_get
 #define snd_soc_dai_tdm_mask_set			snd_soc_dai_stream_tdm_mask_set
+#define snd_soc_dai_stream_active			snd_soc_dai_active_stream
 static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai, void *playback, void *capture)
 {
 	snd_soc_dai_stream_dma_data_set_playback(dai, playback);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 1df58861c8388..112e04049d10d 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -718,13 +718,20 @@ void snd_soc_dai_action(struct snd_soc_dai *dai,
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_action);
 
+unsigned int snd_soc_dai_active_stream(const struct snd_soc_dai *dai, int stream)
+{
+	/* see snd_soc_dai_action() for setup */
+	return dai->stream[stream].active;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dai_active_stream);
+
 int snd_soc_dai_active(const struct snd_soc_dai *dai)
 {
 	int stream, active;
 
 	active = 0;
 	for_each_pcm_streams(stream)
-		active += dai->stream[stream].active;
+		active += snd_soc_dai_stream_active(dai, stream);
 
 	return active;
 }
@@ -1159,13 +1166,6 @@ void snd_soc_dai_stream_tdm_mask_set(struct snd_soc_dai *dai, int stream, unsign
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_stream_tdm_mask_set);
 
-unsigned int snd_soc_dai_stream_active(const struct snd_soc_dai *dai, int stream)
-{
-	/* see snd_soc_dai_action() for setup */
-	return dai->stream[stream].active;
-}
-EXPORT_SYMBOL_GPL(snd_soc_dai_stream_active);
-
 /**
  * snd_soc_dai_set_stream() - Configures a DAI for stream operation
  * @dai: DAI
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/10] ASoC: soc-dai: rename snd_soc_dai_action()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (6 preceding siblings ...)
  2026-09-14  1:46 ` [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active() Kuninori Morimoto
@ 2026-09-14  1:46 ` Kuninori Morimoto
  2026-09-14  1:46 ` [PATCH 09/10] ASoC: soc-dai: move snd_soc_dai_active_action() to soc-internal.h Kuninori Morimoto
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

We have snd_soc_dai_action() (A) and snd_soc_dai_active_xxx() (B).
These are related function, but implemented as different naming.

Let's rename it.

(A)-	snd_soc_dai_action()
   +	snd_soc_dai_active_action()
(B)	snd_soc_dai_active_stream()
(B)	snd_soc_dai_active()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h | 16 ++++------------
 sound/soc/soc-dai.c     |  7 +++----
 sound/soc/soc-dapm.c    |  8 ++++----
 sound/soc/soc-pcm.c     |  2 +-
 4 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 52c7f4282ef55..27a85abcab51f 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -231,18 +231,10 @@ void snd_soc_dai_suspend(struct snd_soc_dai *dai);
 void snd_soc_dai_resume(struct snd_soc_dai *dai);
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai, struct snd_soc_pcm_runtime *rtd);
 bool snd_soc_dai_stream_valid(const struct snd_soc_dai *dai, int stream);
-void snd_soc_dai_action(struct snd_soc_dai *dai,
-			int stream, int action);
-static inline void snd_soc_dai_activate(struct snd_soc_dai *dai,
-					int stream)
-{
-	snd_soc_dai_action(dai, stream,  1);
-}
-static inline void snd_soc_dai_deactivate(struct snd_soc_dai *dai,
-					  int stream)
-{
-	snd_soc_dai_action(dai, stream, -1);
-}
+
+#define snd_soc_dai_active_activate(dai, stream)	snd_soc_dai_active_action(dai, stream,  1)
+#define snd_soc_dai_active_deactivate(dai, stream)	snd_soc_dai_active_action(dai, stream, -1)
+void snd_soc_dai_active_action(struct snd_soc_dai *dai, int stream, int action);
 int snd_soc_dai_active(const struct snd_soc_dai *dai);
 unsigned int snd_soc_dai_active_stream(const struct snd_soc_dai *dai, int stream);
 
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 112e04049d10d..b8bdbaf200b05 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -707,8 +707,7 @@ bool snd_soc_dai_stream_valid(const struct snd_soc_dai *dai, int dir)
 	return stream->channels_min;
 }
 
-void snd_soc_dai_action(struct snd_soc_dai *dai,
-			int stream, int action)
+void snd_soc_dai_active_action(struct snd_soc_dai *dai, int stream, int action)
 {
 	/* see snd_soc_dai_stream_active() */
 	dai->stream[stream].active	+= action;
@@ -716,11 +715,11 @@ void snd_soc_dai_action(struct snd_soc_dai *dai,
 	/* see snd_soc_component_active() */
 	dai->component->active		+= action;
 }
-EXPORT_SYMBOL_GPL(snd_soc_dai_action);
+EXPORT_SYMBOL_GPL(snd_soc_dai_active_action);
 
 unsigned int snd_soc_dai_active_stream(const struct snd_soc_dai *dai, int stream)
 {
-	/* see snd_soc_dai_action() for setup */
+	/* see snd_soc_dai_active_action() for setup */
 	return dai->stream[stream].active;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_active_stream);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 06b85313af126..dff23127de429 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -4010,7 +4010,7 @@ static int dapm_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 		if (ret < 0)
 			return ret;
 
-		snd_soc_dai_activate(source, substream->stream);
+		snd_soc_dai_active_activate(source, substream->stream);
 	}
 
 	substream->stream = SNDRV_PCM_STREAM_PLAYBACK;
@@ -4021,7 +4021,7 @@ static int dapm_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 		if (ret < 0)
 			return ret;
 
-		snd_soc_dai_activate(sink, substream->stream);
+		snd_soc_dai_active_activate(sink, substream->stream);
 	}
 
 	substream->hw_opened = 1;
@@ -4150,14 +4150,14 @@ static int dapm_dai_link_event(struct snd_soc_dapm_widget *w,
 		substream->stream = SNDRV_PCM_STREAM_CAPTURE;
 		snd_soc_dapm_widget_for_each_source_path(w, path) {
 			source = path->source->priv;
-			snd_soc_dai_deactivate(source, substream->stream);
+			snd_soc_dai_active_deactivate(source, substream->stream);
 			snd_soc_dai_shutdown(source, substream, 0);
 		}
 
 		substream->stream = SNDRV_PCM_STREAM_PLAYBACK;
 		snd_soc_dapm_widget_for_each_sink_path(w, path) {
 			sink = path->sink->priv;
-			snd_soc_dai_deactivate(sink, substream->stream);
+			snd_soc_dai_active_deactivate(sink, substream->stream);
 			snd_soc_dai_shutdown(sink, substream, 0);
 		}
 		break;
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index aaba9ca724e61..7eb58c4b6fc31 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -368,7 +368,7 @@ void snd_soc_runtime_action(struct snd_soc_pcm_runtime *rtd,
 	snd_soc_dpcm_mutex_assert_held(rtd);
 
 	for_each_rtd_dais(rtd, i, dai)
-		snd_soc_dai_action(dai, stream, action);
+		snd_soc_dai_active_action(dai, stream, action);
 
 	/* Increments/Decrements the active count for components without DAIs */
 	for_each_rtd_components(rtd, i, component) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/10] ASoC: soc-dai: move snd_soc_dai_active_action() to soc-internal.h
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (7 preceding siblings ...)
  2026-09-14  1:46 ` [PATCH 08/10] ASoC: soc-dai: rename snd_soc_dai_action() Kuninori Morimoto
@ 2026-09-14  1:46 ` Kuninori Morimoto
  2026-09-14  1:47 ` [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk() Kuninori Morimoto
  2026-09-14 13:37 ` [PATCH 00/10] ASoC: add new DAI functions Mark Brown
  10 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

snd_soc_dai_active_action() is used only for ASoC framework. Let's move
it to soc-internal.h.
Now, we have activate/deactivate() macro (A), but it makes grep difficult.
Let's standardize to soc_dai_active_action()

(A)	#define snd_soc_dai_active_activate(...)   snd_soc_dai_active_action(...,  1)
	#define snd_soc_dai_active_deactivate(..)  snd_soc_dai_active_action(..., -1)

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/soc-dai.h  | 3 ---
 sound/soc/soc-dai.c      | 1 -
 sound/soc/soc-dapm.c     | 9 +++++----
 sound/soc/soc-internal.h | 1 +
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 27a85abcab51f..699c0a2674904 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -232,9 +232,6 @@ void snd_soc_dai_resume(struct snd_soc_dai *dai);
 int snd_soc_dai_compress_new(struct snd_soc_dai *dai, struct snd_soc_pcm_runtime *rtd);
 bool snd_soc_dai_stream_valid(const struct snd_soc_dai *dai, int stream);
 
-#define snd_soc_dai_active_activate(dai, stream)	snd_soc_dai_active_action(dai, stream,  1)
-#define snd_soc_dai_active_deactivate(dai, stream)	snd_soc_dai_active_action(dai, stream, -1)
-void snd_soc_dai_active_action(struct snd_soc_dai *dai, int stream, int action);
 int snd_soc_dai_active(const struct snd_soc_dai *dai);
 unsigned int snd_soc_dai_active_stream(const struct snd_soc_dai *dai, int stream);
 
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index b8bdbaf200b05..28827523e3622 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -715,7 +715,6 @@ void snd_soc_dai_active_action(struct snd_soc_dai *dai, int stream, int action)
 	/* see snd_soc_component_active() */
 	dai->component->active		+= action;
 }
-EXPORT_SYMBOL_GPL(snd_soc_dai_active_action);
 
 unsigned int snd_soc_dai_active_stream(const struct snd_soc_dai *dai, int stream)
 {
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index dff23127de429..17e761c911492 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -37,6 +37,7 @@
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
 #include <sound/initval.h>
+#include "soc-internal.h"
 
 #include <trace/events/asoc.h>
 
@@ -4010,7 +4011,7 @@ static int dapm_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 		if (ret < 0)
 			return ret;
 
-		snd_soc_dai_active_activate(source, substream->stream);
+		snd_soc_dai_active_action(source, substream->stream, 1);
 	}
 
 	substream->stream = SNDRV_PCM_STREAM_PLAYBACK;
@@ -4021,7 +4022,7 @@ static int dapm_dai_link_event_pre_pmu(struct snd_soc_dapm_widget *w,
 		if (ret < 0)
 			return ret;
 
-		snd_soc_dai_active_activate(sink, substream->stream);
+		snd_soc_dai_active_action(sink, substream->stream, 1);
 	}
 
 	substream->hw_opened = 1;
@@ -4150,14 +4151,14 @@ static int dapm_dai_link_event(struct snd_soc_dapm_widget *w,
 		substream->stream = SNDRV_PCM_STREAM_CAPTURE;
 		snd_soc_dapm_widget_for_each_source_path(w, path) {
 			source = path->source->priv;
-			snd_soc_dai_active_deactivate(source, substream->stream);
+			snd_soc_dai_active_action(source, substream->stream, -1);
 			snd_soc_dai_shutdown(source, substream, 0);
 		}
 
 		substream->stream = SNDRV_PCM_STREAM_PLAYBACK;
 		snd_soc_dapm_widget_for_each_sink_path(w, path) {
 			sink = path->sink->priv;
-			snd_soc_dai_active_deactivate(sink, substream->stream);
+			snd_soc_dai_active_action(sink, substream->stream, -1);
 			snd_soc_dai_shutdown(sink, substream, 0);
 		}
 		break;
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 3afc50d5760eb..3f3406a006354 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -32,5 +32,6 @@ void snd_soc_dai_symmetric_set_params(struct snd_soc_dai *dai,
 int snd_soc_dai_symmetric_apply(struct snd_pcm_substream *substream, struct snd_soc_dai *dai);
 int snd_soc_dai_symmetric_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
 void snd_soc_dai_symmetric_update(struct snd_pcm_substream *substream);
+void snd_soc_dai_active_action(struct snd_soc_dai *dai, int stream, int action);
 
 #endif /* __SOC_INTERNAL_H */
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk()
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (8 preceding siblings ...)
  2026-09-14  1:46 ` [PATCH 09/10] ASoC: soc-dai: move snd_soc_dai_active_action() to soc-internal.h Kuninori Morimoto
@ 2026-09-14  1:47 ` Kuninori Morimoto
  2026-09-14 13:55   ` Mark Brown
  2026-09-15 15:19   ` Alvin Šipraga
  2026-09-14 13:37 ` [PATCH 00/10] ASoC: add new DAI functions Mark Brown
  10 siblings, 2 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14  1:47 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound

DAI parameter will be capsuled soon, will be not enable to access from
each drivers. DAI priv has been mainly referred from SoundWire driver.
Let's add snd_soc_dai_get_bclk() for internal use.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/soc-dai.c      |  8 ++++++++
 sound/soc/soc-internal.h |  1 +
 sound/soc/soc-pcm.c      | 23 +++++++++++++++++------
 3 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 28827523e3622..6418f5b12fb14 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -1385,3 +1385,11 @@ void snd_soc_dai_symmetric_update(struct snd_pcm_substream *substream)
 	if (symmetry)
 		substream->runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX;
 }
+
+void snd_soc_dai_get_bclk(struct snd_soc_dai *dai, struct clk **bclk, unsigned int *bclk_ratio)
+{
+	if (bclk)
+		*bclk = dai->bclk;
+	if (bclk_ratio)
+		*bclk_ratio = dai->bclk_ratio;
+}
diff --git a/sound/soc/soc-internal.h b/sound/soc/soc-internal.h
index 3f3406a006354..10208ac310095 100644
--- a/sound/soc/soc-internal.h
+++ b/sound/soc/soc-internal.h
@@ -33,5 +33,6 @@ int snd_soc_dai_symmetric_apply(struct snd_pcm_substream *substream, struct snd_
 int snd_soc_dai_symmetric_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params);
 void snd_soc_dai_symmetric_update(struct snd_pcm_substream *substream);
 void snd_soc_dai_active_action(struct snd_soc_dai *dai, int stream, int action);
+void snd_soc_dai_get_bclk(struct snd_soc_dai *dai, struct clk **bclk, unsigned int *bclk_ratio);
 
 #endif /* __SOC_INTERNAL_H */
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 7eb58c4b6fc31..f2a1a13eb95f2 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -445,19 +445,26 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
 	struct snd_interval *rate = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE);
 	struct snd_interval constraint = { .empty = 1 };
 	unsigned int target_rate;
+	struct clk *dai_bclk;
+	unsigned int dai_bclk_ratio;
 	int i;
 
 	/* Protect the rtd list traversal with the ASoC card mutex helper. */
 	guard(snd_soc_card_mutex)(card);
 
+	snd_soc_dai_get_bclk(dai, &dai_bclk, &dai_bclk_ratio);
+
 	/* Scan all DAIs on the card for an active peer sharing the same BCLK */
 	for_each_card_rtds(card, rtd) {
 		for_each_rtd_cpu_dais(rtd, i, other_dai) {
 			unsigned int symmetric_rate;
+			struct clk *other_dai_bclk;
+
+			snd_soc_dai_get_bclk(other_dai, &other_dai_bclk, NULL);
 
 			if (other_dai == dai)
 				continue;
-			if (!other_dai->bclk)
+			if (!other_dai_bclk)
 				continue;
 			if (!snd_soc_dai_active(other_dai))
 				continue;
@@ -470,10 +477,10 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
 			snd_soc_dai_symmetric_get_params(other_dai, &symmetric_rate, NULL, NULL);
 			if (!symmetric_rate)
 				continue;
-			if (!clk_is_match(dai->bclk, other_dai->bclk))
+			if (!clk_is_match(dai_bclk, other_dai_bclk))
 				continue;
 
-			active_bclk_rate = clk_get_rate(other_dai->bclk);
+			active_bclk_rate = clk_get_rate(other_dai_bclk);
 			if (active_bclk_rate)
 				goto found;
 		}
@@ -482,13 +489,13 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
 	return 0;
 
 found:
-	if (dai->bclk_ratio) {
+	if (dai_bclk_ratio) {
 		/*
 		 * Driver has set an explicit BCLK ratio (e.g. for TDM where
 		 * BCLK = rate * slots * slot_width). The only valid rate is
 		 * active_bclk_rate / bclk_ratio.
 		 */
-		target_rate = active_bclk_rate / dai->bclk_ratio;
+		target_rate = active_bclk_rate / dai_bclk_ratio;
 
 		constraint.min = target_rate;
 		constraint.max = target_rate;
@@ -525,7 +532,11 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
 static int soc_pcm_apply_shared_bclk(struct snd_pcm_substream *substream,
 				     struct snd_soc_dai *dai)
 {
-	if (!dai->bclk)
+	struct clk *dai_bclk;
+
+	snd_soc_dai_get_bclk(dai, &dai_bclk, NULL);
+
+	if (!dai_bclk)
 		return 0;
 
 	dev_dbg(dai->dev,
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv()
  2026-09-14  1:46 ` [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv() Kuninori Morimoto
@ 2026-09-14  8:38   ` Charles Keepax
  2026-09-15 15:05   ` Alvin Šipraga
  1 sibling, 0 replies; 33+ messages in thread
From: Charles Keepax @ 2026-09-14  8:38 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Maciej Strozek, Bard Liao, Pierre-Louis Bossart,
	linux-sound

On Mon, Sep 14, 2026 at 01:46:07AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. DAI priv has been mainly referred from SoundWire driver.
> Let's add snd_soc_dai_{set/to}_priv() for it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/10] ASoC: add new DAI functions
  2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
                   ` (9 preceding siblings ...)
  2026-09-14  1:47 ` [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk() Kuninori Morimoto
@ 2026-09-14 13:37 ` Mark Brown
  2026-09-15  0:05   ` Kuninori Morimoto
  10 siblings, 1 reply; 33+ messages in thread
From: Mark Brown @ 2026-09-14 13:37 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: linux-sound

[-- Attachment #1: Type: text/plain, Size: 626 bytes --]

On Mon, Sep 14, 2026 at 01:43:01AM +0000, Kuninori Morimoto wrote:

> This patch-set adds new DAI functions to get dai->xxx, because each
> driver will not be access to them directly when capsuling has done.
> This patch-set just adds new functions, but no user for now.
> All user will use them at (A) timing.

There are a couple of users updated:

>  sound/soc/mediatek/mt8188/mt8188-dai-pcm.c  |  5 +-
>  sound/soc/mediatek/mt8195/mt8195-dai-pcm.c  |  5 +-
>  sound/soc/mediatek/mt8365/mt8365-dai-dmic.c | 10 ++-
>  sound/soc/mediatek/mt8365/mt8365-dai-pcm.c  |  4 +-
>  sound/soc/sdca/sdca_asoc.c                  |  4 +-

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk()
  2026-09-14  1:47 ` [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk() Kuninori Morimoto
@ 2026-09-14 13:55   ` Mark Brown
  2026-09-14 23:56     ` Kuninori Morimoto
  2026-09-15 15:19   ` Alvin Šipraga
  1 sibling, 1 reply; 33+ messages in thread
From: Mark Brown @ 2026-09-14 13:55 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: linux-sound

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

On Mon, Sep 14, 2026 at 01:47:55AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. DAI priv has been mainly referred from SoundWire driver.
> Let's add snd_soc_dai_get_bclk() for internal use.

Weren't we trying to move more to snd_soc_dai_bclk_get()?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk()
  2026-09-14 13:55   ` Mark Brown
@ 2026-09-14 23:56     ` Kuninori Morimoto
  0 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-14 23:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound


Hi Mark

> > DAI parameter will be capsuled soon, will be not enable to access from
> > each drivers. DAI priv has been mainly referred from SoundWire driver.
> > Let's add snd_soc_dai_get_bclk() for internal use.
> 
> Weren't we trying to move more to snd_soc_dai_bclk_get()?

Thank you for your feedback

Yes, I have tried to that. However, since existing functions already
using xxx_{set/get}_yyy() pattern, I have started to worry that using
xxx_{set/get}() pattern looks unnatural.

That said, some functions are using that naming.
But it is very case-by-case. if you ask me "do you have any rules for
naming ?", unfortunately, honestly, I can't answer the question...

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 00/10] ASoC: add new DAI functions
  2026-09-14 13:37 ` [PATCH 00/10] ASoC: add new DAI functions Mark Brown
@ 2026-09-15  0:05   ` Kuninori Morimoto
  0 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-15  0:05 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-sound


Hi Mark

> > This patch-set just adds new functions, but no user for now.
> > All user will use them at (A) timing.
> 
> There are a couple of users updated:
> 
> >  sound/soc/mediatek/mt8188/mt8188-dai-pcm.c  |  5 +-
> >  sound/soc/mediatek/mt8195/mt8195-dai-pcm.c  |  5 +-
> >  sound/soc/mediatek/mt8365/mt8365-dai-dmic.c | 10 ++-
> >  sound/soc/mediatek/mt8365/mt8365-dai-pcm.c  |  4 +-
> >  sound/soc/sdca/sdca_asoc.c                  |  4 +-

Ah, yes indeed.

If it has small number of users, it do add and use in 1 patch.
I believe I have added each driver's maintainer/reviewer on that patch

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active()
  2026-09-14  1:46 ` [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active() Kuninori Morimoto
@ 2026-09-15  1:00   ` Alvin Šipraga
  2026-09-15  5:20     ` Kuninori Morimoto
  0 siblings, 1 reply; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15  1:00 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

Hi Kuninori,

On Mon, Sep 14, 2026 at 01:46:21AM +0000, Kuninori Morimoto wrote:
> snd_soc_dai_stream_active() (A) and snd_soc_dai_active() (B) are almost
> same function, but implemented different place with different naming.
> 
> Let's move snd_soc_dai_stream_active() (A) prev to snd_soc_dai_active()
> (B), and rename it (C).
> 
> (C)+	snd_soc_dai_active_stream()
> (B)	snd_soc_dai_active()
> 	...
> (A)-	snd_soc_dai_stream_active()

I found this rename quite confusing.

Normally I read a function like snd_soc_dai_steam_active(x, y) to mean
"is stream y of dai x active"? We also have snd_soc_dai_stream_valid()
which has similar semantics.

OTOH snd_soc_dai_active_stream() sounds like "what's the active stream
of the DAI?" (which of course doesn't make sense; could be that both or
neither are active).

I sense you're trying to "namespace" all the dai->stream[dir].active
logic under functions named snd_soc_dai_active_xxx(), which is
understandable, but don't you think the following is cleaner?

snd_soc_dai_action()          <=>   similar to snd_soc_runtime_action()
snd_soc_dai_active()          <=>   is (any) DAI stream active?
snd_soc_dai_stream_active()   <=>   is (given) DAI stream active?

BTW, maybe patches 7-9 should be one patch? It might make the review a
bit easier.

Kind regards,
Alvin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params()
  2026-09-14  1:45 ` [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params() Kuninori Morimoto
@ 2026-09-15  1:51   ` Alvin Šipraga
  2026-09-15  4:30     ` Kuninori Morimoto
  0 siblings, 1 reply; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15  1:51 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-sound

Hi Kuninori,

A few more naming ideas below.

On Mon, Sep 14, 2026 at 01:45:14AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. DAI symmetric_xxx has been mainly referred from Mediatek
> drivers. Let's add snd_soc_dai_symmetric_get_params() for it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-dai.h                     |  4 ++++
>  sound/soc/mediatek/mt8188/mt8188-dai-pcm.c  |  5 ++++-
>  sound/soc/mediatek/mt8195/mt8195-dai-pcm.c  |  5 ++++-
>  sound/soc/mediatek/mt8365/mt8365-dai-dmic.c | 10 +++++++---
>  sound/soc/mediatek/mt8365/mt8365-dai-pcm.c  |  4 +++-
>  sound/soc/soc-dai.c                         | 14 ++++++++++++++
>  sound/soc/soc-pcm.c                         |  5 ++++-
>  7 files changed, 40 insertions(+), 7 deletions(-)
> 
> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
> index bd714c3bbf3df..c5544f1789425 100644
> --- a/include/sound/soc-dai.h
> +++ b/include/sound/soc-dai.h
> @@ -563,6 +563,10 @@ struct snd_soc_dai *snd_soc_dai_register(struct snd_soc_component *component,
>  void snd_soc_dai_unregister(struct snd_soc_dai *dai);
>  struct snd_soc_dai *snd_soc_dai_from_list(struct list_head *list);
>  struct list_head *snd_soc_dai_to_list(struct snd_soc_dai *dai);
> +void snd_soc_dai_symmetric_get_params(struct snd_soc_dai *dai,
> +				      unsigned int *symmetric_rate,
> +				      unsigned int *symmetric_channels,
> +				      unsigned int *symmetric_sample_bits);

Why not split into 3 functions:

snd_soc_dai_get_symmetric_rate()
snd_soc_dai_get_symmetric_channels()
snd_soc_dai_get_symmetric_sample_bits()

Or if not, similar to my comment in your other patch, consider
snd_soc_dai_get_symmetric_params() instead. I think it'd be more
consistent with the rest of the API.

>  
>  /* REMOVE ME */
>  #define snd_soc_dai_get_pcm_stream			snd_soc_dai_pcm_stream_get
> diff --git a/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c b/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c
> index 8ca7cc75e21dc..766893ca56d45 100644
> --- a/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c
> +++ b/sound/soc/mediatek/mt8188/mt8188-dai-pcm.c
> @@ -128,7 +128,7 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
>  	unsigned int lrck_inv;
>  	unsigned int bck_inv;
>  	unsigned int fmt;
> -	unsigned int bit_width = dai->symmetric_sample_bits;
> +	unsigned int bit_width;

Alternative:

	unsigned int bit_width = snd_soc_dai_get_symmetric_sample_bits(dai);

>  	unsigned int val = 0;
>  	unsigned int mask = 0;
>  	int fs = 0;
> @@ -137,7 +137,10 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
>  	if (dai->id < 0)
>  		return -EINVAL;
>  
> +	snd_soc_dai_symmetric_get_params(dai, NULL, NULL, &bit_width);
> +
>  	pcmif_priv = afe_priv->dai_priv[dai->id];
> +
>  	slave_mode = pcmif_priv->slave_mode;
>  	lrck_inv = pcmif_priv->lrck_inv;
>  	bck_inv = pcmif_priv->bck_inv;
> diff --git a/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c b/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c
> index cdc16057d50e2..a090995ac9a7f 100644
> --- a/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c
> +++ b/sound/soc/mediatek/mt8195/mt8195-dai-pcm.c
> @@ -127,7 +127,7 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
>  	unsigned int lrck_inv;
>  	unsigned int bck_inv;
>  	unsigned int fmt;
> -	unsigned int bit_width = dai->symmetric_sample_bits;
> +	unsigned int bit_width;

Ditto:

	unsigned int bit_width = snd_soc_dai_get_symmetric_sample_bits(dai);

>  	unsigned int val = 0;
>  	unsigned int mask = 0;
>  	int fs = 0;
> @@ -136,7 +136,10 @@ static int mtk_dai_pcm_configure(struct snd_pcm_substream *substream,
>  	if (dai->id != MT8195_AFE_IO_PCM)
>  		return -EINVAL;
>  
> +	snd_soc_dai_symmetric_get_params(dai, NULL, NULL, &bit_width);
> +
>  	pcmif_priv = afe_priv->dai_priv[dai->id];
> +
>  	slave_mode = pcmif_priv->slave_mode;
>  	lrck_inv = pcmif_priv->lrck_inv;
>  	bck_inv = pcmif_priv->bck_inv;
> diff --git a/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c b/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
> index 0bac143b48bfb..6e1d48f757d22 100644
> --- a/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
> +++ b/sound/soc/mediatek/mt8365/mt8365-dai-dmic.c
> @@ -118,13 +118,17 @@ static int mt8365_dai_configure_dmic(struct mtk_base_afe *afe,
>  	unsigned int clk_phase_sel_ch1 = dmic_data->clk_phase_sel_ch1;
>  	unsigned int clk_phase_sel_ch2 = dmic_data->clk_phase_sel_ch2;
>  	unsigned int val = 0;
> -	unsigned int rate = dai->symmetric_rate;
> -	int reg = get_chan_reg(dai->symmetric_channels);
> +	unsigned int rate;
> +	unsigned int channel;

Alternative:

	unsigned int rate = snd_soc_dai_get_symmetric_rate(dai);
	unsigned int channels = snd_soc_dai_get_symmetric_channels(dai);
	int reg = get_chan_reg(channels);

you get the idea.

[...]

> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index a446e9c1c9887..aaba9ca724e61 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -453,6 +453,8 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
>  	/* Scan all DAIs on the card for an active peer sharing the same BCLK */
>  	for_each_card_rtds(card, rtd) {
>  		for_each_rtd_cpu_dais(rtd, i, other_dai) {
> +			unsigned int symmetric_rate;
> +
>  			if (other_dai == dai)
>  				continue;
>  			if (!other_dai->bclk)
> @@ -465,7 +467,8 @@ static int soc_pcm_shared_bclk_rule_rate(struct snd_pcm_hw_params *params,
>  			 * after snd_soc_dai_hw_params(), so non-zero means
>  			 * the DAI's clk_set_rate() has already executed.
>  			 */
> -			if (!other_dai->symmetric_rate)
> +			snd_soc_dai_symmetric_get_params(other_dai, &symmetric_rate, NULL, NULL);
> +			if (!symmetric_rate)
>  				continue;

 for_each_rtd_cpu_dais(rtd, i, other_dai) {
   ...

   if (!snd_soc_dai_get_symmetric_rate(other_dai))
     continue;
 }

It's a bit more explicit, and avoids the NULL, NULL stuff.

Kind regards,
Alvin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params()
  2026-09-15  1:51   ` Alvin Šipraga
@ 2026-09-15  4:30     ` Kuninori Morimoto
  0 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-15  4:30 UTC (permalink / raw)
  To: Alvin Šipraga
  Cc: Mark Brown, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-sound


Hi Alvin

Thank you for the review

> > +void snd_soc_dai_symmetric_get_params(struct snd_soc_dai *dai,
> > +				      unsigned int *symmetric_rate,
> > +				      unsigned int *symmetric_channels,
> > +				      unsigned int *symmetric_sample_bits);
> 
> Why not split into 3 functions:
> 
> snd_soc_dai_get_symmetric_rate()
> snd_soc_dai_get_symmetric_channels()
> snd_soc_dai_get_symmetric_sample_bits()

Not a big deal. Because user was very few.
Adding 3 functions is very OK, but 1 or 2 user only use each of them.
But indeed the code can be difficult to read, let's add 3 functions.
But I will wait +1 week for other review

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active()
  2026-09-15  1:00   ` Alvin Šipraga
@ 2026-09-15  5:20     ` Kuninori Morimoto
  2026-09-15 13:42       ` Alvin Šipraga
  0 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-15  5:20 UTC (permalink / raw)
  To: Alvin Šipraga; +Cc: Mark Brown, linux-sound


Hi Alvin

Thank you for your review

> Normally I read a function like snd_soc_dai_steam_active(x, y) to mean
> "is stream y of dai x active"? We also have snd_soc_dai_stream_valid()
> which has similar semantics.
> 
> OTOH snd_soc_dai_active_stream() sounds like "what's the active stream
> of the DAI?" (which of course doesn't make sense; could be that both or
> neither are active).
> 
> I sense you're trying to "namespace" all the dai->stream[dir].active
> logic under functions named snd_soc_dai_active_xxx(), which is
> understandable, but don't you think the following is cleaner?
> 
> snd_soc_dai_action()          <=>   similar to snd_soc_runtime_action()
> snd_soc_dai_active()          <=>   is (any) DAI stream active?
> snd_soc_dai_stream_active()   <=>   is (given) DAI stream active?

Yeah, agree.
This is maybe because of my English-skill, but "active" / "action" are
makes it more confusable / non-intuitive.

How about this ?

	snd_soc_dai_stream_count()		(= snd_soc_dai_active_stream())
	snd_soc_dai_stream_count_update()	(= snd_soc_dai_active_action())

	snd_soc_dai_count()			(= snd_soc_dai_active())
	// no _count_update()

Not only DAI, but Component/runtime too

	snd_soc_component_count()		(= snd_soc_component_active())
	snd_soc_component_count_update()	(= snd_soc_component_active_action())

	// no _count()
	snd_soc_runtime_count_update()		(= snd_soc_runtime_action())

Then, we want to rename .active to .count

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active()
  2026-09-15  5:20     ` Kuninori Morimoto
@ 2026-09-15 13:42       ` Alvin Šipraga
  2026-09-16  0:48         ` Kuninori Morimoto
  0 siblings, 1 reply; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 13:42 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

On Tue, Sep 15, 2026 at 05:20:50AM +0000, Kuninori Morimoto wrote:
> 
> Hi Alvin
> 
> Thank you for your review
> 
> > Normally I read a function like snd_soc_dai_steam_active(x, y) to mean
> > "is stream y of dai x active"? We also have snd_soc_dai_stream_valid()
> > which has similar semantics.
> > 
> > OTOH snd_soc_dai_active_stream() sounds like "what's the active stream
> > of the DAI?" (which of course doesn't make sense; could be that both or
> > neither are active).
> > 
> > I sense you're trying to "namespace" all the dai->stream[dir].active
> > logic under functions named snd_soc_dai_active_xxx(), which is
> > understandable, but don't you think the following is cleaner?
> > 
> > snd_soc_dai_action()          <=>   similar to snd_soc_runtime_action()
> > snd_soc_dai_active()          <=>   is (any) DAI stream active?
> > snd_soc_dai_stream_active()   <=>   is (given) DAI stream active?
> 
> Yeah, agree.
> This is maybe because of my English-skill, but "active" / "action" are
> makes it more confusable / non-intuitive.

I agree _active() <=> _action() is not an obvious relationship. But the
_action() form is just an internal thing to avoid code duplication in
snd_soc_runtime_activate()/deactivate():


   snd_soc_runtime_activate()               snd_soc_runtime_deactivate()
            |                                           |
            +----------------------+--------------------+
                                   |
                                   v
                           snd_soc_runtime_action()
                                   |
            +----------------------+--------------------+
            |                                           |
            v                                           v
(A) snd_soc_dai_action(+1)                    snd_soc_dai_action(-1)
              `-> snd_soc_dai_activate()                `-> snd_soc_dai_deactivate()
                  component->active++;                      component->active--;
        or                                          or
(B) snd_soc_component_action(+1) *            snd_soc_component_action(-1) *
              `-> component->active++;                  `-> component->active--;
                           

[*] snd_soc_component_action() doesn't exist yet but I guess it will if
    you proceed with your series this way.

(B) this path is only relevant for PLATFORM components associated with
    the runtime, all CPU/CODEC components' active update go via path (A)


Since it's internal, I wouldn't care too much about the naming. It could
also be snd_soc_dai_active_update(dai, +/-1). Or maybe _push/_pop? But
even as a native English speaker, I think _action() is quite fine.

> 
> How about this ?
> 
> 	snd_soc_dai_stream_count()		(= snd_soc_dai_active_stream())
> 	snd_soc_dai_stream_count_update()	(= snd_soc_dai_active_action())
> 
> 	snd_soc_dai_count()			(= snd_soc_dai_active())
> 	// no _count_update()
> 
> Not only DAI, but Component/runtime too
> 
> 	snd_soc_component_count()		(= snd_soc_component_active())
> 	snd_soc_component_count_update()	(= snd_soc_component_active_action())
> 
> 	// no _count()
> 	snd_soc_runtime_count_update()		(= snd_soc_runtime_action())
> 
> Then, we want to rename .active to .count

I would look at it more from the API consumer side, since naming can
confuse driver authors.

Most users of snd_soc_dai_active() just treat it as a boolean. By
changing it from "active" to "count", we would be advertising the
internal reference counter, which suggests to the author that he/she
should maybe care about it. I don't think drivers should care about it
though. Especially for more niche things like DPCM, the reference
counter value can be surprising.

There's a few cases where the actual integer value of
snd_soc_dai_active() is tested, but they all seem a bit wrong to me.

What I mean to say is, maybe better to keep the consumer API the same
(snd_soc_dai_active()), and instead consider whether it can be removed
from the public API altogether later on? I think when you are done with
your series it will make it much easier to analyze the codebase and see
what can be simplified!

...

Just a few observations on this snd_soc_dai_active() stuff to explain
what I mean.

As best as I can tell, it's a marker saying that the DAI's .startup op
has been called successfully. If it goes from nonzero to zero, then it's
guaranteed that .shutdown has also been called. Nonzero is also
equivalent to PCM .open having been called, except for codec2codec where
there's no PCM.

snd_soc_component_active() always follows snd_soc_dai_active(). That is,
the following condition is always true:

  !!snd_soc_component_active(dai->component) == !!snd_soc_dai_active(dai)

snd_soc_dai_active() is interesting for drivers' DAI ops. It's used as a
guard sometimes in .startup/shutdown to check if substream-independent
work has been done already. Another common pattern is to guard against
.set_sysclk if a substream is already active [codecs/arizona.c].

snd_soc_component_active() is interesting for components drivers' power
management. You see it being checked in .suspend/resume component
ops. I'm not sure if that's actually necessary?

Personally I always found it surprising that DAI .startup can get called
multiple times on the same substream. (I think this is just a DPCM
thing though?) Unlike .hw_params, here is no new info to act on I think.
So maybe the core can guarantee balanced calls of .startup/.shutdown
per-substream, and the guards can be removed. Equally for .set_sysclk,
it's mostly the machine driver's fault if it does that when the PCM is
open. Along the same lines, maybe the core can help here.

Some of the substream-independent work of DAI drivers' .startup/shutdown
probably belong in the component_driver .open/close ops instead. This
would also remove a few of the guards.

Just some thoughts here. I know we were only talking about naming and
don't mean to derail things. But if you have some input then feel free
to share!

Kind regards,
Alvin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id()
  2026-09-15 13:43   ` Alvin Šipraga
@ 2026-09-15 13:43     ` Alvin Šipraga
  0 siblings, 0 replies; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 13:43 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

On Mon, Sep 14, 2026 at 01:43:18AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. add snd_soc_dai_id() to get ID from DAI.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id()
  2026-09-14  1:43 ` [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id() Kuninori Morimoto
@ 2026-09-15 13:43   ` Alvin Šipraga
  2026-09-15 13:43     ` Alvin Šipraga
  0 siblings, 1 reply; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 13:43 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

On Mon, Sep 14, 2026 at 01:43:18AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. add snd_soc_dai_id() to get ID from DAI.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/10] ASoC: soc-dai: add snd_soc_dai_to_component()
  2026-09-14  1:43 ` [PATCH 02/10] ASoC: soc-dai: add snd_soc_dai_to_component() Kuninori Morimoto
@ 2026-09-15 13:44   ` Alvin Šipraga
  0 siblings, 0 replies; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 13:44 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

On Mon, Sep 14, 2026 at 01:43:29AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. add snd_soc_dai_to_component() to get component from DAI.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/10] ASoC: soc-dai: add snd_soc_dai_to_driver()
  2026-09-14  1:43 ` [PATCH 03/10] ASoC: soc-dai: add snd_soc_dai_to_driver() Kuninori Morimoto
@ 2026-09-15 13:44   ` Alvin Šipraga
  0 siblings, 0 replies; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 13:44 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

On Mon, Sep 14, 2026 at 01:43:38AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. add snd_soc_dai_to_driver() to get driver from DAI.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list()
  2026-09-14  1:43 ` [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list() Kuninori Morimoto
@ 2026-09-15 15:03   ` Alvin Šipraga
  2026-09-15 23:37     ` Kuninori Morimoto
  0 siblings, 1 reply; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 15:03 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

On Mon, Sep 14, 2026 at 01:43:51AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. add snd_soc_dai_{to/from}_list() to use for_each macro.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  include/sound/soc-component.h | 14 ++++++++++----
>  include/sound/soc-dai.h       |  2 ++
>  sound/soc/soc-dai.c           | 12 ++++++++++++
>  3 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
> index c49b59630101f..6c1acc984ecb0 100644
> --- a/include/sound/soc-component.h
> +++ b/include/sound/soc-component.h
> @@ -258,10 +258,16 @@ struct snd_soc_component {
>  	void *priv;
>  };
>  
> -#define for_each_component_dais(component, dai)\
> -	list_for_each_entry(dai, &(component)->dai_list, list)
> -#define for_each_component_dais_safe(component, dai, _dai)\
> -	list_for_each_entry_safe(dai, _dai, &(component)->dai_list, list)
> +#define for_each_component_dais(component, dai)				\
> +	for (dai = snd_soc_dai_from_list((component)->dai_list.next);	\
> +	     snd_soc_dai_to_list(dai) != &(component)->dai_list;	\
> +	     dai = snd_soc_dai_from_list(snd_soc_dai_to_list(dai)->next))
> +
> +#define for_each_component_dais_safe(component, dai, _dai)			\
> +	for (dai = snd_soc_dai_from_list((component)->dai_list.next),		\
> +	     _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(dai)->next);	\
> +	     snd_soc_dai_to_list(dai) != &(component)->dai_list;		\
> +	     dai = _dai, _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(_dai)->next))

Hmm, I guess later on you will have to also encapsulate components, and
so this header macro won't be allowed to expose (component)->dai_list
either. You will need some function like:

struct list_head *component_dai_list(c) {
  return &c->dai_list;
}

Then it will be kind of an explosion of function calls when
iterating:

#define for_each_component_dais(c, dai)                   \
  for (dai = dai_from_list(component_dai_list(c)->next),  \
       dai_to_list(dai) != component_dai_list(c);         \
       dai = dai_from_list(dai_to_list(n)->next))

That's 4 calls per iteration I think. Idk if it really matters.

But if you find yourself repeating the pattern, maybe some generic
helper like this would be useful:

#define list_for_each_opaque(pos, head, from_list)        \
  for (struct list_head *_h = (head), *_i = _h->next;     \
       _i != _h && ((pos) = from_list(_i), true);         \
       _i = _i->next)

It's ugly only once, but more optimal (only 1 call to from_list per
iteration, and one call of component_dai_list() at the start).

Then you can do:

#define for_each_component_dais(c, dai)                   \
  list_for_each_opaque(dai, component_dai_list(c), snd_soc_dai_from_list)


It's also fine this way though!


Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

Kind regards,
Alvin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv()
  2026-09-14  1:46 ` [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv() Kuninori Morimoto
  2026-09-14  8:38   ` Charles Keepax
@ 2026-09-15 15:05   ` Alvin Šipraga
  1 sibling, 0 replies; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 15:05 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: Mark Brown, Charles Keepax, Maciej Strozek, Bard Liao,
	Pierre-Louis Bossart, linux-sound

On Mon, Sep 14, 2026 at 01:46:07AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. DAI priv has been mainly referred from SoundWire driver.
> Let's add snd_soc_dai_{set/to}_priv() for it.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

> ---
>  include/sound/soc-dai.h    |  2 ++
>  sound/soc/sdca/sdca_asoc.c |  4 ++--
>  sound/soc/soc-dai.c        | 12 ++++++++++++
>  3 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
> index c5544f1789425..e91f87ca57689 100644
> --- a/include/sound/soc-dai.h
> +++ b/include/sound/soc-dai.h
> @@ -567,6 +567,8 @@ void snd_soc_dai_symmetric_get_params(struct snd_soc_dai *dai,
>  				      unsigned int *symmetric_rate,
>  				      unsigned int *symmetric_channels,
>  				      unsigned int *symmetric_sample_bits);
> +void snd_soc_dai_set_priv(struct snd_soc_dai *dai, void *priv);
> +void *snd_soc_dai_to_priv(struct snd_soc_dai *dai);
>  
>  /* REMOVE ME */
>  #define snd_soc_dai_get_pcm_stream			snd_soc_dai_pcm_stream_get
> diff --git a/sound/soc/sdca/sdca_asoc.c b/sound/soc/sdca/sdca_asoc.c
> index ce2e7c2707657..ccc579f878ff1 100644
> --- a/sound/soc/sdca/sdca_asoc.c
> +++ b/sound/soc/sdca/sdca_asoc.c
> @@ -1507,7 +1507,7 @@ int sdca_asoc_set_constraints(struct device *dev, struct regmap *regmap,
>  		return ret;
>  	}
>  
> -	dai->priv = constraint;
> +	snd_soc_dai_set_priv(dai, constraint);
>  
>  	return 0;
>  }
> @@ -1523,7 +1523,7 @@ EXPORT_SYMBOL_NS(sdca_asoc_set_constraints, "SND_SOC_SDCA");
>  void sdca_asoc_free_constraints(struct snd_pcm_substream *substream,
>  				struct snd_soc_dai *dai)
>  {
> -	struct snd_pcm_hw_constraint_list *constraint = dai->priv;
> +	struct snd_pcm_hw_constraint_list *constraint = snd_soc_dai_to_priv(dai);
>  
>  	kfree(constraint);
>  }
> diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
> index b9a3d29d60914..1df58861c8388 100644
> --- a/sound/soc/soc-dai.c
> +++ b/sound/soc/soc-dai.c
> @@ -32,6 +32,18 @@ struct snd_soc_dai_driver *snd_soc_dai_to_driver(const struct snd_soc_dai *dai)
>  }
>  EXPORT_SYMBOL_GPL(snd_soc_dai_to_driver);
>  
> +void snd_soc_dai_set_priv(struct snd_soc_dai *dai, void *priv)
> +{
> +	dai->priv = priv;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_dai_set_priv);
> +
> +void *snd_soc_dai_to_priv(struct snd_soc_dai *dai)
> +{
> +	return dai->priv;
> +}
> +EXPORT_SYMBOL_GPL(snd_soc_dai_to_priv);
> +
>  struct snd_soc_dai *snd_soc_dai_from_list(struct list_head *list)
>  {
>  	return list_entry(list, typeof(struct snd_soc_dai), list);
> -- 
> 2.53.0
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk()
  2026-09-14  1:47 ` [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk() Kuninori Morimoto
  2026-09-14 13:55   ` Mark Brown
@ 2026-09-15 15:19   ` Alvin Šipraga
  2026-09-15 23:38     ` Kuninori Morimoto
  1 sibling, 1 reply; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-15 15:19 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

On Mon, Sep 14, 2026 at 01:47:55AM +0000, Kuninori Morimoto wrote:
> DAI parameter will be capsuled soon, will be not enable to access from
> each drivers. DAI priv has been mainly referred from SoundWire driver.

^ Stale copy-paste from previous patch?

I guess you will fix it in v2, so you can add:

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

> Let's add snd_soc_dai_get_bclk() for internal use.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> ---
>  sound/soc/soc-dai.c      |  8 ++++++++
>  sound/soc/soc-internal.h |  1 +
>  sound/soc/soc-pcm.c      | 23 +++++++++++++++++------
>  3 files changed, 26 insertions(+), 6 deletions(-)
[...]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list()
  2026-09-15 15:03   ` Alvin Šipraga
@ 2026-09-15 23:37     ` Kuninori Morimoto
  0 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-15 23:37 UTC (permalink / raw)
  To: Alvin Šipraga; +Cc: Mark Brown, linux-sound


Hi Alvin

Thank you for your review

> > DAI parameter will be capsuled soon, will be not enable to access from
> > each drivers. add snd_soc_dai_{to/from}_list() to use for_each macro.
> > 
> > Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
(snip)
> > +#define for_each_component_dais_safe(component, dai, _dai)			\
> > +	for (dai = snd_soc_dai_from_list((component)->dai_list.next),		\
> > +	     _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(dai)->next);	\
> > +	     snd_soc_dai_to_list(dai) != &(component)->dai_list;		\
> > +	     dai = _dai, _dai = snd_soc_dai_from_list(snd_soc_dai_to_list(_dai)->next))
> 
> Hmm, I guess later on you will have to also encapsulate components, and
> so this header macro won't be allowed to expose (component)->dai_list
> either. You will need some function like:

Yes, I will post such patch at some steps later
(It needs many steps for capsuling)

> That's 4 calls per iteration I think. Idk if it really matters.
(snip)
>   for (struct list_head *_h = (head), *_i = _h->next;     \
>        _i != _h && ((pos) = from_list(_i), true);         \
>        _i = _i->next)

Indeed it makes function call a lot is bad point of capsuling...
I don't prepare for loop template, but it is good idea.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk()
  2026-09-15 15:19   ` Alvin Šipraga
@ 2026-09-15 23:38     ` Kuninori Morimoto
  0 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-15 23:38 UTC (permalink / raw)
  To: Alvin Šipraga; +Cc: Mark Brown, linux-sound


Hi Alvin

> > DAI parameter will be capsuled soon, will be not enable to access from
> > each drivers. DAI priv has been mainly referred from SoundWire driver.
> 
> ^ Stale copy-paste from previous patch?

Grr. Thank you for pointing it.
Will fix in v2

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active()
  2026-09-15 13:42       ` Alvin Šipraga
@ 2026-09-16  0:48         ` Kuninori Morimoto
  2026-09-16  1:13           ` Alvin Šipraga
  0 siblings, 1 reply; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-16  0:48 UTC (permalink / raw)
  To: Alvin Šipraga; +Cc: Mark Brown, linux-sound


Hi Alvin

Thank you for your feedback.

> I agree _active() <=> _action() is not an obvious relationship. But the
> _action() form is just an internal thing to avoid code duplication in
> snd_soc_runtime_activate()/deactivate():
(snip)
> Since it's internal, I wouldn't care too much about the naming. It could
> also be snd_soc_dai_active_update(dai, +/-1). Or maybe _push/_pop? But
> even as a native English speaker, I think _action() is quite fine.
(snip)
> Most users of snd_soc_dai_active() just treat it as a boolean.
> changing it from "active" to "count", we would be advertising the
> internal reference counter, which suggests to the author that he/she
> should maybe care about it. I don't think drivers should care about it
> though. Especially for more niche things like DPCM, the reference
> counter value can be surprising.

Basically I have no big objection from my side. But I have few concern.

1. Most users are using it as boolean. This is OK. But it is count
   up/down on .active value. It is confusable ? Indeed it is internal
   things, but this kind of confusion load some issue.

   I want to rename .active to .count

-	xxx->active += xxx;
+	xxx->count  += xxx;

   But the function is keeping _active().  Maybe _is_active() is more
   good naming (?), and use bool.
	
-	unsigned int xxx_active()
+	bool         xxx_is_active()
	{
-		return   xxx->count;
+		return !!xxx->count;
	}

2. From non-English speaker (or only me ?) point of view,
   active / action are very confusable. The diff is "ve" / "on" only :(

	snd_soc_dai_active()
	snd_soc_dai_action()
	                ^^

   I personally would like to grep related things by same grep.
   So I would like to use active_update() instead.
   # Ah, so _is_active() is not good match to this naming...

	snd_soc_dai_active()
	snd_soc_dai_active_update()
	^^^^^^^^^^^^^^^^^^

   # this is one of the reason why I want to use get/set at end of
   # function. But is a little bit strange name and different from
   # traditional naming
   #	snd_soc_dai_xxx_get()		snd_soc_dai_get_xxx()
   #	snd_soc_dai_xxx_set()		snd_soc_dai_set_xxx()
   #	^^^^^^^^^^^^^^^^		^^^^^^^^^^^^   ^^^^

These are not a big deal, and I don't want to start bicycle shed mail here.
If you have no big objection about above, I will use it.
If you have, I will use your idea.

> As best as I can tell, it's a marker saying that the DAI's .startup op
> has been called successfully. If it goes from nonzero to zero, then it's
> guaranteed that .shutdown has also been called. Nonzero is also
> equivalent to PCM .open having been called, except for codec2codec where
> there's no PCM.

Yes.

> snd_soc_component_active() always follows snd_soc_dai_active(). That is,
> the following condition is always true:
> 
>   !!snd_soc_component_active(dai->component) == !!snd_soc_dai_active(dai)

Maybe not always ?
For example, if Component has many DAIs or, Component is used as "platform"
(= DAI is not working, but Component is working)

	component (1)
	  - DAI1 (1)
=>	  - DAI2 (0)

> Personally I always found it surprising that DAI .startup can get called
> multiple times on the same substream. (I think this is just a DPCM
> thing though?) Unlike .hw_params, here is no new info to act on I think.
> So maybe the core can guarantee balanced calls of .startup/.shutdown
> per-substream, and the guards can be removed. Equally for .set_sysclk,
> it's mostly the machine driver's fault if it does that when the PCM is
> open. Along the same lines, maybe the core can help here.

Yeah, agree.
I will focus to capsuling for a while, but this can be next focus point.
(Actually I already have next topic, after capsuling)


Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active()
  2026-09-16  0:48         ` Kuninori Morimoto
@ 2026-09-16  1:13           ` Alvin Šipraga
  2026-09-16  1:45             ` Kuninori Morimoto
  0 siblings, 1 reply; 33+ messages in thread
From: Alvin Šipraga @ 2026-09-16  1:13 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Mark Brown, linux-sound

Hi Kuninori,

On Wed, Sep 16, 2026 at 12:48:52AM +0000, Kuninori Morimoto wrote:
> 
> Hi Alvin
> 
> Thank you for your feedback.
> 
> > I agree _active() <=> _action() is not an obvious relationship. But the
> > _action() form is just an internal thing to avoid code duplication in
> > snd_soc_runtime_activate()/deactivate():
> (snip)
> > Since it's internal, I wouldn't care too much about the naming. It could
> > also be snd_soc_dai_active_update(dai, +/-1). Or maybe _push/_pop? But
> > even as a native English speaker, I think _action() is quite fine.
> (snip)
> > Most users of snd_soc_dai_active() just treat it as a boolean.
> > changing it from "active" to "count", we would be advertising the
> > internal reference counter, which suggests to the author that he/she
> > should maybe care about it. I don't think drivers should care about it
> > though. Especially for more niche things like DPCM, the reference
> > counter value can be surprising.
> 
> Basically I have no big objection from my side. But I have few concern.
> 
> 1. Most users are using it as boolean. This is OK. But it is count
>    up/down on .active value. It is confusable ? Indeed it is internal
>    things, but this kind of confusion load some issue.
> 
>    I want to rename .active to .count
> 
> -	xxx->active += xxx;
> +	xxx->count  += xxx;
> 
>    But the function is keeping _active().  Maybe _is_active() is more
>    good naming (?), and use bool.
> 	
> -	unsigned int xxx_active()
> +	bool         xxx_is_active()
> 	{
> -		return   xxx->count;
> +		return !!xxx->count;
> 	}

Making it a bool would be an improvement I think. But it will require a
few driver changes, and I think it's out of the scope of your
series. But good you agree with the reasoning.

> 
> 2. From non-English speaker (or only me ?) point of view,
>    active / action are very confusable. The diff is "ve" / "on" only :(

That's a good reason to change it then. And to be honest, I can't give
you a good reason for why it feels OK to me... I guess that's the
problem with English ;-D

> 
> 	snd_soc_dai_active()
> 	snd_soc_dai_action()
> 	                ^^
> 
>    I personally would like to grep related things by same grep.
>    So I would like to use active_update() instead.

I think changing _action() => _active_update() is intuitive and makes
good sense.

>    # Ah, so _is_active() is not good match to this naming...
> 
> 	snd_soc_dai_active()
> 	snd_soc_dai_active_update()
> 	^^^^^^^^^^^^^^^^^^
> 
>    # this is one of the reason why I want to use get/set at end of
>    # function. But is a little bit strange name and different from
>    # traditional naming
>    #	snd_soc_dai_xxx_get()		snd_soc_dai_get_xxx()
>    #	snd_soc_dai_xxx_set()		snd_soc_dai_set_xxx()
>    #	^^^^^^^^^^^^^^^^		^^^^^^^^^^^^   ^^^^

Yea, I see your grepping point. I see from your mail agent that you are
an emacs user. Normally I do a fuzzy projectile grep[*] of the form:

snd_soc    dai_fmt      set

       ^^^^       ^^^^^^ -------- extra spaces for emphasis, I only use one

[*] helm-projectile-rg

and it gets me quite far (set can be before dai_fmt and it still matches).

But agree the get_xxx/xxx_get inconsistency is unfortunate.

> 
> These are not a big deal, and I don't want to start bicycle shed mail here.
> If you have no big objection about above, I will use it.
> If you have, I will use your idea.

No objection

> 
> > As best as I can tell, it's a marker saying that the DAI's .startup op
> > has been called successfully. If it goes from nonzero to zero, then it's
> > guaranteed that .shutdown has also been called. Nonzero is also
> > equivalent to PCM .open having been called, except for codec2codec where
> > there's no PCM.
> 
> Yes.
> 
> > snd_soc_component_active() always follows snd_soc_dai_active(). That is,
> > the following condition is always true:
> > 
> >   !!snd_soc_component_active(dai->component) == !!snd_soc_dai_active(dai)
> 
> Maybe not always ?
> For example, if Component has many DAIs or, Component is used as "platform"
> (= DAI is not working, but Component is working)
> 
> 	component (1)
> 	  - DAI1 (1)
> =>	  - DAI2 (0)

Yes, of course, forgot about multiple DAIis per component.

> 
> > Personally I always found it surprising that DAI .startup can get called
> > multiple times on the same substream. (I think this is just a DPCM
> > thing though?) Unlike .hw_params, here is no new info to act on I think.
> > So maybe the core can guarantee balanced calls of .startup/.shutdown
> > per-substream, and the guards can be removed. Equally for .set_sysclk,
> > it's mostly the machine driver's fault if it does that when the PCM is
> > open. Along the same lines, maybe the core can help here.
> 
> Yeah, agree.
> I will focus to capsuling for a while, but this can be next focus point.
> (Actually I already have next topic, after capsuling)

Of course. I think it's a big/messy topic I'm bringing anyway. I will
look into a bit more and maybe try to submit some improvements if the
idea makes sense.

Kind regards,
Alvin

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active()
  2026-09-16  1:13           ` Alvin Šipraga
@ 2026-09-16  1:45             ` Kuninori Morimoto
  0 siblings, 0 replies; 33+ messages in thread
From: Kuninori Morimoto @ 2026-09-16  1:45 UTC (permalink / raw)
  To: Alvin Šipraga; +Cc: Mark Brown, linux-sound


Hi Alvin

Thank you for your review/help

> Making it a bool would be an improvement I think. But it will require a
> few driver changes, and I think it's out of the scope of your
> series. But good you agree with the reasoning.

Thanks.
Yes, not to break existing code, let's keep "unsigned int" for a while

> That's a good reason to change it then. And to be honest, I can't give
> you a good reason for why it feels OK to me... I guess that's the
> problem with English ;-D

Hehe :)

> I think changing _action() => _active_update() is intuitive and makes
> good sense.

Thank you

> Yea, I see your grepping point. I see from your mail agent that you are
> an emacs user. Normally I do a fuzzy projectile grep[*] of the form:
(snip)
> [*] helm-projectile-rg

Nice to know that you are the Helm user :)

Thank you for your feedback.
I will prepare v2 patch.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2026-09-16  1:45 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14  1:43 [PATCH 00/10] ASoC: add new DAI functions Kuninori Morimoto
2026-09-14  1:43 ` [PATCH 01/10] ASoC: soc-dai: add snd_soc_dai_id() Kuninori Morimoto
2026-09-15 13:43   ` Alvin Šipraga
2026-09-15 13:43     ` Alvin Šipraga
2026-09-14  1:43 ` [PATCH 02/10] ASoC: soc-dai: add snd_soc_dai_to_component() Kuninori Morimoto
2026-09-15 13:44   ` Alvin Šipraga
2026-09-14  1:43 ` [PATCH 03/10] ASoC: soc-dai: add snd_soc_dai_to_driver() Kuninori Morimoto
2026-09-15 13:44   ` Alvin Šipraga
2026-09-14  1:43 ` [PATCH 04/10] ASoC: soc-dai: add snd_soc_dai_{to/from}_list() Kuninori Morimoto
2026-09-15 15:03   ` Alvin Šipraga
2026-09-15 23:37     ` Kuninori Morimoto
2026-09-14  1:45 ` [PATCH 05/10] ASoC: soc-dai: add snd_soc_dai_symmetric_get_params() Kuninori Morimoto
2026-09-15  1:51   ` Alvin Šipraga
2026-09-15  4:30     ` Kuninori Morimoto
2026-09-14  1:46 ` [PATCH 06/10] ASoC: soc-dai: add snd_soc_dai_{set/to}_priv() Kuninori Morimoto
2026-09-14  8:38   ` Charles Keepax
2026-09-15 15:05   ` Alvin Šipraga
2026-09-14  1:46 ` [PATCH 07/10] ASoC: soc-dai: rename snd_soc_dai_stream_active() Kuninori Morimoto
2026-09-15  1:00   ` Alvin Šipraga
2026-09-15  5:20     ` Kuninori Morimoto
2026-09-15 13:42       ` Alvin Šipraga
2026-09-16  0:48         ` Kuninori Morimoto
2026-09-16  1:13           ` Alvin Šipraga
2026-09-16  1:45             ` Kuninori Morimoto
2026-09-14  1:46 ` [PATCH 08/10] ASoC: soc-dai: rename snd_soc_dai_action() Kuninori Morimoto
2026-09-14  1:46 ` [PATCH 09/10] ASoC: soc-dai: move snd_soc_dai_active_action() to soc-internal.h Kuninori Morimoto
2026-09-14  1:47 ` [PATCH 10/10] ASoC: soc-dai: add snd_soc_dai_get_bclk() Kuninori Morimoto
2026-09-14 13:55   ` Mark Brown
2026-09-14 23:56     ` Kuninori Morimoto
2026-09-15 15:19   ` Alvin Šipraga
2026-09-15 23:38     ` Kuninori Morimoto
2026-09-14 13:37 ` [PATCH 00/10] ASoC: add new DAI functions Mark Brown
2026-09-15  0:05   ` Kuninori Morimoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).