Sound Open Firmware
Loading...
Searching...
No Matches
crossover_common.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2023 Intel Corporation. All rights reserved.
4 *
5 * Author: Sebastiano Carlucci <scarlucci@google.com>
6 */
7
8#ifndef __SOF_CROSSOVER_COMMON_H__
9#define __SOF_CROSSOVER_COMMON_H__
10
12#include <sof/math/iir_df1.h>
13#include <user/eq.h>
14
15/* Number of sinks for a 2 way crossover filter */
16#define CROSSOVER_2WAY_NUM_SINKS 2
17/* Number of sinks for a 3 way crossover filter */
18#define CROSSOVER_3WAY_NUM_SINKS 3
19/* Number of sinks for a 4 way crossover filter */
20#define CROSSOVER_4WAY_NUM_SINKS 4
21/* Number of delay slots allocated for LR4 Filters */
22#define CROSSOVER_NUM_DELAYS_LR4 4
23/* Maximum number of LR4 highpass OR lowpass filters */
24#define CROSSOVER_MAX_LR4 3
25/* Maximum Number of sinks allowed in config */
26#define SOF_CROSSOVER_MAX_STREAMS 4
27
32 /* Store the state for each LR4 filter. */
35};
36
37typedef void (*crossover_split)(int32_t in, int32_t out[],
38 struct crossover_state *state);
39
41
42/* crossover init function */
44 struct sof_eq_iir_biquad *coef,
45 struct crossover_state *ch_state,
46 int32_t num_sinks);
47
51static inline void crossover_reset_state_lr4(struct processing_module *mod,
52 struct iir_state_df1 *lr4)
53{
54 mod_free(mod, lr4->coef);
55 mod_free(mod, lr4->delay);
56
57 lr4->coef = NULL;
58 lr4->delay = NULL;
59}
60
65static inline void crossover_reset_state_ch(struct processing_module *mod,
66 struct crossover_state *ch_state)
67{
68 int i;
69
70 for (i = 0; i < CROSSOVER_MAX_LR4; i++) {
71 crossover_reset_state_lr4(mod, &ch_state->lowpass[i]);
72 crossover_reset_state_lr4(mod, &ch_state->highpass[i]);
73 }
74}
75
79static inline crossover_split crossover_find_split_func(int32_t num_sinks)
80{
81 if (num_sinks < CROSSOVER_2WAY_NUM_SINKS ||
82 num_sinks > CROSSOVER_4WAY_NUM_SINKS)
83 return NULL;
84 // The functions in the map are offset by 2 indices.
86}
87
88#endif /* __SOF_CROSSOVER_COMMON_H__ */
#define CROSSOVER_2WAY_NUM_SINKS
Definition crossover_common.h:16
const crossover_split crossover_split_fnmap[]
#define CROSSOVER_MAX_LR4
Definition crossover_common.h:24
int crossover_init_coef_ch(struct processing_module *mod, struct sof_eq_iir_biquad *coef, struct crossover_state *ch_state, int32_t num_sinks)
static void crossover_reset_state_lr4(struct processing_module *mod, struct iir_state_df1 *lr4)
Reset the state of an LR4 filter.
Definition crossover_common.h:51
static void crossover_reset_state_ch(struct processing_module *mod, struct crossover_state *ch_state)
Reset the state (coefficients and delay) of the crossover filter of a single channel.
Definition crossover_common.h:65
#define CROSSOVER_4WAY_NUM_SINKS
Definition crossover_common.h:20
void(* crossover_split)(int32_t in, int32_t out[], struct crossover_state *state)
Definition crossover_common.h:37
static crossover_split crossover_find_split_func(int32_t num_sinks)
Returns Crossover split function.
Definition crossover_common.h:79
int mod_free(struct processing_module *mod, const void *ptr)
Free a memory block previously allocated for a module.
Infinite Impulse Response Direct Form I (DF1) filter definitions.
Stores the state of one channel of the Crossover filter.
Definition crossover_common.h:31
struct iir_state_df1 lowpass[CROSSOVER_MAX_LR4]
Definition crossover_common.h:33
struct iir_state_df1 highpass[CROSSOVER_MAX_LR4]
Definition crossover_common.h:34
Definition iir_df1.h:24
int32_t * coef
Definition iir_df1.h:29
int32_t * delay
Definition iir_df1.h:30
Definition base.h:103
Definition eq.h:127