Patch Detail
Show a patch.
GET /api/patches/24727/?format=api
{ "id": 24727, "url": "https://patchwork.libcamera.org/api/patches/24727/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24727/", "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": "<20251023115034.2207-3-david.plowman@raspberrypi.com>", "date": "2025-10-23T11:49:14", "name": "[v2,2/5] ipa: rpi: lux: Handle camera mode sensitivity correctly", "commit_ref": "17ee3b608989ace6b2435655f745d624019be842", "pull_url": null, "state": "accepted", "archived": false, "hash": "85e1a787e0d96752a2cfae9b05eadafa672de251", "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/24727/mbox/", "series": [ { "id": 5519, "url": "https://patchwork.libcamera.org/api/series/5519/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5519", "date": "2025-10-23T11:49:12", "name": "Fix and improve full image Y statistics", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5519/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24727/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24727/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 71B63C3331\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 11:50:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6BC6A607E5;\n\tThu, 23 Oct 2025 13:50:45 +0200 (CEST)", "from mail-wr1-x430.google.com (mail-wr1-x430.google.com\n\t[IPv6:2a00:1450:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1691A607CA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 13:50:41 +0200 (CEST)", "by mail-wr1-x430.google.com with SMTP id\n\tffacd0b85a97d-4270a3464bcso557403f8f.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 04:50:41 -0700 (PDT)", "from davidp-pi.pitowers.org\n\t([2a00:1098:3142:1f:f75f:a9a5:3eb7:34d4])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-4298b996aaasm1900760f8f.3.2025.10.23.04.50.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 23 Oct 2025 04:50:40 -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=\"Iq+MKu92\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1761220241; x=1761825041;\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=SVMDCIFmjD7WxzZUSX69iF9RZaDZQ5KpDvQNG78nIu8=;\n\tb=Iq+MKu92uISuNesYSDo06xiSn1BJGhMamOWNErTSXh0duAD2mKgFU63Ydd/pSYhExp\n\tNSporsK5hdb0F7c1ummC6GeWKionBG2U4ahSIX91lsuE+/WsW6nAwyNGnLkXf6iSm/ZZ\n\tvbNzntOwBIlkz48QqSgBTuuJ6MaQGKCH17jutQZyRjHUojHwFxlaEUpDnnpqaLK9IlKk\n\tP1QtZYxhXhNAug3W7NN3LFfwZSW2nW2fZpW3pjtST/ZCxCxjE4DHwxUFngkEMiZON7OU\n\takm8PPYeamxXJcUraMxTC7CV0w6o7bniOuCKfAjmKMoerQ3nz+qYrgcVjnRH2wB5pRXJ\n\t/aAg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1761220241; x=1761825041;\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=SVMDCIFmjD7WxzZUSX69iF9RZaDZQ5KpDvQNG78nIu8=;\n\tb=Pe1uroAcZFSv2nljSRno3yrjQk0r+024DgQl+3SHUeAQMr78fokrEw/EQQ9JW1vabL\n\tS41grTSUJdqhr3+o/yNo6VZ4sAvH7pG3encvG7pPxw1R83lk7OTFTHnlMYzY3/w3qWKF\n\ts8Tc04GdNVp2yyxXhMa9jkR9hEXTalrRbkflVy4AY7WHuL5m51Gn7cVhJyNRzB9fymzq\n\tD/myCDkHQ2bbhPj2bWjhjUbTCX+aE3pEq7tapk/uLBnURC5Uq+pNMyHTqwkXMF691RLH\n\tg189swVEkp8ZduDTU+X6/P85IkogWqMChnBBwDxK6lg576BAReW33ZBYDjL+LMrH95Y2\n\tOg0w==", "X-Gm-Message-State": "AOJu0YxTmfUbT1qyUCvVY9CFI6xzxfYoHtxsvbOllW/cBy9YXqn+zzbK\n\t/4SUAg6/198C8dbWvThaV+p9H5FIiIxHGpb1goTPZGLVIR/1Zyb2RWMyShKEW1pKYeJWxcXKnID\n\tCjr8i0ZM=", "X-Gm-Gg": "ASbGnct69EXG2JK6W9Q+nKoS5HccA/OhY1gYGwVEIvpwUzZfj+oxqabxmw7Lc0eWrZd\n\tBnZwwt6mW0rOANBCM52fD03X5ygUq2hzuPn4+bZxkHtlnNwK1FQL55EFQ998SbqeJ6Nqd4iMYbc\n\tGF93Atr0NL8MYEvF1uX2HUn476LuLTh6wRnh0/YEJhXVbY80ZEtd+aDLUIoXUa18XKkygG/KtGt\n\tgbIarJJcRrQNl41tz8pHyzyKGJSd1zuR1w65pCNuwHs64ciic1jdNa9l2VkgWeEJZTG27ilwtdO\n\tM97AufWunWw54WU+WRkT6MBS+fF4OI6fsizl/AKYoaDA/bwrVphnaiTftwPKyuZvt1i1uIWl9oQ\n\trT3SjX+DbCxc/ktWMXShXFrlnt9HFTE9+HKGpSqX6CAdJ/zYy3q5SEXUsQkZs1RCDV4UjqwWtDs\n\tUDOx10hHWnrXI+Zj8Gbk78IBQnQ4i0APVg5+E/CniZf/Lf8TugV8dWiIp1sy+hGQv+ja2C2psEV\n\tN0qPxrix7ZPU8pa+A==", "X-Google-Smtp-Source": "AGHT+IEh2jDPJUwmqChoV8H5GQ51WNy79xQP2n67V5xeX0gJtKHGRFEtZKkUiBhEKaMYC1ZwNlNlNQ==", "X-Received": "by 2002:a5d:5f82:0:b0:3eb:5245:7c1f with SMTP id\n\tffacd0b85a97d-42704d7ea04mr13991409f8f.2.1761220240957; \n\tThu, 23 Oct 2025 04:50:40 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "David Plowman <david.plowman@raspberrypi.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>", "Subject": "[PATCH v2 2/5] ipa: rpi: lux: Handle camera mode sensitivity\n\tcorrectly", "Date": "Thu, 23 Oct 2025 12:49:14 +0100", "Message-ID": "<20251023115034.2207-3-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.47.3", "In-Reply-To": "<20251023115034.2207-1-david.plowman@raspberrypi.com>", "References": "<20251023115034.2207-1-david.plowman@raspberrypi.com>", "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": "The camera mode sensitivity needs to be taken into account for the lux\ncalculation. For example, the IMX708 binned mode (with a sensitivity\nof 2.0) would otherwise show double the correct lux value.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/rpi/lux.cpp | 13 +++++++++++--\n src/ipa/rpi/controller/rpi/lux.h | 3 +++\n 2 files changed, 14 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/ipa/rpi/controller/rpi/lux.cpp b/src/ipa/rpi/controller/rpi/lux.cpp\nindex 27b89a8f..acaa6e57 100644\n--- a/src/ipa/rpi/controller/rpi/lux.cpp\n+++ b/src/ipa/rpi/controller/rpi/lux.cpp\n@@ -20,7 +20,7 @@ LOG_DEFINE_CATEGORY(RPiLux)\n #define NAME \"rpi.lux\"\n \n Lux::Lux(Controller *controller)\n-\t: Algorithm(controller)\n+\t: Algorithm(controller), sensitivity_(1.0)\n {\n \t/*\n \t * Put in some defaults as there will be no meaningful values until\n@@ -68,6 +68,13 @@ void Lux::setCurrentAperture(double aperture)\n \tcurrentAperture_ = aperture;\n }\n \n+void Lux::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata)\n+{\n+\t/* We will need to compensate for the camera sensitivity. */\n+\tASSERT(cameraMode.sensitivity);\n+\tsensitivity_ = cameraMode.sensitivity;\n+}\n+\n void Lux::prepare(Metadata *imageMetadata)\n {\n \tstd::unique_lock<std::mutex> lock(mutex_);\n@@ -88,10 +95,12 @@ void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata)\n \t\tdouble yRatio = currentY * (65536 / stats->yHist.bins()) / referenceY_;\n \t\tdouble estimatedLux = exposureTimeRatio * gainRatio *\n \t\t\t\t apertureRatio * apertureRatio *\n-\t\t\t\t yRatio * referenceLux_;\n+\t\t\t\t yRatio * referenceLux_ / sensitivity_;\n+\n \t\tLuxStatus status;\n \t\tstatus.lux = estimatedLux;\n \t\tstatus.aperture = currentAperture;\n+\n \t\tLOG(RPiLux, Debug) << \": estimated lux \" << estimatedLux;\n \t\t{\n \t\t\tstd::unique_lock<std::mutex> lock(mutex_);\ndiff --git a/src/ipa/rpi/controller/rpi/lux.h b/src/ipa/rpi/controller/rpi/lux.h\nindex da007fe9..db2227e4 100644\n--- a/src/ipa/rpi/controller/rpi/lux.h\n+++ b/src/ipa/rpi/controller/rpi/lux.h\n@@ -10,6 +10,7 @@\n \n #include <libcamera/base/utils.h>\n \n+#include \"../camera_mode.h\"\n #include \"../lux_status.h\"\n #include \"../algorithm.h\"\n \n@@ -23,6 +24,7 @@ public:\n \tLux(Controller *controller);\n \tchar const *name() const override;\n \tint read(const libcamera::YamlObject ¶ms) override;\n+\tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n \tvoid prepare(Metadata *imageMetadata) override;\n \tvoid process(StatisticsPtr &stats, Metadata *imageMetadata) override;\n \tvoid setCurrentAperture(double aperture);\n@@ -40,6 +42,7 @@ private:\n \tdouble currentAperture_;\n \tLuxStatus status_;\n \tstd::mutex mutex_;\n+\tdouble sensitivity_;\n };\n \n } /* namespace RPiController */\n", "prefixes": [ "v2", "2/5" ] }