From patchwork Tue Dec 8 20:44:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 10614 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 109E1BDB20 for ; Tue, 8 Dec 2020 20:44:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D156167E4D; Tue, 8 Dec 2020 21:44:48 +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="r4251brt"; dkim-atps=neutral Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8575567F0B for ; Tue, 8 Dec 2020 21:44:46 +0100 (CET) Received: by mail-ed1-x52a.google.com with SMTP id u19so19035263edx.2 for ; Tue, 08 Dec 2020 12:44:46 -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=UYqtHEtBUNAP4L0qxPTMgG5zq+NcHWYZHLEVzCW38KQ=; b=r4251brtCqji/ieJdgO/tgiZcludjXOD2fc3+XnbXGbTVFrIsD4dcaKFk3P0fKXEzn nNpNk/oOnb66oJb23FloBAxmLTQTpX7mdksOUkLS9FV3FRco+a7V8KNwED4qd1Enyvrg HpH8E2SxKsrp3Ix9A8auXvYT+VpN6voj9eJlYXg30woXvXm+PJ8Vrudz9Q8FUinXvVPl C3pO2mEtEZSVA+emYcTM37EOFWkNyRPOYMuB8sUeG+b/sCrbn8pClAImAkP+4tdMPLSC 0qvNb7AYhtp4FTUoTlHQjSBWu3H5/QUINDVLmn4YMRyHyYaRmoyO5T3a+t1D6d3l9Nl3 0FMQ== 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=UYqtHEtBUNAP4L0qxPTMgG5zq+NcHWYZHLEVzCW38KQ=; b=mWshqtZb8uEOy3QW521ej47e1KaMpNwR+FXONX1H9HIJj4sEJ235/QGpL3BunX/KOZ B+W87BsJZBcana1l7skawyMdamj+2QSSAi6yTfrFTbP59mUNOZQ4k/n9dso26UDycFLN c111CCEBpk9z1VEyrRDWTpHx+iN3hg2wYwsiFQUyUzbPqbRgG38HoPBRYz1HfIEwcWeB pq3Ln5zgEznnTv8zIxijBPHQWaq/K/7yAjreC7wBJdYx8xrtmnpmYTu4Qx7DBGIg1zKc NvWkbTKhosPPgwUvcN4FmU/h6ltFV8rvfmnipdJkN+BDNT9ULEdEsd/qKzN5e7yPAnKD 3jIA== X-Gm-Message-State: AOAM532TkDDdWyYR80/97G7GeiIDyHHYZZIIqCuzxk2SzMz2Ounm7Ket 5jPBrRCP0BcUsn191v8U9xvtGskcUAVZNrZK X-Google-Smtp-Source: ABdhPJyJpUtXmPka4yBw5n5b6HM+ds+t/rVNam4KpGckBJmJcrGbhKjPLxPg1YAq6zhIuBtz2o1piQ== X-Received: by 2002:aa7:cf8f:: with SMTP id z15mr22970078edx.17.1607460285847; Tue, 08 Dec 2020 12:44:45 -0800 (PST) Received: from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72]) by smtp.gmail.com with ESMTPSA id be6sm18441471edb.29.2020.12.08.12.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 12:44:45 -0800 (PST) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Dec 2020 20:44:37 +0000 Message-Id: <20201208204441.9356-3-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201208204441.9356-1-david.plowman@raspberrypi.com> References: <20201208204441.9356-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 | 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..981f1de2 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() 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..eddd1684 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,16 @@ void Agc::Resume() fixed_analogue_gain_ = 0; } +unsigned int Agc::GetConvergenceFrames() const +{ + // If shutter and gain have been explicitly set, there is no + // convergence to happen, so no need to drop any frames - return zero. + if (fixed_shutter_ && fixed_analogue_gain_) + return 0; + else + return config_.convergence_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..05c334e4 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() const override; void SetEv(double ev) override; void SetFlickerPeriod(double flicker_period) override; void SetFixedShutter(double fixed_shutter) override; // microseconds