Skip to content

Commit

Permalink
asrc: enable building as an llext module
Browse files Browse the repository at this point in the history
Add support for LLEXT building to asrc.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
  • Loading branch information
lyakh authored and kv2019i committed Sep 12, 2024
1 parent ed65e22 commit 5c025b0
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 15 deletions.
1 change: 1 addition & 0 deletions app/configs/lnl/modules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ CONFIG_COMP_FIR=m
CONFIG_COMP_IIR=m
CONFIG_COMP_DRC=m
CONFIG_COMP_SRC=m
CONFIG_COMP_ASRC=m
CONFIG_COMP_VOLUME=m
1 change: 1 addition & 0 deletions app/configs/mtl/modules.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ CONFIG_COMP_FIR=m
CONFIG_COMP_IIR=m
CONFIG_COMP_DRC=m
CONFIG_COMP_SRC=m
CONFIG_COMP_ASRC=m
CONFIG_COMP_VOLUME=m
5 changes: 3 additions & 2 deletions src/audio/asrc/Kconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause

config COMP_ASRC
bool "ASRC component"
tristate "ASRC component"
default m if LIBRARY_DEFAULT_MODULAR
default y
help
Select for Asynchronous sample rate conversion (ASRC)
Expand All @@ -14,7 +15,7 @@ config COMP_ASRC
not have pre-computed filter coefficients for every
conversion fraction that SRC does.

if COMP_ASRC
if COMP_ASRC != n

rsource "Kconfig.simd"

Expand Down
23 changes: 20 additions & 3 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static int asrc_free(struct processing_module *mod)
struct comp_data *cd = module_get_private_data(mod);
struct comp_dev *dev = mod->dev;

comp_info(dev, "asrc_free()");
comp_dbg(dev, "asrc_free()");

rfree(cd->buf);
asrc_release_buffers(cd->asrc_obj);
Expand Down Expand Up @@ -850,8 +850,7 @@ static int asrc_reset(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
struct comp_data *cd = module_get_private_data(mod);

comp_info(dev, "asrc_reset(), skew_min=%d, skew_max=%d", cd->skew_min, cd->skew_max);

comp_dbg(dev, "asrc_reset(), skew_min=%d, skew_max=%d", cd->skew_min, cd->skew_max);

/* If any resources feasible to stop */
if (cd->track_drift)
Expand Down Expand Up @@ -879,3 +878,21 @@ static const struct module_interface asrc_interface = {

DECLARE_MODULE_ADAPTER(asrc_interface, ASRC_UUID, asrc_tr);
SOF_MODULE_INIT(asrc, sys_comp_module_asrc_interface_init);

#if CONFIG_COMP_ASRC_MODULE
/* modular: llext dynamic link */

#include <module/module/api_ver.h>
#include <module/module/llext.h>
#include <rimage/sof/user/manifest.h>

#define UUID_ASRC 0x2d, 0x40, 0xb4, 0x66, 0x68, 0xb4, 0xf2, 0x42, \
0x81, 0xa7, 0xb3, 0x71, 0x21, 0x86, 0x3d, 0xd4
SOF_LLEXT_MOD_ENTRY(asrc, &asrc_interface);

static const struct sof_man_module_manifest mod_manifest[] __section(".module") __used = {
SOF_LLEXT_MODULE_MANIFEST("ASRC", asrc_llext_entry, 1, UUID_ASRC, 2),
};

SOF_LLEXT_BUILDINFO;
#endif
6 changes: 5 additions & 1 deletion src/audio/asrc/asrc.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#ifndef LOAD_TYPE
#define LOAD_TYPE "0"
#endif

[[module.entry]]
name = "ASRC"
uuid = "66B4402D-B468-42F2-81A7-B37121863DD4"
affinity_mask = "0x3"
instance_count = "2"
domain_types = "0"

load_type = "0"
load_type = LOAD_TYPE
module_type = "9"
auto_start = "0"
sched_caps = [1, 0x00008000]
Expand Down
10 changes: 10 additions & 0 deletions src/audio/asrc/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0

sof_llext_build("asrc"
SOURCES ../asrc.c
../asrc_farrow_hifi3.c
../asrc_farrow.c
../asrc_farrow_generic.c
../asrc_ipc4.c
)
6 changes: 6 additions & 0 deletions src/audio/asrc/llext/llext.toml.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <tools/rimage/config/platform.toml>
#define LOAD_TYPE "2"
#include "../asrc.toml"

[module]
count = __COUNTER__
21 changes: 12 additions & 9 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -612,15 +612,18 @@ zephyr_library_sources_ifdef(CONFIG_MATH_IIR_DF2T
${SOF_MATH_PATH}/iir_df2t.c
)

zephyr_library_sources_ifdef(CONFIG_COMP_ASRC
${SOF_AUDIO_PATH}/asrc/asrc.c
${SOF_AUDIO_PATH}/asrc/asrc_farrow_hifi3.c
${SOF_AUDIO_PATH}/asrc/asrc_farrow.c
${SOF_AUDIO_PATH}/asrc/asrc_farrow_generic.c
)

if(CONFIG_COMP_ASRC)
zephyr_library_sources(${SOF_AUDIO_PATH}/asrc/asrc_${ipc_suffix}.c)
if(CONFIG_COMP_ASRC STREQUAL "m")
add_subdirectory(${SOF_AUDIO_PATH}/asrc/llext
${PROJECT_BINARY_DIR}/asrc_llext)
add_dependencies(app asrc)
elseif(CONFIG_COMP_ASRC)
zephyr_library_sources(
${SOF_AUDIO_PATH}/asrc/asrc.c
${SOF_AUDIO_PATH}/asrc/asrc_farrow_hifi3.c
${SOF_AUDIO_PATH}/asrc/asrc_farrow.c
${SOF_AUDIO_PATH}/asrc/asrc_farrow_generic.c
${SOF_AUDIO_PATH}/asrc/asrc_${ipc_suffix}.c
)
endif()

zephyr_library_sources_ifdef(CONFIG_COMP_DCBLOCK
Expand Down

0 comments on commit 5c025b0

Please sign in to comment.