Show a patch.

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

{
    "id": 18504,
    "url": "https://patchwork.libcamera.org/api/patches/18504/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18504/",
    "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": "<20230331072341.24851-9-naush@raspberrypi.com>",
    "date": "2023-03-31T07:23:39",
    "name": "[libcamera-devel,v3,08/10] ipa: raspberrypi: Generalise the agc algorithm",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "f936aef4b7099bcbcdffb48cbbcc0236d35ba0ef",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18504/mbox/",
    "series": [
        {
            "id": 3830,
            "url": "https://patchwork.libcamera.org/api/series/3830/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3830",
            "date": "2023-03-31T07:23:31",
            "name": "Raspberry Pi: Generalised algorithms",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/3830/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18504/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18504/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 3F1EBC329F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Mar 2023 07:41:01 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D425E6277E;\n\tFri, 31 Mar 2023 09:41:00 +0200 (CEST)",
            "from mail-io1-xd30.google.com (mail-io1-xd30.google.com\n\t[IPv6:2607:f8b0:4864:20::d30])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E0C66279C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 09:40:57 +0200 (CEST)",
            "by mail-io1-xd30.google.com with SMTP id x3so1879023iov.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 00:40:57 -0700 (PDT)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ti17-20020a6bf411000000b0074555814e73sm421943iog.32.2023.03.31.00.40.55\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 31 Mar 2023 00:40:55 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680248460;\n\tbh=zxN8L9BcQbJI34o+Lrtm03FoFSjDEr3NlDyqe82KZiA=;\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:Cc:\n\tFrom;\n\tb=d+dapaJMfZh7k5P9/Fhj+jY/DfwM7Vghid6eUlrnk167fl7PbGDiFDeHCOf+tu1+c\n\tcWMhgPfDNOVE/qxrda1MQwE+QJbVoi/z8QpU2O66mUit9iiv1ScW0m34s0DAUJojTk\n\tprub6DaeiyQQPihaiH7NaC6LowKjULzT/7UHkROO6lvhz/IrVT81Wml9Et7eDgx8AG\n\tbB20eVQf+otBjnry+ATCuCr7KDFLbUrF1cpMRRaCqXWBCO4Y0JFU32ekqVllnhlRMz\n\tZNQjq7i23wARCWRMPQoR4NSM1ORP7Dn2NgVPApu0yapbSvifauIr6guZWjUq/n18aQ\n\tCGiTvATS8K9SQ==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1680248456;\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=rrS46SBM06NUoF4wxPBdfbbZvRNbGZyJPXft+5T02xE=;\n\tb=RbeHncS/3pL4Xg6CPucUhgn/ZCNxWhXsFdcBTvDxsMkd6u9Nvzr+BthAKX7uEEsKe6\n\tObeP3AvM/+6fKoedkWu3R5N6R0ZH8oxKGr+6uZfW+bRgNF7HlWrjGqeDzT6w6zRg0BFO\n\ty+l9Gjp5dshk9cZgv/Y2A7f0Tp64AbluPzqmIOWq8n77gacCdgANZ+eTAtWnUUjxKXs+\n\t60IhIhZx0t0jc32vpTNVVCawmOpfenZ0Iwf9HLuJArjcDK7pDeVjBnTf9FQc8BoDm6Qn\n\tUxDZQjOj3DDYw0guIBEZMBfiz5HM+FSJxxIUkjNEVc7dNFHsgzwJtnXfRDMCWwYc9znu\n\t8PVA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"RbeHncS/\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1680248456;\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=rrS46SBM06NUoF4wxPBdfbbZvRNbGZyJPXft+5T02xE=;\n\tb=kbNX5OYxL4C7kkdEzrsWGKxZRMuwXrMl7yPTLCyfcW4wUI8wR3N6FTL9CevSgAdWEc\n\tv+tDvznlHHXPid4sNQmBPCj6hHXJM6t2En5J2p5fHw2aBPzlhrGg8r1D8DukpGuTZP4o\n\tL439wEdQ2jLwrYOcecYhXNQVMcZpkJRKxFXP8rRZRdMfHrEtHfUbbBcZ3QI7SlLuiDMl\n\tjDXhRY/J0qOmpg1KDwnw9W08Z4f1T0H4B+uOMQL/52CNYhC4qUEcVIq+KYU+W07vNnOl\n\tOnmI6qBVzeGhGT7UjD25ajbhlzXJEDj0VR1f6zI8p56JEXTszHw2v9yRwmm8ljFNTiZn\n\tgDMQ==",
        "X-Gm-Message-State": "AO0yUKW1sHv+hwkb06e+9eq4LeJZkk1h5QKNXwoYKxiCCHZJ2gv/hq1x\n\tru3kxAWUKmU8PaaeI3dricVwcVEB0kdIEtDdC6sleg==",
        "X-Google-Smtp-Source": "AK7set//g8Bwy9l51n1GAGQDDEjq4zIeOAFKiiy5pomWgHFjNONN/Ddtzt1Fj/CjxJ1V04Mtz3A+YQ==",
        "X-Received": "by 2002:a5e:8412:0:b0:758:a647:d21e with SMTP id\n\th18-20020a5e8412000000b00758a647d21emr17587818ioj.21.1680248456097; \n\tFri, 31 Mar 2023 00:40:56 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 31 Mar 2023 08:23:39 +0100",
        "Message-Id": "<20230331072341.24851-9-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230331072341.24851-1-naush@raspberrypi.com>",
        "References": "<20230331072341.24851-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 08/10] ipa: raspberrypi: Generalise the\n\tagc algorithm",
        "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>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Remove any hard-coded assumptions about the target hardware platform\nfrom the AGC algorithm. Instead, use the \"target\" string provided by\nthe camera tuning config and generalised statistics structures to\ndeterming parameters such as grid and region sizes.\n\nThis change replaces all hard-coded arrays with equivalent std::vector\ntypes.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 20 +++++++++++++-------\n src/ipa/raspberrypi/controller/rpi/agc.h   |  9 +--------\n 2 files changed, 14 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex f438cab8840a..e6fb7b8dbeb3 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -31,17 +31,12 @@ LOG_DEFINE_CATEGORY(RPiAgc)\n int AgcMeteringMode::read(const libcamera::YamlObject &params)\n {\n \tconst YamlObject &yamlWeights = params[\"weights\"];\n-\tif (yamlWeights.size() != AgcStatsSize) {\n-\t\tLOG(RPiAgc, Error) << \"AgcMeteringMode: Incorrect number of weights\";\n-\t\treturn -EINVAL;\n-\t}\n \n-\tunsigned int num = 0;\n \tfor (const auto &p : yamlWeights.asList()) {\n \t\tauto value = p.get<double>();\n \t\tif (!value)\n \t\t\treturn -EINVAL;\n-\t\tweights[num++] = *value;\n+\t\tweights.push_back(*value);\n \t}\n \n \treturn 0;\n@@ -248,6 +243,14 @@ int Agc::read(const libcamera::YamlObject &params)\n \tif (ret)\n \t\treturn ret;\n \n+\tconst Size &size = getHardwareConfig().agcZoneWeights;\n+\tfor (auto const &modes : config_.meteringModes) {\n+\t\tif (modes.second.weights.size() != size.width * size.height) {\n+\t\t\tLOG(RPiAgc, Error) << \"AgcMeteringMode: Incorrect number of weights\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n \t/*\n \t * Set the config's defaults (which are the first ones it read) as our\n \t * current modes, until someone changes them.  (they're all known to\n@@ -585,9 +588,12 @@ void Agc::fetchAwbStatus(Metadata *imageMetadata)\n }\n \n static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,\n-\t\t\t      double weights[], double gain)\n+\t\t\t      std::vector<double> &weights, double gain)\n {\n \tconstexpr uint64_t maxVal = 1 << Statistics::NormalisationFactorPow2;\n+\n+\tASSERT(weights.size() == stats->agcRegions.numRegions());\n+\n \t/*\n \t * Note how the calculation below means that equal weights give you\n \t * \"average\" metering (i.e. all pixels equally important).\ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.h b/src/ipa/raspberrypi/controller/rpi/agc.h\nindex 4fa9b8de5fb2..4e5f272fac78 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.h\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.h\n@@ -17,17 +17,10 @@\n \n /* This is our implementation of AGC. */\n \n-/*\n- * This is the number actually set up by the firmware, not the maximum possible\n- * number (which is 16).\n- */\n-\n-constexpr unsigned int AgcStatsSize = 15;\n-\n namespace RPiController {\n \n struct AgcMeteringMode {\n-\tdouble weights[AgcStatsSize];\n+\tstd::vector<double> weights;\n \tint read(const libcamera::YamlObject &params);\n };\n \n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "08/10"
    ]
}