The tools/topology directory contains the build infrastructure and source files used to generate Advanced Linux Sound Architecture (ALSA) topology (.tplg) binaries for Sound Open Firmware.
ALSA topology files describe the audio DSP graph (pipelines, widgets, routes, DAIs) and are loaded dynamically by the Linux kernel SOF driver during initialization. This allows a single generic driver to support a wide variety of hardware configurations and routing paths without requiring source code changes in the kernel.
To support the evolution of the SOF topology syntax, the configuration files are split into two main versions:
topology1/: Contains the legacy (v1)m4-based ALSA topology generation scripts and configuration files. Topology v1 heavily relies onm4macro preprocessing to generate the final.conffiles before being compiled byalsatplg.topology2/: Contains the newer (v2) ALSA topology generation files. Topology v2 introduces a more structured, object-oriented syntax natively supported by newer versions of thealsatplgcompiler (specifically the pre-processor-pflag), reducing reliance on external macro languages.
The topology build process is managed by CMakeLists.txt in this root directory. It performs the following key steps:
- Compiler Detection: It locates the
alsatplgtool (usually built intools/bin/alsatplgalongside the firmware) and checks its version. - Feature Validation: It ensures the
alsatplgversion is at least1.2.5. Older versions are known to silently corrupt certain topology structures (e.g., convertingcodec_consumertocodec_master). If the tool is too old, topology generation is safely skipped with a warning. - Target Generation: It provides macros (
add_alsatplg_commandandadd_alsatplg2_command) used by the subdirectories to invoke the topology compiler on the pre-processed.conffiles to generate the final.tplgbinaries.
The topologies CMake target is the master target that depends on the generation targets inside both topology1 and topology2.