From 707c0c5bcebbf10b289c0bdaa6bd628ccab7ce75 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 6 Sep 2024 13:51:27 +0300 Subject: [PATCH] Tools: Topology2: Add beamformer and DRC to HDA analog capture This patch adds to analog microphone capture pipeline TDFB beamformer and DRC for dynamic range control. The enhanced host copier pipeline is enabled if HDA_MIC_ENHANCED_CAPTURE is set to true in topologies build. The keys EFX_HDA_MIC_TDFB_PARAMS and EFX_HDA_MIC_DRC_PARAMS control the applied configurations blobs. There is no processing applied to capture audio since the topology is built with pass-through blobs. E.g. UCM2 should set up processing with blobs those have effect. The change impacts sof-hda-generic.tplg. The other topologies with DMIC are kept as before without added processing. The analog capture pipelines are before this change: dai-copier -> eqiir -> module-copier -> host-copier After: dai-copier -> eqiir -> module-copier -> TDFB -> DRC -> host-copier Signed-off-by: Seppo Ingalsuo --- .../topology2/cavs-mixin-mixout-hda.conf | 119 +++++++++++++++++- .../production/tplg-targets-hda-generic.cmake | 4 +- 2 files changed, 118 insertions(+), 5 deletions(-) diff --git a/tools/topology/topology2/cavs-mixin-mixout-hda.conf b/tools/topology/topology2/cavs-mixin-mixout-hda.conf index 7672230d5aaf..83742186fb8b 100644 --- a/tools/topology/topology2/cavs-mixin-mixout-hda.conf +++ b/tools/topology/topology2/cavs-mixin-mixout-hda.conf @@ -1,3 +1,5 @@ + + Define { ANALOG_PLAYBACK_PCM 'Analog Playback' ANALOG_CAPTURE_PCM 'Analog Capture' @@ -12,6 +14,7 @@ Define { EFX_FIR_PARAMS 'passthrough' EFX_IIR_PARAMS 'passthrough' EFX_DRC_PARAMS 'passthrough' + HDA_MIC_ENHANCED_CAPTURE 'false' } # include deep buffer config if buffer size is in 1 - 1000 ms. @@ -270,6 +273,91 @@ Object.Pipeline { } ] } + +IncludeByKey.HDA_MIC_ENHANCED_CAPTURE { + "true" { + Object.Widget.tdfb.1 { + index 3 + Object.Control { + bytes."1" { + name 'Analog Capture TDFB bytes' + max 16384 + IncludeByKey.EFX_HDA_MIC_TDFB_PARAMS { + "line2_pass" "include/components/tdfb/line2_pass.conf" + "line2_generic_pm10deg" "include/components/tdfb/line2_generic_pm10deg_48khz.conf" + "line2_50mm" "include/components/tdfb/line2_50mm_pm0_30_90deg_48khz.conf" + "line2_68mm" "include/components/tdfb/line2_68mm_pm0_30_90deg_48khz.conf" + "line2_74mm" "include/components/tdfb/line2_74mm_pm0_30_90deg_48khz.conf" + } + } + mixer."1" { + name 'Analog Capture TDFB beam switch' + } + enum."1" { + name 'Analog Capture TDFB angle set enum' + } + # Tracking is disabled from this topology, causes high MCPS + #mixer."2" { + # name 'Analog Capture TDFB track switch' + #} + #enum."2" { + # name 'Analog Capture TDFB angle estimate enum' + #} + } + num_input_audio_formats 1 + Object.Base.input_audio_format [ + { + in_rate $HDA_ANALOG_CAPTURE_RATE + in_channels 2 + in_bit_depth 32 + in_valid_bit_depth 32 + } + ] + num_output_audio_formats 1 + Object.Base.output_audio_format [ + { + out_channels 2 + out_rate $HDA_ANALOG_CAPTURE_RATE + out_bit_depth 32 + out_valid_bit_depth 32 + } + ] + } + + Object.Widget.drc.1 { + index 3 + Object.Control { + bytes."1" { + name 'Analog Capture DRC bytes' + IncludeByKey.EFX_HDA_MIC_DRC_PARAMS { + "passthrough" "include/components/drc/passthrough.conf" + "amic_default" "include/components/drc/amic_default.conf" + } + } + mixer."1" { + name 'Analog Capture DRC switch' + } + } + num_input_audio_formats 1 + Object.Base.input_audio_format [ + { + in_rate $HDA_ANALOG_CAPTURE_RATE + in_bit_depth 32 + in_valid_bit_depth 32 + } + ] + num_output_audio_formats 1 + Object.Base.output_audio_format [ + { + out_rate $HDA_ANALOG_CAPTURE_RATE + out_bit_depth 32 + out_valid_bit_depth 32 + } + ] + } + } +} + Object.PCM.pcm [ { id 0 @@ -309,12 +397,35 @@ Object.Base.route [ source 'dai-copier.HDA.$HDA_ANALOG_DAI_NAME.capture' sink 'eqiir.4.1' } - { - source 'module-copier.4.2' - sink 'host-copier.0.capture' - } { source 'host-copier.0.playback' sink 'gain.1.1' } ] + +IncludeByKey.HDA_MIC_ENHANCED_CAPTURE { + "true" { + Object.Base.route [ + { + source 'module-copier.4.2' + sink 'tdfb.3.1' + } + { + source 'tdfb.3.1' + sink 'drc.3.1' + } + { + source 'drc.3.1' + sink 'host-copier.0.capture' + } + ] + } + "false" { + Object.Base.route [ + { + source 'module-copier.4.2' + sink 'host-copier.0.capture' + } + ] + } +} diff --git a/tools/topology/topology2/production/tplg-targets-hda-generic.cmake b/tools/topology/topology2/production/tplg-targets-hda-generic.cmake index 484f57fa08ad..ce0c455e1998 100644 --- a/tools/topology/topology2/production/tplg-targets-hda-generic.cmake +++ b/tools/topology/topology2/production/tplg-targets-hda-generic.cmake @@ -6,7 +6,9 @@ list(APPEND TPLGS "sof-hda-generic\;sof-hda-generic-idisp\;" # HDA topology with mixer-based pipelines for HDA and # passthrough pipelines for HDMI -"sof-hda-generic\;sof-hda-generic\;HDA_CONFIG=mix" +"sof-hda-generic\;sof-hda-generic\;HDA_CONFIG=mix,HDA_MIC_ENHANCED_CAPTURE=true,\ +EFX_HDA_MIC_TDFB_PARAMS=line2_pass,EFX_HDA_MIC_DRC_PARAMS=passthrough" + # HDA topology with mixer-based pipelines for HDA and # passthrough pipelines for HDMI and # 2 or 4 DMIC, no NHLT blob included in topology