Skip to content

Commit

Permalink
Volume: Add volume simd build option
Browse files Browse the repository at this point in the history
Previously, volume simd version selection is based on compiler toolchain,
this change keep the original logic as default, if there is no valid
simd option was selected.

If there is a selection from kconfig, then this option will override
compiler build option and be used to build volume module.

Signed-off-by: Baofeng Tian <[email protected]>
  • Loading branch information
btian1 committed Jan 25, 2024
1 parent ac76b3e commit 130f26a
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/audio/volume/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

if COMP_VOLUME

rsource "Kconfig.simd"

config COMP_VOLUME_WINDOWS_FADE
bool "Windows Fade shape volume transitions support"
help
Expand Down
32 changes: 32 additions & 0 deletions src/audio/volume/Kconfig.simd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-License-Identifier: BSD-3-Clause

comment "volume optimization level select"

choice "VOLUME_SIMD_LEVEL_SELECT"
prompt "choose which SIMD level used for volume module"

config VOLUME_SIMD_TOOLCHAIN_SELECT
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 VOLUME_HIFI3
prompt "choose HIFI3 intrinsic optimized volume module"
bool
help
This option used to build HIFI3 intrinsic optimized volume code

config VOLUME_HIFI4
prompt "choose HIFI4 intrinsic optimized volume module"
bool
help
This option used to build HIFI4 optimized volume code

config VOLUME_GENERIC
prompt "choose generic C volume module, no SIMD involved"
bool
help
This option used to build volume generic code.
endchoice
2 changes: 1 addition & 1 deletion src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ static int volume_process(struct processing_module *mod,
cd->peak_cnt = 0;
peak_vol_update(cd);
memset(cd->peak_regs.peak_meter, 0, sizeof(cd->peak_regs.peak_meter));
#ifdef VOLUME_HIFI4
#if CONFIG_VOLUME_HIFI4
memset(cd->peak_vol, 0, sizeof(int32_t) * SOF_IPC_MAX_CHANNELS * 4);
#endif
}
Expand Down
10 changes: 6 additions & 4 deletions src/audio/volume/volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ struct sof_ipc_ctrl_value_chan;

#if defined(__XCC__)
# include <xtensa/config/core-isa.h>
#if CONFIG_VOLUME_SIMD_TOOLCHAIN_SELECT
# if XCHAL_HAVE_HIFI4
# define VOLUME_HIFI4
# define CONFIG_VOLUME_HIFI4 1
# elif XCHAL_HAVE_HIFI3
# define VOLUME_HIFI3
# define CONFIG_VOLUME_HIFI3 1
# else
# define VOLUME_GENERIC
# define CONFIG_VOLUME_GENERIC 1
# endif
#endif
#else
# define VOLUME_GENERIC
# define CONFIG_VOLUME_GENERIC 1
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion src/audio/volume/volume_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LOG_MODULE_DECLARE(volume_generic, CONFIG_SOF_LOG_LEVEL);

#include "volume.h"

#ifdef VOLUME_GENERIC
#if CONFIG_VOLUME_GENERIC

#if (!CONFIG_COMP_PEAK_VOL)

Expand Down
2 changes: 1 addition & 1 deletion src/audio/volume/volume_generic_with_peakvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LOG_MODULE_DECLARE(volume_generic, CONFIG_SOF_LOG_LEVEL);

#include "volume.h"

#ifdef VOLUME_GENERIC
#if CONFIG_VOLUME_GENERIC

#if CONFIG_COMP_PEAK_VOL

Expand Down
2 changes: 1 addition & 1 deletion src/audio/volume/volume_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(volume_hifi3, CONFIG_SOF_LOG_LEVEL);

#include "volume.h"

#ifdef VOLUME_HIFI3
#if CONFIG_VOLUME_HIFI3

#if (!CONFIG_COMP_PEAK_VOL)

Expand Down
2 changes: 1 addition & 1 deletion src/audio/volume/volume_hifi3_with_peakvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(volume_hifi3, CONFIG_SOF_LOG_LEVEL);

#include "volume.h"

#ifdef VOLUME_HIFI3
#if CONFIG_VOLUME_HIFI3

#if CONFIG_COMP_PEAK_VOL

Expand Down
2 changes: 1 addition & 1 deletion src/audio/volume/volume_hifi4.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(volume_hifi4, CONFIG_SOF_LOG_LEVEL);

#include "volume.h"

#ifdef VOLUME_HIFI4
#if CONFIG_VOLUME_HIFI4

#if (!CONFIG_COMP_PEAK_VOL)

Expand Down
2 changes: 1 addition & 1 deletion src/audio/volume/volume_hifi4_with_peakvol.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LOG_MODULE_DECLARE(volume_hifi4, CONFIG_SOF_LOG_LEVEL);

#include "volume.h"

#ifdef VOLUME_HIFI4
#if CONFIG_VOLUME_HIFI4

#if CONFIG_COMP_PEAK_VOL
#include <xtensa/tie/xt_hifi4.h>
Expand Down

0 comments on commit 130f26a

Please sign in to comment.