From patchwork Fri Oct 20 08:40:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19167 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 03C89C32B8 for ; Fri, 20 Oct 2023 08:40:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A554562988; Fri, 20 Oct 2023 10:40:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1697791236; bh=Yp1iH+nU2dfob3NUfknPBnEJJ6Ut319oQzWEz8fTTzs=; 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=eq1eKlU1RdczhQTyS4WKztfMnnMei3ZIi1aaIcoDW7yWou7wJfnniK7FJhal+LI/l EN6lothnw1amLJA71ORr1AcEztIWzQPBsMsmv5OTCeQOaSw1gJ0CobaTCcCRqpVcbR tpKw7KLVdJUMkjG9G+DWyxhM6AMrXWDnkoxJC5Vwx/YIXm1mtZRxH8RxTfkxoU+WMM NY4beNPMChDeiHlZUMk3gWnwxp6mvGfoFMEOOIa8/zhmG+5vL5uIJkE0tCC2Svdwv1 PvURRlIthcmDWRcyVb/c7h91WBQXY4xhROG/ueyXlHZFKBbkdcIXRek1uJNSJON9vB YI9ivvD+fnk4g== Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C73396298A for ; Fri, 20 Oct 2023 10:40:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="PYHCfc+T"; dkim-atps=neutral Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31c5cac3ae2so430733f8f.3 for ; Fri, 20 Oct 2023 01:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1697791231; x=1698396031; darn=lists.libcamera.org; 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=ONlW2T4HkI3qwVgetsJja6/efFs+Qrn3bOK1EZjcag4=; b=PYHCfc+Tsirfckb9ThgE/xo4RfnCldwP8ZClnMJ3E1kipBCBUt+lh4sp3RqFXOcJKY ZqwhtgtvsbJnNMZgjKK9LMpIApKZqgcUQMgGuoavCV4C8zgGCu25wqI3X1W+TVTkNjTm DywdLSS6rvceH8OXIX58Xqy7TwjYBnU7e/YZLOVwsqDuV65CWGfyx6cctWGKX2Ip1Pp6 FTXSQHGD89pqLllqQRvPsy8oxpwRwsPARMwDlSdITsaTs5/jTmmHGdW0yzux4aSBaXq2 cBQGp6SzT17N/oP/iMmAggALEddW/KI5vByCWWmABBbXel2TSZTKAm9yWfOVOS6O4OjO YueQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697791231; x=1698396031; 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=ONlW2T4HkI3qwVgetsJja6/efFs+Qrn3bOK1EZjcag4=; b=kD+0cG41efWxdc3zLzPpGbkZDRx7KNl+C4MkVZeu2G9+K15S3PKEJwvoXLni+9d7Cg WxHDAwM6FnD7k6Ds95gFlJ3VKCy70wxW9c/FSlEUpP2+uBW376y+RHtlvlpYc7bOdF1g 26wuAgVMs2om7MFKr8wDEOFcGSTaLjIb/QLNEivMHMftVQDzuunAENVnhw9zDMxdJFTq BhifG9cspy9DwHcuSzuf9duVUTY5GeaeozOtna4XbeAFGZUJqbtZiWqpMJx1KW2QCRQY m7CFUNesl7oZuKWWHeg31hAJkYclQGTtbpfW40kL+sY/CXqleOf1rpKkIua5un+MBol2 klSA== X-Gm-Message-State: AOJu0YxH1MR2w3bX9GKlSZasjmj4YefuzAKQ06Rjy+PTqDxpJvtD5+hh toHjEQj+pEOXs8MYEvokgMCxd2PyZC11HwWzraUUsA== X-Google-Smtp-Source: AGHT+IEk71pn0N6xWdEq3YobfW2udBMIHXGfWBnxp6rWXskrwR6YlkPsw8O+FqWZU4yeyQ6BvLsINg== X-Received: by 2002:a05:6000:ac9:b0:31a:e8e6:8a96 with SMTP id di9-20020a0560000ac900b0031ae8e68a96mr797758wrb.67.1697791231193; Fri, 20 Oct 2023 01:40:31 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id r3-20020adff103000000b0032d9337e7d1sm1213356wro.11.2023.10.20.01.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 01:40:30 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 20 Oct 2023 09:40:02 +0100 Message-Id: <20231020084002.30665-7-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020084002.30665-1-naush@raspberrypi.com> References: <20231020084002.30665-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 6/6] ipa: rpi: agc: Make AGC controls affect all channels 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" From: David Plowman We need to be able to do things like enable/disable AGC for all the channels, so most of the AGC controls are updated to be applied to all channels. There are a couple of exceptions, such as setting explicit shutter/gain values, which apply only to channel 0. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/rpi/common/ipa_base.cpp | 14 +++---- src/ipa/rpi/controller/agc_algorithm.h | 11 +++--- src/ipa/rpi/controller/rpi/agc.cpp | 51 +++++++++++++------------- src/ipa/rpi/controller/rpi/agc.h | 13 +++---- 4 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 2583c6226f44..a1fec3aa3dd1 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -702,9 +702,9 @@ void IpaBase::applyControls(const ControlList &controls) } if (ctrl.second.get() == false) - agc->disableAuto(0); + agc->disableAuto(); else - agc->enableAuto(0); + agc->enableAuto(); libcameraMetadata_.set(controls::AeEnable, ctrl.second.get()); break; @@ -773,7 +773,7 @@ void IpaBase::applyControls(const ControlList &controls) int32_t idx = ctrl.second.get(); if (ConstraintModeTable.count(idx)) { - agc->setConstraintMode(0, ConstraintModeTable.at(idx)); + agc->setConstraintMode(ConstraintModeTable.at(idx)); libcameraMetadata_.set(controls::AeConstraintMode, idx); } else { LOG(IPARPI, Error) << "Constraint mode " << idx @@ -793,7 +793,7 @@ void IpaBase::applyControls(const ControlList &controls) int32_t idx = ctrl.second.get(); if (ExposureModeTable.count(idx)) { - agc->setExposureMode(0, ExposureModeTable.at(idx)); + agc->setExposureMode(ExposureModeTable.at(idx)); libcameraMetadata_.set(controls::AeExposureMode, idx); } else { LOG(IPARPI, Error) << "Exposure mode " << idx @@ -836,12 +836,12 @@ void IpaBase::applyControls(const ControlList &controls) switch (mode) { case controls::FlickerOff: - agc->setFlickerPeriod(0, 0us); + agc->setFlickerPeriod(0us); break; case controls::FlickerManual: - agc->setFlickerPeriod(0, flickerState_.manualPeriod); + agc->setFlickerPeriod(flickerState_.manualPeriod); break; @@ -875,7 +875,7 @@ void IpaBase::applyControls(const ControlList &controls) * first, and the period updated after, or vice versa. */ if (flickerState_.mode == controls::FlickerManual) - agc->setFlickerPeriod(0, flickerState_.manualPeriod); + agc->setFlickerPeriod(flickerState_.manualPeriod); break; } diff --git a/src/ipa/rpi/controller/agc_algorithm.h b/src/ipa/rpi/controller/agc_algorithm.h index b8986560ac88..534e38e2b5b7 100644 --- a/src/ipa/rpi/controller/agc_algorithm.h +++ b/src/ipa/rpi/controller/agc_algorithm.h @@ -22,17 +22,16 @@ public: virtual unsigned int getConvergenceFrames() const = 0; virtual std::vector const &getWeights() const = 0; virtual void setEv(unsigned int channel, double ev) = 0; - virtual void setFlickerPeriod(unsigned int channel, - libcamera::utils::Duration flickerPeriod) = 0; + virtual void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) = 0; virtual void setFixedShutter(unsigned int channel, libcamera::utils::Duration fixedShutter) = 0; virtual void setMaxShutter(libcamera::utils::Duration maxShutter) = 0; virtual void setFixedAnalogueGain(unsigned int channel, double fixedAnalogueGain) = 0; virtual void setMeteringMode(std::string const &meteringModeName) = 0; - virtual void setExposureMode(unsigned int channel, std::string const &exposureModeName) = 0; - virtual void setConstraintMode(unsigned int channel, std::string const &contraintModeName) = 0; - virtual void enableAuto(unsigned int channel) = 0; - virtual void disableAuto(unsigned int channel) = 0; + virtual void setExposureMode(std::string const &exposureModeName) = 0; + virtual void setConstraintMode(std::string const &contraintModeName) = 0; + virtual void enableAuto() = 0; + virtual void disableAuto() = 0; virtual void setActiveChannels(const std::vector &activeChannels) = 0; }; diff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp index 32eb36242268..6549dedd0a07 100644 --- a/src/ipa/rpi/controller/rpi/agc.cpp +++ b/src/ipa/rpi/controller/rpi/agc.cpp @@ -74,22 +74,22 @@ int Agc::checkChannel(unsigned int channelIndex) const return 0; } -void Agc::disableAuto(unsigned int channelIndex) +void Agc::disableAuto() { - if (checkChannel(channelIndex)) - return; + LOG(RPiAgc, Debug) << "disableAuto"; - LOG(RPiAgc, Debug) << "disableAuto for channel " << channelIndex; - channelData_[channelIndex].channel.disableAuto(); + /* All channels are enabled/disabled together. */ + for (auto &data : channelData_) + data.channel.disableAuto(); } -void Agc::enableAuto(unsigned int channelIndex) +void Agc::enableAuto() { - if (checkChannel(channelIndex)) - return; + LOG(RPiAgc, Debug) << "enableAuto"; - LOG(RPiAgc, Debug) << "enableAuto for channel " << channelIndex; - channelData_[channelIndex].channel.enableAuto(); + /* All channels are enabled/disabled together. */ + for (auto &data : channelData_) + data.channel.enableAuto(); } unsigned int Agc::getConvergenceFrames() const @@ -118,14 +118,13 @@ void Agc::setEv(unsigned int channelIndex, double ev) channelData_[channelIndex].channel.setEv(ev); } -void Agc::setFlickerPeriod(unsigned int channelIndex, Duration flickerPeriod) +void Agc::setFlickerPeriod(Duration flickerPeriod) { - if (checkChannel(channelIndex)) - return; + LOG(RPiAgc, Debug) << "setFlickerPeriod " << flickerPeriod; - LOG(RPiAgc, Debug) << "setFlickerPeriod " << flickerPeriod - << " for channel " << channelIndex; - channelData_[channelIndex].channel.setFlickerPeriod(flickerPeriod); + /* Flicker period will be the same across all channels. */ + for (auto &data : channelData_) + data.channel.setFlickerPeriod(flickerPeriod); } void Agc::setMaxShutter(Duration maxShutter) @@ -162,22 +161,22 @@ void Agc::setMeteringMode(std::string const &meteringModeName) data.channel.setMeteringMode(meteringModeName); } -void Agc::setExposureMode(unsigned int channelIndex, std::string const &exposureModeName) +void Agc::setExposureMode(std::string const &exposureModeName) { - if (checkChannel(channelIndex)) - return; + LOG(RPiAgc, Debug) << "setExposureMode " << exposureModeName; - LOG(RPiAgc, Debug) << "setExposureMode " << exposureModeName - << " for channel " << channelIndex; - channelData_[channelIndex].channel.setExposureMode(exposureModeName); + /* Exposure mode will be the same across all channels. */ + for (auto &data : channelData_) + data.channel.setExposureMode(exposureModeName); } -void Agc::setConstraintMode(unsigned int channelIndex, std::string const &constraintModeName) +void Agc::setConstraintMode(std::string const &constraintModeName) { - if (checkChannel(channelIndex)) - return; + LOG(RPiAgc, Debug) << "setConstraintMode " << constraintModeName; - channelData_[channelIndex].channel.setConstraintMode(constraintModeName); + /* Constraint mode will be the same across all channels. */ + for (auto &data : channelData_) + data.channel.setConstraintMode(constraintModeName); } template diff --git a/src/ipa/rpi/controller/rpi/agc.h b/src/ipa/rpi/controller/rpi/agc.h index 908904393fbf..7d26bdf6df45 100644 --- a/src/ipa/rpi/controller/rpi/agc.h +++ b/src/ipa/rpi/controller/rpi/agc.h @@ -31,20 +31,17 @@ public: unsigned int getConvergenceFrames() const override; std::vector const &getWeights() const override; void setEv(unsigned int channel, double ev) override; - void setFlickerPeriod(unsigned int channelIndex, - libcamera::utils::Duration flickerPeriod) override; + void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) override; void setMaxShutter(libcamera::utils::Duration maxShutter) override; void setFixedShutter(unsigned int channelIndex, libcamera::utils::Duration fixedShutter) override; void setFixedAnalogueGain(unsigned int channelIndex, double fixedAnalogueGain) override; void setMeteringMode(std::string const &meteringModeName) override; - void setExposureMode(unsigned int channelIndex, - std::string const &exposureModeName) override; - void setConstraintMode(unsigned int channelIndex, - std::string const &contraintModeName) override; - void enableAuto(unsigned int channelIndex) override; - void disableAuto(unsigned int channelIndex) override; + void setExposureMode(std::string const &exposureModeName) override; + void setConstraintMode(std::string const &contraintModeName) override; + void enableAuto() override; + void disableAuto() override; void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; void prepare(Metadata *imageMetadata) override; void process(StatisticsPtr &stats, Metadata *imageMetadata) override;