diff --git a/app/overlays/mtl/module_overlay.conf b/app/overlays/mtl/module_overlay.conf index 172a8ea28e82..45babe736c53 100644 --- a/app/overlays/mtl/module_overlay.conf +++ b/app/overlays/mtl/module_overlay.conf @@ -1 +1,3 @@ CONFIG_SAMPLE_SMART_AMP=m +CONFIG_COMP_MIXIN_MIXOUT=m +CONFIG_COMP_IIR=m diff --git a/scripts/xtensa-build-zephyr.py b/scripts/xtensa-build-zephyr.py index 770efda47794..c0f9d48e82a7 100755 --- a/scripts/xtensa-build-zephyr.py +++ b/scripts/xtensa-build-zephyr.py @@ -931,10 +931,10 @@ def install_lib(sof_lib_dir, abs_build_dir, platform_wconfig): dst = sof_lib_dir / llext_file rimage_cfg = entry_path / 'rimage_config.toml' - llext_input = entry_path / (llext_base + '.so') - llext_output = entry_path / llext_file + llext_input = entry_path / (llext_base + '.llext') + llext_output = entry_path / (llext_file + '.ri') - sign_cmd = [str(platform_wconfig.get("rimage.path")), "-o", str(llext_output), + sign_cmd = [platform_wconfig.get("rimage.path"), "-o", str(llext_output), "-e", "-c", str(rimage_cfg), "-k", str(signing_key), "-l", "-r", str(llext_input)] @@ -947,7 +947,7 @@ def install_lib(sof_lib_dir, abs_build_dir, platform_wconfig): # Thus we're left with a choice between a 150-character # long line and an illogical split like this with open(dst, 'wb') as fdst, open(llext_output, 'rb') as fllext, open( - llext_output.with_suffix('.llext.xman'), 'rb') as fman: + llext_output.with_suffix('.ri.xman'), 'rb') as fman: # Concatenate the manifest and the llext shutil.copyfileobj(fman, fdst) shutil.copyfileobj(fllext, fdst) diff --git a/src/audio/audio_stream.c b/src/audio/audio_stream.c index d479bf80c788..c7f1cb1a7767 100644 --- a/src/audio/audio_stream.c +++ b/src/audio/audio_stream.c @@ -3,6 +3,8 @@ // Copyright(c) 2023 Intel Corporation. All rights reserved. // +#include + #include #include @@ -101,7 +103,7 @@ void audio_stream_set_align(const uint32_t byte_align, stream->frame_align_req = frame_align_req; audio_stream_recalc_align(stream); } - +EXPORT_SYMBOL(audio_stream_set_align); static int audio_stream_release_data(struct sof_source *source, size_t free_size) { diff --git a/src/audio/buffer.c b/src/audio/buffer.c index 02f6c9da0777..93337ce05078 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,7 @@ int buffer_set_params(struct comp_buffer *buffer, return 0; } +EXPORT_SYMBOL(buffer_set_params); bool buffer_params_match(struct comp_buffer *buffer, struct sof_ipc_stream_params *params, uint32_t flag) diff --git a/src/audio/component.c b/src/audio/component.c index 3acbc47f9e78..0186f5531dcd 100644 --- a/src/audio/component.c +++ b/src/audio/component.c @@ -153,6 +153,7 @@ int comp_set_state(struct comp_dev *dev, int cmd) return 0; } +EXPORT_SYMBOL(comp_set_state); void sys_comp_init(struct sof *sof) { @@ -419,6 +420,7 @@ void cir_buf_copy(void *src, void *src_addr, void *src_end, void *dst, } #endif +EXPORT_SYMBOL(audio_stream_copy); void audio_stream_copy_from_linear(const void *linear_source, int ioffset, struct audio_stream *sink, int ooffset, diff --git a/src/audio/data_blob.c b/src/audio/data_blob.c index 3edacc3edc82..3e6415d5d22e 100644 --- a/src/audio/data_blob.c +++ b/src/audio/data_blob.c @@ -102,6 +102,7 @@ void *comp_get_data_blob(struct comp_data_blob_handler *blob_handler, return blob_handler->data; } +EXPORT_SYMBOL(comp_get_data_blob); bool comp_is_new_data_blob_available(struct comp_data_blob_handler *blob_handler) @@ -119,6 +120,7 @@ bool comp_is_new_data_blob_available(struct comp_data_blob_handler return false; } +EXPORT_SYMBOL(comp_is_new_data_blob_available); bool comp_is_current_data_blob_valid(struct comp_data_blob_handler *blob_handler) @@ -162,6 +164,7 @@ int comp_init_data_blob(struct comp_data_blob_handler *blob_handler, return 0; } +EXPORT_SYMBOL(comp_init_data_blob); int comp_data_blob_set(struct comp_data_blob_handler *blob_handler, enum module_cfg_fragment_position pos, uint32_t data_offset_size, @@ -615,6 +618,7 @@ int comp_data_blob_get_cmd(struct comp_data_blob_handler *blob_handler, return ret; } +EXPORT_SYMBOL(comp_data_blob_get_cmd); static void *default_alloc(size_t size) { diff --git a/src/audio/eq_iir/Kconfig b/src/audio/eq_iir/Kconfig index 6c93059d9be8..2fee46d9a29f 100644 --- a/src/audio/eq_iir/Kconfig +++ b/src/audio/eq_iir/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause config COMP_IIR - bool "IIR component" + tristate "IIR component" select COMP_BLOB default y depends on COMP_MODULE_ADAPTER diff --git a/src/audio/eq_iir/eq_iir.c b/src/audio/eq_iir/eq_iir.c index 3c3312d1557c..f60f38ffd4b5 100644 --- a/src/audio/eq_iir/eq_iir.c +++ b/src/audio/eq_iir/eq_iir.c @@ -257,3 +257,23 @@ static const struct module_interface eq_iir_interface = { DECLARE_MODULE_ADAPTER(eq_iir_interface, eq_iir_uuid, eq_iir_tr); SOF_MODULE_INIT(eq_iir, sys_comp_module_eq_iir_interface_init); + +#if CONFIG_COMP_IIR_MODULE +/* modular: llext dynamic link */ + +#include +#include + +#include + +#define UUID_EQIIR 0xE6, 0xC0, 0x50, 0x51, 0xF9, 0x27, 0xC8, 0x4E, \ + 0x83, 0x51, 0xC7, 0x05, 0xB6, 0x42, 0xD1, 0x2F + +SOF_LLEXT_MOD_ENTRY(eq_iir, &eq_iir_interface); + +static const struct sof_man_module_manifest mod_manifest __section(".module") __used = + SOF_LLEXT_MODULE_MANIFEST("EQIIR", eq_iir_llext_entry, 1, UUID_EQIIR); + +SOF_LLEXT_BUILDINFO; + +#endif diff --git a/src/audio/eq_iir/eq_iir.toml b/src/audio/eq_iir/eq_iir.toml index e2a81bf8d495..f47020c648ac 100644 --- a/src/audio/eq_iir/eq_iir.toml +++ b/src/audio/eq_iir/eq_iir.toml @@ -1,3 +1,7 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + REM # eq iir module config [[module.entry]] name = "EQIIR" @@ -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/eq_iir/llext/CMakeLists.txt b/src/audio/eq_iir/llext/CMakeLists.txt new file mode 100644 index 000000000000..9bf8a4b4e7ef --- /dev/null +++ b/src/audio/eq_iir/llext/CMakeLists.txt @@ -0,0 +1,10 @@ +# 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/eq_iir/llext/llext.toml.h b/src/audio/eq_iir/llext/llext.toml.h new file mode 100644 index 000000000000..a5c40c9c2a2a --- /dev/null +++ b/src/audio/eq_iir/llext/llext.toml.h @@ -0,0 +1,6 @@ +#include +#define LOAD_TYPE "2" +#include "../eq_iir.toml" + +[module] +count = __COUNTER__ diff --git a/src/audio/mixin_mixout/Kconfig b/src/audio/mixin_mixout/Kconfig index 2315023d61d1..852b23f18e08 100644 --- a/src/audio/mixin_mixout/Kconfig +++ b/src/audio/mixin_mixout/Kconfig @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause config COMP_MIXIN_MIXOUT - bool "Mixin_mixout component" + tristate "Mixin_mixout component" depends on IPC_MAJOR_4 default y help diff --git a/src/audio/mixin_mixout/llext/CMakeLists.txt b/src/audio/mixin_mixout/llext/CMakeLists.txt new file mode 100644 index 000000000000..a9743e379d54 --- /dev/null +++ b/src/audio/mixin_mixout/llext/CMakeLists.txt @@ -0,0 +1,11 @@ +# 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/audio/mixin_mixout/llext/llext.toml.h b/src/audio/mixin_mixout/llext/llext.toml.h new file mode 100644 index 000000000000..bfadd2c55a96 --- /dev/null +++ b/src/audio/mixin_mixout/llext/llext.toml.h @@ -0,0 +1,6 @@ +#include +#define LOAD_TYPE "2" +#include "../mixin_mixout.toml" + +[module] +count = __COUNTER__ diff --git a/src/audio/mixin_mixout/mixin_mixout.c b/src/audio/mixin_mixout/mixin_mixout.c index 576b46bb31f7..a9efde4cb25e 100644 --- a/src/audio/mixin_mixout/mixin_mixout.c +++ b/src/audio/mixin_mixout/mixin_mixout.c @@ -31,7 +31,7 @@ #include "mixin_mixout.h" -LOG_MODULE_REGISTER(mixer, CONFIG_SOF_LOG_LEVEL); +LOG_MODULE_REGISTER(mixin_mixout, CONFIG_SOF_LOG_LEVEL); /* mixin 39656eb2-3b71-4049-8d3f-f92cd5c43c09 */ DECLARE_SOF_RT_UUID("mix_in", mixin_uuid, 0x39656eb2, 0x3b71, 0x4049, @@ -964,3 +964,29 @@ static const struct module_interface mixout_interface = { DECLARE_MODULE_ADAPTER(mixout_interface, mixout_uuid, mixout_tr); SOF_MODULE_INIT(mixout, sys_comp_module_mixout_interface_init); + +#if CONFIG_COMP_MIXIN_MIXOUT_MODULE +/* modular: llext dynamic link */ + +#include +#include + +#include + +#define UUID_MIXIN 0xB2, 0x6E, 0x65, 0x39, 0x71, 0x3B, 0x49, 0x40, \ + 0x8D, 0x3F, 0xF9, 0x2C, 0xD5, 0xC4, 0x3C, 0x09 +#define UUID_MIXOUT 0x5A, 0x50, 0x56, 0x3C, 0xD7, 0x24, 0x8F, 0x41, \ + 0xBD, 0xDC, 0xC1, 0xF5, 0xA3, 0xAC, 0x2A, 0xE0 + +SOF_LLEXT_MOD_ENTRY(mixin, &mixin_interface); +SOF_LLEXT_MOD_ENTRY(mixout, &mixout_interface); + +static const struct sof_man_module_manifest mod_manifest[] __section(".module") __used = +{ + SOF_LLEXT_MODULE_MANIFEST("MIXIN", mixin_llext_entry, 1, UUID_MIXIN), + SOF_LLEXT_MODULE_MANIFEST("MIXOUT", mixout_llext_entry, 1, UUID_MIXOUT), +}; + +SOF_LLEXT_BUILDINFO; + +#endif diff --git a/src/audio/mixin_mixout/mixin_mixout.toml b/src/audio/mixin_mixout/mixin_mixout.toml index 9aedd0c7dc9d..4e799f86bdbf 100644 --- a/src/audio/mixin_mixout/mixin_mixout.toml +++ b/src/audio/mixin_mixout/mixin_mixout.toml @@ -1,10 +1,14 @@ +#ifndef LOAD_TYPE +#define LOAD_TYPE "0" +#endif + [[module.entry]] name = "MIXIN" uuid = "39656EB2-3B71-4049-8D3F-F92CD5C43C09" affinity_mask = "0x1" instance_count = "30" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE module_type = "1" auto_start = "0" sched_caps = [1, 0x00008000] @@ -30,7 +34,7 @@ affinity_mask = "0x1" instance_count = "30" domain_types = "0" - load_type = "0" + load_type = LOAD_TYPE module_type = "2" auto_start = "0" sched_caps = [1, 0x00008000] diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index f593166f56a8..85e6f4cadff8 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -11,6 +11,8 @@ * */ +#include + #include LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL); @@ -537,3 +539,4 @@ void module_update_buffer_position(struct input_stream_buffer *input_buffers, input_buffers->consumed += audio_stream_frame_bytes(source) * frames; output_buffers->size += audio_stream_frame_bytes(sink) * frames; } +EXPORT_SYMBOL(module_update_buffer_position); diff --git a/src/include/module/module/llext.h b/src/include/module/module/llext.h new file mode 100644 index 000000000000..61532e3fb70f --- /dev/null +++ b/src/include/module/module/llext.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* + * Copyright(c) 2024 Intel Corporation. All rights reserved. + */ + +#ifndef MODULE_LLEXT_H +#define MODULE_LLEXT_H + +#define SOF_LLEXT_MODULE_MANIFEST(manifest_name, entry, affinity, mod_uuid) \ +{ \ + .module = { \ + .name = manifest_name, \ + .uuid = {mod_uuid}, \ + .entry_point = (uint32_t)(entry), \ + .type = { \ + .load_type = SOF_MAN_MOD_TYPE_LLEXT, \ + .domain_ll = 1, \ + }, \ + .affinity_mask = (affinity), \ + } \ +} + +#define SOF_LLEXT_MOD_ENTRY(name, interface) \ +static const struct module_interface *name##_llext_entry(void *mod_cfg, \ + void *parent_ppl, void **mod_ptr) \ +{ \ + return interface; \ +} + +#define SOF_LLEXT_BUILDINFO \ +static const struct sof_module_api_build_info buildinfo __section(".mod_buildinfo") __used = { \ + .format = SOF_MODULE_API_BUILD_INFO_FORMAT, \ + .api_version_number.full = SOF_MODULE_API_CURRENT_VERSION, \ +} + +#endif diff --git a/src/include/sof/common.h b/src/include/sof/common.h index 349b806e08a8..6968f3ba44e5 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -117,7 +117,7 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif #define container_of(ptr, type, member) \ - ({const typeof(((type *)0)->member)*__memberptr = (ptr); \ + ({const __typeof__(((type *)0)->member)*__memberptr = (ptr); \ (type *)((char *)__memberptr - offsetof(type, member)); }) /* * typeof() doesn't preserve __attribute__((address_space(x))) sparse @@ -127,7 +127,7 @@ * re-inforce the address space onto the new pointer. */ #define attr_container_of(ptr, type, member, attr) \ - ({const typeof(((type *)0)->member) attr *__memberptr = (ptr); \ + ({const __typeof__(((type *)0)->member) attr *__memberptr = (ptr); \ (type *)((char attr *)__memberptr - offsetof(type, member)); }) #define ffs(i) __builtin_ffs(i) @@ -219,7 +219,7 @@ * alignment. This compiler builtin may not be available on all compilers so * this macro can be defined as NULL if needed. */ -#define ASSUME_ALIGNED(x, a) ((typeof(x))__builtin_assume_aligned((x), a)) +#define ASSUME_ALIGNED(x, a) ((__typeof__(x))__builtin_assume_aligned((x), a)) #endif /* __XCC__ */ #endif /* __ASSEMBLER__ */ diff --git a/src/include/sof/debug/debug.h b/src/include/sof/debug/debug.h index 9a836b1b443d..8103da3012b8 100644 --- a/src/include/sof/debug/debug.h +++ b/src/include/sof/debug/debug.h @@ -140,7 +140,7 @@ /* swap an endianness of 32-bit word */ #define bswap32(N) ({ \ - typeof(N) n = (N); \ + __typeof__(N) n = (N); \ ((n & 0x000000FF) << 24) | \ ((n & 0x0000FF00) << 8) | \ ((n & 0x00FF0000) >> 8) | \ @@ -153,10 +153,10 @@ */ #define dump_hex(ptr, idx, len) \ do { \ - typeof(idx) __i = (idx); \ - typeof(ptr) __p = (ptr) + __i; \ - typeof(idx) __l = (len) - __i; \ - typeof(idx) __n = __l > 4 ? 4 : __l; \ + __typeof__(idx) __i = (idx); \ + __typeof__(ptr) __p = (ptr) + __i; \ + __typeof__(idx) __l = (len) - __i; \ + __typeof__(idx) __n = __l > 4 ? 4 : __l; \ if (__n == 4) { \ comp_info(dev, "%08x%08x%08x%08x", bswap32(__p[0]), bswap32(__p[1]), \ bswap32(__p[2]), bswap32(__p[3])); \ diff --git a/src/include/sof/math/numbers.h b/src/include/sof/math/numbers.h index 6ecfc9024463..1fd61f6324eb 100644 --- a/src/include/sof/math/numbers.h +++ b/src/include/sof/math/numbers.h @@ -20,18 +20,18 @@ #define MAX(a, b) ((a) < (b) ? (b) : (a)) #define ROUND_DOWN(size, alignment) ({ \ - typeof(size) __size = (size); \ - typeof(alignment) __alignment = (alignment); \ + __typeof__(size) __size = (size); \ + __typeof__(alignment) __alignment = (alignment); \ __size - (__size % __alignment); \ }) #endif /* ! __ZEPHYR__ */ #define ABS(a) ({ \ - typeof(a) __a = (a); \ + __typeof__(a) __a = (a); \ __a < 0 ? -__a : __a; \ }) #define SGN(a) ({ \ - typeof(a) __a = (a); \ + __typeof__(a) __a = (a); \ __a < 0 ? -1 : \ __a > 0 ? 1 : 0; \ }) diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 572515365db4..8d4258627bf2 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -1019,6 +1019,7 @@ struct comp_dev *ipc4_get_comp_dev(uint32_t comp_id) return icd ? icd->cd : NULL; } +EXPORT_SYMBOL(ipc4_get_comp_dev); int ipc4_add_comp_dev(struct comp_dev *dev) { diff --git a/src/library_manager/lib_manager.c b/src/library_manager/lib_manager.c index ad6a9da02c88..9c4f071d0baa 100644 --- a/src/library_manager/lib_manager.c +++ b/src/library_manager/lib_manager.c @@ -557,6 +557,8 @@ static struct comp_dev *lib_manager_module_create(const struct comp_driver *drv, struct processing_module *mod = comp_get_drvdata(dev); mod->priv.llext = tmp_proc.priv.llext; + } else { + lib_manager_free_module(module_id); } return dev; } diff --git a/src/library_manager/llext_manager.c b/src/library_manager/llext_manager.c index 9d32023b2aa5..23c35eb3d15d 100644 --- a/src/library_manager/llext_manager.c +++ b/src/library_manager/llext_manager.c @@ -241,12 +241,13 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc, const void *ipc_specific_config) { struct sof_man_fw_desc *desc; - struct sof_man_module *mod; + struct sof_man_module *mod, *mod_array; int ret; uint32_t module_id = IPC4_MOD_ID(ipc_config->id); uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(module_id); struct lib_manager_mod_ctx *ctx = lib_manager_get_mod_ctx(module_id); const struct sof_module_api_build_info *buildinfo; + const struct sof_man_module_manifest *mod_manifest; tr_dbg(&lib_manager_tr, "llext_manager_allocate_module(): mod_id: %#x", ipc_config->id); @@ -258,10 +259,12 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc, return 0; } - mod = (struct sof_man_module *)((char *)desc + SOF_MAN_MODULE_OFFSET(entry_index)); + mod_array = (struct sof_man_module *)((char *)desc + SOF_MAN_MODULE_OFFSET(0)); + mod = mod_array + entry_index; - ret = llext_manager_link(desc, mod, module_id, &proc->priv, (const void **)&buildinfo, - &ctx->mod_manifest); + /* LLEXT linking is only needed once for all the modules in the library */ + ret = llext_manager_link(desc, mod_array, module_id, &proc->priv, (const void **)&buildinfo, + &mod_manifest); if (ret < 0) return 0; @@ -274,6 +277,9 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc, return -ENOEXEC; } + /* ctx->mod_manifest points to the array of module manifests */ + ctx->mod_manifest = mod_manifest; + /* Map .text and the rest as .data */ ret = llext_manager_load_module(module_id, mod); if (ret < 0) @@ -288,24 +294,26 @@ uintptr_t llext_manager_allocate_module(struct processing_module *proc, } } - return ctx->mod_manifest->module.entry_point; + return ctx->mod_manifest[entry_index].module.entry_point; } int llext_manager_free_module(const uint32_t component_id) { const struct sof_man_module *mod; const uint32_t module_id = IPC4_MOD_ID(component_id); + const unsigned int base_module_id = LIB_MANAGER_GET_LIB_ID(module_id) << + LIB_MANAGER_LIB_ID_SHIFT; int ret; tr_dbg(&lib_manager_tr, "llext_manager_free_module(): mod_id: %#x", component_id); - mod = lib_manager_get_module_manifest(module_id); + mod = lib_manager_get_module_manifest(base_module_id); - ret = llext_manager_unload_module(module_id, mod); + ret = llext_manager_unload_module(base_module_id, mod); if (ret < 0) return ret; - ret = llext_manager_free_module_bss(module_id, mod); + ret = llext_manager_free_module_bss(base_module_id, mod); if (ret < 0) { tr_err(&lib_manager_tr, "llext_manager_free_module(): free module bss failed: %d", ret); diff --git a/src/math/iir_df1.c b/src/math/iir_df1.c index df9f8f1a6e05..861c5cd2cf19 100644 --- a/src/math/iir_df1.c +++ b/src/math/iir_df1.c @@ -12,6 +12,8 @@ #include #include +#include + int iir_delay_size_df1(struct sof_eq_iir_header *config) { int n = config->num_sections; /* One section uses two unit delays */ @@ -21,6 +23,7 @@ int iir_delay_size_df1(struct sof_eq_iir_header *config) return 4 * n * sizeof(int32_t); } +EXPORT_SYMBOL(iir_delay_size_df1); int iir_init_coef_df1(struct iir_state_df1 *iir, struct sof_eq_iir_header *config) @@ -31,6 +34,7 @@ int iir_init_coef_df1(struct iir_state_df1 *iir, return 0; } +EXPORT_SYMBOL(iir_init_coef_df1); void iir_init_delay_df1(struct iir_state_df1 *iir, int32_t **delay) { @@ -40,6 +44,7 @@ void iir_init_delay_df1(struct iir_state_df1 *iir, int32_t **delay) /* Point to next IIR delay line start. */ *delay += 4 * iir->biquads; } +EXPORT_SYMBOL(iir_init_delay_df1); void iir_reset_df1(struct iir_state_df1 *iir) { @@ -50,3 +55,4 @@ void iir_reset_df1(struct iir_state_df1 *iir) * omitting setting iir->delay to NULL. */ } +EXPORT_SYMBOL(iir_reset_df1); diff --git a/src/math/iir_df1_generic.c b/src/math/iir_df1_generic.c index 1be36e0a222e..6e6482259569 100644 --- a/src/math/iir_df1_generic.c +++ b/src/math/iir_df1_generic.c @@ -11,6 +11,8 @@ #include #include +#include + #if SOF_USE_HIFI(NONE, FILTER) /* @@ -105,5 +107,6 @@ int32_t iir_df1(struct iir_state_df1 *iir, int32_t x) } return sat_int32(out); } +EXPORT_SYMBOL(iir_df1); #endif diff --git a/src/math/iir_df1_hifi3.c b/src/math/iir_df1_hifi3.c index 39be8e3a6e54..d1aa05f55c0d 100644 --- a/src/math/iir_df1_hifi3.c +++ b/src/math/iir_df1_hifi3.c @@ -12,6 +12,8 @@ #include #include +#include + #if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) /* @@ -122,5 +124,6 @@ int32_t iir_df1(struct iir_state_df1 *iir, int32_t x) } return out; } +EXPORT_SYMBOL(iir_df1); #endif diff --git a/src/math/numbers.c b/src/math/numbers.c index 72efb20fcf01..46ee9c9ac732 100644 --- a/src/math/numbers.c +++ b/src/math/numbers.c @@ -175,3 +175,6 @@ uint32_t crc32(uint32_t base, const void *data, uint32_t bytes) return ~crc; } + +uint64_t __udivdi3(uint64_t a, uint64_t b); +EXPORT_SYMBOL(__udivdi3); diff --git a/src/module/audio/sink_api.c b/src/module/audio/sink_api.c index a454dbb76706..856a6bb5689e 100644 --- a/src/module/audio/sink_api.c +++ b/src/module/audio/sink_api.c @@ -67,16 +67,19 @@ int sink_set_frm_fmt(struct sof_sink *sink, enum sof_ipc_frame frame_fmt) return sink->ops->on_audio_format_set(sink); return 0; } +EXPORT_SYMBOL(sink_set_frm_fmt); size_t sink_get_frame_bytes(struct sof_sink *sink) { return get_frame_bytes(sink_get_frm_fmt(sink), sink_get_channels(sink)); } +EXPORT_SYMBOL(sink_get_frame_bytes); size_t sink_get_free_frames(struct sof_sink *sink) { return sink_get_free_size(sink) / sink_get_frame_bytes(sink); } +EXPORT_SYMBOL(sink_get_free_frames); int sink_set_valid_fmt(struct sof_sink *sink, enum sof_ipc_frame valid_sample_fmt) { @@ -85,6 +88,7 @@ int sink_set_valid_fmt(struct sof_sink *sink, enum sof_ipc_frame valid_sample_fm return sink->ops->on_audio_format_set(sink); return 0; } +EXPORT_SYMBOL(sink_set_valid_fmt); int sink_set_rate(struct sof_sink *sink, unsigned int rate) { @@ -101,6 +105,7 @@ int sink_set_channels(struct sof_sink *sink, unsigned int channels) return sink->ops->on_audio_format_set(sink); return 0; } +EXPORT_SYMBOL(sink_set_channels); int sink_set_buffer_fmt(struct sof_sink *sink, uint32_t buffer_fmt) { diff --git a/src/module/audio/source_api.c b/src/module/audio/source_api.c index 33e62fc6ab2a..b74a6716b344 100644 --- a/src/module/audio/source_api.c +++ b/src/module/audio/source_api.c @@ -62,6 +62,7 @@ size_t source_get_frame_bytes(struct sof_source *source) return get_frame_bytes(source_get_frm_fmt(source), source_get_channels(source)); } +EXPORT_SYMBOL(source_get_frame_bytes); size_t source_get_data_frames_available(struct sof_source *source) { @@ -72,3 +73,4 @@ size_t source_get_data_frames_available(struct sof_source *source) else return 0; } +EXPORT_SYMBOL(source_get_data_frames_available); diff --git a/src/samples/audio/smart_amp_test_ipc4.c b/src/samples/audio/smart_amp_test_ipc4.c index 789f70a5b149..c0d6acc872aa 100644 --- a/src/samples/audio/smart_amp_test_ipc4.c +++ b/src/samples/audio/smart_amp_test_ipc4.c @@ -404,22 +404,19 @@ SOF_MODULE_INIT(smart_amp_test, sys_comp_module_smart_amp_test_interface_init); #endif -#ifdef MAJOR_IADSP_API_VERSION +#if defined(MAJOR_IADSP_API_VERSION) || defined(CONFIG_SAMPLE_SMART_AMP_MODULE) /* modular: system-services or dynamic link */ -static const struct module_interface *loadable_module_main(void *mod_cfg, - void *parent_ppl, - void **mod_ptr) -{ - return &smart_amp_test_interface; -} +#include + +SOF_LLEXT_MOD_ENTRY(smart_amp_test, &smart_amp_test_interface); static const struct sof_man_module_manifest main_manifest __section(".module") __attribute__((used)) = { .module = { .name = "SMATEST", .uuid = {0x1E, 0x96, 0x7A, 0x16, 0xE4, 0x8A, 0xEA, 0x11, 0x89, 0xF1, 0x00, 0x0C, 0x29, 0xCE, 0x16, 0x35}, - .entry_point = (uint32_t)loadable_module_main, + .entry_point = (uint32_t)smart_amp_test_llext_entry, .type = { #ifdef __SOF_MODULE_SERVICE_BUILD__ .load_type = SOF_MAN_MOD_TYPE_MODULE, @@ -440,10 +437,7 @@ DECLARE_LOADABLE_MODULE_API_VERSION(smart_amp_test); #else /* dynamic link */ -static const struct sof_module_api_build_info buildinfo __section(".mod_buildinfo") __attribute__((used)) = { - .format = SOF_MODULE_API_BUILD_INFO_FORMAT, - .api_version_number.full = SOF_MODULE_API_CURRENT_VERSION, -}; +SOF_LLEXT_BUILDINFO; #endif diff --git a/src/samples/audio/smart_amp_test_llext/CMakeLists.txt b/src/samples/audio/smart_amp_test_llext/CMakeLists.txt index 265290e38a75..873eb61de81b 100644 --- a/src/samples/audio/smart_amp_test_llext/CMakeLists.txt +++ b/src/samples/audio/smart_amp_test_llext/CMakeLists.txt @@ -1,102 +1,8 @@ # Copyright (c) 2023 Intel Corporation. # SPDX-License-Identifier: Apache-2.0 -# FIXME: This *WILL* be converted to add_llext_target() as long as that's -# reasonably possible, and if it isn't, a *significant* effort will be made to -# make that possible - -cmake_minimum_required(VERSION 3.20.0) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(smart_amp_test) - -SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) - -set(MODULE "smart_amp_test") -cmake_path(SET SOF_BASE NORMALIZE ${PROJECT_SOURCE_DIR}/../../../..) - -file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/../${MODULE}.toml uuids REGEX "^[ \t]*uuid *=") - -file(WRITE ${PROJECT_BINARY_DIR}/llext.uuid "") - -foreach(line IN LISTS uuids) - # extract UUID value - drop the 'uuid = ' part of the assignment line - string(REGEX REPLACE "^[ \t]*uuid *= \"([0-9A-F\-]*)\"" "\\1" uuid ${line}) - file(APPEND ${PROJECT_BINARY_DIR}/llext.uuid "${uuid}\n") -endforeach() - -add_library(${MODULE} SHARED) - -target_sources(${MODULE} PRIVATE - ${CMAKE_CURRENT_LIST_DIR}/../smart_amp_test_ipc4.c -) - -sof_append_relative_path_definitions(${MODULE}) - -target_include_directories(${MODULE} PRIVATE - "${ZEPHYR_BASE}/include" - "${ZEPHYR_BASE}/soc/intel/intel_adsp/common/include" - "${ZEPHYR_BASE}/soc/intel/intel_adsp/ace/include/ace15_mtpm" - "${ZEPHYR_BASE}/../modules/hal/xtensa/include" - "${ZEPHYR_BASE}/../modules/hal/xtensa/zephyr/soc/intel_ace15_mtpm" - "${SOF_BASE}/src/include" - "${SOF_BASE}/src/arch/xtensa/include" - "${SOF_BASE}/src/platform/meteorlake/include" - "${SOF_BASE}/src/platform/intel/ace/include" - "${SOF_BASE}/src/include/sof/audio/module_adapter/iadk" - "${SOF_BASE}/zephyr/include" - "${SOF_BASE}/xtos/include" - "${SOF_BASE}/tools/rimage/src/include" - "${PROJECT_BINARY_DIR}/../include/generated" -) - -set(MODULE_PROPERTIES HPSRAM_ADDR "0xa06c1000") -set_target_properties(${MODULE} PROPERTIES ${MODULE_PROPERTIES}) - -set(MODULE_COMPILE_DEF - __ZEPHYR__=1 - __XTENSA__ - KERNEL - MAJOR_IADSP_API_VERSION=5 - MIDDLE_IADSP_API_VERSION=0 - MINOR_IADSP_API_VERSION=0 -) -target_compile_definitions(${MODULE} PRIVATE ${MODULE_COMPILE_DEF}) - -target_compile_options(${MODULE} PRIVATE - -imacros${PROJECT_BINARY_DIR}/../include/generated/autoconf.h - -save-temps -O2 -) - -if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr") -set(MODULE_LINKER_PARAMS -nostdlib -nodefaultlibs) -set(EXTRA_LINKER_PARAMS -shared) -set(COPY_CMD ${CMAKE_STRIP} -R .xt.* -o ${MODULE}.so ${MODULE}_pre.so) -else() -set(MODULE_LINKER_PARAMS -nostdlib -nodefaultlibs -r) -set(EXTRA_LINKER_PARAMS) -set(COPY_CMD ${CMAKE_OBJCOPY} -R .xt.* ${MODULE}_pre.so ${MODULE}.so) -endif() - -target_link_options(${MODULE} PRIVATE - ${MODULE_LINKER_PARAMS} -) - -add_custom_command(OUTPUT lib${MODULE}_out.so - DEPENDS ${MODULE} - COMMAND ${CMAKE_C_COMPILER} -E ${CMAKE_CURRENT_LIST_DIR}/llext.toml.h -P -DREM= - -I${SOF_BASE} -I${SOF_BASE}src - -imacros ../include/generated/autoconf.h - -o rimage_config.toml - COMMAND ${SOF_BASE}scripts/llext_link_helper.py - -f lib${MODULE}.so -t "0xa06ca000" ${CMAKE_C_COMPILER} -- - ${MODULE_LINKER_PARAMS} ${EXTRA_LINKER_PARAMS} -fPIC - -o ${MODULE}_pre.so $ - COMMAND ${COPY_CMD} - COMMAND_EXPAND_LISTS +# 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 ) - -add_custom_target(${MODULE}_llext ALL - DEPENDS lib${MODULE}_out.so -) - -add_dependencies(${MODULE} zephyr_interface) diff --git a/tools/rimage/config/mtl.toml.h b/tools/rimage/config/mtl.toml.h index a1c23dbcba2c..9efd19360469 100644 --- a/tools/rimage/config/mtl.toml.h +++ b/tools/rimage/config/mtl.toml.h @@ -24,7 +24,9 @@ index = __COUNTER__ +#ifdef CONFIG_COMP_MIXIN_MIXOUT #include