Show a patch.

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

{
    "id": 19206,
    "url": "https://patchwork.libcamera.org/api/patches/19206/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19206/",
    "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": "<20231110161433.413382-1-david.plowman@raspberrypi.com>",
    "date": "2023-11-10T16:14:33",
    "name": "[libcamera-devel] ipa: rpi: awb: Make is possible to set the colour temperature directly",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "9312eae606b6cebd560d7453713427ba2dc0639a",
    "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/19206/mbox/",
    "series": [
        {
            "id": 4071,
            "url": "https://patchwork.libcamera.org/api/series/4071/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4071",
            "date": "2023-11-10T16:14:33",
            "name": "[libcamera-devel] ipa: rpi: awb: Make is possible to set the colour temperature directly",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4071/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19206/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19206/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 B4835BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Nov 2023 16:14:38 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 170AA629B6;\n\tFri, 10 Nov 2023 17:14:38 +0100 (CET)",
            "from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6BFF661DB6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Nov 2023 17:14:36 +0100 (CET)",
            "by mail-wr1-x42d.google.com with SMTP id\n\tffacd0b85a97d-32f87b1c725so1448683f8f.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Nov 2023 08:14:36 -0800 (PST)",
            "from pi5-davidp.pitowers.org\n\t([2a00:1098:3142:14:183e:6cc8:a436:a27c])\n\tby smtp.gmail.com with ESMTPSA id\n\ti9-20020adfe489000000b0032da8fb0d05sm2167468wrm.110.2023.11.10.08.14.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 10 Nov 2023 08:14:34 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1699632878;\n\tbh=gRcMOWzjBiVTTYDKFeK8kIY2Z+sHNFMn9Tz1Dvtz4sQ=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=1BoIw/jQokCNXKYN7EG++AVDixw68CVpWWlq2VX4QrSp88TkTVm5iAhogp49k2kE8\n\tNZZtvJxNsk8aJQoEOhpHV+vyEH24lN8TBH7iDKw4FAW6dG//tRzNjXL0Mkg4PmfvUL\n\tZtmec7iAd1hgPYJsOEr2bB6qjyfJDlHOUVBYaU/eTLaHEX+b+C8K4DzfIclgzTW1ij\n\tQb+KmsKDHhsAAP3ttgE0xCTFf5/qYdLMYv/dwqHaEv9cfde8+pa0SLBJFlPVEzd9TT\n\tojGablglR9/msVSwsyix0AOfSVfKLk9HSnNM4YYo5axLEy6j3e19guJaFRH/CcqCgB\n\tifBE7CUQYP4xg==",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1699632875; x=1700237675;\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=+Y5t0BVJB50ee+3vSFOAvozfznYlHKOdVYI3EtNlGVM=;\n\tb=dElLd/ZNHaMxwyMHwb4o8Aiaq18z17RNlMx0BWtTbjXAkeaY6vxxpySmXz7QyioL0R\n\tNza4Iwhxo3hqR7fEEZPx2L+I/s1qyMXxFYh+IGBN5rUxQ56AJCzwq3pikuFnrF+7FvxM\n\tDLm94pCbnRR9YPfxDn1AHsx+L9HHmUT6vm7tlUQV6wtSKQC7Mi/uEJ2rijwKp87UcEtu\n\t57QbRk1e3Nilt1SjXCiaS9CmM1fxNMPAGf/v2VJOr9mKrQkNO8PfEpU3wsTUH3Zom2b3\n\tATg8R0BTGu/lZcd111UWGhndkkAJf6LKSvROHnWRhISKAgec1JKaLs1PG9hP9zA5Tfh7\n\tKwwA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"dElLd/ZN\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1699632875; x=1700237675;\n\th=content-transfer-encoding:mime-version:message-id:date:subject:cc\n\t:to:from:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=+Y5t0BVJB50ee+3vSFOAvozfznYlHKOdVYI3EtNlGVM=;\n\tb=KgCqDLwCXPpD/n+zImllgG0oSY5F67KD6cAiPLm9imfDFJu0ewAAVKgZRPUNOr3Jln\n\tXydqM1TEQyN8No0Tt1K1NP+1dLsCrJ88xcps/BxXKd/qM7vMPKPn5y1DPU7LSzLsLHQa\n\t1qYUT+jrwCoFjGXAT8JNGIDL8V8YSqSSZf/OtERWF4yjl857yflMGkdVUAiFeZc+1VxM\n\tHgfHmwh1E4O7bJhe3z9YIaGyrpWUZ7dFO3RMGWcynSDtNkSNUp8+CzQ2VlynCUlO2AOv\n\tRaNniJCznGd/dYj33BYHyX1VnmcKt8+BsZ87kow1oHPLEB+jye9D7WG+kSebLRFX+Cnc\n\txIaw==",
        "X-Gm-Message-State": "AOJu0YxTJcLvi5xvnORb0eLMFZ7c6bZk9XNczTTT9FE6F3oTkCqqpHFU\n\tOdn1BHoAd0lkwDFsluQuthAA7BS+faAKug1yo3U=",
        "X-Google-Smtp-Source": "AGHT+IFY2u5i++uHJkNGaZpy53E3pNAvFldOKv2nzXbAaDjHdQ31cHI6XgPU8N3xdbYbpdW6xJwE0w==",
        "X-Received": "by 2002:a5d:44c7:0:b0:32d:885e:633 with SMTP id\n\tz7-20020a5d44c7000000b0032d885e0633mr6884194wrr.19.1699632875383; \n\tFri, 10 Nov 2023 08:14:35 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 10 Nov 2023 16:14:33 +0000",
        "Message-Id": "<20231110161433.413382-1-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.39.2",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] ipa: rpi: awb: Make is possible to set\n\tthe colour temperature directly",
        "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": "David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "David Plowman <david.plowman@raspberrypi.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "ColourTemperature is now exported as a writable control so that\nalgorithms can set it directly. The AWB algorithm class now requires a\nmethod to be provided to perform this operation. The method should\nclamp the passed value to the calibrated range known to the algorithm.\n\nThe default range is set very wide to cover all conceivable future AWB\ncalibrations. It will always be clamped before use.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/rpi/common/ipa_base.cpp        | 20 ++++++++++++++++++++\n src/ipa/rpi/controller/awb_algorithm.h |  1 +\n src/ipa/rpi/controller/rpi/awb.cpp     | 18 ++++++++++++++++++\n src/ipa/rpi/controller/rpi/awb.h       |  1 +\n 4 files changed, 40 insertions(+)",
    "diff": "diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\nindex 97a32522..cd1d6e3d 100644\n--- a/src/ipa/rpi/common/ipa_base.cpp\n+++ b/src/ipa/rpi/common/ipa_base.cpp\n@@ -80,6 +80,7 @@ const ControlInfoMap::Map ipaColourControls{\n \t{ &controls::AwbEnable, ControlInfo(false, true) },\n \t{ &controls::AwbMode, ControlInfo(controls::AwbModeValues) },\n \t{ &controls::ColourGains, ControlInfo(0.0f, 32.0f) },\n+\t{ &controls::ColourTemperature, ControlInfo(100, 100000) },\n \t{ &controls::Saturation, ControlInfo(0.0f, 32.0f, 1.0f) },\n };\n \n@@ -972,6 +973,25 @@ void IpaBase::applyControls(const ControlList &controls)\n \t\t\tbreak;\n \t\t}\n \n+\t\tcase controls::COLOUR_TEMPERATURE: {\n+\t\t\t/* Silently ignore this control for a mono sensor. */\n+\t\t\tif (monoSensor_)\n+\t\t\t\tbreak;\n+\n+\t\t\tauto temperatureK = ctrl.second.get<int32_t>();\n+\t\t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n+\t\t\t\tcontroller_.getAlgorithm(\"awb\"));\n+\t\t\tif (!awb) {\n+\t\t\t\tLOG(IPARPI, Warning)\n+\t\t\t\t\t<< \"Could not set COLOUR_TEMPERATURE - no AWB algorithm\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tawb->setColourTemperature(temperatureK);\n+\t\t\t/* This metadata will get reported back automatically. */\n+\t\t\tbreak;\n+\t\t}\n+\n \t\tcase controls::BRIGHTNESS: {\n \t\t\tRPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>(\n \t\t\t\tcontroller_.getAlgorithm(\"contrast\"));\ndiff --git a/src/ipa/rpi/controller/awb_algorithm.h b/src/ipa/rpi/controller/awb_algorithm.h\nindex 8462c4db..d966dfa8 100644\n--- a/src/ipa/rpi/controller/awb_algorithm.h\n+++ b/src/ipa/rpi/controller/awb_algorithm.h\n@@ -18,6 +18,7 @@ public:\n \tvirtual unsigned int getConvergenceFrames() const = 0;\n \tvirtual void setMode(std::string const &modeName) = 0;\n \tvirtual void setManualGains(double manualR, double manualB) = 0;\n+\tvirtual void setColourTemperature(double temperatureK) = 0;\n \tvirtual void enableAuto() = 0;\n \tvirtual void disableAuto() = 0;\n };\ndiff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\nindex 5ae0c2fa..0918e20d 100644\n--- a/src/ipa/rpi/controller/rpi/awb.cpp\n+++ b/src/ipa/rpi/controller/rpi/awb.cpp\n@@ -275,6 +275,24 @@ void Awb::setManualGains(double manualR, double manualB)\n \t}\n }\n \n+void Awb::setColourTemperature(double temperatureK)\n+{\n+\tif (!config_.bayes) {\n+\t\tLOG(RPiAwb, Warning) << \"AWB uncalibrated - cannot set colour temperature\";\n+\t\treturn;\n+\t}\n+\n+\ttemperatureK = config_.ctR.domain().clip(temperatureK);\n+\tmanualR_ = 1 / config_.ctR.eval(temperatureK);\n+\tmanualB_ = 1 / config_.ctB.eval(temperatureK);\n+\n+\tsyncResults_.temperatureK = temperatureK;\n+\tsyncResults_.gainR = manualR_;\n+\tsyncResults_.gainG = 1.0;\n+\tsyncResults_.gainB = manualB_;\n+\tprevSyncResults_ = syncResults_;\n+}\n+\n void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n \t\t     Metadata *metadata)\n {\ndiff --git a/src/ipa/rpi/controller/rpi/awb.h b/src/ipa/rpi/controller/rpi/awb.h\nindex e7d49cd8..dbd79eda 100644\n--- a/src/ipa/rpi/controller/rpi/awb.h\n+++ b/src/ipa/rpi/controller/rpi/awb.h\n@@ -97,6 +97,7 @@ public:\n \tunsigned int getConvergenceFrames() const override;\n \tvoid setMode(std::string const &name) override;\n \tvoid setManualGains(double manualR, double manualB) override;\n+\tvoid setColourTemperature(double temperatureK) override;\n \tvoid enableAuto() override;\n \tvoid disableAuto() override;\n \tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n",
    "prefixes": [
        "libcamera-devel"
    ]
}