From patchwork Wed Dec 2 11:52:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10544 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 C962FBE177 for ; Wed, 2 Dec 2020 11:53:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 85477635AF; Wed, 2 Dec 2020 12:53:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pQYEFlNm"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F002635A1 for ; Wed, 2 Dec 2020 12:53:01 +0100 (CET) Received: by mail-wr1-x42b.google.com with SMTP id g14so3505179wrm.13 for ; Wed, 02 Dec 2020 03:53:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rHVELqS19rTQ4tecujAhRQFO0ru7LWVkfSyFhbGD/bA=; b=pQYEFlNmCHkhR8QdgLVu5pTH2KKevhIKhJ74rar+HOt8tY1O00tmp+e5x243Eow2IX wBGboqe0ud3m9dfpOQNayWZbOrSStQjF/LrzhcCt8TICohtrcZk6vJUlreOGpd950zzN Tu9uK0YIYhIvf+Xhqe3p8lQ1e3R8wueOJf2i0i69jYy6agKNGnsybpeH1fENodvBFVS3 K2Gr4cMN1Qt8iVl1gEUf0otdJyaq6RAOtGAVrhahi/LBpn+noZukxznFyfiu43lXOs2Z 60grsNrkvNFavvB2V/ywERJmNA0N8HTH+V7VCZdPkTwE6IcK/uummKQP3xddN/d1WdKP d9uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rHVELqS19rTQ4tecujAhRQFO0ru7LWVkfSyFhbGD/bA=; b=YAsaVPFy4RDaGTRzLpE6zi1C9TY7T/itz7/oWBvKhb5uGEiC9HcGvUAGnwK8TinKvj r6fL3jR+u6ZaK3vAcCgSpcjZtgpxtz1gXMBSZPq4E6fsM6RrbxxX5I0oTGrXCsY0VB4j kAvjYXFmkaDtyBhaXwXYP530gGtg9NtK+3ZfGQAI3uTncwLkeuVuWcGQIio/5ospeYKo g4sdTML4KASjTr0fFxsZqn3vMio5ZSEmLBDihG37XN/+Mhm1KHKULr5wh6aCY0VGI5Vr BX7c9Tonjpa2u28FQV/XzD93fXjx4B8JsNw8E/wasKCvk6K2o6MgdQ485/9b27LLNr67 NsxA== X-Gm-Message-State: AOAM531x7jhteS1iZ+pwvNvHoRBH5T2KfgjRJu3KeuAdUD6v7sp7ZkIO D9t45U1tuIqpd9V3HnrVe0Q4wcXM/Sra8Ofg X-Google-Smtp-Source: ABdhPJyqqpZyiW/57Sn3NUfP2mPwsltUyFTH305D0cirTS8t47bBprSTSwvnlgP+XfoQadAjfBsxZA== X-Received: by 2002:adf:dd04:: with SMTP id a4mr2999482wrm.77.1606909980599; Wed, 02 Dec 2020 03:53:00 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id n189sm1739215wmf.20.2020.12.02.03.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 03:52:59 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 2 Dec 2020 11:52:51 +0000 Message-Id: <20201202115253.14705-4-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201202115253.14705-1-david.plowman@raspberrypi.com> References: <20201202115253.14705-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] src: ipa: raspberrypi: agc: Add GetDropFrames method to AGC base class 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" We add a GetDropFrames method to the AgcAlgorithm class which can be called when the AGC is started from scratch. It suggests how many frames should be dropped before displaying any (while the AGC converges). The Raspberry Pi specific implementation makes this customisable from the tuning file. Signed-off-by: David Plowman --- src/ipa/raspberrypi/controller/agc_algorithm.hpp | 1 + src/ipa/raspberrypi/controller/rpi/agc.cpp | 11 +++++++++++ src/ipa/raspberrypi/controller/rpi/agc.hpp | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp index b4ea54fb..bfc9743f 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/agc_algorithm.hpp @@ -15,6 +15,7 @@ class AgcAlgorithm : public Algorithm public: AgcAlgorithm(Controller *controller) : Algorithm(controller) {} // An AGC algorithm must provide the following: + virtual unsigned int GetDropFrames() const = 0; virtual void SetEv(double ev) = 0; virtual void SetFlickerPeriod(double flicker_period) = 0; virtual void SetFixedShutter(double fixed_shutter) = 0; // microseconds diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 9da18c31..94c02d47 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -142,6 +142,7 @@ void AgcConfig::Read(boost::property_tree::ptree const ¶ms) Y_target.Read(params.get_child("y_target")); speed = params.get("speed", 0.2); startup_frames = params.get("startup_frames", 10); + drop_frames = params.get("drop_frames", 6); fast_reduce_threshold = params.get("fast_reduce_threshold", 0.4); base_ev = params.get("base_ev", 1.0); @@ -206,6 +207,16 @@ void Agc::Resume() fixed_analogue_gain_ = 0; } +unsigned int Agc::GetDropFrames() const +{ + // If shutter and gain have been explicitly set, there is no + // convergence to happen, so no need to drop any frames. + if (fixed_shutter_ && fixed_analogue_gain_) + return 0; + else + return config_.drop_frames; +} + void Agc::SetEv(double ev) { ev_ = ev; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp index 95db1812..1de4d505 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp @@ -52,6 +52,7 @@ struct AgcConfig { Pwl Y_target; double speed; uint16_t startup_frames; + unsigned int drop_frames; double max_change; double min_change; double fast_reduce_threshold; @@ -74,6 +75,7 @@ public: bool IsPaused() const override; void Pause() override; void Resume() override; + unsigned int GetDropFrames() const override; void SetEv(double ev) override; void SetFlickerPeriod(double flicker_period) override; void SetFixedShutter(double fixed_shutter) override; // microseconds