Show a patch.

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

{
    "id": 18429,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18429/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18429/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20230322130612.5208-3-naush@raspberrypi.com>",
    "date": "2023-03-22T13:06:04",
    "name": "[libcamera-devel,v1,02/10] ipa: raspberrypi: Add hardware configuration to the controller",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6204ebaad8e305b537475512c27153015b50f228",
    "submitter": {
        "id": 34,
        "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api",
        "name": "Naushir Patuck",
        "email": "naush@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18429/mbox/",
    "series": [
        {
            "id": 3810,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3810/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3810",
            "date": "2023-03-22T13:06:02",
            "name": "Raspberry Pi: Generalised algorithms",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3810/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18429/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18429/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 594F6C329C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Mar 2023 13:06:24 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A0B9E626E6;\n\tWed, 22 Mar 2023 14:06:23 +0100 (CET)",
            "from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com\n\t[IPv6:2607:f8b0:4864:20::d2e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 991FE61ECE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 14:06:20 +0100 (CET)",
            "by mail-io1-xd2e.google.com with SMTP id m22so8406911ioy.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 06:06:20 -0700 (PDT)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tl6-20020a026646000000b003c488204c6fsm4927960jaf.76.2023.03.22.06.06.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 22 Mar 2023 06:06:18 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679490383;\n\tbh=J1uasa5/tJAHTXqgL1/mM0u5Q3ArfZnJ87UFIogFh88=;\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=eB6wyYSwASaqkoh5yo+6u5o7Xy9uDevIoi+dvET34BGZre92BbZgrM2G9t3OTvPX9\n\t3QKhDKX7E2vPLKzuLoWuB7alIVT9l2Fh8Et0jLmf2qQMwOn/gKQXZE7SVn0vXevGtc\n\tOyJIGU5uSKC5Oq72EF1F0Ieb6kkzaFAvJPyLngCM5w5syxWQ79NT0oI7Efa6BQRBF/\n\tEhNTlP36RcQvRiG4igksdmcJsMfRSZXYwlWneKZcjq7APkdGaPB4d4/9LjgQMhMQEX\n\tVru2AAo+1KzXdz/vDaz4lTBlDWtBN8l/jFyZXUCvrO0PCPyYAOZXj4W8KJH0L130Xj\n\tVSlFCL31vwHAw==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1679490379;\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=xf8pOLOBSpsB8lB4jAOqwlWtCYuXLJMzQzDn0iSf5F4=;\n\tb=Gg35Co84B+VcmfBaHoNjKgzVITDHGRKcaHlvsNqQjIt6XSTov1FZmbDO2749Lj72ze\n\tj4mRbL8ikyHrlIxbHhaUkt83l46SaVOJVJWGQMx6VpiGbJxh6ANnIS0HQxW35d5ZAG/h\n\tLqk/Lo8cvH3IkAQeHfpgj0VJq8gQGaz/2RMYmbN1Nl1sy8mfsAFAo2xe9fb0Z74BAXhj\n\tfWA6jdki/1imqLQL4RE+uQDcH/hKjy4fD6cn7JKvsEBit/BOGvGU/f85v2/BNzfSdD3U\n\traTnOcBrNTD3WbGoT0SEtGgBH/HyqGq+UMuIcOnfEnd++CvLwLGkU+dm1mfv0TcQw8hs\n\tdRrw=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Gg35Co84\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1679490379;\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=xf8pOLOBSpsB8lB4jAOqwlWtCYuXLJMzQzDn0iSf5F4=;\n\tb=tabPjjIN9MXcwyljU8QUJ+j7kV09OvXtlSohrH+3DZpshIOBg7ux1FpBU5+ThhMj6q\n\tkjynq+mIf2coyLcRJk04FpZTZ0133ILxazUU3WHbd0RVTq4ixvcavZINTl324dBm1VX1\n\tU8PAVs0R0N9wsG8Kc7xe1kaL34vlFRu+jckRVVRSOciLLW5Pg9xOtbYjWxJlz0aiN9DR\n\t0JSkwG0AzkDsEeOXLcCP5o0gturTiXUgEMIcDov3LxLhdXtUBxNYsVJFGtI62Q78M99l\n\tXr9LC487PJ/LQnhIW9j4dEbhaIFW+3y8t5h2Y6m3/2JCedBjFVNdfcCPY7qrKdxq/d0a\n\tFMEA==",
        "X-Gm-Message-State": "AO0yUKXkpUfTuxhxKsV48iWIFo6dJTpW55h0pI8vCvPsFgvf23zdf9LM\n\t71Lf4l9nJZjSCNeEB+g5HCIkSQWodrZk8S/tAWhs/Q==",
        "X-Google-Smtp-Source": "AK7set/BYwWUWicJqbLAYhwHGgTtVwF9Ow62denmkmsP9LljcShdzMNlWsvUYTquF/jUdYeSj2ShJQ==",
        "X-Received": "by 2002:a05:6602:1616:b0:752:6f1b:63a2 with SMTP id\n\tx22-20020a056602161600b007526f1b63a2mr2043043iow.3.1679490378288; \n\tWed, 22 Mar 2023 06:06:18 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 22 Mar 2023 13:06:04 +0000",
        "Message-Id": "<20230322130612.5208-3-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230322130612.5208-1-naush@raspberrypi.com>",
        "References": "<20230322130612.5208-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v1 02/10] ipa: raspberrypi: Add hardware\n\tconfiguration to the controller",
        "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": "Add a new Controller::HardwareConfig structure that captures the\nhardware statistics grid/histogram sizes and pipeline widths. This\nensures there is a single centralised places for these parameters.\n\nAdd a getHardwareConfig() helper function to retrieve these values for a\ngiven hardware target.\n\nUpdate the statistics populating routine in the IPA to use the values\nfrom this structure instead of the hardcoded numbers.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/algorithm.h    |  4 ++\n src/ipa/raspberrypi/controller/controller.cpp | 39 +++++++++++++++++++\n src/ipa/raspberrypi/controller/controller.h   | 11 ++++++\n src/ipa/raspberrypi/raspberrypi.cpp           | 21 ++++------\n 4 files changed, 62 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/controller/algorithm.h b/src/ipa/raspberrypi/controller/algorithm.h\nindex 7c22fbe4945c..4aa814ebbebd 100644\n--- a/src/ipa/raspberrypi/controller/algorithm.h\n+++ b/src/ipa/raspberrypi/controller/algorithm.h\n@@ -45,6 +45,10 @@ public:\n \t{\n \t\treturn controller_->getTarget();\n \t}\n+\tconst Controller::HardwareConfig &getHardwareConfig() const\n+\t{\n+\t\treturn controller_->getHardwareConfig();\n+\t}\n \n private:\n \tController *controller_;\ndiff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp\nindex a6250ee140b0..2c7517aec6b4 100644\n--- a/src/ipa/raspberrypi/controller/controller.cpp\n+++ b/src/ipa/raspberrypi/controller/controller.cpp\n@@ -20,6 +20,31 @@ using namespace libcamera;\n \n LOG_DEFINE_CATEGORY(RPiController)\n \n+static const std::map<std::string, Controller::HardwareConfig> HardwareConfigMap = {\n+\t{\n+\t\t\"bcm2835\",\n+\t\t{\n+\t\t\t/*\n+\t\t\t * There are only ever 15 AGC regions computed by the firmware\n+\t\t\t * due to zoning, but the HW defines AGC_REGIONS == 16!\n+\t\t\t */\n+\t\t\t.agcRegions = { 15 , 1 },\n+\t\t\t.agcZoneWeights = { 15 , 1 },\n+\t\t\t.awbRegions = { 16, 12 },\n+\t\t\t.focusRegions = { 4, 3 },\n+\t\t\t.numHistogramBins = 128,\n+\t\t\t.numGammaPoints = 33,\n+\t\t\t.pipelineWidth = 13\n+\t\t}\n+\t},\n+\t/* For error handling. */\n+\t{\n+\t\t\"error\",\n+\t\t{\n+\t\t}\n+\t}\n+};\n+\n Controller::Controller()\n \t: switchModeCalled_(false)\n {\n@@ -148,3 +173,17 @@ const std::string &Controller::getTarget() const\n {\n \treturn target_;\n }\n+\n+const Controller::HardwareConfig &Controller::getHardwareConfig() const\n+{\n+\tauto cfg = HardwareConfigMap.find(getTarget());\n+\n+\t/*\n+\t * This really should not happen, the IPA ought to validate the target\n+\t * on initialisation.\n+\t */\n+\tif (cfg == HardwareConfigMap.end())\n+\t\treturn HardwareConfigMap.at(\"error\");\n+\n+\treturn cfg->second;\n+}\ndiff --git a/src/ipa/raspberrypi/controller/controller.h b/src/ipa/raspberrypi/controller/controller.h\nindex 24e02903d438..c6af5cd6c7d4 100644\n--- a/src/ipa/raspberrypi/controller/controller.h\n+++ b/src/ipa/raspberrypi/controller/controller.h\n@@ -37,6 +37,16 @@ typedef std::unique_ptr<Algorithm> AlgorithmPtr;\n class Controller\n {\n public:\n+\tstruct HardwareConfig {\n+\t\tlibcamera::Size agcRegions;\n+\t\tlibcamera::Size agcZoneWeights;\n+\t\tlibcamera::Size awbRegions;\n+\t\tlibcamera::Size focusRegions;\n+\t\tunsigned int numHistogramBins;\n+\t\tunsigned int numGammaPoints;\n+\t\tunsigned int pipelineWidth;\n+\t};\n+\n \tController();\n \t~Controller();\n \tint read(char const *filename);\n@@ -47,6 +57,7 @@ public:\n \tMetadata &getGlobalMetadata();\n \tAlgorithm *getAlgorithm(std::string const &name) const;\n \tconst std::string &getTarget() const;\n+\tconst HardwareConfig &getHardwareConfig() const;\n \n protected:\n \tint createAlgorithm(const std::string &name, const libcamera::YamlObject &params);\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 86359538cf67..b64cb96e2dde 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1392,20 +1392,19 @@ RPiController::StatisticsPtr IPARPi::fillStatistics(bcm2835_isp_stats *stats) co\n {\n \tusing namespace RPiController;\n \n+\tconst Controller::HardwareConfig &hw = controller_.getHardwareConfig();\n \tunsigned int i;\n \tStatisticsPtr statistics =\n \t\tstd::make_unique<Statistics>(Statistics::AgcStatsPos::PreWb, Statistics::ColourStatsPos::PostLsc);\n \n \t/* RGB histograms are not used, so do not populate them. */\n-\tstatistics->yHist = RPiController::Histogram(stats->hist[0].g_hist, NUM_HISTOGRAM_BINS);\n+\tstatistics->yHist = RPiController::Histogram(stats->hist[0].g_hist,\n+\t\t\t\t\t\t     hw.numHistogramBins);\n \n-\t/*\n-\t * All region sums are based on a 13-bit pipeline bit-depth. Normalise\n-\t * this to 16-bits for the AGC/AWB/ALSC algorithms.\n-\t */\n-\tconstexpr unsigned int scale = Statistics::NormalisationFactorPow2 - 13;\n+\t/* All region sums are based on a 16-bit normalised pipeline bit-depth. */\n+\tunsigned int scale = Statistics::NormalisationFactorPow2 - hw.pipelineWidth;\n \n-\tstatistics->awbRegions.init({ DEFAULT_AWB_REGIONS_X, DEFAULT_AWB_REGIONS_Y });\n+\tstatistics->awbRegions.init(hw.awbRegions);\n \tfor (i = 0; i < statistics->awbRegions.numRegions(); i++)\n \t\tstatistics->awbRegions.set(i, { { stats->awb_stats[i].r_sum << scale,\n \t\t\t\t\t\t  stats->awb_stats[i].g_sum << scale,\n@@ -1413,11 +1412,7 @@ RPiController::StatisticsPtr IPARPi::fillStatistics(bcm2835_isp_stats *stats) co\n \t\t\t\t\t\tstats->awb_stats[i].counted,\n \t\t\t\t\t\tstats->awb_stats[i].notcounted });\n \n-\t/*\n-\t * There are only ever 15 regions computed by the firmware due to zoning,\n-\t * but the HW defines AGC_REGIONS == 16!\n-\t */\n-\tstatistics->agcRegions.init(15);\n+\tstatistics->agcRegions.init(hw.agcRegions);\n \tfor (i = 0; i < statistics->agcRegions.numRegions(); i++)\n \t\tstatistics->agcRegions.set(i, { { stats->agc_stats[i].r_sum << scale,\n \t\t\t\t\t\t  stats->agc_stats[i].g_sum << scale,\n@@ -1425,7 +1420,7 @@ RPiController::StatisticsPtr IPARPi::fillStatistics(bcm2835_isp_stats *stats) co\n \t\t\t\t\t\tstats->agc_stats[i].counted,\n \t\t\t\t\t\tstats->awb_stats[i].notcounted });\n \n-\tstatistics->focusRegions.init({ 4, 3 });\n+\tstatistics->focusRegions.init(hw.focusRegions);\n \tfor (i = 0; i < statistics->focusRegions.numRegions(); i++)\n \t\tstatistics->focusRegions.set(i, { stats->focus_stats[i].contrast_val[1][1] / 1000,\n \t\t\t\t\t\t  stats->focus_stats[i].contrast_val_num[1][1],\n",
    "prefixes": [
        "libcamera-devel",
        "v1",
        "02/10"
    ]
}