From 4acc8e35cff7548eba9fb1e4be4052d5340a9254 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 31 May 2024 12:20:34 +0200 Subject: ipa: rkisp1: Use the extensible parameters format Signed-off-by: Jacopo Mondi --- src/ipa/rkisp1/rkisp1.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/ipa/rkisp1/rkisp1.cpp') diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 6687c91e..05e5ed26 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -325,16 +325,40 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls) void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) { IPAFrameContext &frameContext = context_.frameContexts.get(frame); + rkisp1_ext_params_block_header *block; + size_t totalSize = 0; - rkisp1_params_cfg *params = - reinterpret_cast( - mappedBuffers_.at(bufferId).planes()[0].data()); + rkisp1_ext_params_cfg *params = + reinterpret_cast( + mappedBuffers_.at(bufferId).planes()[0].data()); /* Prepare parameters buffer. */ memset(params, 0, sizeof(*params)); - for (auto const &algo : algorithms()) - algo->prepare(context_, frame, frameContext, params); + params->version = RKISP1_EXT_PARAM_BUFFER_V1; + + block = reinterpret_cast(params->data); + for (auto const &algo : algorithms()) { + + algo->prepare(context_, frame, frameContext, block); + + /* + * Each algorithm could add multiple parameter blocks, each of + * which will have its own embedded header struct with the size + * of that block. We need to iterate through them, sum all of + * the block sizes and advance the 'block' pointer to the next + * empty one. + */ + while (totalSize < RKISP1_EXT_PARAMS_MAX_SIZE && block->size) { + totalSize += block->size; + block = reinterpret_cast + (params->data + totalSize); + } + + ASSERT(totalSize <= RKISP1_EXT_PARAMS_MAX_SIZE); + } + + params->total_size = totalSize; paramsBufferReady.emit(frame); } -- cgit v1.2.1