From 0b905859c4e27cc82015c3111674c5463d97e82a Mon Sep 17 00:00:00 2001 From: Jun Lai Date: Wed, 12 Nov 2025 10:06:33 +0800 Subject: [PATCH] audio: codec_adapter: add llext support for dax LLEXT support for dax. Signed-off-by: Jun Lai --- app/overlays/mtl/dax_overlay.conf | 7 ++ src/audio/module_adapter/CMakeLists.txt | 25 ++++--- src/audio/module_adapter/Kconfig | 3 +- src/audio/module_adapter/module/dolby/dax.c | 27 +++++++ .../module_adapter/module/dolby/llext-wrap.c | 75 +++++++++++++++++++ .../module/dolby/llext/CMakeLists.txt | 17 +++++ .../module/dolby/llext/llext.toml.h | 10 +++ 7 files changed, 153 insertions(+), 11 deletions(-) create mode 100644 src/audio/module_adapter/module/dolby/llext-wrap.c create mode 100644 src/audio/module_adapter/module/dolby/llext/CMakeLists.txt create mode 100644 src/audio/module_adapter/module/dolby/llext/llext.toml.h diff --git a/app/overlays/mtl/dax_overlay.conf b/app/overlays/mtl/dax_overlay.conf index 41423daa3cb8..f73f79addf32 100644 --- a/app/overlays/mtl/dax_overlay.conf +++ b/app/overlays/mtl/dax_overlay.conf @@ -2,3 +2,10 @@ CONFIG_COMP_MODULE_ADAPTER=y CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING=y CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING_MOCK=n CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL=n +CONFIG_SOF_STACK_SIZE=8192 + +# LLEXT +CONFIG_LLEXT_HEAP_SIZE=32 +# Disabled due to issues encountered on the MTL platform. +# See https://github.com/thesofproject/sof/issues/10370 +CONFIG_LLEXT_EXPERIMENTAL=n diff --git a/src/audio/module_adapter/CMakeLists.txt b/src/audio/module_adapter/CMakeLists.txt index ab15558d361d..1f137c217057 100644 --- a/src/audio/module_adapter/CMakeLists.txt +++ b/src/audio/module_adapter/CMakeLists.txt @@ -26,17 +26,24 @@ if(zephyr) ### Zephyr ### endif() if (CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING) - zephyr_library_sources( - module/dolby/dax.c - ) - if (CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING_MOCK) + if(CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING STREQUAL "m" AND DEFINED CONFIG_LLEXT) + add_subdirectory(module/dolby/llext + ${PROJECT_BINARY_DIR}/dolby_dax_audio_processing_llext) + add_dependencies(app dolby_dax_audio_processing) + else() zephyr_library_sources( - module/dolby/dax_mock.c + module/dolby/dax.c ) - else() - target_link_libraries(SOF INTERFACE m) - target_link_libraries(SOF INTERFACE c) - zephyr_library_import(dax_effect ${sof_top_dir}/third_party/lib/libdax.a) + if (CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING_MOCK) + zephyr_library_sources( + module/dolby/dax_mock.c + ) + else() + target_link_libraries(SOF INTERFACE m) + target_link_libraries(SOF INTERFACE c) + zephyr_library_import(dax_effect + ${sof_top_dir}/third_party/lib/libdax.a) + endif() endif() endif() diff --git a/src/audio/module_adapter/Kconfig b/src/audio/module_adapter/Kconfig index b4a7b36c18d7..a9f88dd1f2ad 100644 --- a/src/audio/module_adapter/Kconfig +++ b/src/audio/module_adapter/Kconfig @@ -176,8 +176,7 @@ if CADENCE_CODEC endif # Cadence config COMP_DOLBY_DAX_AUDIO_PROCESSING - bool "Dolby DAX audio processing component" - default n + tristate "Dolby DAX audio processing component" help Select to include Dolby DAX component. Dolby DAX component implements DAX API. API definition together with pre-compiled library is shared by Dolby. diff --git a/src/audio/module_adapter/module/dolby/dax.c b/src/audio/module_adapter/module/dolby/dax.c index e5998f15fc71..eaf6bfd9b03b 100644 --- a/src/audio/module_adapter/module/dolby/dax.c +++ b/src/audio/module_adapter/module/dolby/dax.c @@ -814,7 +814,34 @@ static const struct module_interface dolby_dax_audio_processing_interface = { .free = sof_dax_free, }; +#if CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING_MODULE +/* modular: llext dynamic link */ + +#include +#include +#include + +static const struct sof_man_module_manifest main_manifest __section(".module") __used = { + .module = { + .name = "DAX", + .uuid = SOF_REG_UUID(dolby_dax_audio_processing), + .entry_point = (uint32_t)(&dolby_dax_audio_processing_interface), + .instance_max_count = 1, + .type = { + .load_type = SOF_MAN_MOD_TYPE_LLEXT, + .domain_dp = 1, + }, + .affinity_mask = 7, + } +}; + +SOF_LLEXT_BUILDINFO; + +#else + DECLARE_MODULE_ADAPTER(dolby_dax_audio_processing_interface, dolby_dax_audio_processing_uuid, dolby_dax_audio_processing_tr); SOF_MODULE_INIT(dolby_dax_audio_processing, sys_comp_module_dolby_dax_audio_processing_interface_init); + +#endif diff --git a/src/audio/module_adapter/module/dolby/llext-wrap.c b/src/audio/module_adapter/module/dolby/llext-wrap.c new file mode 100644 index 000000000000..30c7be24e22b --- /dev/null +++ b/src/audio/module_adapter/module/dolby/llext-wrap.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2025 Intel Corporation. All rights reserved. + +#include +#include +#include +#include + +/* + * Stubs that are needed for linkage of some applications or libraries + * that come from porting userspace code. Anyone porting should + * make sure that any code does not depend on working copies of these + * reentrant functions. We will fail for any caller. + */ + +struct stat; +struct _reent; + +size_t _read_r(struct _reent *ptr, int fd, char *buf, size_t cnt) +{ + errno = -ENOTSUP; + return -ENOTSUP; +} + +size_t _write_r(struct _reent *ptr, int fd, char *buf, size_t cnt) +{ + errno = -ENOTSUP; + return -ENOTSUP; +} + +void *_sbrk_r(struct _reent *ptr, ptrdiff_t incr) +{ + errno = -ENOTSUP; + return NULL; +} + +int _lseek_r(struct _reent *ptr, int fd, int pos, int whence) +{ + errno = -ENOTSUP; + return -ENOTSUP; +} + +int _kill_r(struct _reent *ptr, int pid, int sig) +{ + errno = -ENOTSUP; + return -ENOTSUP; +} + +int _getpid_r(struct _reent *ptr) +{ + errno = -ENOTSUP; + return -ENOTSUP; +} + +int _fstat_r(struct _reent *ptr, int fd, struct stat *pstat) +{ + errno = -ENOTSUP; + return -ENOTSUP; +} + +int _close_r(struct _reent *ptr, int fd) +{ + errno = -ENOTSUP; + return -ENOTSUP; +} + +void _exit(int status) +{ + assert(0); + while (1) { + /* spin forever */ + } + /* NOTREACHED */ +} diff --git a/src/audio/module_adapter/module/dolby/llext/CMakeLists.txt b/src/audio/module_adapter/module/dolby/llext/CMakeLists.txt new file mode 100644 index 000000000000..fe8a965d8c87 --- /dev/null +++ b/src/audio/module_adapter/module/dolby/llext/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright(c) 2025 Dolby Laboratories. +# SPDX-License-Identifier: Apache-2.0 + +if(CONFIG_COMP_DOLBY_DAX_AUDIO_PROCESSING_MOCK) + sof_llext_build("dolby_dax_audio_processing" + SOURCES ../dax.c + ../dax_mock.c + INCLUDES ${sof_top_dir}/third_party/include + ) +else() + sof_llext_build("dolby_dax_audio_processing" + SOURCES ../dax.c ../llext-wrap.c + INCLUDES ${sof_top_dir}/third_party/include + LIBS_PATH ${sof_top_dir}/third_party/lib/ + LIBS dax m c gcc + ) +endif() diff --git a/src/audio/module_adapter/module/dolby/llext/llext.toml.h b/src/audio/module_adapter/module/dolby/llext/llext.toml.h new file mode 100644 index 000000000000..74f92b85fb81 --- /dev/null +++ b/src/audio/module_adapter/module/dolby/llext/llext.toml.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2025 Dolby Laboratories. All rights reserved. + */ +#include +#define LOAD_TYPE "2" +#include "../dax.toml" + +[module] +count = __COUNTER__