Skip to content

Commit

Permalink
fir: enable building FIR support code as an LLEXT object
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lyakh authored and lgirdwood committed Feb 18, 2025
1 parent 94ce70e commit 5661b3f
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/math/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ choice "FILTER_SIMD_LEVEL_SELECT"
endchoice

config MATH_FIR
bool "FIR filter library"
tristate "FIR filter library"
default n
help
This option builds FIR (Finite Impulse Response) filter library. It
Expand Down
6 changes: 6 additions & 0 deletions src/math/fir.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[module.entry]]
name = "FIR"
uuid = "93446E12-1864-4E04-AFE0-3B1D778FFB79"
load_type = "3"

index = __COUNTER__
18 changes: 18 additions & 0 deletions src/math/fir_common.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2024 Intel Corporation.

/* modular: llext dynamic link */

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

#include <stddef.h>

static const struct sof_man_module_manifest mod_manifest __section(".module") __used =
SOF_LLEXT_AUX_MANIFEST("FIR", NULL, SOF_REG_UUID(fir));

SOF_LLEXT_BUILDINFO;
2 changes: 2 additions & 0 deletions src/math/fir_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ int32_t fir_32x16(struct fir_state_32x16 *fir, int32_t x)
/* Q2.46 -> Q2.31, saturate to Q1.31 */
return sat_int32(y >> shift);
}
EXPORT_SYMBOL(fir_32x16);

void fir_32x16_2x(struct fir_state_32x16 *fir, int32_t x0, int32_t x1, int32_t *y0, int32_t *y1)
{
Expand Down Expand Up @@ -184,5 +185,6 @@ void fir_32x16_2x(struct fir_state_32x16 *fir, int32_t x0, int32_t x1, int32_t *
*y0 = sat_int32(a0 >> shift);
*y1 = sat_int32(a1 >> shift);
}
EXPORT_SYMBOL(fir_32x16_2x);

#endif
2 changes: 2 additions & 0 deletions src/math/fir_hifi2ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void fir_32x16_hifiep(struct fir_state_32x16 *fir, int32_t x, int32_t *y, int ls
a = AE_SRAAQ56(AE_SLLASQ56S(a, lshift), rshift);
AE_SQ32F_I(AE_ROUNDSQ32SYM(a), (ae_q32s *)y, 0);
}
EXPORT_SYMBOL(fir_32x16_hifiep);

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

#endif
1 change: 1 addition & 0 deletions src/math/fir_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ void fir_32x16_hifi3(struct fir_state_32x16 *fir, ae_int32 x, ae_int32 *y,
a = AE_SLAA64S(a, shift);
AE_S32_L_I(AE_ROUND32F48SSYM(a), (ae_int32 *)y, 0);
}
EXPORT_SYMBOL(fir_32x16_hifi3);

/* HiFi EP has the follow number of reqisters that should not be exceeded
* 4x 56 bit registers in register file Q
Expand Down
10 changes: 10 additions & 0 deletions src/math/fir_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("fir"
SOURCES ../fir_common.c
../fir_generic.c
../fir_hifi2ep.c
../fir_hifi3.c
LIB openmodules
)
5 changes: 5 additions & 0 deletions src/math/fir_llext/llext.toml.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <tools/rimage/config/platform.toml>
#include "../fir.toml"
[module]
count = __COUNTER__
1 change: 1 addition & 0 deletions uuid-registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ f6d15ad3-b122-458c-ae9b0ab0b5867aa0 dummy_dma
5150c0e6-27f9-4ec8-8351c705b642d12f eq_iir
889f6dcd-ddcd-4e05-aa5b0d39f8bca961 esai
bfc7488c-75aa-4ce8-9dbed8da08a698c2 file
93446e12-1864-4e04-afe03b1d778ffb79 fir
61bca9a8-18d0-4a18-8e7b2639219804b7 gain
c3c74249-058e-414f-82404da5f3fc2389 google_hotword
bf0e1bbc-dc6a-45fe-bc902554cb137ab4 google_ctc_audio_processing
Expand Down
16 changes: 11 additions & 5 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,17 @@ elseif(CONFIG_COMP_IIR)
)
endif()

zephyr_library_sources_ifdef(CONFIG_MATH_FIR
${SOF_MATH_PATH}/fir_generic.c
${SOF_MATH_PATH}/fir_hifi2ep.c
${SOF_MATH_PATH}/fir_hifi3.c
)
if(CONFIG_MATH_FIR STREQUAL "m")
add_subdirectory(${SOF_MATH_PATH}/fir_llext
${PROJECT_BINARY_DIR}/fir_llext)
add_dependencies(app fir)
elseif(CONFIG_MATH_FIR)
zephyr_library_sources(
${SOF_MATH_PATH}/fir_generic.c
${SOF_MATH_PATH}/fir_hifi2ep.c
${SOF_MATH_PATH}/fir_hifi3.c
)
endif()

zephyr_library_sources_ifdef(CONFIG_MATH_IIR_DF1
${SOF_MATH_PATH}/iir_df1_generic.c
Expand Down

0 comments on commit 5661b3f

Please sign in to comment.