diff --git a/src/audio/asrc/Kconfig b/src/audio/asrc/Kconfig index 9e121ada2d1f..7bdbf68d2a94 100644 --- a/src/audio/asrc/Kconfig +++ b/src/audio/asrc/Kconfig @@ -16,6 +16,8 @@ config COMP_ASRC if COMP_ASRC +rsource "Kconfig.simd" + choice prompt "ASRC down sampling conversions set" default COMP_ASRC_DOWNSAMPLING_FULL diff --git a/src/audio/asrc/Kconfig.simd b/src/audio/asrc/Kconfig.simd new file mode 100644 index 000000000000..20a77107db08 --- /dev/null +++ b/src/audio/asrc/Kconfig.simd @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause + +comment "ASRC optimization level select" + +choice "ASRC_SIMD_LEVEL_SELECT" + prompt "choose which SIMD level used for ASRC module" + depends on COMP_ASRC + default ASRC_HIFI_MAX + + config ASRC_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 ASRC_HIFI_5 + prompt "choose HIFI5 intrinsic optimized ASRC module" + bool + help + This option used to build HIFI5 optimized ASRC code + + config ASRC_HIFI_4 + prompt "choose HIFI4 intrinsic optimized ASRC module" + bool + help + This option used to build HIFI4 optimized ASRC code + + config ASRC_HIFI_3 + prompt "choose HIFI3 intrinsic optimized ASRC module" + bool + help + This option used to build HIFI3 intrinsic optimized ASRC code + + config ASRC_HIFI_NONE + prompt "choose generic C ASRC module, no HIFI SIMD involved" + bool + help + This option used to build ASRC generic code. +endchoice diff --git a/src/audio/asrc/asrc_config.h b/src/audio/asrc/asrc_config.h deleted file mode 100644 index 6c9b3fa7f8ec..000000000000 --- a/src/audio/asrc/asrc_config.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * - * Copyright(c) 2012 Intel Corporation. All rights reserved. - */ - -#ifndef __SOF_AUDIO_ASRC_ASRC_CONFIG_H__ -#define __SOF_AUDIO_ASRC_ASRC_CONFIG_H__ - -/* If next define is set to 1 the ASRC is configured automatically. Setting - * to zero temporarily is useful is for testing needs. - */ -#define ASRC_AUTOARCH 1 - -/* Select optimized code variant when xt-xcc compiler is used on HiFi3 */ -#if ASRC_AUTOARCH == 1 -#if defined __XCC__ -/* For xt-xcc */ -#include -#if XCHAL_HAVE_HIFI3 == 1 || XCHAL_HAVE_HIFI4 == 1 -/* Version for HiFi3 */ -#define ASRC_HIFI3 1 -#define ASRC_GENERIC 0 -#else -/* Version for e.g. HiFi2EP */ -#define ASRC_HIFI3 0 -#define ASRC_GENERIC 1 -#endif -#else -/* For GCC */ -#define ASRC_GENERIC 1 -#define ASRC_HIFI3 0 -#endif /* XCC */ -#else -/* Applied when ASRC_AUTOARCH is set to zero */ -#define ASRC_GENERIC 1 /* Enable generic */ -#define ASRC_HIFI3 0 /* Disable HiFi3 */ -#endif /* Autoarch */ - -#endif /* __SOF_AUDIO_ASRC_ASRC_CONFIG_H__ */ diff --git a/src/audio/asrc/asrc_farrow.c b/src/audio/asrc/asrc_farrow.c index 001f6244e8cb..dbe1edbe2aaa 100644 --- a/src/audio/asrc/asrc_farrow.c +++ b/src/audio/asrc/asrc_farrow.c @@ -12,7 +12,6 @@ #include #include #include -#include "asrc_config.h" #include "asrc_farrow.h" LOG_MODULE_DECLARE(asrc, CONFIG_SOF_LOG_LEVEL); diff --git a/src/audio/asrc/asrc_farrow_generic.c b/src/audio/asrc/asrc_farrow_generic.c index 1c556ef5f648..65c073ac02f7 100644 --- a/src/audio/asrc/asrc_farrow_generic.c +++ b/src/audio/asrc/asrc_farrow_generic.c @@ -2,9 +2,9 @@ // // Copyright(c) 2012-2019 Intel Corporation. All rights reserved. -#include "asrc_config.h" +#include -#if ASRC_GENERIC == 1 +#if SOF_USE_HIFI(NONE, ASRC) #include "asrc_farrow.h" #include @@ -360,4 +360,4 @@ void asrc_calc_impulse_response_n7(struct asrc_farrow *src_obj) } } -#endif /* ASRC_GENERIC */ +#endif /* ASRC_HIFI_NONE */ diff --git a/src/audio/asrc/asrc_farrow_hifi3.c b/src/audio/asrc/asrc_farrow_hifi3.c index b949072ba9db..0220804f696d 100644 --- a/src/audio/asrc/asrc_farrow_hifi3.c +++ b/src/audio/asrc/asrc_farrow_hifi3.c @@ -2,11 +2,11 @@ // // Copyright(c) 2012-2019 Intel Corporation. All rights reserved. -#include "asrc_config.h" -#include "asrc_farrow.h" +#include -#if ASRC_HIFI3 == 1 +#if SOF_USE_HIFI(3, ASRC) || SOF_USE_HIFI(4, ASRC) || SOF_USE_HIFI(5, ASRC) +#include "asrc_farrow.h" #include LOG_MODULE_DECLARE(asrc, CONFIG_SOF_LOG_LEVEL); @@ -401,4 +401,4 @@ void asrc_calc_impulse_response_n7(struct asrc_farrow *src_obj) AE_SA64POS_FP(align_out, result_P); } -#endif /* ASRC Hifi3 */ +#endif /* ASRC_HIFI_3 */ diff --git a/src/audio/copier/Kconfig b/src/audio/copier/Kconfig index 05d7886456a3..7c4c38a1776b 100644 --- a/src/audio/copier/Kconfig +++ b/src/audio/copier/Kconfig @@ -1,5 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause +rsource "Kconfig.simd" + config COMP_COPIER bool "COPIER component" default y diff --git a/src/audio/copier/Kconfig.simd b/src/audio/copier/Kconfig.simd new file mode 100644 index 000000000000..d8639fcdb069 --- /dev/null +++ b/src/audio/copier/Kconfig.simd @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause + +comment "COPIER optimization level select" + +choice "COPIER_SIMD_LEVEL_SELECT" + prompt "choose which SIMD level used for COPIER module" + depends on COMP_COPIER + default COPIER_HIFI_MAX + + config COPIER_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 COPIER_HIFI_5 + prompt "choose HIFI5 intrinsic optimized COPIER module" + bool + help + This option used to build HIFI5 optimized COPIER code + + config COPIER_HIFI_4 + prompt "choose HIFI4 intrinsic optimized COPIER module" + bool + help + This option used to build HIFI4 optimized COPIER code + + config COPIER_HIFI_3 + prompt "choose HIFI3 intrinsic optimized COPIER module" + bool + help + This option used to build HIFI3 intrinsic optimized COPIER code + + config COPIER_HIFI_NONE + prompt "choose generic C COPIER module, no HIFI SIMD involved" + bool + help + This option used to build COPIER generic code. +endchoice diff --git a/src/audio/copier/copier.h b/src/audio/copier/copier.h index ab27d3faf956..550219a2aa83 100644 --- a/src/audio/copier/copier.h +++ b/src/audio/copier/copier.h @@ -33,17 +33,6 @@ #include #include -#define COPIER_GENERIC - -#if defined(__XCC__) -#include - -#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4 -#undef COPIER_GENERIC -#endif - -#endif - static const uint32_t INVALID_QUEUE_ID = 0xFFFFFFFF; /* copier Module Configuration & Interface diff --git a/src/audio/copier/copier_generic.c b/src/audio/copier/copier_generic.c index 37d89430d38f..b270e55461a6 100644 --- a/src/audio/copier/copier_generic.c +++ b/src/audio/copier/copier_generic.c @@ -7,16 +7,16 @@ #include #include #include "copier.h" +#include LOG_MODULE_DECLARE(copier, CONFIG_SOF_LOG_LEVEL); -#ifdef COPIER_GENERIC +#if SOF_USE_HIFI(NONE, COPIER) #include #include #include #include -#include #include #include #include diff --git a/src/audio/copier/copier_hifi.c b/src/audio/copier/copier_hifi.c index 8d05fe924f51..f428d1f9008e 100644 --- a/src/audio/copier/copier_hifi.c +++ b/src/audio/copier/copier_hifi.c @@ -4,15 +4,15 @@ // // Author: Andrula Song #include "copier.h" +#include -#if __XCC__ && (XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4) +#if SOF_USE_HIFI(3, COPIER) || SOF_USE_HIFI(4, COPIER) || SOF_USE_HIFI(5, COPIER) #include #include #include #include #include -#include #include #include #include diff --git a/src/audio/drc/Kconfig b/src/audio/drc/Kconfig index dfc5aba4f4fe..9e6aaf6388ed 100644 --- a/src/audio/drc/Kconfig +++ b/src/audio/drc/Kconfig @@ -1,5 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause +rsource "Kconfig.simd" + config COMP_DRC bool "Dynamic Range Compressor component" select CORDIC_FIXED diff --git a/src/audio/drc/Kconfig.simd b/src/audio/drc/Kconfig.simd new file mode 100644 index 000000000000..498758c4813d --- /dev/null +++ b/src/audio/drc/Kconfig.simd @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: BSD-3-Clause + +comment "DRC optimization level select" + +choice "DRC_SIMD_LEVEL_SELECT" + prompt "choose which SIMD level used for DRC module" + depends on COMP_DRC + default DRC_HIFI_MAX + + config DRC_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 DRC_HIFI_5 + prompt "choose HIFI5 intrinsic optimized DRC module" + bool + help + This option used to build HIFI5 optimized DRC code + + config DRC_HIFI_4 + prompt "choose HIFI4 intrinsic optimized DRC module" + bool + help + This option used to build HIFI4 optimized DRC code + + config DRC_HIFI_3 + prompt "choose HIFI3 intrinsic optimized DRC module" + bool + help + This option used to build HIFI3 intrinsic optimized DRC code + + config DRC_HIFI_NONE + prompt "choose generic C DRC module, no HIFI SIMD involved" + bool + help + This option used to build DRC generic code. +endchoice diff --git a/src/audio/drc/drc.h b/src/audio/drc/drc.h index 01236243359a..5598d64c87de 100644 --- a/src/audio/drc/drc.h +++ b/src/audio/drc/drc.h @@ -12,7 +12,6 @@ #include #include -#include "drc_plat_conf.h" #include "drc_user.h" struct audio_stream; diff --git a/src/audio/drc/drc_generic.c b/src/audio/drc/drc_generic.c index bc16fc670f99..8ace19623045 100644 --- a/src/audio/drc/drc_generic.c +++ b/src/audio/drc/drc_generic.c @@ -8,13 +8,14 @@ #include #include #include +#include #include #include "drc.h" #include "drc_algorithm.h" #include "drc_math.h" -#if DRC_GENERIC +#if SOF_USE_HIFI(NONE, DRC) #define ONE_Q20 Q_CONVERT_FLOAT(1.0f, 20) /* Q12.20 */ #define ONE_Q21 Q_CONVERT_FLOAT(1.0f, 21) /* Q11.21 */ @@ -450,9 +451,9 @@ void drc_compress_output(struct drc_state *state, } } -#endif /* DRC_GENERIC */ +#endif /* DRC_HIFI_NONE */ -#if DRC_GENERIC || DRC_HIFI3 +#if SOF_USE_HIFI(NONE, DRC) || SOF_USE_HIFI(3, DRC) /* After one complete division of samples have been received (and one division of * samples have been output), we calculate shaped power average * (detector_average) from the input division, update envelope parameters from diff --git a/src/audio/drc/drc_hifi3.c b/src/audio/drc/drc_hifi3.c index 73f171fd7ece..3a5d23c7d230 100644 --- a/src/audio/drc/drc_hifi3.c +++ b/src/audio/drc/drc_hifi3.c @@ -8,13 +8,14 @@ #include #include #include +#include #include #include "drc.h" #include "drc_algorithm.h" #include "drc_math.h" -#if DRC_HIFI3 +#if SOF_USE_HIFI(3, DRC) #include @@ -494,4 +495,4 @@ void drc_compress_output(struct drc_state *state, } } -#endif /* DRC_HIFI3 */ +#endif /* DRC_HIFI_3 */ diff --git a/src/audio/drc/drc_hifi4.c b/src/audio/drc/drc_hifi4.c index b414831a30a6..6ae3f86bf50d 100644 --- a/src/audio/drc/drc_hifi4.c +++ b/src/audio/drc/drc_hifi4.c @@ -8,13 +8,14 @@ #include #include #include +#include #include #include "drc.h" #include "drc_algorithm.h" #include "drc_math.h" -#if DRC_HIFI4 +#if SOF_USE_HIFI(4, DRC) #include @@ -910,4 +911,4 @@ const struct drc_proc_fnmap drc_proc_fnmap[] = { const size_t drc_proc_fncount = ARRAY_SIZE(drc_proc_fnmap); -#endif /* DRC_HIFI4 */ +#endif /* DRC_HIFI_4 */ diff --git a/src/audio/drc/drc_math.h b/src/audio/drc/drc_math.h index 0d89fd77a52c..96c3e4e34868 100644 --- a/src/audio/drc/drc_math.h +++ b/src/audio/drc/drc_math.h @@ -13,13 +13,12 @@ #include #include #include - -#include "drc_plat_conf.h" +#include /* Unmark this define to use cordic arc sine implementation. */ /* #define DRC_USE_CORDIC_ASIN */ -#if DRC_HIFI3 || DRC_HIFI4 +#if SOF_USE_HIFI(4, DRC) || SOF_USE_HIFI(3, DRC) #include @@ -106,7 +105,7 @@ static inline int32_t drc_asin_fixed(int32_t x) } #endif /* DRC_USE_CORDIC_ASIN */ -#endif /* DRC_HIFI3 */ +#endif /* DRC_HIFI_3/4 */ int32_t drc_lin2db_fixed(int32_t linear); /* Input:Q6.26 Output:Q11.21 */ int32_t drc_log_fixed(int32_t x); /* Input:Q6.26 Output:Q6.26 */ diff --git a/src/audio/drc/drc_math_generic.c b/src/audio/drc/drc_math_generic.c index 436ee444c7c4..574a387bf70c 100644 --- a/src/audio/drc/drc_math_generic.c +++ b/src/audio/drc/drc_math_generic.c @@ -9,13 +9,14 @@ #include #include #include +#include #include "drc_math.h" #define q_mult(a, b, qa, qb, qy) ((int32_t)Q_MULTSR_32X32((int64_t)(a), b, qa, qb, qy)) #define q_multq(a, b, q) ((int32_t)Q_MULTSR_32X32((int64_t)(a), b, q, q, q)) -#if DRC_GENERIC +#if SOF_USE_HIFI(NONE, DRC) /* * Input depends on precision_x @@ -221,7 +222,7 @@ inline int32_t drc_inv_fixed(int32_t x, int32_t precision_x, int32_t precision_y #undef qc } -#endif /* DRC_GENERIC */ +#endif /* DRC_HIFI_NONE */ /* * Input x is Q6.26; valid range: (0.0, 32.0); x <= 0 is not supported diff --git a/src/audio/drc/drc_math_hifi3.c b/src/audio/drc/drc_math_hifi3.c index de6ca46367c1..90cad95e029d 100644 --- a/src/audio/drc/drc_math_hifi3.c +++ b/src/audio/drc/drc_math_hifi3.c @@ -5,9 +5,10 @@ // Author: Pin-chih Lin #include +#include #include "drc_math.h" -#if DRC_HIFI3 || DRC_HIFI4 +#if SOF_USE_HIFI(4, DRC) || SOF_USE_HIFI(3, DRC) #include @@ -225,4 +226,4 @@ inline int32_t drc_inv_fixed(int32_t x, int32_t precision_x, int32_t precision_y return acc; } -#endif /* DRC_HIFI3 */ +#endif /* DRC_HIFI_3/4 */ diff --git a/src/audio/drc/drc_plat_conf.h b/src/audio/drc/drc_plat_conf.h deleted file mode 100644 index 8bdab58bb308..000000000000 --- a/src/audio/drc/drc_plat_conf.h +++ /dev/null @@ -1,51 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * - * Copyright(c) 2021 Google LLC. All rights reserved. - * - * Author: Pin-chih Lin - */ -#ifndef __SOF_AUDIO_DRC_DRC_PLAT_CONF_H__ -#define __SOF_AUDIO_DRC_DRC_PLAT_CONF_H__ - -/* Get platforms configuration */ - -/* If next defines are set to 1 the DRC is configured automatically. Setting - * to zero temporarily is useful is for testing needs. - */ -#define DRC_AUTOARCH 1 - -/* Force manually some code variant when DRC_AUTOARCH is set to zero. These - * are useful in code debugging. - */ -#if DRC_AUTOARCH == 0 -#define DRC_GENERIC 1 -#define DRC_HIFI3 0 -#define DRC_HIFI4 0 -#endif - -/* Select optimized code variant when xt-xcc compiler is used */ -#if DRC_AUTOARCH == 1 -#if defined __XCC__ -#include -#if XCHAL_HAVE_HIFI4 == 1 -#define DRC_GENERIC 0 -#define DRC_HIFI3 0 -#define DRC_HIFI4 1 -#elif XCHAL_HAVE_HIFI3 == 1 -#define DRC_GENERIC 0 -#define DRC_HIFI3 1 -#define DRC_HIFI4 0 -#else -#define DRC_GENERIC 1 -#define DRC_HIFI3 0 -#define DRC_HIFI4 0 -#endif /* XCHAL_HAVE_HIFI3 */ -#else -/* GCC */ -#define DRC_GENERIC 1 -#define DRC_HIFI3 0 -#define DRC_HIFI4 0 -#endif /* __XCC__ */ -#endif /* DRC_AUTOARCH */ - -#endif /* __SOF_AUDIO_DRC_DRC_PLAT_CONF_H__ */ 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