Patch Detail
Show a patch.
GET /api/patches/12444/?format=api
{ "id": 12444, "url": "https://patchwork.libcamera.org/api/patches/12444/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12444/", "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": "<20210527084540.9983-3-david.plowman@raspberrypi.com>", "date": "2021-05-27T08:45:40", "name": "[libcamera-devel,2/2] ipa: raspberrypi: AGC: handle modes with different sensitivities", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "56fd02fe340f2c9670ce3289fec15b5710c25de4", "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/12444/mbox/", "series": [ { "id": 2083, "url": "https://patchwork.libcamera.org/api/series/2083/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2083", "date": "2021-05-27T08:45:38", "name": "Raspberrypi: support per-mode camera sensitivities", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2083/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12444/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12444/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 7ED26BDB80\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 May 2021 08:45:52 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C9A168925;\n\tThu, 27 May 2021 10:45:51 +0200 (CEST)", "from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C403602AA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 May 2021 10:45:47 +0200 (CEST)", "by mail-wm1-x334.google.com with SMTP id\n\tf6-20020a1c1f060000b0290175ca89f698so2072969wmf.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 May 2021 01:45:47 -0700 (PDT)", "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tq11sm2325553wrx.80.2021.05.27.01.45.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 27 May 2021 01:45:46 -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=\"qapg+gY6\"; 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=NzHu98sOk4xja6FwzR2w3UuPTGhHwGZQofZOG9a8B6c=;\n\tb=qapg+gY6snTHYEDOSQWKHNWFlssL/SqMcNimPEcaAJaJl7Fq1ONEhh2jmvIye3GYo2\n\tf0BoEwEpxiXRj06Fx8splWXSUgl6Rd30YmpyAylNKUgKtgeWXFrBPElbwgSj53R6sqcC\n\t5L7ij7IG7MPUSav45ySpy3wnPtZ0GQY2MbmsC6EYF8qNz+CLxXxBr+UWTl7yGSa4Knin\n\tZM6pclqeLAAoR/yG6r/HoaKWdAqE4IYxTkUMyGiI/swBATZVrndzz7LIEcZBHjd+GLoi\n\ttziqLC35lG7UUAeveA8NOx7i05LslzvanqjV5+tcGnSSyVI0tGJvvjc0t4v/a04vmbD4\n\tGgUA==", "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=NzHu98sOk4xja6FwzR2w3UuPTGhHwGZQofZOG9a8B6c=;\n\tb=hLncUranLXXUjM4VCDFRrfas2m2SHTYvI7hdExTjkG96Maq3iW9mOuIgpPBfgsJwr+\n\t3U4PWiBvUa1Dtesu2hvVKKTO5ZMzyuzZSJLmBdn9XsNgvo+XIYY6j+h5oY9Az78ONvS2\n\t7Qnkv6TiQHfWG6MKv3yzVlv+/sPwFARhZ3qcNdvqec4vT6SebsmeYOFWaCnkFBvvdMVI\n\tp28heyQW270FfrTSwo1IClAClqbcM7VhGs+RL9j5uUJAB5H+qEb5919d3Fwyb9OKOaV+\n\tQvrDBMTbGZMSmKhFNUjxNrMagyXuK0F4goBuN5ochYQW62rKq18mMkhGIeLu+ywUfMvD\n\tz3fw==", "X-Gm-Message-State": "AOAM5318utH3bNgGIfPFqobZA7w+/elzt9AX4UpOBt0O3w1KYbBKUVNS\n\ttHfoTgEEwCUwTTZQg9pdI84BqMR7Izgq4A==", "X-Google-Smtp-Source": "ABdhPJxkmpHiZTin2VUZ0Ld+cf1FB735XmmyD+O4aLBtlPuQE5rL2iw0/WRLlUa56Xwd+O7QtbenmA==", "X-Received": "by 2002:a7b:cd98:: with SMTP id y24mr7326698wmj.4.1622105147141; \n\tThu, 27 May 2021 01:45:47 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 27 May 2021 09:45:40 +0100", "Message-Id": "<20210527084540.9983-3-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20210527084540.9983-1-david.plowman@raspberrypi.com>", "References": "<20210527084540.9983-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/2] ipa: raspberrypi: AGC: handle modes\n\twith 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>\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 f4cd5d26..6f0e9702 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -155,7 +155,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_(0.0),\n+\t last_target_exposure_(0.0), last_sensitivity_(0.0),\n \t ev_(1.0), flicker_period_(0.0),\n \t max_shutter_(0), fixed_shutter_(0), fixed_analogue_gain_(0.0)\n {\n@@ -261,7 +261,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@@ -285,9 +285,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@@ -301,6 +312,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 0427fb59..025878a2 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp\n@@ -122,6 +122,7 @@ private:\n \tint lock_count_;\n \tDeviceStatus last_device_status_;\n \tdouble 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", "2/2" ] }