Show a patch.

GET /api/patches/18993/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 18993,
    "url": "https://patchwork.libcamera.org/api/patches/18993/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18993/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20230912102442.169001-5-david.plowman@raspberrypi.com>",
    "date": "2023-09-12T10:24:41",
    "name": "[libcamera-devel,v3,4/5] ipa: rpi: agc: Add AgcChannelConstraint class",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e2ff1544b98cf0431a1c8b8000e8d00e3ea5debd",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18993/mbox/",
    "series": [
        {
            "id": 4017,
            "url": "https://patchwork.libcamera.org/api/series/4017/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4017",
            "date": "2023-09-12T10:24:37",
            "name": "Multi-channel AGC",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4017/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18993/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18993/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 2173CC32B2\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 12 Sep 2023 10:24:56 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D09A628F8;\n\tTue, 12 Sep 2023 12:24:55 +0200 (CEST)",
            "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AEF7061DEF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Sep 2023 12:24:52 +0200 (CEST)",
            "by mail-wm1-x32a.google.com with SMTP id\n\t5b1f17b1804b1-401d67434daso58373145e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Sep 2023 03:24:52 -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\tn10-20020a05600c294a00b003fefaf299b6sm12426575wmd.38.2023.09.12.03.24.51\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 12 Sep 2023 03:24:51 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1694514295;\n\tbh=ssOxDy1COKONYMwOqGbhPP9i46GebBKZrY7TAZsl72I=;\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=FXjF8Ua+CgdWWwFistzDVBNW/vFqW2HnGVqBCFVcql5QM79U/sbw8AGT+e3DZNJWw\n\tRD+wwo2YxsWc+ahjkWRpNpIZUzlOwko2TjF+jLnKbjUlxek1D2gyOipfT7Nb2jnWVe\n\tJThM7sfaHP4Dy8OfmOjvJTOSFNHPpPLKNBrT8u5duZ/YpzJhAbsBX5qf8WiSFAsaYT\n\tgQcF5Kt7KsU9yIQfiObeFrqnun5CI6O8zKIXW7Yp+v5GGDAieTMrMjGSTtqwIaZ1n+\n\t+Nyx4ZvwGFoQSgpJr2SxjLoC8Mb+upvl8HUoCZLtAZPKlFWt2bEzswQpb0GFuJVSMv\n\t3c+4xHBMBsUMg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1694514292; x=1695119092;\n\tdarn=lists.libcamera.org; \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=Fh/H/WqAaCgcyXj/u7SH9bguu1ZXy8aCpSWRL27uAKg=;\n\tb=B4rxI1Bz5L3JViZPqfvgz965nMDN7/0U7jaRC3jXxrC0AGF5omx35Fa4JUf6+tBDjz\n\tr1lZbmyvm8cmZl9hb0yGT2JD7H5u+7CGO0pDwV+/1hN6hDxhorcnhRHgBS9wYncOTxUP\n\tQpLuzot7/0xWSxrUCluMjcC3QXXe0Wh4a1shI2DI1DoQIgCFxcdmDPnXZ7hYJdD/dCvd\n\tPnL5krYXoxIIcPogb4OG11u171w2Ne4fJmvyD/Ffc2KEoWbSLGg1+Mknfzy4YHWyqp65\n\tU32YCvJD7aa4BZ+VR11wxNr4W5vVZEvkiteNShfrDJnKIHJkv05PlxxxTlUhJKYnfUfc\n\tBSQQ=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"B4rxI1Bz\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1694514292; x=1695119092;\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=Fh/H/WqAaCgcyXj/u7SH9bguu1ZXy8aCpSWRL27uAKg=;\n\tb=NHjVbpVGiuISAtkqUFhbKjMNw9KJJFSP6MIHjgy3phkY6mGhLoBJ3vGX2l2n3w7AWh\n\tdzqEWllr+M+PQABF+V9sQB/5ZkWDCj2g+ioRf8NdCBHhvFB+gqeF+W/G4IXg+J/FExOL\n\t8CMDA2jVx+HO8cezxaekW3BabNGdE5oOycrKMz2Aw4TXyYv7YxK2perUbyK4kjvzWMa5\n\tn4M5zEYsH1B0ONtKZ8VjPfOpElVwESGFSzKN5/odwRfTI/C6QBtZrx2PWIyAiRQSP+11\n\tUyqzwODbFWujFQAAefqrxcNwxligvJGXUUZahsjIA6di/JgiQvq5AqO3XrEX7maTZfVi\n\tTRdQ==",
        "X-Gm-Message-State": "AOJu0Yzm4ESNCLyZgJoLEIIQP2+mvOTO2VQu8vNdGS5PIdADO7p3L5Ux\n\txx/v9mfVoK/SPqBqsLSFtMlutfg2NuuCcWaW4nw=",
        "X-Google-Smtp-Source": "AGHT+IE3C7MuiQUY3uC3tn/cxxzzgWF50UMuAfrf7wDIqmQZf5pJYv3IUIZlqdRciPgiy1SnwMrVZA==",
        "X-Received": "by 2002:a05:600c:ad3:b0:401:bcd9:4871 with SMTP id\n\tc19-20020a05600c0ad300b00401bcd94871mr11019630wmr.21.1694514292006; \n\tTue, 12 Sep 2023 03:24:52 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 12 Sep 2023 11:24:41 +0100",
        "Message-Id": "<20230912102442.169001-5-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20230912102442.169001-1-david.plowman@raspberrypi.com>",
        "References": "<20230912102442.169001-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 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 | 49 ++++++++++++++++++++++\n src/ipa/rpi/controller/rpi/agc_channel.h   | 10 +++++\n 2 files changed, 59 insertions(+)",
    "diff": "diff --git a/src/ipa/rpi/controller/rpi/agc_channel.cpp b/src/ipa/rpi/controller/rpi/agc_channel.cpp\nindex f1f19598..7fce35b0 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.cpp\n@@ -170,6 +170,49 @@ readConstraintModes(std::map<std::string, AgcConstraintMode> &constraintModes,\n \treturn { 0, first };\n }\n \n+int AgcChannelConstraint::read(const libcamera::YamlObject &params)\n+{\n+\tauto channelValue = params[\"channel\"].get<unsigned int>();\n+\tif (!channelValue) {\n+\t\tLOG(RPiAgc, Error) << \"AGC channel constraint must have a channel\";\n+\t\treturn -EINVAL;\n+\t}\n+\tchannel = *channelValue;\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 channel constraint type should be UPPER or LOWER\";\n+\t\treturn -EINVAL;\n+\t}\n+\tbound = boundString == \"UPPER\" ? Bound::UPPER : Bound::LOWER;\n+\n+\tauto factorValue = params[\"factor\"].get<double>();\n+\tif (!factorValue) {\n+\t\tLOG(RPiAgc, Error) << \"AGC channel constraint must have a factor\";\n+\t\treturn -EINVAL;\n+\t}\n+\tfactor = *factorValue;\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+\tfor (const auto &p : params.asList()) {\n+\t\tAgcChannelConstraint constraint;\n+\t\tint ret = constraint.read(p);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tchannelConstraints.push_back(constraint);\n+\t}\n+\n+\treturn 0;\n+}\n+\n int AgcConfig::read(const libcamera::YamlObject &params)\n {\n \tLOG(RPiAgc, Debug) << \"AgcConfig\";\n@@ -188,6 +231,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 24ee3491..5d2d8a11 100644\n--- a/src/ipa/rpi/controller/rpi/agc_channel.h\n+++ b/src/ipa/rpi/controller/rpi/agc_channel.h\n@@ -44,11 +44,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",
        "v3",
        "4/5"
    ]
}