[PATCH v3 3/3] ASoC: SDCA: Support devices with multiple functions of identical type
From: Charles Keepax
Date: Thu Apr 30 2026 - 11:15:09 EST
It is possible that SDCAs devices might have multiple functions of
the same type, as the entity names within a function are defined by
the specification it is very likely such a device will have duplicate
entities. This causes problems where DAIs and ALSA controls end up
with clashing names.
This can be handled by adding the function address into the names to
ensure uniqueness, although, ideally this would have been included from
the start. User-space already has UCM using the current control names,
so as a compromise the first function of a given type will use the
raw entity names, then duplicates will get an added function address.
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxx>
Signed-off-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>
---
No changes since v2.
include/sound/sdca.h | 4 ++++
sound/soc/sdca/sdca_functions.c | 26 ++++++++++++++++++++++++--
sound/soc/sdca/sdca_interrupts.c | 3 +--
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/include/sound/sdca.h b/include/sound/sdca.h
index 67ff3c88705d5..2bdf4e333e044 100644
--- a/include/sound/sdca.h
+++ b/include/sound/sdca.h
@@ -26,6 +26,8 @@ struct sdca_dev;
* @name: Human-readable string.
* @type: Function topology type.
* @adr: ACPI address (used for SDCA register access).
+ * @duplicate: Internal flag to indicate if other functions of the same type
+ * exist.
*/
struct sdca_function_desc {
struct fwnode_handle *node;
@@ -33,6 +35,8 @@ struct sdca_function_desc {
const char *name;
u32 type;
u8 adr;
+
+ bool duplicate;
};
/**
diff --git a/sound/soc/sdca/sdca_functions.c b/sound/soc/sdca/sdca_functions.c
index 02abb7315b727..77940bd6b33c9 100644
--- a/sound/soc/sdca/sdca_functions.c
+++ b/sound/soc/sdca/sdca_functions.c
@@ -98,7 +98,7 @@ static int find_sdca_function(struct acpi_device *adev, void *data)
u32 function_type;
int function_index;
u64 addr;
- int ret;
+ int i, ret;
if (sdca_data->num_functions >= SDCA_MAX_FUNCTION_COUNT) {
dev_err(dev, "maximum number of functions exceeded\n");
@@ -159,6 +159,14 @@ static int find_sdca_function(struct acpi_device *adev, void *data)
/* store results */
function_index = sdca_data->num_functions;
+
+ for (i = 0; i < function_index; i++) {
+ if (sdca_data->function[i].type == function_type) {
+ sdca_data->function[function_index].duplicate = true;
+ break;
+ }
+ }
+
sdca_data->function[function_index].adr = addr;
sdca_data->function[function_index].type = function_type;
sdca_data->function[function_index].name = function_name;
@@ -1466,6 +1474,7 @@ static int find_sdca_entity_xu(struct device *dev,
}
static int find_sdca_entity(struct device *dev, struct sdw_slave *sdw,
+ struct sdca_function_data *function,
struct fwnode_handle *function_node,
struct fwnode_handle *entity_node,
struct sdca_entity *entity)
@@ -1481,6 +1490,13 @@ static int find_sdca_entity(struct device *dev, struct sdw_slave *sdw,
return ret;
}
+ if (function->desc->duplicate) {
+ entity->label = devm_kasprintf(dev, GFP_KERNEL, "%d %s",
+ function->desc->adr, entity->label);
+ if (!entity->label)
+ return -ENOMEM;
+ }
+
ret = fwnode_property_read_u32(entity_node, "mipi-sdca-entity-type", &tmp);
if (ret) {
dev_err(dev, "%s: type missing: %d\n", entity->label, ret);
@@ -1578,7 +1594,7 @@ static int find_sdca_entities(struct device *dev, struct sdw_slave *sdw,
return -EINVAL;
}
- ret = find_sdca_entity(dev, sdw, function_node,
+ ret = find_sdca_entity(dev, sdw, function, function_node,
entity_node, &entities[i]);
fwnode_handle_put(entity_node);
if (ret)
@@ -1605,8 +1621,14 @@ static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data *
const char *entity_label)
{
struct sdca_entity *entity = NULL;
+ char tmp[64];
int i;
+ if (function->desc->duplicate) {
+ snprintf(tmp, sizeof(tmp), "%d %s", function->desc->adr, entity_label);
+ entity_label = tmp;
+ }
+
for (i = 0; i < function->num_entities; i++) {
entity = &function->entities[i];
diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c
index 6e10b4e660d96..4539a52a8e32b 100644
--- a/sound/soc/sdca/sdca_interrupts.c
+++ b/sound/soc/sdca/sdca_interrupts.c
@@ -375,8 +375,7 @@ int sdca_irq_data_populate(struct device *dev, struct regmap *regmap,
if (!dev)
return -ENODEV;
- name = kasprintf(GFP_KERNEL, "%s %s %s", function->desc->name,
- entity->label, control->label);
+ name = kasprintf(GFP_KERNEL, "%s %s", entity->label, control->label);
if (!name)
return -ENOMEM;
--
2.47.3