From patchwork Tue Oct 29 11:25:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 21768 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 25949C31E9 for ; Tue, 29 Oct 2024 11:25:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1F18C6539F; Tue, 29 Oct 2024 12:25:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="i2ZQKUQw"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 36BC860366 for ; Tue, 29 Oct 2024 12:25:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730201107; x=1761737107; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=FXiuxxqi1c+vuMUxhBh7Jto5dgBhQcwTBrgQIeWoF5A=; b=i2ZQKUQwlT75vbxJbPd+bM48OA766irwR5XJqM+12KrSIoPf+U/tk3sz nc3OO04TbuU/QNnyVt6DUe8oq/RoqMMeSxMzNMEuckF2A2P8yBysJZgWs J8uw6g8fr3Meq/70pWx0EawMORIUr7ug7UCaF0xIOTwUvRCnjqpMH9nO6 uCSxokQj+rpJricG7S8pTxeLYAQ4amTyy02+AVB314ANQJYwHFycNhgAF +KwNUEXsVF+cFZ6zZF045Bi9yGBsuNCXye/SBnj/efiUIigvtKj/IkqNq FQOZPNd+jXNZQY2onmZrcFy/CZiBPcJxW7xX6nxqhe3ZrFK7BGc42drY4 g==; X-CSE-ConnectionGUID: DpPnmRC2SK2AwHW+yLzzWA== X-CSE-MsgGUID: 9iaC6KpFR9O8wtoofeC2+w== X-IronPort-AV: E=McAfee;i="6700,10204,11239"; a="29289311" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="29289311" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 04:25:04 -0700 X-CSE-ConnectionGUID: Skz/2GX+Sc2x8nPyDCrhDA== X-CSE-MsgGUID: 6ZXixHotS2iFsysoDXWr9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="85890418" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.246.8.237]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 04:25:03 -0700 From: Stanislaw Gruszka To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH 1/2] libcamera: software_isp: Initialize exposure+gain before agc calculations Date: Tue, 29 Oct 2024 12:25:00 +0100 Message-Id: <20241029112501.140252-1-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 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" On my setup, since commit fb8ad13d ("libcamera: software_isp: Move exposure+gain to an algorithm module"), at start camera output stays very dark for dozen of seconds, and then later slowly gets to normal. This is because existing sensor exposure+gain settings are not used at start. We save initial values in frameContext but in the agc algorithm we use IPA context. Fix the problem by using in frameContext sensor values, since we already use those in blc algorithm and change exposure type to int32_t to unnecessary castings. Signed-off-by: Stanislaw Gruszka Reviewed-by: Milan Zamazal Tested-by: Robert Mader Tested-by: Kieran Bingham Reviewed-by: Kieran Bingham --- src/ipa/simple/algorithms/agc.cpp | 8 ++++---- src/ipa/simple/algorithms/agc.h | 2 +- src/ipa/simple/algorithms/blc.h | 2 +- src/ipa/simple/ipa_context.h | 2 +- src/ipa/simple/soft_simple.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp index df92edd7..72aade14 100644 --- a/src/ipa/simple/algorithms/agc.cpp +++ b/src/ipa/simple/algorithms/agc.cpp @@ -39,7 +39,7 @@ Agc::Agc() { } -void Agc::updateExposure(IPAContext &context, double exposureMSV) +void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV) { /* * kExpDenominator of 10 gives ~10% increment/decrement; @@ -50,8 +50,8 @@ void Agc::updateExposure(IPAContext &context, double exposureMSV) static constexpr uint8_t kExpNumeratorDown = kExpDenominator - 1; double next; - int32_t &exposure = context.activeState.agc.exposure; - double &again = context.activeState.agc.again; + int32_t &exposure = frameContext.sensor.exposure; + double &again = frameContext.sensor.gain; if (exposureMSV < kExposureOptimal - kExposureSatisfactory) { next = exposure * kExpNumeratorUp / kExpDenominator; @@ -129,7 +129,7 @@ void Agc::process(IPAContext &context, } float exposureMSV = (denom == 0 ? 0 : static_cast(num) / denom); - updateExposure(context, exposureMSV); + updateExposure(context, frameContext, exposureMSV); } REGISTER_IPA_ALGORITHM(Agc, "Agc") diff --git a/src/ipa/simple/algorithms/agc.h b/src/ipa/simple/algorithms/agc.h index ad5fca9f..112d9f5a 100644 --- a/src/ipa/simple/algorithms/agc.h +++ b/src/ipa/simple/algorithms/agc.h @@ -25,7 +25,7 @@ public: ControlList &metadata) override; private: - void updateExposure(IPAContext &context, double exposureMSV); + void updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV); }; } /* namespace ipa::soft::algorithms */ diff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h index 2cf2a877..67c688ae 100644 --- a/src/ipa/simple/algorithms/blc.h +++ b/src/ipa/simple/algorithms/blc.h @@ -27,7 +27,7 @@ public: ControlList &metadata) override; private: - uint32_t exposure_; + int32_t exposure_; double gain_; }; diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h index fd121eeb..c510c436 100644 --- a/src/ipa/simple/ipa_context.h +++ b/src/ipa/simple/ipa_context.h @@ -53,7 +53,7 @@ struct IPAActiveState { struct IPAFrameContext : public FrameContext { struct { - uint32_t exposure; + int32_t exposure; double gain; } sensor; }; diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp index c8ad55a2..dfacd6aa 100644 --- a/src/ipa/simple/soft_simple.cpp +++ b/src/ipa/simple/soft_simple.cpp @@ -310,8 +310,8 @@ void IPASoftSimple::processStats(const uint32_t frame, ControlList ctrls(sensorInfoMap_); - auto &againNew = context_.activeState.agc.again; - ctrls.set(V4L2_CID_EXPOSURE, context_.activeState.agc.exposure); + auto &againNew = frameContext.sensor.gain; + ctrls.set(V4L2_CID_EXPOSURE, frameContext.sensor.exposure); ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(camHelper_ ? camHelper_->gainCode(againNew) : againNew)); From patchwork Tue Oct 29 11:25:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 21769 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 46F68C31E9 for ; Tue, 29 Oct 2024 11:25:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1D748653A0; Tue, 29 Oct 2024 12:25:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="loG5AZYr"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E00BA60366 for ; Tue, 29 Oct 2024 12:25:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730201108; x=1761737108; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9zmMjx0bGyfmYhQd+Taa6ZfjWcAKr04ll4MRai2cMEE=; b=loG5AZYr1X2AEyel7FFRmC8T43olfCIz3o57hCKS/9/7Ud0rnt16wjNx eUhAem5eg5+aCwTDCwIkVvkaLX1/cp4w7m6/7/PQBr9BC9jNCHWqVJWlv 6iuWxtOa8t8SBSKX6BQF1XHet3Pf4rmOoFD9n5ikXvO4ySmML3b4ydljL dv90lYzrSs06lJ5gMWEj6Xd2hOhMpCHBBZxDVhF6qyc0IJo77AvG8uX6i fj8tXnptSWevAUlu5M6vhhAbxzTC7L9k7lBbadUDw4FQj+qXHzq0af2dm Wczc1IZPUJJeuIialzfr99zLjLvbRBDqF27iP0mSh7grCx4Df+FlpJtrq w==; X-CSE-ConnectionGUID: NDk35Cp4Q2CqpZwwZTXxTw== X-CSE-MsgGUID: +Y3IEcWYTaW0MV+atFvySQ== X-IronPort-AV: E=McAfee;i="6700,10204,11239"; a="29289320" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="29289320" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 04:25:08 -0700 X-CSE-ConnectionGUID: AJrsAvU2SEaWC7sUlgIwdA== X-CSE-MsgGUID: afM7rZFbS/2pzdCOpJqbXQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="85890428" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.246.8.237]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 04:25:07 -0700 From: Stanislaw Gruszka To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH 2/2] libcamera: software_isp: Remove unused IPAActiveState fields Date: Tue, 29 Oct 2024 12:25:01 +0100 Message-Id: <20241029112501.140252-2-stanislaw.gruszka@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241029112501.140252-1-stanislaw.gruszka@linux.intel.com> References: <20241029112501.140252-1-stanislaw.gruszka@linux.intel.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" Now agc struct in IPAActiveState is not used any longer. If there will be need to have this struct, this patch can be reverted. Signed-off-by: Stanislaw Gruszka Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham --- src/ipa/simple/ipa_context.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h index c510c436..2885a851 100644 --- a/src/ipa/simple/ipa_context.h +++ b/src/ipa/simple/ipa_context.h @@ -39,11 +39,6 @@ struct IPAActiveState { double blue; } gains; - struct { - int32_t exposure; - double again; - } agc; - static constexpr unsigned int kGammaLookupSize = 1024; struct { std::array gammaTable;