Skip to content

Commit d0f40d9

Browse files
committed
library-manager: make disabling INTEL_MODULES possible
IADK is rarely needed, but when enabled it adds C++ objects to the build, while otherwise builds are pure C. Disabling INTEL_MODULES however is currently broken. Fix it to make modular builds without IADK support possible. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent fc9edf7 commit d0f40d9

3 files changed

Lines changed: 29 additions & 15 deletions

File tree

src/audio/module_adapter/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ if(zephyr) ### Zephyr ###
2525
zephyr_library_import(xa_mp3_enc ${CONFIG_CADENCE_CODEC_MP3_ENC_LIB})
2626
endif()
2727

28-
zephyr_include_directories_ifdef(CONFIG_INTEL_MODULES
28+
zephyr_include_directories_ifdef(CONFIG_LIBRARY_MANAGER
2929
${SOF_SRC_PATH}/include/sof/audio/module_adapter/iadk/
3030
${SOF_SRC_PATH}/include/sof/audio/module_adapter/library/
3131
)
3232

33+
zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER
34+
library/native_system_agent.c
35+
)
36+
3337
zephyr_library_sources_ifdef(CONFIG_INTEL_MODULES
3438
module/modules.c
3539
iadk/module_initial_settings_concrete.cpp
3640
iadk/iadk_module_adapter.cpp
3741
iadk/system_agent.cpp
38-
library/native_system_agent.c
3942
library/native_system_service.c
4043
)
4144

src/include/sof/audio/module_adapter/library/native_system_service.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#define NATIVE_SYSTEM_SERVICE_H
88

99
#include <stdint.h>
10-
#include <adsp_stddef.h>
1110

1211
#ifdef __cplusplus
1312
extern "C" {

src/library_manager/lib_manager.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ const struct sof_man_module *lib_manager_get_module_manifest(const uint32_t modu
485485
SOF_MAN_MODULE_OFFSET(entry_index));
486486
}
487487

488-
#if CONFIG_INTEL_MODULES
489488
/*
490489
* \brief Load module code, allocate its instance and create a module adapter component.
491490
* \param[in] drv - component driver pointer.
@@ -584,7 +583,18 @@ static void lib_manager_prepare_module_adapter(struct comp_driver *drv, const st
584583
drv->ops.dai_ts_start = module_adapter_ts_start_op;
585584
drv->ops.dai_ts_stop = module_adapter_ts_stop_op;
586585
drv->ops.dai_ts_get = module_adapter_ts_get_op;
586+
#if CONFIG_INTEL_MODULES
587587
drv->adapter_ops = &processing_module_adapter_interface;
588+
#endif
589+
}
590+
591+
static const struct sof_module_api_build_info *lib_manager_get_build_info(
592+
const struct sof_man_fw_desc *desc,
593+
const struct sof_man_module *mod)
594+
{
595+
return (const struct sof_module_api_build_info *)((const uint8_t *)desc -
596+
SOF_MAN_ELF_TEXT_OFFSET +
597+
mod->segment[SOF_MAN_SEGMENT_TEXT].file_offset);
588598
}
589599

590600
int lib_manager_register_module(const uint32_t component_id)
@@ -638,9 +648,7 @@ int lib_manager_register_module(const uint32_t component_id)
638648
* llext modules store build info structure in separate section which is not accessible now.
639649
*/
640650
if (!module_is_llext(mod)) {
641-
build_info = (const struct sof_module_api_build_info *)((const char *)desc -
642-
SOF_MAN_ELF_TEXT_OFFSET +
643-
mod->segment[SOF_MAN_SEGMENT_TEXT].file_offset);
651+
build_info = lib_manager_get_build_info(desc, mod);
644652

645653
tr_info(&lib_manager_tr, "Module API version: %u.%u.%u, format: 0x%x",
646654
build_info->api_version_number.fields.major,
@@ -679,14 +687,6 @@ int lib_manager_register_module(const uint32_t component_id)
679687
return ret;
680688
}
681689

682-
#else /* CONFIG_INTEL_MODULES */
683-
int lib_manager_register_module(const uint32_t component_id)
684-
{
685-
tr_err(&lib_manager_tr, "Dynamic module loading is not supported");
686-
return -ENOTSUP;
687-
}
688-
#endif /* CONFIG_INTEL_MODULES */
689-
690690
static int lib_manager_dma_buffer_alloc(struct lib_manager_dma_ext *dma_ext,
691691
uint32_t size)
692692
{
@@ -831,6 +831,7 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext,
831831
void __sparse_cache *library_base_address;
832832
const struct sof_man_fw_desc *man_desc = (struct sof_man_fw_desc *)
833833
((__sparse_force uint8_t *)man_buffer + SOF_MAN_ELF_TEXT_OFFSET);
834+
const struct sof_man_module *mod = (const struct sof_man_module *)(man_desc + 1);
834835
uint32_t preload_size = man_desc->header.preload_page_count * PAGE_SZ;
835836
int ret;
836837

@@ -843,6 +844,17 @@ static int lib_manager_store_library(struct lib_manager_dma_ext *dma_ext,
843844
return -EINVAL;
844845
}
845846

847+
if (!IS_ENABLED(CONFIG_INTEL_MODULES) && !module_is_llext(mod)) {
848+
const struct sof_module_api_build_info *build_info =
849+
lib_manager_get_build_info(man_desc, mod);
850+
851+
if (build_info->format == IADK_MODULE_API_BUILD_INFO_FORMAT &&
852+
build_info->api_version_number.full == IADK_MODULE_API_CURRENT_VERSION) {
853+
tr_err(&lib_manager_tr, "Unsupported module type %u", mod->type.load_type);
854+
return -ENOTSUP;
855+
}
856+
}
857+
846858
/* Prepare storage memory, note: it is never freed, library unloading is unsupported */
847859
/*
848860
* Prepare storage memory, note: it is never freed, it is assumed, that this

0 commit comments

Comments
 (0)