Skip to content

Commit 937a805

Browse files
lrgirdworanj063
authored andcommitted
Topology2: introduction to topology2.0
About ----- This is a high level keyword extension on top of the existing ALSA conf topology format designed to: 1) Simplify the ALSA conf topology definitions by providing high level "classes" so topology designers need to write less config for common object definitions. 2) Allow simple reuse of objects. Define once and reuse (like M4) with the ability to alter objects configuration attributes from defaults. 3) Allow data type and value verification. This is not done today and frequently crops up in FW bug reports. Common Topology Classes ----------------------- Topology today has some common classes that are often reused throughout with slightly altered configurations. i.e. widgets (components), pipelines, dais and controls. This PR introduces the high level concept of reusable "class" like definitions that can be used to create topology objects e.g. Class.Component - Class for widgets that can be instantiated by pipeline classes/objects. See volume.conf, buffer.conf, host.conf, dai.conf in <include/components> Class.Pipeline - Class for pipelines that can be instantiated in the top-level conf files. See pipeline-volume.conf in <include/pipelines> Class.DAI - Class for DAIs such as SSP/DMIC/HDA etc. See ssp.conf in <include/dais> Class.Control- Class for mixers, byte controls, enum controls etc. See mixer.conf in <include/controls> Class.Base - Class for generic objects that cannot be inherited and are not usually instantiated as stand-alone objects but embedded within classes/objects of the above types. Ex: hw_config class for SSP hw_config params, see ssp_hw_config.conf in <include/dais> Common Topology Attributes -------------------------- Topology defines a lot of attributes per object with different types and constraints. Today there is no easy way to validate type or constraints and this can lead to many hard to find problems in FW at runtime. A new keyword "DefineAttribute" has been added to define attribute type, size, min value, max value, enum_values. This then allows alsatplg to validate each topology object attribute. Topology Classes define the list of attributes that they use and whether the attribute is mandatory, can be overridden by parent users or is immutable. This also helps alsatplg emit the appropriate errors for attribute misuse. Common Topology Arguments ------------------------- Arguments are used to pass essential data needed for instantiating an object particulary needed for the object name. Ex: host."5.playback". The first part in the object name stands for the class name “host” and the remaining “5.playback” stand for the 3 arguments needed to instantiate the host object i.e.. pipeline_id, , direction. ALSA Conf Parser ---------------- All the changes being proposed and discussed here must be 100% compliant with the ALSA conf parser. i.e. no syntax changes or changes to semantics for any existing keyword. It's intended that there will be NO changes to the ALSA conf parser (unless new keywords require this ?) and all topology building changes will be in the alsatplg compiler. alsatplg Compiler ----------------- The alsatplg compiler requires changes to construct and validate objects based on the new keywords. No changes to existing keywords. Existing topologies will not require any changes. The only two new keywords proposed at the top-level are “Class” and “Object”. All other keywords for class arguments and attributes are limited within the tplg2 compiler changes. Topology2 compiler changes also re-uses most of the code in the conf parser for parsing the configuration for widgets, controls, DAI, hw_config, backends etc. Opens ----- Add platform constraints and capabilities and include them so that alsatplg can apply these platform constraints on top of existing class attribute constraints such as valid SSP port number is 3 or 6 depending on the platform. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent b0faccc commit 937a805

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+6228
-3
lines changed

scripts/build-tools.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ usage: $0 [-c|-f|-h|-l|-p|-t|-T]
1616
-p Rebuild probes
1717
-t Rebuild test topologies
1818
-T Rebuild topologies
19+
-z Rebuild topology2
1920
-C No build, only CMake re-configuration
2021
EOFUSAGE
2122
}
@@ -60,6 +61,7 @@ Build commands for respective tools:
6061
probes: make -C "$BUILD_TOOLS_DIR" sof-probes
6162
tests: make -C "$BUILD_TOOLS_DIR" tests
6263
topologies: make -C "$BUILD_TOOLS_DIR" topologies
64+
topology2: make -C "$BUILD_TOOLS_DIR" topology2
6365
fuzzer: make -C "$BUILD_TOOLS_DIR/fuzzer"
6466
EOFUSAGE
6567
}
@@ -68,7 +70,7 @@ main()
6870
{
6971
local DO_BUILD_ctl DO_BUILD_fuzzer DO_BUILD_logger DO_BUILD_probes \
7072
DO_BUILD_tests DO_BUILD_topologies SCRIPT_DIR SOF_REPO CMAKE_ONLY \
71-
BUILD_ALL
73+
DO_BUILD_topology2 BUILD_ALL
7274
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
7375
SOF_REPO=$(dirname "$SCRIPT_DIR")
7476
BUILD_TOOLS_DIR="$SOF_REPO"/tools/build_tools
@@ -85,18 +87,20 @@ main()
8587
DO_BUILD_probes=false
8688
DO_BUILD_tests=false
8789
DO_BUILD_topologies=false
90+
DO_BUILD_topology2=false
8891
CMAKE_ONLY=false
8992

9093
# eval is a sometimes necessary evil
9194
# shellcheck disable=SC2034
92-
while getopts "cfhlptTC" OPTION; do
95+
while getopts "cfhlptTzC" OPTION; do
9396
case "$OPTION" in
9497
c) DO_BUILD_ctl=true ;;
9598
f) DO_BUILD_fuzzer=true ;;
9699
l) DO_BUILD_logger=true ;;
97100
p) DO_BUILD_probes=true ;;
98101
t) DO_BUILD_tests=true ;;
99102
T) DO_BUILD_topologies=true ;;
103+
z) DO_BUILD_topology2=true ;;
100104
C) CMAKE_ONLY=true ;;
101105
h) print_usage; exit 1;;
102106
*) print_usage; exit 1;;
@@ -122,7 +126,7 @@ main()
122126
fi
123127
done
124128

125-
for util in tests topologies; do
129+
for util in tests topologies topology2; do
126130
if eval '$DO_BUILD_'$util; then
127131
make_tool $util
128132
fi

tools/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ add_subdirectory(probes)
2626
add_subdirectory(logger)
2727
add_subdirectory(ctl)
2828
add_subdirectory(topology)
29+
add_subdirectory(topology2)
2930
add_subdirectory(test)

tools/topology2/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
3+
add_custom_target(abi2
4+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_abi.sh ${SOF_ROOT_SOURCE_DIRECTORY}
5+
DEPENDS ${TPLG_DEPS}
6+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
7+
VERBATIM
8+
USES_TERMINAL
9+
)
10+
11+
# Array of "input-file-name;output-file-name;"
12+
set(TPLGS
13+
"sof-cnl-nocodec\;sof-cnl-nocodec\;"
14+
"cavs-nocodec\;cavs-nocodec\;"
15+
"sof-hda-generic-4ch\;sof-hda-generic-4ch\;"
16+
"sof-hda-generic-2ch\;sof-hda-generic-2ch\;"
17+
"sof-tgl-max98373-rt5682\;sof-tgl-max98373-rt5682\;"
18+
"sof-tgl-sdw-max98373-rt5682-2ch\;sof-tgl-sdw-max98373-rt5682-2ch\;"
19+
"sof-tgl-sdw-max98373-rt5682-4ch\;sof-tgl-sdw-max98373-rt5682-4ch\;"
20+
)
21+
22+
add_custom_target(topology2 ALL)
23+
24+
foreach(tplg ${TPLGS})
25+
list(GET tplg 0 input)
26+
list(GET tplg 1 output)
27+
# Note: this does NOT use VERBATIM, see explanation in ../topology/CMakeLists.txt
28+
add_custom_command(
29+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output}.tplg
30+
COMMAND alsatplg \$\${VERBOSE:+-v 1} -c ${CMAKE_CURRENT_SOURCE_DIR}/${input}.conf -o ${output}.tplg
31+
DEPENDS abi2
32+
USES_TERMINAL
33+
)
34+
35+
add_custom_target(topology2_${output} DEPENDS ${output}.tplg)
36+
add_dependencies(topology2 topology2_${output})
37+
endforeach()

tools/topology2/abi-generated.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Object.manifest."sof_manifest" {
2+
data."sof_manifest" {
3+
bytes "0x03,0x12,0x01"
4+
}
5+
}

tools/topology2/cavs-nocodec.conf

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#
2+
# Simple Machine - High level topology - Maps to machine driver.
3+
#
4+
# PCM 0 <-> copier.host.N.0 <-> copier.SSP.0.M <-> SSP0
5+
#
6+
7+
<include/common/tokens.conf>
8+
<include/pipelines/cavs/pipeline-passthrough-playback.conf>
9+
<include/pipelines/cavs/pipeline-passthrough-capture.conf>
10+
<include/common/connection.conf>
11+
<include/common/endpoint.conf>
12+
<include/dais/ssp.conf>
13+
14+
#
15+
# Pipeline definitions
16+
#
17+
18+
# Pipeline ID:1 PCM ID: 0
19+
Object.pipeline-passthrough-playback."1.0" {
20+
pcm_name "Port0"
21+
format "s32le"
22+
channels 2
23+
rate 48000
24+
}
25+
26+
# Pipeline ID:2 PCM ID: 0
27+
Object.pipeline-passthrough-capture."2.0" {
28+
pcm_name "Port0"
29+
format "s32le"
30+
channels 2
31+
rate 48000
32+
}
33+
34+
#
35+
# List of all DAIs
36+
#
37+
#SSP Index: 0, Direction: duplex
38+
Object.SSP."0.0.duplex" {
39+
dai_name "NoCodec-0"
40+
id 0
41+
format "s24le"
42+
sample_bits 32
43+
quirks 64
44+
hw_config."0" {
45+
mclk_freq 24000000
46+
bclk_freq 4800000
47+
tdm_slot_width 32
48+
}
49+
50+
# include DAI copier components
51+
<include/dais/pipe-copier-playback.conf>
52+
<include/dais/pipe-copier-capture.conf>
53+
}
54+
55+
#
56+
# List of all endpoint connections
57+
#
58+
# Connect: Pipeline 1 -> SSP 0 DAI_IN
59+
Object.connection."endpoint.1.0" {
60+
source "endpoint.sink.pipeline.1.0"
61+
sink "endpoint.source.SSP.0.0"
62+
}
63+
64+
# Connect: Pipeline 2 <- SSP 0 DAI_OUT
65+
Object.connection."endpoint.2.0" {
66+
source "endpoint.sink.SSP.0.0"
67+
sink "endpoint.source.pipeline.2.0"
68+
}
69+
70+
#add abi
71+
<include/common/data.conf>
72+
<include/common/manifest.conf>
73+
<abi-generated.conf>

tools/topology2/get_abi.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
# Copyright(c) 2019 Intel Corporation. All rights reserved.
4+
5+
MAJOR=`grep '#define SOF_ABI_MAJOR ' $1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
6+
MINOR=`grep '#define SOF_ABI_MINOR ' $1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
7+
PATCH=`grep '#define SOF_ABI_PATCH ' $1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
8+
MAJOR_SHIFT=`grep '#define SOF_ABI_MAJOR_SHIFT'\
9+
$1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
10+
MINOR_SHIFT=`grep '#define SOF_ABI_MINOR_SHIFT'\
11+
$1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
12+
13+
major_val=$(($MAJOR << $MAJOR_SHIFT))
14+
minor_val=$(($MINOR << $MINOR_SHIFT))
15+
abi_version_3_8=$((3<<$MAJOR_SHIFT | 8<<$MINOR_SHIFT))
16+
abi_version=$(($major_val | $minor_val))
17+
abi_version_3_9_or_greater=$(($abi_version > $abi_version_3_8))
18+
abi_version_3_17=$((3<<$MAJOR_SHIFT | 17<<$MINOR_SHIFT))
19+
abi_version_3_17_or_greater=$(($abi_version >= $abi_version_3_17))
20+
21+
printf "Object.manifest.\"sof_manifest\" {\n" > abi-generated.conf
22+
printf "\tdata.\"sof_manifest\" {\n" >> abi-generated.conf
23+
printf "\t\tbytes\t\"0x%02x," $MAJOR >> abi-generated.conf
24+
printf "0x%02x," $MINOR >> abi-generated.conf
25+
printf "0x%02x\"\n" $PATCH >> abi-generated.conf
26+
printf "\t}\n" >> abi-generated.conf
27+
printf "}" >> abi-generated.conf
28+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Class.Base."connection" {
2+
3+
@args."type" {
4+
type "string"
5+
}
6+
7+
@args."pipeline_id" {
8+
type "integer"
9+
}
10+
11+
@args."index" {
12+
type "integer"
13+
}
14+
15+
DefineAttribute."source" {}
16+
17+
DefineAttribute."sink" {}
18+
19+
DefineAttribute."control" {}
20+
21+
attributes {
22+
mandatory [
23+
"source"
24+
"sink"
25+
]
26+
}
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Class.Base."data" {
2+
3+
@args."name" {
4+
type "string"
5+
}
6+
7+
DefineAttribute."bytes" {}
8+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Class.Base."endpoint" {
2+
3+
# sink/source
4+
@args."type" {
5+
type "string"
6+
constraints {
7+
values [
8+
"sink"
9+
"source"
10+
]
11+
}
12+
}
13+
14+
@args."class_name" {
15+
type "string"
16+
}
17+
18+
@args."id" {
19+
type "integer"
20+
}
21+
22+
@args."index" {
23+
type "integer"
24+
}
25+
26+
DefineAttribute."widget" {}
27+
28+
attributes {
29+
mandatory [
30+
"widget"
31+
]
32+
}
33+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Class.Base."manifest" {
2+
@args."name" {
3+
type "string"
4+
}
5+
}

0 commit comments

Comments
 (0)