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 <baofeng.tian@intel.com>
This commit is contained in:
Baofeng Tian 2024-02-19 16:14:06 +08:00 committed by Liam Girdwood
parent 7e3f4a2f21
commit 80dd84c333
10 changed files with 61 additions and 67 deletions

View File

@ -1,5 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
rsource "Kconfig.simd"
config COMP_DRC
bool "Dynamic Range Compressor component"
select CORDIC_FIXED

View File

@ -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

View File

@ -12,7 +12,6 @@
#include <sof/audio/buffer.h>
#include <sof/platform.h>
#include "drc_plat_conf.h"
#include "drc_user.h"
struct audio_stream;

View File

@ -8,13 +8,14 @@
#include <sof/audio/format.h>
#include <sof/math/exp_fcn.h>
#include <sof/math/numbers.h>
#include <sof/common.h>
#include <stdint.h>
#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

View File

@ -8,13 +8,14 @@
#include <sof/audio/format.h>
#include <sof/math/exp_fcn.h>
#include <sof/math/numbers.h>
#include <sof/common.h>
#include <stdint.h>
#include "drc.h"
#include "drc_algorithm.h"
#include "drc_math.h"
#if DRC_HIFI3
#if SOF_USE_HIFI(3, DRC)
#include <xtensa/tie/xt_hifi3.h>
@ -494,4 +495,4 @@ void drc_compress_output(struct drc_state *state,
}
}
#endif /* DRC_HIFI3 */
#endif /* DRC_HIFI_3 */

View File

@ -8,13 +8,14 @@
#include <sof/audio/format.h>
#include <sof/math/exp_fcn.h>
#include <sof/math/numbers.h>
#include <sof/common.h>
#include <stdint.h>
#include "drc.h"
#include "drc_algorithm.h"
#include "drc_math.h"
#if DRC_HIFI4
#if SOF_USE_HIFI(4, DRC)
#include <xtensa/tie/xt_hifi4.h>
@ -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 */

View File

@ -13,13 +13,12 @@
#include <sof/math/numbers.h>
#include <sof/math/lut_trig.h>
#include <sof/math/trig.h>
#include "drc_plat_conf.h"
#include <sof/common.h>
/* 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 <xtensa/tie/xt_hifi3.h>
@ -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 */

View File

@ -9,13 +9,14 @@
#include <sof/math/exp_fcn.h>
#include <sof/math/numbers.h>
#include <sof/math/trig.h>
#include <sof/common.h>
#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

View File

@ -5,9 +5,10 @@
// Author: Pin-chih Lin <johnylin@google.com>
#include <sof/math/numbers.h>
#include <sof/common.h>
#include "drc_math.h"
#if DRC_HIFI3 || DRC_HIFI4
#if SOF_USE_HIFI(4, DRC) || SOF_USE_HIFI(3, DRC)
#include <xtensa/tie/xt_hifi3.h>
@ -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 */

View File

@ -1,51 +0,0 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2021 Google LLC. All rights reserved.
*
* Author: Pin-chih Lin <johnylin@google.com>
*/
#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 <xtensa/config/core-isa.h>
#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__ */