Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
38 changes: 38 additions & 0 deletions tools/topology2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: BSD-3-Clause

# Array of "input-file-name;output-file-name;"
# Array of "input-file-name;output-file-name;"
set(TPLGS
"sof-cnl-nocodec\;sof-cnl-nocodec\;"
"cavs-nocodec\;cavs-nocodec\;"
"sof-hda-generic-4ch\;sof-hda-generic-4ch\;"
"sof-hda-generic-2ch\;sof-hda-generic-2ch\;"
"sof-tgl-max98373-rt5682\;sof-tgl-max98373-rt5682\;"
"sof-tgl-sdw-max98373-rt5682-2ch\;sof-tgl-sdw-max98373-rt5682-2ch\;"
"sof-tgl-sdw-max98373-rt5682-4ch\;sof-tgl-sdw-max98373-rt5682-4ch\;"
)

add_custom_target(topology2 ALL)

foreach(tplg ${TPLGS})
list(GET tplg 0 input)
list(GET tplg 1 output)
# Note: this does NOT use VERBATIM, see explanation in ../topology/CMakeLists.txt

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
)

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()
69 changes: 69 additions & 0 deletions tools/topology2/cavs-nocodec.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
# Simple Machine - High level topology - Maps to machine driver.
#
# PCM 0 <-> copier.host.N.0 <-> copier.SSP.0.M <-> SSP0
#

<include/common/tokens.conf>
<include/pipelines/cavs/pipeline-passthrough-playback.conf>
<include/pipelines/cavs/pipeline-passthrough-capture.conf>
<include/common/connection.conf>
<include/common/endpoint.conf>
<include/dais/ssp.conf>
Copy link
Member Author

Choose a reason for hiding this comment

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

best to order this on dependencies, i.e. common at the top

<include/common/manifest.conf>

#
# Pipeline definitions
#

# Pipeline ID:1 PCM ID: 0
Object.pipeline-passthrough-playback."1.0" {
pcm_name "Port0"
format "s32le"
channels 2
rate 48000
}

# Pipeline ID:2 PCM ID: 0
Object.pipeline-passthrough-capture."2.0" {
pcm_name "Port0"
format "s32le"
channels 2
rate 48000
}

#
# List of all DAIs
#
#SSP Index: 0, Direction: duplex
Object.SSP."0.0.duplex" {
dai_name "NoCodec-0"
id 0
format "s24le"
sample_bits 32
quirks 64
Copy link
Member Author

Choose a reason for hiding this comment

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

These should be named boolean attributes rather than a value. e.g.

attribute."ssp_do_this" {
    type boolean
    default false
   tuple_id ssp_do_this_quirk
}

it can then be invoked via

ssp_do_this "true"

hw_config."0" {
mclk_freq 24000000
bclk_freq 4800000
tdm_slot_width 32
}

# include DAI copier components
<include/dais/pipe-copier-playback.conf>
<include/dais/pipe-copier-capture.conf>
}

#
# List of all endpoint connections
#
# Connect: Pipeline 1 -> SSP 0 DAI_IN
Object.connection."endpoint.1.0" {
source "endpoint.sink.pipeline.1.0"
sink "endpoint.source.SSP.0.0"
}

# Connect: Pipeline 2 <- SSP 0 DAI_OUT
Object.connection."endpoint.2.0" {
source "endpoint.sink.SSP.0.0"
sink "endpoint.source.pipeline.2.0"
}
28 changes: 28 additions & 0 deletions tools/topology2/get_abi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2019 Intel Corporation. All rights reserved.

MAJOR=`grep '#define SOF_ABI_MAJOR ' $1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
MINOR=`grep '#define SOF_ABI_MINOR ' $1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
PATCH=`grep '#define SOF_ABI_PATCH ' $1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
MAJOR_SHIFT=`grep '#define SOF_ABI_MAJOR_SHIFT'\
$1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`
MINOR_SHIFT=`grep '#define SOF_ABI_MINOR_SHIFT'\
$1/src/include/kernel/abi.h | grep -E ".[[:digit:]]$" -o`

major_val=$(($MAJOR << $MAJOR_SHIFT))
minor_val=$(($MINOR << $MINOR_SHIFT))
abi_version_3_8=$((3<<$MAJOR_SHIFT | 8<<$MINOR_SHIFT))
abi_version=$(($major_val | $minor_val))
abi_version_3_9_or_greater=$(($abi_version > $abi_version_3_8))
abi_version_3_17=$((3<<$MAJOR_SHIFT | 17<<$MINOR_SHIFT))
abi_version_3_17_or_greater=$(($abi_version >= $abi_version_3_17))

cat $2
printf "Object.manifest.\"sof_manifest\" {\n"
printf "\tdata.\"sof_manifest\" {\n"
printf "\t\tbytes\t\"0x%02x," $MAJOR
printf "0x%02x," $MINOR
printf "0x%02x\"\n" $PATCH
printf "\t}\n"
printf "}"
27 changes: 27 additions & 0 deletions tools/topology2/include/common/connection.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Class.Custom."connection" {

@args."type" {
Copy link
Member Author

Choose a reason for hiding this comment

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

I would also have a doxygen comment for arg too.

type "string"
}

@args."pipeline_id" {
type "integer"
}

@args."index" {
type "integer"
}

DefineAttribute."source" {}

DefineAttribute."sink" {}

DefineAttribute."control" {}

attributes {
mandatory [
"source"
"sink"
]
}
}
8 changes: 8 additions & 0 deletions tools/topology2/include/common/data.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Class.Base."data" {

@args."name" {
type "string"
}

DefineAttribute."bytes" {}
}
33 changes: 33 additions & 0 deletions tools/topology2/include/common/endpoint.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Class.Base."endpoint" {

# sink/source
@args."type" {
type "string"
constraints {
values [
"sink"
"source"
]
}
}

@args."class_name" {
type "string"
}

@args."id" {
type "integer"
}

@args."index" {
type "integer"
}

DefineAttribute."widget" {}

attributes {
mandatory [
"widget"
]
}
Copy link
Member Author

Choose a reason for hiding this comment

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

will need some comment in bases classes describing the attributes

}
5 changes: 5 additions & 0 deletions tools/topology2/include/common/manifest.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class.Base."manifest" {
@args."name" {
type "string"
}
}
37 changes: 37 additions & 0 deletions tools/topology2/include/common/pcm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Class.PCM."pcm" {
#
# Argument used to construct PCM
#
@args."pcm_name" {
type "string"
}

@args."direction" {
type "string"
}

@args."pcm_id" {
type "integer"
}

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"
]
}

# Default values for PCM attributes
compress "false"
}
71 changes: 71 additions & 0 deletions tools/topology2/include/common/pcm_caps.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Class.PCM."pcm_caps" {
#
# Argument used to construct PCM Capabilities
#
@args."pcm_name" {
type "string"
}

@args."direction" {
type "string"
}

@args."pcm_id" {
type "integer"
}

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 {}
Copy link
Member Author

Choose a reason for hiding this comment

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

These and all other attributes should all have default values. This way it's easy to grep for the value and change the default.


attributes {
mandatory [
"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"
]
}

# 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
}
Loading