Skip to content

Audio: Selector: Add support for multiple up/down-mix profiles#10613

Open
singalsu wants to merge 3 commits intothesofproject:mainfrom
singalsu:selector_multiblob_support
Open

Audio: Selector: Add support for multiple up/down-mix profiles#10613
singalsu wants to merge 3 commits intothesofproject:mainfrom
singalsu:selector_multiblob_support

Conversation

@singalsu
Copy link
Collaborator

No description provided.

@singalsu
Copy link
Collaborator Author

singalsu commented Mar 10, 2026

WIP - I seem to have still incorrect channels order assumption for 5.1 format.

Update - it wasn't wrong, the cplay in tinycompress wasn't parsing the extended wav header that is used with more than two channels: alsa-project/tinycompress#32

@singalsu singalsu force-pushed the selector_multiblob_support branch from 7dcf377 to b2d33be Compare March 11, 2026 15:47
@singalsu singalsu marked this pull request as ready for review March 11, 2026 15:51
@singalsu singalsu requested a review from ranj063 as a code owner March 11, 2026 15:51
Copilot AI review requested due to automatic review settings March 11, 2026 15:51
Copy link
Contributor

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 extends the IPC4 selector/micsel coefficient blob format and firmware handling to support receiving multiple up/down-mix profiles in a single set_config() call, and adds a new combined topology blob intended for playback endpoint decoder-offload conversions.

Changes:

  • Add support in selector IPC4 path for multiple coefficient configurations and runtime selection by (source_channels, sink_channels), plus a “passthrough copy” fast-path.
  • Update the Octave blob-generation script to emit packed headers per profile and to generate a combined multi-profile blob.
  • Replace/remove legacy single-purpose downmix blob config files and add a new stereo_endpoint_playback_updownmix.conf multi-profile blob.

Reviewed changes

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

Show a summary per file
File Description
tools/topology/topology2/include/components/micsel/stereo_endpoint_playback_updownmix.conf Adds a new multi-profile selector_config blob for playback endpoint conversions.
tools/topology/topology2/include/components/micsel/downmix_71_to_stereo.conf Removes legacy single-profile blob (no-LFE variant).
tools/topology/topology2/include/components/micsel/downmix_71_to_mono.conf Removes legacy single-profile blob (no-LFE variant).
tools/topology/topology2/include/components/micsel/downmix_51_to_stereo.conf Removes legacy single-profile blob (no-LFE variant).
tools/topology/topology2/include/components/micsel/downmix_51_to_mono.conf Removes legacy single-profile blob (no-LFE variant).
src/include/sof/audio/selector.h Extends coeff config header layout and adds constants for Q10 unity and max config count.
src/audio/selector/tune/sof_selector_blobs.m Generates packed profile headers and a combined multi-profile blob.
src/audio/selector/selector_generic.c Updates processing calls to use a pointer to the selected coefficient config.
src/audio/selector/selector.c Allocates storage for multiple configs, parses multi-config blobs, selects profile at prepare time, and adds passthrough fast-path.

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

Copy link
Contributor

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

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


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

Copy link
Contributor

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

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


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

Comment on lines +803 to 806
cd->num_configs = n;
return memcpy_s(cd->multi_coeffs_config, cd->multi_coeffs_config_size,
fragment, data_offset_size);
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

selector_set_config() updates cd->num_configs and overwrites cd->multi_coeffs_config, but it does not reset/reselect cd->coeffs_config (or recompute cd->passthrough). If set_config() is called after prepare() (or if the new blob contains fewer profiles than before), cd->coeffs_config can keep pointing at an out-of-range/stale profile and the selector may use incorrect coefficients or an incorrect passthrough decision until the next prepare(). Consider resetting cd->coeffs_config to &cd->multi_coeffs_config[0] after the copy and, when the module is already initialized/prepared, re-running the coefficient selection + passthrough detection for the currently connected source/sink channel counts.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I wasn't planning on-the-run re-configuration but it can be added. Need to synchronize the changes to begin of copy() with a duplicate coeffs_config instead of a pointer to blob.

Comment on lines +904 to +911
if (cd->num_configs > 1) {
found = selector_config_array_search(cd, source_channels, sink_channels);
if (!found && source_channels == sink_channels) {
/* The pass-through mix is defined for the max channels count (8) */
source_channels = SEL_SOURCE_CHANNELS_MAX;
sink_channels = SEL_SINK_CHANNELS_MAX;
found = selector_config_array_search(cd, source_channels, sink_channels);
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

In selector_find_coefficients(), the fallback path overwrites source_channels/sink_channels with the hard-coded max (8) before logging and passthrough detection. This can make logs misleading for e.g. a 2->2 stream and also makes same-channel operation depend on an explicit 8->8 profile being present in multi-profile blobs. Consider preserving the original channel counts for logging/passthrough checks and treating “no matching profile + source==sink” as a valid passthrough case (use the default unity matrix) instead of requiring an 8->8 entry.

Copilot uses AI. Check for mistakes.
if (data_offset_size != sizeof(cd->coeffs_config))
if (data_offset_size > cd->multi_coeffs_config_size ||
pos != MODULE_CFG_FRAGMENT_SINGLE) {
comp_err(mod->dev, "Failure with size %d pos %d", data_offset_size, pos);
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

comp_err() uses %d for data_offset_size (a uint32_t) which can print negative values for large sizes. Use %u (and consider casting pos to int if you want to keep %d).

Suggested change
comp_err(mod->dev, "Failure with size %d pos %d", data_offset_size, pos);
comp_err(mod->dev, "Failure with size %u pos %d", data_offset_size, pos);

Copilot uses AI. Check for mistakes.
sel.rsvd1 = 0;
sel.ch_count = [8 8]; % Number of channels
sel.ch_config = [IPC4_CHANNEL_CONFIG_7_POINT_1 IPC4_CHANNEL_CONFIG_7_POINT_1];
sel.ch_out = 8;
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

sel.ch_out is assigned but never used. Removing it would avoid confusion about whether output channel count is expected to be part of the packed blob format.

Suggested change
sel.ch_out = 8;

Copilot uses AI. Check for mistakes.
This patch extends the struct ipc4_selector_coeffs_config. The
first 16-bit reserved field is split into to 8-bit field
for source and sink channels count.

The configuration is changed to array of the previous structs
instead of single. When preparing for stream the array is checked
for matching number of channels for source and sink and if found
the coefficients for the channels counts is selected into use.

The change avoids the need for user space to update the
configuration in runtime if the blob used for initialization
contains all the needed channels up/down-mix profiles.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch modifies the configuration blobs build script
sof_selector_blobs.m to create one blob that contains several
of them for the purpose to up or down-mix DSP offloaded decoder
output. The blob uses the reserved fields of selector configuration
to describe source and sink channel counts and channel config
values. The exported blob is "stereo_endpoint_playback_updownmix.conf".

The single configuration blobs continue to be with the reserved
fields as zeros. The .conf blobs may be removed later when other
topologies are modified to not use them.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds for micsel component configuration blob
"stereo_endpoint_playback_updownmix.conf". It contains the
needed up-mix and down-mix coefficients to handle playback
of mono, 5.1 and 7.1 channels into stereo endpoint.

The old configuration blobs with five and seven channels
without LFE channel are removed. Despite the file names with
"51" and "71" the blobs are not suitable for 6ch or 8ch
handling.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu force-pushed the selector_multiblob_support branch from 9ec813f to 5ee027d Compare March 13, 2026 10:45
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