Skip to content

ASoC/soundwire: add companion amp support - #6025

Open
bardliao wants to merge 11 commits into
thesofproject:topic/sof-devfrom
bardliao:companion_amp-machine_driver
Open

bardliao wants to merge 11 commits into
thesofproject:topic/sof-devfrom
bardliao:companion_amp-machine_driver

Conversation

@bardliao

@bardliao bardliao commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Some platforms use a SoundWire companion amp, which gets its audio data
from another SoundWire peripheral (the main amp) instead of from the
host. The current machine drivers and SoundWire core assume that every
stream is exchanged with the host, so these amps cannot be described or
configured.

This series adds the common support needed for such configurations:
a way to mark companion amp endpoints in the mach table, machine driver
support for the peripheral to peripheral path, a SoundWire stream type
that fits it.

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

Critical defects can block card registration, permanently defer probing, overlap companion-stream payload slots, and omit codec prefixes required to avoid control-name collisions and resolve routes.

5 open issues
What changed in this PR

This PR adds shared ASoC and SoundWire support for companion amplifiers that receive audio from another peripheral rather than the host.

Changes:

  • Adds companion endpoint metadata, grouping, and RT712/RT1320 DAI entries.
  • Creates Intel codec-to-codec links and adapts AMD drivers to the updated endpoint helpers.
  • Introduces a companion stream type and adjusts peripheral port offsets.
File Description
sound/​soc/​sof/​intel/​hda.c Excludes companion endpoints from automatic discovery.
sound/​soc/​sdw_utils/​soc_sdw_utils.c Adds companion DAI entries and endpoint grouping.
sound/​soc/​intel/​boards/​sof_sdw.c Creates companion codec-to-codec links.
sound/​soc/​amd/​acp/​acp-sdw-sof-mach.c Adapts SOF endpoint parsing for companion groups.
sound/​soc/​amd/​acp/​acp-sdw-legacy-mach.c Adapts legacy endpoint parsing for companion groups.
include/​sound/​soc-acpi.h Adds the companion endpoint flag.
include/​sound/​soc_sdw_utils.h Defines companion grouping structures and helper interfaces.
include/​linux/​soundwire/​sdw.h Adds the companion stream type.
drivers/​soundwire/​generic_bandwidth_allocation.c Resets port offsets for companion streams.

Review effort: Balanced

Comment thread sound/soc/intel/boards/sof_sdw.c Resolved
Comment thread sound/soc/intel/boards/sof_sdw.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Man you seem to start really big SoundWire changes. You should hire me haha...

Overall I didn't quite get how the new dailink is supposed to be handled, specifically how it's allocated, prepared and triggered. It's quite dependent on the host-peripheral dailink.

Comment thread include/sound/soc_sdw_utils.h Resolved
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num + 1;
dai_links = devm_kcalloc(dev, num_links, sizeof(*dai_links), GFP_KERNEL);
num_links = sdw_be_num + ssp_num + dmic_num + hdmi_num + bt_num + num_comp_amps + 1;
dai_links = devm_kcalloc(dev, num_links + 1, sizeof(*dai_links), GFP_KERNEL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you should explain why there's an additional dailink.

What's not clear specifically is how this dailink is handled, i.e. how it's allocated, prepared, triggered.

so far the device-to-device connections are not handled by the SoundWire core, so it's not clear how this might work?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

That is a codec to codec dai link to connect 2 peripherals. I will add some commits from @shumingfan to this PR to show how the link might work.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are test commits as follows:
5ad33ef
edffa25
6032198

Comment thread include/linux/soundwire/sdw.h Outdated
SDW_STREAM_PCM = 0,
SDW_STREAM_PDM = 1,
SDW_STREAM_BPT = 2,
SDW_STREAM_COMPANION = 3,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah but it could be PDM or PCM.

It think you'd need to add a new transport type, such as MANAGER_PERIPHERAL or PERIPHERAL_PERIPHERAL.

There are other uses cases where device-to-device communication is needed, e.g. to share the amp feedback. Don't make this just for the companion case.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ack

slave_total_ch += ch;

if (m_rt->stream->type == SDW_STREAM_COMPANION)
port_bo = t_data->block_offset;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not following this one.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is trying to let all peripherals use the same frame slots. Like rt1320 and rt712 use the same frame slots.

Comment thread sound/soc/sof/intel/hda.c
* the mach table if it is present.
*/
if (!is_endpoint_present(sdw_device, codec_info_list[i].dais[j].dai_type) ||
(codec_info_list[i].dais[j].quirk & SOC_SDW_COMPANION_AMPS))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the commit message says the opposite of what's done in other patches where you create a new dailink.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Trying to skip the companion dais here to avoid creating the dai links that connect the companion dai to the host. And the companion link will be created later by create_sdw_comp_dailinks().

Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:55
@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from e890ae0 to ced34fe Compare November 10, 2026 09:55

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.

Comment thread include/sound/soc_sdw_utils.h Resolved
Comment thread sound/soc/codecs/rt1320-sdw.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment thread sound/soc/codecs/rt1320-sdw.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Copilot AI balanced review requested due to automatic review settings November 12, 2026 06:23
@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from ced34fe to 79f4a06 Compare November 12, 2026 06:23

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.

Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment thread include/sound/soc_sdw_utils.h Resolved
Comment thread sound/soc/intel/boards/sof_sdw.c Resolved
@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from 79f4a06 to f033865 Compare November 13, 2026 08:37
Copilot AI balanced review requested due to automatic review settings November 13, 2026 08:37

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.

Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from f033865 to f43467a Compare November 17, 2026 06:20
Copilot AI balanced review requested due to automatic review settings November 17, 2026 06: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.

Comment thread sound/soc/intel/boards/sof_sdw.c Resolved
Copilot AI balanced review requested due to automatic review settings November 17, 2026 12:48

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

Companion playback can overwrite active DMIC capture clocks, while a manager port enabled without receiver-direction configuration can cause bus contention.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread drivers/soundwire/intel_auxdevice.c Resolved
Comment thread sound/soc/intel/boards/sof_sdw.c Resolved
The companion stream is from peripheral to peripheral and all
peripherals need to use the same SoundWire frame area to transfer the
stream data.

Signed-off-by: Bard Liao <[email protected]>
Add manager callbacks to reserve and release ports for
peripheral-to-peripheral streams. Track DAI-linked and reserved ports
on Intel managers, and reuse a stream's existing port when it is
reconfigured.

Signed-off-by: Bard Liao <[email protected]>
The companion amp dai links should not be created by the default machine
driver. We will create a mach table for the config that companion amp is
used.

Signed-off-by: Bard Liao <[email protected]>
@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from 98286ef to 5a17e3d Compare November 17, 2026 13:24
Copilot AI balanced review requested due to automatic review settings November 17, 2026 13:24

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.

🔵 Needs a closer look

AIF3 companion playback falls through to microphone clock programming, potentially overwriting an active AIF2 capture clock without updating its SoundWire stream configuration.

2 open issues
1 resolved since last review

Review effort: Balanced

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.

🔵 Needs a closer look

AIF3 setup falls through into microphone clock configuration, overwriting an active AIF2 capture rate with 48 kHz without updating its SoundWire stream configuration.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from 5a17e3d to 92c189e Compare November 18, 2026 06:21
Copilot AI balanced review requested due to automatic review settings November 18, 2026 06: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

Stream teardown can release still-live resources without reclaiming bandwidth, while missing DAI registrations and shared-stream preparation failures prevent companion-codec operation.

3 open issues

Review effort: Balanced

Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Comment on lines +1965 to +1966
.name = "rt721-sdca-aif4",
.id = RT721_AIF4,
Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
A companion amp gets its audio data from another SoundWire peripheral
(the main amp) instead of from the host, so the machine driver does not
open a host DMA stream for it. Add common dai ops that the companion amp
codec drivers can plug into their dai to handle the peripheral to
peripheral stream.

Signed-off-by: Shuming Fan <[email protected]>
Co-developed-by: Bard Liao <[email protected]>
Signed-off-by: Bard Liao <[email protected]>
Add a companion input DAI to the RT712 SoundWire codec to support
codec-to-codec audio streaming with the main amp.

For the companion DAI, retrieve the SoundWire stream from the CPU DAI
instead of using the codec DAI's DMA data, allowing the RT712 to add
the slave to master stream with the companion c2c link.

Signed-off-by: Shuming Fan <[email protected]>
Add a companion input DAI to the RT721 SoundWire codec to support
codec-to-codec audio streaming with the main amp.

For the companion DAI, retrieve the SoundWire stream from the CPU DAI
instead of using the codec DAI's DMA data, allowing the RT721 to add
the slave to master stream with the companion c2c link.

Signed-off-by: Shuming Fan <[email protected]>
Add a companion DAI to the RT1320 SoundWire codec to support
codec-to-codec audio streaming.

SoundWire peripheral-to-peripheral transport and add the corresponding
DAPM widgets and routes. Use the ASoC SoundWire companion amplifier helpers
to manage the companion stream, including startup, preparation, and
cleanup.

Signed-off-by: Shuming Fan <[email protected]>
@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from 92c189e to 8ebe5bf Compare November 18, 2026 07:45
Copilot AI balanced review requested due to automatic review settings November 18, 2026 07:45

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

RT721 companion AIF4 entries lack the speaker initializer, leaving the playback path potentially powered when the Speaker pin is disabled.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread sound/soc/sdw_utils/soc_sdw_utils.c Resolved
Add the componion amp dai info for rt712 ,rt721 and rt1320.

Signed-off-by: Bard Liao <[email protected]>
@bardliao
bardliao force-pushed the companion_amp-machine_driver branch from 8ebe5bf to 37f44f6 Compare November 18, 2026 08:12
Copilot AI balanced review requested due to automatic review settings November 18, 2026 08:12

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.

🔵 Needs a closer look

Changes spanning DAPM stream lifetime, SoundWire slot allocation, and port ownership require hardware validation of concurrent playback and suspend/resume that was unavailable in this source-only review.

1 open issue
1 resolved since last review

Review effort: Balanced

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.

4 participants