topology2: introduction to topology2.0 by lgirdwood · Pull Request #3211 · thesofproject/sof · GitHub
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
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Loading