Patch Detail
Show a patch.
GET /api/patches/17632/?format=api
{ "id": 17632, "url": "https://patchwork.libcamera.org/api/patches/17632/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17632/", "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": "<20221019090107.19975-8-naush@raspberrypi.com>", "date": "2022-10-19T09:01:07", "name": "[libcamera-devel,v4,7/7] ipa: raspberrypi: agc: Fix digital gain calculation for manual mode", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4591deb984cb911dd9cf0e613b528d4443769b20", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17632/mbox/", "series": [ { "id": 3566, "url": "https://patchwork.libcamera.org/api/series/3566/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3566", "date": "2022-10-19T09:01:00", "name": "Raspberry Pi AGC digital gain fixes", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3566/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17632/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17632/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 42B3AC3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 19 Oct 2022 09:01:28 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C0D2E62E58;\n\tWed, 19 Oct 2022 11:01:27 +0200 (CEST)", "from mail-wr1-x431.google.com (mail-wr1-x431.google.com\n\t[IPv6:2a00:1450:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5ED5F62E46\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 11:01:24 +0200 (CEST)", "by mail-wr1-x431.google.com with SMTP id j7so28002922wrr.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 19 Oct 2022 02:01:24 -0700 (PDT)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tr9-20020a05600c458900b003b47b913901sm1017595wmo.1.2022.10.19.02.01.22\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 19 Oct 2022 02:01:23 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1666170087;\n\tbh=/6GhMhetbOE+yc09yQxkOk8kZ5IJvoL23EuHpX7OmxE=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=ggKxW1RMVvTDOuEItjnRAUUgYY4A9GSX3+3Bzb87f5RbrlYmcFFKB4Az5Zh4qXaUm\n\tPmK6gM/VQRGcVBI+sM3jbwTil8MeKhPGI/AehQHia/abOkWWCd/O2+eD6wkUAyiSFe\n\tFjmGRHdEfgfTNY7HGssY6Gb7nT3P0bhiMcixuBGtJGNiiIvbH+rskOXDIXS3bR6fgW\n\td4vW8dCvlThcIRw/4bYjhToDuHdZQDysp4vJGNnkerxrECgnywqw7g06E92K97tVkJ\n\tCZfEnVorjCumEri67vgrVyskn5pWq9evyEjon4eMmeqHMVG/1dnkPx5WeXdzZ94i/s\n\tASYpTSSXKVurg==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\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=Ti3vLKdKN85OxloaVfMzj8nn2D6wytryKDydft3JQig=;\n\tb=E0HutGw/ZZpDkjzo3R5CnjJ8lzl/WJc9vZIuxe2ouUZwlTg0e35zISBm99RAzcbtiq\n\tETtTGBRxGGtqakbpdYoDkcik49gmQ/Hxy7J8u9PSRR+l9Wpsbb/dob89AvMZqWhRaFa3\n\tXlKZP3iniiJLYIQj7YKYzCsDbbQbvy4GpJw05NtFyJ/R9poHYa3edAhnOYQeMdHU1CVi\n\tnIOUketKPvvatO1PjpKtI+m2RrDpqhnEnUGXNqEtuYg/jOAnG1g3rgtUS2bSk5+Vz0tU\n\tmoAIxlx5U+HhEQCGxXIbHj4TO+uunAOG3PwRKErcYanfiuiY2aDn4XX05FAsba/tdnr8\n\taVfg==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"E0HutGw/\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=Ti3vLKdKN85OxloaVfMzj8nn2D6wytryKDydft3JQig=;\n\tb=PHzwHcPkxnDbgfhIifhskBsL7TLzXNEP8PCUev/8GDLCffF9s+v007jWdeJFzmJoLv\n\tUDXCyti7Na19/1SAn8Nwsiu7xx5nlkAD4p1nhvTOkIcmBKZzUwE5QKgV552dNG7qFE6d\n\tvRuBJZdAE+VqNbo21QcY2V3EaQYDU2nK4lSDtcMoM6IfqJ48Zc3GydFMgCLtI0OE98qq\n\twTXdAvFoPHgjeJ6992AgPWxRn1vr7Ex+eOoa5IJnru+1ngRrzSJX0n054dRdpoSq/ANX\n\teF6/k3qvwoT0DW4iGGJ75k/gCbGSIHhRWdnJ/9yRWr+KpAzOSgHCmP8++G7FI5i8PAOe\n\tzCbg==", "X-Gm-Message-State": "ACrzQf0XJbHLP6592eJFyy/bD6uHAb7XHBG7z4iKIFG6VjAxyfQRAZX9\n\tq5f1/VdN9hn4Xc8Tf2q0O6KOqJhT8+RfYQ==", "X-Google-Smtp-Source": "AMsMyM7iuAQ/AxrLObElWL/I9hep7QaegpDEU1Vo3U399KIeqj9FRgAaYaCKiyQ47stcfBIyBLNKCA==", "X-Received": "by 2002:a5d:64a8:0:b0:22e:409f:a3cb with SMTP id\n\tm8-20020a5d64a8000000b0022e409fa3cbmr4285667wrp.168.1666170083803; \n\tWed, 19 Oct 2022 02:01:23 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 19 Oct 2022 10:01:07 +0100", "Message-Id": "<20221019090107.19975-8-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20221019090107.19975-1-naush@raspberrypi.com>", "References": "<20221019090107.19975-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 7/7] ipa: raspberrypi: agc: Fix digital\n\tgain calculation for manual mode", "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": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The digital gain calculation uses a total exposure value computed with the\ncurrent AGC state. However, this is wrong in the case of manual shutter/gain\ncontrols, as the total exposure value used must be the value computed when the\nAGC sent the manual shutter/gain controls to the pipeline handler to action.\n\nTo fix this, the IPA now adds the historical AgcStatus structure to the metadata\n(tagged with \"agc.delayed_status\"). This historical AgcStatus structure contains\nthe total exposure value calculated when the AGC sent the manual shutter/gain\ncontrols to the pipeline handler.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 10 ++++++++--\n src/ipa/raspberrypi/raspberrypi.cpp | 11 +++++++++++\n 2 files changed, 19 insertions(+), 2 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex bd54a639d637..b18bd7b5b19e 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -408,6 +408,12 @@ void Agc::switchMode(CameraMode const &cameraMode,\n \n void Agc::prepare(Metadata *imageMetadata)\n {\n+\tDuration totalExposureValue = status_.totalExposureValue;\n+\tAgcStatus delayedStatus;\n+\n+\tif (!imageMetadata->get(\"agc.delayed_status\", delayedStatus))\n+\t\ttotalExposureValue = delayedStatus.totalExposureValue;\n+\n \tstatus_.digitalGain = 1.0;\n \tfetchAwbStatus(imageMetadata); /* always fetch it so that Process knows it's been done */\n \n@@ -418,8 +424,8 @@ void Agc::prepare(Metadata *imageMetadata)\n \t\t\tDuration actualExposure = deviceStatus.shutterSpeed *\n \t\t\t\t\t\t deviceStatus.analogueGain;\n \t\t\tif (actualExposure) {\n-\t\t\t\tstatus_.digitalGain = status_.totalExposureValue / actualExposure;\n-\t\t\t\tLOG(RPiAgc, Debug) << \"Want total exposure \" << status_.totalExposureValue;\n+\t\t\t\tstatus_.digitalGain = totalExposureValue / actualExposure;\n+\t\t\t\tLOG(RPiAgc, Debug) << \"Want total exposure \" << totalExposureValue;\n \t\t\t\t/*\n \t\t\t\t * Never ask for a gain < 1.0, and also impose\n \t\t\t\t * some upper limit. Make it customisable?\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex aed8f68aded9..983745fcad98 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1029,6 +1029,17 @@ void IPARPi::prepareISP(const ISPConfig &data)\n \t\tembeddedBuffer = it->second.planes()[0];\n \t}\n \n+\t/*\n+\t * AGC wants to know the algorithm status from the time it actioned the\n+\t * sensor exposure/gain changes. So fetch it from the metadata list\n+\t * indexed by the IPA cookie returned, and put it in the current frame\n+\t * metadata.\n+\t */\n+\tAgcStatus agcStatus;\n+\tRPiController::Metadata &delayedMetadata = rpiMetadata_[data.delayCookie];\n+\tif (!delayedMetadata.get<AgcStatus>(\"agc.status\", agcStatus))\n+\t\trpiMetadata.set(\"agc.delayed_status\", agcStatus);\n+\n \t/*\n \t * This may overwrite the DeviceStatus using values from the sensor\n \t * metadata, and may also do additional custom processing.\n", "prefixes": [ "libcamera-devel", "v4", "7/7" ] }