Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,15 @@ 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)
set(eq-iir_sources eq_iir/eq_iir_ipc4.c eq_iir/eq_iir_generic.c)
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)
Expand Down
6 changes: 6 additions & 0 deletions src/audio/dcblock/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
53 changes: 4 additions & 49 deletions src/audio/dcblock/dcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <sof/audio/data_blob.h>
#include <sof/audio/format.h>
#include <sof/audio/pipeline.h>
#include <sof/audio/dcblock/dcblock.h>
#include <sof/audio/ipc-config.h>
#include <sof/common.h>
#include <rtos/panic.h>
Expand All @@ -32,6 +31,8 @@
#include <stddef.h>
#include <stdint.h>

#include "dcblock.h"

LOG_MODULE_REGISTER(dcblock, CONFIG_SOF_LOG_LEVEL);

/* b809efaf-5681-42b1-9ed6-04bb012dd384 */
Expand Down Expand Up @@ -143,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);
}

/**
Expand All @@ -166,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);
}

/**
Expand Down Expand Up @@ -217,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.
Expand All @@ -252,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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__ */
3 changes: 2 additions & 1 deletion src/audio/dcblock/dcblock_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <stdint.h>
#include <sof/audio/component.h>
#include <sof/audio/format.h>
#include <sof/audio/dcblock/dcblock.h>

#include "dcblock.h"

#ifdef DCBLOCK_GENERIC

Expand Down
3 changes: 2 additions & 1 deletion src/audio/dcblock/dcblock_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <stdint.h>
#include <sof/audio/component.h>
#include <sof/audio/format.h>
#include <sof/audio/dcblock/dcblock.h>

#include "dcblock.h"

#ifdef DCBLOCK_HIFI3

Expand Down
3 changes: 2 additions & 1 deletion src/audio/dcblock/dcblock_hifi4.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
#include <stdint.h>
#include <sof/audio/component.h>
#include <sof/audio/format.h>
#include <sof/audio/dcblock/dcblock.h>

#include "dcblock.h"

#ifdef DCBLOCK_HIFI4

Expand Down
66 changes: 66 additions & 0 deletions src/audio/dcblock/dcblock_ipc3.c
Original file line number Diff line number Diff line change
@@ -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)
{
}

70 changes: 70 additions & 0 deletions src/audio/dcblock/dcblock_ipc4.c
Original file line number Diff line number Diff line change
@@ -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);
}

10 changes: 10 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down