From patchwork Tue May 18 10:07:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12311 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 40B7BC31FF for ; Tue, 18 May 2021 10:09:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D024168926; Tue, 18 May 2021 12:09:17 +0200 (CEST) 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="KSV/obGj"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1852C602B2 for ; Tue, 18 May 2021 12:09:13 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id r12so9567043wrp.1 for ; Tue, 18 May 2021 03:09:13 -0700 (PDT) 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=Y5RXuJHyUTxuAceYnXQsVzi1M30dRbpIawpuv7wWDUM=; b=KSV/obGjDaLaXguvASYAOLMdDgKpU2zk5jyjgY8XAuCFeSOoOtGUyjXJpkh317HgpW Hzs4Xd6qmGTlHitURIP2Lg5s2OAT6mgrzGJhGK+pRtVjralfdv9CoSycjggT1QypOgT4 rFva6Sop9InHbbOeDwuVcumDDaL9ifUoCImkCdfhcxtssqa6qNSf3L+RX9dVI4nFOHKx H18XXhm1o1Hev/4z+rxtKgs3H3u/9KMyYJkPGL61/EYLc6bVvIfOT0+SYNaQlK9sl/Ha YkcUw/7sOvz14qktpmxyR7JeYSq42de1Y6YoOiMpIvEvzE4UOTf2BXEcYVvbl00YoCHM rpQQ== 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=Y5RXuJHyUTxuAceYnXQsVzi1M30dRbpIawpuv7wWDUM=; b=E3sIzc5aN+XYVEoDZKlVTc+NsMXXsnZum8DWkgq6gm15qloNrMZ5MwNdeTghutNLrE jxM6iDQeTVfYNkHTuFKe9a+NAnibIAAAtTkIo0Vq41EFkbYg6MoVWSpnvvvoBWHl6ia+ Cd0MeX2Nw4BC47hRgv723xVaxQgw9KNBZGDwDFA0auSygr9P+mg1Y1y5qRRr8KWHaF3Y +2QD/Bw23pvqL36jvspg4tyrLP8QrGDsAXsXX66r9igUD0CE0A96RClZsRxKVFD3SCtD zRlCNSMgBH5FOf07g9lPszhpterRJKA/IiudvqoP2WgY66Yk01TVl2ovz/uNDBzJY24u X+ww== X-Gm-Message-State: AOAM533VSmDJNW9Xn9tieeMueAvP7Kjt5Itc2lOfYQufE0RcszHFgpp7 3q5kbGE5O89mcN2CEHuUMnASy2i6K7IeHA== X-Google-Smtp-Source: ABdhPJzKq8ySsdtJbDD+kxUIQEhc5+DMKSwyqpkInYPQA06iv6vCP1wCR94EMea9oUXqR8KjDwYr+Q== X-Received: by 2002:adf:fa45:: with SMTP id y5mr5935819wrr.311.1621332552540; Tue, 18 May 2021 03:09:12 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:34e4:187b:f2:ed28]) by smtp.gmail.com with ESMTPSA id o11sm6566682wrq.93.2021.05.18.03.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 03:09:12 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 18 May 2021 11:07:05 +0100 Message-Id: <20210518100706.578526-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210518100706.578526-1-naush@raspberrypi.com> References: <20210518100706.578526-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] ipa: raspberrypi: Switch AgcAlgorithm API to use RPiController::Duration 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" Switch the AgcAlgorithm API functions to use RPiController::Duration for all time based variables. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/agc_algorithm.hpp | 7 ++++--- src/ipa/raspberrypi/controller/rpi/agc.cpp | 12 ++++++------ src/ipa/raspberrypi/controller/rpi/agc.hpp | 6 +++--- src/ipa/raspberrypi/raspberrypi.cpp | 6 +++--- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp index f97deb0fca59..668912c47388 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/agc_algorithm.hpp @@ -7,6 +7,7 @@ #pragma once #include "algorithm.hpp" +#include "duration.hpp" namespace RPiController { @@ -17,9 +18,9 @@ public: // 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 - virtual void SetMaxShutter(double max_shutter) = 0; // microseconds + virtual void SetFlickerPeriod(Duration flicker_period) = 0; + virtual void SetFixedShutter(Duration fixed_shutter) = 0; + virtual void SetMaxShutter(Duration max_shutter) = 0; virtual void SetFixedAnalogueGain(double fixed_analogue_gain) = 0; virtual void SetMeteringMode(std::string const &metering_mode_name) = 0; virtual void SetExposureMode(std::string const &exposure_mode_name) = 0; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index f4cd5d26fb4e..1cb4472b2691 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -222,19 +222,19 @@ void Agc::SetEv(double ev) ev_ = ev; } -void Agc::SetFlickerPeriod(double flicker_period) +void Agc::SetFlickerPeriod(Duration flicker_period) { - flicker_period_ = flicker_period; + flicker_period_ = DurationValue(flicker_period); } -void Agc::SetMaxShutter(double max_shutter) +void Agc::SetMaxShutter(Duration max_shutter) { - max_shutter_ = max_shutter; + max_shutter_ = DurationValue(max_shutter); } -void Agc::SetFixedShutter(double fixed_shutter) +void Agc::SetFixedShutter(Duration fixed_shutter) { - fixed_shutter_ = fixed_shutter; + fixed_shutter_ = DurationValue(fixed_shutter); // Set this in case someone calls Pause() straight after. status_.shutter_time = clipShutter(fixed_shutter_); } diff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp index 0427fb59ec1b..cb79bf61ba42 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp @@ -77,9 +77,9 @@ public: void Resume() override; unsigned int GetConvergenceFrames() const override; void SetEv(double ev) override; - void SetFlickerPeriod(double flicker_period) override; - void SetMaxShutter(double max_shutter) override; // microseconds - void SetFixedShutter(double fixed_shutter) override; // microseconds + void SetFlickerPeriod(Duration flicker_period) override; + void SetMaxShutter(Duration max_shutter) override; + void SetFixedShutter(Duration fixed_shutter) override; void SetFixedAnalogueGain(double fixed_analogue_gain) override; void SetMeteringMode(std::string const &metering_mode_name) override; void SetExposureMode(std::string const &exposure_mode_name) override; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 994fb7e057a9..f080f2e53bac 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -643,8 +643,8 @@ void IPARPi::queueRequest(const ControlList &controls) break; } - /* This expects units of micro-seconds. */ - agc->SetFixedShutter(ctrl.second.get()); + /* The control provides units of microseconds. */ + agc->SetFixedShutter(ctrl.second.get() * 1.0us); libcameraMetadata_.set(controls::ExposureTime, ctrl.second.get()); break; @@ -1097,7 +1097,7 @@ void IPARPi::applyFrameDurations(const Duration &minFrameDuration, RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - agc->SetMaxShutter(DurationValue(maxShutter)); + agc->SetMaxShutter(maxShutter); } void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)