Skip to content

topology2: alh: add tuple_values for the direction attribute - #11412

Open
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202611-tplg2-fix-build-with-upstream
Open

kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202611-tplg2-fix-build-with-upstream

Conversation

@kv2019i

@kv2019i kv2019i commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

The ALH DAI class defines "direction" as a string attribute with token_ref "dai.word", but lacks the tuple_values mapping that other classes (dai, dai-copier, host-copier) use. As a result the string values "playback"/"capture" end up verbatim in a word tuple.

Older alsa-lib converted such strings with strtoul() and silently encoded them as 0 (so capture links were also encoded as 0). Since alsa-lib commit c41be26af2d9 ("topology: use snd_config_get_llong() in tplg_get_integer/unsigned()"), non-numeric strings are rejected and the build of e.g. cavs-sdw.tplg fails with:

ALSA lib data.c:866:(parse_tuple_set) [error.topology] tuple direction: Invalid argument

Add tuple_values to map the direction strings to numeric values.

Link: alsa-project/alsa-lib@c41be26

The ALH DAI class defines "direction" as a string attribute with
token_ref "dai.word", but lacks the tuple_values mapping that other
classes (dai, dai-copier, host-copier) use. As a result the string
values "playback"/"capture" end up verbatim in a word tuple.

Older alsa-lib converted such strings with strtoul() and silently
encoded them as 0 (so capture links were also encoded as 0). Since
alsa-lib commit c41be26af2d9 ("topology: use snd_config_get_llong() in
tplg_get_integer/unsigned()"), non-numeric strings are rejected and
the build of e.g. cavs-sdw.tplg fails with:

  ALSA lib data.c:866:(parse_tuple_set) [error.topology] tuple direction: Invalid argument

Add tuple_values to map the direction strings to numeric values.

Link: alsa-project/alsa-lib@c41be26
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i
kv2019i requested review from bardliao and ujfalusi and a balanced review from Copilot November 6, 2026 16:44
@kv2019i

kv2019i commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

This fixes SOF build with upstream alsa-lib. @ujfalusi and @bardliao I do wonder should we alternatively drop the direction value for ALH. Based on my analysis, it is not really used by the kernel, which explains why the wrong values in existing topologies have not caused any bad outcomes. My checks so far from kernel source:

  • IPC4: never reads this token. Its dai_tokens list (ipc4-topology.c:150) has only SOF_TKN_DAI_TYPE and SOF_TKN_DAI_INDEX.
  • IPC3: reads it in one place, the dai_tokens entry at ipc3-topology.c:88, which fills sof_ipc_comp_dai.direction. That list is applied only to DAI widget tuples (swidget->tuples, ipc3-topology.c:1630).
  • Link private data: sof_link_load() (topology.c:2028-2050) copies only the SOF_DAI_LINK_TOKENS set (type and index, no direction) plus the per-DAI-type set. For ALH, those are just the ALH rate and channels tokens. Tuples are matched by token ID, so a direction tuple in link data is skipped.

So as an alternative to this PR, we could also drop "dai.word" from ALH. Let me know what you think.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

No open issues 🎉

What changed in this PR

Adds an explicit tuple_values mapping for the ALH DAI direction attribute so string tokens (playback/capture/duplex) are encoded as numeric tuple values and don’t fail parsing on newer alsa-lib.

Changes:

  • Add !tuple_values for ALH direction to map direction strings to numeric values (0/1/2).
File Description
tools/​topology/​topology2/​include/​dais/​alh.conf Adds tuple_values mapping for direction to ensure topology tuple encoding works with stricter alsa-lib parsing

Review effort: Lite

@intel-sofci

Copy link
Copy Markdown

PR 11412: test results

Run date: 2026-11-06 18:36 UTC

Tested commit: c63b6406b4353fda5432528551072bfe4f17fbd2

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

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