Skip to content

Conversation

@bardliao
Copy link
Collaborator

Use sof_sdw as default Intel SoundWire machine driver when there is no link adr matches in the acpi match table.

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

This PR updates the default SoundWire machine driver configuration to use "sof_sdw" when no matching link ADR is found in the ACPI table. Key changes include new endpoint discovery functions in the Intel HDA driver, updates to symbol exports and cast assignments for link structures, and modifications to ACPI endpoint definitions across multiple files (including header changes to support a new "name_prefix" field).

Reviewed Changes

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

Show a summary per file
File Description
sound/soc/sof/intel/hda.c Adds new helper functions and creates a default SDW machine driver with updated cast assignments.
sound/soc/sof/amd/acp-common.c Updates the assignment of mach_params.links with an explicit cast.
sound/soc/sdw_utils/soc_sdw_utils.c Updates codec info structures with new "name_prefix" attributes and makes asoc_sdw_get_dai_type public.
Various ACPI match files Removes const qualifiers from endpoint data and updates symbol exports.
include/sound/soc_sdw_utils.h & include/sound/soc-acpi.h Updates structure definitions to support mutable link pointers and the new "name_prefix" field.
Comments suppressed due to low confidence (1)

include/sound/soc-acpi.h:84

  • The update from a const pointer to a mutable pointer for the 'links' field in struct snd_soc_acpi_mach_params should be reviewed and documented to ensure it is consistent with the intended immutability or mutability of endpoint data across the codebase.
struct snd_soc_acpi_link_adr *links;

Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

The explicit cast from a const pointer to a mutable pointer for 'mach->mach_params.links' suggests an underlying type mismatch. Consider updating the structure definitions to align the types, which would avoid the need for the cast.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

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

A new field 'name_prefix' has been added to asoc_sdw_codec_info without accompanying documentation. Please add a descriptive comment to clarify its intended purpose and usage.

Copilot uses AI. Check for mistakes.
@bardliao bardliao force-pushed the use_sof_sdw_as_default_sdw_machine branch from 63ea027 to 7c63353 Compare May 16, 2025 10:17
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Only minor questions. @charleskeepax good for you ?

Copy link
Member

Choose a reason for hiding this comment

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

if (!) continue would help with indentation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@bardliao bardliao force-pushed the use_sof_sdw_as_default_sdw_machine branch 2 times, most recently from 3ca3ebc to 630629d Compare May 27, 2025 05:29
@bardliao
Copy link
Collaborator Author

@lgirdwood comments added

@bardliao bardliao requested a review from lgirdwood May 27, 2025 06:00

Choose a reason for hiding this comment

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

Do we actually need to remove the const on all of these hard coded entries? At least from the description where we are only creating a match if one doesn't exist that doesn't imply we would be changing an existing hard coded entry?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem is that I don't know how to convert a const struct to a non-const struct. For example, I will get below compile error if I don't remove the const of cs42l43_endpoints and try to force cast the type when set the .endpoints.

sound/soc/intel/common/soc-acpi-intel-arl-match.c:200:38: error: conversion to non-scalar type requested
  200 |                 .endpoints = (struct snd_soc_acpi_endpoint)cs42l43_endpoints,
      |                                      ^~~~~~~~~~~~~~~~~~~~~

It would be great if you could provide me some advice. I am more than happy if we don't need to remove the const on all of those hard coded entries.

Choose a reason for hiding this comment

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

Is this right? I feel like num_peripherals is the number of devices but links are the soundwire links in usage? Is the naming slightly confusing or are we allocating the right sizes here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My idea was that as we don't know the link numbers at this moment. Allocating the number of devices can guarantee that we allocate enough space for the links array. But, I use a loop to get the number of the links now. Thanks for pointing it out.

@bardliao bardliao force-pushed the use_sof_sdw_as_default_sdw_machine branch from 630629d to 133b10f Compare May 28, 2025 06:48
@bardliao
Copy link
Collaborator Author

SOFCI TEST


adr_dev[index].endpoints =
devm_kzalloc(dev, codec_info_list[i].dai_num *
sizeof(struct snd_soc_acpi_endpoint), GFP_KERNEL);

Choose a reason for hiding this comment

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

Is the problem here? If instead of assigning the endpoint pointer in adr_dev directly what if you made a local non-const pointer, then once you have filled in the endpoints you can then assign that to the const pointer in the adr_dev structure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, the problem is

struct snd_soc_acpi_adr_device {
        const u64 adr;
        const u8 num_endpoints;
        const struct snd_soc_acpi_endpoint *endpoints;
        const char *name_prefix;
};

and

struct snd_soc_acpi_link_adr {
        const u32 mask;
        const u32 num_adr;
        const struct snd_soc_acpi_adr_device *adr_d;
};

I will get assignment of read-only member error even if the adr_device and the link_adr themselves are not const.

Copy link

@charleskeepax charleskeepax May 29, 2025

Choose a reason for hiding this comment

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

Pretty sure the problem is there, this seems to build, although I haven't actually runtime tested it:

charleskeepax@ce250fb
https://github.com/charleskeepax/linux/commits/sof/fix/

And feel free squash that in where ever it goes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, yes. Just make required variables non const and keep snd_soc_acpi_endpoint and snd_soc_acpi_adr_device const. Thanks for the advice. I will revise my PR, thanks.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

LGTM

@bardliao bardliao force-pushed the use_sof_sdw_as_default_sdw_machine branch from 133b10f to 06ad996 Compare May 29, 2025 12:22

Choose a reason for hiding this comment

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

Rather than doing this which depends on the links being ordered, would it be reasonable to do something like:

link_index = link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1);

Pretty sure that works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But the link_index may exceed the array size if the link_id is not continued or it doesn't start from 0. Like link 2 and 3 are used.

Choose a reason for hiding this comment

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

Apologies it seems I forgot an hweight in my comment there:

link_index = hweight(link_mask & (BIT(peripherals->array[i]->bus->link_id) - 1));

For example a system using links 1,3 would look like:

link_index = hweight(link_mask & (BIT(link_id) - 1))) = hweight(0xA & (0x2 - 1)) = hweight(0xA & 0x1) = 0
link_index = hweight(link_mask & (BIT(link_id) - 1))) = hweight(0xA & (0x8 - 1)) = hweight(0xA & 0x3) = 1

Choose a reason for hiding this comment

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

It basically counts the number of used links below the current link to get the link_index.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wow, that is clever. Thanks for the suggestion.

@bardliao
Copy link
Collaborator Author

Hi @bardliao Cool,

Having sof_tplg_filename and .get_function_tplg_files in the match table is for backward compatibility. The new kernel with the function topology feature support may work with a old firmware version that doesn't have the function topologies included. So that we need to use the monolithic topology file if any of the required function topology is not found. I hope someday we can remove it entirely. The issue for now is that we don't get the function topology file names when we do the file checking. It could be the next step that we can improve.

Well, forward compatibility :) Just thinking that the monolithic topologies would be in linux-firmware and we generally don't remove support from there (for the backwards compatibility reasons), if the firmware has the monolithic topology described in a match wouldn't it be sensible to use it? (there's a match, there is a topology named in the match, why not use it?). At which point the function topology files only come into play if there isn't a match, which is hopefully the way going forward.

What in my mind is that new match tables will use a generic topology file which doesn't have to prefect match to the audio configuration. And the function topologies will be used. And yes, our goal is to use function topologies.

I switched off all the debug to see what how things looked with the last PR,

[ 3.498324] sof-audio-pci-intel-lnl 0000:00:1f.3: No SoundWire machine driver found for the ACPI-reported configuration:
...
[ 3.498347] sof-audio-pci-intel-lnl 0000:00:1f.3: Use SoundWire default machine driver with function topologies
...
[ 3.503910] sof-audio-pci-intel-lnl 0000:00:1f.3: Firmware file: intel/sof-ipc4/lnl/sof-lnl.ri
[ 3.503911] sof-audio-pci-intel-lnl 0000:00:1f.3: Firmware lib path: intel/sof-ipc4-lib/lnl
[ 3.503912] sof-audio-pci-intel-lnl 0000:00:1f.3: Topology file: function topologies
...
[ 3.465462] sof-audio-pci-intel-lnl 0000:00:1f.3: Using function topologies instead intel/sof-ipc4-tplg/sof-lnl-rt713-l2-rt1320-l13.tplg
[ 3.465466] sof-audio-pci-intel-lnl 0000:00:1f.3: loading topology 0: intel/sof-ipc4-tplg/sof-sdca-jack-id0.tplg
[ 3.465492] sof-audio-pci-intel-lnl 0000:00:1f.3: Topology: ABI 3:29:1 Kernel ABI 3:23:1
[ 3.465643] sof_sdw sof_sdw: ASoC: Parent card not yet available, widget card binding deferred
[ 3.465646] sof-audio-pci-intel-lnl 0000:00:1f.3: loading topology 1: intel/sof-ipc4-tplg/sof-sdca-2amp-id2.tplg
[ 3.465660] sof-audio-pci-intel-lnl 0000:00:1f.3: Topology: ABI 3:29:1 Kernel ABI 3:23:1
[ 3.465733] sof_sdw sof_sdw: ASoC: Parent card not yet available, widget card binding deferred
[ 3.465735] sof-audio-pci-intel-lnl 0000:00:1f.3: loading topology 2: intel/sof-ipc4-tplg/sof-lnl-dmic-2ch-id4.tplg
[ 3.465750] sof-audio-pci-intel-lnl 0000:00:1f.3: Topology: ABI 3:29:1 Kernel ABI 3:23:1
[ 3.465796] sof_sdw sof_sdw: ASoC: Parent card not yet available, widget card binding deferred
[ 3.465797] sof-audio-pci-intel-lnl 0000:00:1f.3: loading topology 3: intel/sof-ipc4-tplg/sof-hdmi-pcm5-id6.tplg
[ 3.465810] sof-audio-pci-intel-lnl 0000:00:1f.3: Topology: ABI 3:29:1 Kernel ABI 3:23:1

Which is OK, though the message at 3.465462 is referencing the unused topology is a bit awkward.

I removed the first functional topology file to see what a failure looked like:

[ 3.206355] sof_sdw sof_sdw: ASoC: physical link dmic01 (id 3) not exist
[ 3.206359] sof_sdw sof_sdw: ASoC: topology: could not load header: -22
[ 3.206416] sof-audio-pci-intel-lnl 0000:00:1f.3: tplg intel/sof-ipc4-tplg/sof-lnl-rt713-l2-rt1320-l13.tplg component load failed -22
[ 3.206418] sof-audio-pci-intel-lnl 0000:00:1f.3: error: failed to load DSP topology -22
[ 3.206419] sof-audio-pci-intel-lnl 0000:00:1f.3: ASoC error (-22): at snd_soc_component_probe() on 0000:00:1f.3
[ 3.206434] sof_sdw sof_sdw: ASoC: failed to instantiate card -22

Which isn't so great - it doesn't log that that an expected functional topology file isn't present and then appears to use the wrong one (which was a dummy)

Added 7faf4cf to fix it. Missing function topology was not an error that's why we used dev_dbg.

@simontrimmer
Copy link
Collaborator

simontrimmer commented Aug 19, 2025

@bardliao Cool, I'll be able to test tomorrow but I see the message change, it'll be interesting to see what the failure case looks like now in the log.

on

What in my mind is that new match tables will use a generic topology file which doesn't have to prefect match to the audio configuration. And the function topologies will be used. And yes, our goal is to use function topologies.

We have a load of PTL matches that we're considering upstreaming as we already have some entries that will match on just the codec. I'm debating with myself whether these should have the functional topology callback for the reasons I mentioned - if there is a specific match entry then shouldn't the system use it in preference to the generic support?

@bardliao
Copy link
Collaborator Author

@bardliao Cool, I'll be able to test tomorrow but I see the message change, it'll be interesting to see what the failure case looks like now in the log.

on

What in my mind is that new match tables will use a generic topology file which doesn't have to prefect match to the audio configuration. And the function topologies will be used. And yes, our goal is to use function topologies.

We have a load of PTL matches that we're considering upstreaming as we already have some entries that will match on just the codec. I'm debating with myself whether these should have the functional topology callback for the reasons I mentioned - if there is a specific match entry then shouldn't the system use it in preference to the generic support?

To me the benefit of using functional topology is to reduce the effort of creating new monolithic topologies. It is totally fine if the matches don't have the functional topology callback.

@simontrimmer
Copy link
Collaborator

Hi @bardliao ,
Just documenting some findings as I'm going to be offline for a week

So I tried that branch, continuing from where we were:

[ 3.134801] sof-audio-pci-intel-lnl 0000:00:1f.3: No SoundWire machine driver found for the ACPI-reported configuration:
[ 3.134806] sof-audio-pci-intel-lnl 0000:00:1f.3: link 0 mfg_id 0x01fa part_id 0x4243 version 0x3
[ 3.134811] sof-audio-pci-intel-lnl 0000:00:1f.3: link 2 mfg_id 0x01fa part_id 0x3556 version 0x3
[ 3.134813] sof-audio-pci-intel-lnl 0000:00:1f.3: link 2 mfg_id 0x01fa part_id 0x3556 version 0x3
[ 3.134814] sof-audio-pci-intel-lnl 0000:00:1f.3: link 3 mfg_id 0x01fa part_id 0x3556 version 0x3
[ 3.134816] sof-audio-pci-intel-lnl 0000:00:1f.3: link 3 mfg_id 0x01fa part_id 0x3556 version 0x3
[ 3.134828] sof-audio-pci-intel-lnl 0000:00:1f.3: Use SoundWire default machine driver with function topologies

[ 3.141552] sof-audio-pci-intel-lnl 0000:00:1f.3: Firmware paths/files for ipc type 1:
[ 3.141557] sof-audio-pci-intel-lnl 0000:00:1f.3: Firmware file: intel/sof-ipc4/lnl/sof-lnl.ri
[ 3.141558] sof-audio-pci-intel-lnl 0000:00:1f.3: Firmware lib path: intel/sof-ipc4-lib/lnl
[ 3.141560] sof-audio-pci-intel-lnl 0000:00:1f.3: Topology file: function topologies

[ 3.392869] sof_sdw sof_sdw: Failed to open topology file: intel/sof-ipc4-tplg/sof-sdca-jack-id0.tplg, you might need to
[ 3.392873] sof_sdw sof_sdw: download it from https://github.com/thesofproject/sof-bin/

[ 3.393303] sof_sdw sof_sdw: ASoC: physical link dmic01 (id 3) not exist
[ 3.393308] sof_sdw sof_sdw: ASoC: topology: could not load header: -22
[ 3.393369] sof-audio-pci-intel-lnl 0000:00:1f.3: tplg intel/sof-ipc4-tplg/sof-lnl-rt713-l2-rt1320-l13.tplg component load failed -22
[ 3.393373] sof-audio-pci-intel-lnl 0000:00:1f.3: error: failed to load DSP topology -22
[ 3.393388] sof-audio-pci-intel-lnl 0000:00:1f.3: ASoC error (-22): at snd_soc_component_probe() on 0000:00:1f.3
[ 3.393405] sof_sdw sof_sdw: ASoC: failed to instantiate card -22
[ 3.394652] sof_sdw sof_sdw: error -EINVAL: snd_soc_register_card failed -22
[ 3.394659] sof_sdw sof_sdw: probe with driver sof_sdw failed with error -22

So it didn't find a match table entry, said it was going to use functional topologies, couldn't find the file that I'd sabotaged and then It did fall back to using the monolithic topology that should only be used as a dummy to get the "lnl" platform and pass a file existence check.

This got us wondering.... if someone upgraded the kernel to a version that did this, but didn't upgrade SOF, what if the monolithic topology it chose didn't actually fail... and the answer is that it look like it succeeds, the codec and amp drivers appeared to initialise properly, we get a sound card that includes all the controls we'd expect, wireplumber has a Lunar Lake audio controller with a stereo sink that you can play to but there are no catastrophic error messages in the log. Wireplumber gets headset events and appears to switch between speakers and headphones.

Is there a way of not using the dummy monolithic topology? Replace the tlpg filename with the platform name string, bypass the filename check if it's only three characters and if the functional topology load fails bail out without using the dummy file?

-Simon

@bardliao
Copy link
Collaborator Author

So it didn't find a match table entry, said it was going to use functional topologies, couldn't find the file that I'd sabotaged and then It did fall back to using the monolithic topology that should only be used as a dummy to get the "lnl" platform and pass a file existence check.

This got us wondering.... if someone upgraded the kernel to a version that did this, but didn't upgrade SOF, what if the monolithic topology it chose didn't actually fail... and the answer is that it look like it succeeds, the codec and amp drivers appeared to initialise properly, we get a sound card that includes all the controls we'd expect, wireplumber has a Lunar Lake audio controller with a stereo sink that you can play to but there are no catastrophic error messages in the log. Wireplumber gets headset events and appears to switch between speakers and headphones.

I don't think it will break the existing devices if they upgrade the kernel without upgrading SOF. All the existing working devices have their own ACPI match table. So, the driver will find the specific match. And regarding the dummy topology, if an acpi mach with .get_function_tplg_files is selected, I would expect that the SoundWire part will work.
But yeah, I agree that the dummy topology should not be used.

Is there a way of not using the dummy monolithic topology? Replace the tlpg filename with the platform name string, bypass the filename check if it's only three characters and if the functional topology load fails bail out without using the dummy file?

Yes, I will try to do it.

@bardliao bardliao force-pushed the use_sof_sdw_as_default_sdw_machine branch from 7faf4cf to 67c965d Compare August 29, 2025 12:26
@bardliao
Copy link
Collaborator Author

@simontrimmer PR updated.

@simontrimmer
Copy link
Collaborator

Hiya @bardliao the well configured and error scenarios are a lot clearer now.

I'll, er, try to break it a bit more but I think that'll do the trick. @stefdb ?

@simontrimmer
Copy link
Collaborator

Hi @bardliao,
I just tried this out on a different laptop and found something a bit undesirable -

This product has a match table entry in the kernel and a monolithic topology file on the filesystem, but because of

commit d348b41
Author: Bard Liao yung-chuan.liao@linux.intel.com
Date: Mon Apr 14 14:32:35 2025 +0800

ASoC: Intel: soc-acpi-intel-arl-match: set get_function_tplg_files ops

The audio configs with multi-function SDCA codecs can use the
sof_sdw_get_tplg_files ops to get function topologies dynamically.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20250414063239.85200-8-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

It'll try to use functional topologies first, which aren't on this filesystem

[ 3.864763] sof-audio-pci-intel-mtl 0000:00:1f.3: Firmware file: intel/sof-ipc4/arl/sof-arl.ri
[ 3.864765] sof-audio-pci-intel-mtl 0000:00:1f.3: Firmware lib path: intel/sof-ipc4-lib/arl
[ 3.864766] sof-audio-pci-intel-mtl 0000:00:1f.3: Topology file: function topologies
...
[ 4.073069] sof_sdw sof_sdw: Failed to open topology file: intel/sof-ace-tplg/sof-sdca-jack-id0.tplg, you might need to
[ 4.073074] sof_sdw sof_sdw: download it from https://github.com/thesofproject/sof-bin/
...

but does seem to then fallback to the monolithic topology as the sound card does all hook up, but it doesn't print the topology that was used (intel/sof-ace-tplg/sof-arl-cs42l43-l0-cs35l56-l23.tplg)

Did we have to add functional topology callbacks to all the existing match entries? It makes sense to use it going forward but I'm wondering how much confusion this is going to cause

@bardliao
Copy link
Collaborator Author

bardliao commented Sep 3, 2025

Hi @bardliao, I just tried this out on a different laptop and found something a bit undesirable -

This product has a match table entry in the kernel and a monolithic topology file on the filesystem, but because of

commit d348b41
Author: Bard Liao yung-chuan.liao@linux.intel.com
Date: Mon Apr 14 14:32:35 2025 +0800

ASoC: Intel: soc-acpi-intel-arl-match: set get_function_tplg_files ops

The audio configs with multi-function SDCA codecs can use the
sof_sdw_get_tplg_files ops to get function topologies dynamically.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://patch.msgid.link/20250414063239.85200-8-yung-chuan.liao@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

It'll try to use functional topologies first, which aren't on this filesystem

[ 3.864763] sof-audio-pci-intel-mtl 0000:00:1f.3: Firmware file: intel/sof-ipc4/arl/sof-arl.ri
[ 3.864765] sof-audio-pci-intel-mtl 0000:00:1f.3: Firmware lib path: intel/sof-ipc4-lib/arl
[ 3.864766] sof-audio-pci-intel-mtl 0000:00:1f.3: Topology file: function topologies
...
[ 4.073069] sof_sdw sof_sdw: Failed to open topology file: intel/sof-ace-tplg/sof-sdca-jack-id0.tplg, you might need to
[ 4.073074] sof_sdw sof_sdw: download it from https://github.com/thesofproject/sof-bin/
...

but does seem to then fallback to the monolithic topology as the sound card does all hook up, but it doesn't print the topology that was used (intel/sof-ace-tplg/sof-arl-cs42l43-l0-cs35l56-l23.tplg)

Hmm, the topology name is printed with debug level.
https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/topology.c#L2528

Did we have to add functional topology callbacks to all the existing match entries? It makes sense to use it going forward but I'm wondering how much confusion this is going to cause

I added functional topology callbacks to the multi-function codecs match entries. Currently the sof_sdw_get_tplg_files callback only supports multi-function codecs.

@simontrimmer
Copy link
Collaborator

I'm just weighing up continuing changing the level of debug messages vs removing the callback from matches (there are around 15 the moment in scope for the Cirrus codecs and amps).

The logic is ideally if there is a match it should use the monolithic topology specified in the match entry as this maintains the behaviour of products that have already been tested with customers and it's extremely unlikely that we'd remove topology files from sof-bin as that would break compatibility with older kernels. On the downside that does mean I have a load of matches and topologies to make and upstream for PTL products.

I'm extremely keen to not add matches for the future Cirrus devices and any that sneak in before end user products go to market we'd back out so that they only used functional topologies.

@bardliao
Copy link
Collaborator Author

bardliao commented Sep 4, 2025

I'm just weighing up continuing changing the level of debug messages vs removing the callback from matches (there are around 15 the moment in scope for the Cirrus codecs and amps).

The logic is ideally if there is a match it should use the monolithic topology specified in the match entry as this maintains the behaviour of products that have already been tested with customers and it's extremely unlikely that we'd remove topology files from sof-bin as that would break compatibility with older kernels. On the downside that does mean I have a load of matches and topologies to make and upstream for PTL products.

I am totally fine if you want to remove the get_function_tplg_files callback from the acpi mach table. I added them just because I think they should work.

I'm extremely keen to not add matches for the future Cirrus devices and any that sneak in before end user products go to market we'd back out so that they only used functional topologies.

That is my goal, too. I am tired of adding new matches and new topologies. :)


return NULL;
/* The function topology needs the tplg file name to get the platform name for PCH DMIC */
/* FIXME: find another way to get the platform name */
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we update struct sof_intel_dsp_desc with the platform name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good suggestion will update.

@simontrimmer
Copy link
Collaborator

simontrimmer commented Sep 10, 2025

HI @bardliao ,
I've been trying to work out a way forward

Hmm, the topology name is printed with debug level.
https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/topology.c#L2528

I think increasing this to an info level is worthwhile; I've been trying out the changes on some different products that have different bios features and encountered one with bios mic mute. This product drops the SDCA function associated with the SmartMic so our old friend ID numbering comes up again:

[ 3.953565] sof_sdw sof_sdw: Failed to open topology file: intel/sof-ace-tplg/sof-hdmi-pcm5-id3.tplg, you might need to
[ 3.953577] sof_sdw sof_sdw: download it from https://github.com/thesofproject/sof-bin/

The code then (silently) falls back into the monolithic topology and you get errors beginning with

[ 3.955852] sof-audio-pci-intel-mtl 0000:00:1f.3: error: can't connect DAI alh-copier.Capture-SmartMic.0 stream Capture-SmartMic

So the error message would actually be quite helpful to understand what really happened

[ 3.953582] sof-audio-pci-intel-mtl 0000:00:1f.3: loading topology: intel/sof-ace-tplg/sof-arl-cs42l43-l0-cs35l56-l23.tplg

I'm also trying to find a good reason why we shouldn't remove this match entirely:

	{
		.link_mask = BIT(3),
		.links = ptl_cs42l43_l3,
		.drv_name = "sof_sdw",
		.sof_tplg_filename = "sof-ptl-cs42l43-l3.tplg",
		.get_function_tplg_files = sof_sdw_get_tplg_files,
	},

Which I think would channel all of our PTL products down the functional topology support (except the one ptl_cs42l43_l2_cs35l56x6_l13 that you'd added without the callback, maybe remove that earlier one too). We'd likely still have to make PTL matches and monolithic topologies for products that require a backport, but it would certainly reduce the amount of product support patches we'd have to make.

I'm just debating approaches with the other developers now...
-Simon

may be used

It may confuse people if "Topology file:" is printed but the topology
file is not really used. We keep the print if the topology file is
missing thus user can know what topology is missed in the file system.
And increase the log level to info for the actual topology that is used.
So that user can get which topology is used.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Currently, we use predefined snd_soc_acpi_link_adr tables to match the
link adr from ACPI table to select the machine driver and the topology.
However, with the mechanism, we need to create the snd_soc_acpi_link_adr
table for each audio config. The sof_sdw machine driver is used by
almost all Intel platforms with SOF and we can load required topology
file dynamically today. In other words, we can use sof_sdw machine
driver as the default machine driver for Intel SOF SoundWire codecs and
no need to create snd_soc_acpi_link_adr table for every new audio
configs.
To achieve it, we need to drop the const for some members and edit the
link adr and acpi adr data to match the data from the ACPI table.

Suggested-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Currently, the codec name_prefix of Intel SoundWire machine driver is
from the ACPI match table. We can have it in the asoc_sdw_codec_info
struct as a default name_prefix of a codec if there is no corresponding
audio config found in the ACPI match table.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
The sof_sdw_get_tplg_files function is a callback of snd_soc_acpi_mach.
Export it to allow other modules to use it.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
asoc_sdw_get_dai_type() is quite useful to convert SDCA function types
to SDW DAI types. It can be used by other drivers.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
The platform name will be used construct the topology name.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
If there is no SoundWire machine matches the existing acpi match table,
get the required machine data from the acpi table and construct the
link adrs and endpoints. Pass the data to the default Intel SoundWire
machine driver. And we don't need to add new item to the acpi match
table in common cases.
We will construct a dummy topology name. The dummy topology is just
used to extract the platform name for function topology and should not
be used.

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

Function topology must be used if the ACPI match table is created based
on the reported ACPI table because the monolithic topology is not picked
for the audio configuration.
Escalate the log and ask the user to download the latest topologies.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
@bardliao bardliao force-pushed the use_sof_sdw_as_default_sdw_machine branch from 67c965d to 698c629 Compare September 11, 2025 09:09
@bardliao bardliao requested a review from lyakh as a code owner September 11, 2025 09:09
@bardliao
Copy link
Collaborator Author

HI @bardliao , I've been trying to work out a way forward

Hmm, the topology name is printed with debug level.
https://github.com/thesofproject/linux/blob/topic/sof-dev/sound/soc/sof/topology.c#L2528

I think increasing this to an info level is worthwhile; I've been trying out the changes on some different products that have different bios features and encountered one with bios mic mute. This product drops the SDCA function associated with the SmartMic so our old friend ID numbering comes up again:

Increased the log level.

[ 3.953565] sof_sdw sof_sdw: Failed to open topology file: intel/sof-ace-tplg/sof-hdmi-pcm5-id3.tplg, you might need to
[ 3.953577] sof_sdw sof_sdw: download it from https://github.com/thesofproject/sof-bin/

Ah, another missing id. I will submit a PR to add the topology.

The code then (silently) falls back into the monolithic topology and you get errors beginning with

[ 3.955852] sof-audio-pci-intel-mtl 0000:00:1f.3: error: can't connect DAI alh-copier.Capture-SmartMic.0 stream Capture-SmartMic

So the error message would actually be quite helpful to understand what really happened

[ 3.953582] sof-audio-pci-intel-mtl 0000:00:1f.3: loading topology: intel/sof-ace-tplg/sof-arl-cs42l43-l0-cs35l56-l23.tplg

I'm also trying to find a good reason why we shouldn't remove this match entirely:

This can only be removed after this PR is merged. Otherwise, the driver can't find any match that matches the config and SDW machine driver will not be used.

	{
		.link_mask = BIT(3),
		.links = ptl_cs42l43_l3,
		.drv_name = "sof_sdw",
		.sof_tplg_filename = "sof-ptl-cs42l43-l3.tplg",
		.get_function_tplg_files = sof_sdw_get_tplg_files,
	},

Which I think would channel all of our PTL products down the functional topology support (except the one ptl_cs42l43_l2_cs35l56x6_l13 that you'd added without the callback, maybe remove that earlier one too). We'd likely still have to make PTL matches and monolithic topologies for products that require a backport, but it would certainly reduce the amount of product support patches we'd have to make.

This match will be selected when the cs42l43 is on SDW link 3 and no preceding match matches. Note that the more specific match should be added in the front of the table so it will be selected.

I'm just debating approaches with the other developers now... -Simon

@simontrimmer
Copy link
Collaborator

Hi @bardliao ,
Thanks!

Yes removing the lone cs42l43 bus match would be after this chain, at the moment at least some of the PTL products I'm tracking would match it and wouldn't instantiate the amplifiers in various arrangements, whereas it it is removed they would all just use the new method. Doing it at the point of a new CPU generation has it's attraction.
-Simon

@simontrimmer
Copy link
Collaborator

Hi @bardliao ,
I think we're out of thoughts on this one, we're looking at a few things that came out of wider testing but they won't get in the way of this chain
-Simon

@bardliao bardliao merged commit affe009 into thesofproject:topic/sof-dev Sep 16, 2025
7 of 16 checks passed
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.

9 participants