Skip to content

topology: alsatplg: add double-expansion for global defines - #337

Open
kv2019i wants to merge 1 commit into
alsa-project:masterfrom
kv2019i:202610-tplg-fix-global-define-expansion
Open

kv2019i wants to merge 1 commit into
alsa-project:masterfrom
kv2019i:202610-tplg-fix-global-define-expansion

Conversation

@kv2019i

@kv2019i kv2019i commented Oct 9, 2026

Copy link
Copy Markdown

Add support for following definition for global variables:

IncludeByKey.SDW_DMIC_PCM_CHANNELS {
"1" { Define { SDW_DMIC_CHANNEL_CFG $CHANNEL_CONFIG_MONO } }
}

This doesn't currently work as the pre-processor merges the nested Define into the global define registry as a STRING value ("$CHANNEL_CONFIG_MONO"). Later, during object attribute expansion, pre_process_object_variables_expand_fcn finds the variable in the global defines and returns immediately with that unresolved string. The caller then passes "$CHANNEL_CONFIG_MONO" to the token encoder, which cannot parse it as an integer and silently substitutes 0.

Add support for double expansion for such global defines. This is similar to how local variables are already handled (see commit 0029ab7 ("topology: Expand attribute references inside $[] expressions")), and will help to reduce repeated IncludeByKey statements in topology files.

Add support for following definition for global variables:

  IncludeByKey.SDW_DMIC_PCM_CHANNELS {
    "1" { Define { SDW_DMIC_CHANNEL_CFG $CHANNEL_CONFIG_MONO } }
  }

This doesn't currently work as the pre-processor merges the nested
Define into the global define registry as a STRING value
("$CHANNEL_CONFIG_MONO").  Later, during object attribute expansion,
pre_process_object_variables_expand_fcn finds the variable in the global
defines and returns immediately with that unresolved string.  The caller
then passes "$CHANNEL_CONFIG_MONO" to the token encoder, which cannot
parse it as an integer and silently substitutes 0.

Add support for double expansion for such global defines. This is
similar to how local variables are already handled (see commit
0029ab7 ("topology: Expand attribute references inside $[]
expressions")), and will help to reduce repeated IncludeByKey statements
in topology files.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
@kv2019i

kv2019i commented Oct 9, 2026

Copy link
Copy Markdown
Author

@perexg This would be useful to allow sort of definitions that are used in:
thesofproject/sof@87dc581

... we later needed to revert this as upstream alsa-utils cannot support such constructs, but upon review, I concluded this is useful facility and we should add support to upstream.

FYI @bardliao @singalsu @ujfalusi

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.

2 participants