Patch Detail
Show a patch.
GET /api/patches/26767/?format=api
{ "id": 26767, "url": "https://patchwork.libcamera.org/api/patches/26767/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26767/", "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": "<20260518142600.6546-1-david.plowman@raspberrypi.com>", "date": "2026-05-18T14:22:27", "name": "[v1] ipa: rpi: Improve control over which sensor modes require \"debinning\"", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "df62cf2baeabe137b034c015e157482f56536be2", "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/26767/mbox/", "series": [ { "id": 5952, "url": "https://patchwork.libcamera.org/api/series/5952/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5952", "date": "2026-05-18T14:22:27", "name": "[v1] ipa: rpi: Improve control over which sensor modes require \"debinning\"", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5952/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26767/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26767/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 8111EBDCBD\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 18 May 2026 14:26:07 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 654EE62FD3;\n\tMon, 18 May 2026 16:26:06 +0200 (CEST)", "from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n\t[IPv6:2a00:1450:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 52C3E62FB1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 May 2026 16:26:04 +0200 (CEST)", "by mail-wm1-x336.google.com with SMTP id\n\t5b1f17b1804b1-488b8bc6bc9so13584055e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 18 May 2026 07:26:04 -0700 (PDT)", "from davidp-pi5.pitowers.org\n\t([2a00:1098:3142:1f:fcab:48df:35ab:5c26])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-48fffb9aac4sm255817905e9.9.2026.05.18.07.26.03\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 18 May 2026 07:26:03 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"WNe2QW2H\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1779114363; x=1779719163;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=mrk23Gkd1SxujjgkYP6Pca+LtlEzBxLVI0f/pr7Kbqs=;\n\tb=WNe2QW2HVMWryjUyHNHq6BsPA50lyjNgXRepxc2JxNVAfGJs3Bhq5UT7yUXBztkqp/\n\tCeriaccqtt2aoFVPSdoOagMoqZ+q65uh4IoGrfFO3jE6nNw1qQXDw/mt1EzUiZOXOf9v\n\tR3brcSmbkP+EtpKbRUlnx6ETyG3NDohSsapQGjT1r0qy5SkgXxFxdhs4Rjzkjrv3dbqw\n\tdo/D4a41w5xft8u4M8KK+H1V5Lwcsr1X0wSsuJttQEtZHCZo3jGDyjZ+HzAKo0ucXb7/\n\tjiZMbQdouNBHgb+VH/AV3MuBA6fhOaSnoIWOEx0R+/8/SU/VxNQso040mFYlnRBgFJsk\n\t1sOA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1779114363; x=1779719163;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=mrk23Gkd1SxujjgkYP6Pca+LtlEzBxLVI0f/pr7Kbqs=;\n\tb=nJFylEAruYDL2Np3tkLNT3n2jjIA8YaZlesdC/sG5SeEgQB4f44aliMxEDtfkcyvoj\n\tn7BCQNR+CLPLGelFUA85x7IcJNRb1AJ8s0dcmzGxLDXWsn77FFH0lWsjAfgD1ShmcCs3\n\tA9HcflajCoyyHjLJr2xnYVoSnApJjpNWUvF56bbig+esJ8Onvc1N2A3s8cAXWFcMu+PT\n\tzGQtsqSiU6nHBo5C54D7RL1RMdKkMStJN0j7sjnME5fPG9We+GqlmitWkVGzKi8CR3QW\n\ttueHHFJuLk479rHAk9YrYCLKzMZy7yLZKzrhP4xUJZYVM6aucSzzbDferuvZKZVuCJJb\n\twZEA==", "X-Gm-Message-State": "AOJu0YzoJsfCV3nGvE4uVS69L7rAdOJXhSgANF0GN2lPXOo9PnbmzzNj\n\tKgWB+NrZ77+h7RPmoQ+xx6Qx970K8FkPyE8IOeOP/MGbUvHoDIhPMK4xVzV2grfgWHGyvOcIhP1\n\tX31qnhlU=", "X-Gm-Gg": "Acq92OFaFl0fAwE0o5b5RUozdY4ImiBEgg6TPG9O6eOvqOD4T7/tcGa+TUyb+Hfnl/h\n\t7i+/URH5/wplMOLc6oGL9YIKYK+kOUPqlBC+TtHIEH9zqXpH6nx3h1EGrpQvDiLkdnfUw/hfDQt\n\tAl9JnkzfkfSrfnkkqcjfU+poz7wQXKy+qj9C06KG2yk2C4EV1iNKP7lz0HPJOApycng1WQP1UMo\n\tAS2hoUKYsZKGX2YQRSRv7VCxqRVUo7gRK6JGU99qMniNfoghZSuBmpq2PiM518W87Q7avmpWKBr\n\tNnAQAW9rijFcF0LnX4RUdrxC1Y+yTyaUsU6MtmsoY80UxHegz1sO5o+RzMtXUvww4sykwxp+q3s\n\tMBYcosWX/yaFrlh8XZs+L5FnhEd/8MeiwqzTqGYwcgP7aNMfEuqezxLU52yYruIDdEpHyzR9n7g\n\tAsBTKQ6hcoIWCiIFGoqBK80pUqreIBSFxEke8mGCNHGm9ssROHwnA72/lQksYbQMuZp01VYE6Ch\n\tjub9bCwbxLHtajrP4v+FMfy0yjRkOhavVXgX7Xf41g=", "X-Received": "by 2002:a05:600c:c096:b0:48f:d1b8:9aaa with SMTP id\n\t5b1f17b1804b1-48fe60e525bmr176321795e9.6.1779114363490; \n\tMon, 18 May 2026 07:26:03 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "David Plowman <david.plowman@raspberrypi.com>", "Subject": "[PATCH v1] ipa: rpi: Improve control over which sensor modes require\n\t\"debinning\"", "Date": "Mon, 18 May 2026 15:22:27 +0100", "Message-ID": "<20260518142600.6546-1-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.47.3", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "\"Debinning\" is the process that corrects the spatial sampling of\npixels when this has been disturbed by the standard binning process.\n\nHowever, debinning is not required for sensors that do it themselves,\nor for quad Bayer sensors at 2x2 binning where the spatial sampling is\nalready correct.\n\nHere we add a getMinDebinFactor() to the CamHelper which allows us to\ncustomise at what binning (or downscaling) factor we need to apply the\ncorrection. This value is then used to decide whether to enable the\nrelevant PiSP block.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/cam_helper/cam_helper.cpp | 6 ++++++\n src/ipa/rpi/cam_helper/cam_helper.h | 6 ++++++\n src/ipa/rpi/cam_helper/cam_helper_imx708.cpp | 7 +++++++\n src/ipa/rpi/pisp/pisp.cpp | 8 +++++---\n 4 files changed, 24 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/ipa/rpi/cam_helper/cam_helper.cpp b/src/ipa/rpi/cam_helper/cam_helper.cpp\nindex a78db9c1..dfdcd167 100644\n--- a/src/ipa/rpi/cam_helper/cam_helper.cpp\n+++ b/src/ipa/rpi/cam_helper/cam_helper.cpp\n@@ -204,6 +204,12 @@ unsigned int CamHelper::mistrustFramesModeSwitch() const\n \treturn 0;\n }\n \n+unsigned int CamHelper::getMinDebinFactor() const\n+{\n+\t/* Most cameras require debinning from 2x2 binning upwards. */\n+\treturn 2;\n+}\n+\n void CamHelper::parseEmbeddedData(Span<const uint8_t> buffer,\n \t\t\t\t Metadata &metadata)\n {\ndiff --git a/src/ipa/rpi/cam_helper/cam_helper.h b/src/ipa/rpi/cam_helper/cam_helper.h\nindex 4a826690..349891c4 100644\n--- a/src/ipa/rpi/cam_helper/cam_helper.h\n+++ b/src/ipa/rpi/cam_helper/cam_helper.h\n@@ -62,6 +62,11 @@ namespace RPiController {\n * MistrustFramesModeSwitch(): The number of frames, after a mode switch\n * (other than start-up), for which control algorithms should not run\n * (for example, metadata may be unreliable).\n+ * getMinDebinFactor(): the binning factor after which we should apply\n+ * \"debinning\", which corrects for the uneven spatial sampling of the\n+ * standard binning process. A return value of 2 means to enable\n+ * debinning for camera modes using 2x2, or larger, binning. A return\n+ * value of zero means never to enable binning.\n */\n \n class CamHelper\n@@ -93,6 +98,7 @@ public:\n \tvirtual unsigned int hideFramesModeSwitch() const;\n \tvirtual unsigned int mistrustFramesStartup() const;\n \tvirtual unsigned int mistrustFramesModeSwitch() const;\n+\tvirtual unsigned int getMinDebinFactor() const;\n \n protected:\n \tvoid parseEmbeddedData(libcamera::Span<const uint8_t> buffer,\ndiff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\nindex 6150909c..e7b8d671 100644\n--- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n+++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n@@ -58,6 +58,7 @@ public:\n \tdouble getModeSensitivity(const CameraMode &mode) const override;\n \tunsigned int hideFramesModeSwitch() const override;\n \tunsigned int hideFramesStartup() const override;\n+\tunsigned int getMinDebinFactor() const override;\n \n private:\n \t/*\n@@ -237,6 +238,12 @@ unsigned int CamHelperImx708::hideFramesStartup() const\n \treturn hideFramesModeSwitch();\n }\n \n+unsigned int CamHelperImx708::getMinDebinFactor() const\n+{\n+\t/* Quad-Bayer sensor, so debinning required only at 4x4 binning. */\n+\treturn 4;\n+}\n+\n void CamHelperImx708::populateMetadata(const MdParser::RegisterMap ®isters,\n \t\t\t\t Metadata &metadata) const\n {\ndiff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\nindex de2a6afe..fd28fc38 100644\n--- a/src/ipa/rpi/pisp/pisp.cpp\n+++ b/src/ipa/rpi/pisp/pisp.cpp\n@@ -1078,12 +1078,14 @@ void IpaPiSP::setStatsAndDebin()\n \tpisp_be_global_config beGlobal;\n \tbe_->GetGlobal(beGlobal);\n \n-\tif (mode_.binX > 1 || mode_.binY > 1) {\n+\tunsigned int minDebinFactor = helper_->getMinDebinFactor();\n+\tif (minDebinFactor &&\n+\t (mode_.binX >= minDebinFactor || mode_.binY >= minDebinFactor)) {\n \t\tpisp_be_debin_config debin;\n \n \t\tbe_->GetDebin(debin);\n-\t\tdebin.h_enable = (mode_.binX > 1);\n-\t\tdebin.v_enable = (mode_.binY > 1);\n+\t\tdebin.h_enable = (mode_.binX >= minDebinFactor);\n+\t\tdebin.v_enable = (mode_.binY >= minDebinFactor);\n \t\tbe_->SetDebin(debin);\n \t\tbeGlobal.bayer_enables |= PISP_BE_BAYER_ENABLE_DEBIN;\n \t} else\n", "prefixes": [ "v1" ] }