From patchwork Tue Jun 8 11:03:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12515 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 45F3BBD22E for ; Tue, 8 Jun 2021 11:03:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F2EEB68930; Tue, 8 Jun 2021 13:03: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="pK0SKqnl"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C7586892E for ; Tue, 8 Jun 2021 13:03:42 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id l11-20020a05600c4f0bb029017a7cd488f5so1591063wmq.0 for ; Tue, 08 Jun 2021 04:03:42 -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=fdrC8KEhavjfv2hqPb4hbHb8dTYssUbrYPASaoaD9ks=; b=pK0SKqnlMaXubRXJ/EvUJnbYN39g4pHcc2nkBOrMYLz3anynuYd5wznnAUZUKHnGlr Ej8eWogJTGCZr/fDKPetH10hZQ126XpgiD9Cfq2uvNy5Bwj9G5QCpkdpl4yzZC4yxCg4 f8HjiKCnNAxRZSyWi241yfDcrrd+vyu0tW1abyqcII8qO80l4BgemqBUXI1GuYFYubp/ W4ejXllNA0rtMae5CKCzIoW/mhX8x06868+yng5FzK+N9/gHmB0QUIxq5MTaTYBpoVvN qSFHODUGsI6/vqwJUd7FPjDPFsVgjnvWj6wBiKNykE4ry3Nq8Skh2yt8HUBkbeUlLqQa RczQ== 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=fdrC8KEhavjfv2hqPb4hbHb8dTYssUbrYPASaoaD9ks=; b=S1L1Ic7WFv1df6WDZIPtbhw81RK9JwuKaWOsrJslsYehtc2i3WHqybxsMZcfczxGHC eEMEGyohvPoJkC5e1gNBpQMXDX7MejWkA9rHc9y+2PvnGjIMV1OaPRLlQJLyw/WXOAmX 4Twt5D3WBU370+qjsIHe74Cvolk0C2q/OtpkGEepa/UTd/oOUq/AD1k2rjofJQ7N+w44 jgGblSTaQlyd4mrJ69S8jSq0WiYlAW5GXyIAjboQKZvzzfIwk2o08Y8MEjb2ylKdM0Hv 9qyUhU/tbb70zuU9O7evFLgFde/dOdrfWW41oZC8+jFLTbdgN7Z4vqz9GtfDAegFd1Am aV9g== X-Gm-Message-State: AOAM531CFz4CAe/o+59DhLKsuRfS9Pe61HuANPWwruB059J3GJFzwJXG JFmD8IVm7PkyZ7qkrRmi1VGuqDRGXZGwOw== X-Google-Smtp-Source: ABdhPJxw2yF6qFBpgMzw3YRvW/O5Ix+IBEk5trWaExYMoAAxY1Dhk7aWt7RgNap2khdbTWF9/j3iuw== X-Received: by 2002:a7b:c414:: with SMTP id k20mr21717777wmi.90.1623150221378; Tue, 08 Jun 2021 04:03:41 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:5aef:f665:51b0:d8c0]) by smtp.gmail.com with ESMTPSA id o129sm2639350wmo.22.2021.06.08.04.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 04:03:41 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Jun 2021 12:03:34 +0100 Message-Id: <20210608110335.4078551-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210608110335.4078551-1-naush@raspberrypi.com> References: <20210608110335.4078551-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/agc_algorithm.hpp | 7 ++++--- src/ipa/raspberrypi/controller/rpi/agc.cpp | 13 +++++++------ src/ipa/raspberrypi/controller/rpi/agc.hpp | 6 +++--- src/ipa/raspberrypi/raspberrypi.cpp | 6 +++--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp index f97deb0fca59..134bbcda50ce 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/agc_algorithm.hpp @@ -6,6 +6,7 @@ */ #pragma once +#include "libcamera/internal/utils.h" #include "algorithm.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(libcamera::utils::Duration flicker_period) = 0; + virtual void SetFixedShutter(libcamera::utils::Duration fixed_shutter) = 0; + virtual void SetMaxShutter(libcamera::utils::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..fd3359a77958 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -21,6 +21,7 @@ using namespace RPiController; using namespace libcamera; +using libcamera::utils::Duration; LOG_DEFINE_CATEGORY(RPiAgc) @@ -222,19 +223,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_ = flicker_period.get(); } -void Agc::SetMaxShutter(double max_shutter) +void Agc::SetMaxShutter(Duration max_shutter) { - max_shutter_ = max_shutter; + max_shutter_ = max_shutter.get(); } -void Agc::SetFixedShutter(double fixed_shutter) +void Agc::SetFixedShutter(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..b52aaa23d51c 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(libcamera::utils::Duration flicker_period) override; + void SetMaxShutter(libcamera::utils::Duration max_shutter) override; + void SetFixedShutter(libcamera::utils::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 33b316b90d16..4aa8ccaa985a 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -638,8 +638,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; @@ -1091,7 +1091,7 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.GetAlgorithm("agc")); - agc->SetMaxShutter(maxShutter.get()); + agc->SetMaxShutter(maxShutter); } void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)