Skip to content
10 changes: 7 additions & 3 deletions scripts/build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ usage: $0 [-c|-f|-h|-l|-p|-t|-T]
-p Rebuild probes
-t Rebuild test topologies
-T Rebuild topologies
-z Rebuild topology2
-C No build, only CMake re-configuration
EOFUSAGE
}
Expand Down Expand Up @@ -62,6 +63,7 @@ Build commands for respective tools:
probes: make -C "$BUILD_TOOLS_DIR" sof-probes
topologies: make -C "$BUILD_TOOLS_DIR" topologies
test tplgs: make -C "$BUILD_TOOLS_DIR" tests
topology2: make -C "$BUILD_TOOLS_DIR" topology2
fuzzer: make -C "$BUILD_TOOLS_DIR/fuzzer"
EOFUSAGE
}
Expand All @@ -70,7 +72,7 @@ main()
{
local DO_BUILD_ctl DO_BUILD_fuzzer DO_BUILD_logger DO_BUILD_probes \
DO_BUILD_tests DO_BUILD_topologies SCRIPT_DIR SOF_REPO CMAKE_ONLY \
BUILD_ALL
DO_BUILD_topology2 BUILD_ALL
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SOF_REPO=$(dirname "$SCRIPT_DIR")
: "${BUILD_TOOLS_DIR:=$SOF_REPO/tools/build_tools}"
Expand All @@ -87,18 +89,20 @@ main()
DO_BUILD_probes=false
DO_BUILD_tests=false
DO_BUILD_topologies=false
DO_BUILD_topology2=false
CMAKE_ONLY=false

# eval is a sometimes necessary evil
# shellcheck disable=SC2034
while getopts "cfhlptTC" OPTION; do
while getopts "cfhlptTzC" OPTION; do
case "$OPTION" in
c) DO_BUILD_ctl=true ;;
f) DO_BUILD_fuzzer=true ;;
l) DO_BUILD_logger=true ;;
p) DO_BUILD_probes=true ;;
t) DO_BUILD_tests=true ;;
T) DO_BUILD_topologies=true ;;
z) DO_BUILD_topology2=true ;;
C) CMAKE_ONLY=true ;;
h) print_usage; exit 1;;
*) print_usage; exit 1;;
Expand All @@ -124,7 +128,7 @@ main()
fi
done

for util in tests topologies; do
for util in tests topologies topology2; do
if eval '$DO_BUILD_'$util; then
make_tool $util
fi
Expand Down
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ add_subdirectory(probes)
add_subdirectory(logger)
add_subdirectory(ctl)
add_subdirectory(topology)
add_subdirectory(topology2)
add_subdirectory(test)
31 changes: 31 additions & 0 deletions tools/topology2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: BSD-3-Clause

# Array of "input-file-name;output-file-name;"
set(TPLGS
"sof-cnl-nocodec\;sof-cnl-nocodec\;"
Copy link
Collaborator

@marc-hb marc-hb Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned on the chat, you can't have ${input}.conf == ${output}.conf, no build system will support that.

I suggest sof-cnl-nocodec_output.conf or something.

)

add_custom_target(topology2 ALL)

foreach(tplg ${TPLGS})
list(GET tplg 0 input)
list(GET tplg 1 output)

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/get_abi.sh ${SOF_ROOT_SOURCE_DIRECTORY}
${CMAKE_CURRENT_SOURCE_DIR}/${input}.conf > ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf
USES_TERMINAL
)

# Note: this does NOT use VERBATIM, see explanation in ../topology/CMakeLists.txt
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${output}.tplg
COMMAND alsatplg \$\${VERBOSE:+-v 1} -p -c ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf -o ${output}.tplg
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output}.conf
USES_TERMINAL
)

add_custom_target(topology2_${output} DEPENDS ${output}.tplg)
add_dependencies(topology2 topology2_${output})
endforeach()
20 changes: 20 additions & 0 deletions tools/topology2/get_abi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2019 Intel Corporation. All rights reserved.
set -e

ABI_MAJOR=$(awk '/^ *# *define *SOF_ABI_MAJOR / { print $3 }' $1/src/include/kernel/abi.h)
ABI_MINOR=$(awk '/^ *# *define *SOF_ABI_MINOR / { print $3 }' $1/src/include/kernel/abi.h)
ABI_PATCH=$(awk '/^ *# *define *SOF_ABI_PATCH / { print $3 }' $1/src/include/kernel/abi.h)

cat $2
cat <<EOF_HEADER

Object.Base.manifest."sof_manifest" {
Object.Base.data."SOF ABI" {
EOF_HEADER
printf '\t\tbytes\t"0x%02x,' "$ABI_MAJOR"
printf "0x%02x," "$ABI_MINOR"
printf '0x%02x\"\n' "$ABI_PATCH"
printf "\t}\n"
printf "}"
28 changes: 28 additions & 0 deletions tools/topology2/include/common/data.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Class definition for data object
# Data objects can be instantiated as:
#
# Object.Base.data."SOF ABI" {
# bytes "0x3, 0x12,0x1"
# }
#
Class.Base."data" {

DefineAttribute."name" {
type "string"
}

DefineAttribute."bytes" {
type "string"
}

attributes {
constructor [
"name"
]
#
# data objects instantiated within the same alsaconf node must have unique
# name attribute
#
unique "name"
}
}
27 changes: 27 additions & 0 deletions tools/topology2/include/common/fe_dai.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Class definition for data object
# FE DAI objects can be instantiated as
# Object.Base.fe_dai."Port 0" {
# id "0"
# }
Class.Base."fe_dai" {

DefineAttribute."name" {
type "string"
}

DefineAttribute."id" {}

attributes {
constructor [
"name"
]
mandatory [
"id"
]
#
# name attribute values for fe_dai objects must be unique in the same alsaconf
# node
#
unique "name"
}
}
18 changes: 18 additions & 0 deletions tools/topology2/include/common/manifest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Class definition for manifest object
Class.Base."manifest" {
DefineAttribute."name" {
type "string"
}

attributes {
constructor [
"name"
]
#
# name attribute values for manifest objects must be unique in the same alsaconf
# node
#
unique "name"
}

}
54 changes: 54 additions & 0 deletions tools/topology2/include/common/pcm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# PCM Class definition. PCM object can be instantiated as:
# PCM
# Object.pcm."N" {
# pcm_name "Headset"
# direction "playback"
# id 2
# }
# where N is the unique instance number for the PCM object within the same alsaconf node.
Class.PCM."pcm" {
#
# Argument used to construct PCM
#
DefineAttribute."name" {}

DefineAttribute."direction" {
constraints {
valid_values [
playback
capture
duplex
]
}
}

DefineAttribute."id" {}

DefineAttribute."compress" {}

DefineAttribute."playback_compatible_d0i3" {
# Token reference and type
token_ref "sof_tkn_stream.bool"
}

DefineAttribute."capture_compatible_d0i3" {
# Token reference and type
token_ref "sof_tkn_stream.bool"
}

attributes {
constructor [
"name"
"id"
"direction"
]
#
# pcm objects instantiated within the same alsaconf node must have unique
# id attribute
#
unique "id"
}

# Default values for PCM attributes
compress "false"
}
86 changes: 86 additions & 0 deletions tools/topology2/include/common/pcm_caps.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# PCM Capabilities Class definition. PCM object can be instantiated as:

# Object.pcm_caps."N" {
# name "Headset"
# capabilities "Headset Playback"
# direction "playback"
# formats "S32_LE,S24_LE,S16_LE"
# rate_min 48000
# rate_max 48000
# channels_min 2
# channels_max 2
# periods_min 2
# }
# where N is the unique instance number for the pcm_caps object within the same alsaconf node.

Class.PCM."pcm_caps" {
#
# Argument used to construct PCM Capabilities
#
DefineAttribute."name" {
type "string"
}

DefineAttribute."direction" {
type "string"
valid_values [
playback
capture
]
}

DefineAttribute."formats" {
type "string"
}

DefineAttribute."rates" {
type "string"
}

DefineAttribute."sigbits" {}

DefineAttribute."rate_min" {}

DefineAttribute."rate_max" {}

DefineAttribute."channels_min" {}

DefineAttribute."channels_max" {}

DefineAttribute."periods_min" {}

DefineAttribute."periods_max" {}

DefineAttribute."period_size_min" {}

DefineAttribute."period_size_max" {}

DefineAttribute."buffer_size_min" {}

DefineAttribute."buffer_size_max" {}

attributes {
constructor [
"name"
"direction"
]
#
# pcm_caps objects instantiated within the same alsaconf node must have unique
# direction attribute
#
unique "direction"
}

# Default attribute values for PCM capabilities
formats "S32_LE,S24_LE,S16_LE"
rate_min 48000
rate_max 48000
channels_min 2
channels_max 2
periods_min 2
periods_max 16
period_size_min 192
period_size_max 16384
buffer_size_min 65536
buffer_size_max 65536
}
48 changes: 48 additions & 0 deletions tools/topology2/include/common/route.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Class definition for DAPM graph route objects
# These are instantiated as follows:
# Example:
# Object.Base.route."N" {
# source "Object.SSP.1.dai.capture"
# sink "Object.volume-playback.0.endpoint.0"
# }
# The above object specifies a DAPM graph route:
# "SSP.1 capture DAI -> volume-playback pipeline endpoint 0"
# The alsatplg compiler will look up the widget that the pipeline endpoint refers to.
# and N is the unique instance number for the route object within the same alsaconf node.
#
#
#
Class.Base."route" {


# control name for the route
DefineAttribute."control" {}

# source and sink attributes should refer an object of a certain class with a unique value
# in the parent object_list
DefineAttribute."sink" {}
DefineAttribute."source" {}

#
# Pipeline ID of the pipeline the route object belongs to
#
DefineAttribute."index" {}

DefineAttribute."instance" {}

attributes {
constructor [
"instance"
]
mandatory [
"instance"
"source"
"sink"
]
#
# route objects instantiated within the same alsaconf node must have unique
# index attribute
#
unique "instance"
}
}
Loading