From daac448b27e423f5d2a8ea09f601f9129060cdab Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 3 Jun 2024 15:26:03 +0200 Subject: [PATCH] drc: enable building as an llext module Add support for LLEXT building to drc. Since multiband DRC calls functions from DRC, we cannot so far build it if DRC is configured as a module. In the future it should be possible to build both as modules and to export symbols between them. Signed-off-by: Guennadi Liakhovetski --- app/overlays/lnl/module_overlay.conf | 1 + app/overlays/mtl/module_overlay.conf | 1 + src/audio/drc/Kconfig | 2 +- src/audio/drc/drc.c | 19 +++++++++++++++++++ src/audio/drc/drc.toml | 6 +++++- src/audio/drc/llext/CMakeLists.txt | 11 +++++++++++ src/audio/drc/llext/llext.toml.h | 6 ++++++ src/audio/multiband_drc/Kconfig | 2 +- zephyr/CMakeLists.txt | 22 ++++++++++++++-------- 9 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 src/audio/drc/llext/CMakeLists.txt create mode 100644 src/audio/drc/llext/llext.toml.h diff --git a/app/overlays/lnl/module_overlay.conf b/app/overlays/lnl/module_overlay.conf index 5355932bf3da..fd351428f506 100644 --- a/app/overlays/lnl/module_overlay.conf +++ b/app/overlays/lnl/module_overlay.conf @@ -6,3 +6,4 @@ CONFIG_COMP_IIR=m CONFIG_COMP_FIR=m CONFIG_COMP_SRC=m CONFIG_COMP_ASRC=m +CONFIG_COMP_DRC=m diff --git a/app/overlays/mtl/module_overlay.conf b/app/overlays/mtl/module_overlay.conf index 5355932bf3da..fd351428f506 100644 --- a/app/overlays/mtl/module_overlay.conf +++ b/app/overlays/mtl/module_overlay.conf @@ -6,3 +6,4 @@ CONFIG_COMP_IIR=m CONFIG_COMP_FIR=m CONFIG_COMP_SRC=m CONFIG_COMP_ASRC=m +CONFIG_COMP_DRC=m diff --git a/src/audio/drc/Kconfig b/src/audio/drc/Kconfig index 9e6aaf6388ed..56e3c4d9e6fc 100644 --- a/src/audio/drc/Kconfig +++ b/src/audio/drc/Kconfig @@ -3,7 +3,7 @@ rsource "Kconfig.simd" config COMP_DRC - bool "Dynamic Range Compressor component" + tristate "Dynamic Range Compressor component" select CORDIC_FIXED select MATH_LUT_SINE_FIXED select NUMBERS_NORM diff --git a/src/audio/drc/drc.c b/src/audio/drc/drc.c index 7080fdea55f1..53c472bb16e5 100644 --- a/src/audio/drc/drc.c +++ b/src/audio/drc/drc.c @@ -389,3 +389,22 @@ static const struct module_interface drc_interface = { DECLARE_MODULE_ADAPTER(drc_interface, drc_uuid, drc_tr); SOF_MODULE_INIT(drc, sys_comp_module_drc_interface_init); + +#if CONFIG_COMP_DRC_MODULE +/* modular: llext dynamic link */ + +#include +#include +#include + +#define UUID_DRC 0xda, 0xe4, 0x6e, 0xb3, 0x6f, 0x00, 0xf9, 0x47, \ + 0xa0, 0x6d, 0xfe, 0xcb, 0xe2, 0xd8, 0xb6, 0xce + +SOF_LLEXT_MOD_ENTRY(drc, &drc_interface); + +static const struct sof_man_module_manifest mod_manifest __section(".module") __used = + SOF_LLEXT_MODULE_MANIFEST("DRC", drc_llext_entry, 1, UUID_DRC, 40); + +SOF_LLEXT_BUILDINFO; + +#endif diff --git a/src/audio/drc/drc.toml b/src/audio/drc/drc.toml index 29ee8d856cbb..4c0b25601425 100644 --- a/src/audio/drc/drc.toml +++ b/src/audio/drc/drc.toml @@ -1,3 +1,7 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + REM # DRC module config [[module.entry]] name = "DRC" @@ -5,7 +9,7 @@ affinity_mask = "0x1" instance_count = "40" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE module_type = "9" auto_start = "0" sched_caps = [1, 0x00008000] diff --git a/src/audio/drc/llext/CMakeLists.txt b/src/audio/drc/llext/CMakeLists.txt new file mode 100644 index 000000000000..29920d8c2a5d --- /dev/null +++ b/src/audio/drc/llext/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2024 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +sof_llext_build("drc" + SOURCES ../drc.c + ../drc_generic.c + ../drc_math_generic.c + ../drc_hifi3.c + ../drc_hifi4.c + ../drc_math_hifi3.c +) diff --git a/src/audio/drc/llext/llext.toml.h b/src/audio/drc/llext/llext.toml.h new file mode 100644 index 000000000000..89469d54fffb --- /dev/null +++ b/src/audio/drc/llext/llext.toml.h @@ -0,0 +1,6 @@ +#include +#define LOAD_TYPE "2" +#include "../drc.toml" + +[module] +count = __COUNTER__ diff --git a/src/audio/multiband_drc/Kconfig b/src/audio/multiband_drc/Kconfig index 175a6bf09c48..d9e61c915ccd 100644 --- a/src/audio/multiband_drc/Kconfig +++ b/src/audio/multiband_drc/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause config COMP_MULTIBAND_DRC - depends on COMP_IIR && COMP_CROSSOVER && COMP_DRC + depends on COMP_IIR && COMP_CROSSOVER && COMP_DRC = y bool "Multiband Dynamic Range Compressor component" select CORDIC_FIXED select COMP_BLOB diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index cd254314bbb5..63c788f4733b 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -796,14 +796,20 @@ zephyr_library_sources_ifdef(CONFIG_COMP_CROSSOVER ${SOF_AUDIO_PATH}/crossover/crossover_${ipc_suffix}.c ) -zephyr_library_sources_ifdef(CONFIG_COMP_DRC - ${SOF_AUDIO_PATH}/drc/drc.c - ${SOF_AUDIO_PATH}/drc/drc_generic.c - ${SOF_AUDIO_PATH}/drc/drc_math_generic.c - ${SOF_AUDIO_PATH}/drc/drc_hifi3.c - ${SOF_AUDIO_PATH}/drc/drc_hifi4.c - ${SOF_AUDIO_PATH}/drc/drc_math_hifi3.c -) +if(CONFIG_COMP_DRC STREQUAL "m") + add_subdirectory(${SOF_AUDIO_PATH}/drc/llext + ${PROJECT_BINARY_DIR}/drc_llext) + add_dependencies(app drc) +elseif(CONFIG_COMP_DRC) + zephyr_library_sources( + ${SOF_AUDIO_PATH}/drc/drc.c + ${SOF_AUDIO_PATH}/drc/drc_generic.c + ${SOF_AUDIO_PATH}/drc/drc_math_generic.c + ${SOF_AUDIO_PATH}/drc/drc_hifi3.c + ${SOF_AUDIO_PATH}/drc/drc_hifi4.c + ${SOF_AUDIO_PATH}/drc/drc_math_hifi3.c + ) +endif() zephyr_library_sources_ifdef(CONFIG_COMP_MULTIBAND_DRC ${SOF_AUDIO_PATH}/multiband_drc/multiband_drc.c