{"id":12412,"url":"https://patchwork.libcamera.org/api/patches/12412/?format=json","web_url":"https://patchwork.libcamera.org/patch/12412/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210525114241.906280-4-naush@raspberrypi.com>","date":"2021-05-25T11:42:40","name":"[libcamera-devel,v5,3/4] ipa: raspberrypi: Switch AgcAlgorithm API to use utils::Duration","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"0c4788b25fd41d29d8746a91bcc7e7a41cf2e2dc","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12412/mbox/","series":[{"id":2066,"url":"https://patchwork.libcamera.org/api/series/2066/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2066","date":"2021-05-25T11:42:37","name":"Switch RaspberryPi IPA to use std::chrono::duration","version":5,"mbox":"https://patchwork.libcamera.org/series/2066/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12412/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12412/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5F593C3204\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 May 2021 11:42:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 12E5468922;\n\tTue, 25 May 2021 13:42:52 +0200 (CEST)","from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BFF668922\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 13:42:48 +0200 (CEST)","by mail-wm1-x32c.google.com with SMTP id h3so3811130wmq.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 04:42:48 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:f3e2:c7ee:8a9d:4c3a])\n\tby smtp.gmail.com with ESMTPSA id\n\tv15sm2471443wmj.39.2021.05.25.04.42.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 25 May 2021 04:42:47 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"fXpo+om9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=bdqjGQ3FRaijmRa4Ylnuj7BQ8SDOANcbw7MuSIxFc3Q=;\n\tb=fXpo+om9Hi7ydNOhiqFJvjps/vawbER9NFCX2dURlEgGprxsiqXFy4MLhvhTjrTwFV\n\t+Zjb+wKJtHVrnkg5mH+gnHeghsrREOEqtLHWUx4IubiUoZC5pMJyU3FkifBi4oEJQOqT\n\te3TBMVWSPIv+bTf14vmr2Gb8zjwyBpGo9Xt8b9Wn9268TYm+QeyMqiLK1T2/ApxDz6B6\n\tz/5o82Q6MXLFLXvf1jam4grWxHB58LjSc/oX3KCrUJ/c74IKUuiFb6eyj/bI+AupNTbH\n\tiRNxlYuviUksdwJFPjgDLwCQeH+1Mr9zfcqrrx5fR6pArBMeBR74qJCICJWMI68BXSBL\n\tVQoQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=bdqjGQ3FRaijmRa4Ylnuj7BQ8SDOANcbw7MuSIxFc3Q=;\n\tb=CDhTv+JBjs1EMUlxHRIufMTcrxoBY8wBGPtzHt+WDXmWhGE+E3X+2Syon/k1SyiMKT\n\t61BbHH/nLGeBRT7Cj4ek8pZWCbNxpWWzlbhZ7h+VfG5X+TLzcxS7gOkhtd0myLZdxnq+\n\tyduYOTAhIF9FAih0DEAGVzGVqjHKgt271O9tPiJkCsuQ3uVd+Et6F/mqGzjBHrBXtfi7\n\tL1XZApCeeC37M5DhCLYp/SfjuDSX6nawyW+0o4lr8DtdlYZqzPtuelJEaYzdW1DAIYaU\n\tYogCKQp1AEdnTAKq1HGPh0xz4gIyvFO0jcWWo7aM+Q0G/VW857IbDXonZrUwSyaEVpX5\n\tXJgQ==","X-Gm-Message-State":"AOAM530uo2BaFR/b6ls9UB534iO/mZ1Y1DSkFLlp5trqB0eMVfOmPgkA\n\tXEJAJAR3m+1wIcias3+zOCCtqoI7u2D9+A==","X-Google-Smtp-Source":"ABdhPJzsmF6edFA7/FIMrlIb2SmaMGIhi6dKkKorFxsHZh/x+r2C7T0OYaOOho7vZvDbvlq0eM1xVw==","X-Received":"by 2002:a7b:c5d2:: with SMTP id n18mr3458674wmk.97.1621942968002;\n\tTue, 25 May 2021 04:42:48 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 3/4] ipa: raspberrypi: Switch\n\tAgcAlgorithm API to use utils::Duration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Switch the AgcAlgorithm API functions to use utils::Duration for all\ntime based variables.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/ipa/raspberrypi/controller/agc_algorithm.hpp |  7 ++++---\n src/ipa/raspberrypi/controller/rpi/agc.cpp       | 13 +++++++------\n src/ipa/raspberrypi/controller/rpi/agc.hpp       |  6 +++---\n src/ipa/raspberrypi/raspberrypi.cpp              |  6 +++---\n 4 files changed, 17 insertions(+), 15 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp\nindex f97deb0fca59..579ee2c91fa8 100644\n--- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp\n+++ b/src/ipa/raspberrypi/controller/agc_algorithm.hpp\n@@ -6,6 +6,7 @@\n  */\n #pragma once\n \n+#include \"libcamera/internal/utils.h\"\n #include \"algorithm.hpp\"\n \n namespace RPiController {\n@@ -17,9 +18,9 @@ public:\n \t// An AGC algorithm must provide the following:\n \tvirtual unsigned int GetConvergenceFrames() const = 0;\n \tvirtual void SetEv(double ev) = 0;\n-\tvirtual void SetFlickerPeriod(double flicker_period) = 0;\n-\tvirtual void SetFixedShutter(double fixed_shutter) = 0; // microseconds\n-\tvirtual void SetMaxShutter(double max_shutter) = 0; // microseconds\n+\tvirtual void SetFlickerPeriod(const libcamera::utils::Duration &flicker_period) = 0;\n+\tvirtual void SetFixedShutter(const libcamera::utils::Duration &fixed_shutter) = 0;\n+\tvirtual void SetMaxShutter(const libcamera::utils::Duration &max_shutter) = 0;\n \tvirtual void SetFixedAnalogueGain(double fixed_analogue_gain) = 0;\n \tvirtual void SetMeteringMode(std::string const &metering_mode_name) = 0;\n \tvirtual void SetExposureMode(std::string const &exposure_mode_name) = 0;\ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex f4cd5d26fb4e..4e3318445cf3 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -21,6 +21,7 @@\n \n using namespace RPiController;\n using namespace libcamera;\n+using libcamera::utils::Duration;\n \n LOG_DEFINE_CATEGORY(RPiAgc)\n \n@@ -222,19 +223,19 @@ void Agc::SetEv(double ev)\n \tev_ = ev;\n }\n \n-void Agc::SetFlickerPeriod(double flicker_period)\n+void Agc::SetFlickerPeriod(const Duration &flicker_period)\n {\n-\tflicker_period_ = flicker_period;\n+\tflicker_period_ = flicker_period.get<std::micro>();\n }\n \n-void Agc::SetMaxShutter(double max_shutter)\n+void Agc::SetMaxShutter(const Duration &max_shutter)\n {\n-\tmax_shutter_ = max_shutter;\n+\tmax_shutter_ = max_shutter.get<std::micro>();\n }\n \n-void Agc::SetFixedShutter(double fixed_shutter)\n+void Agc::SetFixedShutter(const Duration &fixed_shutter)\n {\n-\tfixed_shutter_ = fixed_shutter;\n+\tfixed_shutter_ = fixed_shutter.get<std::micro>();\n \t// Set this in case someone calls Pause() straight after.\n \tstatus_.shutter_time = clipShutter(fixed_shutter_);\n }\ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp\nindex 0427fb59ec1b..2b39fcabada3 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp\n@@ -77,9 +77,9 @@ public:\n \tvoid Resume() override;\n \tunsigned int GetConvergenceFrames() const override;\n \tvoid SetEv(double ev) override;\n-\tvoid SetFlickerPeriod(double flicker_period) override;\n-\tvoid SetMaxShutter(double max_shutter) override; // microseconds\n-\tvoid SetFixedShutter(double fixed_shutter) override; // microseconds\n+\tvoid SetFlickerPeriod(const libcamera::utils::Duration &flicker_period) override;\n+\tvoid SetMaxShutter(const libcamera::utils::Duration &max_shutter) override;\n+\tvoid SetFixedShutter(const libcamera::utils::Duration &fixed_shutter) override;\n \tvoid SetFixedAnalogueGain(double fixed_analogue_gain) override;\n \tvoid SetMeteringMode(std::string const &metering_mode_name) override;\n \tvoid SetExposureMode(std::string const &exposure_mode_name) override;\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 4e02e94084f7..e083f6c254cc 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -640,8 +640,8 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\t\tbreak;\n \t\t\t}\n \n-\t\t\t/* This expects units of micro-seconds. */\n-\t\t\tagc->SetFixedShutter(ctrl.second.get<int32_t>());\n+\t\t\t/* The control provides units of microseconds. */\n+\t\t\tagc->SetFixedShutter(ctrl.second.get<int32_t>() * 1.0us);\n \n \t\t\tlibcameraMetadata_.set(controls::ExposureTime, ctrl.second.get<int32_t>());\n \t\t\tbreak;\n@@ -1094,7 +1094,7 @@ void IPARPi::applyFrameDurations(const Duration &minFrameDuration,\n \n \tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n \t\tcontroller_.GetAlgorithm(\"agc\"));\n-\tagc->SetMaxShutter(maxShutter.get<std::micro>());\n+\tagc->SetMaxShutter(maxShutter);\n }\n \n void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n","prefixes":["libcamera-devel","v5","3/4"]}