From 06e4723ca84487c7c05dc098e859c7f1be2259ae Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 13 Jun 2024 12:02:32 +0200 Subject: [PATCH 1/7] src: convert to a loadable module Build src as a loadable llext module. Signed-off-by: Guennadi Liakhovetski --- app/boards/intel_adsp_ace15_mtpm.conf | 1 - app/boards/intel_adsp_ace20_lnl.conf | 1 - app/configs/lnl/modules.conf | 3 ++- app/configs/mtl/modules.conf | 1 + src/audio/src/Kconfig | 1 + src/audio/src/llext/CMakeLists.txt | 25 +++++++++++++++++++++ src/audio/src/llext/llext.toml.h | 6 ++++++ src/audio/src/src.c | 28 ++++++++++++++++++++++++ src/audio/src/src.toml | 8 +++++-- src/audio/src/src_lite.c | 2 +- zephyr/CMakeLists.txt | 31 ++++++++++++++++----------- 11 files changed, 89 insertions(+), 18 deletions(-) create mode 100644 src/audio/src/llext/CMakeLists.txt create mode 100644 src/audio/src/llext/llext.toml.h diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 4084a6b5d2b3..31009202196a 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -2,7 +2,6 @@ CONFIG_METEORLAKE=y CONFIG_IPC_MAJOR_4=y CONFIG_IPC4_BASE_FW_INTEL=y -CONFIG_COMP_SRC=y CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y CONFIG_COMP_SRC_LITE=y CONFIG_COMP_DRC=m diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index e2d92511d336..a5d7ce9ce269 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -2,7 +2,6 @@ CONFIG_LUNARLAKE=y CONFIG_IPC_MAJOR_4=y CONFIG_IPC4_BASE_FW_INTEL=y -CONFIG_COMP_SRC=y CONFIG_COMP_SRC_IPC4_FULL_MATRIX=y CONFIG_COMP_DRC=m diff --git a/app/configs/lnl/modules.conf b/app/configs/lnl/modules.conf index cab858609c28..44521a4cb314 100644 --- a/app/configs/lnl/modules.conf +++ b/app/configs/lnl/modules.conf @@ -1,4 +1,5 @@ +CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_MIXIN_MIXOUT=m CONFIG_COMP_IIR=m -CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_DRC=m +CONFIG_COMP_SRC=m diff --git a/app/configs/mtl/modules.conf b/app/configs/mtl/modules.conf index 1fb5549e9d82..44521a4cb314 100644 --- a/app/configs/mtl/modules.conf +++ b/app/configs/mtl/modules.conf @@ -2,3 +2,4 @@ CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_MIXIN_MIXOUT=m CONFIG_COMP_IIR=m CONFIG_COMP_DRC=m +CONFIG_COMP_SRC=m diff --git a/src/audio/src/Kconfig b/src/audio/src/Kconfig index ef651703a252..0b08e6358a98 100644 --- a/src/audio/src/Kconfig +++ b/src/audio/src/Kconfig @@ -2,6 +2,7 @@ config COMP_SRC tristate "SRC component" + default m if LIBRARY_DEFAULT_MODULAR default y help Select for SRC component diff --git a/src/audio/src/llext/CMakeLists.txt b/src/audio/src/llext/CMakeLists.txt new file mode 100644 index 000000000000..84a0bc4465df --- /dev/null +++ b/src/audio/src/llext/CMakeLists.txt @@ -0,0 +1,25 @@ +# Copyright (c) 2024 Intel Corporation. +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_COMP_SRC_LITE) +sof_llext_build("src" + SOURCES ../src_hifi2ep.c + ../src_generic.c + ../src_hifi3.c + ../src_hifi4.c + ../src.c + ../src_common.c + ../src_ipc4.c + ../src_lite.c +) +else() +sof_llext_build("src" + SOURCES ../src_hifi2ep.c + ../src_generic.c + ../src_hifi3.c + ../src_hifi4.c + ../src.c + ../src_common.c + ../src_ipc4.c +) +endif() diff --git a/src/audio/src/llext/llext.toml.h b/src/audio/src/llext/llext.toml.h new file mode 100644 index 000000000000..cfb334ca24e7 --- /dev/null +++ b/src/audio/src/llext/llext.toml.h @@ -0,0 +1,6 @@ +#include +#define LOAD_TYPE "2" +#include "../src.toml" + +[module] +count = __COUNTER__ diff --git a/src/audio/src/src.c b/src/audio/src/src.c index b064a180b690..d75b1eb53822 100644 --- a/src/audio/src/src.c +++ b/src/audio/src/src.c @@ -81,3 +81,31 @@ static const struct module_interface src_interface = { DECLARE_MODULE_ADAPTER(src_interface, SRC_UUID, src_tr); SOF_MODULE_INIT(src, sys_comp_module_src_interface_init); + +#if CONFIG_COMP_SRC_MODULE +/* modular: llext dynamic link */ + +#include +#include +#include + +#define UUID_SRC 0x8D, 0xB2, 0x1B, 0xE6, 0x9A, 0x14, 0x1F, 0x4C, \ + 0xB7, 0x09, 0x46, 0x82, 0x3E, 0xF5, 0xF5, 0xAE +SOF_LLEXT_MOD_ENTRY(src, &src_interface); + +#if CONFIG_COMP_SRC_LITE +#define UUID_SRC_LITE 0x51, 0x10, 0x44, 0x33, 0xCD, 0x44, 0x6A, 0x46, \ + 0x83, 0xA3, 0x17, 0x84, 0x78, 0x70, 0x8A, 0xEA +extern const struct module_interface src_lite_interface; +SOF_LLEXT_MOD_ENTRY(src_lite, &src_lite_interface); +#endif + +static const struct sof_man_module_manifest mod_manifest[] __section(".module") __used = { + SOF_LLEXT_MODULE_MANIFEST("SRC", src_llext_entry, 1, UUID_SRC, 1), +#if CONFIG_COMP_SRC_LITE + SOF_LLEXT_MODULE_MANIFEST("SRC_LITE", src_lite_llext_entry, 1, UUID_SRC_LITE, 1), +#endif +}; + +SOF_LLEXT_BUILDINFO; +#endif diff --git a/src/audio/src/src.toml b/src/audio/src/src.toml index 9cd67f28d9ce..448739cf2f19 100644 --- a/src/audio/src/src.toml +++ b/src/audio/src/src.toml @@ -1,10 +1,14 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + [[module.entry]] name = "SRC" uuid = "E61BB28D-149A-4C1F-B709-46823EF5F5AE" affinity_mask = "0x1" REM #instance_count = "10" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE module_type = "7" auto_start = "0" sched_caps = [1, 0x00008000] @@ -77,7 +81,7 @@ affinity_mask = "0x1" REM #instance_count = "10" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE module_type = "0x1F" auto_start = "0" sched_caps = [1, 0x00008000] diff --git a/src/audio/src/src_lite.c b/src/audio/src/src_lite.c index 249c6a57d2de..35423dad9225 100644 --- a/src/audio/src/src_lite.c +++ b/src/audio/src/src_lite.c @@ -53,7 +53,7 @@ static int src_lite_prepare(struct processing_module *mod, return src_prepare_general(mod, sources[0], sinks[0]); } -static const struct module_interface src_lite_interface = { +const struct module_interface src_lite_interface = { .init = src_init, .prepare = src_lite_prepare, .process = src_process, diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 80c055e90fb1..f005ca289551 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -746,19 +746,26 @@ zephyr_library_sources_ifdef(CONFIG_COMP_CHAIN_DMA ${SOF_AUDIO_PATH}/chain_dma.c ) -zephyr_library_sources_ifdef(CONFIG_COMP_SRC - ${SOF_AUDIO_PATH}/src/src_hifi2ep.c - ${SOF_AUDIO_PATH}/src/src_generic.c - ${SOF_AUDIO_PATH}/src/src_hifi3.c - ${SOF_AUDIO_PATH}/src/src_hifi4.c - ${SOF_AUDIO_PATH}/src/src_common.c - ${SOF_AUDIO_PATH}/src/src.c - ${SOF_AUDIO_PATH}/src/src_${ipc_suffix}.c -) +if(CONFIG_COMP_SRC STREQUAL "m") + add_subdirectory(${SOF_AUDIO_PATH}/src/llext + ${PROJECT_BINARY_DIR}/src_llext) + add_dependencies(app src) +elseif(CONFIG_COMP_SRC) + zephyr_library_sources_ifdef(CONFIG_COMP_SRC + ${SOF_AUDIO_PATH}/src/src_hifi2ep.c + ${SOF_AUDIO_PATH}/src/src_generic.c + ${SOF_AUDIO_PATH}/src/src_hifi3.c + ${SOF_AUDIO_PATH}/src/src_hifi4.c + ${SOF_AUDIO_PATH}/src/src_common.c + ${SOF_AUDIO_PATH}/src/src.c + ${SOF_AUDIO_PATH}/src/src_${ipc_suffix}.c + ) + + zephyr_library_sources_ifdef(CONFIG_COMP_SRC_LITE + ${SOF_AUDIO_PATH}/src/src_lite.c + ) +endif() -zephyr_library_sources_ifdef(CONFIG_COMP_SRC_LITE - ${SOF_AUDIO_PATH}/src/src_lite.c -) zephyr_library_sources_ifdef(CONFIG_COMP_BASEFW_IPC4 ${SOF_AUDIO_PATH}/base_fw.c ) From ad4a98c973db4d7841364cba7efb2e3cddef6aca Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 28 May 2024 14:17:03 +0200 Subject: [PATCH 2/7] volume: move gain.toml and peakvol.toml into volume.toml To make volume an LLEXT module it should have a single TOML configuration file named volume.toml. This is easy to do, using respective Kconfig options. Signed-off-by: Guennadi Liakhovetski --- src/audio/volume/gain.toml | 33 ---------------- src/audio/volume/peakvol.toml | 33 ---------------- src/audio/volume/volume.toml | 71 ++++++++++++++++++++++++++++++++++ tools/rimage/config/lnl.toml.h | 8 +--- tools/rimage/config/mtl.toml.h | 8 +--- tools/rimage/config/ptl.toml.h | 8 +--- 6 files changed, 77 insertions(+), 84 deletions(-) delete mode 100644 src/audio/volume/gain.toml delete mode 100644 src/audio/volume/peakvol.toml create mode 100644 src/audio/volume/volume.toml diff --git a/src/audio/volume/gain.toml b/src/audio/volume/gain.toml deleted file mode 100644 index 1bd8defc4e2b..000000000000 --- a/src/audio/volume/gain.toml +++ /dev/null @@ -1,33 +0,0 @@ - [[module.entry]] - name = "GAIN" - uuid = "61BCA9A8-18D0-4A18-8E7B-2639219804B7" - affinity_mask = "0x1" - instance_count = "40" - domain_types = "0" - load_type = "0" - module_type = "9" - auto_start = "0" - sched_caps = [1, 0x00008000] - - REM # pin = [dir, type, sample rate, size, container, channel-cfg] - pin = [0, 0, 0xfeef, 0xf, 0xf, 0x45ff, - 1, 0, 0xfeef, 0xf, 0xf, 0x45ff] - - REM # mod_cfg [PAR_0 PAR_1 PAR_2 PAR_3 IS_BYTES CPS IBS OBS MOD_FLAGS CPC OBLS] -#if CONFIG_METEORLAKE - mod_cfg = [1, 0, 0, 0, 416, 12100000, 1536, 1536, 0, 12100, 0, - 2, 0, 0, 0, 416, 10183000, 384, 384, 0, 10183, 0, - 3, 0, 0, 0, 416, 8192000, 512, 512, 0, 8192, 0, - 4, 0, 0, 0, 416, 10091000, 128, 128, 0, 10091, 0, - 5, 0, 0, 0, 416, 5908000, 768, 768, 0, 5908, 0] -#elif defined(CONFIG_LUNARLAKE) || defined(CONFIG_PANTHERLAKE) - mod_cfg = [0, 0, 0, 0, 416, 914000, 48, 64, 0, 0, 0, - 1, 0, 0, 0, 416, 1321600, 192, 256, 0, 0, 0, - 2, 0, 0, 0, 416, 1786000, 192, 256, 0, 0, 0, - 3, 0, 0, 0, 416, 2333000, 48, 64, 0, 0, 0, - 4, 0, 0, 0, 416, 2910000, 192, 256, 0, 0, 0, - 5, 0, 0, 0, 416, 3441000, 192, 256, 0, 0, 0, - 6, 0, 0, 0, 416, 4265000, 192, 256, 0, 0, 0] -#endif - - index = __COUNTER__ diff --git a/src/audio/volume/peakvol.toml b/src/audio/volume/peakvol.toml deleted file mode 100644 index c7a3bea647f3..000000000000 --- a/src/audio/volume/peakvol.toml +++ /dev/null @@ -1,33 +0,0 @@ - [[module.entry]] - name = "PEAKVOL" - uuid = "8A171323-94A3-4E1D-AFE9-FE5DBAA4C393" - affinity_mask = "0x1" - instance_count = "10" - domain_types = "0" - load_type = "0" - module_type = "4" - auto_start = "0" - sched_caps = [1, 0x00008000] - - REM # pin = [dir, type, sample rate, size, container, channel-cfg] - pin = [0, 0, 0xfeef, 0xf, 0xa, 0x45ff, - 1, 0, 0xfeef, 0xf, 0xa, 0x45ff] - - REM # mod_cfg [PAR_0 PAR_1 PAR_2 PAR_3 IS_BYTES CPS IBS OBS MOD_FLAGS CPC OBLS] -#if CONFIG_METEORLAKE - mod_cfg = [1, 0, 0, 0, 480, 11667000, 384, 384, 0, 11667, 0, - 2, 0, 0, 0, 480, 5943000, 192, 192, 0, 5943, 0, - 3, 0, 0, 0, 480, 12567000, 720, 720, 0, 12567, 0, - 4, 0, 0, 0, 480, 7360000, 768, 768, 0, 7360, 0, - 5, 0, 0, 0, 480, 12236000, 1536, 1536, 0, 12236, 0] -#elif defined(CONFIG_LUNARLAKE) || defined(CONFIG_PANTHERLAKE) - mod_cfg = [0, 0, 0, 0, 480, 1114000, 48, 64, 0, 0, 0, - 1, 0, 0, 0, 480, 3321600, 192, 256, 0, 0, 0, - 2, 0, 0, 0, 480, 3786000, 192, 256, 0, 0, 0, - 3, 0, 0, 0, 480, 4333000, 48, 64, 0, 0, 0, - 4, 0, 0, 0, 480, 4910000, 192, 256, 0, 0, 0, - 5, 0, 0, 0, 480, 5441000, 192, 256, 0, 0, 0, - 6, 0, 0, 0, 480, 6265000, 192, 256, 0, 0, 0] -#endif - - index = __COUNTER__ diff --git a/src/audio/volume/volume.toml b/src/audio/volume/volume.toml new file mode 100644 index 000000000000..2aaa0bbccbc3 --- /dev/null +++ b/src/audio/volume/volume.toml @@ -0,0 +1,71 @@ +#if CONFIG_COMP_PEAK_VOL + [[module.entry]] + name = "PEAKVOL" + uuid = "8A171323-94A3-4E1D-AFE9-FE5DBAA4C393" + affinity_mask = "0x1" + instance_count = "10" + domain_types = "0" + load_type = "0" + module_type = "4" + auto_start = "0" + sched_caps = [1, 0x00008000] + + REM # pin = [dir, type, sample rate, size, container, channel-cfg] + pin = [0, 0, 0xfeef, 0xf, 0xa, 0x45ff, + 1, 0, 0xfeef, 0xf, 0xa, 0x45ff] + + REM # mod_cfg [PAR_0 PAR_1 PAR_2 PAR_3 IS_BYTES CPS IBS OBS MOD_FLAGS CPC OBLS] +#if CONFIG_METEORLAKE + mod_cfg = [1, 0, 0, 0, 480, 11667000, 384, 384, 0, 11667, 0, + 2, 0, 0, 0, 480, 5943000, 192, 192, 0, 5943, 0, + 3, 0, 0, 0, 480, 12567000, 720, 720, 0, 12567, 0, + 4, 0, 0, 0, 480, 7360000, 768, 768, 0, 7360, 0, + 5, 0, 0, 0, 480, 12236000, 1536, 1536, 0, 12236, 0] +#elif CONFIG_LUNARLAKE || CONFIG_PANTHERLAKE + mod_cfg = [0, 0, 0, 0, 480, 1114000, 48, 64, 0, 0, 0, + 1, 0, 0, 0, 480, 3321600, 192, 256, 0, 0, 0, + 2, 0, 0, 0, 480, 3786000, 192, 256, 0, 0, 0, + 3, 0, 0, 0, 480, 4333000, 48, 64, 0, 0, 0, + 4, 0, 0, 0, 480, 4910000, 192, 256, 0, 0, 0, + 5, 0, 0, 0, 480, 5441000, 192, 256, 0, 0, 0, + 6, 0, 0, 0, 480, 6265000, 192, 256, 0, 0, 0] +#endif + + index = __COUNTER__ +#endif + +#if CONFIG_COMP_GAIN + [[module.entry]] + name = "GAIN" + uuid = "61BCA9A8-18D0-4A18-8E7B-2639219804B7" + affinity_mask = "0x1" + instance_count = "40" + domain_types = "0" + load_type = "0" + module_type = "9" + auto_start = "0" + sched_caps = [1, 0x00008000] + + REM # pin = [dir, type, sample rate, size, container, channel-cfg] + pin = [0, 0, 0xfeef, 0xf, 0xf, 0x45ff, + 1, 0, 0xfeef, 0xf, 0xf, 0x45ff] + + REM # mod_cfg [PAR_0 PAR_1 PAR_2 PAR_3 IS_BYTES CPS IBS OBS MOD_FLAGS CPC OBLS] +#if CONFIG_METEORLAKE + mod_cfg = [1, 0, 0, 0, 416, 12100000, 1536, 1536, 0, 12100, 0, + 2, 0, 0, 0, 416, 10183000, 384, 384, 0, 10183, 0, + 3, 0, 0, 0, 416, 8192000, 512, 512, 0, 8192, 0, + 4, 0, 0, 0, 416, 10091000, 128, 128, 0, 10091, 0, + 5, 0, 0, 0, 416, 5908000, 768, 768, 0, 5908, 0] +#elif CONFIG_LUNARLAKE || CONFIG_PANTHERLAKE + mod_cfg = [0, 0, 0, 0, 416, 914000, 48, 64, 0, 0, 0, + 1, 0, 0, 0, 416, 1321600, 192, 256, 0, 0, 0, + 2, 0, 0, 0, 416, 1786000, 192, 256, 0, 0, 0, + 3, 0, 0, 0, 416, 2333000, 48, 64, 0, 0, 0, + 4, 0, 0, 0, 416, 2910000, 192, 256, 0, 0, 0, + 5, 0, 0, 0, 416, 3441000, 192, 256, 0, 0, 0, + 6, 0, 0, 0, 416, 4265000, 192, 256, 0, 0, 0] +#endif + + index = __COUNTER__ +#endif diff --git a/tools/rimage/config/lnl.toml.h b/tools/rimage/config/lnl.toml.h index 3386f06fe074..247a4975f9c8 100644 --- a/tools/rimage/config/lnl.toml.h +++ b/tools/rimage/config/lnl.toml.h @@ -32,12 +32,8 @@ #include