From a2e01942a59cbcae0586647d541a705e021420fd Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Mon, 13 Jun 2022 13:20:44 +0800 Subject: [PATCH 1/5] topology2: add support for sampling rate The original calculation will generate 44 sample size for 44.1khz, actually it at least needs 45 sample size. This patch uses ceil value for such rate, also inlcude 11.025kh, 22.05kh, 88.2khz, 176.4khz. Signed-off-by: Rander Wang --- tools/topology/topology2/include/common/audio_format.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/topology/topology2/include/common/audio_format.conf b/tools/topology/topology2/include/common/audio_format.conf index 9ce8e35cb410..7fc3f0e70aed 100644 --- a/tools/topology/topology2/include/common/audio_format.conf +++ b/tools/topology/topology2/include/common/audio_format.conf @@ -232,6 +232,7 @@ Class.Base."audio_format" { out_fmt_cfg "$[($out_channels | ($out_valid_bit_depth * 256)) | ($out_sample_type * 65536)]" # math expression for computing input/put buffer sizes - ibs "$[($in_channels * ($in_rate / 1000)) * ($in_bit_depth / 8)]" - obs "$[($out_channels * ($out_rate / 1000)) * ($out_bit_depth / 8)]" + # for 11.025 22.05, 44.1, 88.2 and 176.4khz, we need to round it to ceiling value + ibs "$[($in_channels * ($[($in_rate + 999)] / 1000)) * ($in_bit_depth / 8)]" + obs "$[($out_channels * ($[($out_rate + 999)] / 1000)) * ($out_bit_depth / 8)]" } From 690c4d0c1488f706fbafb468a5ad7753e4e1b9e5 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Mon, 13 Jun 2022 14:48:31 +0800 Subject: [PATCH 2/5] topology2: add cavs src support Cavs src is different with sof src. It has different uuid and param which are composed of base module definition and output rate. Signed-off-by: Rander Wang --- .../include/components/cavs/src.conf | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tools/topology/topology2/include/components/cavs/src.conf diff --git a/tools/topology/topology2/include/components/cavs/src.conf b/tools/topology/topology2/include/components/cavs/src.conf new file mode 100644 index 000000000000..d1333b8ed7f8 --- /dev/null +++ b/tools/topology/topology2/include/components/cavs/src.conf @@ -0,0 +1,96 @@ +# +# +# A generic src component. All attributes defined herein are namespaced +# by alsatplg to "Object.Widget.src.N.attribute_name" +# +# Usage: this component can be used by instantiating it in the parent object. i.e. +# +# Object.Widget.src."N" { +# period_sink_count 2 +# period_source_count 2 +# format "s24le" +# rate_out 48000 +# } +# +# Where N is the unique instance number for the src widget within the same alsaconf node. + +Class.Widget."src" { + # + # Pipeline ID for the src widget object + # + DefineAttribute."index" {} + + # + # object instance + # + DefineAttribute."instance" {} + + #include common component definition + + + # + # widget UUID + # + DefineAttribute."uuid" { + type "string" + # Token set reference name and type + token_ref "sof_tkn_comp.uuid" + } + + # + # Bespoke attributes + # + + # Target sample rate + DefineAttribute."rate_out" { + # Token set reference name and type + token_ref "sof_tkn_src.word" + } + + DefineAttribute."num_audio_formats" { + # Token set reference name and type + token_ref "sof_tkn_comp.word" + } + + attributes { + # + # The widget name would be constructed using the index and instance attributes. + # For ex: "src.1.1" or "src.10.2" etc. + # + !constructor [ + "index" + "instance" + ] + + !mandatory [ + "rate_out" + ] + + # + # immutable attributes cannot be modified in the object instance + # + !immutable [ + "uuid" + "type" + ] + + # + # deprecated attributes should not be added in the object instance + # + !deprecated [ + "preload_count" + ] + + unique "instance" + } + + # + # Default attributes + # + type "src" + # E61BB28D-149A-4C1F-B709-46823EF5F5AE + uuid "8d:b2:1b:e6:9a:14:1f:4c:b7:09:46:82:3e:f5:f5:ae" + no_pm "true" + + rate_out 48000 +} From 2af0d94b6a5db0c4a373ce8f0e8315cddf412543 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Mon, 13 Jun 2022 14:54:40 +0800 Subject: [PATCH 3/5] topology2: add pipeline for src This pipeline supports conversion from 8k ~ 192k to 48k. Signed-off-by: Rander Wang --- .../include/components/cavs/src_format.conf | 368 +++++++++++++++ .../cavs/src_passthrough_format.conf | 436 ++++++++++++++++++ .../cavs/src-gain-mixin-playback.conf | 117 +++++ 3 files changed, 921 insertions(+) create mode 100644 tools/topology/topology2/include/components/cavs/src_format.conf create mode 100644 tools/topology/topology2/include/components/cavs/src_passthrough_format.conf create mode 100644 tools/topology/topology2/include/pipelines/cavs/src-gain-mixin-playback.conf diff --git a/tools/topology/topology2/include/components/cavs/src_format.conf b/tools/topology/topology2/include/components/cavs/src_format.conf new file mode 100644 index 000000000000..5522b246b3c3 --- /dev/null +++ b/tools/topology/topology2/include/components/cavs/src_format.conf @@ -0,0 +1,368 @@ +#src format array + num_audio_formats 42 + + # 8khz input + Object.Base.audio_format.1 { + in_rate 8000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.2 { + in_rate 8000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.3{ + in_rate 8000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + + # 11.025 khz input + Object.Base.audio_format.4 { + in_rate 11025 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + # for 11.025k, 22.05k, 44.1k, 88.2k and 176.4k, extra 4 sample size is needed + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.5 { + in_rate 11025 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.6{ + in_rate 11025 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + # 12khz input + Object.Base.audio_format.7 { + in_rate 12000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.8 { + in_rate 12000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.9{ + in_rate 12000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + + # 16khz input + Object.Base.audio_format.10 { + in_rate 16000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.11 { + in_rate 16000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.12{ + in_rate 16000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + + # 22.05khz input + Object.Base.audio_format.13 { + in_rate 22050 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.14 { + in_rate 22050 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.15{ + in_rate 22050 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + + # 24khz input + Object.Base.audio_format.16 { + in_rate 24000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.17 { + in_rate 24000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.18{ + in_rate 24000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + + # 32khz input + Object.Base.audio_format.19 { + in_rate 32000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.20 { + in_rate 32000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.21 { + in_rate 32000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + + # 44.1khz input + Object.Base.audio_format.22 { + in_rate 44100 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.23 { + in_rate 44100 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.24{ + in_rate 44100 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + # 48khz input + Object.Base.audio_format.25 { + in_rate 48000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.26 { + in_rate 48000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.27 { + in_rate 48000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + + # 64khz input + Object.Base.audio_format.28 { + in_rate 64000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.29 { + in_rate 64000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.30 { + in_rate 64000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + # 88.2khz input + Object.Base.audio_format.31 { + in_rate 88200 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.32 { + in_rate 88200 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.33 { + in_rate 88200 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + # 96khz input + Object.Base.audio_format.34 { + in_rate 96000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.35 { + in_rate 96000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.36 { + in_rate 96000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + + # 176.4khz input + Object.Base.audio_format.37 { + in_rate 176400 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.38 { + in_rate 176400 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + Object.Base.audio_format.39 { + in_rate 176400 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + obs "$[($out_channels * (($[($out_rate + 999)] / 1000) + 4)) * ($out_bit_depth / 8)]" + } + + # 192khz input + Object.Base.audio_format.40 { + in_rate 192000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.41 { + in_rate 192000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.42 { + in_rate 192000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } diff --git a/tools/topology/topology2/include/components/cavs/src_passthrough_format.conf b/tools/topology/topology2/include/components/cavs/src_passthrough_format.conf new file mode 100644 index 000000000000..cc553610bb65 --- /dev/null +++ b/tools/topology/topology2/include/components/cavs/src_passthrough_format.conf @@ -0,0 +1,436 @@ +#src format array + num_audio_formats 42 + + # 8khz input + Object.Base.audio_format.1 { + in_rate 8000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 8000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.2 { + in_rate 8000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 8000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.3{ + in_rate 8000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 8000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 11.025 khz input + Object.Base.audio_format.4 { + in_rate 11025 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 11025 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.5 { + in_rate 11025 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 11025 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.6{ + in_rate 11025 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 11025 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 12khz input + Object.Base.audio_format.7 { + in_rate 12000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 12000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.8 { + in_rate 12000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 12000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.9{ + in_rate 12000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 12000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 16khz input + Object.Base.audio_format.10 { + in_rate 16000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 16000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.11 { + in_rate 16000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 16000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.12{ + in_rate 16000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 16000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 22.05khz input + Object.Base.audio_format.13 { + in_rate 22050 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 22050 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.14 { + in_rate 22050 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 22050 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.15{ + in_rate 22050 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 22050 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + + # 24khz input + Object.Base.audio_format.16 { + in_rate 24000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 24000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.17 { + in_rate 24000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 24000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.18{ + in_rate 24000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 24000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 32khz input + Object.Base.audio_format.19 { + in_rate 32000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 32000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.20 { + in_rate 32000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 32000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.21 { + in_rate 32000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 32000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 44.1khz input + Object.Base.audio_format.22 { + in_rate 44100 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 44100 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.23 { + in_rate 44100 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 44100 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.24{ + in_rate 44100 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 44100 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 48khz input + Object.Base.audio_format.25 { + in_rate 48000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 48000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.26 { + in_rate 48000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 48000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.27 { + in_rate 48000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 48000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 64khz input + Object.Base.audio_format.28 { + in_rate 64000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 64000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.29 { + in_rate 64000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 64000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.30 { + in_rate 64000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 64000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + # 88.2khz input + Object.Base.audio_format.31 { + in_rate 88200 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 88200 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.32 { + in_rate 88200 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 88200 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.33 { + in_rate 88200 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 88200 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 96khz input + Object.Base.audio_format.34 { + in_rate 96000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 96000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.35 { + in_rate 96000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 96000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.36 { + in_rate 96000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 96000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 176.4khz input + Object.Base.audio_format.37 { + in_rate 176400 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 176400 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.38 { + in_rate 176400 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 176400 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.39 { + in_rate 176400 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 176400 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } + + # 192khz input + Object.Base.audio_format.40 { + in_rate 192000 + in_bit_depth 16 + in_valid_bit_depth 16 + out_rate 192000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.41 { + in_rate 192000 + in_bit_depth 32 + in_valid_bit_depth 24 + out_rate 192000 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.42 { + in_rate 192000 + in_bit_depth 32 + in_valid_bit_depth 32 + out_rate 192000 + out_bit_depth 32 + out_valid_bit_depth 32 + dma_buffer_size "$[$obs * 2]" + } diff --git a/tools/topology/topology2/include/pipelines/cavs/src-gain-mixin-playback.conf b/tools/topology/topology2/include/pipelines/cavs/src-gain-mixin-playback.conf new file mode 100644 index 000000000000..afc656d61eff --- /dev/null +++ b/tools/topology/topology2/include/pipelines/cavs/src-gain-mixin-playback.conf @@ -0,0 +1,117 @@ +# +# src gain (volume) playback pipeline +# +# All attributes defined herein are namespaced +# by alsatplg to "Object.Pipeline.src-gain-mixin-playback.N.attribute_name" +# +# Usage: src-gain-mixin-playback pipeline object can be instantiated as: +# +# Object.Pipeline.src-gain-mixin-playback."N" { +# format "s16le" +# period 1000 +# time_domain "timer" +# channels 2 +# rate 48000 +# } +# +# Where N is the unique pipeline ID within the same alsaconf node. +# + + + + + + + + +Class.Pipeline."src-gain-mixin-playback" { + + DefineAttribute."index" {} + + + + attributes { + !constructor [ + "index" + ] + + !mandatory [ + "format" + ] + + !immutable [ + "direction" + ] + + unique "instance" + } + + Object.Widget { + copier."1" { + copier_type "host" + type "aif_in" + + + + node_type $HDA_HOST_OUTPUT_CLASS + } + + src."1" { + + } + + gain."1" { + num_audio_formats 3 + #16-bit 48KHz 2ch + Object.Base.audio_format.1 {} + + Object.Base.audio_format.2 { + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.3 { + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 + } + } + + mixin."1" { } + + pipeline."1" { + priority 0 + lp_mode 0 + } + } + + Object.Base { + route."1" { + source "copier.host..1" + sink "src..1" + } + + route."2" { + source "src..1" + sink "gain..1" + } + + route."3" { + source "gain..1" + sink "mixin..1" + } + } + + direction "playback" + dynamic_pipeline 1 + time_domain "timer" + channels 2 + channels_min 2 + channels_max 2 + rate 48000 + rate_min 8000 + rate_max 192000 +} From a1d1292e7ad34079716d873ba28c0be414ff2f89 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Wed, 15 Jun 2022 17:15:24 +0800 Subject: [PATCH 4/5] topology2: add src support on sdw platform Signed-off-by: Rander Wang --- tools/topology/topology2/cavs/CMakeLists.txt | 4 + .../cavs/cavs-sdw-src-gain-mixin.conf | 181 ++++++++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 tools/topology/topology2/cavs/cavs-sdw-src-gain-mixin.conf diff --git a/tools/topology/topology2/cavs/CMakeLists.txt b/tools/topology/topology2/cavs/CMakeLists.txt index 9caab688063b..2fb2ee3a06ff 100644 --- a/tools/topology/topology2/cavs/CMakeLists.txt +++ b/tools/topology/topology2/cavs/CMakeLists.txt @@ -25,6 +25,10 @@ PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt.bin" # CAVS SDW topology with passthrough pipelines "cavs-sdw\;cavs-sdw" + +# CAVS SDW with SRC gain and mixer support +"cavs-sdw-src-gain-mixin\;cavs-sdw-src-gain-mixin" + # CAVS SSP topology for TGL "cavs-nocodec\;cavs-tgl-nocodec\;NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,\ PREPROCESS_PLUGINS=nhlt,NHLT_BIN=nhlt-cavs-tgl-nocodec.bin" diff --git a/tools/topology/topology2/cavs/cavs-sdw-src-gain-mixin.conf b/tools/topology/topology2/cavs/cavs-sdw-src-gain-mixin.conf new file mode 100644 index 000000000000..f37daf7ffa7e --- /dev/null +++ b/tools/topology/topology2/cavs/cavs-sdw-src-gain-mixin.conf @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Define { + SDW_PLAYBACK_PCM 'SDW0-Playback' + SDW_CAPTURE_PCM 'SDW0-Capture' + PLAYBACK_LINK_ID 0 + CAPTURE_LINK_ID 1 +} + +# +# List of all DAIs +# +#ALH Index: 0, Direction: duplex +Object.Dai { + ALH."2" { + id $PLAYBACK_LINK_ID + direction "playback" + name $SDW_PLAYBACK_PCM + default_hw_conf_id 0 + rate 48000 + channels 2 + + Object.Base.hw_config."ALH2" { + id 0 + } + } + ALH."3" { + id $CAPTURE_LINK_ID + direction "capture" + name $SDW_CAPTURE_PCM + default_hw_conf_id 1 + rate 48000 + channels 2 + + Object.Base.hw_config."ALH3" { + id 1 + } + } +} + +# +# Pipeline definitions +# + +# Pipeline ID:1 PCM ID: 0 +Object.Pipeline { + src-gain-mixin-playback."1" { + format "s16le" + index 1 + + Object.Widget.copier.1.stream_name "Gain Playback 0" + Object.Widget.gain.1{ + Object.Control.mixer.1 { + name 'Src Playback Volume' + } + } + + } + mixout-gain-dai-copier-playback."3" { + index 2 + + Object.Widget.pipeline.1 { + stream_name 'copier.ALH.2.1' + } + Object.Widget.copier.1 { + stream_name $SDW_PLAYBACK_PCM + dai_type "ALH" + copier_type "ALH" + type "dai_in" + node_type $ALH_LINK_OUTPUT_CLASS + } + + Object.Widget.gain.1 { + Object.Control.mixer.1 { + name 'Main Playback Volume' + } + } + + format s16le + } + + passthrough-capture."4" { + format "s16le" + index 4 + + Object.Widget.copier.1.stream_name "Passthrough Capture 0" + Object.Widget.copier.1.Object.Base.audio_format.1 { + # 32 -> 16 bits conversion is done here, + # so in_bit_depth is 32 (and out_bit_depth is 16). + in_bit_depth 32 + } + } + passthrough-be.2 { + direction "capture" + index 3 + copier_type "ALH" + Object.Widget.pipeline.1 { + stream_name 'copier.ALH.3.1' + } + Object.Widget.copier.1 { + stream_name $SDW_CAPTURE_PCM + dai_type "ALH" + copier_type "ALH" + type "dai_out" + node_type $ALH_LINK_INPUT_CLASS + } + format s16le + } +} + +Object.PCM { + pcm."0" { + name "Jack out" + id 0 + direction "playback" + Object.Base.fe_dai."Jack out" {} + + Object.PCM.pcm_caps."playback" { + name "Gain Playback 0" + formats 'S16_LE,S32_LE' + rate_min 16000 + rate_max 48000 + } + } + pcm."1" { + name "Jack in" + id 1 + direction "capture" + Object.Base.fe_dai."Jack in" {} + + Object.PCM.pcm_caps."capture" { + name "Passthrough Capture 0" + formats 'S16_LE,S32_LE' + } + } +} + +Object.Base { + route."1" { + source "mixin.1.1" + sink "mixout.2.1" + } + + route."2" { + source 'gain.2.1' + sink 'copier.ALH.2.1' + } + + route."3" { + source "copier.ALH.3.1" + sink "copier.host.4.1" + } +} From c659e92d8377fb685b283ee0532531b8cc67379b Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Wed, 15 Jun 2022 14:04:50 +0800 Subject: [PATCH 5/5] topology2: add S24LE support S24LE is the major format used by SOF IPC4 FW and windows platform and has better perfomance than S32. Signed-off-by: Rander Wang --- .../topology2/include/components/gain.conf | 1 - .../topology2/include/components/mixin.conf | 15 +++++++++---- .../topology2/include/components/mixout.conf | 15 +++++++++---- .../cavs/mixout-gain-dai-copier-playback.conf | 20 ++++++++++++++++- .../cavs/mixout-gain-host-copier-capture.conf | 22 +++++++++++++++++-- .../pipelines/cavs/passthrough-be.conf | 10 ++++++++- 6 files changed, 70 insertions(+), 13 deletions(-) diff --git a/tools/topology/topology2/include/components/gain.conf b/tools/topology/topology2/include/components/gain.conf index ec30b890a040..f64b6e79481e 100644 --- a/tools/topology/topology2/include/components/gain.conf +++ b/tools/topology/topology2/include/components/gain.conf @@ -154,5 +154,4 @@ Class.Widget."gain" { curve_type "linear" curve_duration 10 init_value 0x7fffffff - num_audio_formats 1 } diff --git a/tools/topology/topology2/include/components/mixin.conf b/tools/topology/topology2/include/components/mixin.conf index 91fd932d8d29..82dec1897783 100644 --- a/tools/topology/topology2/include/components/mixin.conf +++ b/tools/topology/topology2/include/components/mixin.conf @@ -97,14 +97,21 @@ Class.Widget."mixin" { unique "instance" } - # Only 32-bit format is supported by mixin - num_audio_formats 1 + # Only 32-bit depth format is supported by mixin + num_audio_formats 2 # 32-bit 48KHz 2ch Object.Base.audio_format.1 { in_bit_depth 32 - in_valid_bit_depth 32 + in_valid_bit_depth 24 out_bit_depth 32 - out_valid_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.2 { + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 } # diff --git a/tools/topology/topology2/include/components/mixout.conf b/tools/topology/topology2/include/components/mixout.conf index bb819d97ae6d..c4037021ed70 100644 --- a/tools/topology/topology2/include/components/mixout.conf +++ b/tools/topology/topology2/include/components/mixout.conf @@ -97,14 +97,21 @@ Class.Widget."mixout" { unique "instance" } - # Only 32-bit format is supported by mixout - num_audio_formats 1 + # Only 32-bit depth format is supported by mixout + num_audio_formats 2 # 32-bit 48KHz 2ch Object.Base.audio_format.1 { in_bit_depth 32 - in_valid_bit_depth 32 + in_valid_bit_depth 24 out_bit_depth 32 - out_valid_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.2 { + in_bit_depth 32 + in_valid_bit_depth 32 + out_bit_depth 32 + out_valid_bit_depth 32 } # diff --git a/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf b/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf index 3f9a88afe85c..30c54f32fa77 100644 --- a/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf +++ b/tools/topology/topology2/include/pipelines/cavs/mixout-gain-dai-copier-playback.conf @@ -56,9 +56,18 @@ Class.Pipeline."mixout-gain-dai-copier-playback" { node_type $HDA_LINK_OUTPUT_CLASS period_sink_count 0 period_source_count 2 - num_audio_formats 1 + num_audio_formats 2 + # copier only supports one format based on mixin/mixout requirements: 32-bit 48KHz 2ch Object.Base.audio_format.1 { + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + Object.Base.audio_format.2 { in_bit_depth 32 in_valid_bit_depth 32 out_bit_depth 32 @@ -67,8 +76,17 @@ Class.Pipeline."mixout-gain-dai-copier-playback" { } } gain."1" { + num_audio_formats 2 + # 32-bit 48KHz 2ch Object.Base.audio_format.1 { + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.2 { in_bit_depth 32 in_valid_bit_depth 32 out_bit_depth 32 diff --git a/tools/topology/topology2/include/pipelines/cavs/mixout-gain-host-copier-capture.conf b/tools/topology/topology2/include/pipelines/cavs/mixout-gain-host-copier-capture.conf index dfa9e837f11a..88ae79938844 100644 --- a/tools/topology/topology2/include/pipelines/cavs/mixout-gain-host-copier-capture.conf +++ b/tools/topology/topology2/include/pipelines/cavs/mixout-gain-host-copier-capture.conf @@ -56,7 +56,7 @@ Class.Pipeline."mixout-gain-host-copier-capture" { copier_type "host" type "aif_out" node_type $HDA_HOST_INPUT_CLASS - num_audio_formats 3 + num_audio_formats 4 # 16-bit 48KHz 2ch Object.Base.audio_format.1 { in_bit_depth 32 @@ -71,8 +71,17 @@ Class.Pipeline."mixout-gain-host-copier-capture" { out_valid_bit_depth 24 dma_buffer_size "$[$obs * 2]" } - # 32-bit 48KHz 2ch + Object.Base.audio_format.3 { + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + + # 32-bit 48KHz 2ch + Object.Base.audio_format.4 { in_bit_depth 32 in_valid_bit_depth 32 out_bit_depth 32 @@ -82,8 +91,17 @@ Class.Pipeline."mixout-gain-host-copier-capture" { } gain."1"{ + num_audio_formats 2 + # 32-bit 48KHz 2ch Object.Base.audio_format.1 { + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + } + + Object.Base.audio_format.2 { in_bit_depth 32 in_valid_bit_depth 32 out_bit_depth 32 diff --git a/tools/topology/topology2/include/pipelines/cavs/passthrough-be.conf b/tools/topology/topology2/include/pipelines/cavs/passthrough-be.conf index 3d3ef6a07c39..1d542eacce3f 100644 --- a/tools/topology/topology2/include/pipelines/cavs/passthrough-be.conf +++ b/tools/topology/topology2/include/pipelines/cavs/passthrough-be.conf @@ -48,8 +48,16 @@ Class.Pipeline."passthrough-be" { copier."1" { type dai_in node_type $HDA_LINK_OUTPUT_CLASS - num_audio_formats 2 + num_audio_formats 3 # 32-bit 48KHz 2ch + Object.Base.audio_format.3 { + in_bit_depth 32 + in_valid_bit_depth 24 + out_bit_depth 32 + out_valid_bit_depth 24 + dma_buffer_size "$[$obs * 2]" + } + Object.Base.audio_format.1 { in_bit_depth 32 in_valid_bit_depth 32