Skip to content

ASoC: get sdw dmic number for Intel platforms - #5843

Open
bardliao wants to merge 4 commits into
thesofproject:topic/sof-devfrom
bardliao:sdca-mic-num
Open

ASoC: get sdw dmic number for Intel platforms#5843
bardliao wants to merge 4 commits into
thesofproject:topic/sof-devfrom
bardliao:sdca-mic-num

Conversation

@bardliao

Copy link
Copy Markdown
Collaborator

The topology needs to set the DMIC channel number according to the number of transducers connected to the codec. This information can be provided via the DAI link name for proper topology selection.

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.

Pull request overview

This PR adds support for deriving the SoundWire DMIC channel/transducer count from SDCA firmware-described entities and appending that count to Intel SOF SoundWire DAI link names, enabling more precise topology selection based on connected microphone transducers.

Changes:

  • Add sdca_get_mic_count() to parse SDCA Function entity metadata and return a microphone transducer count.
  • Update Intel SOF SoundWire machine driver to query SDCA SmartMic functions and suffix the DAI link name with -<N>ch.
  • Expose the new helper via include/sound/sdca.h and import the SDCA symbol namespace in the machine driver.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
sound/soc/sdca/sdca_functions.c Adds sdca_get_mic_count() to parse SDCA entity properties and extract microphone transducer count.
sound/soc/intel/boards/sof_sdw.c Appends SDCA-derived mic channel count to SoundWire capture link name for topology matching; adds SDCA namespace import.
include/sound/sdca.h Exposes sdca_get_mic_count() in the public SDCA header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sound/soc/intel/boards/sof_sdw.c
Comment thread sound/soc/sdca/sdca_functions.c
Comment thread sound/soc/sdca/sdca_functions.c
Comment thread include/sound/sdca.h Outdated
Comment thread sound/soc/intel/boards/sof_sdw.c Outdated
Copilot AI review requested due to automatic review settings July 15, 2026 06:17

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread sound/soc/sdca/sdca_functions.c
Comment thread sound/soc/sdca/sdca_functions.c
Comment thread sound/soc/sdca/sdca_functions.c Outdated
Comment thread sound/soc/intel/boards/sof_sdw.c
Comment thread include/sound/sdca.h
Copilot AI review requested due to automatic review settings July 15, 2026 09:20

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread sound/soc/sdca/sdca_functions.c
Comment thread sound/soc/intel/boards/sof_sdw.c Outdated
Comment thread include/sound/sdca.h Outdated
Copilot AI review requested due to automatic review settings July 15, 2026 09:43

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread sound/soc/sdca/sdca_functions.c Outdated
Comment thread sound/soc/sdca/sdca_functions.c Outdated
Comment thread sound/soc/intel/boards/sof_sdw.c Outdated
Copilot AI review requested due to automatic review settings July 15, 2026 11:44

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread sound/soc/sdca/sdca_functions.c Outdated
Comment thread sound/soc/intel/boards/sof_sdw.c
Comment thread sound/soc/intel/boards/sof_sdw.c
Copilot AI review requested due to automatic review settings July 15, 2026 12:25

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread sound/soc/intel/boards/sof_sdw.c Outdated
Comment thread sound/soc/intel/boards/sof_sdw.c Outdated

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

sound/soc/sdca/sdca_functions.c:225

  • When the entity-id-list property is missing, fwnode_property_count_u32() returns a negative errno (typically -EINVAL), and the current log prints it as an "entity number" (e.g. -22), which is misleading. This can be made consistent with existing sdca parsing code (find_sdca_entities()) by distinguishing missing list vs exceeding SDCA_MAX_ENTITY_COUNT.
	num_entities = fwnode_property_count_u32(function_node,
					 "mipi-sdca-entity-id-list");
	if (num_entities <= 0 || num_entities > SDCA_MAX_ENTITY_COUNT) {
		dev_err(&slave->dev,
			"%pfwP: entity number %d is invalid for function type %u\n",
			function_node, num_entities, function->type);
		return -EINVAL;
	}

Comment thread sound/soc/intel/boards/sof_sdw.c Outdated
@bardliao

Copy link
Copy Markdown
Collaborator Author

This depends on thesofproject/sof#11013.

@bardliao
bardliao marked this pull request as draft July 20, 2026 03:37
@lgirdwood

Copy link
Copy Markdown
Member

This depends on thesofproject/sof#11013.

Topology LGTM @bardliao

@bardliao
bardliao marked this pull request as ready for review September 14, 2026 03:35
Copilot AI review requested due to automatic review settings September 14, 2026 03:35
We can get how many mic transducers are connected to the codec.
The information will be used for selecting the topology with proper dmic
channel number.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.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.

🟢 Approval recommended

No unresolved blocking issues were identified.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 14, 2026 06:34

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.

🟡 Changes recommended

Two moderate issues remain in SmartMic count handling and codec-component lookup.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

sound/soc/intel/boards/sof_sdw.c:1059

  • This lookup is not guaranteed by asoc_sdw_parse_sdw_endpoints(): endpoints whose dai_info->codec_name is NULL (for example the generic rt712 MIC entry) use the raw SoundWire device name without looking up an ASoC component. If the codec component is not registered yet, snd_soc_lookup_component_by_name() returns NULL here and the new -EINVAL aborts link creation instead of allowing the card probe to defer/retry. Resolve the peripheral from the SoundWire device name (or preserve -EPROBE_DEFER for this ordering case).
				peripheral = sof_sdw_get_peripheral_by_codec_name(codec_name);
				if (!peripheral) {
					/*
					 * asoc_sdw_parse_sdw_endpoints() is already checked
					 * peripheral is not NULL, so this should never happen.
					 */
					dev_err(dev, "Can't get peripheral for codec %s\n",
						sof_end->codec_name);
					return -EINVAL;
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread sound/soc/intel/boards/sof_sdw.c Outdated
Copilot AI review requested due to automatic review settings September 14, 2026 08:04

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.

🟡 Changes recommended

Unresolved critical and moderate findings remain.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (2)

sound/soc/intel/boards/sof_sdw.c:1091

  • sdw_mic_num remains zero for every amp and jack DAI link, but this unconditional switch sends mic count 0 is not supported for each of those links during normal card creation. Guard the suffix-selection switch with sdw_mic_num > 0 (or track whether this is a mic link) so non-mic links do not generate misleading probe warnings.
			dev_warn(dev, "mic count %d is not supported\n", sdw_mic_num);

sound/soc/sdw_utils/soc_sdw_utils.c:1619

  • This aggregation runs only after the rtd_init_done guard above, so an RTD containing multiple physical codecs that share the same codec_info/DAI (for example an aggregated SmartMic link) counts only the first codec's transducers. The DAI-link naming code counts every endpoint, but cfg-sdw-dmic is then smaller and describes a different channel count. Count unique physical SmartMic peripherals independently of the one-time rtd-init bookkeeping (the existing soc_sdw_rt_dmic.c path scans all card components for this reason).
			for (j = 0; j < sdw_peripheral->sdca_data.num_functions; j++) {
				struct sdca_function_desc *function =
					&sdw_peripheral->sdca_data.function[j];

				if (function->type != SDCA_FUNCTION_TYPE_SMART_MIC)
					continue;

				mic_count = sdca_get_mic_count(sdw_peripheral, function);
				if (mic_count > 0)
					sdw_dmic_num += mic_count;
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread sound/soc/sdw_utils/soc_sdw_utils.c
Comment thread sound/soc/intel/boards/sof_sdw.c
Copilot AI review requested due to automatic review settings September 14, 2026 08:21

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.

🟡 Changes recommended

Unresolved findings remain around error propagation and supported microphone function coverage.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (4)

sound/soc/intel/boards/sof_sdw.c:1092

  • When the DAI is a microphone but the peripheral has no SMART_MIC SDCA function, sdw_mic_num remains zero by design. The new default branch nevertheless logs mic count 0 is not supported for those existing non-SDCA microphone paths, creating a misleading warning; only positive, unsupported counts should reach this warning.
		default:
			dev_warn(dev, "mic count %d is not supported\n", sdw_mic_num);
			break;

sound/soc/intel/boards/sof_sdw.c:1068

  • This filter only counts SMART_MIC functions, but asoc_sdw_get_dai_type() treats SIMPLE_MIC and SPEAKER_MIC as microphone DAIs too; the generated link name is still SmartMic for those DAI types. A codec exposing one of those functions therefore falls back to the default topology instead of selecting the topology for its transducer count. Filter by the DAI type (or include all supported microphone function types) here.
					if (function->type != SDCA_FUNCTION_TYPE_SMART_MIC)
						continue;

sound/soc/sdw_utils/soc_sdw_utils.c:1615

  • This accounting is below the existing rtd_init_done early-continue, so it only runs for the first physical codec that maps to a given codec_info->dais[dai_index]. That flag is shared by all instances of the static codec-info entry; with two identical SmartMic peripherals, the later peripheral's transducers are omitted from cfg-sdw-dmic. Compute the count per peripheral/card independently of the one-time DAI initialization guard.
			for (j = 0; j < sdw_peripheral->sdca_data.num_functions; j++) {
				struct sdca_function_desc *function =
					&sdw_peripheral->sdca_data.function[j];

				if (function->type != SDCA_FUNCTION_TYPE_SMART_MIC)

sound/soc/sdw_utils/soc_sdw_utils.c:1616

  • This repeats the SMART_MIC-only restriction even though asoc_sdw_get_dai_type() classifies SIMPLE_MIC and SPEAKER_MIC as microphone DAIs. For those supported SDCA functions, cfg-sdw-dmic is never emitted, so the card reports no transducer-derived channel count. Use the common DAI-type mapping (or include all microphone function types) when selecting functions to count.
				if (function->type != SDCA_FUNCTION_TYPE_SMART_MIC)
					continue;
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread sound/soc/intel/boards/sof_sdw.c Outdated
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Outdated
The commit get the sdca sdw dmic number form the
mipi-sdca-cluster-channel-id property.
The dai link name will be used to select the function topology with a
proper dmic channel number.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
dmic support

Now the machine driver provides the sdca dmic channel number information
in the dai link name. We can use the information to select different
topologies for different dmic channels. To be backward compatible, the
2ch sdca dmic topology will still use the "sdca-mic" topology.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
It will provide the SoundWire dmic number information to UCM and will be
used for setting PCM channel number.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Copilot AI review requested due to automatic review settings September 14, 2026 10:25

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.

🟡 Changes recommended

Unresolved microphone classification, topology fallback, aggregation, and Kconfig linkage issues remain.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (4)

sound/soc/intel/boards/sof_sdw.c:1068

  • asoc_sdw_get_dai_type() classifies SIMPLE_MIC and SPEAKER_MIC as SOC_SDW_DAI_TYPE_MIC, and this code still emits those links with the SmartMic type string. Filtering only SMART_MIC leaves such a link without a channel suffix, so topology selection falls back to the 2-channel sdca-mic topology even when the firmware reports another transducer count. Use the common mic classification here (or include all supported mic function types).
					if (function->type != SDCA_FUNCTION_TYPE_SMART_MIC)
						continue;

sound/soc/intel/boards/sof_sdw.c:1093

  • For any positive transducer count other than 1, 2, 4, or 8, this only logs a warning and leaves the link named SmartMic. sof_sdw_get_tplg_files() then intentionally maps that name to the default 2-channel sdca-mic topology, so a codec reporting (for example) 3 or 6 transducers is configured with the wrong channel count. Fail link creation or provide a topology for every supported count instead of silently selecting 2ch.
		default:
			dev_warn(dev, "mic count %d is not supported\n", sdw_mic_num);
			break;

sound/soc/sdw_utils/soc_sdw_utils.c:1616

  • The shared DAI classifier also treats SIMPLE_MIC and SPEAKER_MIC as microphone DAIs, but this filter excludes them. For those valid SDCA microphone functions, sdw_dmic_num stays zero and no cfg-sdw-dmic channel count is exported in card->components, so the reported configuration does not match the codec transducers.
				if (function->type != SDCA_FUNCTION_TYPE_SMART_MIC)
					continue;

sound/soc/sdw_utils/soc_sdw_utils.c:1611

  • The rtd_init_done check above is shared by every instance of a matching codec_info_list entry, not by the physical sdw_peripheral. With two identical SmartMic codecs (including two endpoints in one aggregated link), the second DAI hits continue and never reaches this block, so cfg-sdw-dmic contains only the first codec's transducer count even though sof_sdw.c sums both for the DAI-link name. Count/deduplicate by peripheral rather than using this shared per-codec-info flag for the new marker.
		/* Set sdw dmic numbers to the component stream */
		if (codec_info->dais[dai_index].dai_type == SOC_SDW_DAI_TYPE_MIC) {
			int mic_count;

			for (j = 0; j < sdw_peripheral->sdca_data.num_functions; j++) {
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

if (function->type != SDCA_FUNCTION_TYPE_SMART_MIC)
continue;

mic_count = sdca_get_mic_count(sdw_peripheral, function);
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.

3 participants