Skip to content

Commit

Permalink
audio: volume: Simplify volume_params()
Browse files Browse the repository at this point in the history
Use the helper functions to update the stream params and the source/sink
buffer formats.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
  • Loading branch information
ranj063 authored and lgirdwood committed Jul 13, 2023
1 parent 7427d7f commit 385110c
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions src/audio/module_adapter/module/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,39 +1118,28 @@ static int volume_get_config(struct processing_module *mod,
static int volume_params(struct processing_module *mod)
{
struct sof_ipc_stream_params *params = mod->stream_params;
struct sof_ipc_stream_params vol_params;
enum sof_ipc_frame frame_fmt, valid_fmt;
struct comp_buffer __sparse_cache *sink_c, *source_c;
struct comp_buffer *sinkb, *sourceb;
struct comp_dev *dev = mod->dev;
struct comp_buffer *sinkb;
struct comp_buffer __sparse_cache *sink_c;
int i, ret;

comp_dbg(dev, "volume_params()");

vol_params = *params;
vol_params.channels = mod->priv.cfg.base_cfg.audio_fmt.channels_count;
vol_params.rate = mod->priv.cfg.base_cfg.audio_fmt.sampling_frequency;
vol_params.buffer_fmt = mod->priv.cfg.base_cfg.audio_fmt.interleaving_style;

audio_stream_fmt_conversion(mod->priv.cfg.base_cfg.audio_fmt.depth,
mod->priv.cfg.base_cfg.audio_fmt.valid_bit_depth,
&frame_fmt, &valid_fmt,
mod->priv.cfg.base_cfg.audio_fmt.s_type);

vol_params.frame_fmt = valid_fmt;
ipc4_base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params);

for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++)
vol_params.chmap[i] = (mod->priv.cfg.base_cfg.audio_fmt.ch_map >> i * 4) & 0xf;

component_set_nearest_period_frames(dev, vol_params.rate);
component_set_nearest_period_frames(dev, params->rate);

/* volume component will only ever have 1 sink buffer */
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
sink_c = buffer_acquire(sinkb);
ret = buffer_set_params(sink_c, &vol_params, true);
ipc4_update_buffer_format(sink_c, &mod->priv.cfg.base_cfg.audio_fmt);
buffer_release(sink_c);

return ret;
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
source_c = buffer_acquire(sourceb);
ipc4_update_buffer_format(source_c, &mod->priv.cfg.base_cfg.audio_fmt);
buffer_release(source_c);

return 0;
}
#endif /* CONFIG_IPC_MAJOR_4 */

Expand Down

0 comments on commit 385110c

Please sign in to comment.