From 736e7a93732d26b06ef38489341c61735f3a36cd Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 13 Jun 2024 14:32:27 +0200 Subject: [PATCH 01/22] llext: add a convenience Kconfig option to build LLEXT modules Add a Kconfig option that can be used to flip all LLEXT-supporting code to a modular build. Use that global flag for smart-amp-test, mixin-mixout and eq-iir. Signed-off-by: Guennadi Liakhovetski --- src/audio/eq_iir/Kconfig | 1 + src/audio/mixin_mixout/Kconfig | 1 + src/library_manager/Kconfig | 8 ++++++++ src/samples/audio/Kconfig | 1 + 4 files changed, 11 insertions(+) diff --git a/src/audio/eq_iir/Kconfig b/src/audio/eq_iir/Kconfig index 2fee46d9a29f..11433d27cfb3 100644 --- a/src/audio/eq_iir/Kconfig +++ b/src/audio/eq_iir/Kconfig @@ -3,6 +3,7 @@ config COMP_IIR tristate "IIR component" select COMP_BLOB + default m if LIBRARY_DEFAULT_MODULAR default y depends on COMP_MODULE_ADAPTER select MATH_IIR_DF1 diff --git a/src/audio/mixin_mixout/Kconfig b/src/audio/mixin_mixout/Kconfig index 852b23f18e08..73016a667bd7 100644 --- a/src/audio/mixin_mixout/Kconfig +++ b/src/audio/mixin_mixout/Kconfig @@ -3,6 +3,7 @@ config COMP_MIXIN_MIXOUT tristate "Mixin_mixout component" depends on IPC_MAJOR_4 + default m if LIBRARY_DEFAULT_MODULAR default y help Select for Mixin_mixout component diff --git a/src/library_manager/Kconfig b/src/library_manager/Kconfig index e167f956a37a..d0657aefc9fb 100644 --- a/src/library_manager/Kconfig +++ b/src/library_manager/Kconfig @@ -33,4 +33,12 @@ config LIBRARY_AUTH_SUPPORT could be used if enabled. If unsure say N. +config LIBRARY_DEFAULT_MODULAR + bool "Build LLEXT modules by default" + depends on LLEXT + help + Build code, that can be built as LLEXT modules as such. Usually such + code has tristate Kconfig entries, they will default to "m" if this + option is selected. + endmenu diff --git a/src/samples/audio/Kconfig b/src/samples/audio/Kconfig index 0338ced15875..7463d8c31412 100644 --- a/src/samples/audio/Kconfig +++ b/src/samples/audio/Kconfig @@ -4,6 +4,7 @@ menu "Audio component samples" config SAMPLE_SMART_AMP tristate "Smart amplifier test component" + default m if LIBRARY_DEFAULT_MODULAR default y help Select for test smart amplifier component From 11e76b63d15cf30d1c2780610f9957a38524968c Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 23 Jul 2024 15:30:00 +0200 Subject: [PATCH 02/22] lnl: build all supporting code as LLEXT modules Enable CONFIG_LIBRARY_DEFAULT_MODULAR for LNL to build all supporting code as LLEXT modules. Signed-off-by: Guennadi Liakhovetski --- app/boards/intel_adsp_ace20_lnl.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index 8a9e4b295f5d..443f0a7bae71 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -82,7 +82,7 @@ CONFIG_MEMORY_WIN_2_SIZE=12288 CONFIG_LLEXT=y CONFIG_LLEXT_STORAGE_WRITABLE=y CONFIG_MODULES=y - +CONFIG_LIBRARY_DEFAULT_MODULAR=y # Temporary disabled options CONFIG_TRACE=n From afc30e42f25a5982641b66dba0e054085ea18cc8 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 30 May 2024 16:04:38 +0200 Subject: [PATCH 03/22] llext: automatically calculate module addresses Currently LLEXT module starting addresses are hard-coded in their respective CMakeLists.txt files. This is very wasteful, since it's unknown in what order modules are loaded, inflexible and not easily extendible to other platforms. Switch to calculating addresses automatically based on a single per-platform Kconfig value. Signed-off-by: Guennadi Liakhovetski --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + app/boards/intel_adsp_ace20_lnl.conf | 1 + app/overlays/lnl/module_overlay.conf | 1 + app/overlays/mtl/module_overlay.conf | 1 + scripts/llext_link_helper.py | 17 ++++++- scripts/llext_offset_calc.py | 47 +++++++++++++++++++ src/audio/drc/llext/CMakeLists.txt | 2 - src/audio/eq_iir/llext/CMakeLists.txt | 2 - src/audio/mixin_mixout/llext/CMakeLists.txt | 2 - src/library_manager/Kconfig | 9 ++++ .../audio/smart_amp_test_llext/CMakeLists.txt | 2 - zephyr/CMakeLists.txt | 28 +++++++++-- 12 files changed, 100 insertions(+), 13 deletions(-) create mode 100755 scripts/llext_offset_calc.py diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 293ffe747e82..fbc2385845b8 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -88,6 +88,7 @@ CONFIG_MEMORY_WIN_2_SIZE=12288 CONFIG_LLEXT=y CONFIG_LLEXT_STORAGE_WRITABLE=y CONFIG_MODULES=y +CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 # Temporary disabled options CONFIG_TRACE=n diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index 443f0a7bae71..7ed0811b1d56 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -83,6 +83,7 @@ CONFIG_LLEXT=y CONFIG_LLEXT_STORAGE_WRITABLE=y CONFIG_MODULES=y CONFIG_LIBRARY_DEFAULT_MODULAR=y +CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 # Temporary disabled options CONFIG_TRACE=n diff --git a/app/overlays/lnl/module_overlay.conf b/app/overlays/lnl/module_overlay.conf index 88006880acd9..7ff56ce53e03 100644 --- a/app/overlays/lnl/module_overlay.conf +++ b/app/overlays/lnl/module_overlay.conf @@ -1,2 +1,3 @@ +CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_DRC=m diff --git a/app/overlays/mtl/module_overlay.conf b/app/overlays/mtl/module_overlay.conf index 1fb5549e9d82..0a258780e545 100644 --- a/app/overlays/mtl/module_overlay.conf +++ b/app/overlays/mtl/module_overlay.conf @@ -1,3 +1,4 @@ +CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_MIXIN_MIXOUT=m CONFIG_COMP_IIR=m diff --git a/scripts/llext_link_helper.py b/scripts/llext_link_helper.py index b1674e523784..98514c35a6cd 100755 --- a/scripts/llext_link_helper.py +++ b/scripts/llext_link_helper.py @@ -28,6 +28,8 @@ def parse_args(): help='Object file name') parser.add_argument("-t", "--text-addr", required=True, type=str, help='.text section address') + parser.add_argument("-s", "--size-file", required=True, type=str, + help='File with stored accumulated size') args = parser.parse_args() @@ -43,11 +45,20 @@ def max_alignment(addr, align1, align2): return upper - (upper % align1) def main(): + global args + parse_args() - elf = ELFFile(open(args.file, 'rb')) + # Get the size of the previous module, if this isn't the first one. + # It is used to automatically calculate starting address of the current + # module. + try: + with open(args.size_file, 'r') as f_size: + size = int(f_size.read().strip(), base = 0) + except OSError: + size = 0 - text_addr = int(args.text_addr, 0) + text_addr = int(args.text_addr, 0) + size text_size = 0 # File names differ when building shared or relocatable objects @@ -65,6 +76,8 @@ def main(): writable = [] readonly = [] + elf = ELFFile(open(args.file, 'rb')) + # Create an object file with sections grouped by their properties, # similar to how program segments are created: all executable sections, # then all read-only data sections, and eventually all writable data diff --git a/scripts/llext_offset_calc.py b/scripts/llext_offset_calc.py new file mode 100755 index 000000000000..cef0662449bf --- /dev/null +++ b/scripts/llext_offset_calc.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause + +# Add rounded new file size to accumulated module size cache + +import argparse +import pathlib +import os + +args = None + +def parse_args(): + global args + + parser = argparse.ArgumentParser(description='Add a file size to a sum in a file') + + parser.add_argument("-i", "--input", required=True, type=str, + help='Object file name') + parser.add_argument("-s", "--size-file", required=True, type=str, + help='File to store accumulated size') + + args = parser.parse_args() + +def main(): + global args + + parse_args() + + f_output = pathlib.Path(args.size_file) + + try: + with open(f_output, 'r') as f_size: + size = int(f_size.read().strip(), base = 0) + except OSError: + size = 0 + + # Failure will raise an exception + f_size = open(f_output, "w") + + # align to a page border + size += os.path.getsize(args.input) + 0xfff + size &= ~0xfff + + f_size.write(f'0x{size:x}\n') + +if __name__ == "__main__": + main() diff --git a/src/audio/drc/llext/CMakeLists.txt b/src/audio/drc/llext/CMakeLists.txt index 5a59b9bade98..e658c3acfe0b 100644 --- a/src/audio/drc/llext/CMakeLists.txt +++ b/src/audio/drc/llext/CMakeLists.txt @@ -1,7 +1,6 @@ # Copyright (c) 2024 Intel Corporation. # SPDX-License-Identifier: Apache-2.0 -# Hard-coded .text address to be moved to a common place sof_llext_build("drc" SOURCES ../drc.c ../drc_generic.c @@ -9,5 +8,4 @@ sof_llext_build("drc" ../drc_hifi3.c ../drc_hifi4.c ../drc_math_hifi3.c - TEXT_ADDR 0xa068a000 ) diff --git a/src/audio/eq_iir/llext/CMakeLists.txt b/src/audio/eq_iir/llext/CMakeLists.txt index 9bf8a4b4e7ef..535455105515 100644 --- a/src/audio/eq_iir/llext/CMakeLists.txt +++ b/src/audio/eq_iir/llext/CMakeLists.txt @@ -1,10 +1,8 @@ # Copyright (c) 2024 Intel Corporation. # SPDX-License-Identifier: Apache-2.0 -# Hard-coded .text address to be moved to a common place sof_llext_build("eq_iir" SOURCES ../eq_iir.c ../eq_iir_ipc4.c ../eq_iir_generic.c - TEXT_ADDR 0xa06ea000 ) diff --git a/src/audio/mixin_mixout/llext/CMakeLists.txt b/src/audio/mixin_mixout/llext/CMakeLists.txt index a9743e379d54..fc5278dc47b0 100644 --- a/src/audio/mixin_mixout/llext/CMakeLists.txt +++ b/src/audio/mixin_mixout/llext/CMakeLists.txt @@ -1,11 +1,9 @@ # Copyright (c) 2024 Intel Corporation. # SPDX-License-Identifier: Apache-2.0 -# Hard-coded .text address to be moved to a common place sof_llext_build("mixin_mixout" SOURCES ../mixin_mixout.c ../mixin_mixout_hifi3.c ../mixin_mixout_hifi5.c ../mixin_mixout_generic.c - TEXT_ADDR 0xa06aa000 ) diff --git a/src/library_manager/Kconfig b/src/library_manager/Kconfig index d0657aefc9fb..7791e8839ac2 100644 --- a/src/library_manager/Kconfig +++ b/src/library_manager/Kconfig @@ -41,4 +41,13 @@ config LIBRARY_DEFAULT_MODULAR code has tristate Kconfig entries, they will default to "m" if this option is selected. +config LIBRARY_BASE_ADDRESS + hex "Base address for memory, dedicated to loadable modules" + default 0 + help + When initializing modules SOF will allocate memory for them and map + it to a predefined per-module address. Those addresses are calculated + automatically but the beginning of that area is platform-specific and + should be set by this option. + endmenu diff --git a/src/samples/audio/smart_amp_test_llext/CMakeLists.txt b/src/samples/audio/smart_amp_test_llext/CMakeLists.txt index 873eb61de81b..2218f41423b5 100644 --- a/src/samples/audio/smart_amp_test_llext/CMakeLists.txt +++ b/src/samples/audio/smart_amp_test_llext/CMakeLists.txt @@ -1,8 +1,6 @@ # Copyright (c) 2023 Intel Corporation. # SPDX-License-Identifier: Apache-2.0 -# Hard-coded .text address to be moved to a common place sof_llext_build("smart_amp_test" SOURCES ../smart_amp_test_ipc4.c - TEXT_ADDR 0xa06ca000 ) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index c74596a060af..7e2e87234987 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -38,6 +38,13 @@ function(sof_append_relative_path_definitions target) endforeach() endfunction() +define_property(GLOBAL PROPERTY SOF_LLEXT_LAST_TARGET + BRIEF_DOCS "Last LLEXT target" + FULL_DOCS "\ +Building LLEXT targets must be serialized. This property contains the \ +previously added LLEXT module for the establishment of a dependency chain." +) + # Used by LLEXT modules to create a file with module UUIDs function(sof_llext_write_uuids module) file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/../${module}.toml uuids REGEX "^[ \t]*uuid *=") @@ -54,7 +61,6 @@ endfunction() # Build an LLEXT module. Provice a module name, a list of sources and an address # of the .text section as arguments. function(sof_llext_build module) - set(single_args TEXT_ADDR) set(multi_args SOURCES) cmake_parse_arguments(PARSE_ARGV 1 SOF_LLEXT "${options}" "${single_args}" "${multi_args}") @@ -91,13 +97,29 @@ function(sof_llext_build module) get_target_property(proc_in_file ${module} lib_output) get_target_property(proc_out_file ${module} pkg_input) + get_target_property(proc_pkg_file ${module} pkg_output) + set(size_file ${PROJECT_BINARY_DIR}/module_size) + + get_property(last_target GLOBAL PROPERTY SOF_LLEXT_LAST_TARGET) + if(NOT "${last_target}" STREQUAL "") + add_dependencies(${module}_llext_proc ${last_target}) + endif() + set_property(GLOBAL PROPERTY SOF_LLEXT_LAST_TARGET ${module}) + add_llext_command(TARGET ${module} POST_BUILD - COMMAND ${PYTHON_EXECUTABLE} ${SOF_BASE}scripts/llext_link_helper.py - --text-addr="${SOF_LLEXT_TEXT_ADDR}" -f ${proc_in_file} ${CMAKE_C_COMPILER} -- + COMMAND ${PYTHON_EXECUTABLE} ${SOF_BASE}scripts/llext_link_helper.py -s ${size_file} + --text-addr=${CONFIG_LIBRARY_BASE_ADDRESS} + -f ${proc_in_file} ${CMAKE_C_COMPILER} -- -o ${proc_out_file} ${EXTRA_LINKER_PARAMS} $ ) + + add_llext_command(TARGET ${module} + POST_PKG + COMMAND ${PYTHON_EXECUTABLE} ${SOF_BASE}scripts/llext_offset_calc.py + -i ${proc_pkg_file} -s ${size_file} + ) endfunction() # Initial SOF module will contain From 859996e69b65edc94c4499859b0a82c3a7272e02 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 13 Jun 2024 11:43:08 +0200 Subject: [PATCH 04/22] llext: add missing modules to LNL overlay LNL modules overlay is missing eq_iir and mixin_mixout entries, add them there. Signed-off-by: Guennadi Liakhovetski --- app/overlays/lnl/module_overlay.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/overlays/lnl/module_overlay.conf b/app/overlays/lnl/module_overlay.conf index 7ff56ce53e03..c8624e47b6c9 100644 --- a/app/overlays/lnl/module_overlay.conf +++ b/app/overlays/lnl/module_overlay.conf @@ -1,3 +1,5 @@ CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 +CONFIG_COMP_MIXIN_MIXOUT=m +CONFIG_COMP_IIR=m CONFIG_SAMPLE_SMART_AMP=m CONFIG_COMP_DRC=m From 543ee6ad75df32fd56a03fc769c15187255befdd Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 13 Jun 2024 12:02:32 +0200 Subject: [PATCH 05/22] 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/overlays/lnl/module_overlay.conf | 3 ++- app/overlays/mtl/module_overlay.conf | 1 + src/audio/src/CMakeLists.txt | 10 +++++++- src/audio/src/Kconfig | 1 + src/audio/src/llext/CMakeLists.txt | 23 +++++++++++++++++ src/audio/src/llext/llext.toml.h | 6 +++++ src/audio/src/src.c | 28 ++++++++++++++++++++ src/audio/src/src.toml | 8 ++++-- src/audio/src/src_common.c | 2 +- src/audio/src/src_ipc3.c | 6 ++--- src/audio/src/src_ipc4.c | 6 ++--- src/audio/src/src_lite.c | 2 +- src/audio/src/src_log.c | 21 +++++++++++++++ zephyr/CMakeLists.txt | 37 ++++++++++++++++++--------- 16 files changed, 128 insertions(+), 28 deletions(-) create mode 100644 src/audio/src/llext/CMakeLists.txt create mode 100644 src/audio/src/llext/llext.toml.h create mode 100644 src/audio/src/src_log.c diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index fbc2385845b8..9c34c85f815b 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 7ed0811b1d56..ae391d252f69 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/overlays/lnl/module_overlay.conf b/app/overlays/lnl/module_overlay.conf index c8624e47b6c9..ea6688063622 100644 --- a/app/overlays/lnl/module_overlay.conf +++ b/app/overlays/lnl/module_overlay.conf @@ -1,5 +1,6 @@ CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 +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/overlays/mtl/module_overlay.conf b/app/overlays/mtl/module_overlay.conf index 0a258780e545..ea6688063622 100644 --- a/app/overlays/mtl/module_overlay.conf +++ b/app/overlays/mtl/module_overlay.conf @@ -3,3 +3,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/CMakeLists.txt b/src/audio/src/CMakeLists.txt index bfc6361afedb..650bd2d60ceb 100644 --- a/src/audio/src/CMakeLists.txt +++ b/src/audio/src/CMakeLists.txt @@ -1,6 +1,14 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof src_generic.c src_hifi2ep.c src_hifi3.c src_hifi4.c src_common.c src.c) +add_local_sources(sof + src_generic.c + src_hifi2ep.c + src_hifi3.c + src_hifi4.c + src_common.c + src_log.c + src.c +) if(CONFIG_IPC_MAJOR_3) add_local_sources(sof src_ipc3.c) 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..04a5cc4c5266 --- /dev/null +++ b/src/audio/src/llext/CMakeLists.txt @@ -0,0 +1,23 @@ +# 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_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_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_common.c b/src/audio/src/src_common.c index e2d16dc7e2d3..f79f4b7bd912 100644 --- a/src/audio/src/src_common.c +++ b/src/audio/src/src_common.c @@ -41,7 +41,7 @@ #include "src_common.h" #include "src_config.h" -LOG_MODULE_REGISTER(src, CONFIG_SOF_LOG_LEVEL); +LOG_MODULE_DECLARE(src, CONFIG_SOF_LOG_LEVEL); /* Calculates buffers to allocate for a SRC mode */ static int src_buffer_lengths(struct comp_dev *dev, struct comp_data *cd, int nch) diff --git a/src/audio/src/src_ipc3.c b/src/audio/src/src_ipc3.c index f61c2345f2d9..5e8b00a4d98b 100644 --- a/src/audio/src/src_ipc3.c +++ b/src/audio/src/src_ipc3.c @@ -41,11 +41,9 @@ #include "src_common.h" #include "src_config.h" -SOF_DEFINE_REG_UUID(src); - -DECLARE_TR_CTX(src_tr, SOF_UUID(src_uuid), LOG_LEVEL_INFO); - LOG_MODULE_DECLARE(src, CONFIG_SOF_LOG_LEVEL); +extern const struct sof_uuid src_uuid; +extern struct tr_ctx src_tr; int src_rate_check(const void *spec) { diff --git a/src/audio/src/src_ipc4.c b/src/audio/src/src_ipc4.c index c337f34b404c..0458c8bd3b50 100644 --- a/src/audio/src/src_ipc4.c +++ b/src/audio/src/src_ipc4.c @@ -41,11 +41,9 @@ #include "src_common.h" #include "src_config.h" -SOF_DEFINE_REG_UUID(src4); - -DECLARE_TR_CTX(src_tr, SOF_UUID(src4_uuid), LOG_LEVEL_INFO); - LOG_MODULE_DECLARE(src, CONFIG_SOF_LOG_LEVEL); +extern const struct sof_uuid src4_uuid; +extern struct tr_ctx src_tr; int src_rate_check(const void *spec) { 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/src/audio/src/src_log.c b/src/audio/src/src_log.c new file mode 100644 index 000000000000..847642d902b1 --- /dev/null +++ b/src/audio/src/src_log.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2024 Intel Corporation. + +#include +#include +#include +#include + +LOG_MODULE_REGISTER(src, CONFIG_SOF_LOG_LEVEL); +#if CONFIG_IPC_MAJOR_4 +SOF_DEFINE_REG_UUID(src4); +DECLARE_TR_CTX(src_tr, SOF_UUID(src4_uuid), LOG_LEVEL_INFO); +EXPORT_SYMBOL(src4_uuid); +#elif CONFIG_IPC_MAJOR_3 +SOF_DEFINE_REG_UUID(src); +DECLARE_TR_CTX(src_tr, SOF_UUID(src_uuid), LOG_LEVEL_INFO); +EXPORT_SYMBOL(src_uuid); +#endif +EXPORT_SYMBOL(src_tr); +EXPORT_SYMBOL(log_const_src); diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 7e2e87234987..5785bd4e070e 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -744,19 +744,32 @@ 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() + +if(NOT CONFIG_COMP_SRC STREQUAL "n") + zephyr_library_sources( + ${SOF_AUDIO_PATH}/src/src_log.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 45ae3a233f7e050413b9195466bf198c1a64bb63 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Tue, 28 May 2024 14:17:03 +0200 Subject: [PATCH 06/22] 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 +--- 5 files changed, 75 insertions(+), 78 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