Patch Detail
Show a patch.
GET /api/patches/18498/?format=api
{ "id": 18498, "url": "https://patchwork.libcamera.org/api/patches/18498/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18498/", "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-3-naush@raspberrypi.com>", "date": "2023-03-31T07:23:33", "name": "[libcamera-devel,v3,02/10] ipa: raspberrypi: Add hardware configuration to the controller", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "befe13d32c3bf5c74eb6d2e41193af6a2715c6c1", "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/18498/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/18498/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18498/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 58619C329D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 31 Mar 2023 07:40:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AE47962759;\n\tFri, 31 Mar 2023 09:40:51 +0200 (CEST)", "from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com\n\t[IPv6:2607:f8b0:4864:20::d2c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C62AA62754\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 09:40:49 +0200 (CEST)", "by mail-io1-xd2c.google.com with SMTP id h187so7668253iof.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 31 Mar 2023 00:40:49 -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.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 31 Mar 2023 00:40:48 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1680248451;\n\tbh=eJv12V6KwFXPTSxr4TloZ2Rl1o7jM2rYSgPYX4ktmR0=;\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=TcLbVGnIh5OmzjXkNeDT+FSL6vWM3dY3XeeppGVhuFcnUx1QDQwRZyLLy6t7QCC/+\n\ts5b7xiRcBznYo16jgFMy4yV29nqm+emEF6UJbKvqolWrhDd0saG+OKdZBfP7tIct3K\n\tAuoE8+v0+Ot1/FhWmNpScs8YLN7LcVN0ZrBb+oESzuh9q9YDHp3HtFFbQLkuAf6t4+\n\tE4hfPpgQM/Ur/jmnkq0hW8FyIlvoO63U+sJGEnJiCJ2VRGpUTZAkOEzAM2Rj0Lmsde\n\tENbJwRmkDTLygHKXzwKKS3V5HrTH5DtzPVhZDeBJVrYpsWHvr9FFeJ9KePfxIFY2io\n\t5Z+IQZ3LO3ffg==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1680248448;\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=WfsHCbIkbpjQForzTwd4q36w5B1LLe0FLiY7FZyGvyo=;\n\tb=nfsDN1tqHVHyVmLTZVaTJjQtwoWtURIIRg6L6iQVoRQ3VsIBXrB2OtfuFlxrPm3rdw\n\tBe81alWGQVfKRSKaFVDZGEPnYAZxAnBPutSS3vVUG5BWxAcqSLUfL13rhzqSo8nP/g11\n\tIzj48Yh3jhJn/GMBO9OyzjzlomRQ9nTw9/HDI8c2fKy9w+6D9Cm/Qg0F4MYSqEpaca37\n\tvAN92BZm9j0a2U+vTTKohcmIDNIkRIPVyt/K9QxH/h3DlszRPGI+YHDX8I7PA5zwUEZs\n\tim3d7ysCDt8jrvvt++G3ePYRpjSpDQ3DT5o512SD/fYhnVBz9eVsmTctqUOdmoHyc04l\n\t2RXw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"nfsDN1tq\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1680248448;\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=WfsHCbIkbpjQForzTwd4q36w5B1LLe0FLiY7FZyGvyo=;\n\tb=VObWhrYjaIRJSCOahIimFSWw4d8iOIxlc2xjqclCtfCpIAW0HBpl1HD5TyaaHXBM8L\n\tPBvegV3ARKSxWcrxWJqMVrJ1absxecjLNPc7d6I1v9ZW2JFG4VG8ydC8hDj8ftxrmPfY\n\t+lNFMFNE40cKduXY+7GvOrnWkB9mg/km88k+maG62Kx9jWtQekHzFhElASSt//Fus5PF\n\tiV/wms23zTL1ifxctxpSvCx4rCqVkWKUsfzfB6qDquFuelikJv9eXNC4elaovC/GbPj/\n\tHb7CWc8gSlwdNLdqks/EQyroK+WFW/aQMcsfZj0Jr17r+jUoBslhdZMkbFIMuSNn0++M\n\tREgw==", "X-Gm-Message-State": "AO0yUKXNx8BRvQ4G5ohwylBuk2D5K6btl48Yfj3TdqiunmXJek4oKOBX\n\to1ejT08twWvZC2kZafL2Z89S661S0FIeF0bRho98rw==", "X-Google-Smtp-Source": "AK7set99C4JBGL/5dwIPE4XNdh+R7u5RGbmWx1p5KJbAq62b/aBjNamxB1Rgr4gBRJdM+uv8sO/qZQ==", "X-Received": "by 2002:a5e:d612:0:b0:753:121f:72a7 with SMTP id\n\tw18-20020a5ed612000000b00753121f72a7mr20020518iom.8.1680248448340; \n\tFri, 31 Mar 2023 00:40:48 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 31 Mar 2023 08:23:33 +0100", "Message-Id": "<20230331072341.24851-3-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 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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/raspberrypi/controller/algorithm.h | 4 +++\n src/ipa/raspberrypi/controller/controller.cpp | 31 +++++++++++++++++++\n src/ipa/raspberrypi/controller/controller.h | 11 +++++++\n src/ipa/raspberrypi/raspberrypi.cpp | 21 +++++--------\n 4 files changed, 54 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..fa1721130783 100644\n--- a/src/ipa/raspberrypi/controller/controller.cpp\n+++ b/src/ipa/raspberrypi/controller/controller.cpp\n@@ -20,6 +20,25 @@ 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+};\n+\n Controller::Controller()\n \t: switchModeCalled_(false)\n {\n@@ -148,3 +167,15 @@ 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+\tASSERT(cfg != HardwareConfigMap.end());\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 ¶ms);\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 92c65a2c2f6c..e24529920a4b 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1394,20 +1394,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@@ -1415,11 +1414,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@@ -1427,7 +1422,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", "v3", "02/10" ] }