From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, yung-chuan.liao@linux.intel.com,
pierre-louis.bossart@linux.dev, peter.ujfalusi@linux.intel.com,
niranjan.hy@ti.com, kevin-lu@ti.com, baojun.xu@ti.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: [PATCH v2 3/3] ASoC: SDCA: Support devices with multiple functions of identical type
Date: Thu, 30 Apr 2026 11:21:20 +0100 [thread overview]
Message-ID: <20260430102120.1283320-4-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20260430102120.1283320-1-ckeepax@opensource.cirrus.com>
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@linux.dev>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
Changes since v1:
- Correct kernel doc.
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
prev parent reply other threads:[~2026-04-30 10:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 10:21 [PATCH v2 0/3] Improve SDCA support for duplicated features Charles Keepax
2026-04-30 10:21 ` [PATCH v2 1/3] ASoC: SDCA: Add correct masks whilst reporting SDCA jack status Charles Keepax
2026-04-30 10:21 ` [PATCH v2 2/3] ASoC: SDCA: Remove sdca_function_data duplication Charles Keepax
2026-04-30 10:55 ` Mark Brown
2026-04-30 12:03 ` Charles Keepax
2026-04-30 10:21 ` Charles Keepax [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260430102120.1283320-4-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=kevin-lu@ti.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=niranjan.hy@ti.com \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox