Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ src/audio/kpb.c @mrajwa
src/audio/mux/* @akloniex
src/audio/dcblock* @cujomalainey @dgreid
src/audio/crossover* @cujomalainey @dgreid
src/audio/tdfb* @singalsu

# platforms
src/platform/baytrail/* @xiulipan
Expand Down
1 change: 1 addition & 0 deletions src/arch/xtensa/configs/baytrail_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ CONFIG_COMP_IIR=n
CONFIG_COMP_DCBLOCK=n
CONFIG_COMP_SRC=n
CONFIG_COMP_ASRC=n
CONFIG_COMP_TDFB=n
CONFIG_OPTIMIZE_FOR_SIZE=y
CONFIG_HAVE_AGENT=n
1 change: 1 addition & 0 deletions src/arch/xtensa/configs/baytrail_gcc_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ CONFIG_COMP_IIR=n
CONFIG_COMP_DCBLOCK=n
CONFIG_COMP_SRC=n
CONFIG_COMP_ASRC=n
CONFIG_COMP_TDFB=n
CONFIG_HAVE_AGENT=n
1 change: 1 addition & 0 deletions src/arch/xtensa/configs/cherrytrail_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ CONFIG_COMP_IIR=n
CONFIG_COMP_DCBLOCK=n
CONFIG_COMP_ASRC=n
CONFIG_COMP_SRC=n
CONFIG_COMP_TDFB=n
CONFIG_OPTIMIZE_FOR_SIZE=y
CONFIG_HAVE_AGENT=n
1 change: 1 addition & 0 deletions src/arch/xtensa/configs/cherrytrail_gcc_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ CONFIG_COMP_IIR=n
CONFIG_COMP_DCBLOCK=n
CONFIG_COMP_SRC=n
CONFIG_COMP_ASRC=n
CONFIG_COMP_TDFB=n
CONFIG_HAVE_AGENT=n
8 changes: 6 additions & 2 deletions src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ if(NOT CONFIG_LIBRARY)
if(CONFIG_COMP_CROSSOVER)
add_subdirectory(crossover)
endif()
if(CONFIG_COMP_TDFB)
add_subdirectory(tdfb)
endif()
if(CONFIG_COMP_TONE)
add_local_sources(sof
tone.c
Expand Down Expand Up @@ -119,16 +122,17 @@ check_optimization(fma -mfma -DOPS_FMA)
check_optimization(hifi2ep -mhifi2ep -DOPS_HIFI2EP)
check_optimization(hifi3 -mhifi3 -DOPS_HIFI3)

set(sof_audio_modules volume src asrc eq-fir eq-iir dcblock crossover)
set(sof_audio_modules volume src asrc eq-fir eq-iir dcblock crossover tdfb)

# sources for each module
set(volume_sources volume/volume.c volume/volume_generic.c)
set(src_sources src/src.c src/src_generic.c)
set(asrc_sources asrc/asrc.c asrc/asrc_farrow.c asrc/asrc_farrow_generic.c)
set(eq-fir_sources eq_fir/eq_fir.c eq_fir/fir.c)
set(eq-fir_sources eq_fir/eq_fir.c eq_fir/eq_fir_generic.c)
set(eq-iir_sources eq_iir/eq_iir.c eq_iir/iir.c)
set(dcblock_sources dcblock/dcblock.c dcblock/dcblock_generic.c)
set(crossover_sources crossover/crossover.c crossover/crossover_generic.c)
set(tdfb_sources tdfb/tdfb.c tdfb/tdfb_generic.c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are you linking this against fir?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, I'm not good with cmake... I assume the maths library where FIR is by default is included to link of SOF. I haven't seen issues with SOF images and testbench build. But there was one case where link with cmake did the build and actual compile phase was skipped so I need to check this is not a similar case (by observing build shell text output). But is such check enough?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@singalsu pls work with @juimonen here, there should be a Kconfig dependency/select already for FIR users so that if any FIR client is enabled then this would also build FIR core. It's also possible in your testing that FIR is already being built by another client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I noticed myself the mistake now. It's easy to fix and test, at least the make menuconfig ui level issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is here, sorry for missing you point. This makes the make menuconfig UI work logically. MATH_FIR is enabled when FIR EQ or TDFB is enabled.

diff --git a/src/audio/Kconfig b/src/audio/Kconfig
index 56dd2d858330..f3b04e893afb 100644
--- a/src/audio/Kconfig
+++ b/src/audio/Kconfig
@@ -302,7 +302,7 @@ endif # COMP_ASRC
 
 config COMP_TDFB
        bool "TDFB component"
-        depends on COMP_FIR
+       select MATH_FIR
        default y
        help
          Select for time domain fixed beamformer (TDFB) component. The

CMakeLists.txt in math directory already contained this:

if(CONFIG_MATH_FIR)
        add_local_sources(sof fir_generic.c fir_hifi2ep.c fir_hifi3.c)
endif()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, this fix is in current version.


foreach(audio_module ${sof_audio_modules})
# first compile with no optimizations
Expand Down
25 changes: 25 additions & 0 deletions src/audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,19 @@ endchoice

endif # SRC

config MATH_FIR
bool "FIR filter library"
default n
help
This option builds FIR (Finite Impulse Response) filter library. It
is selected by components for their digital signal processing. A FIR
filter calculates a convolution of input PCM sample and a configurable
impulse response.


config COMP_FIR
bool "FIR component"
select MATH_FIR
default y
help
Select for FIR component. FIR performance can differ between DSP
Expand Down Expand Up @@ -289,6 +300,20 @@ endmenu # "Downsampling ratios"

endif # COMP_ASRC

config COMP_TDFB
bool "TDFB component"
select MATH_FIR
default y
help
Select for time domain fixed beamformer (TDFB) component. The
beamformer component enhances microphone capture by spatial
suppression of noise and improvement of signal-to-noise ratio of
capture from beam direction. The component is essentially a generic
single rate FIR filter bank that performs microphone array
directivity enhancement when programmed with suitable configuration
for channels selection, channel filter coefficients, and output
streams mixing.

endmenu # "Audio components"

menu "Data formats"
Expand Down
2 changes: 1 addition & 1 deletion src/audio/eq_fir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause

add_local_sources(sof eq_fir.c fir_hifi2ep.c fir_hifi3.c fir.c)
add_local_sources(sof eq_fir.c eq_fir_generic.c eq_fir_hifi2ep.c eq_fir_hifi3.c)
51 changes: 11 additions & 40 deletions src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Liam Girdwood <liam.r.girdwood@linux.intel.com>
// Keyon Jie <yang.jie@linux.intel.com>

#include <sof/audio/eq_fir/eq_fir.h>
#include <sof/audio/buffer.h>
#include <sof/audio/component.h>
#include <sof/audio/eq_fir/fir_config.h>
#include <sof/audio/pipeline.h>
#include <sof/common.h>
#include <sof/debug/panic.h>
Expand All @@ -17,6 +17,7 @@
#include <sof/lib/memory.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
#include <sof/math/fir_config.h>
#include <sof/platform.h>
#include <sof/string.h>
#include <sof/ut.h>
Expand All @@ -26,23 +27,12 @@
#include <ipc/topology.h>
#include <kernel/abi.h>
#include <user/eq.h>
#include <user/fir.h>
#include <user/trace.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>

#if FIR_GENERIC
#include <sof/audio/eq_fir/fir.h>
#endif

#if FIR_HIFIEP
#include <sof/audio/eq_fir/fir_hifi2ep.h>
#endif

#if FIR_HIFI3
#include <sof/audio/eq_fir/fir_hifi3.h>
#endif

static const struct comp_driver comp_eq_fir;

/* 43a90ce7-f3a5-41df-ac06-ba98651ae6a3 */
Expand Down Expand Up @@ -71,45 +61,26 @@ struct comp_data {
* set_fir_func.
*/

#if FIR_HIFI3
#if FIR_HIFI3 || FIR_HIFIEP
#if CONFIG_FORMAT_S16LE
static inline void set_s16_fir(struct comp_data *cd)
{
cd->eq_fir_func = eq_fir_2x_s16_hifi3;
cd->eq_fir_func = eq_fir_2x_s16;
}
#endif /* CONFIG_FORMAT_S16LE */
#if CONFIG_FORMAT_S24LE
static inline void set_s24_fir(struct comp_data *cd)
{
cd->eq_fir_func = eq_fir_2x_s24_hifi3;
cd->eq_fir_func = eq_fir_2x_s24;
}
#endif /* CONFIG_FORMAT_S24LE */
#if CONFIG_FORMAT_S32LE
static inline void set_s32_fir(struct comp_data *cd)
{
cd->eq_fir_func = eq_fir_2x_s32_hifi3;
cd->eq_fir_func = eq_fir_2x_s32;
}
#endif /* CONFIG_FORMAT_S32LE */

#elif FIR_HIFIEP
#if CONFIG_FORMAT_S16LE
static inline void set_s16_fir(struct comp_data *cd)
{
cd->eq_fir_func = eq_fir_2x_s16_hifiep;
}
#endif /* CONFIG_FORMAT_S16LE */
#if CONFIG_FORMAT_S24LE
static inline void set_s24_fir(struct comp_data *cd)
{
cd->eq_fir_func = eq_fir_2x_s24_hifiep;
}
#endif /* CONFIG_FORMAT_S24LE */
#if CONFIG_FORMAT_S32LE
static inline void set_s32_fir(struct comp_data *cd)
{
cd->eq_fir_func = eq_fir_2x_s32_hifiep;
}
#endif /* CONFIG_FORMAT_S32LE */
#else
/* FIR_GENERIC */
#if CONFIG_FORMAT_S16LE
Expand Down Expand Up @@ -196,8 +167,8 @@ static void eq_fir_free_delaylines(struct comp_data *cd)
static int eq_fir_init_coef(struct sof_eq_fir_config *config,
struct fir_state_32x16 *fir, int nch)
{
struct sof_eq_fir_coef_data *lookup[SOF_EQ_FIR_MAX_RESPONSES];
struct sof_eq_fir_coef_data *eq;
struct sof_fir_coef_data *lookup[SOF_EQ_FIR_MAX_RESPONSES];
struct sof_fir_coef_data *eq;
int16_t *assign_response;
int16_t *coef_data;
size_t size_sum = 0;
Expand Down Expand Up @@ -229,9 +200,9 @@ static int eq_fir_init_coef(struct sof_eq_fir_config *config,
4);
for (i = 0; i < SOF_EQ_FIR_MAX_RESPONSES; i++) {
if (i < config->number_of_responses) {
eq = (struct sof_eq_fir_coef_data *)&coef_data[j];
eq = (struct sof_fir_coef_data *)&coef_data[j];
lookup[i] = eq;
j += SOF_EQ_FIR_COEF_NHEADER + coef_data[j];
j += SOF_FIR_COEF_NHEADER + coef_data[j];
} else {
lookup[i] = NULL;
}
Expand Down
54 changes: 4 additions & 50 deletions src/audio/eq_fir/fir.c → src/audio/eq_fir/eq_fir_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,16 @@
// Liam Girdwood <liam.r.girdwood@linux.intel.com>
// Keyon Jie <yang.jie@linux.intel.com>

#include <sof/audio/eq_fir/fir_config.h>
#include <sof/math/fir_config.h>

#if FIR_GENERIC

#include <sof/common.h>
#include <sof/audio/buffer.h>
#include <sof/audio/eq_fir/fir.h>
#include <sof/audio/format.h>
#include <user/eq.h>
#include <sof/audio/eq_fir/eq_fir.h>
#include <sof/math/fir_generic.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>

/*
* EQ FIR algorithm code
*/

void fir_reset(struct fir_state_32x16 *fir)
{
fir->rwi = 0;
fir->length = 0;
fir->out_shift = 0;
fir->coef = NULL;
/* There may need to know the beginning of dynamic allocation after
* reset so omitting setting also fir->delay to NULL.
*/
}

int fir_delay_size(struct sof_eq_fir_coef_data *config)
{
/* Check for sane FIR length. The generic version does not
* have other constraints.
*/
if (config->length > SOF_EQ_FIR_MAX_LENGTH || config->length < 1)
return -EINVAL;

return config->length * sizeof(int32_t);
}

int fir_init_coef(struct fir_state_32x16 *fir,
struct sof_eq_fir_coef_data *config)
{
fir->rwi = 0;
fir->length = (int)config->length;
fir->taps = fir->length; /* The same for generic C version */
fir->out_shift = (int)config->out_shift;
fir->coef = ASSUME_ALIGNED(&config->coef[0], 4);
return 0;
}

void fir_init_delay(struct fir_state_32x16 *fir, int32_t **data)
{
fir->delay = *data;
*data += fir->length; /* Point to next delay line start */
}

#if CONFIG_FORMAT_S16LE
void eq_fir_s16(struct fir_state_32x16 fir[], const struct audio_stream *source,
struct audio_stream *sink, int frames, int nch)
Expand Down Expand Up @@ -138,4 +92,4 @@ void eq_fir_s32(struct fir_state_32x16 fir[], const struct audio_stream *source,
}
#endif /* CONFIG_FORMAT_S32LE */

#endif
#endif /* FIR_GENERIC */
Loading