{"id":18439,"url":"https://patchwork.libcamera.org/api/patches/18439/?format=json","web_url":"https://patchwork.libcamera.org/patch/18439/","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":"<20230322161317.18055-2-naush@raspberrypi.com>","date":"2023-03-22T16:13:15","name":"[libcamera-devel,v1,1/3] ipa: raspberrypi: Replace setMaxShutter with setSensorLimits in AGC","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"678975a81e9b01f0fef6f39729773990160193d9","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/18439/mbox/","series":[{"id":3811,"url":"https://patchwork.libcamera.org/api/series/3811/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3811","date":"2023-03-22T16:13:14","name":"Raspberry Pi: Sensor limits","version":1,"mbox":"https://patchwork.libcamera.org/series/3811/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18439/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18439/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 A1D66C3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Mar 2023 16:13:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 403C262713;\n\tWed, 22 Mar 2023 17:13:16 +0100 (CET)","from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com\n\t[IPv6:2607:f8b0:4864:20::d2a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 97CE261ECE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 17:13:13 +0100 (CET)","by mail-io1-xd2a.google.com with SMTP id s4so8682061ioj.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 09:13:13 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tn24-20020a02a918000000b004050d92f6d4sm5100119jam.50.2023.03.22.09.13.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 22 Mar 2023 09:13:11 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679501596;\n\tbh=Q9nYWYgXbYyKB9xNapmUD/AEc/dU8XmqqZPszshPCeg=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=XVhubd1js9UZY4zwsrLIOpq9r7XP1Fu3VSYSQiSgn4qRVwMDGJnxEu8n5pHm4jC7t\n\t6KNy1xchazo6FBtL6HoPH6/sgPea8XY1pqHqd/DdNeJN9HKs1+IGOBwCCxdTBtb57e\n\tkpZUXzkf17E/O8Idqh9GijqgcdRXxSD9G3secN5BrykfM2+lN4CurhmxKq9BtqkvfX\n\t/Cd7e002KHRtoZYl1zJxaZH6HwMhSIq5m0sQez0xCI9vw/kcERilJK+IKOKyO3RZiz\n\tfmL9ZqMdbDdMIyNiOyvuAFLB9X8L54NL/Xt4b79iyFRT/Wb74FQ5pD+UOP7YKToOyF\n\tmxGqZ/7Sj2Hug==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1679501592;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=Ldq/Rlt6NYA7xymrGzIpw8UgcgCXe3O7zbO3IBqcui4=;\n\tb=Pl+TGrxdt1F/3BwDdyMkcz6/yZ4I9vRfb+Fgvac1sho1BaoXA+ZLl3+khEzqTJ2s5l\n\tG8s4XYM0jwa2dCn3/dL/I7OQlgPpUMGJuvoLS5ExrcLXVS4Vj8PrQVpupVhuWanczX4V\n\tk7cJkuUY4DNrSyERteLxrCE4b/jisWhSrhy82JUxEqRES8ZanJZntSZiuFL6B4hcGB4C\n\twA9AorsURSmLy1gBc+xJCmoBgPLEfZDQhkNCN9KieikAJ3//bfUbRtn/qO6EvY6Da2fy\n\tMw1EmKIo3d8Acr1TP143xU/3MZe0lmmIpzt77O5nKzSOd7X4rFsaKjuYjlTzX/tn/7NF\n\t+evg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Pl+TGrxd\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1679501592;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=Ldq/Rlt6NYA7xymrGzIpw8UgcgCXe3O7zbO3IBqcui4=;\n\tb=StloSyRVZ2MIvXpsp1TQslocDG0r8/rAaExGYskvZoz3czFz63nEkRYq6N8K5Xfjjc\n\tdGKHP8zE6swsSbZ6N9P+PCd/+1uAOWznsWe78QfzAOD72EpfAWmT7AqfxhhHSmNHKVxL\n\tKgD/UMSklBrd+QE8LIz2lwcvvgfPHr/nvUnC3Et3J3Kh7Vf0GECYPMCE8o8cWVaU661t\n\torRWD8UnCXduJFHWNAA56//iGLPnyzi6odD+0uXfllgCIuX6O8HXT54SDc196qRSvQ7n\n\trjj8d56e3pA2p2QO2YHbvJTbJ/it2eQwZAX8Rm5i+Ue1w5iABgv9guuERelu4VNSPpyc\n\tzm+w==","X-Gm-Message-State":"AO0yUKXVU2iXUOc9HKbkO9EdeOBTlAfJlIgcRt7+ux5adwGLDl6nIUmj\n\tbtVVCXYRfm7zAO8EMcsxXlvVaD19nleXNw+AmKR+Rg==","X-Google-Smtp-Source":"AK7set8B97V0PepPp/7ZdBpSQEwoBJZ7f6aDuc+dsXZoMwleLerxgtJBereC9qOwQXbPPpW57XFlPA==","X-Received":"by 2002:a6b:4f0b:0:b0:752:e9e5:49af with SMTP id\n\td11-20020a6b4f0b000000b00752e9e549afmr5058931iob.2.1679501591975; \n\tWed, 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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 1/3] ipa: raspberrypi: Replace\n\tsetMaxShutter with setSensorLimits in AGC","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Create a SensorLimits structure in the AgcAlgorithm class. The maximum\nshutter time is stored in this structure from the IPA. In a subsequent\ncommit, all gain and shutter limits will additionally be stored.\n\nPass the SensorLimits structure with the maximum shutter time into the\nAGC algorithm through the new setSensorLimits() member function,\nreplacing the call to setMaxShutter().\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/agc_algorithm.h | 11 ++++++++++-\n src/ipa/raspberrypi/controller/rpi/agc.cpp     | 10 +++++-----\n src/ipa/raspberrypi/controller/rpi/agc.h       |  4 ++--\n src/ipa/raspberrypi/raspberrypi.cpp            |  7 ++++---\n 4 files changed, 21 insertions(+), 11 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.h b/src/ipa/raspberrypi/controller/agc_algorithm.h\nindex 36e6c11058ee..c2759689c7f9 100644\n--- a/src/ipa/raspberrypi/controller/agc_algorithm.h\n+++ b/src/ipa/raspberrypi/controller/agc_algorithm.h\n@@ -15,13 +15,22 @@ namespace RPiController {\n class AgcAlgorithm : public Algorithm\n {\n public:\n+\tstruct SensorLimits {\n+\t\tlibcamera::utils::Duration minShutter;\n+\t\tlibcamera::utils::Duration maxShutter;\n+\t\tlibcamera::utils::Duration minFrameDuration;\n+\t\tlibcamera::utils::Duration maxFrameDuration;\n+\t\tdouble minAnalogueGain;\n+\t\tdouble maxAnalogueGain;\n+\t};\n+\n \tAgcAlgorithm(Controller *controller) : Algorithm(controller) {}\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(libcamera::utils::Duration flickerPeriod) = 0;\n \tvirtual void setFixedShutter(libcamera::utils::Duration fixedShutter) = 0;\n-\tvirtual void setMaxShutter(libcamera::utils::Duration maxShutter) = 0;\n+\tvirtual void setSensorLimits(const SensorLimits &limits) = 0;\n \tvirtual void setFixedAnalogueGain(double fixedAnalogueGain) = 0;\n \tvirtual void setMeteringMode(std::string const &meteringModeName) = 0;\n \tvirtual void setExposureMode(std::string const &exposureModeName) = 0;\ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex 4ea0dd41e66c..eaabc5fa9cd0 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -225,7 +225,7 @@ Agc::Agc(Controller *controller)\n \t  frameCount_(0), lockCount_(0),\n \t  lastTargetExposure_(0s), lastSensitivity_(0.0),\n \t  ev_(1.0), flickerPeriod_(0s),\n-\t  maxShutter_(0s), fixedShutter_(0s), fixedAnalogueGain_(0.0)\n+\t  fixedShutter_(0s), fixedAnalogueGain_(0.0)\n {\n \tmemset(&awb_, 0, sizeof(awb_));\n \t/*\n@@ -300,9 +300,9 @@ void Agc::setFlickerPeriod(Duration flickerPeriod)\n \tflickerPeriod_ = flickerPeriod;\n }\n \n-void Agc::setMaxShutter(Duration maxShutter)\n+void Agc::setSensorLimits(const SensorLimits &limits)\n {\n-\tmaxShutter_ = maxShutter;\n+\tsensorLimits_ = limits;\n }\n \n void Agc::setFixedShutter(Duration fixedShutter)\n@@ -874,8 +874,8 @@ void Agc::writeAndFinish(Metadata *imageMetadata, bool desaturate)\n \n Duration Agc::clipShutter(Duration shutter)\n {\n-\tif (maxShutter_)\n-\t\tshutter = std::min(shutter, maxShutter_);\n+\tif (sensorLimits_.maxShutter)\n+\t\tshutter = std::min(shutter, sensorLimits_.maxShutter);\n \treturn shutter;\n }\n \ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.h b/src/ipa/raspberrypi/controller/rpi/agc.h\nindex f04896ca25ad..150a5f6e4428 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.h\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.h\n@@ -78,7 +78,7 @@ public:\n \tunsigned int getConvergenceFrames() const override;\n \tvoid setEv(double ev) override;\n \tvoid setFlickerPeriod(libcamera::utils::Duration flickerPeriod) override;\n-\tvoid setMaxShutter(libcamera::utils::Duration maxShutter) override;\n+\tvoid setSensorLimits(const SensorLimits &limits) override;\n \tvoid setFixedShutter(libcamera::utils::Duration fixedShutter) override;\n \tvoid setFixedAnalogueGain(double fixedAnalogueGain) override;\n \tvoid setMeteringMode(std::string const &meteringModeName) override;\n@@ -131,7 +131,7 @@ private:\n \tstd::string constraintModeName_;\n \tdouble ev_;\n \tlibcamera::utils::Duration flickerPeriod_;\n-\tlibcamera::utils::Duration maxShutter_;\n+\tSensorLimits sensorLimits_;\n \tlibcamera::utils::Duration fixedShutter_;\n \tdouble fixedAnalogueGain_;\n };\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 1375795568e2..c3b2c375036f 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1505,12 +1505,13 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur\n \t * getBlanking() will update maxShutter with the largest exposure\n \t * value possible.\n \t */\n-\tDuration maxShutter = Duration::max();\n-\thelper_->getBlanking(maxShutter, minFrameDuration_, maxFrameDuration_);\n+\tRPiController::AgcAlgorithm::SensorLimits limits;\n+\tlimits.maxShutter = Duration::max();\n+\thelper_->getBlanking(limits.maxShutter, minFrameDuration_, maxFrameDuration_);\n \n \tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n \t\tcontroller_.getAlgorithm(\"agc\"));\n-\tagc->setMaxShutter(maxShutter);\n+\tagc->setSensorLimits(limits);\n }\n \n void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n","prefixes":["libcamera-devel","v1","1/3"]}