From c5ef0e3c65aacf85b1940e3730398bf490461fb6 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 29 Oct 2024 18:53:20 +0200 Subject: [PATCH] Audio: DRC: Use audio_stream_copy() with pass-through configuration The configuration blob is checked in drc_prepare(). If the blob does not have params.enable set, then it is safe to switch to a more efficient buffer copy function that bypasses the internal DRC lookup delay with channels de-interleave and interleave operations. The enable in the blob is a master switch for DRC. With such configuration in the blob the switch control from user space can't switch the processing on. Therefore it is safe to change the processing function. This change minimizes the MCPS overhead of unused DRC and reduces audio latency. If a new blob is received during streaming, the params.enable is checked again and the processing function is set again if the pass-through copy mode was in use. If the new blob has enable false, then the processing is changed to pass-through mode. The pass-through blob configuration is useful when the same pipeline is used for both headphone and speaker, where DRC is usually disabled for headphone mode. This change saves in hda-generic topologies with the default blob about 1.2 MCPS in TGL platform. Signed-off-by: Seppo Ingalsuo --- src/audio/drc/drc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/audio/drc/drc.c b/src/audio/drc/drc.c index 5543de987456..af29dfaefa78 100644 --- a/src/audio/drc/drc.c +++ b/src/audio/drc/drc.c @@ -278,6 +278,18 @@ static int drc_process(struct processing_module *mod, comp_err(dev, "drc_copy(), failed DRC setup"); return ret; } + + /* If new configuration blob is received in pass-through mode, and it + * has params.enabled true, then find the DRC processing function. + */ + if (cd->drc_func == drc_default_pass && cd->config->params.enabled) + cd->drc_func = drc_find_proc_func(cd->source_format); + + /* If new configuration blob has params.enabled false, then it is safe + * to switch to pass-through mode. + */ + if (!cd->config->params.enabled) + cd->drc_func = drc_default_pass; } /* Control pass-though in processing function with switch control */ @@ -351,6 +363,15 @@ static int drc_prepare(struct processing_module *mod, comp_err(dev, "drc_prepare(), No proc func"); return -EINVAL; } + + /* Params.enabled in the configuration blob is the master switch of DRC. + * The enable switch control does not have impact if this is not set to + * true. When false it is safe to use fast pass-through copy. A + * non-enabled blob can be used when same pipeline is used for both + * headphone and speaker where DRC should be off for headphone mode. + */ + if (!cd->config->params.enabled) + cd->drc_func = drc_default_pass; } else { /* Generic function for all formats */ cd->drc_func = drc_default_pass;