From patchwork Mon May 24 08:48:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12376 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 9AD82C3201 for ; Mon, 24 May 2021 08:48:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 447D068925; Mon, 24 May 2021 10:48:35 +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="FggvbYo5"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 078B868922 for ; Mon, 24 May 2021 10:48:31 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id n17-20020a7bc5d10000b0290169edfadac9so1165192wmk.1 for ; Mon, 24 May 2021 01:48:31 -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=l9Rhxy7l9fwAKZj9Q2e2L0sQKBLDPV0pSpzK9+xure4=; b=FggvbYo5vNgpZhNiHyHziAEj/kZW+spVvfl6xdnURLEJpH4xEDHvETEAWFbMWgxKk0 ZecRitYQX8Xnt5s+dpPqPp7G5DMPZ5HveyEUirg4hmmjvzyYo8/9DklWVvdQIjlbQSsL pRqqbVb0/0ScouT4bt6//+faFy911isUmooTywXBlJuXJOoLV7zVZw1KP27wX8PBID9p hMvEhgerUG9iMM7ATSOmlzl5Qz3BU9S6vL9Wre+BOYpjUEUxirQlewKBVc+oLuGD0sl1 PfybxNtNNYK+nNljlFEM6U96tOYkyoEXYI1w2V7Q32duCvhVA+E77Qh3e+diDVZ8qcok TrBQ== 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=l9Rhxy7l9fwAKZj9Q2e2L0sQKBLDPV0pSpzK9+xure4=; b=WpHtPCtBaRoFpTy33gv4hv22QjPW+0oPBWMHENv927y9T6IvGPIQxpq7iBxMIRx5np D3+R9zQ3HTJl/x2p3/XoI6XkCaDN8mWfnmoXCUErBfnNRbZ8D1B42BBfF51Pg6kAPSrv KTkDLdUSTTinJVszrLoaJfU/8F5SY/scKHnk26677+quC5YZ5ui6MmvU/1KlD61Ee5Bl HHvEzpN6k38RFn/S1ch7NXv8G5ZVHEZZwOoj6NwQwkfxYPs3iiTRq9X/qK/+welGbyld EfWpwIuJYlVdwzpaEsoD3g6QSTLrUjvE66FkQ5MJwEf9HYmb6hyjVorpsVq5w9sSHqGU 7U2w== X-Gm-Message-State: AOAM5300bwM+FKhx6xjuQ1todnf5Tt+XklSQmnOhOXA+wZKIdRoFA92I XK2tGY3X207ElfUGFXuPXeC3YqzVPv2q0Q== X-Google-Smtp-Source: ABdhPJzLczBsuChYCBbMsI6BvX0XA0zBDAIL9SbTa5CpCjQatuPVNfY5tmeD7MQ0vll5CMvwAH/fhQ== X-Received: by 2002:a05:600c:2054:: with SMTP id p20mr19390493wmg.165.1621846110474; Mon, 24 May 2021 01:48:30 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:4bf6:b415:2edf:916a]) by smtp.gmail.com with ESMTPSA id x10sm11275767wrt.65.2021.05.24.01.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 01:48:30 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 24 May 2021 09:48:21 +0100 Message-Id: <20210524084822.3690690-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210524084822.3690690-1-naush@raspberrypi.com> References: <20210524084822.3690690-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- 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 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)