ASoC: get sdw dmic number for Intel platforms - #5843
Conversation
There was a problem hiding this comment.
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.hand 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.
There was a problem hiding this comment.
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;
}
|
This depends on thesofproject/sof#11013. |
Topology LGTM @bardliao |
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>
a432523 to
cc0c9e8
Compare
There was a problem hiding this comment.
🟡 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 whosedai_info->codec_nameis 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-EINVALaborts link creation instead of allowing the card probe to defer/retry. Resolve the peripheral from the SoundWire device name (or preserve-EPROBE_DEFERfor 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
12da4c2 to
468a344
Compare
There was a problem hiding this comment.
🟡 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_numremains zero for every amp and jack DAI link, but this unconditional switch sendsmic count 0 is not supportedfor each of those links during normal card creation. Guard the suffix-selection switch withsdw_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_doneguard above, so an RTD containing multiple physical codecs that share the samecodec_info/DAI (for example an aggregated SmartMic link) counts only the first codec's transducers. The DAI-link naming code counts every endpoint, butcfg-sdw-dmicis then smaller and describes a different channel count. Count unique physical SmartMic peripherals independently of the one-time rtd-init bookkeeping (the existingsoc_sdw_rt_dmic.cpath 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
468a344 to
a50fcb3
Compare
There was a problem hiding this comment.
🟡 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_MICSDCA function,sdw_mic_numremains zero by design. The new default branch nevertheless logsmic count 0 is not supportedfor 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 stillSmartMicfor 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_doneearly-continue, so it only runs for the first physical codec that maps to a givencodec_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 fromcfg-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-dmicis 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
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>
a50fcb3 to
64ce1ec
Compare
There was a problem hiding this comment.
🟡 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()classifiesSIMPLE_MICandSPEAKER_MICasSOC_SDW_DAI_TYPE_MIC, and this code still emits those links with theSmartMictype string. Filtering onlySMART_MICleaves such a link without a channel suffix, so topology selection falls back to the 2-channelsdca-mictopology 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-channelsdca-mictopology, 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_MICandSPEAKER_MICas microphone DAIs, but this filter excludes them. For those valid SDCA microphone functions,sdw_dmic_numstays zero and nocfg-sdw-dmicchannel count is exported incard->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_donecheck above is shared by every instance of a matchingcodec_info_listentry, not by the physicalsdw_peripheral. With two identical SmartMic codecs (including two endpoints in one aggregated link), the second DAI hitscontinueand never reaches this block, socfg-sdw-dmiccontains only the first codec's transducer count even thoughsof_sdw.csums 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); |
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.