Skip to content

ASoC: SOF: ipc4-topology: Track topology-defined SRC sink rates - #5994

Open
ujfalusi wants to merge 1 commit into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/ipc4-src-dont_forget
Open

ujfalusi wants to merge 1 commit into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/ipc4-src-dont_forget

Conversation

@ujfalusi

Copy link
Copy Markdown
Collaborator

The SRC prepare callback gives a nonzero sink rate precedence over the rate requested by the capture stream. However, it also writes the selected output rate back to the same field. If topology does not specify a sink rate, subsequent prepares therefore treat the previous runtime rate as a fixed topology rate instead of following the current stream parameters.

Record whether topology supplied a nonzero sink rate for SRC and ASRC, and only prioritize the stored rate in that case. Otherwise, select the rate at runtime on each prepare.

Select the format, base configuration, rate and provenance flag through the appropriate SRC or ASRC type in the shared prepare callback. Their IPC payloads have different sizes, so accessing ASRC through an SRC pointer must not rely on matching member offsets.

Fixes: 3c3ce66 ("ASoC: SOF: ipc4-topology: Allow the use of multiple formats for src output")
Cc: stable@vger.kernel.org

Copilot AI balanced review requested due to automatic review settings October 21, 2026 13:35

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.

🟢 Approval recommended

The focused changes address stale runtime rates and incorrect ASRC structure access, with no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes SOF IPC4 sample-rate selection so repeated prepares distinguish topology-defined rates from runtime-selected rates.

Changes:

  • Track whether topology specifies the SRC or ASRC sink rate.
  • Recalculate runtime rates on each prepare when topology leaves them unspecified.
  • Access SRC and ASRC fields through their correct structure types.
File Description
sound/​soc/​sof/​ipc4-topology.h Adds and documents topology-rate flags for SRC and ASRC.
sound/​soc/​sof/​ipc4-topology.c Initializes the flags and uses type-correct access during rate selection.

Review effort: Balanced

@ujfalusi

Copy link
Copy Markdown
Collaborator Author

build fix: #5995

kv2019i
kv2019i previously approved these changes Oct 21, 2026

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review +1 and also:

Reviewed-by: Kai Vehmanen kai.vehmanen@linux.intel.com
Tested-by: Kai Vehmanen kai.vehmanen@linux.intel.com

Copilot AI balanced review requested due to automatic review settings October 22, 2026 07:08
@ujfalusi
ujfalusi force-pushed the peter/sof/pr/ipc4-src-dont_forget branch from 46f77a7 to 631a6fe Compare October 22, 2026 07:08
@ujfalusi

Copy link
Copy Markdown
Collaborator Author

Changes since v1:

  • drop the approach and go with smaller, backportable patches:
  • fix the src/asrc main struct by moving the data at the end
  • add a flag to mark the src/out rate/freq from topology to allow reconfiguration
  • separate fixes tags, smaller changes.

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

The structure reorderings break input-format lookup for SRC and ASRC sinks on nonzero copier output queues.

1 open issue

Review effort: Balanced

Comment thread sound/soc/sof/ipc4-topology.h Outdated
Copilot AI balanced review requested due to automatic review settings October 22, 2026 07:33
@ujfalusi
ujfalusi force-pushed the peter/sof/pr/ipc4-src-dont_forget branch from 631a6fe to d1b1d7f Compare October 22, 2026 07:33
@ujfalusi
ujfalusi force-pushed the peter/sof/pr/ipc4-src-dont_forget branch from d1b1d7f to 65d72ab Compare October 22, 2026 07:36
The shared SRC/ASRC prepare callback gives a nonzero sink rate precedence
over the rate requested by the capture stream. However, it also writes
the selected output rate back to the same field. If topology does not
specify a sink rate, subsequent prepares therefore treat the previous
runtime rate as a fixed topology rate instead of following the current
stream parameters. For example a capture stream opened at 16 kHz after
one at 48 kHz on the same SRC keeps converting to 48 kHz.

Record whether topology supplied a nonzero sink rate for SRC and ASRC,
and only prioritize the stored rate in that case. Otherwise, select the
rate at runtime on each prepare.

Select the format, base configuration, rate and provenance flag through
the appropriate SRC or ASRC type in the shared prepare callback. Their IPC
payloads have different sizes, so accessing ASRC through an SRC pointer
must not rely on matching member offsets. On 64-bit the two sizes happen
to round up to the same offset for the following members, but on
architectures with 4-byte pointer alignment available_fmt and msg are
accessed at the wrong offset for ASRC.

Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Fixes: 3c3ce66 ("ASoC: SOF: ipc4-topology: Allow the use of multiple formats for src output")
Cc: stable@vger.kernel.org
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Tested-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>

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.

🟢 Approval recommended

Static review found no unresolved defects in repeated-prepare rate selection, structure access, or IPC payload handling.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 22, 2026 07:37
@ujfalusi

Copy link
Copy Markdown
Collaborator Author

Changes since v2:

  • back to v1, added @kv2019i 's reported/reviwed/tested tag

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.

🟢 Approval recommended

The focused changes correct repeated rate selection and ASRC field access without changing required payload layouts, and no unresolved issues remain.

No open issues 🎉

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.

3 participants