Skip to content

Commit

Permalink
audio: crossover: move some inline functions to header file
Browse files Browse the repository at this point in the history
This is a clean up, purpose is declutter headers, toml files,
Readme.md etc per module basis, since today everything is scattered
in current code base.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
  • Loading branch information
btian1 committed Dec 14, 2023
1 parent 612a400 commit a8cbf37
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
34 changes: 1 addition & 33 deletions src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,43 +46,11 @@ DECLARE_SOF_RT_UUID("crossover", crossover_uuid, 0x948c9ad1, 0x806a, 0x4131,

DECLARE_TR_CTX(crossover_tr, SOF_UUID(crossover_uuid), LOG_LEVEL_INFO);

static inline void crossover_free_config(struct sof_crossover_config **config)
{
rfree(*config);
*config = NULL;
}

/**
* \brief Reset the state of an LR4 filter.
*/
static inline void crossover_reset_state_lr4(struct iir_state_df2t *lr4)
{
rfree(lr4->coef);
rfree(lr4->delay);

lr4->coef = NULL;
lr4->delay = NULL;
}

/**
* \brief Reset the state (coefficients and delay) of the crossover filter
* of a single channel.
*/
inline void crossover_reset_state_ch(struct crossover_state *ch_state)
{
int i;

for (i = 0; i < CROSSOVER_MAX_LR4; i++) {
crossover_reset_state_lr4(&ch_state->lowpass[i]);
crossover_reset_state_lr4(&ch_state->highpass[i]);
}
}

/**
* \brief Reset the state (coefficients and delay) of the crossover filter
* across all channels
*/
static inline void crossover_reset_state(struct comp_data *cd)
static void crossover_reset_state(struct comp_data *cd)
{
int i;

Expand Down
6 changes: 6 additions & 0 deletions src/audio/crossover/crossover.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,10 @@ static inline int32_t crossover_generic_process_lr4(int32_t in,
return iir_df2t(lr4, in);
}

static inline void crossover_free_config(struct sof_crossover_config **config)
{
rfree(*config);
*config = NULL;
}

#endif // __SOF_AUDIO_CROSSOVER_CROSSOVER_H__
28 changes: 26 additions & 2 deletions src/audio/crossover/crossover_algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,36 @@
#include <stdint.h>
#include <sof/platform.h>
#include <sof/math/iir_df2t.h>
#include <rtos/alloc.h>

#include "crossover_user.h"
#include "crossover.h"

/* crossover reset function */
void crossover_reset_state_ch(struct crossover_state *ch_state);
/**
* \brief Reset the state of an LR4 filter.
*/
static inline void crossover_reset_state_lr4(struct iir_state_df2t *lr4)
{
rfree(lr4->coef);
rfree(lr4->delay);

lr4->coef = NULL;
lr4->delay = NULL;
}

/**
* \brief Reset the state (coefficients and delay) of the crossover filter
* of a single channel.
*/
static inline void crossover_reset_state_ch(struct crossover_state *ch_state)
{
int i;

for (i = 0; i < CROSSOVER_MAX_LR4; i++) {
crossover_reset_state_lr4(&ch_state->lowpass[i]);
crossover_reset_state_lr4(&ch_state->highpass[i]);
}
}

/* crossover init function */
int crossover_init_coef_ch(struct sof_eq_iir_biquad *coef,
Expand Down

0 comments on commit a8cbf37

Please sign in to comment.