Skip to content

Commit

Permalink
audio: aria: Add set_large_config op
Browse files Browse the repository at this point in the history
This patch is needed to make the module work with linux and avoid
firmware crash. This patch sets the attenuation parameters with the
bytes control since the setup parameters can't be passed in init()
as in Windows OS.

Signed-off-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
ranj063 authored and singalsu committed Oct 17, 2023
1 parent 8819667 commit 43672c6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/boards/intel_adsp_cavs25.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CONFIG_COMP_VOLUME_WINDOWS_FADE=y
CONFIG_COMP_DRC=y
CONFIG_COMP_CROSSOVER=y
CONFIG_COMP_MULTIBAND_DRC=y
CONFIG_COMP_ARIA=y

# route SOF logs to Zephyr logging subsystem
CONFIG_SOF_LOG_LEVEL_INF=y
Expand Down
1 change: 1 addition & 0 deletions app/boards/intel_adsp_cavs25_tgph.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ CONFIG_COMP_VOLUME_WINDOWS_FADE=y
CONFIG_COMP_DRC=y
CONFIG_COMP_CROSSOVER=y
CONFIG_COMP_MULTIBAND_DRC=y
CONFIG_COMP_ARIA=y

# route SOF logs to Zephyr logging subsystem
CONFIG_SOF_LOG_LEVEL_INF=y
Expand Down
40 changes: 35 additions & 5 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <stddef.h>
#include <stdint.h>

#define ARIA_SET_ATTENUATION 1

LOG_MODULE_REGISTER(aria, CONFIG_SOF_LOG_LEVEL);

/* these ids aligns windows driver requirement to support windows driver */
Expand All @@ -46,11 +48,17 @@ static size_t get_required_emory(size_t chan_cnt, size_t smpl_group_cnt)
return ALIGN_UP(num_of_ms * chan_cnt * smpl_group_cnt, 2) * sizeof(int32_t);
}

static void aria_set_gains(struct aria_data *cd)
{
int i;

for (i = 0; i < ARIA_MAX_GAIN_STATES; ++i)
cd->gains[i] = (1ULL << (32 - cd->att - 1)) - 1;
}

static int aria_algo_init(struct aria_data *cd, void *buffer_desc,
size_t att, size_t chan_cnt, size_t smpl_group_cnt)
{
size_t idx;

cd->chan_cnt = chan_cnt;
cd->smpl_group_cnt = smpl_group_cnt;
/* ensures buffer size is aligned to 8 bytes */
Expand All @@ -62,8 +70,7 @@ static int aria_algo_init(struct aria_data *cd, void *buffer_desc,
cd->data_end = cd->data_addr + cd->buff_size;
cd->buff_pos = 0;

for (idx = 0; idx < ARIA_MAX_GAIN_STATES; ++idx)
cd->gains[idx] = (1ULL << (32 - cd->att - 1)) - 1;
aria_set_gains(cd);

memset((void *)cd->data_addr, 0, sizeof(int32_t) * cd->buff_size);
cd->gain_state = 0;
Expand Down Expand Up @@ -249,12 +256,35 @@ static int aria_process(struct processing_module *mod,
return 0;
}

static int aria_set_config(struct processing_module *mod, uint32_t param_id,
enum module_cfg_fragment_position pos, uint32_t data_offset_size,
const uint8_t *fragment, size_t fragment_size, uint8_t *response,
size_t response_size)
{
struct aria_data *cd = module_get_private_data(mod);

if (param_id == ARIA_SET_ATTENUATION) {
if (fragment_size != sizeof(uint32_t)) {
comp_err(mod->dev, "Illegal fragment_size = %d", fragment_size);
return -EINVAL;
}
memcpy_s(&cd->att, sizeof(uint32_t), fragment, sizeof(uint32_t));
aria_set_gains(cd);
} else {
comp_err(mod->dev, "Illegal param_id = %d", param_id);
return -EINVAL;
}

return 0;
}

static const struct module_interface aria_interface = {
.init = aria_init,
.prepare = aria_prepare,
.process_audio_stream = aria_process,
.reset = aria_reset,
.free = aria_free
.free = aria_free,
.set_configuration = aria_set_config,
};

DECLARE_MODULE_ADAPTER(aria_interface, aria_comp_uuid, aria_comp_tr);
Expand Down

0 comments on commit 43672c6

Please sign in to comment.