Skip to content

Support Lenovo laptop with rt722 and rt1320#5707

Closed
oortcomet wants to merge 3 commits intothesofproject:topic/sof-devfrom
oortcomet:lnv-rt722-rt1320-2
Closed

Support Lenovo laptop with rt722 and rt1320#5707
oortcomet wants to merge 3 commits intothesofproject:topic/sof-devfrom
oortcomet:lnv-rt722-rt1320-2

Conversation

@oortcomet
Copy link

These commits support the combination with rt722 and rt1320 soundwire devices.

  • rt722 in Link3 -> UAJ
  • rt1320 in Link2 -> AMP & MIC

…bles

Use functional topologies to support RT722 topologies with/without
amplifiers,
e.g. sof-ptl-rt722.tplg, sof-ptl-rt722-rt1320.tplg...

If these entries are not removed, they will find the first same link of
sof-ptl-rt722.tplg.

Signed-off-by: Mac Chiang <mac.chiang@intel.com>
Co-developed-by: Derek Fang <derek.fang@realtek.com>
Signed-off-by: Derek Fang <derek.fang@realtek.com>
Copilot AI review requested due to automatic review settings March 23, 2026 06:09
@sofci
Copy link
Collaborator

sofci commented Mar 23, 2026

Can one of the admins verify this patch?

reply test this please to run this test once

@bardliao
Copy link
Collaborator

test this please

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds SoundWire plumbing to support a Lenovo platform using an rt722 on Link3 (UAJ) and an rt1320 on Link2 (AMP + MIC), primarily by expanding codec metadata and improving runtime component-string generation.

Changes:

  • Mark rt1320 as an “amp-class” codec and add an additional MIC DAI definition (rt1320-aif2) in codec_info_list.
  • Extend the Realtek DMIC runtime init to optionally append cfg-mics:<n> for rt1320-based DMIC discovery using SDCA function types.
  • Remove a set of PTL ACPI match-table entries for rt722-only configurations.

Reviewed changes

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

Show a summary per file
File Description
sound/soc/sof/intel/hda.c Tweaks amp/non-amp classification logic used during dynamic link/ADR generation.
sound/soc/sdw_utils/soc_sdw_utils.c Updates rt1320 codec metadata: adds is_amp flag and a second (MIC) DAI.
sound/soc/sdw_utils/soc_sdw_rt_dmic.c Adds rt1320-specific SDCA-based counting to append cfg-mics into card->components.
sound/soc/intel/common/soc-acpi-intel-ptl-match.c Removes rt722-only endpoint/ADR/link tables and related machine entries.
include/sound/soc_sdw_utils.h Extends asoc_sdw_codec_info with a new is_amp field.

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

Comment on lines +45 to +62
part_id = codec_info->part_id;

// count the rt1320 with SDCA function SmartMic type in this card
for_each_card_components(card, component) {
sdw_peripheral = dev_to_sdw_dev(component->dev);
if (sdw_peripheral->id.part_id != part_id)
continue;
for (i = 0; i < sdw_peripheral->sdca_data.num_functions; i++) {
if (sdw_peripheral->sdca_data.function[i].type ==
SDCA_FUNCTION_TYPE_SMART_MIC) {
rt1320_dmic_num++;
break;
}
}
}
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s mic:%s cfg-mics:%d", card->components,
mic_name, rt1320_dmic_num);
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

asoc_sdw_find_codec_info_dai() can return NULL; the new code dereferences codec_info->part_id unconditionally. Please add a NULL check and return an error (e.g., -EINVAL) or fall back to the previous card->components formatting when the DAI isn't found.

Suggested change
part_id = codec_info->part_id;
// count the rt1320 with SDCA function SmartMic type in this card
for_each_card_components(card, component) {
sdw_peripheral = dev_to_sdw_dev(component->dev);
if (sdw_peripheral->id.part_id != part_id)
continue;
for (i = 0; i < sdw_peripheral->sdca_data.num_functions; i++) {
if (sdw_peripheral->sdca_data.function[i].type ==
SDCA_FUNCTION_TYPE_SMART_MIC) {
rt1320_dmic_num++;
break;
}
}
}
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s mic:%s cfg-mics:%d", card->components,
mic_name, rt1320_dmic_num);
if (!codec_info) {
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s mic:%s", card->components,
mic_name);
} else {
part_id = codec_info->part_id;
// count the rt1320 with SDCA function SmartMic type in this card
for_each_card_components(card, component) {
sdw_peripheral = dev_to_sdw_dev(component->dev);
if (sdw_peripheral->id.part_id != part_id)
continue;
for (i = 0; i < sdw_peripheral->sdca_data.num_functions; i++) {
if (sdw_peripheral->sdca_data.function[i].type ==
SDCA_FUNCTION_TYPE_SMART_MIC) {
rt1320_dmic_num++;
break;
}
}
}
card->components = devm_kasprintf(card->dev, GFP_KERNEL,
"%s mic:%s cfg-mics:%d", card->components,
mic_name, rt1320_dmic_num);
}

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +51
for_each_card_components(card, component) {
sdw_peripheral = dev_to_sdw_dev(component->dev);
if (sdw_peripheral->id.part_id != part_id)
continue;
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

for_each_card_components() iterates over all card components (CPU/platform/codecs). The new logic unconditionally calls dev_to_sdw_dev(component->dev), which is only valid for SoundWire slave devices and can lead to invalid casts/crashes. Please check is_sdw_slave(component->dev) (and possibly the parent like in asoc_sdw_rtd_init()) before converting, and skip non-SoundWire components.

Copilot uses AI. Check for mistakes.
According to the Intel sof design, it will create the name prefix
appended with amp index for the amp codec only, such as:
rt1318-1, rt1318-2, etc...

But the rt1320 is a codec with amp and mic codec functions, it doesn't
have the amp index in its name prefix as above.
And then it will be hard to identify the codec if in multi-rt1320 case.
So we add a flag to force the amp index to be appended.

Signed-off-by: Derek Fang <derek.fang@realtek.com>
Add 'rt1320-aif2' dai info for rt1320 dmic function.

Signed-off-by: Derek Fang <derek.fang@realtek.com>
@oortcomet oortcomet force-pushed the lnv-rt722-rt1320-2 branch from 556b9b7 to 75cb60c Compare March 23, 2026 07:33
@oortcomet oortcomet closed this Mar 23, 2026
@oortcomet oortcomet deleted the lnv-rt722-rt1320-2 branch March 23, 2026 11:12
@oortcomet oortcomet restored the lnv-rt722-rt1320-2 branch March 23, 2026 11:14
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.

5 participants