From 80dd84c333e25de5f742d90d36c840586e2d23a4 Mon Sep 17 00:00:00 2001 From: Baofeng Tian Date: Mon, 19 Feb 2024 16:14:06 +0800 Subject: [PATCH] DRC: add simd build option to DRC Add HIFI build option to DRC module, with this, developer are able to select HIFI version for SOF build. Signed-off-by: Baofeng Tian --- src/audio/drc/Kconfig | 2 ++ src/audio/drc/Kconfig.simd | 40 +++++++++++++++++++++++++ src/audio/drc/drc.h | 1 - src/audio/drc/drc_generic.c | 7 +++-- src/audio/drc/drc_hifi3.c | 5 ++-- src/audio/drc/drc_hifi4.c | 5 ++-- src/audio/drc/drc_math.h | 7 ++--- src/audio/drc/drc_math_generic.c | 5 ++-- src/audio/drc/drc_math_hifi3.c | 5 ++-- src/audio/drc/drc_plat_conf.h | 51 -------------------------------- 10 files changed, 61 insertions(+), 67 deletions(-) create mode 100644 src/audio/drc/Kconfig.simd delete mode 100644 src/audio/drc/drc_plat_conf.h diff --git a/src/audio/drc/Kconfig b/src/audio/drc/Kconfig index dfc5aba4f..9e6aaf638 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 000000000..498758c48 --- /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 012362433..5598d64c8 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 bc16fc670..8ace19623 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 73f171fd7..3a5d23c7d 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 b414831a3..6ae3f86bf 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 0d89fd77a..96c3e4e34 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 436ee444c..574a387bf 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 de6ca4636..90cad95e0 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 8bdab58bb..000000000 --- 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__ */