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
34 changes: 7 additions & 27 deletions src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,16 @@ if(NOT BUILD_LIBRARY)
buffer.c
)
if(CONFIG_COMP_VOLUME)
add_local_sources(sof
volume.c
volume_generic.c
volume_hifi3.c
)
add_subdirectory(volume)
endif()
if(CONFIG_COMP_SRC)
add_local_sources(sof
src.c
src_generic.c
src_hifi2ep.c
src_hifi3.c
)
add_subdirectory(src)
endif()
if(CONFIG_COMP_FIR)
add_local_sources(sof
eq_fir.c
fir.c
fir_hifi2ep.c
fir_hifi3.c
)
add_subdirectory(eq_fir)
endif()
if(CONFIG_COMP_IIR)
add_local_sources(sof
eq_iir.c
iir.c
)
add_subdirectory(eq_iir)
endif()
if(CONFIG_COMP_TONE)
add_local_sources(sof
Expand Down Expand Up @@ -66,10 +49,7 @@ if(NOT BUILD_LIBRARY)
)
endif()
if(CONFIG_COMP_SEL)
add_local_sources(sof
selector.c
selector_generic.c
)
add_subdirectory(selector)
endif()
if(CONFIG_COMP_TEST_KEYPHRASE)
add_local_sources(sof
Expand Down Expand Up @@ -121,8 +101,8 @@ check_optimization(hifi3 -mhifi3 -DOPS_HIFI3)
set(sof_audio_modules volume src)

# sources for each module
set(volume_sources volume.c volume_generic.c)
set(src_sources src.c src_generic.c)
set(volume_sources volume/volume.c volume/volume_generic.c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to not handle f.e. volume.c on 2 different levels for different builds. We should have some kind of function here that is called in subdirs maybe. I can refactor that part later. We can merge it like it is now cos it's step in the good direction and it's better to have smaller PRs anyway.

set(src_sources src/src.c src/src_generic.c)

foreach(audio_module ${sof_audio_modules})
# first compile with no optimizations
Expand Down
1 change: 1 addition & 0 deletions src/audio/eq_fir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_local_sources(sof eq_fir.c fir_hifi2ep.c fir_hifi3.c fir.c)
27 changes: 13 additions & 14 deletions src/audio/eq_fir.c → src/audio/eq_fir/eq_fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,20 @@
#include <stdbool.h>
#include <sof/sof.h>
#include <sof/audio/component.h>
#include <sof/audio/eq_fir/fir_config.h>
#include <sof/ipc.h>
#include <uapi/user/eq.h>
#include "fir_config.h"

#if FIR_GENERIC
#include "fir.h"
#include <sof/audio/eq_fir/fir.h>
#endif

#if FIR_HIFIEP
#include "fir_hifi2ep.h"
#include <sof/audio/eq_fir/fir_hifi2ep.h>
#endif

#if FIR_HIFI3
#include "fir_hifi3.h"
#endif

#ifdef MODULE_TEST
#include <stdio.h>
#include <sof/audio/eq_fir/fir_hifi3.h>
#endif

#define trace_eq(__e, ...) trace_event(TRACE_CLASS_EQ_FIR, __e, ##__VA_ARGS__)
Expand Down Expand Up @@ -356,9 +352,8 @@ static int eq_fir_setup(struct comp_data *cd, int nch)
fir_delay = cd->fir_delay;
for (i = 0; i < nch; i++) {
resp = assign_response[i];
if (resp >= 0) {
if (resp >= 0)
fir_init_delay(&fir[i], &fir_delay);
}
}

return 0;
Expand Down Expand Up @@ -415,8 +410,8 @@ static struct comp_dev *eq_fir_new(struct sof_ipc_comp *comp)
return NULL;

fir = (struct sof_ipc_comp_process *)&dev->comp;
assert(!memcpy_s(fir, sizeof(*fir),
ipc_fir, sizeof(struct sof_ipc_comp_process)));
assert(!memcpy_s(fir, sizeof(*fir), ipc_fir,
sizeof(struct sof_ipc_comp_process)));

cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (!cd) {
Expand Down Expand Up @@ -508,7 +503,9 @@ static int fir_cmd_get_data(struct comp_dev *dev,
trace_eq("fir_cmd_get_data(), blob size %zu "
"msg index %u max size %u offset %zu", bs,
cdata->msg_index, max_size, offset);
memcpy(dst, src + offset, bs);
assert(!memcpy_s(dst, ((struct sof_abi_hdr *)
(cdata->data))->size, src + offset,
bs));
cdata->data->abi = SOF_ABI_VERSION;
cdata->data->size = bs;
} else {
Expand Down Expand Up @@ -613,7 +610,9 @@ static int fir_cmd_set_data(struct comp_dev *dev,
/* Just copy the configuration. The EQ will be initialized in
* prepare().
*/
memcpy(dst + offset, src, cdata->num_elems);
assert(!memcpy_s(dst + offset, cdata->num_elems +
cdata->elems_remaining - offset, src,
cdata->num_elems));

/* we can check data when elems_remaining == 0 */
break;
Expand Down
4 changes: 2 additions & 2 deletions src/audio/fir.c → src/audio/eq_fir/fir.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
#include <stddef.h>
#include <errno.h>
#include <sof/audio/component.h>
#include <sof/audio/eq_fir/fir_config.h>
#include <sof/audio/format.h>
#include <uapi/user/eq.h>
#include "fir_config.h"

#if FIR_GENERIC

#include "fir.h"
#include <sof/audio/eq_fir/fir.h>

/*
* EQ FIR algorithm code
Expand Down
4 changes: 2 additions & 2 deletions src/audio/fir_hifi2ep.c → src/audio/eq_fir/fir_hifi2ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
#include <stddef.h>
#include <errno.h>
#include <sof/audio/component.h>
#include <sof/audio/eq_fir/fir_config.h>
#include <sof/audio/format.h>
#include <uapi/user/eq.h>
#include "fir_config.h"

#if FIR_HIFIEP

#include <xtensa/config/defs.h>
#include <xtensa/tie/xt_hifi2.h>
#include "fir_hifi2ep.h"
#include <sof/audio/eq_fir/fir_hifi2ep.h>

/*
* EQ FIR algorithm code
Expand Down
5 changes: 2 additions & 3 deletions src/audio/fir_hifi3.c → src/audio/eq_fir/fir_hifi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@
#include <stddef.h>
#include <errno.h>
#include <sof/audio/component.h>
#include <sof/audio/eq_fir/fir_config.h>
#include <sof/audio/format.h>
#include <uapi/user/eq.h>
#include "fir_config.h"

#if FIR_HIFI3

#include <xtensa/config/defs.h>
#include <xtensa/tie/xt_hifi3.h>
#include "fir_hifi3.h"
#include <sof/audio/eq_fir/fir_hifi3.h>

/*
* EQ FIR algorithm code
Expand Down Expand Up @@ -226,7 +226,6 @@ void eq_fir_2x_s24_hifi3(struct fir_state_32x16 fir[],
AE_S32_L_XC(d0, y0, inc_2nch_s);
AE_S32_L_XC(d1, y1, inc_2nch_s);
}

}
}

Expand Down
1 change: 1 addition & 0 deletions src/audio/eq_iir/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_local_sources(sof eq_iir.c iir.c)
18 changes: 7 additions & 11 deletions src/audio/eq_iir.c → src/audio/eq_iir/eq_iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,10 @@
#include <sof/clk.h>
#include <sof/ipc.h>
#include <sof/audio/component.h>
#include <sof/audio/eq_iir/eq_iir.h>
#include <sof/audio/format.h>
#include <sof/audio/eq_iir/iir.h>
#include <uapi/user/eq.h>
#include "eq_iir.h"
#include "iir.h"

#ifdef MODULE_TEST
#include <stdio.h>
#endif

#define trace_eq(__e, ...) trace_event(TRACE_CLASS_EQ_IIR, __e, ##__VA_ARGS__)
#define tracev_eq(__e, ...) tracev_event(TRACE_CLASS_EQ_IIR, __e, ##__VA_ARGS__)
Expand Down Expand Up @@ -509,8 +505,8 @@ static struct comp_dev *eq_iir_new(struct sof_ipc_comp *comp)
return NULL;

iir = (struct sof_ipc_comp_process *)&dev->comp;
assert(!memcpy_s(iir, sizeof(*iir),
ipc_iir, sizeof(struct sof_ipc_comp_process)));
assert(!memcpy_s(iir, sizeof(*iir), ipc_iir,
sizeof(struct sof_ipc_comp_process)));

cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (!cd) {
Expand Down Expand Up @@ -588,8 +584,9 @@ static int iir_cmd_get_data(struct comp_dev *dev,
bs > max_size)
return -EINVAL;
assert(!memcpy_s(cdata->data->data,
((struct sof_abi_hdr *)
(cdata->data))->size, cd->config, bs));
((struct sof_abi_hdr *)
(cdata->data))->size, cd->config,
bs));

cdata->data->abi = SOF_ABI_VERSION;
cdata->data->size = bs;
Expand Down Expand Up @@ -923,7 +920,6 @@ struct comp_driver comp_eq_iir = {
},
};


static void sys_comp_eq_iir_init(void)
{
comp_register(&comp_eq_iir);
Expand Down
7 changes: 1 addition & 6 deletions src/audio/iir.c → src/audio/eq_iir/iir.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,9 @@
#include <stdint.h>
#include <stddef.h>
#include <errno.h>

#ifdef MODULE_TEST
#include <stdio.h>
#endif

#include <sof/audio/format.h>
#include <sof/audio/eq_iir/iir.h>
#include <uapi/user/eq.h>
#include "iir.h"

/*
* Direct form II transposed second order filter block (biquad)
Expand Down
1 change: 1 addition & 0 deletions src/audio/selector/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_local_sources(sof selector_generic.c selector.c)
23 changes: 11 additions & 12 deletions src/audio/selector.c → src/audio/selector/selector.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* \file audio/selector.c
* \brief Audio channel selection component. In case 1 output channel is
* \brief selected in topology the component provides the selected channel on
* \brief ouput. In case 2 or 4 channels are selected on output the component
* \brief output. In case 2 or 4 channels are selected on output the component
* \brief works in a passthrough mode.
* \authors Lech Betlej <lech.betlej@linux.intel.com>
*/
Expand All @@ -46,7 +46,7 @@
#include <sof/alloc.h>
#include <sof/clk.h>
#include <sof/ipc.h>
#include "selector.h"
#include <sof/audio/selector.h>
#include <sof/math/numbers.h>

/**
Expand Down Expand Up @@ -124,7 +124,8 @@ static struct comp_dev *selector_new(struct sof_ipc_comp *comp)
if (!dev)
return NULL;

memcpy(&dev->comp, comp, sizeof(struct sof_ipc_comp_process));
assert(!memcpy_s(&dev->comp, sizeof(struct sof_ipc_comp_process), comp,
sizeof(struct sof_ipc_comp_process)));

cd = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*cd));
if (!cd) {
Expand All @@ -134,7 +135,8 @@ static struct comp_dev *selector_new(struct sof_ipc_comp *comp)

comp_set_drvdata(dev, cd);

memcpy(&cd->config, ipc_process->data, bs);
assert(!memcpy_s(&cd->config, sizeof(cd->config), ipc_process->data,
bs));

/* verification of initial parameters */
ret = sel_set_channel_values(cd, cd->config.in_channels_count,
Expand Down Expand Up @@ -186,7 +188,6 @@ static int selector_params(struct comp_dev *dev)
return PPL_STATUS_PATH_STOP;
}


/**
* \brief Sets selector control command.
* \param[in,out] dev Selector base component device.
Expand All @@ -201,13 +202,14 @@ static int selector_ctrl_set_data(struct comp_dev *dev,
int ret = 0;

switch (cdata->cmd) {
case SOF_CTRL_CMD_BINARY:
case SOF_CTRL_CMD_BINARY:
trace_selector("selector_ctrl_set_data(), SOF_CTRL_CMD_BINARY");

cfg = (struct sof_sel_config *)cdata->data->data;
/* Just copy the configuration & verify input params.*/
ret = sel_set_channel_values(cd, cfg->in_channels_count,
cfg->out_channels_count, cfg->sel_channel);
cfg->out_channels_count,
cfg->sel_channel);
break;
default:
trace_selector_error("selector_ctrl_set_cmd() error: "
Expand Down Expand Up @@ -239,10 +241,8 @@ static int selector_ctrl_get_data(struct comp_dev *dev,

/* Copy back to user space */
assert(!memcpy_s(cdata->data->data, ((struct sof_abi_hdr *)
(cdata->data))->size, &(cd->config),
sizeof(cd->config)));
if (ret < 0)
return ret;
(cdata->data))->size, &cd->config,
sizeof(cd->config)));

cdata->data->abi = SOF_ABI_VERSION;
cdata->data->size = sizeof(cd->config);
Expand Down Expand Up @@ -310,7 +310,6 @@ static int selector_trigger(struct comp_dev *dev, int cmd)
return ret == 0 ? PPL_STATUS_PATH_STOP : ret;
}


/**
* \brief Copies and processes stream data.
* \param[in,out] dev Selector base component device.
Expand Down
Loading