From 27edbae2c83420d8ecd4a07affae7b29af657260 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 4 Jul 2024 12:48:07 +0200 Subject: [PATCH] tdfb: enable building as an llext module Add support for LLEXT building to tdfb. Signed-off-by: Guennadi Liakhovetski --- app/overlays/lnl/module_overlay.conf | 1 + app/overlays/mtl/module_overlay.conf | 1 + src/audio/tdfb/Kconfig | 3 ++- src/audio/tdfb/llext/CMakeLists.txt | 11 +++++++++++ src/audio/tdfb/llext/llext.toml.h | 6 ++++++ src/audio/tdfb/tdfb.c | 23 +++++++++++++++++++++-- src/audio/tdfb/tdfb.toml | 6 +++++- zephyr/CMakeLists.txt | 22 ++++++++++++++-------- 8 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 src/audio/tdfb/llext/CMakeLists.txt create mode 100644 src/audio/tdfb/llext/llext.toml.h diff --git a/app/overlays/lnl/module_overlay.conf b/app/overlays/lnl/module_overlay.conf index 7dd35cc66cf0..ff331e700b29 100644 --- a/app/overlays/lnl/module_overlay.conf +++ b/app/overlays/lnl/module_overlay.conf @@ -1,6 +1,7 @@ CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_MIXIN_MIXOUT=m +CONFIG_COMP_TDFB=m CONFIG_COMP_FIR=m CONFIG_COMP_IIR=m CONFIG_COMP_DRC=m diff --git a/app/overlays/mtl/module_overlay.conf b/app/overlays/mtl/module_overlay.conf index 7dd35cc66cf0..ff331e700b29 100644 --- a/app/overlays/mtl/module_overlay.conf +++ b/app/overlays/mtl/module_overlay.conf @@ -1,6 +1,7 @@ CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_MIXIN_MIXOUT=m +CONFIG_COMP_TDFB=m CONFIG_COMP_FIR=m CONFIG_COMP_IIR=m CONFIG_COMP_DRC=m diff --git a/src/audio/tdfb/Kconfig b/src/audio/tdfb/Kconfig index f30f8aa4fe8a..3a8cff21431a 100644 --- a/src/audio/tdfb/Kconfig +++ b/src/audio/tdfb/Kconfig @@ -1,13 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause config COMP_TDFB - bool "TDFB component" + tristate "TDFB component" depends on COMP_MODULE_ADAPTER select MATH_FIR select MATH_IIR_DF1 select SQRT_FIXED select CORDIC_FIXED select COMP_BLOB + default m if LIBRARY_DEFAULT_MODULAR default y help Select for time domain fixed beamformer (TDFB) component. The diff --git a/src/audio/tdfb/llext/CMakeLists.txt b/src/audio/tdfb/llext/CMakeLists.txt new file mode 100644 index 000000000000..3f9e301947dd --- /dev/null +++ b/src/audio/tdfb/llext/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) 2024 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +sof_llext_build("tdfb" + SOURCES ../tdfb.c + ../tdfb_direction.c + ../tdfb_generic.c + ../tdfb_hifiep.c + ../tdfb_hifi3.c + ../tdfb_ipc4.c +) diff --git a/src/audio/tdfb/llext/llext.toml.h b/src/audio/tdfb/llext/llext.toml.h new file mode 100644 index 000000000000..f5dbd89a4cc2 --- /dev/null +++ b/src/audio/tdfb/llext/llext.toml.h @@ -0,0 +1,6 @@ +#include +#define LOAD_TYPE "2" +#include "../tdfb.toml" + +[module] +count = __COUNTER__ diff --git a/src/audio/tdfb/tdfb.c b/src/audio/tdfb/tdfb.c index 128a39b19e1c..b45fd04773d5 100644 --- a/src/audio/tdfb/tdfb.c +++ b/src/audio/tdfb/tdfb.c @@ -613,7 +613,7 @@ static int tdfb_free(struct processing_module *mod) { struct tdfb_comp_data *cd = module_get_private_data(mod); - comp_info(mod->dev, "tdfb_free()"); + comp_dbg(mod->dev, "tdfb_free()"); ipc_msg_free(cd->msg); tdfb_free_delaylines(cd); @@ -797,7 +797,7 @@ static int tdfb_reset(struct processing_module *mod) struct tdfb_comp_data *cd = module_get_private_data(mod); int i; - comp_info(mod->dev, "tdfb_reset()"); + comp_dbg(mod->dev, "tdfb_reset()"); tdfb_free_delaylines(cd); @@ -824,3 +824,22 @@ static const struct module_interface tdfb_interface = { DECLARE_MODULE_ADAPTER(tdfb_interface, tdfb_uuid, tdfb_tr); SOF_MODULE_INIT(tdfb, sys_comp_module_tdfb_interface_init); + +#if CONFIG_COMP_TDFB_MODULE +/* modular: llext dynamic link */ + +#include +#include +#include + +#define UUID_TDFB 0x49, 0x17, 0x51, 0xdd, 0xfa, 0xd9, 0x5c, 0x45, 0xb3, 0xa7, \ + 0x13, 0x58, 0x56, 0x93, 0xf1, 0xaf + +SOF_LLEXT_MOD_ENTRY(tdfb, &tdfb_interface); + +static const struct sof_man_module_manifest mod_manifest __section(".module") __used = + SOF_LLEXT_MODULE_MANIFEST("TDFB", tdfb_llext_entry, 1, UUID_TDFB, 40); + +SOF_LLEXT_BUILDINFO; + +#endif diff --git a/src/audio/tdfb/tdfb.toml b/src/audio/tdfb/tdfb.toml index 4cabb78ae081..ee1f7ffaee31 100644 --- a/src/audio/tdfb/tdfb.toml +++ b/src/audio/tdfb/tdfb.toml @@ -1,3 +1,7 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + REM # TDFB module config [[module.entry]] name = "TDFB" @@ -5,7 +9,7 @@ affinity_mask = "0x1" instance_count = "40" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE init_config = "1" module_type = "9" auto_start = "0" diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 7f8d492d164f..4e1451f2d08b 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -937,14 +937,20 @@ zephyr_library_sources_ifdef(CONFIG_COMP_RTNR_STUB ${SOF_AUDIO_PATH}/rtnr/rtnr_stub.c ) -zephyr_library_sources_ifdef(CONFIG_COMP_TDFB - ${SOF_AUDIO_PATH}/tdfb/tdfb.c - ${SOF_AUDIO_PATH}/tdfb/tdfb_direction.c - ${SOF_AUDIO_PATH}/tdfb/tdfb_generic.c - ${SOF_AUDIO_PATH}/tdfb/tdfb_hifiep.c - ${SOF_AUDIO_PATH}/tdfb/tdfb_hifi3.c - ${SOF_AUDIO_PATH}/tdfb/tdfb_${ipc_suffix}.c -) +if(CONFIG_COMP_TDFB STREQUAL "m") + add_subdirectory(${SOF_AUDIO_PATH}/tdfb/llext + ${PROJECT_BINARY_DIR}/tdfb_llext) + add_dependencies(app tdfb) +elseif(CONFIG_COMP_TDFB) + zephyr_library_sources( + ${SOF_AUDIO_PATH}/tdfb/tdfb.c + ${SOF_AUDIO_PATH}/tdfb/tdfb_direction.c + ${SOF_AUDIO_PATH}/tdfb/tdfb_generic.c + ${SOF_AUDIO_PATH}/tdfb/tdfb_hifiep.c + ${SOF_AUDIO_PATH}/tdfb/tdfb_hifi3.c + ${SOF_AUDIO_PATH}/tdfb/tdfb_${ipc_suffix}.c + ) +endif() zephyr_library_sources_ifdef(CONFIG_SQRT_FIXED ${SOF_MATH_PATH}/sqrt_int16.c