sof: math: move iir_df2t function to src/math

Moved iir_df2t() from src/audio/eq_iir to src/math as a common library for
IIR and Crossover usage.

Signed-off-by: Pin-chih Lin <johnylin@google.com>
This commit is contained in:
Pin-chih Lin 2020-08-11 14:08:51 +08:00 committed by Liam Girdwood
parent 5777ef7903
commit baa43558f6
8 changed files with 72 additions and 55 deletions

View File

@ -122,7 +122,7 @@ 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-iir_sources eq_iir/eq_iir.c eq_iir/iir.c eq_iir/iir_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)
foreach(audio_module ${sof_audio_modules})

View File

@ -1,3 +1,3 @@
# SPDX-License-Identifier: BSD-3-Clause
add_local_sources(sof eq_iir.c iir.c iir_generic.c iir_hifi3.c)
add_local_sources(sof eq_iir.c iir.c)

View File

@ -19,6 +19,7 @@
#include <sof/lib/memory.h>
#include <sof/lib/uuid.h>
#include <sof/list.h>
#include <sof/math/iir_df2t.h>
#include <sof/platform.h>
#include <sof/string.h>
#include <sof/ut.h>

View File

@ -12,57 +12,11 @@
#include <stddef.h>
#include <stdint.h>
#include <sof/audio/format.h>
#include <sof/math/iir_df2t.h>
struct sof_eq_iir_header_df2t;
/* Get platforms configuration */
/* If next defines are set to 1 the EQ is configured automatically. Setting
* to zero temporarily is useful is for testing needs.
* Setting EQ_FIR_AUTOARCH to 0 allows to manually set the code variant.
*/
#define IIR_AUTOARCH 1
/* Force manually some code variant when IIR_AUTOARCH is set to zero. These
* are useful in code debugging.
*/
#if IIR_AUTOARCH == 0
#define IIR_GENERIC 1
#define IIR_HIFI3 0
#endif
/* Select optimized code variant when xt-xcc compiler is used */
#if IIR_AUTOARCH == 1
#if defined __XCC__
#include <xtensa/config/core-isa.h>
#if XCHAL_HAVE_HIFI3 == 1
#define IIR_GENERIC 0
#define IIR_HIFI3 1
#else
#define IIR_GENERIC 1
#define IIR_HIFI3 0
#endif /* XCHAL_HAVE_HIFI3 */
#else
/* GCC */
#define IIR_GENERIC 1
#define IIR_HIFI3 0
#endif /* __XCC__ */
#endif /* IIR_AUTOARCH */
#define IIR_DF2T_NUM_DELAYS 2
struct iir_state_df2t {
unsigned int biquads; /* Number of IIR 2nd order sections total */
unsigned int biquads_in_series; /* Number of IIR 2nd order sections
* in series.
*/
int32_t *coef; /* Pointer to IIR coefficients */
int64_t *delay; /* Pointer to IIR delay line */
};
int32_t iir_df2t(struct iir_state_df2t *iir, int32_t x);
int iir_init_coef_df2t(struct iir_state_df2t *iir,
struct sof_eq_iir_header_df2t *config);

View File

@ -0,0 +1,63 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2017 Intel Corporation. All rights reserved.
*
* Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
* Liam Girdwood <liam.r.girdwood@linux.intel.com>
* Keyon Jie <yang.jie@linux.intel.com>
*/
#ifndef __SOF_MATH_IIR_DF2T_H__
#define __SOF_MATH_IIR_DF2T_H__
#include <stddef.h>
#include <stdint.h>
/* Get platforms configuration */
/* If next defines are set to 1 the EQ is configured automatically. Setting
* to zero temporarily is useful is for testing needs.
* Setting EQ_FIR_AUTOARCH to 0 allows to manually set the code variant.
*/
#define IIR_AUTOARCH 1
/* Force manually some code variant when IIR_AUTOARCH is set to zero. These
* are useful in code debugging.
*/
#if IIR_AUTOARCH == 0
#define IIR_GENERIC 1
#define IIR_HIFI3 0
#endif
/* Select optimized code variant when xt-xcc compiler is used */
#if IIR_AUTOARCH == 1
#if defined __XCC__
#include <xtensa/config/core-isa.h>
#if XCHAL_HAVE_HIFI3 == 1
#define IIR_GENERIC 0
#define IIR_HIFI3 1
#else
#define IIR_GENERIC 1
#define IIR_HIFI3 0
#endif /* XCHAL_HAVE_HIFI3 */
#else
/* GCC */
#define IIR_GENERIC 1
#define IIR_HIFI3 0
#endif /* __XCC__ */
#endif /* IIR_AUTOARCH */
#define IIR_DF2T_NUM_DELAYS 2
struct iir_state_df2t {
unsigned int biquads; /* Number of IIR 2nd order sections total */
unsigned int biquads_in_series; /* Number of IIR 2nd order sections
* in series.
*/
int32_t *coef; /* Pointer to IIR coefficients */
int64_t *delay; /* Pointer to IIR delay line */
};
int32_t iir_df2t(struct iir_state_df2t *iir, int32_t x);
#endif /* __SOF_MATH_IIR_DF2T_H__ */

View File

@ -1,9 +1,9 @@
# SPDX-License-Identifier: BSD-3-Clause
add_local_sources(sof numbers.c trig.c decibels.c)
add_local_sources(sof numbers.c trig.c decibels.c iir_df2t_generic.c iir_df2t_hifi3.c)
if(BUILD_LIBRARY)
return()
endif()
add_local_sources(sof trig.c decibels.c)
add_local_sources(sof trig.c decibels.c iir_df2t_generic.c iir_df2t_hifi3.c)

View File

@ -6,8 +6,8 @@
// Liam Girdwood <liam.r.girdwood@linux.intel.com>
// Keyon Jie <yang.jie@linux.intel.com>
#include <sof/audio/eq_iir/iir.h>
#include <sof/audio/format.h>
#include <sof/math/iir_df2t.h>
#include <user/eq.h>
#include <errno.h>
#include <stddef.h>
@ -105,4 +105,3 @@ int32_t iir_df2t(struct iir_state_df2t *iir, int32_t x)
}
#endif

View File

@ -10,7 +10,7 @@
#include <stddef.h>
#include <errno.h>
#include <sof/audio/format.h>
#include <sof/audio/eq_iir/iir.h>
#include <sof/math/iir_df2t.h>
#include <user/eq.h>
#if IIR_HIFI3