Skip to content

Commit

Permalink
DRC: add simd build option to DRC
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
btian1 authored and lgirdwood committed Feb 26, 2024
1 parent 7e3f4a2 commit 80dd84c
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 67 deletions.
2 changes: 2 additions & 0 deletions src/audio/drc/Kconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

rsource "Kconfig.simd"

config COMP_DRC
bool "Dynamic Range Compressor component"
select CORDIC_FIXED
Expand Down
40 changes: 40 additions & 0 deletions src/audio/drc/Kconfig.simd
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion src/audio/drc/drc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions src/audio/drc/drc_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/audio/drc/drc_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -494,4 +495,4 @@ void drc_compress_output(struct drc_state *state,
}
}

#endif /* DRC_HIFI3 */
#endif /* DRC_HIFI_3 */
5 changes: 3 additions & 2 deletions src/audio/drc/drc_hifi4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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 */
7 changes: 3 additions & 4 deletions src/audio/drc/drc_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions src/audio/drc/drc_math_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/audio/drc/drc_math_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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 */
51 changes: 0 additions & 51 deletions src/audio/drc/drc_plat_conf.h

This file was deleted.

0 comments on commit 80dd84c

Please sign in to comment.