From feed14db76643bfde254be21875635abdfe585ba Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 28 Aug 2024 19:47:33 +0300 Subject: [PATCH] Audio: Fix Xtensa HiFi5 build for audio processing components This patch avoids build error when testbench is built with a Xtensa HiFi5 tool chain. The same issue is assumed to happen in a normal firmware build as well. A new macro SOF_USE_MIN_HIFI(minlevel, component) is added. It can be used for the highest HiFi version optimization source to allow build with a toolchain that is for a higher HiFi version. E.g. build a HiFi4 module with toolchain for HiFi4 or HiFi5. The updated components those got build issues are: DCblock, DRC, FIR, TDFB, and IIR. Signed-off-by: Seppo Ingalsuo --- src/audio/dcblock/dcblock_hifi4.c | 2 +- src/audio/drc/drc_hifi4.c | 2 +- src/audio/drc/drc_math.h | 2 +- src/audio/drc/drc_math_hifi3.c | 2 +- src/audio/eq_fir/eq_fir.h | 4 ++-- src/audio/eq_fir/eq_fir_hifi3.c | 2 +- src/audio/tdfb/tdfb_comp.h | 2 +- src/include/sof/common.h | 11 +++++++++++ src/include/sof/math/fir_hifi3.h | 2 +- src/math/fir_hifi3.c | 2 +- src/math/iir_df1_hifi3.c | 2 +- src/math/iir_df2t_hifi3.c | 2 +- 12 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/audio/dcblock/dcblock_hifi4.c b/src/audio/dcblock/dcblock_hifi4.c index 44afa6834c91..f6ff06a55a63 100644 --- a/src/audio/dcblock/dcblock_hifi4.c +++ b/src/audio/dcblock/dcblock_hifi4.c @@ -10,7 +10,7 @@ #include "dcblock.h" -#if SOF_USE_HIFI(4, DCBLOCK) +#if SOF_USE_MIN_HIFI(4, DCBLOCK) #include LOG_MODULE_DECLARE(dcblock, CONFIG_SOF_LOG_LEVEL); diff --git a/src/audio/drc/drc_hifi4.c b/src/audio/drc/drc_hifi4.c index 6ae3f86bf50d..1e931616600c 100644 --- a/src/audio/drc/drc_hifi4.c +++ b/src/audio/drc/drc_hifi4.c @@ -15,7 +15,7 @@ #include "drc_algorithm.h" #include "drc_math.h" -#if SOF_USE_HIFI(4, DRC) +#if SOF_USE_MIN_HIFI(4, DRC) #include diff --git a/src/audio/drc/drc_math.h b/src/audio/drc/drc_math.h index 96c3e4e34868..09e210262e7e 100644 --- a/src/audio/drc/drc_math.h +++ b/src/audio/drc/drc_math.h @@ -18,7 +18,7 @@ /* Unmark this define to use cordic arc sine implementation. */ /* #define DRC_USE_CORDIC_ASIN */ -#if SOF_USE_HIFI(4, DRC) || SOF_USE_HIFI(3, DRC) +#if SOF_USE_MIN_HIFI(3, DRC) #include diff --git a/src/audio/drc/drc_math_hifi3.c b/src/audio/drc/drc_math_hifi3.c index f396eb3139ac..9ed82ac24d80 100644 --- a/src/audio/drc/drc_math_hifi3.c +++ b/src/audio/drc/drc_math_hifi3.c @@ -8,7 +8,7 @@ #include #include "drc_math.h" -#if SOF_USE_HIFI(4, DRC) || SOF_USE_HIFI(3, DRC) +#if SOF_USE_MIN_HIFI(3, DRC) #include diff --git a/src/audio/eq_fir/eq_fir.h b/src/audio/eq_fir/eq_fir.h index 6d3865efbdcc..921d39939d69 100644 --- a/src/audio/eq_fir/eq_fir.h +++ b/src/audio/eq_fir/eq_fir.h @@ -20,7 +20,7 @@ #if SOF_USE_HIFI(2, FILTER) #include #endif -#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) +#if SOF_USE_MIN_HIFI(3, FILTER) #include #endif #include @@ -77,7 +77,7 @@ int eq_fir_params(struct processing_module *mod); * set_fir_func. */ -#if SOF_USE_HIFI(2, FILTER) || SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) +#if SOF_USE_MIN_HIFI(2, FILTER) #if CONFIG_FORMAT_S16LE static inline void set_s16_fir(struct comp_data *cd) { diff --git a/src/audio/eq_fir/eq_fir_hifi3.c b/src/audio/eq_fir/eq_fir_hifi3.c index a607d6d05097..638b296a74c4 100644 --- a/src/audio/eq_fir/eq_fir_hifi3.c +++ b/src/audio/eq_fir/eq_fir_hifi3.c @@ -7,7 +7,7 @@ #include #include -#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) +#if SOF_USE_MIN_HIFI(3, FILTER) #include #include diff --git a/src/audio/tdfb/tdfb_comp.h b/src/audio/tdfb/tdfb_comp.h index e15684c2bd4a..e2d5075e06b5 100644 --- a/src/audio/tdfb/tdfb_comp.h +++ b/src/audio/tdfb/tdfb_comp.h @@ -20,7 +20,7 @@ /* 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) +#if SOF_USE_MIN_HIFI(3, FILTER) #define TDFB_HIFI3 1 #elif SOF_USE_HIFI(2, FILTER) #define TDFB_HIFI2 1 diff --git a/src/include/sof/common.h b/src/include/sof/common.h index 6968f3ba44e5..f07df7c85e4d 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -187,6 +187,17 @@ #define SOF_USE_HIFI(level, component) (SOF_CONFIG_HIFI(level, component) || \ (SOF_CONFIG_HIFI(MAX, component) && level == SOF_MAX_XCHAL_HIFI)) +/* True if: + * (1) EITHER this particular level was manually forced in Kconfig, + * (2) OR: - this component defaulted to "MAX" + * - AND this level is less or equal to max available in the XC HAL. + * + * Use e.g. for highest optimization level source file, e.g. SOF_USE_MIN_HIFI(4, component) + * for HiFi4 code version that can be built with HiFi4 or HiFi5 tool chain. + */ +#define SOF_USE_MIN_HIFI(minlevel, component) (SOF_CONFIG_HIFI(minlevel, component) || \ + (SOF_CONFIG_HIFI(MAX, component) && minlevel <= SOF_MAX_XCHAL_HIFI)) + #ifndef __XCC__ // Cadence toolchains: either xt-xcc or xt-clang. # define SOF_MAX_XCHAL_HIFI NONE #else diff --git a/src/include/sof/math/fir_hifi3.h b/src/include/sof/math/fir_hifi3.h index c6730021b955..1a9e626247d7 100644 --- a/src/include/sof/math/fir_hifi3.h +++ b/src/include/sof/math/fir_hifi3.h @@ -11,7 +11,7 @@ #include #include -#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) +#if SOF_USE_MIN_HIFI(3, FILTER) #include #include diff --git a/src/math/fir_hifi3.c b/src/math/fir_hifi3.c index a9cb19e3072f..e71fc47fc900 100644 --- a/src/math/fir_hifi3.c +++ b/src/math/fir_hifi3.c @@ -7,7 +7,7 @@ #include #include -#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) +#if SOF_USE_MIN_HIFI(3, FILTER) #include #include diff --git a/src/math/iir_df1_hifi3.c b/src/math/iir_df1_hifi3.c index d1aa05f55c0d..9351574ec23c 100644 --- a/src/math/iir_df1_hifi3.c +++ b/src/math/iir_df1_hifi3.c @@ -14,7 +14,7 @@ #include -#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) +#if SOF_USE_MIN_HIFI(3, FILTER) /* * Direct form I second order filter block (biquad) diff --git a/src/math/iir_df2t_hifi3.c b/src/math/iir_df2t_hifi3.c index 013af20a9ae4..13bddb32a9e6 100644 --- a/src/math/iir_df2t_hifi3.c +++ b/src/math/iir_df2t_hifi3.c @@ -13,7 +13,7 @@ #include #include -#if SOF_USE_HIFI(3, FILTER) || SOF_USE_HIFI(4, FILTER) +#if SOF_USE_MIN_HIFI(3, FILTER) #include