From e79893ee02d88ffeb8f6beed7bbd38bc11f13dae Mon Sep 17 00:00:00 2001 From: Marcin Rajwa Date: Mon, 23 Nov 2020 17:25:18 +0100 Subject: [PATCH] codec_adapter: update .params() method This patch updates the .params() method with verification of runtime parameters and stores them in component data for future use. Signed-off-by: Marcin Rajwa --- src/audio/codec_adapter/codec_adapter.c | 15 ++++++++++++++- .../sof/audio/codec_adapter/codec/generic.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/audio/codec_adapter/codec_adapter.c b/src/audio/codec_adapter/codec_adapter.c index 3d43374da..c8591f40e 100644 --- a/src/audio/codec_adapter/codec_adapter.c +++ b/src/audio/codec_adapter/codec_adapter.c @@ -225,8 +225,21 @@ static int codec_adapter_prepare(struct comp_dev *dev) static int codec_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *params) { - comp_dbg(dev, "codec_adapter_params(): codec_adapter doesn't support .params() method."); + int ret; + struct comp_data *cd = comp_get_drvdata(dev); + ret = comp_verify_params(dev, 0, params); + if (ret < 0) { + comp_err(dev, "codec_adapter_params(): comp_verify_params() failed."); + return ret; + } + + ret = memcpy_s(&cd->stream_params, sizeof(struct sof_ipc_stream_params), + params, sizeof(struct sof_ipc_stream_params)); + assert(!ret); + + cd->period_bytes = params->sample_container_bytes * + params->channels * params->rate / 1000; return 0; } diff --git a/src/include/sof/audio/codec_adapter/codec/generic.h b/src/include/sof/audio/codec_adapter/codec/generic.h index fd757703c..52c359076 100644 --- a/src/include/sof/audio/codec_adapter/codec/generic.h +++ b/src/include/sof/audio/codec_adapter/codec/generic.h @@ -183,6 +183,8 @@ struct comp_data { struct comp_buffer *ca_sink; struct comp_buffer *ca_source; void *runtime_params; + struct sof_ipc_stream_params stream_params; + uint32_t period_bytes; /** pipeline period bytes */ }; /*****************************************************************************/