diff --git a/src/audio/eq_fir/eq_fir.h b/src/audio/eq_fir/eq_fir.h index fafca0e485f7..6d3865efbdcc 100644 --- a/src/audio/eq_fir/eq_fir.h +++ b/src/audio/eq_fir/eq_fir.h @@ -12,13 +12,15 @@ #include #include #include -#if FIR_GENERIC +#include + +#if SOF_USE_HIFI(NONE, FILTER) #include #endif -#if FIR_HIFIEP +#if SOF_USE_HIFI(2, FILTER) #include #endif -#if FIR_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #include #endif #include @@ -75,7 +77,7 @@ int eq_fir_params(struct processing_module *mod); * set_fir_func. */ -#if FIR_HIFI3 || FIR_HIFIEP +#if SOF_USE_HIFI(2, FILTER) || SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #if CONFIG_FORMAT_S16LE static inline void set_s16_fir(struct comp_data *cd) { diff --git a/src/audio/eq_fir/eq_fir_generic.c b/src/audio/eq_fir/eq_fir_generic.c index 6454ded2a0fd..d13757e29716 100644 --- a/src/audio/eq_fir/eq_fir_generic.c +++ b/src/audio/eq_fir/eq_fir_generic.c @@ -7,8 +7,9 @@ // Keyon Jie #include +#include -#if FIR_GENERIC +#if SOF_USE_HIFI(NONE, FILTER) #include #include @@ -132,4 +133,4 @@ void eq_fir_s32(struct fir_state_32x16 fir[], struct input_stream_buffer *bsourc } #endif /* CONFIG_FORMAT_S32LE */ -#endif /* FIR_GENERIC */ +#endif /* FILTER_HIFI_NONE */ diff --git a/src/audio/eq_fir/eq_fir_hifi2ep.c b/src/audio/eq_fir/eq_fir_hifi2ep.c index 270ba7a6c645..2a687623ea51 100644 --- a/src/audio/eq_fir/eq_fir_hifi2ep.c +++ b/src/audio/eq_fir/eq_fir_hifi2ep.c @@ -5,8 +5,9 @@ // Author: Seppo Ingalsuo #include +#include -#if FIR_HIFIEP +#if SOF_USE_HIFI(2, FILTER) #include #include diff --git a/src/audio/eq_fir/eq_fir_hifi3.c b/src/audio/eq_fir/eq_fir_hifi3.c index 2b75526057ac..a607d6d05097 100644 --- a/src/audio/eq_fir/eq_fir_hifi3.c +++ b/src/audio/eq_fir/eq_fir_hifi3.c @@ -5,8 +5,9 @@ // Author: Seppo Ingalsuo #include +#include -#if FIR_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #include #include diff --git a/src/audio/tdfb/tdfb_comp.h b/src/audio/tdfb/tdfb_comp.h index f4c54d15b3b0..565bde1d62bf 100644 --- a/src/audio/tdfb/tdfb_comp.h +++ b/src/audio/tdfb/tdfb_comp.h @@ -15,26 +15,17 @@ #include #include #include +#include -/* Select optimized code variant when xt-xcc compiler is used */ -#if defined __XCC__ -#include -#if XCHAL_HAVE_HIFI2EP == 1 -#define TDFB_GENERIC 0 -#define TDFB_HIFIEP 1 -#define TDFB_HIFI3 0 -#elif XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1 +/* TDFB and EQFIR depend on math FIR. + * so align TDFB, math FIR, and EQFIR use same selection. + */ +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #define TDFB_HIFI3 1 -#define TDFB_HIFIEP 0 -#define TDFB_GENERIC 0 -#else -#error "No HIFIEP or HIFI3 found. Cannot build TDFB module." -#endif +#elif SOF_USE_HIFI(2, FILTER) +#define TDFB_HIFI2 1 #else -/* GCC */ #define TDFB_GENERIC 1 -#define TDFB_HIFIEP 0 -#define TDFB_HIFI3 0 #endif #define TDFB_IN_BUF_LENGTH (2 * PLATFORM_MAX_CHANNELS) diff --git a/src/include/sof/math/fir_config.h b/src/include/sof/math/fir_config.h index 4079732219a4..4818118253f6 100644 --- a/src/include/sof/math/fir_config.h +++ b/src/include/sof/math/fir_config.h @@ -21,42 +21,4 @@ #endif #endif -/* Define SOFM_FIR_FORCEARCH 0/2/3 in build command line or temporarily in - * this file to override the default auto detection. - */ -#ifdef SOFM_FIR_FORCEARCH -# if SOFM_FIR_FORCEARCH == 3 -# define FIR_GENERIC 0 -# define FIR_HIFIEP 0 -# define FIR_HIFI3 1 -# elif SOFM_FIR_FORCEARCH == 2 -# define FIR_GENERIC 0 -# define FIR_HIFIEP 1 -# define FIR_HIFI3 0 -# elif SOFM_FIR_FORCEARCH == 0 -# define FIR_GENERIC 1 -# define FIR_HIFIEP 0 -# define FIR_HIFI3 0 -# else -# error "Unsupported SOFM_FIR_FORCEARCH value." -# endif -#else -# if defined __XCC__ -# include -# define FIR_GENERIC 0 -# if XCHAL_HAVE_HIFI2EP == 1 -# define FIR_HIFIEP 1 -# define FIR_HIFI3 0 -# elif XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1 -# define FIR_HIFI3 1 -# define FIR_HIFIEP 0 -# else -# error "No HIFIEP or HIFI3 found. Cannot build FIR module." -# endif -# else -# define FIR_GENERIC 1 -# define FIR_HIFI3 0 -# endif /* __XCC__ */ -#endif /* SOFM_FIR_FORCEARCH */ - #endif /* __SOF_AUDIO_EQ_FIR_FIR_CONFIG_H__ */ diff --git a/src/include/sof/math/fir_generic.h b/src/include/sof/math/fir_generic.h index 28944c7d107c..79be1f575ff7 100644 --- a/src/include/sof/math/fir_generic.h +++ b/src/include/sof/math/fir_generic.h @@ -11,8 +11,9 @@ #define __SOF_MATH_FIR_GENERIC_H__ #include +#include -#if FIR_GENERIC +#if SOF_USE_HIFI(NONE, FILTER) #include #include diff --git a/src/include/sof/math/fir_hifi2ep.h b/src/include/sof/math/fir_hifi2ep.h index c84e647d6de3..85561c770c23 100644 --- a/src/include/sof/math/fir_hifi2ep.h +++ b/src/include/sof/math/fir_hifi2ep.h @@ -9,8 +9,9 @@ #define __SOF_MATH_FIR_HIFI2EP_H__ #include +#include -#if FIR_HIFIEP +#if SOF_USE_HIFI(2, FILTER) #include #include diff --git a/src/include/sof/math/fir_hifi3.h b/src/include/sof/math/fir_hifi3.h index aa1102ef2a1f..c6730021b955 100644 --- a/src/include/sof/math/fir_hifi3.h +++ b/src/include/sof/math/fir_hifi3.h @@ -9,8 +9,9 @@ #define __SOF_MATH_FIR_HIFI3_H__ #include +#include -#if FIR_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #include #include diff --git a/src/include/sof/math/iir_df1.h b/src/include/sof/math/iir_df1.h index 931a9ffe54f0..4f709d59bcd6 100644 --- a/src/include/sof/math/iir_df1.h +++ b/src/include/sof/math/iir_df1.h @@ -10,24 +10,10 @@ #include #include +#include #define IIR_DF1_NUM_STATE 4 -#if defined __XCC__ -#include -#if XCHAL_HAVE_HIFI3 -#define IIR_DF1_GENERIC 0 -#define IIR_DF1_HIFI3 1 -#else -#define IIR_DF1_GENERIC 1 -#define IIR_DF1_HIFI3 0 -#endif /* XCHAL_HAVE_HIFI3 */ -#else -/* GCC */ -#define IIR_DF1_GENERIC 1 -#define IIR_DF1_HIFI3 0 -#endif - struct iir_state_df1 { unsigned int biquads; /* Number of IIR 2nd order sections total */ unsigned int biquads_in_series; /* Number of IIR 2nd order sections @@ -51,7 +37,7 @@ void iir_reset_df1(struct iir_state_df1 *iir); int32_t iir_df1(struct iir_state_df1 *iir, int32_t x); /* Inline functions */ -#if IIR_DF1_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #include "iir_df1_hifi3.h" #else #include "iir_df1_generic.h" diff --git a/src/include/sof/math/iir_df2t.h b/src/include/sof/math/iir_df2t.h index 852463b93465..bf342520cb03 100644 --- a/src/include/sof/math/iir_df2t.h +++ b/src/include/sof/math/iir_df2t.h @@ -12,35 +12,7 @@ #include #include - -/* Define SOFM_IIR_DF2T_FORCEARCH 0/3 in build command line or temporarily in - * this file to override the default auto detection. - */ -#ifdef SOFM_IIR_DF2T_FORCEARCH -# if SOFM_IIR_DF2T_FORCEARCH == 3 -# define IIR_GENERIC 0 -# define IIR_HIFI3 1 -# elif SOFM_IIR_DF2T_FORCEARCH == 0 -# define IIR_GENERIC 1 -# define IIR_HIFI3 0 -# else -# error "Unsupported SOFM_IIR_DF2T_FORCEARCH value." -# endif -#else -# if defined __XCC__ -# include -# if XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1 -# define IIR_GENERIC 0 -# define IIR_HIFI3 1 -# else -# define IIR_GENERIC 1 -# define IIR_HIFI3 0 -# endif /* XCHAL_HAVE_HIFIn */ -# else -# define IIR_GENERIC 1 -# define IIR_HIFI3 0 -# endif /* __XCC__ */ -#endif /* SOFM_IIR_DF2T_FORCEARCH */ +#include #define IIR_DF2T_NUM_DELAYS 2 @@ -71,7 +43,7 @@ void iir_reset_df2t(struct iir_state_df2t *iir); int32_t iir_df2t(struct iir_state_df2t *iir, int32_t x); /* Inline functions with or without HiFi3 intrinsics */ -#if IIR_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #include "iir_df2t_hifi3.h" #else #include "iir_df2t_generic.h" diff --git a/src/math/Kconfig b/src/math/Kconfig index d911fd4befe5..08e4f9a554f0 100644 --- a/src/math/Kconfig +++ b/src/math/Kconfig @@ -125,6 +125,52 @@ config MATH_32BIT_FFT endmenu +# this choice covers math iir, math fir, tdfb, and eqfir, eqiir. +choice "FILTER_SIMD_LEVEL_SELECT" + prompt "choose which SIMD level used for IIR/FIR/TDFB module" + depends on COMP_FIR + depends on COMP_IIR + depends on COMP_TDFB + default FILTER_HIFI_MAX + + config FILTER_HIFI_MAX + prompt "SIMD will selected by toolchain pre-defined header" + bool + help + When this was selected, optimization level will be determined + by toolchain pre-defined macros in core isa header file. + + config FILTER_HIFI_5 + prompt "choose HIFI5 intrinsic optimized FILTER module" + bool + help + This option used to build HIFI5 optimized FILTER code + + config FILTER_HIFI_4 + prompt "choose HIFI4 intrinsic optimized FILTER module" + bool + help + This option used to build HIFI4 optimized FILTER code + + config FILTER_HIFI_3 + prompt "choose HIFI3 intrinsic optimized FILTER module" + bool + help + This option used to build HIFI3 intrinsic optimized FILTER code + + config FILTER_HIFI_2 + prompt "choose HIFI2ep intrinsic optimized FILTER module" + bool + help + This option used to build HIFI2ep intrinsic optimized FILTER code + + config FILTER_HIFI_NONE + prompt "choose generic C FILTER module, no HIFI SIMD involved" + bool + help + This option used to build FILTER generic code. +endchoice + config MATH_FIR bool "FIR filter library" default n diff --git a/src/math/Kconfig.simd b/src/math/Kconfig.simd new file mode 100644 index 000000000000..6521259be116 --- /dev/null +++ b/src/math/Kconfig.simd @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: BSD-3-Clause + +comment "filter optimization level select" + +# this choice covers math iir, math fir, tdfb, and eqfir, eqiir. +choice "FILTER_SIMD_LEVEL_SELECT" + prompt "choose which SIMD level used for filter module" + depends on COMP_FIR + depends on COMP_IIR + default FILTER_HIFI_MAX + + config FILTER_HIFI_MAX + prompt "SIMD will selected by toolchain pre-defined header" + bool + help + When this was selected, optimization level will be determined + by toolchain pre-defined macros in core isa header file. + + config FILTER_HIFI_5 + prompt "choose HIFI5 intrinsic optimized FILTER module" + bool + help + This option used to build HIFI5 optimized FILTER code + + config FILTER_HIFI_4 + prompt "choose HIFI4 intrinsic optimized FILTER module" + bool + help + This option used to build HIFI4 optimized FILTER code + + config FILTER_HIFI_3 + prompt "choose HIFI3 intrinsic optimized FILTER module" + bool + help + This option used to build HIFI3 intrinsic optimized FILTER code + + config FILTER_HIFI_2 + prompt "choose HIFI2ep intrinsic optimized FILTER module" + bool + help + This option used to build HIFI2ep intrinsic optimized FILTER code + + config FILTER_HIFI_NONE + prompt "choose generic C FILTER module, no HIFI SIMD involved" + bool + help + This option used to build FILTER generic code. +endchoice diff --git a/src/math/fir_generic.c b/src/math/fir_generic.c index 53f650a2056d..0b19c6e14da1 100644 --- a/src/math/fir_generic.c +++ b/src/math/fir_generic.c @@ -7,10 +7,10 @@ // Keyon Jie #include +#include -#if FIR_GENERIC +#if SOF_USE_HIFI(NONE, FILTER) -#include #include #include #include diff --git a/src/math/fir_hifi2ep.c b/src/math/fir_hifi2ep.c index a1566fb5c5d5..f95b039a15fa 100644 --- a/src/math/fir_hifi2ep.c +++ b/src/math/fir_hifi2ep.c @@ -5,8 +5,9 @@ // Author: Seppo Ingalsuo #include +#include -#if FIR_HIFIEP +#if SOF_USE_HIFI(2, FILTER) #include #include diff --git a/src/math/fir_hifi3.c b/src/math/fir_hifi3.c index 149d19b0d0bc..30be6b8196cc 100644 --- a/src/math/fir_hifi3.c +++ b/src/math/fir_hifi3.c @@ -5,8 +5,9 @@ // Author: Seppo Ingalsuo #include +#include -#if FIR_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #include #include diff --git a/src/math/iir_df1_generic.c b/src/math/iir_df1_generic.c index 0a01020968ea..1be36e0a222e 100644 --- a/src/math/iir_df1_generic.c +++ b/src/math/iir_df1_generic.c @@ -11,7 +11,7 @@ #include #include -#if IIR_DF1_GENERIC +#if SOF_USE_HIFI(NONE, FILTER) /* * Direct form I second order filter block (biquad) diff --git a/src/math/iir_df1_hifi3.c b/src/math/iir_df1_hifi3.c index b80bc2a16509..39be8e3a6e54 100644 --- a/src/math/iir_df1_hifi3.c +++ b/src/math/iir_df1_hifi3.c @@ -10,8 +10,9 @@ #include #include #include +#include -#if IIR_DF1_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) /* * Direct form I second order filter block (biquad) diff --git a/src/math/iir_df2t_generic.c b/src/math/iir_df2t_generic.c index 19c27a56a61a..1e1f9385a3aa 100644 --- a/src/math/iir_df2t_generic.c +++ b/src/math/iir_df2t_generic.c @@ -8,12 +8,13 @@ #include #include +#include #include #include #include #include -#if IIR_GENERIC +#if SOF_USE_HIFI(NONE, FILTER) /* * Direct form II transposed second order filter block (biquad) diff --git a/src/math/iir_df2t_hifi3.c b/src/math/iir_df2t_hifi3.c index 914a9d72cc4d..013af20a9ae4 100644 --- a/src/math/iir_df2t_hifi3.c +++ b/src/math/iir_df2t_hifi3.c @@ -13,7 +13,7 @@ #include #include -#if IIR_HIFI3 +#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) #include