From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: broonie@kernel.org, tiwai@suse.de
Cc: linux-sound@vger.kernel.org, bard.liao@intel.com,
peter.ujfalusi@linux.intel.com
Subject: [PATCH 1/2] ASoC: soc_sdw_utils: skip aux device if it is not present
Date: Fri, 8 May 2026 17:47:49 +0800 [thread overview]
Message-ID: <20260508094750.1246796-2-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20260508094750.1246796-1-yung-chuan.liao@linux.intel.com>
From: Maciej Strozek <mstrozek@opensource.cirrus.com>
Similarly to codec endpoints that may not be used [1], aux devices (like
HID) also may not be used. Hence skip aux devices which are not present.
[1] https://lore.kernel.org/all/20250414063239.85200-12-yung-chuan.liao@linux.intel.com/
Signed-off-by: Maciej Strozek <mstrozek@opensource.cirrus.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
sound/soc/sdw_utils/soc_sdw_utils.c | 76 ++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 2 deletions(-)
diff --git a/sound/soc/sdw_utils/soc_sdw_utils.c b/sound/soc/sdw_utils/soc_sdw_utils.c
index ede41c532c52..da626969a657 100644
--- a/sound/soc/sdw_utils/soc_sdw_utils.c
+++ b/sound/soc/sdw_utils/soc_sdw_utils.c
@@ -1708,6 +1708,63 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
}
EXPORT_SYMBOL_NS(asoc_sdw_init_simple_dai_link, "SND_SOC_SDW_UTILS");
+/**
+ * is_sdca_aux_dev_present - Check if an SDCA aux device is present on the SDW peripheral
+ * @dev: Device pointer
+ * @aux_codec_name: Aux codec name from the codec info (e.g. "snd_soc_sdca.HID.2")
+ * @adr_link: ACPI link address
+ * @adr_index: Index of the ACPI link address
+ *
+ * Return: 1 if the aux is present, 0 if the aux is not present, or negative error code.
+ */
+static int is_sdca_aux_dev_present(struct device *dev,
+ const char *aux_codec_name,
+ const struct snd_soc_acpi_link_adr *adr_link,
+ int adr_index)
+{
+ struct sdw_slave *slave;
+ struct device *sdw_dev;
+ const char *sdw_codec_name;
+ int ret = 0;
+ int i;
+
+ if (!aux_codec_name)
+ return 0;
+
+ sdw_codec_name = _asoc_sdw_get_codec_name(dev, adr_link, adr_index);
+ if (!sdw_codec_name)
+ return -ENOMEM;
+
+ sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_codec_name);
+ if (!sdw_dev) {
+ dev_err(dev, "codec %s not found\n", sdw_codec_name);
+ return -EINVAL;
+ }
+
+ slave = dev_to_sdw_dev(sdw_dev);
+
+ if (!slave->sdca_data.interface_revision) {
+ dev_warn(dev, "No SDCA properties, assuming aux '%s' present\n", aux_codec_name);
+ ret = 1;
+ goto put_dev;
+ }
+
+ for (i = 0; i < slave->sdca_data.num_functions; i++) {
+ const char *fname = slave->sdca_data.function[i].name;
+
+ if (fname && strstr(aux_codec_name, fname)) {
+ ret = 1;
+ goto put_dev;
+ }
+ }
+
+ dev_dbg(dev, "SDCA function for aux '%s' NOT FOUND on slave, skipping\n", aux_codec_name);
+
+put_dev:
+ put_device(sdw_dev);
+ return ret;
+}
+
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
int *num_devs, int *num_ends, int *num_aux)
{
@@ -1715,7 +1772,7 @@ int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
struct snd_soc_acpi_mach *mach = dev_get_platdata(dev);
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
const struct snd_soc_acpi_link_adr *adr_link;
- int i;
+ int i, j, ret;
for (adr_link = mach_params->links; adr_link->num_adr; adr_link++) {
*num_devs += adr_link->num_adr;
@@ -1730,7 +1787,14 @@ int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
if (!codec_info)
return -EINVAL;
- *num_aux += codec_info->aux_num;
+ for (j = 0; j < codec_info->aux_num; j++) {
+ ret = is_sdca_aux_dev_present(dev, codec_info->auxs[j].codec_name,
+ adr_link, i);
+ if (ret < 0)
+ return ret;
+ if (ret)
+ (*num_aux)++;
+ }
}
}
@@ -1894,6 +1958,14 @@ int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
for (j = 0; j < codec_info->aux_num; j++) {
struct snd_soc_component *component;
+ ret = is_sdca_aux_dev_present(dev, codec_info->auxs[j].codec_name,
+ adr_link, i);
+ if (ret < 0)
+ return ret;
+
+ if (ret == 0)
+ continue;
+
component = snd_soc_lookup_component_by_name(codec_info->auxs[j].codec_name);
if (component) {
dev_dbg(dev, "%s found component %s for aux name %s\n",
--
2.43.0
next prev parent reply other threads:[~2026-05-08 9:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 9:47 [PATCH 0/2] ASoC: soc_sdw_utils: skip aux device if it is not present Bard Liao
2026-05-08 9:47 ` Bard Liao [this message]
2026-05-08 9:47 ` [PATCH 2/2] ASoC: soc_sdw_utils: Change comment into proper kernel doc Bard Liao
2026-05-11 1:05 ` [PATCH 0/2] ASoC: soc_sdw_utils: skip aux device if it is not present Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260508094750.1246796-2-yung-chuan.liao@linux.intel.com \
--to=yung-chuan.liao@linux.intel.com \
--cc=bard.liao@intel.com \
--cc=broonie@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=peter.ujfalusi@linux.intel.com \
--cc=tiwai@suse.de \
/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