Show a patch.

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

{
    "id": 24699,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/24699/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/24699/",
    "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": "<20251017102704.3887-3-david.plowman@raspberrypi.com>",
    "date": "2025-10-17T10:05:38",
    "name": "[2/5] ipa: rpi: lux: Handle camera mode sensitivity correctly",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "85e1a787e0d96752a2cfae9b05eadafa672de251",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/24699/mbox/",
    "series": [
        {
            "id": 5509,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5509/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5509",
            "date": "2025-10-17T10:05:36",
            "name": "Fix and improve full image Y statistics",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/5509/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/24699/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/24699/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 35746C3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Oct 2025 10:27:15 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F277A606CF;\n\tFri, 17 Oct 2025 12:27:13 +0200 (CEST)",
            "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B3B08606BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 12:27:10 +0200 (CEST)",
            "by mail-wm1-x32a.google.com with SMTP id\n\t5b1f17b1804b1-471076f819bso14051735e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Oct 2025 03:27:10 -0700 (PDT)",
            "from localhost.localdomain ([2a06:61c0:f337:0:8aba:2a85:b765:a23e])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-47114428dedsm73811905e9.7.2025.10.17.03.27.08\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 17 Oct 2025 03:27:08 -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=\"A1WenaEw\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1760696830; x=1761301630;\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=pKNNxUkSF8/sGRxUgmWP5MlL22UtXQN5k0cv1bzA+DA=;\n\tb=A1WenaEw2ctVXVA5ZOwHnTRT/f2ecTiCMFr9/FHhZ0WHptTPPoVosR+5VovVQi6gm2\n\tjSVyH8PyS9qM8KZHHh6x/T83Bf8QtTyuhti2F2wQwW7c/DPNm2szijrSLL50wxWIG1bQ\n\teL0tDJoHoFFKs/nZKLmAarnIipU/rKwP5G9R+kvYgmlJv4zBTB79/esafkGPUnkHPAPV\n\tz0TNv85gF2NVIbzkw61Pf16dI+Hf0IGB+pwhOCp2M6MZ9fEieLZBiVJLatbnA1zZ7qJB\n\tEyh6ZI/W+k9SAODsOwCC5lfamsE9fVc//RjfIi4yuHtS4FJa0jddwgz5OkvN39UpjIHv\n\tVFog==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1760696830; x=1761301630;\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=pKNNxUkSF8/sGRxUgmWP5MlL22UtXQN5k0cv1bzA+DA=;\n\tb=kWPCVW6qv5Gkw4+R96RgznCnMHkmm2JoPEf7vlCtaYzg0UNm+mZ4xS96CwTrm4SVUg\n\t1yUayPr4hZwSHvkzmYZzbz57dBxYeQ4yiMiYZMQ94UiqWmAgDGJtiGHvy/Sh2GgNftzc\n\tFRhKV1RE3mP22g7sflifDQHz6hj2eEmDfX2s6oxdMCtElWp9CvGw84Np8HlkRTexUqO7\n\tG2OhO+IFjr1YFJG9z4CVvWBYTGzTnVPZTlChMZpj1IL2dXcc1kn1ZPA2aFKrTZhLBqXD\n\tSs5t9GCoccfuOQd4BkwCRn5zS8jvnxd9ZWqJuxArb7B9Qu+JA2Lz6oTf/xZ4klWtmf9a\n\tOITA==",
        "X-Gm-Message-State": "AOJu0YyrZnR1vl50e4NpjREl/kse0iJcm99oOvRclhar6oLDoDjyaGx/\n\tGib5/tIYD06b+n5Ii/VAJK5BzyLffTIqnXMiaTKLuGm1k9Wvwm5se9f9p3Urj0WJyWZ2mNMUT3y\n\tIskrgQH0=",
        "X-Gm-Gg": "ASbGncsffl6/0ceDv9Q4cEiN2Km3Eipm7wl9tRXuHIefWhRVow1S27LCGMl4QhpG2Jo\n\t5NMhV8MXMClwshGvwbAWDkC4qGY0V6yXokGN9cgrxjnh7+IkYAlrKBMcFi6NBzzKjLhUPynk44V\n\tkqkyKK82ahVj+bFTT4FZ0C9Iigg9tWdmcr/x88SsM/2ydER191SHqmd0YGcLvDQd4OMdNzllnHv\n\twioOnD2o/K3NtbYC9cAQk09Sf233u8BkfadT0SrgRAkm5SNn2z27cLQk8TOsKTeVnS3WTmaonB0\n\tGUG1YmgBQUbJZZ7eow2D7dL1fKDo5G0gkf/2044JGh1cvmg5j4ZXATcW/mvIurHvVEMmF9a7ztp\n\t4owA8+kj+7QsTDNJk3WUAsRFPPdH7bH4LVxyb7k4caFkt+p/wvDMVJjCJkRTSW2ay2w76AZrnt/\n\tpVBEfZiSGHqXlh//kthOcc8vmxKhokLFbminKPfY6QB07CID/m/cWd5ynLOH9tnJtJmtrdFu+2b\n\trKoSNhDMm8TtEYG8ofx6CakWA==",
        "X-Google-Smtp-Source": "AGHT+IFfYc1mqR4NiLC709TaAhNKT3kJ+Otw0BEw+UfcqttmE2hwaeNBPquditJDc7txpmengn/Yzw==",
        "X-Received": "by 2002:a05:600c:444d:b0:46e:1f86:aeba with SMTP id\n\t5b1f17b1804b1-471178ad982mr20822585e9.17.1760696829626; \n\tFri, 17 Oct 2025 03:27:09 -0700 (PDT)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "David Plowman <david.plowman@raspberrypi.com>",
        "Subject": "[PATCH 2/5] ipa: rpi: lux: Handle camera mode sensitivity correctly",
        "Date": "Fri, 17 Oct 2025 11:05:38 +0100",
        "Message-ID": "<20251017102704.3887-3-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.47.3",
        "In-Reply-To": "<20251017102704.3887-1-david.plowman@raspberrypi.com>",
        "References": "<20251017102704.3887-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>\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 &params) 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": [
        "2/5"
    ]
}