From patchwork Tue May 25 11:42:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12412 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 5F593C3204 for ; Tue, 25 May 2021 11:42:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 12E5468922; Tue, 25 May 2021 13:42:52 +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="fXpo+om9"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BFF668922 for ; Tue, 25 May 2021 13:42:48 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id h3so3811130wmq.3 for ; Tue, 25 May 2021 04:42:48 -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=bdqjGQ3FRaijmRa4Ylnuj7BQ8SDOANcbw7MuSIxFc3Q=; b=fXpo+om9Hi7ydNOhiqFJvjps/vawbER9NFCX2dURlEgGprxsiqXFy4MLhvhTjrTwFV +Zjb+wKJtHVrnkg5mH+gnHeghsrREOEqtLHWUx4IubiUoZC5pMJyU3FkifBi4oEJQOqT e3TBMVWSPIv+bTf14vmr2Gb8zjwyBpGo9Xt8b9Wn9268TYm+QeyMqiLK1T2/ApxDz6B6 z/5o82Q6MXLFLXvf1jam4grWxHB58LjSc/oX3KCrUJ/c74IKUuiFb6eyj/bI+AupNTbH iRNxlYuviUksdwJFPjgDLwCQeH+1Mr9zfcqrrx5fR6pArBMeBR74qJCICJWMI68BXSBL VQoQ== 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=bdqjGQ3FRaijmRa4Ylnuj7BQ8SDOANcbw7MuSIxFc3Q=; b=CDhTv+JBjs1EMUlxHRIufMTcrxoBY8wBGPtzHt+WDXmWhGE+E3X+2Syon/k1SyiMKT 61BbHH/nLGeBRT7Cj4ek8pZWCbNxpWWzlbhZ7h+VfG5X+TLzcxS7gOkhtd0myLZdxnq+ yduYOTAhIF9FAih0DEAGVzGVqjHKgt271O9tPiJkCsuQ3uVd+Et6F/mqGzjBHrBXtfi7 L1XZApCeeC37M5DhCLYp/SfjuDSX6nawyW+0o4lr8DtdlYZqzPtuelJEaYzdW1DAIYaU YogCKQp1AEdnTAKq1HGPh0xz4gIyvFO0jcWWo7aM+Q0G/VW857IbDXonZrUwSyaEVpX5 XJgQ== X-Gm-Message-State: AOAM530uo2BaFR/b6ls9UB534iO/mZ1Y1DSkFLlp5trqB0eMVfOmPgkA XEJAJAR3m+1wIcias3+zOCCtqoI7u2D9+A== X-Google-Smtp-Source: ABdhPJzsmF6edFA7/FIMrlIb2SmaMGIhi6dKkKorFxsHZh/x+r2C7T0OYaOOho7vZvDbvlq0eM1xVw== X-Received: by 2002:a7b:c5d2:: with SMTP id n18mr3458674wmk.97.1621942968002; Tue, 25 May 2021 04:42:48 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:f3e2:c7ee:8a9d:4c3a]) by smtp.gmail.com with ESMTPSA id v15sm2471443wmj.39.2021.05.25.04.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 04:42:47 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 25 May 2021 12:42:40 +0100 Message-Id: <20210525114241.906280-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210525114241.906280-1-naush@raspberrypi.com> References: <20210525114241.906280-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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..579ee2c91fa8 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(const libcamera::utils::Duration &flicker_period) = 0; + virtual void SetFixedShutter(const libcamera::utils::Duration &fixed_shutter) = 0; + virtual void SetMaxShutter(const 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..4e3318445cf3 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(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..2b39fcabada3 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 libcamera::utils::Duration &flicker_period) override; + void SetMaxShutter(const libcamera::utils::Duration &max_shutter) override; + void SetFixedShutter(const 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 4e02e94084f7..e083f6c254cc 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -640,8 +640,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; @@ -1094,7 +1094,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)