{"id":18954,"url":"https://patchwork.libcamera.org/api/1.1/patches/18954/?format=json","web_url":"https://patchwork.libcamera.org/patch/18954/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20230823120915.18621-5-david.plowman@raspberrypi.com>","date":"2023-08-23T12:09:14","name":"[libcamera-devel,v2,4/5] ipa: rpi: agc: Add AgcChannelConstraint class","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"8a7351b8a2ff994308381c8b28a82facc53e635f","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18954/mbox/","series":[{"id":4006,"url":"https://patchwork.libcamera.org/api/1.1/series/4006/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4006","date":"2023-08-23T12:09:10","name":"Multi-channel AGC","version":2,"mbox":"https://patchwork.libcamera.org/series/4006/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18954/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18954/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 460E2C32B0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Aug 2023 12:09:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2F13628D7;\n\tWed, 23 Aug 2023 14:09:27 +0200 (CEST)","from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C117628BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Aug 2023 14:09:22 +0200 (CEST)","by mail-wm1-x32e.google.com with SMTP id\n\t5b1f17b1804b1-3fee600dce6so38332225e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Aug 2023 05:09:22 -0700 (PDT)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:2bce:64d6:1a5c:49a2])\n\tby smtp.gmail.com with ESMTPSA id\n\tu1-20020a7bcb01000000b003fefcbe7fa8sm3800589wmj.28.2023.08.23.05.09.21\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 23 Aug 2023 05:09:21 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1692792567;\n\tbh=Lc9MIYLNUxJ6O1kelx5tO983QpzUCyKjYL6vadoy/5E=;\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=AGZdAoqH0VLPOHSsMcyvLhecSgtTzZmNVLcnlBtjVGSkjIc1p60LsAs3xI4la4o7H\n\t5aKl/H2dTjUqICFDjuI+KDR+6UYu3Nm1m6bX4eZvf6L+YSii/Dzv5eGy9nGD6wblwk\n\tuaMcR3iJlFBIWjgGv+alQnwqqSzcutp8ZaJpKwOt0HVazRGHq/Ngq0pPhH7BAXc1v9\n\tz4HQF63LLNuCHGzuJIQNKiBCxf3ximH0HFZ6TqgL8njAfnedj5GSqWWHe75OBvVzSo\n\tbX2DPucLVhMBmnE6os6DhTADREaARLbXHPofWLmRcYkBZeX6SK8wRJOH5iZUgnF1/d\n\t7AA9QDgzX4SiA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1692792561; x=1693397361;\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=xyBn1rMtUAm//vTeerXmljtU3iKqtQ+pSllh1EOmZ2o=;\n\tb=FOFPcw8Ra64347zqg/CJcPx0WYVxVL8t0ejQKbI4ZiEHsVeXm8Bb8qTtNHaRkDTzKp\n\taqV3bpVTN8vdXDKskr3gZztoqUU0htrrYxi5sddx0Tzi6imaSzfMpjUB1k1KVD3hqYDi\n\t5sCTAl8QJG3rPrLgufrMs9XZfIY3higXIYu7vHiSpGcSa87xFS0r2xiZSW+U73fteQIV\n\tJG0zsD8QJXc7UXL47LmkZB/L1OW3y/HFWGtqU11+hClOL0BgHgF8ibki5cBCEY/ZMyH9\n\t8taI6TNdbce6tsSYaYssAIIUzMGFDcfGsClbws9nQNTzQxLZ04hmAnBRn5H2gK8DgMSY\n\tpPog=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"FOFPcw8R\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1692792561; x=1693397361;\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=xyBn1rMtUAm//vTeerXmljtU3iKqtQ+pSllh1EOmZ2o=;\n\tb=VmHLDKy/6lDpcWt5RMkL+ZZLNG7ghq8NfN31QgqGcgngqk4DgDj33cVlwpWoAhxSA5\n\tSTb+DT5RKzy0FizTvTNu1ld4dy9LvNL/X7n1W9eMqIoyC6I15SD/BHERXZ44EZqUEICT\n\t14LtwT4rDGf0OmNIZhh5s2Wm/UTFffjyfwLGH+2U5rD3hdYG4//DgdmCF8+rMeBhYxSF\n\tWf6ZyNq88aMaYXbRw1WiAFtFR15ZTCE0Scsi+dfjrTgGSGZorcbA632336BzDxIQYIxd\n\tiSaCZfhKRn/lN19R1JNTG63mm0kX4qs9pPmeeu3TBVPchZMYJKn+Dg0dZC2j+a3l5Z35\n\tXMiA==","X-Gm-Message-State":"AOJu0YxT4Ww5JXCY4lO7gSCMZ7RhdPhree17p2501s1vy5HSe76J6wn7\n\tHh2IkcGw19/PyeqTrSq/Uv762ah7QhTpdN8Pjy8=","X-Google-Smtp-Source":"AGHT+IFrtV+SioMcMbZg3NV6/+eo23ep26RPMFPnOea9T+eh+XrlpXlyAGKoQkpvQ8YrLDzrs8du3Q==","X-Received":"by 2002:a05:600c:204b:b0:3fb:b3aa:1c8f with SMTP id\n\tp11-20020a05600c204b00b003fbb3aa1c8fmr10157557wmg.28.1692792561596; \n\tWed, 23 Aug 2023 05:09:21 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 23 Aug 2023 13:09:14 +0100","Message-Id":"<20230823120915.18621-5-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.30.2","In-Reply-To":"<20230823120915.18621-1-david.plowman@raspberrypi.com>","References":"<20230823120915.18621-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 4/5] ipa: rpi: agc: Add\n\tAgcChannelConstraint class","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":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"A channel constraint is somewhat similar to the upper/lower bound\nconstraints that we use elsewhere, but these constraints apply between\nmultiple AGC channels. For example, it lets you say things like \"don't\nlet the channel 1 total exposure be more than 8x that of channel 0\",\nand so on. By using both an upper and lower bound constraint, you\ncould fix one AGC channel always to be a fixed ratio of another.\n\nAlso read a vector of them (if present) when loading the tuning file.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/agc_channel.cpp | 42 ++++++++++++++++++++++\n src/ipa/rpi/controller/rpi/agc_channel.h   | 10 ++++++\n 2 files changed, 52 insertions(+)","diff":"diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\nindex ddec611f..44198c2c 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n@@ -173,6 +173,42 @@ readConstraintModes(std::map<std::string, AgcConstraintMode> &constraintModes,\n \treturn { 0, first };\n }\n \n+int AgcChannelConstraint::read(const libcamera::YamlObject &params)\n+{\n+\tstd::string boundString = params[\"bound\"].get<std::string>(\"\");\n+\ttransform(boundString.begin(), boundString.end(),\n+\t\t  boundString.begin(), ::toupper);\n+\tif (boundString != \"UPPER\" && boundString != \"LOWER\") {\n+\t\tLOG(RPiAgc, Error) << \"AGC channelconstraint type should be UPPER or LOWER\";\n+\t\treturn -EINVAL;\n+\t}\n+\tbound = boundString == \"UPPER\" ? Bound::UPPER : Bound::LOWER;\n+\n+\tauto value = params[\"factor\"].get<double>();\n+\tif (!value)\n+\t\treturn -EINVAL;\n+\tfactor = *value;\n+\n+\treturn 0;\n+}\n+\n+static int readChannelConstraints(std::vector<AgcChannelConstraint> &channelConstraints,\n+\t\t\t\t  const libcamera::YamlObject &params)\n+{\n+\tint ret = 0;\n+\n+\tfor (const auto &p : params.asList()) {\n+\t\tAgcChannelConstraint constraint;\n+\t\tret = constraint.read(p);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tchannelConstraints.push_back(constraint);\n+\t}\n+\n+\treturn ret;\n+}\n+\n int AgcConfig::read(const libcamera::YamlObject &params)\n {\n \tLOG(RPiAgc, Debug) << \"AgcConfig\";\n@@ -191,6 +227,12 @@ int AgcConfig::read(const libcamera::YamlObject &params)\n \tif (ret)\n \t\treturn ret;\n \n+\tif (params.contains(\"channel_constraints\")) {\n+\t\tret = readChannelConstraints(channelConstraints, params[\"channel_constraints\"]);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n \tret = yTarget.read(params[\"y_target\"]);\n \tif (ret)\n \t\treturn ret;\ndiff --git a/src/ipa/rpi/controller/rpi/agc_channel.h b/src/ipa/rpi/controller/rpi/agc_channel.h\nindex 0e3d44b0..446125ef 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.h\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.h\n@@ -42,11 +42,21 @@ struct AgcConstraint {\n \n typedef std::vector<AgcConstraint> AgcConstraintMode;\n \n+struct AgcChannelConstraint {\n+\tenum class Bound { LOWER = 0,\n+\t\t\t   UPPER = 1 };\n+\tBound bound;\n+\tunsigned int channel;\n+\tdouble factor;\n+\tint read(const libcamera::YamlObject &params);\n+};\n+\n struct AgcConfig {\n \tint read(const libcamera::YamlObject &params);\n \tstd::map<std::string, AgcMeteringMode> meteringModes;\n \tstd::map<std::string, AgcExposureMode> exposureModes;\n \tstd::map<std::string, AgcConstraintMode> constraintModes;\n+\tstd::vector<AgcChannelConstraint> channelConstraints;\n \tPwl yTarget;\n \tdouble speed;\n \tuint16_t startupFrames;\n","prefixes":["libcamera-devel","v2","4/5"]}