From patchwork Wed Feb 23 10:48:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 15371 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 0819DBE08A for ; Wed, 23 Feb 2022 10:48:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 57644610B3; Wed, 23 Feb 2022 11:48:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QWE8gAfh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87CDD610B3 for ; Wed, 23 Feb 2022 11:48:28 +0100 (CET) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:7ebc:9e38:c4df:c57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2816D929; Wed, 23 Feb 2022 11:48:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1645613308; bh=69evzyf5yk0B/1jNYt6LwIOVd8DSoIDQs1knjQtkDu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QWE8gAfhxk2v8aW9FgcTKLtpsSE0Sx/IjczoexG82RxUaaJzBfQG7CYoP3Jnz+tkn 5/QNXF2HWh2QBGL+wgp6rO1UZkjyjsB9N5ffeSQwxzxtPiUImKBzzlELVm6n4gOkC3 /Hp6e/vobtQs8jziggOkUwqCyd+m4w68RJgtLTKo= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Wed, 23 Feb 2022 11:48:21 +0100 Message-Id: <20220223104824.25723-2-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220223104824.25723-1-jeanmichel.hautbois@ideasonboard.com> References: <20220223104824.25723-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] ipa: rkisp1: Use frame index 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" Instead of incrementing the frameCount manually in a local counter, use the frame index on the EventStatReay event and store it in a new IPAFrameContext variable named frameId. The frameId may be used by other algorithms later. Signed-off-by: Jean-Michel Hautbois Tested-by: Peter Griffin Reviewed-by: Laurent Pinchart --- src/ipa/rkisp1/algorithms/agc.cpp | 5 ++--- src/ipa/rkisp1/ipa_context.cpp | 5 +++++ src/ipa/rkisp1/ipa_context.h | 2 ++ src/ipa/rkisp1/rkisp1.cpp | 11 +++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index dd97afc0..50980835 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -82,8 +82,6 @@ int Agc::configure(IPAContext &context, else numCells_ = RKISP1_CIF_ISP_AE_MEAN_MAX_V12; - /* \todo Use actual frame index by populating it in the frameContext. */ - frameCount_ = 0; return 0; } @@ -255,6 +253,8 @@ void Agc::process(IPAContext &context, const rkisp1_stat_buffer *stats) const rkisp1_cif_isp_ae_stat *ae = ¶ms->ae; + frameCount_ = context.frameContext.frameId; + /* * Estimate the gain needed to achieve a relative luminance target. To * account for non-linearity caused by saturation, the value needs to be @@ -278,7 +278,6 @@ void Agc::process(IPAContext &context, const rkisp1_stat_buffer *stats) } computeExposure(context, yGain); - frameCount_++; } void Agc::prepare([[maybe_unused]] IPAContext &context, diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 9cb2a9fd..992c9225 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -113,4 +113,9 @@ namespace libcamera::ipa::rkisp1 { * \brief Analogue gain multiplier */ +/** + * \var IPAFrameContext::frameId + * \brief Frame number for this frame context + */ + } /* namespace libcamera::ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index b94ade0c..c447369f 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -43,6 +43,8 @@ struct IPAFrameContext { uint32_t exposure; double gain; } sensor; + + unsigned int frameId; }; struct IPAContext { diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 2d79f15f..732ca2bb 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -56,8 +56,7 @@ public: private: void queueRequest(unsigned int frame, rkisp1_params_cfg *params, const ControlList &controls); - void updateStatistics(unsigned int frame, - const rkisp1_stat_buffer *stats); + void updateStatistics(const rkisp1_stat_buffer *stats); void setControls(unsigned int frame); void metadataReady(unsigned int frame, unsigned int aeState); @@ -239,7 +238,6 @@ void IPARkISP1::processEvent(const RkISP1Event &event) { switch (event.op) { case EventSignalStatBuffer: { - unsigned int frame = event.frame; unsigned int bufferId = event.bufferId; const rkisp1_stat_buffer *stats = @@ -250,8 +248,9 @@ void IPARkISP1::processEvent(const RkISP1Event &event) event.sensorControls.get(V4L2_CID_EXPOSURE).get(); context_.frameContext.sensor.gain = camHelper_->gain(event.sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get()); + context_.frameContext.frameId = event.frame; - updateStatistics(frame, stats); + updateStatistics(stats); break; } case EventQueueRequest: { @@ -286,10 +285,10 @@ void IPARkISP1::queueRequest(unsigned int frame, rkisp1_params_cfg *params, queueFrameAction.emit(frame, op); } -void IPARkISP1::updateStatistics(unsigned int frame, - const rkisp1_stat_buffer *stats) +void IPARkISP1::updateStatistics(const rkisp1_stat_buffer *stats) { unsigned int aeState = 0; + unsigned int frame = context_.frameContext.frameId; for (auto const &algo : algorithms_) algo->process(context_, stats);