Skip to content

Commit ed54993

Browse files
committed
Audio: eq_fir: move out eq_fir ipc3 and ipc4 specific code
Move out ipc3 and ipc4 specific code to corresponding source file. Also, move some common functions to header file. Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
1 parent dc17f23 commit ed54993

9 files changed

Lines changed: 276 additions & 159 deletions

File tree

src/audio/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,12 @@ if(CONFIG_IPC_MAJOR_3)
176176
set(volume_sources volume/volume.c volume/volume_generic.c volume/volume_ipc3.c)
177177
set(src_sources src/src.c src/src_ipc3.c src/src_generic.c)
178178
set(eq-iir_sources eq_iir/eq_iir_ipc3.c eq_iir/eq_iir_generic.c)
179+
set(eq-fir_sources eq_fir/eq_fir_ipc3.c)
179180
elseif(CONFIG_IPC_MAJOR_4)
180181
set(volume_sources volume/volume.c volume/volume_generic.c volume/volume_ipc4.c)
181182
set(src_sources src/src.c src/src_ipc4.c src/src_generic.c)
182183
set(eq-iir_sources eq_iir/eq_iir_ipc4.c eq_iir/eq_iir_generic.c)
184+
set(eq-fir_sources eq_fir/eq_fir_ipc4.c)
183185
endif()
184186
set(mixer_sources ${mixer_src})
185187
set(asrc_sources asrc/asrc.c asrc/asrc_farrow.c asrc/asrc_farrow_generic.c)

src/audio/eq_fir/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22

33
add_local_sources(sof eq_fir.c eq_fir_generic.c eq_fir_hifi2ep.c eq_fir_hifi3.c)
4+
if(CONFIG_IPC_MAJOR_3)
5+
add_local_sources(sof eq_fir_ipc3.c)
6+
elseif(CONFIG_IPC_MAJOR_4)
7+
add_local_sources(sof eq_fir_ipc4.c)
8+
endif()
9+

src/audio/eq_fir/eq_fir.c

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -46,162 +46,6 @@ DECLARE_SOF_RT_UUID("eq-fir", eq_fir_uuid, 0x43a90ce7, 0xf3a5, 0x41df,
4646

4747
DECLARE_TR_CTX(eq_fir_tr, SOF_UUID(eq_fir_uuid), LOG_LEVEL_INFO);
4848

49-
/* src component private data */
50-
struct comp_data {
51-
struct fir_state_32x16 fir[PLATFORM_MAX_CHANNELS]; /**< filters state */
52-
struct comp_data_blob_handler *model_handler;
53-
struct sof_eq_fir_config *config;
54-
int32_t *fir_delay; /**< pointer to allocated RAM */
55-
size_t fir_delay_size; /**< allocated size */
56-
void (*eq_fir_func)(struct fir_state_32x16 fir[],
57-
struct input_stream_buffer *bsource,
58-
struct output_stream_buffer *bsink,
59-
int frames);
60-
int nch;
61-
};
62-
63-
/*
64-
* The optimized FIR functions variants need to be updated into function
65-
* set_fir_func.
66-
*/
67-
68-
#if FIR_HIFI3 || FIR_HIFIEP
69-
#if CONFIG_FORMAT_S16LE
70-
static inline void set_s16_fir(struct comp_data *cd)
71-
{
72-
cd->eq_fir_func = eq_fir_2x_s16;
73-
}
74-
#endif /* CONFIG_FORMAT_S16LE */
75-
#if CONFIG_FORMAT_S24LE
76-
static inline void set_s24_fir(struct comp_data *cd)
77-
{
78-
cd->eq_fir_func = eq_fir_2x_s24;
79-
}
80-
#endif /* CONFIG_FORMAT_S24LE */
81-
#if CONFIG_FORMAT_S32LE
82-
static inline void set_s32_fir(struct comp_data *cd)
83-
{
84-
cd->eq_fir_func = eq_fir_2x_s32;
85-
}
86-
#endif /* CONFIG_FORMAT_S32LE */
87-
88-
#else
89-
/* FIR_GENERIC */
90-
#if CONFIG_FORMAT_S16LE
91-
static inline void set_s16_fir(struct comp_data *cd)
92-
{
93-
cd->eq_fir_func = eq_fir_s16;
94-
}
95-
#endif /* CONFIG_FORMAT_S16LE */
96-
#if CONFIG_FORMAT_S24LE
97-
static inline void set_s24_fir(struct comp_data *cd)
98-
{
99-
cd->eq_fir_func = eq_fir_s24;
100-
}
101-
#endif /* CONFIG_FORMAT_S24LE */
102-
#if CONFIG_FORMAT_S32LE
103-
static inline void set_s32_fir(struct comp_data *cd)
104-
{
105-
cd->eq_fir_func = eq_fir_s32;
106-
}
107-
#endif /* CONFIG_FORMAT_S32LE */
108-
#endif
109-
110-
#if CONFIG_IPC_MAJOR_3
111-
static inline int set_fir_func(struct processing_module *mod, enum sof_ipc_frame fmt)
112-
{
113-
struct comp_data *cd = module_get_private_data(mod);
114-
115-
switch (fmt) {
116-
#if CONFIG_FORMAT_S16LE
117-
case SOF_IPC_FRAME_S16_LE:
118-
comp_dbg(mod->dev, "set_fir_func(), SOF_IPC_FRAME_S16_LE");
119-
set_s16_fir(cd);
120-
break;
121-
#endif /* CONFIG_FORMAT_S16LE */
122-
#if CONFIG_FORMAT_S24LE
123-
case SOF_IPC_FRAME_S24_4LE:
124-
comp_dbg(mod->dev, "set_fir_func(), SOF_IPC_FRAME_S24_4LE");
125-
set_s24_fir(cd);
126-
break;
127-
#endif /* CONFIG_FORMAT_S24LE */
128-
#if CONFIG_FORMAT_S32LE
129-
case SOF_IPC_FRAME_S32_LE:
130-
comp_dbg(mod->dev, "set_fir_func(), SOF_IPC_FRAME_S32_LE");
131-
set_s32_fir(cd);
132-
break;
133-
#endif /* CONFIG_FORMAT_S32LE */
134-
default:
135-
comp_err(mod->dev, "set_fir_func(), invalid frame_fmt");
136-
return -EINVAL;
137-
}
138-
return 0;
139-
}
140-
#endif /* CONFIG_IPC_MAJOR_3 */
141-
142-
#if CONFIG_IPC_MAJOR_4
143-
static inline int set_fir_func(struct processing_module *mod, enum sof_ipc_frame fmt)
144-
{
145-
struct comp_data *cd = module_get_private_data(mod);
146-
unsigned int valid_bit_depth = mod->priv.cfg.base_cfg.audio_fmt.valid_bit_depth;
147-
148-
comp_dbg(mod->dev, "set_fir_func(): valid_bit_depth %d", valid_bit_depth);
149-
switch (valid_bit_depth) {
150-
#if CONFIG_FORMAT_S16LE
151-
case IPC4_DEPTH_16BIT:
152-
set_s16_fir(cd);
153-
break;
154-
#endif /* CONFIG_FORMAT_S16LE */
155-
#if CONFIG_FORMAT_S24LE
156-
case IPC4_DEPTH_24BIT:
157-
set_s24_fir(cd);
158-
break;
159-
#endif /* CONFIG_FORMAT_S24LE */
160-
#if CONFIG_FORMAT_S32LE
161-
case IPC4_DEPTH_32BIT:
162-
set_s32_fir(cd);
163-
break;
164-
#endif /* CONFIG_FORMAT_S32LE */
165-
default:
166-
comp_err(mod->dev, "set_fir_func(), invalid valid_bith_depth");
167-
return -EINVAL;
168-
}
169-
return 0;
170-
}
171-
172-
static int eq_fir_params(struct processing_module *mod)
173-
{
174-
struct sof_ipc_stream_params *params = mod->stream_params;
175-
struct sof_ipc_stream_params comp_params;
176-
struct comp_dev *dev = mod->dev;
177-
struct comp_buffer *sinkb;
178-
enum sof_ipc_frame valid_fmt, frame_fmt;
179-
int i, ret;
180-
181-
comp_dbg(dev, "eq_fir_params()");
182-
183-
comp_params = *params;
184-
comp_params.channels = mod->priv.cfg.base_cfg.audio_fmt.channels_count;
185-
comp_params.rate = mod->priv.cfg.base_cfg.audio_fmt.sampling_frequency;
186-
comp_params.buffer_fmt = mod->priv.cfg.base_cfg.audio_fmt.interleaving_style;
187-
188-
audio_stream_fmt_conversion(mod->priv.cfg.base_cfg.audio_fmt.depth,
189-
mod->priv.cfg.base_cfg.audio_fmt.valid_bit_depth,
190-
&frame_fmt, &valid_fmt,
191-
mod->priv.cfg.base_cfg.audio_fmt.s_type);
192-
193-
comp_params.frame_fmt = valid_fmt;
194-
195-
for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++)
196-
comp_params.chmap[i] = (mod->priv.cfg.base_cfg.audio_fmt.ch_map >> i * 4) & 0xf;
197-
198-
component_set_nearest_period_frames(dev, comp_params.rate);
199-
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
200-
ret = buffer_set_params(sinkb, &comp_params, true);
201-
return ret;
202-
}
203-
#endif /* CONFIG_IPC_MAJOR_4 */
204-
20549
/* Pass-through functions to replace FIR core while not configured for
20650
* response.
20751
*/
@@ -575,13 +419,11 @@ static int eq_fir_prepare(struct processing_module *mod,
575419

576420
comp_dbg(dev, "eq_fir_prepare()");
577421

578-
#if CONFIG_IPC_MAJOR_4
579422
ret = eq_fir_params(mod);
580423
if (ret < 0) {
581424
comp_set_state(dev, COMP_TRIGGER_RESET);
582425
return ret;
583426
}
584-
#endif
585427

586428
/* EQ component will only ever have 1 source and 1 sink buffer. */
587429
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);

src/audio/eq_fir/eq_fir.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
#define EQ_FIR_BYTES_TO_S16_SAMPLES(b) ((b) >> 1)
2929
#define EQ_FIR_BYTES_TO_S32_SAMPLES(b) ((b) >> 2)
3030

31+
/* fir component private data */
32+
struct comp_data {
33+
struct fir_state_32x16 fir[PLATFORM_MAX_CHANNELS]; /**< filters state */
34+
struct comp_data_blob_handler *model_handler;
35+
struct sof_eq_fir_config *config;
36+
int32_t *fir_delay; /**< pointer to allocated RAM */
37+
size_t fir_delay_size; /**< allocated size */
38+
void (*eq_fir_func)(struct fir_state_32x16 fir[],
39+
struct input_stream_buffer *bsource,
40+
struct output_stream_buffer *bsink,
41+
int frames);
42+
int nch;
43+
};
44+
3145
#if CONFIG_FORMAT_S16LE
3246
void eq_fir_s16(struct fir_state_32x16 *fir, struct input_stream_buffer *bsource,
3347
struct output_stream_buffer *bsink, int frames);
@@ -52,6 +66,57 @@ void eq_fir_2x_s32(struct fir_state_32x16 *fir, struct input_stream_buffer *bsou
5266
struct output_stream_buffer *bsink, int frames);
5367
#endif /* CONFIG_FORMAT_S32LE */
5468

69+
int set_fir_func(struct processing_module *mod, enum sof_ipc_frame fmt);
70+
71+
int eq_fir_params(struct processing_module *mod);
72+
73+
/*
74+
* The optimized FIR functions variants need to be updated into function
75+
* set_fir_func.
76+
*/
77+
78+
#if FIR_HIFI3 || FIR_HIFIEP
79+
#if CONFIG_FORMAT_S16LE
80+
static inline void set_s16_fir(struct comp_data *cd)
81+
{
82+
cd->eq_fir_func = eq_fir_2x_s16;
83+
}
84+
#endif /* CONFIG_FORMAT_S16LE */
85+
#if CONFIG_FORMAT_S24LE
86+
static inline void set_s24_fir(struct comp_data *cd)
87+
{
88+
cd->eq_fir_func = eq_fir_2x_s24;
89+
}
90+
#endif /* CONFIG_FORMAT_S24LE */
91+
#if CONFIG_FORMAT_S32LE
92+
static inline void set_s32_fir(struct comp_data *cd)
93+
{
94+
cd->eq_fir_func = eq_fir_2x_s32;
95+
}
96+
#endif /* CONFIG_FORMAT_S32LE */
97+
98+
#else
99+
/* FIR_GENERIC */
100+
#if CONFIG_FORMAT_S16LE
101+
static inline void set_s16_fir(struct comp_data *cd)
102+
{
103+
cd->eq_fir_func = eq_fir_s16;
104+
}
105+
#endif /* CONFIG_FORMAT_S16LE */
106+
#if CONFIG_FORMAT_S24LE
107+
static inline void set_s24_fir(struct comp_data *cd)
108+
{
109+
cd->eq_fir_func = eq_fir_s24;
110+
}
111+
#endif /* CONFIG_FORMAT_S24LE */
112+
#if CONFIG_FORMAT_S32LE
113+
static inline void set_s32_fir(struct comp_data *cd)
114+
{
115+
cd->eq_fir_func = eq_fir_s32;
116+
}
117+
#endif /* CONFIG_FORMAT_S32LE */
118+
#endif
119+
55120
#ifdef UNIT_TEST
56121
void sys_comp_module_eq_fir_interface_init(void);
57122
#endif

src/audio/eq_fir/eq_fir_ipc3.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
//
3+
// Copyright(c) 2017 Intel Corporation. All rights reserved.
4+
//
5+
// Author: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
6+
// Liam Girdwood <liam.r.girdwood@linux.intel.com>
7+
// Keyon Jie <yang.jie@linux.intel.com>
8+
9+
#include <sof/audio/buffer.h>
10+
#include <sof/audio/component.h>
11+
#include <sof/audio/data_blob.h>
12+
#include <sof/audio/pipeline.h>
13+
#include <sof/audio/module_adapter/module/generic.h>
14+
#include <sof/audio/ipc-config.h>
15+
#include <sof/common.h>
16+
#include <rtos/panic.h>
17+
#include <sof/ipc/msg.h>
18+
#include <rtos/alloc.h>
19+
#include <rtos/init.h>
20+
#include <sof/lib/memory.h>
21+
#include <sof/lib/uuid.h>
22+
#include <sof/list.h>
23+
#include <sof/math/fir_config.h>
24+
#include <sof/platform.h>
25+
#include <rtos/string.h>
26+
#include <sof/ut.h>
27+
#include <sof/trace/trace.h>
28+
#include <ipc/control.h>
29+
#include <ipc/stream.h>
30+
#include <ipc/topology.h>
31+
#include <kernel/abi.h>
32+
#include <user/eq.h>
33+
#include <user/fir.h>
34+
#include <user/trace.h>
35+
#include <errno.h>
36+
#include <stddef.h>
37+
#include <stdint.h>
38+
39+
#include "eq_fir.h"
40+
41+
LOG_MODULE_DECLARE(eq_fir, CONFIG_SOF_LOG_LEVEL);
42+
43+
int set_fir_func(struct processing_module *mod, enum sof_ipc_frame fmt)
44+
{
45+
struct comp_data *cd = module_get_private_data(mod);
46+
47+
switch (fmt) {
48+
#if CONFIG_FORMAT_S16LE
49+
case SOF_IPC_FRAME_S16_LE:
50+
comp_dbg(mod->dev, "set_fir_func(), SOF_IPC_FRAME_S16_LE");
51+
set_s16_fir(cd);
52+
break;
53+
#endif /* CONFIG_FORMAT_S16LE */
54+
#if CONFIG_FORMAT_S24LE
55+
case SOF_IPC_FRAME_S24_4LE:
56+
comp_dbg(mod->dev, "set_fir_func(), SOF_IPC_FRAME_S24_4LE");
57+
set_s24_fir(cd);
58+
break;
59+
#endif /* CONFIG_FORMAT_S24LE */
60+
#if CONFIG_FORMAT_S32LE
61+
case SOF_IPC_FRAME_S32_LE:
62+
comp_dbg(mod->dev, "set_fir_func(), SOF_IPC_FRAME_S32_LE");
63+
set_s32_fir(cd);
64+
break;
65+
#endif /* CONFIG_FORMAT_S32LE */
66+
default:
67+
comp_err(mod->dev, "set_fir_func(), invalid frame_fmt");
68+
return -EINVAL;
69+
}
70+
return 0;
71+
}
72+
73+
int eq_fir_params(struct processing_module *mod)
74+
{
75+
return 0;
76+
}
77+

0 commit comments

Comments
 (0)