From d45e0360906a17dcd021842319d4ed7d485c975f Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 6 Nov 2023 17:23:06 +0200 Subject: [PATCH 1/2] Tools: Topology2: Add widget class RTNR This patch allows to build topologies to use the RTNR component. Two bytes control blobs are converted from topology1 to IPC4 format. Signed-off-by: Seppo Ingalsuo --- .../topology2/include/components/rtnr.conf | 86 +++++++++++++++++++ .../components/rtnr/default_bytes.conf | 13 +++ .../include/components/rtnr/default_data.conf | 9 ++ 3 files changed, 108 insertions(+) create mode 100644 tools/topology/topology2/include/components/rtnr.conf create mode 100644 tools/topology/topology2/include/components/rtnr/default_bytes.conf create mode 100644 tools/topology/topology2/include/components/rtnr/default_data.conf diff --git a/tools/topology/topology2/include/components/rtnr.conf b/tools/topology/topology2/include/components/rtnr.conf new file mode 100644 index 000000000000..995870995d61 --- /dev/null +++ b/tools/topology/topology2/include/components/rtnr.conf @@ -0,0 +1,86 @@ +# +# +# A generic RTNR component. All attributes defined herein are namespaced +# by alsatplg to "Object.Widget.rtnr.attribute_name" +# +# Usage: this component can be used by declaring in the parent object. i.e. +# +# Object.Widget.rtnr."N" { +# index 1 +# } +# } + +# +# Where M is pipeline ID and N is a unique integer in the parent object. + + + +Class.Widget."rtnr" { + # + # Pipeline ID + # + DefineAttribute."index" { + type "integer" + } + + # + # Unique instance for RTNR widget + # + DefineAttribute."instance" { + type "integer" + } + + # Include common widget attributes definition + + + attributes { + !constructor [ + "index" + "instance" + ] + !mandatory [ + "num_input_pins" + "num_output_pins" + "num_input_audio_formats" + "num_output_audio_formats" + ] + + !immutable [ + "uuid" + "type" + ] + !deprecated [ + "preload_count" + ] + unique "instance" + } + + + # RTNR widget switch control + Object.Control { + mixer."1" { + Object.Base.channel.1 { + name "fc" + shift 0 + } + Object.Base.ops.1 { + name "ctl" + info "volsw" + #259 binds the mixer control to switch get/put handlers + get 259 + put 259 + } + max 1 + } + } + + # + # Default attributes for rtnr + # + # 5c7ca334-e15d-11eb-ba80-0242ac130004 + uuid "34:a3:7c:5c:5d:e1:eb:11:ba:80:02:42:ac:13:00:04" + type "effect" + no_pm "true" + num_input_pins 1 + num_output_pins 1 +} diff --git a/tools/topology/topology2/include/components/rtnr/default_bytes.conf b/tools/topology/topology2/include/components/rtnr/default_bytes.conf new file mode 100644 index 000000000000..a9a83bd9c2ad --- /dev/null +++ b/tools/topology/topology2/include/components/rtnr/default_bytes.conf @@ -0,0 +1,13 @@ +# Copied and modified for IPC4 from RTNR bytes in +# tools/topology/topology1/sof/pipe-rtnr-google-rtc-audio-processing-capture.m4 +# param_id = 0 for SOF_RTNR_CONFIG +Object.Base.data."rtnr_bytes_config" { + bytes "0x53,0x4f,0x46,0x34,0x00,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x30,0x01,0x03, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x80,0xbb,0x00,0x00,0x00,0x00,0x00,0x00" +} diff --git a/tools/topology/topology2/include/components/rtnr/default_data.conf b/tools/topology/topology2/include/components/rtnr/default_data.conf new file mode 100644 index 000000000000..86b601c37971 --- /dev/null +++ b/tools/topology/topology2/include/components/rtnr/default_data.conf @@ -0,0 +1,9 @@ +# Copied and modified for IPC4 from RTNR data in +# tools/topology/topology1/sof/pipe-rtnr-google-rtc-audio-processing-capture.m4 +# param_id = 1 for SOF_RTNR_DATA +Object.Base.data."rtnr_data_config" { + bytes "0x53,0x4f,0x46,0x34,0x01,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x30,0x01,0x03, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00" +} From 2e67f7c88bfaf84eca84ea548cf9fb6bd8d903be Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 2 Nov 2023 17:28:14 +0200 Subject: [PATCH 2/2] Tools: Topology2: Add sof-hda-benchmark-rtnr16/24/32- This patch adds build of hda-generic development topologies to test RTNR component with all s16/s24/s32 formats. Signed-off-by: Seppo Ingalsuo --- .../topology2/cavs-benchmark-hda.conf | 17 ++++++++++++++ .../development/tplg-targets-bench.cmake | 2 ++ .../include/bench/rtnr_controls_capture.conf | 23 +++++++++++++++++++ .../include/bench/rtnr_controls_playback.conf | 23 +++++++++++++++++++ .../include/bench/rtnr_hda_route.conf | 19 +++++++++++++++ .../topology2/include/bench/rtnr_s16.conf | 13 +++++++++++ .../topology2/include/bench/rtnr_s24.conf | 13 +++++++++++ .../topology2/include/bench/rtnr_s32.conf | 13 +++++++++++ 8 files changed, 123 insertions(+) create mode 100644 tools/topology/topology2/include/bench/rtnr_controls_capture.conf create mode 100644 tools/topology/topology2/include/bench/rtnr_controls_playback.conf create mode 100644 tools/topology/topology2/include/bench/rtnr_hda_route.conf create mode 100644 tools/topology/topology2/include/bench/rtnr_s16.conf create mode 100644 tools/topology/topology2/include/bench/rtnr_s24.conf create mode 100644 tools/topology/topology2/include/bench/rtnr_s32.conf diff --git a/tools/topology/topology2/cavs-benchmark-hda.conf b/tools/topology/topology2/cavs-benchmark-hda.conf index aaa5c914e053..e532fce3088a 100644 --- a/tools/topology/topology2/cavs-benchmark-hda.conf +++ b/tools/topology/topology2/cavs-benchmark-hda.conf @@ -1,4 +1,5 @@ + Define { ANALOG_PLAYBACK_PCM 'Analog Playback' @@ -284,4 +285,20 @@ IncludeByKey.BENCH_CONFIG { "gain32" { } + + # + # RTNR component + # + + "rtnr16" { + + } + + "rtnr24" { + + } + + "rtnr32" { + + } } diff --git a/tools/topology/topology2/development/tplg-targets-bench.cmake b/tools/topology/topology2/development/tplg-targets-bench.cmake index 06ddbfa3b80e..f430ff9e586a 100644 --- a/tools/topology/topology2/development/tplg-targets-bench.cmake +++ b/tools/topology/topology2/development/tplg-targets-bench.cmake @@ -15,6 +15,7 @@ set(components "eqiir" "eqfir" "gain" + "rtnr" ) set(component_parameters @@ -24,6 +25,7 @@ set(component_parameters "BENCH_EQIIR_PARAMS=highpass_50hz_0db_48khz" "BENCH_EQFIR_PARAMS=loudness" "BENCH_GAIN_PARAMS=default" + "BENCH_RTNR_PARAMS=default" ) set(components_s32 diff --git a/tools/topology/topology2/include/bench/rtnr_controls_capture.conf b/tools/topology/topology2/include/bench/rtnr_controls_capture.conf new file mode 100644 index 000000000000..122f73674bc7 --- /dev/null +++ b/tools/topology/topology2/include/bench/rtnr_controls_capture.conf @@ -0,0 +1,23 @@ + # Created initially with script "./bench_comp_generate.sh rtnr" + # may need edits to modify controls + Object.Control { + # Un-comment the supported controls in RTNR + bytes."1" { + name '$ANALOG_CAPTURE_PCM RTNR bytes' + IncludeByKey.BENCH_RTNR_PARAMS { + "default" "include/components/rtnr/default_bytes.conf" + } + } + bytes."2" { + name '$ANALOG_CAPTURE_PCM RTNR data' + IncludeByKey.BENCH_RTNR_PARAMS { + "default" "include/components/rtnr/default_data.conf" + } + } + mixer."1" { + name '$ANALOG_CAPTURE_PCM RTNR enable' + } + #enum."1" { + # name '$ANALOG_CAPTURE_PCM RTNR enum' + #} + } diff --git a/tools/topology/topology2/include/bench/rtnr_controls_playback.conf b/tools/topology/topology2/include/bench/rtnr_controls_playback.conf new file mode 100644 index 000000000000..21280af41cea --- /dev/null +++ b/tools/topology/topology2/include/bench/rtnr_controls_playback.conf @@ -0,0 +1,23 @@ + # Created initially with script "./bench_comp_generate.sh rtnr" + # may need edits to modify controls + Object.Control { + # Un-comment the supported controls in RTNR + bytes."1" { + name '$ANALOG_PLAYBACK_PCM RTNR bytes' + IncludeByKey.BENCH_RTNR_PARAMS { + "default" "include/components/rtnr/default_bytes.conf" + } + } + bytes."2" { + name '$ANALOG_PLAYBACK_PCM RTNR data' + IncludeByKey.BENCH_RTNR_PARAMS { + "default" "include/components/rtnr/default_data.conf" + } + } + mixer."1" { + name '$ANALOG_PLAYBACK_PCM RTNR enable' + } + #enum."1" { + # name '$ANALOG_PLAYBACK_PCM RTNR enum' + #} + } diff --git a/tools/topology/topology2/include/bench/rtnr_hda_route.conf b/tools/topology/topology2/include/bench/rtnr_hda_route.conf new file mode 100644 index 000000000000..71f6de968f1b --- /dev/null +++ b/tools/topology/topology2/include/bench/rtnr_hda_route.conf @@ -0,0 +1,19 @@ + # Created with script "./bench_comp_generate.sh rtnr" + Object.Base.route [ + { + sink 'dai-copier.HDA.$HDA_ANALOG_DAI_NAME.playback' + source 'rtnr.1.1' + } + { + sink 'rtnr.1.1' + source 'host-copier.0.playback' + } + { + source 'dai-copier.HDA.$HDA_ANALOG_DAI_NAME.capture' + sink 'rtnr.3.2' + } + { + source 'rtnr.3.2' + sink 'host-copier.0.capture' + } + ] diff --git a/tools/topology/topology2/include/bench/rtnr_s16.conf b/tools/topology/topology2/include/bench/rtnr_s16.conf new file mode 100644 index 000000000000..94dd01873a18 --- /dev/null +++ b/tools/topology/topology2/include/bench/rtnr_s16.conf @@ -0,0 +1,13 @@ + # Created with script "./bench_comp_generate.sh rtnr" + Object.Widget.rtnr.1 { + index 1 + + + } + Object.Widget.rtnr.2 { + index 3 + + + } + + diff --git a/tools/topology/topology2/include/bench/rtnr_s24.conf b/tools/topology/topology2/include/bench/rtnr_s24.conf new file mode 100644 index 000000000000..1a1475ee02a1 --- /dev/null +++ b/tools/topology/topology2/include/bench/rtnr_s24.conf @@ -0,0 +1,13 @@ + # Created with script "./bench_comp_generate.sh rtnr" + Object.Widget.rtnr.1 { + index 1 + + + } + Object.Widget.rtnr.2 { + index 3 + + + } + + diff --git a/tools/topology/topology2/include/bench/rtnr_s32.conf b/tools/topology/topology2/include/bench/rtnr_s32.conf new file mode 100644 index 000000000000..b03d77b80b4a --- /dev/null +++ b/tools/topology/topology2/include/bench/rtnr_s32.conf @@ -0,0 +1,13 @@ + # Created with script "./bench_comp_generate.sh rtnr" + Object.Widget.rtnr.1 { + index 1 + + + } + Object.Widget.rtnr.2 { + index 3 + + + } + +