From patchwork Wed Oct 16 17:03:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 21648 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 298FFC32FA for ; Wed, 16 Oct 2024 17:04:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8356265390; Wed, 16 Oct 2024 19:04:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="oRGfja8u"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 12D7065387 for ; Wed, 16 Oct 2024 19:04:02 +0200 (CEST) Received: from ideasonboard.com (unknown [5.179.178.254]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 146BCA57; Wed, 16 Oct 2024 19:02:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1729098139; bh=WdPsga3bUrrKjDFEvYjrkFAbfuqXjMX3ciPAAERo/f4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oRGfja8uExYE/NAVb1p5IH5AVgrQRJOsJKy3S892iQrgCD9VhOp7SvM5GeGrsCr17 3PQ1zsAfPbi0APqA85xgQiOOamm0pm+0JKAx1RqQj6c//ARRFCGqMZrfUmNEf0nujl 7DhUECNlZvy8EpSeOy65FyU9RhgIQE4YqWXh74ns= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Paul Elder Subject: [PATCH 4/4] ipa: rkisp1: Initialize FrameContext.agc.meteringMode Date: Wed, 16 Oct 2024 19:03:45 +0200 Message-ID: <20241016170348.715993-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241016170348.715993-1-jacopo.mondi@ideasonboard.com> References: <20241016170348.715993-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The RkISP1 AGC algorithms assumes the metering mode to be "MeteringMatrix" and pre-fill an array of weights associated with it stored in meteringModes_[MeteringMatrix] when intializing the algorithm in parseMeteringModes(). It laters fetches the weights when computing parameters using the FrameContext.agc.meteringMode as index of the meteringModes_ array. When a Request gets queued to the algorithm, the FrameContext.agc.meteringMode index is populated from the algorithm's active state, and optionally updated if the application has specified a different metering mode. In case of Request underrun however, a non-initialized FrameContext gets provided to the algorithm, causing an (unhandled) exception when accessing the meteringModes_ array. Fix this by intializing the AGC metering mode to a supported value coming from the ActiveState in IPAFrameContext::init(). Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/agc.cpp | 2 ++ src/ipa/rkisp1/ipa_context.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 17d074d9c03e..dd7e9468741e 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -175,6 +175,8 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo) static_cast(constraintModes().begin()->first); context.activeState.agc.exposureMode = static_cast(exposureModeHelpers().begin()->first); + + /* Use the metering matrix mode by default. */ context.activeState.agc.meteringMode = static_cast(meteringModes_.begin()->first); diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 2dad42b3154f..e88609137345 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -421,6 +421,11 @@ void IPAFrameContext::init(const uint32_t frameNum, const ActiveState &activeState) { FrameContext::init(frameNum, activeState); + + const IPAActiveState *rkisp1ActiveState = + reinterpret_cast(&activeState); + + agc.meteringMode = rkisp1ActiveState->agc.meteringMode; } /**