Show a patch.

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

{
    "id": 12570,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/12570/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12570/",
    "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": "<20210611100703.2285-3-david.plowman@raspberrypi.com>",
    "date": "2021-06-11T10:07:03",
    "name": "[libcamera-devel,v3,2/2] ipa: raspberrypi: AGC: handle modes with different sensitivities",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6b33206c9f10fa8a5b117d68aefb07c3a1be2eaa",
    "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/12570/mbox/",
    "series": [
        {
            "id": 2122,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2122/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2122",
            "date": "2021-06-11T10:07:01",
            "name": "Raspberrypi: support per-mode camera sensitivities",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/2122/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12570/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12570/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 31D48C320B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 11 Jun 2021 10:07:12 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E0F0568932;\n\tFri, 11 Jun 2021 12:07:11 +0200 (CEST)",
            "from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 24C1368932\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Jun 2021 12:07:09 +0200 (CEST)",
            "by mail-wm1-x32c.google.com with SMTP id\n\tt4-20020a1c77040000b029019d22d84ebdso8303364wmi.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 11 Jun 2021 03:07:09 -0700 (PDT)",
            "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tb135sm12568155wmb.5.2021.06.11.03.07.07\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 11 Jun 2021 03:07:07 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"gg5ToUIu\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=4dd9tk74djwk5oBxLFFfp2oyTcPgl7Oc6QfpzeJ4gA8=;\n\tb=gg5ToUIum1IZsfDBfCW9IN+Dyft7TQf6PSR0KcGK66ItbjdqsUypGumQ45cCNfO/gt\n\tuQghA3ZktiTuwrb9T6BEsvJAyuWBRAUqWrojWMdHQNS2MVt30u/kgdSrk1Q2LAPqsRR4\n\tHWKeRIA7LEcdMdTTrry2KBA9hrz9oa31POMbxVaj5pAoD644tkrJgWa3nXxKbsj4XbpH\n\tFoL1ocMZj7MofoEXntpCbvYka1+vlM9HMErHzlVnfr45AnqeU3RwF0PvGHnubDrPv62Z\n\tDY5hiRDs2um1XRNv9bKuv9LRv9+5sRQjOjz22x+gB6L/KPOmjqwLoco0EL+MSP8/eo5B\n\t41mA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=4dd9tk74djwk5oBxLFFfp2oyTcPgl7Oc6QfpzeJ4gA8=;\n\tb=HFPj/WRVj2tJGnP+o9S1bRogmCEIXbWPkhQucFr18PFibYfS4R9GTt+0KU5WCVQPjp\n\tLWidaCeiwJtWT5Q8JX11b8VWah+lfldN0omooCGYLFVsHdPQEV9vyml2LFlP1EzvpbBE\n\tNniH+g2RGQqqw8yhNIfHx1bnPfyVzz4DjFxEZamjfJp+IpQj2jNlEXJCjGbFyJ8UVIou\n\t5SV57jzBXZFotvyJvfnXdcDycr3YnAY9uPYATQl75MHxW/Bnqp57BLqrSeWJSCto3hUA\n\tx9Oy7f3twSouufhDjXWW2GLhRwoH8YKaOM2xNSbE8w3MNQZyiZUfM43ROBAbO5wQMeJD\n\t847w==",
        "X-Gm-Message-State": "AOAM533q6maJ6eXmnTYfCUBqqvYlBeSMMOSywsjLhJxwzuM6R0t77lcH\n\tKfTlrnTUgrkhL0e9wDyUF/Y8MTzO5UmtAUb/",
        "X-Google-Smtp-Source": "ABdhPJxGn2rkGO/hWrGI4mdd1dzzq2tY9pIE3Nq6CxRz2KW7frXHQlwB1IXtnGwJvaN+yvb3Ky/okw==",
        "X-Received": "by 2002:a05:600c:410a:: with SMTP id\n\tj10mr18966453wmi.6.1623406028489; \n\tFri, 11 Jun 2021 03:07:08 -0700 (PDT)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri, 11 Jun 2021 11:07:03 +0100",
        "Message-Id": "<20210611100703.2285-3-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20210611100703.2285-1-david.plowman@raspberrypi.com>",
        "References": "<20210611100703.2285-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v3 2/2] ipa: raspberrypi: AGC: handle\n\tmodes with different sensitivities",
        "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": "When the sensor is switched to a mode with a different sensitivity,\nthe target exposure values need to be adjusted proportionately to\nmaintain the same image brightness.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 25 +++++++++++++++++-----\n src/ipa/raspberrypi/controller/rpi/agc.hpp |  1 +\n 2 files changed, 21 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex 55e80ac7..431029d0 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -163,7 +163,7 @@ Agc::Agc(Controller *controller)\n \t: AgcAlgorithm(controller), metering_mode_(nullptr),\n \t  exposure_mode_(nullptr), constraint_mode_(nullptr),\n \t  frame_count_(0), lock_count_(0),\n-\t  last_target_exposure_(0s),\n+\t  last_target_exposure_(0s), last_sensitivity_(0.0),\n \t  ev_(1.0), flicker_period_(0s),\n \t  max_shutter_(0s), fixed_shutter_(0s), fixed_analogue_gain_(0.0)\n {\n@@ -269,7 +269,7 @@ void Agc::SetConstraintMode(std::string const &constraint_mode_name)\n \tconstraint_mode_name_ = constraint_mode_name;\n }\n \n-void Agc::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,\n+void Agc::SwitchMode(CameraMode const &camera_mode,\n \t\t     Metadata *metadata)\n {\n \thousekeepConfig();\n@@ -293,9 +293,20 @@ void Agc::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,\n \t\tfiltered_.shutter = fixed_shutter;\n \t\tfiltered_.analogue_gain = fixed_analogue_gain_;\n \t} else if (status_.total_exposure_value) {\n-\t\t// On a mode switch, it's possible the exposure profile could change,\n-\t\t// or a fixed exposure/gain might be set so we divide up the exposure/\n-\t\t// gain again, but we don't change any target values.\n+\t\t// On a mode switch, various things could happen:\n+\t\t// - the exposure profile might change\n+\t\t// - a fixed exposure or gain might be set\n+\t\t// - the new mode's sensitivity might be different\n+\t\t// We cope with the last of these by scaling the target values. After\n+\t\t// that we just need to re-divide the exposure/gain according to the\n+\t\t// current exposure profile, which takes care of everything else.\n+\n+\t\tdouble ratio = last_sensitivity_ / camera_mode.sensitivity;\n+\t\ttarget_.total_exposure_no_dg *= ratio;\n+\t\ttarget_.total_exposure *= ratio;\n+\t\tfiltered_.total_exposure_no_dg *= ratio;\n+\t\tfiltered_.total_exposure *= ratio;\n+\n \t\tdivideUpExposure();\n \t} else {\n \t\t// We come through here on startup, when at least one of the shutter\n@@ -309,6 +320,10 @@ void Agc::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,\n \t}\n \n \twriteAndFinish(metadata, false);\n+\n+\t// We must remember the sensitivity of this mode for the next SwitchMode.\n+\tASSERT(camera_mode.sensitivity != 0.0);\n+\tlast_sensitivity_ = camera_mode.sensitivity;\n }\n \n void Agc::Prepare(Metadata *image_metadata)\ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp\nindex 75078948..0d08dcd7 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp\n@@ -126,6 +126,7 @@ private:\n \tint lock_count_;\n \tDeviceStatus last_device_status_;\n \tlibcamera::utils::Duration last_target_exposure_;\n+\tdouble last_sensitivity_; // sensitivity of the previous camera mode\n \t// Below here the \"settings\" that applications can change.\n \tstd::string metering_mode_name_;\n \tstd::string exposure_mode_name_;\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "2/2"
    ]
}