Skip to content

Commit b544505

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 particularly 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 2 arguments needed to instantiate the host object i.e.. pipeline_id and 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 9fcfd75 commit b544505

64 files changed

Lines changed: 6274 additions & 3 deletions

Some content is hidden

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

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
}
@@ -62,6 +63,7 @@ Build commands for respective tools:
6263
probes: make -C "$BUILD_TOOLS_DIR" sof-probes
6364
tests: make -C "$BUILD_TOOLS_DIR" tests
6465
topologies: make -C "$BUILD_TOOLS_DIR" topologies
66+
topology2: make -C "$BUILD_TOOLS_DIR" topology2
6567
fuzzer: make -C "$BUILD_TOOLS_DIR/fuzzer"
6668
EOFUSAGE
6769
}
@@ -70,7 +72,7 @@ main()
7072
{
7173
local DO_BUILD_ctl DO_BUILD_fuzzer DO_BUILD_logger DO_BUILD_probes \
7274
DO_BUILD_tests DO_BUILD_topologies SCRIPT_DIR SOF_REPO CMAKE_ONLY \
73-
BUILD_ALL
75+
DO_BUILD_topology2 BUILD_ALL
7476
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
7577
SOF_REPO=$(dirname "$SCRIPT_DIR")
7678
: "${BUILD_TOOLS_DIR:=$SOF_REPO/tools/build_tools}"
@@ -87,18 +89,20 @@ main()
8789
DO_BUILD_probes=false
8890
DO_BUILD_tests=false
8991
DO_BUILD_topologies=false
92+
DO_BUILD_topology2=false
9093
CMAKE_ONLY=false
9194

9295
# eval is a sometimes necessary evil
9396
# shellcheck disable=SC2034
94-
while getopts "cfhlptTC" OPTION; do
97+
while getopts "cfhlptTzC" OPTION; do
9598
case "$OPTION" in
9699
c) DO_BUILD_ctl=true ;;
97100
f) DO_BUILD_fuzzer=true ;;
98101
l) DO_BUILD_logger=true ;;
99102
p) DO_BUILD_probes=true ;;
100103
t) DO_BUILD_tests=true ;;
101104
T) DO_BUILD_topologies=true ;;
105+
z) DO_BUILD_topology2=true ;;
102106
C) CMAKE_ONLY=true ;;
103107
h) print_usage; exit 1;;
104108
*) print_usage; exit 1;;
@@ -124,7 +128,7 @@ main()
124128
fi
125129
done
126130

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

tools/topology2/cavs-nocodec.conf

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
<include/common/manifest.conf>
14+
15+
#
16+
# Pipeline definitions
17+
#
18+
19+
# Pipeline ID:1 PCM ID: 0
20+
Object.pipeline-passthrough-playback."1.0" {
21+
pcm_name "Port0"
22+
format "s32le"
23+
channels 2
24+
rate 48000
25+
}
26+
27+
# Pipeline ID:2 PCM ID: 0
28+
Object.pipeline-passthrough-capture."2.0" {
29+
pcm_name "Port0"
30+
format "s32le"
31+
channels 2
32+
rate 48000
33+
}
34+
35+
#
36+
# List of all DAIs
37+
#
38+
#SSP Index: 0, Direction: duplex
39+
Object.SSP."0.0.duplex" {
40+
dai_name "NoCodec-0"
41+
id 0
42+
format "s24le"
43+
sample_bits 32
44+
quirks 64
45+
hw_config."0" {
46+
mclk_freq 24000000
47+
bclk_freq 4800000
48+
tdm_slot_width 32
49+
}
50+
51+
# include DAI copier components
52+
<include/dais/pipe-copier-playback.conf>
53+
<include/dais/pipe-copier-capture.conf>
54+
}
55+
56+
#
57+
# List of all endpoint connections
58+
#
59+
# Connect: Pipeline 1 -> SSP 0 DAI_IN
60+
Object.connection."endpoint.1.0" {
61+
source "endpoint.sink.pipeline.1.0"
62+
sink "endpoint.source.SSP.0.0"
63+
}
64+
65+
# Connect: Pipeline 2 <- SSP 0 DAI_OUT
66+
Object.connection."endpoint.2.0" {
67+
source "endpoint.sink.SSP.0.0"
68+
sink "endpoint.source.pipeline.2.0"
69+
}

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+
cat $2
22+
printf "Object.manifest.\"sof_manifest\" {\n"
23+
printf "\tdata.\"sof_manifest\" {\n"
24+
printf "\t\tbytes\t\"0x%02x," $MAJOR
25+
printf "0x%02x," $MINOR
26+
printf "0x%02x\"\n" $PATCH
27+
printf "\t}\n"
28+
printf "}"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Class.Custom."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+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Class.PCM."pcm" {
2+
#
3+
# Argument used to construct PCM
4+
#
5+
@args."pcm_name" {
6+
type "string"
7+
}
8+
9+
@args."direction" {
10+
type "string"
11+
}
12+
13+
@args."pcm_id" {
14+
type "integer"
15+
}
16+
17+
DefineAttribute.compress {}
18+
19+
DefineAttribute.playback_compatible_d0i3 {
20+
# Token reference and type
21+
token_ref "sof_tkn_stream.bool"
22+
}
23+
24+
DefineAttribute.capture_compatible_d0i3 {
25+
# Token reference and type
26+
token_ref "sof_tkn_stream.bool"
27+
}
28+
29+
attributes {
30+
mandatory [
31+
"compress"
32+
]
33+
}
34+
35+
# Default values for PCM attributes
36+
compress "false"
37+
}

0 commit comments

Comments
 (0)