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
tests: make -C "$BUILD_TOOLS_DIR" tests
topologies: make -C "$BUILD_TOOLS_DIR" topologies
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\;"
)

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} -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()
22 changes: 22 additions & 0 deletions tools/topology2/get_abi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2019 Intel Corporation. All rights reserved.
Copy link
Collaborator

@marc-hb marc-hb Mar 19, 2021

Choose a reason for hiding this comment

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

Please add set -e. DONE

Please move all the code to a main "$@" function, see example in build-tools.sh above.
Pros:

  • can declare other functions in any order
  • can use local variables to avoid shadowing
  • easier to source for interactive debug, just comment out the last line
  • keeps the same indentation level and minimizes diff when moving code around functions

Cons:

  • None

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.manifest."0" {
name "sof_manifest"
Object.data."0" {
name "sof_manifest"
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 "}"
54 changes: 54 additions & 0 deletions tools/topology2/include/common/connection.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Class definition for DAPM graph connection objects
# These are instantiated as follows:
# Example:
# Object.connection."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 connection object within the same alsaconf node.
#
# Example: endpoint connection
# Object.connection."N" {
# source "Object.buffer.2"
# sink "Object.pga.2"
# }
# The above object specifies the route: "buffer.2 -> pga.2" where buffer.2 is the buffer object
# with index 2 and pga.2 refers to the PGA object with index 2 in the parent object.
# and N is the unique instance number for the connection object within the same alsaconf node.
#
#
Class.Base."connection" {
DefineArgument."index" {}

# 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" {}

# these attributes will be set by the alsatplg compiler after resolving the Object
# reference
DefineAttribute."source_widget" {}
DefineAttribute."sink_widget" {}

attributes {
mandatory [
"source"
"sink"
]
automatic [
"source_widget"
"sink_widget"
]
#
# index attribute values for connection objects must be unique in the same alsaconf
# node
#
unique "index"
}
}
18 changes: 18 additions & 0 deletions tools/topology2/include/common/data.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Class definition for data object
Class.Base."data" {

DefineArgument."name" {}

DefineAttribute."bytes" {}

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

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

}
47 changes: 47 additions & 0 deletions tools/topology2/include/common/pcm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# PCM Class definition. PCM object can be instantiated as:
# PCM
# Object.pcm."N" {
# pcm_name "Headset"
# direction "playback"
# pcm_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
#
DefineArgument."pcm_name" {}

DefineArgument."direction" {}

DefineArgument."pcm_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 {
mandatory [
"compress"
"pcm_name"
"pcm_id"
"direction"
]
#
# pcm_id attribute values for pcm objects must be unique in the same alsaconf
# node
#
unique "pcm_id"
}

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

# Object.pcm_caps."N" {
# pcm_name "Headset"
# direction "playback"
# pcm_id 2
# 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
#
DefineArgument."pcm_name" {}

DefineArgument."direction" {}

DefineArgument."pcm_id" {}

DefineAttribute."formats" {}

DefineAttribute."rates" {}

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 {
mandatory [
"pcm_name"
"pcm_id"
"direction"
"formats "
"rate_min"
"rate_max"
"channels_min"
"channels_max"
"periods_min"
"periods_max"
"period_size_min"
"period_size_max"
"buffer_size_min"
"buffer_size_max"
]
#
# pcm_id attribute values for pcm_caps objects must be unique in the same alsaconf
# node
#
unique "pcm_id"
}

# 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
}
41 changes: 41 additions & 0 deletions tools/topology2/include/common/pipe_endpoint.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Class definition for pipeline endpoint objects
# These are instantiated as follows:
# Object.endpoint."N" {
# widget "Object.buffer.0"
# }
# where N is the unique instance number for the endpoint object within the same alsaconf node.
# and widget refers to the buffer object with index 0 in the parent object that instantiates
# the endpoint.

Class.Base."endpoint" {
DefineArgument."pipeline_id" {
type "integer"
}

# unique identifier for endpoints in parent object
DefineArgument."index" {
type "integer"
}

# widget attribute should refer to an Object of a certain class with a unique value.
# in the parent object_list
DefineAttribute."widget" {}

# the widget_name will be set by the alsatplg compiler after resolving the object
# reference
DefineAttribute."widget_name" {}

attributes {
mandatory [
"widget"
]
automatic [
"widget_name"
]
#
# index attribute values for endpoint objects must be unique in the same alsaconf
# node
#
unique "index"
}
}
Loading