Skip to content

Commit 5661b3f

Browse files
lyakhlgirdwood
authored andcommitted
fir: enable building FIR support code as an LLEXT object
FIR support code is used by eq-fir and by tdfb. When both of them are built as LLEXT modules, FIR supporting functions can be dynamically loaded too. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent 94ce70e commit 5661b3f

File tree

10 files changed

+57
-6
lines changed

10 files changed

+57
-6
lines changed

src/math/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ choice "FILTER_SIMD_LEVEL_SELECT"
170170
endchoice
171171

172172
config MATH_FIR
173-
bool "FIR filter library"
173+
tristate "FIR filter library"
174174
default n
175175
help
176176
This option builds FIR (Finite Impulse Response) filter library. It

src/math/fir.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[[module.entry]]
2+
name = "FIR"
3+
uuid = "93446E12-1864-4E04-AFE0-3B1D778FFB79"
4+
load_type = "3"
5+
6+
index = __COUNTER__

src/math/fir_common.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
//
3+
// Copyright(c) 2024 Intel Corporation.
4+
5+
/* modular: llext dynamic link */
6+
7+
#include <sof/compiler_attributes.h>
8+
#include <sof/lib/uuid.h>
9+
#include <module/module/api_ver.h>
10+
#include <module/module/llext.h>
11+
#include <rimage/sof/user/manifest.h>
12+
13+
#include <stddef.h>
14+
15+
static const struct sof_man_module_manifest mod_manifest __section(".module") __used =
16+
SOF_LLEXT_AUX_MANIFEST("FIR", NULL, SOF_REG_UUID(fir));
17+
18+
SOF_LLEXT_BUILDINFO;

src/math/fir_generic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ int32_t fir_32x16(struct fir_state_32x16 *fir, int32_t x)
118118
/* Q2.46 -> Q2.31, saturate to Q1.31 */
119119
return sat_int32(y >> shift);
120120
}
121+
EXPORT_SYMBOL(fir_32x16);
121122

122123
void fir_32x16_2x(struct fir_state_32x16 *fir, int32_t x0, int32_t x1, int32_t *y0, int32_t *y1)
123124
{
@@ -184,5 +185,6 @@ void fir_32x16_2x(struct fir_state_32x16 *fir, int32_t x0, int32_t x1, int32_t *
184185
*y0 = sat_int32(a0 >> shift);
185186
*y1 = sat_int32(a1 >> shift);
186187
}
188+
EXPORT_SYMBOL(fir_32x16_2x);
187189

188190
#endif

src/math/fir_hifi2ep.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ void fir_32x16_hifiep(struct fir_state_32x16 *fir, int32_t x, int32_t *y, int ls
156156
a = AE_SRAAQ56(AE_SLLASQ56S(a, lshift), rshift);
157157
AE_SQ32F_I(AE_ROUNDSQ32SYM(a), (ae_q32s *)y, 0);
158158
}
159+
EXPORT_SYMBOL(fir_32x16_hifiep);
159160

160161
/* HiFi EP has the follow number of reqisters that should not be exceeded
161162
* 4x 56 bit registers in register file Q
@@ -249,5 +250,6 @@ void fir_32x16_2x_hifiep(struct fir_state_32x16 *fir, int32_t x0, int32_t x1,
249250
AE_SQ32F_I(AE_ROUNDSQ32SYM(b), (ae_q32s *)y1, 0);
250251
AE_SQ32F_I(AE_ROUNDSQ32SYM(a), (ae_q32s *)y0, 0);
251252
}
253+
EXPORT_SYMBOL(fir_32x16_2x_hifiep);
252254

253255
#endif

src/math/fir_hifi3.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ void fir_32x16_hifi3(struct fir_state_32x16 *fir, ae_int32 x, ae_int32 *y,
162162
a = AE_SLAA64S(a, shift);
163163
AE_S32_L_I(AE_ROUND32F48SSYM(a), (ae_int32 *)y, 0);
164164
}
165+
EXPORT_SYMBOL(fir_32x16_hifi3);
165166

166167
/* HiFi EP has the follow number of reqisters that should not be exceeded
167168
* 4x 56 bit registers in register file Q

src/math/fir_llext/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2024 Intel Corporation.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
sof_llext_build("fir"
5+
SOURCES ../fir_common.c
6+
../fir_generic.c
7+
../fir_hifi2ep.c
8+
../fir_hifi3.c
9+
LIB openmodules
10+
)

src/math/fir_llext/llext.toml.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <tools/rimage/config/platform.toml>
2+
#include "../fir.toml"
3+
4+
[module]
5+
count = __COUNTER__

uuid-registry.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ f6d15ad3-b122-458c-ae9b0ab0b5867aa0 dummy_dma
7272
5150c0e6-27f9-4ec8-8351c705b642d12f eq_iir
7373
889f6dcd-ddcd-4e05-aa5b0d39f8bca961 esai
7474
bfc7488c-75aa-4ce8-9dbed8da08a698c2 file
75+
93446e12-1864-4e04-afe03b1d778ffb79 fir
7576
61bca9a8-18d0-4a18-8e7b2639219804b7 gain
7677
c3c74249-058e-414f-82404da5f3fc2389 google_hotword
7778
bf0e1bbc-dc6a-45fe-bc902554cb137ab4 google_ctc_audio_processing

zephyr/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,17 @@ elseif(CONFIG_COMP_IIR)
685685
)
686686
endif()
687687

688-
zephyr_library_sources_ifdef(CONFIG_MATH_FIR
689-
${SOF_MATH_PATH}/fir_generic.c
690-
${SOF_MATH_PATH}/fir_hifi2ep.c
691-
${SOF_MATH_PATH}/fir_hifi3.c
692-
)
688+
if(CONFIG_MATH_FIR STREQUAL "m")
689+
add_subdirectory(${SOF_MATH_PATH}/fir_llext
690+
${PROJECT_BINARY_DIR}/fir_llext)
691+
add_dependencies(app fir)
692+
elseif(CONFIG_MATH_FIR)
693+
zephyr_library_sources(
694+
${SOF_MATH_PATH}/fir_generic.c
695+
${SOF_MATH_PATH}/fir_hifi2ep.c
696+
${SOF_MATH_PATH}/fir_hifi3.c
697+
)
698+
endif()
693699

694700
zephyr_library_sources_ifdef(CONFIG_MATH_IIR_DF1
695701
${SOF_MATH_PATH}/iir_df1_generic.c

0 commit comments

Comments
 (0)