Skip to content

[FEATURE] topology2: enable string concatenation for parameter passing #6985

Open

Description

@lyakh

Is your feature request related to a problem? Please describe.
When including topology2 configuration files into a top-level file, where those included files don't only define classes but also instantiate objects, names in the included and in the including files have to match, which currently can only be achieved by hard-coding. Included files should be using parameters passed to them instead, which is unsupported ATM. See e8f170e#diff-3a76b3b9be741be592ab3e43fb13a010876f407a73bb8113c6f3851e84f5bd98R29 for examples of such hard-coding, e.g.

Object.PCM.pcm.210 {
	name "Port0 Aux Playback"
	id 210

Describe the solution you'd like
With topology1 / m4 we could pass parameters and then compose names by simply using parameters in strings like

define(`PIPELINE_ID', $2)
define(`N_BUFFER', `BUF'PIPELINE_ID`.'$1)

which would concatenate the string "BUF" with the value of the variable PIPELINE_ID which was set from the second parameter, a character '.' and the first parameter. That would then generate a string like "BUF20.1" for pipeline 20 and buffer ID 1.
Topology2 uses the alsaconf language which doesn't support this kind of string manipulation. To concatenate strings there something like

{
    @func concat
    strings [ "a1" "b2" "c3" ]
}

is used.

Describe alternatives you've considered
On the one hand alsaconf already has a way to concatenate strings described above - using @func concat, so supposedly we should use it too. OTOH I'm not even sure this is feasible in our case, but defining an additional string concatenation method for alsaconf seems wrong too.

Activity

  1. ranj063 commented on Jan 24, 2023

    @ranj063
    Collaborator

    @lyakh fix posted upstream: alsa-project/alsa-utils#188

    This fix doesnt use string concat but rather the compiler takes care of making sure that the objects in the included file have unique instance ID's

  2. lyakh commented on Jan 25, 2023

    @lyakh
    CollaboratorAuthor

    @lyakh fix posted upstream: alsa-project/alsa-utils#188

    This fix doesnt use string concat but rather the compiler takes care of making sure that the objects in the included file have unique instance ID's

    @ranj063 Thanks! Yes, that should solve this specific problem, but what about others? E.g. look at

    DMIC0_HOST_PIPELINE_SINK 'copier.host.13.1'
    DMIC0_DAI_PIPELINE_SRC 'copier.DMIC.14.1'
    and
    DEEP_BUFFER_PIPELINE_SRC 'mixin.15.1'
    DEEP_BUFFER_PIPELINE_SINK 'mixout.2.1'
    - shouldn't cases like that be created with concatenation too?

  3. jsarha commented on Feb 13, 2025

    @jsarha
    Contributor

    So @lyakh you are looking for something like device-tree p-handle? A possibility to tag a topology object instance and refer to that tag in other parts of the topology, without need to refer to automatically assigned object names?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions