From patchwork Thu May 20 15:17:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12330 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 9F2E4C31FF for ; Thu, 20 May 2021 15:17:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 278A168925; Thu, 20 May 2021 17:17:26 +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="aqqY4f5c"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B63B768921 for ; Thu, 20 May 2021 17:17:22 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id n2so18150943wrm.0 for ; Thu, 20 May 2021 08:17:22 -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=aqqY4f5cKXoJmjAbpnevjMAVVUf3R490qkZNfTUXLVpsX4E437y9iKu2HicIQw7JRk sJWFmwww2R7DdG51Q6aikJd1p9nIFelXfZe3L2Xih1vNSsUqN4qDra0aQ+Ly2Oo1DoEf 7nXwHdfaTCgaVu+YCHDh3bn5sfXnQjOIC+h/PpkTCeRvrF5CU2cImePNlr4ulbGqgT+o KQ4uZVSVwhvX6S2XHG+EtRQqAivZSpyBsO4xE6P0J9fD/S6WsCWEe34TGyPjrf7s46yK 9FzsLvyH/xpp9h0mQvQWnotmniFERl2QMnxP8H7fAbBmX4woFPpAgmltAvP65t/nu3Rv U/tg== 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=tN0hKTa8v9V9muDO2uTmiebaORS9//CEA4BkubiqFst+U7VubIpoJiPg4SWOvjUFru IdfeNva3Sfr9kaFL8dyTbwjfISmhfmhqBlxYdRJNedKIad2fBDW7zvltBIQX0wCzkPFy +abcAsvOSL97rj7TB7yM5QbItxIWlmnl0Oi5dq988QSr6lMUKWxORvrAX6J0abwQootZ lx2wepLFt82NyhSJ2L9bTiJVLDSjcRi4FZxrVtISwUXcVSmVKEofVQ8WmT92a4VgYNBR RYYfdQ5bGZDvawtzFLErn5Vn5jfa2Ev1kAE4aUybhYw4i0Rgey0fyW/0RsgZdEkq6dEJ 1xWw== X-Gm-Message-State: AOAM532aE/zP9kpajA6R2ZKVkossrIPG85zL1Nl32uTtdhtMRxRxsZsF 9v6/YXuYkJY06Pq5jphFZjZc7GNfnyoZDw== X-Google-Smtp-Source: ABdhPJzJB+nWj9MjJ9zDD8HbjlgXrPbU07NnsmQkGcAMJyfS3OXDs3kYIxyWvv8vCVPArO8wZxltvg== X-Received: by 2002:adf:e84e:: with SMTP id d14mr4765399wrn.323.1621523842162; Thu, 20 May 2021 08:17:22 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:de31:dc1f:6be5:f58e]) by smtp.gmail.com with ESMTPSA id a11sm3583885wrr.48.2021.05.20.08.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 08:17:21 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 20 May 2021 16:17:13 +0100 Message-Id: <20210520151714.3366445-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210520151714.3366445-1-naush@raspberrypi.com> References: <20210520151714.3366445-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 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)