From 385110cf9d56458ce6003ac6de1967ec4403a2e4 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Sun, 9 Jul 2023 17:12:31 -0700 Subject: [PATCH] audio: volume: Simplify volume_params() Use the helper functions to update the stream params and the source/sink buffer formats. Signed-off-by: Ranjani Sridharan --- .../module_adapter/module/volume/volume.c | 33 +++++++------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/audio/module_adapter/module/volume/volume.c b/src/audio/module_adapter/module/volume/volume.c index 8a952d3aee7d..fd5501e39fd5 100644 --- a/src/audio/module_adapter/module/volume/volume.c +++ b/src/audio/module_adapter/module/volume/volume.c @@ -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 */