Skip to content

Commit

Permalink
Audio: Volume: Add HiFi5 implementation.
Browse files Browse the repository at this point in the history
Add HiFi5 implementation of volume functions, compared with
HiFi3 version, can reduce about 28% cycles.

Signed-off-by: Andrula Song <andrula.song@intel.com>
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
  • Loading branch information
andrula-song authored and singalsu committed Oct 29, 2024
1 parent f809e13 commit 256b68c
Show file tree
Hide file tree
Showing 10 changed files with 1,176 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/audio/volume/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ if(CONFIG_COMP_VOLUME)
volume_generic.c
volume_hifi3.c
volume_hifi4.c
volume_hifi5.c
volume_generic_with_peakvol.c
volume_hifi3_with_peakvol.c
volume_hifi4_with_peakvol.c
volume_hifi5_with_peakvol.c
volume.c)
if(CONFIG_IPC_MAJOR_3)
add_local_sources(sof volume_ipc3.c)
Expand Down
6 changes: 6 additions & 0 deletions src/audio/volume/Kconfig.simd
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ choice "VOLUME_SIMD_LEVEL_SELECT"
When this was selected, optimization level will be determined
by toolchain pre-defined macros in core isa header file.

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

config VOLUME_HIFI_4
prompt "choose HIFI4 intrinsic optimized volume module"
bool
Expand Down
14 changes: 10 additions & 4 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,19 +646,25 @@ static vol_zc_func vol_get_zc_function(struct comp_dev *dev,
static void volume_set_alignment(struct audio_stream *source,
struct audio_stream *sink)
{
#if SOF_USE_HIFI(3, VOLUME) || SOF_USE_HIFI(4, VOLUME) || SOF_USE_HIFI(5, VOLUME)
/* Both source and sink buffer in HiFi 3 or HiFi4 processing version,
/* Both source and sink buffer in HiFi5 processing version,
* xtensa intrinsics ask for 16-byte aligned.
*
* Both source and sink buffer in HiFi3 or HiFi4 processing version,
* xtensa intrinsics ask for 8-byte aligned. 5.1 format SSE audio
* requires 16-byte aligned.
*/
const uint32_t byte_align = audio_stream_get_channels(source) == 6 ? 16 : 8;
#if SOF_USE_HIFI(3, VOLUME) || SOF_USE_HIFI(4, VOLUME)
const uint32_t byte_align = audio_stream_get_channels(source) == 6 ?
VOLUME_HIFI3_HIFI4_FRAME_BYTE_ALIGN_6CH : SOF_FRAME_BYTE_ALIGN;
#else
const uint32_t byte_align = SOF_FRAME_BYTE_ALIGN;
#endif

/*There is no limit for frame number, so both source and sink set it to be 1*/
const uint32_t frame_align_req = 1;

audio_stream_set_align(byte_align, frame_align_req, source);
audio_stream_set_align(byte_align, frame_align_req, sink);
#endif
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/audio/volume/volume.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ struct sof_ipc_ctrl_value_chan;
#define VOL_S16_SAMPLES_TO_BYTES(s) ((s) << 1)
#define VOL_S32_SAMPLES_TO_BYTES(s) ((s) << 2)

/**
* \brief Bytes align requirement for 6ch PCM frame on HiFi3 and Hifi4
* platforms for volume component.
*/
#define VOLUME_HIFI3_HIFI4_FRAME_BYTE_ALIGN_6CH 16

/**
* \brief volume processing function interface
*/
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"

#if SOF_USE_HIFI(4, VOLUME) || SOF_USE_HIFI(5, VOLUME)
#if SOF_USE_HIFI(4, VOLUME)

#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"

#if SOF_USE_HIFI(4, VOLUME) || SOF_USE_HIFI(5, VOLUME)
#if SOF_USE_HIFI(4, VOLUME)

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

0 comments on commit 256b68c

Please sign in to comment.