From 99e857a77a51571bf7a19635276cb7aa5d8154ae Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 2 Dec 2024 12:26:00 +0200 Subject: [PATCH] Tools: Topology2: Swap gain and eqiir in DMIC capture This patch swaps the order of IIR and gain components in capture pipeline. In IPC4 systems the gain component can only attenuate the signal, largest gain is 0 dB (pass-through). The IIR component can be set up to amplify the signal by e.g. +20 dB that is currently default in many topologies. The gain can possibly distort the signal in loud environment. With current "dai-copier -> eqiir -> gain -> module-copier" topology the user configurable gain (ALSA mixer control) can't prevent clipping of audio signal in IIR. While with swapped order "dai-copier -> gain -> eqiir -> module-copier" using attenuation in gain component can be used to prevent audio signal clipping in IIR. It would be useful in capturing audio in a very loud environment. Since the pipeline is 32-bits there is no practical loss of audio quality even if there would be first attenuation and then gain. Plus normally the gain control for Dmic0 is set to maximum. Signed-off-by: Seppo Ingalsuo --- tools/topology/topology2/cavs-nocodec.conf | 2 +- tools/topology/topology2/cavs-rt5682.conf | 2 +- tools/topology/topology2/cavs-sdw.conf | 2 +- ...pier-gain-eqiir-module-copier-capture.conf} | 18 +++++++++--------- .../topology2/platform/intel/dmic-generic.conf | 7 +++---- .../topology2/platform/intel/dmic1-mfcc.conf | 4 ++-- tools/topology/topology2/sof-hda-generic.conf | 2 +- 7 files changed, 18 insertions(+), 19 deletions(-) rename tools/topology/topology2/include/pipelines/cavs/{dai-copier-eqiir-gain-module-copier-capture.conf => dai-copier-gain-eqiir-module-copier-capture.conf} (89%) diff --git a/tools/topology/topology2/cavs-nocodec.conf b/tools/topology/topology2/cavs-nocodec.conf index 3bd733444f1b..4f66a8c08c9e 100644 --- a/tools/topology/topology2/cavs-nocodec.conf +++ b/tools/topology/topology2/cavs-nocodec.conf @@ -23,7 +23,7 @@ - + diff --git a/tools/topology/topology2/cavs-rt5682.conf b/tools/topology/topology2/cavs-rt5682.conf index 91462a8c762f..13612730599a 100644 --- a/tools/topology/topology2/cavs-rt5682.conf +++ b/tools/topology/topology2/cavs-rt5682.conf @@ -22,7 +22,7 @@ - + diff --git a/tools/topology/topology2/cavs-sdw.conf b/tools/topology/topology2/cavs-sdw.conf index 1a5fa32e95e8..d269afdbbd0b 100644 --- a/tools/topology/topology2/cavs-sdw.conf +++ b/tools/topology/topology2/cavs-sdw.conf @@ -14,7 +14,7 @@ - + diff --git a/tools/topology/topology2/include/pipelines/cavs/dai-copier-eqiir-gain-module-copier-capture.conf b/tools/topology/topology2/include/pipelines/cavs/dai-copier-gain-eqiir-module-copier-capture.conf similarity index 89% rename from tools/topology/topology2/include/pipelines/cavs/dai-copier-eqiir-gain-module-copier-capture.conf rename to tools/topology/topology2/include/pipelines/cavs/dai-copier-gain-eqiir-module-copier-capture.conf index 5bd1ad80446e..7c704065f580 100644 --- a/tools/topology/topology2/include/pipelines/cavs/dai-copier-eqiir-gain-module-copier-capture.conf +++ b/tools/topology/topology2/include/pipelines/cavs/dai-copier-gain-eqiir-module-copier-capture.conf @@ -1,12 +1,12 @@ # -# BE capture pipeline: dai-copier-eqiir-gain-module-copier-capture +# BE capture pipeline: dai-copier-gain-eqiir-module-copier-capture # # All attributes defined herein are namespaced -# by alsatplg to "Object.Pipeline.dai-copier-eqiir-gain-module-copier-capture.N.attribute_name" +# by alsatplg to "Object.Pipeline.dai-copier-gain-eqiir-module-copier-capture.N.attribute_name" # -# Usage: dai-copier-eqiir-gain-module-copier-capture pipeline object can be instantiated as: +# Usage: dai-copier-gain-eqiir-module-copier-capture pipeline object can be instantiated as: # -# Object.Pipeline.dai-copier-eqiir-gain-module-copier-capture."N" { +# Object.Pipeline.dai-copier-gain-eqiir-module-copier-capture."N" { # period 1000 # time_domain "timer" # } @@ -21,7 +21,7 @@ -Class.Pipeline."dai-copier-eqiir-gain-module-copier-capture" { +Class.Pipeline."dai-copier-gain-eqiir-module-copier-capture" { @@ -35,7 +35,7 @@ Class.Pipeline."dai-copier-eqiir-gain-module-copier-capture" { ] # - # dai-copier-eqiir-gain-module-copier-capture objects instantiated + # dai-copier-gain-eqiir-module-copier-capture objects instantiated # within the same alsaconf node must have unique pipeline_id # attribute # @@ -185,12 +185,12 @@ Class.Pipeline."dai-copier-eqiir-gain-module-copier-capture" { Object.Base { route.1 { - source gain.$index.1 + source eqiir.$index.1 sink module-copier.$index.2 } route.2 { - source eqiir.$index.1 - sink gain.$index.1 + source gain.$index.1 + sink eqiir.$index.1 } } diff --git a/tools/topology/topology2/platform/intel/dmic-generic.conf b/tools/topology/topology2/platform/intel/dmic-generic.conf index 4929fbab0687..2788722d476e 100644 --- a/tools/topology/topology2/platform/intel/dmic-generic.conf +++ b/tools/topology/topology2/platform/intel/dmic-generic.conf @@ -2,7 +2,6 @@ Define { DMIC0_PCM_NAME "DMIC Raw" } - # If DMIC0_PCM_CHANNELS is zero, copy it from NUM_DMICS. This # allows by setting both NUM_DMICS and DMIC0_PCM_CHANNELS to # have a different channels count in DAI and host. @@ -152,7 +151,7 @@ IncludeByKey.PASSTHROUGH { } ] - Object.Pipeline.dai-copier-eqiir-gain-module-copier-capture [ + Object.Pipeline.dai-copier-gain-eqiir-module-copier-capture [ { index $DMIC0_DAI_PIPELINE_ID core_id $DMIC_CORE_ID @@ -552,7 +551,7 @@ IncludeByKey.PASSTHROUGH { Object.Base.route [ { source $DMIC0_DAI_COPIER - sink eqiir.$DMIC0_DAI_PIPELINE_ID.1 + sink gain.$DMIC0_DAI_PIPELINE_ID.1 } { source $DMIC0_DAI_PIPELINE_SRC @@ -572,7 +571,7 @@ IncludeByKey.PASSTHROUGH { Object.Base.route [ { source $DMIC0_DAI_COPIER - sink eqiir.$DMIC0_DAI_PIPELINE_ID.1 + sink gain.$DMIC0_DAI_PIPELINE_ID.1 } { source $DMIC0_DAI_PIPELINE_SRC diff --git a/tools/topology/topology2/platform/intel/dmic1-mfcc.conf b/tools/topology/topology2/platform/intel/dmic1-mfcc.conf index e0c394cd7d05..27d59d6ae18b 100644 --- a/tools/topology/topology2/platform/intel/dmic1-mfcc.conf +++ b/tools/topology/topology2/platform/intel/dmic1-mfcc.conf @@ -60,7 +60,7 @@ Object.Pipeline.host-gateway-capture [ } ] -Object.Pipeline.dai-copier-eqiir-gain-module-copier-capture [ +Object.Pipeline.dai-copier-gain-eqiir-module-copier-capture [ { index $DMIC1_DAI_PIPELINE_ID core_id $DMIC_CORE_ID @@ -382,7 +382,7 @@ Object.Widget.mfcc.1 { Object.Base.route [ { source "dai-copier.DMIC.$DMIC1_NAME.capture" - sink "eqiir.$DMIC1_DAI_PIPELINE_ID.1" + sink "gain.$DMIC1_DAI_PIPELINE_ID.1" } { source module-copier.$DMIC1_DAI_PIPELINE_ID.2 diff --git a/tools/topology/topology2/sof-hda-generic.conf b/tools/topology/topology2/sof-hda-generic.conf index 503871d74b2d..ba8a0215009a 100644 --- a/tools/topology/topology2/sof-hda-generic.conf +++ b/tools/topology/topology2/sof-hda-generic.conf @@ -21,7 +21,7 @@ - +