Skip to content

Find codec driver by SoundWire address instead of guessing the name - #5927

Draft
rfvirgil wants to merge 3 commits into
thesofproject:topic/sof-devfrom
CirrusLogic:topic/snd_soc_lookup_component_walk
Draft

rfvirgil wants to merge 3 commits into
thesofproject:topic/sof-devfrom
CirrusLogic:topic/snd_soc_lookup_component_walk

Conversation

@rfvirgil

@rfvirgil rfvirgil commented Sep 8, 2026

Copy link
Copy Markdown

This series adds a walk function to ASoC so sof_sdw can find the codec driver by matching its SoundWire address instead of trying to guess the name of the codec driver.

The struct sdw_bus * argument to sdw_extract_slave_id() is entirely bogus,
and isn't needed for the ID conversion that this helper function performs.

Also provide a stub implementation for !CONFIG_SOUNDWIRE so that callers
can use if (!IS_REACHABLE(CONFIG_SOUNDWIRE)) style instead of having to be
surrounded by #ifdefs.

The bus argument was only used to get a struct device * for two dev_dbg()
statements. This forced callers to have a valid struct sdw_bus object just
to convert an ID from u64 to struct sdw_slave_id.

The debug print is now a utility function sdw_debug_log_slave_id() that
can be used anywhere and only requires a struct device *.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Add a function to walk the component list and call a callback for
each component. This lest the machine driver implement its own
component match.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
…ddress

Use snd_soc_lookup_component_walk() to find the codec for the SoundWire
address instead of trying to guess the name of the codec driver.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Fix the disabled-configuration linkage conflict and include the SoundWire link in component matching.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Adds SoundWire-address-based codec component lookup for ASoC/sof_sdw, replacing codec-name guessing.

Changes:

  • Adds callback-based ASoC component walking.
  • Matches codecs by SoundWire device identity.
  • Refactors SoundWire ID extraction and logging APIs.
File Description
sound/​soc/​soc-core.c Adds component walk API
sound/​soc/​sdw_utils/​soc_sdw_utils.c Implements SoundWire component matching
include/​sound/​soc.h Declares the traversal API
include/​sound/​soc_sdw_utils.h Declares the SoundWire lookup helper
include/​linux/​soundwire/​sdw.h Updates SoundWire ID APIs
drivers/​soundwire/​slave.c Uses revised ID extraction
drivers/​soundwire/​qcom.c Uses revised ID extraction
drivers/​soundwire/​bus.h Removes the obsolete declaration
drivers/​soundwire/​bus.c Refactors ID extraction and logging

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1221 to +1227
static inline void sdw_extract_slave_id(u64 addr, struct sdw_slave_id *id)
{
}

static inline void sdw_debug_log_slave_id(struct device *dev, const struct sdw_slave_id *id)
{
}
Comment on lines +1654 to +1655
if (sdw_compare_devid(dev_to_sdw_dev(dev), info->id) != 0)
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants