Skip to contentSkip to conversation

Add SDCA DAI ops helpers

PATCH In review Charles Keepax 3 participants 12 messages Jul 7, 2025 – Jul 21, 2025

Subsystems (3)
lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

cover Add SDCA DAI ops helpers

First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.

Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.

Thanks,
Charles

Charles Keepax (7):
ASoC: SDCA: Allow read-only controls to be deferrable
ASoC: SDCA: Remove overly chatty input pin list warning
ASoC: SDCA: Move SDCA search functions and export
ASoC: soc-dai: Add private data to snd_soc_dai
ASoC: SDCA: Add helper to add DAI constraints
ASoC: SDCA: Add a helper to get the SoundWire port number
ASoC: SDCA: Add hw_params() helper function

 include/sound/sdca_asoc.h       |  19 ++
 include/sound/sdca_function.h   |  31 +++
 include/sound/soc-dai.h         |   3 +
 sound/soc/sdca/sdca_asoc.c      | 427 +++++++++++++++++++++++++++-----
 sound/soc/sdca/sdca_functions.c |  72 +++++-
 5 files changed, 490 insertions(+), 62 deletions(-)
Signature · 1 line
2.39.5
author maintainer
#1 lore raw

PATCH 1/7 ASoC: SDCA: Allow read-only controls to be deferrable

The current SDCA Control parsing only checks the deferrable flag for Read/Write and Dual Ranked controls. However, reads can defer as well as writes so Read Only controls should also check for the deferrable flag. Add the handling for this into find_sdca_entity_control().

Fixes 42b144cb6a2d ("ASoC: SDCA: Add SDCA Control parsing")
---
 sound/soc/sdca/sdca_functions.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sdca/sdca_functions.c +2 -1
index c34f3bf62983..164dc0e16a31 100644
@@ -881,7 +881,8 @@ static int find_sdca_entity_control(struct device *dev, struct sdca_entity *enti
 			control->value = tmp;
 			control->has_fixed = true;
 		}
-
+		fallthrough;
+	case SDCA_ACCESS_MODE_RO:
 		control->deferrable = fwnode_property_read_bool(control_node,
 								"mipi-sdca-control-deferrable");
 		break;
Signature · 1 line
2.39.5
author maintainer
#2 lore raw

PATCH 2/7 ASoC: SDCA: Remove overly chatty input pin list warning

In reply to Charles Keepax

An input pin list is not generally required, so a warning on the absence of one is a little extreme, remove this warning message.

---
 sound/soc/sdca/sdca_functions.c | 1 -
 1 file changed, 1 deletion(-)
sound/soc/sdca/sdca_functions.c +0 -1
index 164dc0e16a31..1113f8d91b3a 100644
@@ -1635,7 +1635,6 @@ static int find_sdca_entity_connection(struct device *dev,
 	ret = fwnode_property_read_u64(entity_node, "mipi-sdca-input-pin-list", &pin_list);
 	if (ret == -EINVAL) {
 		/* Allow missing pin lists, assume no pins. */
-		dev_warn(dev, "%s: missing pin list\n", entity->label);
 		return 0;
 	} else if (ret) {
 		dev_err(dev, "%s: failed to read pin list: %d\n", entity->label, ret);
Signature · 1 line
2.39.5
author maintainer
#3 lore raw

PATCH 3/7 ASoC: SDCA: Move SDCA search functions and export

In reply to Charles Keepax

The ASoC code for SDCA contains several helper functions that search for controls/ranges/etc. As the code evolves these helpers are likely to be useful to anything interacting with the stored DisCo data. Move the helpers into sdca_function.c and export them so other modules can also use them.

---
 include/sound/sdca_function.h   | 11 +++++
 sound/soc/sdca/sdca_asoc.c      | 73 ++++++---------------------------
 sound/soc/sdca/sdca_functions.c | 50 ++++++++++++++++++++++
 3 files changed, 74 insertions(+), 60 deletions(-)
include/sound/sdca_function.h +11 -0
index b4a97ff08729..543c09e99ab1 100644
@@ -1316,4 +1316,15 @@ int sdca_parse_function(struct device *dev,
 			struct sdca_function_desc *desc,
 			struct sdca_function_data *function);
 
+struct sdca_control *sdca_selector_find_control(struct device *dev,
+						struct sdca_entity *entity,
+						const int sel);
+struct sdca_control_range *sdca_control_find_range(struct device *dev,
+						   struct sdca_entity *entity,
+						   struct sdca_control *control,
+						   int cols, int rows);
+struct sdca_control_range *sdca_selector_find_range(struct device *dev,
+						    struct sdca_entity *entity,
+						    int sel, int cols, int rows);
+
 #endif
sound/soc/sdca/sdca_asoc.c +13 -60

139 lines not on this page · raw message

sound/soc/sdca/sdca_functions.c +50 -0

56 lines not on this page · raw message

Signature · 1 line
2.39.5
author maintainer
#4 lore raw

PATCH 4/7 ASoC: soc-dai: Add private data to snd_soc_dai

In reply to Charles Keepax

Add a private data pointer that can be used to store context along with the DAI. This will be useful to allow the SDCA class library to store data separately from the CODEC driver itself.

---
 include/sound/soc-dai.h | 3 +++
 1 file changed, 3 insertions(+)
include/sound/soc-dai.h +3 -0
index d19ab5572d2b..166c29557e9d 100644
@@ -463,6 +463,9 @@ struct snd_soc_dai {
 
 	/* bit field */
 	unsigned int probed:1;
+
+	/* DAI private data */
+	void *priv;
 };
 
 static inline const struct snd_soc_pcm_stream *
Signature · 1 line
2.39.5
author maintainer
#5 lore raw

PATCH 5/7 ASoC: SDCA: Add helper to add DAI constraints

In reply to Charles Keepax

Currently the core SDCA code simply creates a place holder available channels from 1 to SDCA_MAX_CHANNEL_COUNT. Add a helper function that will constrain the number of channels based on the actual available SDCA Clusters in DisCo. Currently this code only handles Input Terminal Entities as they directly specify the Cluster. More work will be required later for Output Terminals which inherit their Cluster. Typically this new helper would be called from the DAIs startup callback.

---
 include/sound/sdca_asoc.h       | 10 ++++
 include/sound/sdca_function.h   | 12 ++++
 sound/soc/sdca/sdca_asoc.c      | 99 +++++++++++++++++++++++++++++++++
 sound/soc/sdca/sdca_functions.c | 18 ++++++
 4 files changed, 139 insertions(+)
include/sound/sdca_asoc.h +10 -0
index 9121531f0826..bbf146e4fcea 100644
@@ -11,9 +11,12 @@
 #define __SDCA_ASOC_H__
 
 struct device;
+struct regmap;
 struct sdca_function_data;
 struct snd_kcontrol_new;
+struct snd_pcm_substream;
 struct snd_soc_component_driver;
+struct snd_soc_dai;
 struct snd_soc_dai_driver;
 struct snd_soc_dai_ops;
 struct snd_soc_dapm_route;
@@ -39,4 +42,11 @@ int sdca_asoc_populate_component(struct device *dev,
 				 struct snd_soc_dai_driver **dai_drv, int *num_dai_drv,
 				 const struct snd_soc_dai_ops *ops);
 
+int sdca_asoc_set_constraints(struct device *dev, struct regmap *regmap,
+			      struct sdca_function_data *function,
+			      struct snd_pcm_substream *substream,
+			      struct snd_soc_dai *dai);
+void sdca_asoc_free_constraints(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai);
+
 #endif // __SDCA_ASOC_H__
include/sound/sdca_function.h +12 -0
index 543c09e99ab1..3bde07409bf3 100644
@@ -1268,6 +1268,15 @@ struct sdca_cluster {
 	struct sdca_channel *channels;
 };
 
+/**
+ * enum sdca_cluster_range - SDCA Range column definitions for ClusterIndex
+ */
+enum sdca_cluster_range {
+	SDCA_CLUSTER_BYTEINDEX				= 0,
+	SDCA_CLUSTER_CLUSTERID				= 1,
+	SDCA_CLUSTER_NCOLS				= 2,
+};
+
 /**
  * struct sdca_function_data - top-level information for one SDCA function
  * @desc: Pointer to short descriptor from initial parsing.
@@ -1326,5 +1335,8 @@ struct sdca_control_range *sdca_control_find_range(struct device *dev,
 struct sdca_control_range *sdca_selector_find_range(struct device *dev,
 						    struct sdca_entity *entity,
 						    int sel, int cols, int rows);
+struct sdca_cluster *sdca_id_find_cluster(struct device *dev,
+					  struct sdca_function_data *function,
+					  const int id);
 
 #endif
sound/soc/sdca/sdca_asoc.c +99 -0

118 lines not on this page · raw message

sound/soc/sdca/sdca_functions.c +18 -0
index ca965e8a4c46..0019c72b4904 100644
@@ -1991,6 +1991,24 @@ struct sdca_control_range *sdca_selector_find_range(struct device *dev,
 }
 EXPORT_SYMBOL_NS(sdca_selector_find_range, "SND_SOC_SDCA");
 
+struct sdca_cluster *sdca_id_find_cluster(struct device *dev,
+					  struct sdca_function_data *function,
+					  const int id)
+{
+	int i;
+
+	for (i = 0; i < function->num_clusters; i++) {
+		struct sdca_cluster *cluster = &function->clusters[i];
+
+		if (cluster->id == id)
+			return cluster;
+	}
+
+	dev_err(dev, "%s: cluster %#x: missing\n", function->desc->name, id);
+	return NULL;
+}
+EXPORT_SYMBOL_NS(sdca_id_find_cluster, "SND_SOC_SDCA");
+
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("SDCA library");
 MODULE_IMPORT_NS("SND_SOC_SDCA_HID");
Signature · 1 line
2.39.5
author maintainer
#6 lore raw

PATCH 6/7 ASoC: SDCA: Add a helper to get the SoundWire port number

In reply to Charles Keepax

Add a helper function to extract the SoundWire hardware port number from the SDCA DataPort Selector Control. Typically this would be called from hw_params() and used to call sdw_stream_add_slave().

---
 include/sound/sdca_asoc.h     |  3 ++
 include/sound/sdca_function.h |  8 ++++
 sound/soc/sdca/sdca_asoc.c    | 75 +++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
include/sound/sdca_asoc.h +3 -0
index bbf146e4fcea..800a26adcd8e 100644
@@ -48,5 +48,8 @@ int sdca_asoc_set_constraints(struct device *dev, struct regmap *regmap,
 			      struct snd_soc_dai *dai);
 void sdca_asoc_free_constraints(struct snd_pcm_substream *substream,
 				struct snd_soc_dai *dai);
+int sdca_asoc_get_port(struct device *dev, struct regmap *regmap,
+		       struct sdca_function_data *function,
+		       struct snd_soc_dai *dai);
 
 #endif // __SDCA_ASOC_H__
include/sound/sdca_function.h +8 -0
index 3bde07409bf3..90d77fc46416 100644
@@ -185,6 +185,14 @@ enum sdca_usage_range {
 	SDCA_USAGE_NCOLS				= 7,
 };
 
+/**
+ * enum sdca_dataport_selector_range - Column definitions for DataPort_Selector
+ */
+enum sdca_dataport_selector_range {
+	SDCA_DATAPORT_SELECTOR_NCOLS			= 16,
+	SDCA_DATAPORT_SELECTOR_NROWS			= 4,
+};
+
 /**
  * enum sdca_mu_controls - SDCA Controls for Mixer Unit
  *
sound/soc/sdca/sdca_asoc.c +75 -0

84 lines not on this page · raw message

Signature · 1 line
2.39.5
author maintainer
#7 lore raw

PATCH 7/7 ASoC: SDCA: Add hw_params() helper function

In reply to Charles Keepax

Add a helper function that can be called from hw_params() in the DAI ops to configure the SDCA Cluster, Clock and Usage controls. These setup the channels, sample rate, and bit depths that will be used by the Terminal.

---
 include/sound/sdca_asoc.h  |   6 ++
 sound/soc/sdca/sdca_asoc.c | 180 +++++++++++++++++++++++++++++++++++++
 2 files changed, 186 insertions(+)
include/sound/sdca_asoc.h +6 -0
index 800a26adcd8e..aa9124f93218 100644
@@ -14,6 +14,7 @@ struct device;
 struct regmap;
 struct sdca_function_data;
 struct snd_kcontrol_new;
+struct snd_pcm_hw_params;
 struct snd_pcm_substream;
 struct snd_soc_component_driver;
 struct snd_soc_dai;
@@ -51,5 +52,10 @@ void sdca_asoc_free_constraints(struct snd_pcm_substream *substream,
 int sdca_asoc_get_port(struct device *dev, struct regmap *regmap,
 		       struct sdca_function_data *function,
 		       struct snd_soc_dai *dai);
+int sdca_asoc_hw_params(struct device *dev, struct regmap *regmap,
+			struct sdca_function_data *function,
+			struct snd_pcm_substream *substream,
+			struct snd_pcm_hw_params *params,
+			struct snd_soc_dai *dai);
 
 #endif // __SDCA_ASOC_H__
sound/soc/sdca/sdca_asoc.c +180 -0

189 lines not on this page · raw message

Signature · 1 line
2.39.5
reviewer Reviewed-by on the v1 series
#8 lore raw
In reply to Charles Keepax
Quoted 7 lines · Charles Keepax

First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.

For the patchset:

Quoted 4 lines

Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.

FDL is a very desirable feature, but shouldn't there be an UMP (Universal Message Passing) layer first? HID and FDL rely on UMP. I would have expected the ownership changes to be handled in a shared UMP library or set of helpers, no?

author maintainer
#9 lore raw
Quoted 18 lines · Pierre-Louis Bossart
Quoted 7 lines · Charles Keepax

First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.

For the patchset:

Quoted 4 lines

Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.

Quoted 4 lines

FDL is a very desirable feature, but shouldn't there be an UMP (Universal Message Passing) layer first? HID and FDL rely on UMP. I would have expected the ownership changes to be handled in a shared UMP library or set of helpers, no?

Yeah we are still working through the last iterations internally on the FDL stuff. I think it probably does make sense to pull out some UMP helpers (indeed I was have a look at it yesterday) although they should be pretty simple so I imagine we will just send them as part of the FDL set (subject to change as we work through it).

Thanks,
Charles

#10 lore raw
Quoted 24 lines · Charles Keepax
Quoted 18 lines · Pierre-Louis Bossart
Quoted 7 lines · Charles Keepax

First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.

For the patchset:

Quoted 4 lines

Hopefully we are getting fairly close to completing a first version of the SDCA work now. Should be one more series to add FDL (firmware downloading), then we should be able to send a first version of the actual SDCA class driver itself.

Quoted 4 lines

FDL is a very desirable feature, but shouldn't there be an UMP (Universal Message Passing) layer first? HID and FDL rely on UMP. I would have expected the ownership changes to be handled in a shared UMP library or set of helpers, no?

Quoted 6 lines

Yeah we are still working through the last iterations internally on the FDL stuff. I think it probably does make sense to pull out some UMP helpers (indeed I was have a look at it yesterday) although they should be pretty simple so I imagine we will just send them as part of the FDL set (subject to change as we work through it).

Indeed UMP is pretty simple on paper, but as usual there will be corner cases of the ownership change never happening. I vaguely remember there was a sequence required for the HID used by Realtek. FDL is another order of magnitude in terms of error handling, the state machine is rather complicated and it'll fun to see how implementations map to the spec :-)

maintainer
#11 lore raw
In reply to Charles Keepax
Quoted 9 lines · Charles Keepax

First, a couple of minor code fixups to already submitted code. Then some patches to add new DAI ops helpers for the SDCA stuff, these allow configuring things like the sample rate and finding out which SoundWire port should be used for a specific SDCA streaming input/output terminal. Still a few bits of outstanding work here (propogation of Cluster information particularly) but his should be good enough to get some basic use-cases working.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/7] ASoC: SDCA: Allow read-only controls to be deferrable

      commit: 4eb6ad5d2080681b531db2c1764246f9a868062f
[2/7] ASoC: SDCA: Remove overly chatty input pin list warning
      commit: cbcb5f5c2be523ef0908df290b3033138bd4c185
[3/7] ASoC: SDCA: Move SDCA search functions and export
      commit: c57ad862462f064c0bd943a5828f5e0eca469ca5
[4/7] ASoC: soc-dai: Add private data to snd_soc_dai
      commit: 5f86d41d0410b072b5f4875ef5d38bf8d18eed55
[5/7] ASoC: SDCA: Add helper to add DAI constraints
      commit: 7b0d60dbb468fa82e9053292cdc8a5436400bfaf
[6/7] ASoC: SDCA: Add a helper to get the SoundWire port number
      commit: 264d3d776fb1a428706b0ca0f679bbed876fe7c9
[7/7] ASoC: SDCA: Add hw_params() helper function
      commit: 4ed357f72a0e0a691304e5f14a3323811c8ce862

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark