Audio: dcblock: split dcblock with ipc3 and ipc4 specific code

Split dcblock with ipc3 and ipc4 specific code.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
This commit is contained in:
Baofeng Tian 2023-11-30 14:13:41 +08:00 committed by Kai Vehmanen
parent 777ee7beab
commit e72056769c
7 changed files with 165 additions and 48 deletions

View File

@ -182,6 +182,7 @@ if(CONFIG_IPC_MAJOR_3)
set(eq-fir_sources eq_fir/eq_fir_ipc3.c)
set(tdfb_sources tdfb/tdfb_ipc3.c)
set(tdfb_sources multiband_drc/multiband_drc_ipc3.c)
set(dcblock_sources dcblock/dcblock_ipc3.c)
elseif(CONFIG_IPC_MAJOR_4)
set(volume_sources volume/volume.c volume/volume_generic.c volume/volume_ipc4.c)
set(src_sources src/src.c src/src_ipc4.c src/src_generic.c)
@ -189,6 +190,7 @@ elseif(CONFIG_IPC_MAJOR_4)
set(eq-fir_sources eq_fir/eq_fir_ipc4.c)
set(tdfb_sources tdfb/tdfb_ipc4.c)
set(tdfb_sources multiband_drc/multiband_drc_ipc4.c)
set(dcblock_sources dcblock/dcblock_ipc4.c)
endif()
set(mixer_sources ${mixer_src})
set(asrc_sources asrc/asrc.c asrc/asrc_farrow.c asrc/asrc_farrow_generic.c)

View File

@ -2,3 +2,9 @@ add_local_sources(sof dcblock.c)
add_local_sources(sof dcblock_generic.c)
add_local_sources(sof dcblock_hifi3.c)
add_local_sources(sof dcblock_hifi4.c)
if(CONFIG_IPC_MAJOR_3)
add_local_sources(sof dcblock_ipc3.c)
elseif(CONFIG_IPC_MAJOR_4)
add_local_sources(sof dcblock_ipc4.c)
endif()

View File

@ -144,19 +144,7 @@ static int dcblock_get_config(struct processing_module *mod,
uint32_t config_id, uint32_t *data_offset_size,
uint8_t *fragment, size_t fragment_size)
{
struct sof_ipc_ctrl_data *cdata = (struct sof_ipc_ctrl_data *)fragment;
struct comp_data *cd = module_get_private_data(mod);
comp_info(mod->dev, "dcblock_get_config()");
#if CONFIG_IPC_MAJOR_3
if (cdata->cmd != SOF_CTRL_CMD_BINARY) {
comp_err(mod->dev, "dcblock_get_config(), invalid command");
return -EINVAL;
}
#endif
return comp_data_blob_get_cmd(cd->model_handler, cdata, fragment_size);
return dcblock_get_ipc_config(mod, fragment, fragment_size);
}
/**
@ -167,20 +155,8 @@ static int dcblock_set_config(struct processing_module *mod, uint32_t config_id,
const uint8_t *fragment, size_t fragment_size, uint8_t *response,
size_t response_size)
{
struct comp_data *cd = module_get_private_data(mod);
comp_info(mod->dev, "dcblock_set_config()");
#if CONFIG_IPC_MAJOR_3
struct sof_ipc_ctrl_data *cdata = (struct sof_ipc_ctrl_data *)fragment;
if (cdata->cmd != SOF_CTRL_CMD_BINARY) {
comp_err(mod->dev, "dcblock_set_config(), invalid command %i", cdata->cmd);
return -EINVAL;
}
#endif
return comp_data_blob_set(cd->model_handler, pos, data_offset_size, fragment,
fragment_size);
return dcblock_set_ipc_config(mod, pos, data_offset_size, fragment, fragment_size);
}
/**
@ -218,26 +194,6 @@ static inline void dcblock_set_frame_alignment(struct audio_stream *source,
audio_stream_init_alignment_constants(byte_align, frame_align_req, sink);
}
#if CONFIG_IPC_MAJOR_4
static void dcblock_params(struct processing_module *mod)
{
struct sof_ipc_stream_params *params = mod->stream_params;
struct comp_buffer *sinkb, *sourceb;
struct comp_dev *dev = mod->dev;
comp_dbg(dev, "dcblock_params()");
ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params);
component_set_nearest_period_frames(dev, params->rate);
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt);
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);
}
#endif /* CONFIG_IPC_MAJOR_4 */
/**
* \brief Prepares DC Blocking Filter component for processing.
* \param[in,out] dev DC Blocking Filter base component device.
@ -253,9 +209,7 @@ static int dcblock_prepare(struct processing_module *mod,
comp_info(dev, "dcblock_prepare()");
#if CONFIG_IPC_MAJOR_4
dcblock_params(mod);
#endif
/* DC Filter component will only ever have one source and sink buffer */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);

View File

@ -12,6 +12,8 @@
#include <sof/platform.h>
#include <ipc/stream.h>
#include <sof/compiler_info.h>
#include <module/module/base.h>
#include <module/module/interface.h>
/* __XCC__ is both for xt_xcc and xt_clang */
#if defined(__XCC__)
@ -93,4 +95,11 @@ static inline dcblock_func dcblock_find_func(enum sof_ipc_frame src_fmt)
return NULL;
}
int dcblock_get_ipc_config(struct processing_module *mod,
uint8_t *fragment, size_t fragment_size);
int dcblock_set_ipc_config(struct processing_module *mod,
enum module_cfg_fragment_position pos, uint32_t data_offset_size,
const uint8_t *fragment, size_t fragment_size);
void dcblock_params(struct processing_module *mod);
#endif /* __SOF_AUDIO_DCBLOCK_DCBLOCK_H__ */

View File

@ -0,0 +1,66 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2020 Google LLC. All rights reserved.
//
// Author: Sebastiano Carlucci <scarlucci@google.com>
#include <sof/audio/module_adapter/module/generic.h>
#include <sof/trace/trace.h>
#include <module/module/base.h>
#include <ipc/control.h>
#include <sof/audio/component.h>
#include <sof/audio/data_blob.h>
#include <module/module/interface.h>
#include <ipc/stream.h>
#include <sof/audio/buffer.h>
#include <errno.h>
#include "dcblock.h"
LOG_MODULE_DECLARE(dcblock, CONFIG_SOF_LOG_LEVEL);
/**
* \brief Handles incoming get commands for DC Blocking Filter component.
*/
int dcblock_get_ipc_config(struct processing_module *mod,
uint8_t *fragment, size_t fragment_size)
{
struct sof_ipc_ctrl_data *cdata = (struct sof_ipc_ctrl_data *)fragment;
struct comp_data *cd = module_get_private_data(mod);
comp_info(mod->dev, "dcblock_get_config()");
if (cdata->cmd != SOF_CTRL_CMD_BINARY) {
comp_err(mod->dev, "dcblock_get_config(), invalid command");
return -EINVAL;
}
return comp_data_blob_get_cmd(cd->model_handler, cdata, fragment_size);
}
/**
* \brief Handles incoming set commands for DC Blocking Filter component.
*/
int dcblock_set_ipc_config(struct processing_module *mod,
enum module_cfg_fragment_position pos, uint32_t data_offset_size,
const uint8_t *fragment, size_t fragment_size)
{
struct comp_data *cd = module_get_private_data(mod);
comp_info(mod->dev, "dcblock_set_config()");
struct sof_ipc_ctrl_data *cdata = (struct sof_ipc_ctrl_data *)fragment;
if (cdata->cmd != SOF_CTRL_CMD_BINARY) {
comp_err(mod->dev, "dcblock_set_config(), invalid command %i", cdata->cmd);
return -EINVAL;
}
return comp_data_blob_set(cd->model_handler, pos, data_offset_size, fragment,
fragment_size);
}
void dcblock_params(struct processing_module *mod)
{
}

View File

@ -0,0 +1,70 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2020 Google LLC. All rights reserved.
//
// Author: Sebastiano Carlucci <scarlucci@google.com>
#include <sof/audio/module_adapter/module/generic.h>
#include <sof/trace/trace.h>
#include <module/module/base.h>
#include <ipc/control.h>
#include <sof/audio/component.h>
#include <sof/audio/data_blob.h>
#include <module/module/interface.h>
#include <ipc/stream.h>
#include <sof/audio/buffer.h>
#include <module/ipc4/base-config.h>
#include <sof/list.h>
#include <errno.h>
#include "dcblock.h"
LOG_MODULE_DECLARE(dcblock, CONFIG_SOF_LOG_LEVEL);
/**
* \brief Handles incoming get commands for DC Blocking Filter component.
*/
int dcblock_get_ipc_config(struct processing_module *mod,
uint8_t *fragment, size_t fragment_size)
{
struct sof_ipc_ctrl_data *cdata = (struct sof_ipc_ctrl_data *)fragment;
struct comp_data *cd = module_get_private_data(mod);
comp_info(mod->dev, "dcblock_get_ipc_config()");
return comp_data_blob_get_cmd(cd->model_handler, cdata, fragment_size);
}
/**
* \brief Handles incoming set commands for DC Blocking Filter component.
*/
int dcblock_set_ipc_config(struct processing_module *mod,
enum module_cfg_fragment_position pos, uint32_t data_offset_size,
const uint8_t *fragment, size_t fragment_size)
{
struct comp_data *cd = module_get_private_data(mod);
comp_info(mod->dev, "dcblock_set_ipc_config()");
return comp_data_blob_set(cd->model_handler, pos, data_offset_size, fragment,
fragment_size);
}
void dcblock_params(struct processing_module *mod)
{
struct sof_ipc_stream_params *params = mod->stream_params;
struct comp_buffer *sinkb, *sourceb;
struct comp_dev *dev = mod->dev;
comp_dbg(dev, "dcblock_params()");
ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params);
component_set_nearest_period_frames(dev, params->rate);
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
ipc4_update_buffer_format(sinkb, &mod->priv.cfg.base_cfg.audio_fmt);
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
ipc4_update_buffer_format(sourceb, &mod->priv.cfg.base_cfg.audio_fmt);
}

View File

@ -514,6 +514,16 @@ zephyr_library_sources_ifdef(CONFIG_COMP_DCBLOCK
${SOF_AUDIO_PATH}/dcblock/dcblock_hifi4.c
)
if(CONFIG_IPC_MAJOR_3)
zephyr_library_sources_ifdef(CONFIG_COMP_DCBLOCK
${SOF_AUDIO_PATH}/dcblock/dcblock_ipc3.c
)
elseif(CONFIG_IPC_MAJOR_4)
zephyr_library_sources_ifdef(CONFIG_COMP_DCBLOCK
${SOF_AUDIO_PATH}/dcblock/dcblock_ipc4.c
)
endif()
zephyr_library_sources_ifdef(CONFIG_COMP_SEL
${SOF_AUDIO_PATH}/selector/selector_generic.c
${SOF_AUDIO_PATH}/selector/selector.c