From patchwork Wed Mar 22 16:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18439 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 A1D66C3260 for ; Wed, 22 Mar 2023 16:13:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 403C262713; Wed, 22 Mar 2023 17:13:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1679501596; bh=Q9nYWYgXbYyKB9xNapmUD/AEc/dU8XmqqZPszshPCeg=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XVhubd1js9UZY4zwsrLIOpq9r7XP1Fu3VSYSQiSgn4qRVwMDGJnxEu8n5pHm4jC7t 6KNy1xchazo6FBtL6HoPH6/sgPea8XY1pqHqd/DdNeJN9HKs1+IGOBwCCxdTBtb57e kpZUXzkf17E/O8Idqh9GijqgcdRXxSD9G3secN5BrykfM2+lN4CurhmxKq9BtqkvfX /Cd7e002KHRtoZYl1zJxaZH6HwMhSIq5m0sQez0xCI9vw/kcERilJK+IKOKyO3RZiz fmL9ZqMdbDdMIyNiOyvuAFLB9X8L54NL/Xt4b79iyFRT/Wb74FQ5pD+UOP7YKToOyF mxGqZ/7Sj2Hug== Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97CE261ECE for ; Wed, 22 Mar 2023 17:13:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Pl+TGrxd"; dkim-atps=neutral Received: by mail-io1-xd2a.google.com with SMTP id s4so8682061ioj.11 for ; Wed, 22 Mar 2023 09:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1679501592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ldq/Rlt6NYA7xymrGzIpw8UgcgCXe3O7zbO3IBqcui4=; b=Pl+TGrxdt1F/3BwDdyMkcz6/yZ4I9vRfb+Fgvac1sho1BaoXA+ZLl3+khEzqTJ2s5l G8s4XYM0jwa2dCn3/dL/I7OQlgPpUMGJuvoLS5ExrcLXVS4Vj8PrQVpupVhuWanczX4V k7cJkuUY4DNrSyERteLxrCE4b/jisWhSrhy82JUxEqRES8ZanJZntSZiuFL6B4hcGB4C wA9AorsURSmLy1gBc+xJCmoBgPLEfZDQhkNCN9KieikAJ3//bfUbRtn/qO6EvY6Da2fy Mw1EmKIo3d8Acr1TP143xU/3MZe0lmmIpzt77O5nKzSOd7X4rFsaKjuYjlTzX/tn/7NF +evg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679501592; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ldq/Rlt6NYA7xymrGzIpw8UgcgCXe3O7zbO3IBqcui4=; b=StloSyRVZ2MIvXpsp1TQslocDG0r8/rAaExGYskvZoz3czFz63nEkRYq6N8K5Xfjjc dGKHP8zE6swsSbZ6N9P+PCd/+1uAOWznsWe78QfzAOD72EpfAWmT7AqfxhhHSmNHKVxL KgD/UMSklBrd+QE8LIz2lwcvvgfPHr/nvUnC3Et3J3Kh7Vf0GECYPMCE8o8cWVaU661t orRWD8UnCXduJFHWNAA56//iGLPnyzi6odD+0uXfllgCIuX6O8HXT54SDc196qRSvQ7n rjj8d56e3pA2p2QO2YHbvJTbJ/it2eQwZAX8Rm5i+Ue1w5iABgv9guuERelu4VNSPpyc zm+w== X-Gm-Message-State: AO0yUKXVU2iXUOc9HKbkO9EdeOBTlAfJlIgcRt7+ux5adwGLDl6nIUmj btVVCXYRfm7zAO8EMcsxXlvVaD19nleXNw+AmKR+Rg== X-Google-Smtp-Source: AK7set8B97V0PepPp/7ZdBpSQEwoBJZ7f6aDuc+dsXZoMwleLerxgtJBereC9qOwQXbPPpW57XFlPA== X-Received: by 2002:a6b:4f0b:0:b0:752:e9e5:49af with SMTP id d11-20020a6b4f0b000000b00752e9e549afmr5058931iob.2.1679501591975; Wed, 22 Mar 2023 09:13:11 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n24-20020a02a918000000b004050d92f6d4sm5100119jam.50.2023.03.22.09.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Mar 2023 09:13:11 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 22 Mar 2023 16:13:15 +0000 Message-Id: <20230322161317.18055-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230322161317.18055-1-naush@raspberrypi.com> References: <20230322161317.18055-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/3] ipa: raspberrypi: Replace setMaxShutter with setSensorLimits in AGC 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Create a SensorLimits structure in the AgcAlgorithm class. The maximum shutter time is stored in this structure from the IPA. In a subsequent commit, all gain and shutter limits will additionally be stored. Pass the SensorLimits structure with the maximum shutter time into the AGC algorithm through the new setSensorLimits() member function, replacing the call to setMaxShutter(). Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- src/ipa/raspberrypi/controller/agc_algorithm.h | 11 ++++++++++- src/ipa/raspberrypi/controller/rpi/agc.cpp | 10 +++++----- src/ipa/raspberrypi/controller/rpi/agc.h | 4 ++-- src/ipa/raspberrypi/raspberrypi.cpp | 7 ++++--- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.h b/src/ipa/raspberrypi/controller/agc_algorithm.h index 36e6c11058ee..c2759689c7f9 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.h +++ b/src/ipa/raspberrypi/controller/agc_algorithm.h @@ -15,13 +15,22 @@ namespace RPiController { class AgcAlgorithm : public Algorithm { public: + struct SensorLimits { + libcamera::utils::Duration minShutter; + libcamera::utils::Duration maxShutter; + libcamera::utils::Duration minFrameDuration; + libcamera::utils::Duration maxFrameDuration; + double minAnalogueGain; + double maxAnalogueGain; + }; + AgcAlgorithm(Controller *controller) : Algorithm(controller) {} /* An AGC algorithm must provide the following: */ virtual unsigned int getConvergenceFrames() const = 0; virtual void setEv(double ev) = 0; virtual void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) = 0; virtual void setFixedShutter(libcamera::utils::Duration fixedShutter) = 0; - virtual void setMaxShutter(libcamera::utils::Duration maxShutter) = 0; + virtual void setSensorLimits(const SensorLimits &limits) = 0; virtual void setFixedAnalogueGain(double fixedAnalogueGain) = 0; virtual void setMeteringMode(std::string const &meteringModeName) = 0; virtual void setExposureMode(std::string const &exposureModeName) = 0; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 4ea0dd41e66c..eaabc5fa9cd0 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -225,7 +225,7 @@ Agc::Agc(Controller *controller) frameCount_(0), lockCount_(0), lastTargetExposure_(0s), lastSensitivity_(0.0), ev_(1.0), flickerPeriod_(0s), - maxShutter_(0s), fixedShutter_(0s), fixedAnalogueGain_(0.0) + fixedShutter_(0s), fixedAnalogueGain_(0.0) { memset(&awb_, 0, sizeof(awb_)); /* @@ -300,9 +300,9 @@ void Agc::setFlickerPeriod(Duration flickerPeriod) flickerPeriod_ = flickerPeriod; } -void Agc::setMaxShutter(Duration maxShutter) +void Agc::setSensorLimits(const SensorLimits &limits) { - maxShutter_ = maxShutter; + sensorLimits_ = limits; } void Agc::setFixedShutter(Duration fixedShutter) @@ -874,8 +874,8 @@ void Agc::writeAndFinish(Metadata *imageMetadata, bool desaturate) Duration Agc::clipShutter(Duration shutter) { - if (maxShutter_) - shutter = std::min(shutter, maxShutter_); + if (sensorLimits_.maxShutter) + shutter = std::min(shutter, sensorLimits_.maxShutter); return shutter; } diff --git a/src/ipa/raspberrypi/controller/rpi/agc.h b/src/ipa/raspberrypi/controller/rpi/agc.h index f04896ca25ad..150a5f6e4428 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.h +++ b/src/ipa/raspberrypi/controller/rpi/agc.h @@ -78,7 +78,7 @@ public: unsigned int getConvergenceFrames() const override; void setEv(double ev) override; void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) override; - void setMaxShutter(libcamera::utils::Duration maxShutter) override; + void setSensorLimits(const SensorLimits &limits) override; void setFixedShutter(libcamera::utils::Duration fixedShutter) override; void setFixedAnalogueGain(double fixedAnalogueGain) override; void setMeteringMode(std::string const &meteringModeName) override; @@ -131,7 +131,7 @@ private: std::string constraintModeName_; double ev_; libcamera::utils::Duration flickerPeriod_; - libcamera::utils::Duration maxShutter_; + SensorLimits sensorLimits_; libcamera::utils::Duration fixedShutter_; double fixedAnalogueGain_; }; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 1375795568e2..c3b2c375036f 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1505,12 +1505,13 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur * getBlanking() will update maxShutter with the largest exposure * value possible. */ - Duration maxShutter = Duration::max(); - helper_->getBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); + RPiController::AgcAlgorithm::SensorLimits limits; + limits.maxShutter = Duration::max(); + helper_->getBlanking(limits.maxShutter, minFrameDuration_, maxFrameDuration_); RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.getAlgorithm("agc")); - agc->setMaxShutter(maxShutter); + agc->setSensorLimits(limits); } void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)