Skip to content

Commit dcd21cd

Browse files
lyakhkv2019i
authored andcommitted
volume: add LLEXT support
This makes it possible to build volume as an LLEXT module to be loaded at run-time. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent c7e82df commit dcd21cd

8 files changed

Lines changed: 81 additions & 18 deletions

File tree

app/configs/lnl/modules.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CONFIG_COMP_MIXIN_MIXOUT=m
33
CONFIG_COMP_IIR=m
44
CONFIG_COMP_DRC=m
55
CONFIG_COMP_SRC=m
6+
CONFIG_COMP_VOLUME=m

app/configs/mtl/modules.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ CONFIG_COMP_MIXIN_MIXOUT=m
33
CONFIG_COMP_IIR=m
44
CONFIG_COMP_DRC=m
55
CONFIG_COMP_SRC=m
6+
CONFIG_COMP_VOLUME=m

src/audio/volume/Kconfig

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22

3-
config COMP_VOLUME
4-
bool "Volume component"
5-
default y
6-
help
7-
Select for Volume component
3+
config COMP_VOLUME
4+
tristate "Volume component"
5+
default m if LIBRARY_DEFAULT_MODULAR
6+
default y
7+
help
8+
Select for Volume component
89

910
if COMP_VOLUME
1011

@@ -78,4 +79,4 @@ config COMP_GAIN
7879
This option enables gain to change volume. It works
7980
as peak volume without updating peak vol to host
8081

81-
endif # volume
82+
endif # volume
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2024 Intel Corporation.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
sof_llext_build("volume"
5+
SOURCES ../volume_generic.c
6+
../volume_hifi3.c
7+
../volume_hifi4.c
8+
../volume_generic_with_peakvol.c
9+
../volume_hifi3_with_peakvol.c
10+
../volume_hifi4_with_peakvol.c
11+
../volume.c
12+
../volume_ipc4.c
13+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <tools/rimage/config/platform.toml>
2+
#define LOAD_TYPE "2"
3+
#include "../volume.toml"
4+
5+
[module]
6+
count = __COUNTER__

src/audio/volume/volume.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,3 +800,34 @@ static const struct module_interface gain_interface = {
800800
DECLARE_MODULE_ADAPTER(gain_interface, gain_uuid, gain_tr);
801801
SOF_MODULE_INIT(gain, sys_comp_module_gain_interface_init);
802802
#endif
803+
804+
#if CONFIG_COMP_VOLUME_MODULE
805+
/* modular: llext dynamic link */
806+
807+
#include <module/module/api_ver.h>
808+
#include <module/module/llext.h>
809+
#include <rimage/sof/user/manifest.h>
810+
811+
#if CONFIG_COMP_PEAK_VOL
812+
#define UUID_PEAKVOL 0x23, 0x13, 0x17, 0x8a, 0xa3, 0x94, 0x1d, 0x4e, \
813+
0xaf, 0xe9, 0xfe, 0x5d, 0xba, 0xa4, 0xc3, 0x93
814+
SOF_LLEXT_MOD_ENTRY(peakvol, &volume_interface);
815+
#endif
816+
817+
#if CONFIG_COMP_GAIN
818+
#define UUID_GAIN 0xa8, 0xa9, 0xbc, 0x61, 0xd0, 0x18, 0x18, 0x4a, \
819+
0x8e, 0x7b, 0x26, 0x39, 0x21, 0x98, 0x04, 0xb7
820+
SOF_LLEXT_MOD_ENTRY(gain, &gain_interface);
821+
#endif
822+
823+
static const struct sof_man_module_manifest mod_manifest[] __section(".module") __used = {
824+
#if CONFIG_COMP_PEAK_VOL
825+
SOF_LLEXT_MODULE_MANIFEST("PEAKVOL", peakvol_llext_entry, 1, UUID_PEAKVOL, 10),
826+
#endif
827+
#if CONFIG_COMP_GAIN
828+
SOF_LLEXT_MODULE_MANIFEST("GAIN", gain_llext_entry, 1, UUID_GAIN, 40),
829+
#endif
830+
};
831+
832+
SOF_LLEXT_BUILDINFO;
833+
#endif

src/audio/volume/volume.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
#ifndef LOAD_TYPE
2+
#define LOAD_TYPE "0"
3+
#endif
4+
15
#if CONFIG_COMP_PEAK_VOL
26
[[module.entry]]
37
name = "PEAKVOL"
48
uuid = "8A171323-94A3-4E1D-AFE9-FE5DBAA4C393"
59
affinity_mask = "0x1"
610
instance_count = "10"
711
domain_types = "0"
8-
load_type = "0"
12+
load_type = LOAD_TYPE
913
module_type = "4"
1014
auto_start = "0"
1115
sched_caps = [1, 0x00008000]
@@ -41,7 +45,7 @@
4145
affinity_mask = "0x1"
4246
instance_count = "40"
4347
domain_types = "0"
44-
load_type = "0"
48+
load_type = LOAD_TYPE
4549
module_type = "9"
4650
auto_start = "0"
4751
sched_caps = [1, 0x00008000]

zephyr/CMakeLists.txt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,16 +678,22 @@ zephyr_library_sources_ifdef(CONFIG_SAMPLE_KEYPHRASE
678678
${SOF_SAMPLES_PATH}/audio/detect_test.c
679679
)
680680

681-
zephyr_library_sources_ifdef(CONFIG_COMP_VOLUME
682-
${SOF_AUDIO_PATH}/volume/volume_hifi4.c
683-
${SOF_AUDIO_PATH}/volume/volume_hifi3.c
684-
${SOF_AUDIO_PATH}/volume/volume_generic.c
685-
${SOF_AUDIO_PATH}/volume/volume_hifi4_with_peakvol.c
686-
${SOF_AUDIO_PATH}/volume/volume_hifi3_with_peakvol.c
687-
${SOF_AUDIO_PATH}/volume/volume_generic_with_peakvol.c
688-
${SOF_AUDIO_PATH}/volume/volume.c
689-
${SOF_AUDIO_PATH}/volume/volume_${ipc_suffix}.c
690-
)
681+
if(CONFIG_COMP_VOLUME STREQUAL "m")
682+
add_subdirectory(${SOF_AUDIO_PATH}/volume/llext
683+
${PROJECT_BINARY_DIR}/volume_llext)
684+
add_dependencies(app volume)
685+
elseif(CONFIG_COMP_VOLUME)
686+
zephyr_library_sources(
687+
${SOF_AUDIO_PATH}/volume/volume_hifi4.c
688+
${SOF_AUDIO_PATH}/volume/volume_hifi3.c
689+
${SOF_AUDIO_PATH}/volume/volume_generic.c
690+
${SOF_AUDIO_PATH}/volume/volume_hifi4_with_peakvol.c
691+
${SOF_AUDIO_PATH}/volume/volume_hifi3_with_peakvol.c
692+
${SOF_AUDIO_PATH}/volume/volume_generic_with_peakvol.c
693+
${SOF_AUDIO_PATH}/volume/volume.c
694+
${SOF_AUDIO_PATH}/volume/volume_${ipc_suffix}.c
695+
)
696+
endif()
691697

692698
zephyr_library_sources_ifdef(CONFIG_COMP_MODULE_ADAPTER
693699
${SOF_AUDIO_PATH}/module_adapter/module_adapter.c

0 commit comments

Comments
 (0)