From patchwork Mon Dec 7 18:01:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10599 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 D6A2BBDB1F for ; Mon, 7 Dec 2020 18:02:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A080667E6E; Mon, 7 Dec 2020 19:02:07 +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="ri0Cn6OM"; dkim-atps=neutral Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA0CB67E6A for ; Mon, 7 Dec 2020 19:02:05 +0100 (CET) Received: by mail-ej1-x629.google.com with SMTP id f23so20811435ejk.2 for ; Mon, 07 Dec 2020 10:02:05 -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=wm3NAMcIrBR7j+LiHw5ffTkWgOX8WCAQ0spGz33JFqg=; b=ri0Cn6OM8wxoW3RQGOlducmwzbC8JX20KHmlR2W/BhDLn5pUsvZp7a6buc27IIAzLp 6gl1d/0pze55VjStrohMrW4rA7GHbxQ8hck8SYvHHQ2KD8kGdgX2OW1ri2UhKxaq5B6B UEiSk6gCpxMJdXQ4bs92gEWRrFAso0y49t380e8Dq1JHrV3yFpkoYHfGV6lR3F4JoLuu SX4XyIhi52rCylzSi2P8L1yplpXhT0Y2KD3arzd4kafQ3tBh6qfRukVn1MuZY+AiQYb/ jHiubW6AdTBbInIR+iFc2v3UYW/Ny06g78F2gqMcS869uDeZ5hb93MBpB9lUgo9oJ6iR pXsQ== 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=wm3NAMcIrBR7j+LiHw5ffTkWgOX8WCAQ0spGz33JFqg=; b=fI/JyN+leKVGVZhilAVrH8u807TJOqDqCsweQhlHcFKTeGCCNTjxk9PZYBxQ62S7sK kARaKLUmwQnL58pJhpJetCCYJaAIT8GfjTsXSR9AkDjvJoR9mV86WWqW0opgBmzzZTX/ S0Rc6LVxsGnGyBJe/Wgo1DQSDSBxBBwwp9/ByD5OLkf/bCY/d/U3SfnwIzkQ+RKx8DCT NcPmo44Hkeef91o5F65QWHkdjAPsxsXfjsgw/g7ElWo+GfqPtO9USSSZ9WEwZszACOJB NLrLmgAGDuXVMKz9tryj1h17JIvYbOxbrw/7pmpCKj4uXiitVlYeU4HRhQYJhR7s7No5 5PGQ== X-Gm-Message-State: AOAM532QQ51W6wZCIwJgDnGRUYCsL0YR0EpmFTsoa19RsXYP+TIBqjIO RLArkolz58ZhVrVRQjAp7t2N7Rkztcih+gNn X-Google-Smtp-Source: ABdhPJyTnN9ubJ/x6guDYY0MoMLdfrZlkqA5EEvoMmx0F3m4fshvjbFBseZn/6C6qgFKZD2mtwgZGQ== X-Received: by 2002:a17:906:c006:: with SMTP id e6mr19882295ejz.374.1607364125290; Mon, 07 Dec 2020 10:02:05 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id be6sm14657977edb.29.2020.12.07.10.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 10:01:58 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Mon, 7 Dec 2020 18:01:17 +0000 Message-Id: <20201207180121.6374-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201207180121.6374-1-david.plowman@raspberrypi.com> References: <20201207180121.6374-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/6] src: ipa: raspberrypi: agc: Add GetConvergenceFrames 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 GetConvergenceFrames 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 Reviewed-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/agc_algorithm.hpp | 1 + src/ipa/raspberrypi/controller/rpi/agc.cpp | 13 +++++++++++++ src/ipa/raspberrypi/controller/rpi/agc.hpp | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp index b4ea54fb..85fc6084 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 GetConvergenceFrames(unsigned int mistrust_frames) 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..787918cc 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); + convergence_frames = params.get("convergence_frames", 6); fast_reduce_threshold = params.get("fast_reduce_threshold", 0.4); base_ev = params.get("base_ev", 1.0); @@ -206,6 +207,18 @@ void Agc::Resume() fixed_analogue_gain_ = 0; } +unsigned int Agc::GetConvergenceFrames(unsigned int mistrust_frames) const +{ + // If shutter and gain have been explicitly set, there is no + // convergence to happen, so no need to drop any frames - return zero. + // Otherwise, any frames for which we have been told not to trust the + // statistics must be added to our own count. + if (fixed_shutter_ && fixed_analogue_gain_) + return 0; + else + return config_.convergence_frames + mistrust_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..7d41608a 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 convergence_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 GetConvergenceFrames(unsigned int mistrust_frames) const override; void SetEv(double ev) override; void SetFlickerPeriod(double flicker_period) override; void SetFixedShutter(double fixed_shutter) override; // microseconds