Patch Detail
Show a patch.
GET /api/1.1/patches/17279/?format=api
{ "id": 17279, "url": "https://patchwork.libcamera.org/api/1.1/patches/17279/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17279/", "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": "<20220902120808.842-7-naush@raspberrypi.com>", "date": "2022-09-02T12:08:08", "name": "[libcamera-devel,v1,6/6] ipa: raspberrypi: agc: Fix digital gain calculation for manual mode", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a788fb6f5712ca46ca629897c275607579ad195b", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17279/mbox/", "series": [ { "id": 3459, "url": "https://patchwork.libcamera.org/api/1.1/series/3459/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3459", "date": "2022-09-02T12:08:02", "name": "Raspberry Pi AGC digial gain fixes", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3459/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17279/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17279/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 5CB89C327E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 2 Sep 2022 12:08:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 07F4E61FDD;\n\tFri, 2 Sep 2022 14:08:24 +0200 (CEST)", "from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com\n\t[IPv6:2a00:1450:4864:20::42c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 31A7C61FDE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 2 Sep 2022 14:08:21 +0200 (CEST)", "by mail-wr1-x42c.google.com with SMTP id az27so2047914wrb.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 02 Sep 2022 05:08:21 -0700 (PDT)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th2-20020a5d4302000000b0021e51c039c5sm1397809wrq.80.2022.09.02.05.08.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 02 Sep 2022 05:08:19 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662120504;\n\tbh=zws5OoSrDMBlk0wAhq+tw+ujsBf5kF6gB6btg7hIiA8=;\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=EuBwoxlPMSOu0aQnopvn9YcmTkA14LC1IF7nwTko+pRVYownaHWT54cAw0IlrVvu1\n\tVhCW+5OkTSGq53C3Z+wGTtLYSJerbGz/EIlJrplpURxAgGqRnBpTxaSSJq/wx7jFN7\n\tOMfi3s5izfVynUQE5+MB957BPMFEKKEZybmEWhyjFs0cs4pprgeq7X7HHnEI0jS2Aj\n\tiwl+TfcJ1DOSzJYFVqt3GKz4GzgDBW/UP7gHClJyX1RGaDBUy5Sp3pvlJm3SheET4K\n\tAYTuw0/Zf+f15L6eo45izEBkrn3kserutsToSQqE2krMrdSUi9txhpSeUawWK/7AUM\n\tqRlvNqH3WN/Bg==", "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\tbh=PWHtvpbu5t7AV24xAifkrTb/5HFHtuUs1P0hdp1Tv9c=;\n\tb=cZwpeiDDZrVE6wC24h8oYZd4GJmJiTm1/YcfCX9PeY7ZsI2e+qUYkOMrWLfoJIjNog\n\tqOg4186+xjqnhiQbXR43FW6vGByB7Kd1vPw8K+frtPoKn5s5YwQfNHoAn2rv1PwG7GO6\n\tlaZwXjPxKLaaDPD5R96c/46zzlB07owk3LBPQd6UwT8f+AR4pXCiXmU2nlaH+Gpow5hS\n\tTbpBb0KzRIVoyX7G+s+3J+xHM6+JpGC8KYtgiM1dD1pO9xMPC4XsRzMlWXQfOUCDTLgf\n\tG7QlRbBnrW+XgCXRZvtq7AKR7PByMatjNstC2zUGiHW0bXi2D3m1xIadD4ss4hLej9lH\n\tvahw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"cZwpeiDD\"; 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;\n\tbh=PWHtvpbu5t7AV24xAifkrTb/5HFHtuUs1P0hdp1Tv9c=;\n\tb=C1cYmxllhroYwCH64MjlH85W1xJct5aa+5KKonQk0wzcaFPI5eOyJdargs1LC9ZVNG\n\tdN4XssDmPdGHKaqgUCojmjbdfjQuf6WzTjQfj2fV5vkDvBms+QL0fqKItv+gwOUmv2sF\n\tqC+zeL8mRj5DpPAbkRT/9p5NlpfFhQ5OfkaGPETf+9v9SLy2GNvuSzRwqNwKwI565j3a\n\tzJbi+beMsGOf8PNjXSXWfGAIE1+nCeuHLBcTUtplvu2qagNLt8Nx3a0XalzxNHjDWv90\n\tjKgcHALKQ4xQL9JbqcEc0k9xjQgXatH06/WGUBRcBkCLqSlijyD9GyoV5a8RI74Ivk6E\n\teqQQ==", "X-Gm-Message-State": "ACgBeo2cvVNX7T6oCLg9k5NX/ovsFJVnVQOxgYn8kZ0o7EDLFqmpPVpP\n\tm/Hww3gZSWA75Xx4809HDl/VDKZnwfbmHmXE", "X-Google-Smtp-Source": "AA6agR6eaCW65rP7JkR5+Fo6Zm4qDHZaIoP1eLZ18mVPG/i5gjDtnUGz1JOvRRpobCq70TKfD9KciQ==", "X-Received": "by 2002:a05:6000:2a8:b0:226:e711:67f5 with SMTP id\n\tl8-20020a05600002a800b00226e71167f5mr9711480wry.359.1662120500614; \n\tFri, 02 Sep 2022 05:08:20 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 2 Sep 2022 13:08:08 +0100", "Message-Id": "<20220902120808.842-7-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220902120808.842-1-naush@raspberrypi.com>", "References": "<20220902120808.842-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v1 6/6] 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>\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 3faa3d490606..0c057f2689cc 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -1025,6 +1025,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.ipaCookie];\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", "v1", "6/6" ] }