From patchwork Fri May 21 08:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12335 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 7B2F3C31FB for ; Fri, 21 May 2021 08:05:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A4176891F; Fri, 21 May 2021 10:05:43 +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="ePmoGrj6"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7447F68918 for ; Fri, 21 May 2021 10:05:39 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id q5so20093421wrs.4 for ; Fri, 21 May 2021 01:05:39 -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=Jne7FFyHUXM/cwQqpyyWmcX6MOj2YSJs1V/8tN5yUEk=; b=ePmoGrj65TxtBqUY9Z2E7YAFSh0qBsVOKj2MggPXYmZJy0cEpIQyPZWL6tdqt1D3KL ilbJUhwgKDkULuiQR5Gy9xgWY7pwlsiCqCCaPrWoiy2H6j2878flproDU2tcsM855D8P P+UfBdc7+JqchTV8zkb7RJVwF3LMhvCaqhL1y8oAPqRdOWeLW9/4Pmd3vQ0DfuowboOr Sl56PaRctwavZ7RlxIprz/BuJwXpvsACeYoMYggVOLI+CcGNh5EYziBkzcCQ8wH+sqb4 KAzS7g2ITat2D1vQHZIq5n7hMWTSNiGn44jQe5OHWKFn2jtiRO2t4cGbWtJl6nsdD+sE gT4A== 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=Jne7FFyHUXM/cwQqpyyWmcX6MOj2YSJs1V/8tN5yUEk=; b=qqfOnl43wpQ9teHOV6nwh0drnQZZfMk9SwF3VdEO6Brf5CrWySHvSn/WhGyyIB4api LXLMRKfAAxIZTFrNnWPGg16H+S001d7ampAXJzwfpNBpu53W+SlSu13b0urtvv8zd9kt G1I+wZBt8U2GjUvtowo++ck1O/6K3BsgVbykijuZINULboBZZ3PcypoCkTxsWIoD/z0O tad1ew9LKG7Th9IRwaJlG4Q/aBDq1QASB9vPwMEVkWsdwYHuQ4BBSTPiAM1KvXCHqaVY d+1tmZ3hGjz72XjRNFSOYmXS3b3cirvRWLcMm1rup2L5SaL9jiUZjN8TYrg8TIEL74DN rTmQ== X-Gm-Message-State: AOAM533IdTQdhOIodVSNjVzvBOj4xEqQSzs84dT6AKVe3HMTXbe8E6zc Gy55vbZ348Gs5SmEA/6Uk2jFFw6OwbCxBA== X-Google-Smtp-Source: ABdhPJzgQjoAwWS4dcolcmw9pG5CbuyBeDPJ2U7nFqkj27SdSujlQ+RBUuTkP5UuLSal/nuqwat4lQ== X-Received: by 2002:adf:dcd2:: with SMTP id x18mr8015555wrm.202.1621584338939; Fri, 21 May 2021 01:05:38 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:de31:dc1f:6be5:f58e]) by smtp.gmail.com with ESMTPSA id q186sm5159176wme.20.2021.05.21.01.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 01:05:38 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Fri, 21 May 2021 09:05:29 +0100 Message-Id: <20210521080530.37591-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210521080530.37591-1-naush@raspberrypi.com> References: <20210521080530.37591-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/4] ipa: raspberrypi: Switch AgcAlgorithm API to use utils::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 utils::Duration for all time based variables. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/agc_algorithm.hpp | 9 ++++++--- 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, 18 insertions(+), 15 deletions(-) diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp index f97deb0fca59..dabb814ea3dd 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/agc_algorithm.hpp @@ -6,10 +6,13 @@ */ #pragma once +#include "libcamera/internal/utils.h" #include "algorithm.hpp" namespace RPiController { +using libcamera::utils::Duration; + class AgcAlgorithm : public Algorithm { public: @@ -17,9 +20,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(const Duration &flicker_period) = 0; + virtual void SetFixedShutter(const Duration &fixed_shutter) = 0; + virtual void SetMaxShutter(const 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..482eb3ef962d 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(const Duration &flicker_period) { - flicker_period_ = flicker_period; + flicker_period_ = flicker_period.get(); } -void Agc::SetMaxShutter(double max_shutter) +void Agc::SetMaxShutter(const Duration &max_shutter) { - max_shutter_ = max_shutter; + max_shutter_ = max_shutter.get(); } -void Agc::SetFixedShutter(double fixed_shutter) +void Agc::SetFixedShutter(const Duration &fixed_shutter) { - fixed_shutter_ = fixed_shutter; + fixed_shutter_ = fixed_shutter.get(); // 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..16a65959d90e 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(const Duration &flicker_period) override; + void SetMaxShutter(const Duration &max_shutter) override; + void SetFixedShutter(const 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 e5d4c92a8e01..f8f36420b076 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -641,8 +641,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; @@ -1095,7 +1095,7 @@ void IPARPi::applyFrameDurations(const Duration &minFrameDuration, RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - agc->SetMaxShutter(maxShutter.get()); + agc->SetMaxShutter(maxShutter); } void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)