Show a patch.

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

{
    "id": 10618,
    "url": "https://patchwork.libcamera.org/api/patches/10618/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10618/",
    "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": "<20201208204441.9356-7-david.plowman@raspberrypi.com>",
    "date": "2020-12-08T20:44:41",
    "name": "[libcamera-devel,v3,6/6] src: ipa: raspberrypi: Move initial frame drop decision to AGC/AWB",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "4d94979ef773a7902f3744cafdff19c2e480cb9b",
    "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/10618/mbox/",
    "series": [
        {
            "id": 1515,
            "url": "https://patchwork.libcamera.org/api/series/1515/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1515",
            "date": "2020-12-08T20:44:35",
            "name": "Raspberry Pi AGC: initial frame drop count",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1515/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10618/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10618/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 BA8E6BDB21\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Dec 2020 20:44:52 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 84EE267E6F;\n\tTue,  8 Dec 2020 21:44:52 +0100 (CET)",
            "from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com\n\t[IPv6:2a00:1450:4864:20::52f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A918367F0B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Dec 2020 21:44:50 +0100 (CET)",
            "by mail-ed1-x52f.google.com with SMTP id q16so18975754edv.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Dec 2020 12:44:50 -0800 (PST)",
            "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tbe6sm18441471edb.29.2020.12.08.12.44.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Dec 2020 12:44:49 -0800 (PST)"
        ],
        "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=\"Z3cgVBkH\"; 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=XdEmnit+rjT7DnH9yrl+C0JlXKdX3fb/QjsepWpG/tE=;\n\tb=Z3cgVBkHSUy9aY0kQDP+aifbzn7/IY8H8WpGujdVK69QZb7GaOZPqkN2lBwzinTGep\n\tMTc5VOsBpWLfutTqdwGlzGgqpOcbx99AB78ftQSHY8h2vAq65AZLBnuueXCD5IdJYppT\n\tPGNfM+F6qryNsW9d9TXkXQ5HDk2Nf/r6lsgFE/r5YMLJf4/AePxN84U3b9GXV8zpzUaY\n\tDsNZWJQfN+wzNTXOyrKplLX0hyH4bdlsIGoo8QJw/M6YDw0W2b/WyqzVz52kqQ9NpSmE\n\trAHRyHWqdSUwUrUtCJuxLQj/JzXq6sxHUSsVvNRVriOOzRcN/N2OPIyyKVwJMHmJElD7\n\tTuuA==",
        "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=XdEmnit+rjT7DnH9yrl+C0JlXKdX3fb/QjsepWpG/tE=;\n\tb=mpAJT1bdT/3pElL27N60PE2YZmnWcjA8JSa4P+V6+AoUMGT3CXSjh8YsbXqCz1taoq\n\tB6bDQiAd5DvTCpchYwwC+ftX5OiO8qfTkJe5mqJamvWCCoAyqCliqxuBtaX+gwRJSDPq\n\te1xRnNeW5aTU4UclPTb+Q2xFhXjt1IRSqJYRChDFr+79l8nq7nZIKLOyZyslgsqmx+Gl\n\tcNIbvu0lk2GZw26CWS4B7H7Hutd8hVbKACrkTfXhbhIH+pxCjUpUcHRl/CRNHBNzmr+a\n\teppPd9wRfirLL4oNPoh/IeAMGN2voLMd10IhWS49ZUESEuP70xp1e3/iMiekJJx49Mvn\n\tgKeA==",
        "X-Gm-Message-State": "AOAM5307Q4R6ESZkdtKkbAv0HE67G/+2iEqPQeRngUfRCjA9XEVW1swl\n\tkDRLodeIbWeW+u849Q8mDyXu+qw9cyV+tvXK",
        "X-Google-Smtp-Source": "ABdhPJxJz/mT7ygHLT715uCKSlIAFp1G3ZmFKxLqUujpXs/hObqexjFLAGo/wpWwwmEYec8I/UQfNQ==",
        "X-Received": "by 2002:a50:875b:: with SMTP id 27mr26588440edv.24.1607460290050;\n\tTue, 08 Dec 2020 12:44:50 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  8 Dec 2020 20:44:41 +0000",
        "Message-Id": "<20201208204441.9356-7-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20201208204441.9356-1-david.plowman@raspberrypi.com>",
        "References": "<20201208204441.9356-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 6/6] src: ipa: raspberrypi: Move\n\tinitial frame drop decision to AGC/AWB",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Previously the CamHelper was returning the number of frames to drop\n(on account of AGC/AWB converging). This wasn't really appropriate,\nit's better for the algorithms to do it as they know how many frames\nthey might need.\n\nThe CamHelper::HideFramesStartup method should now just be returning\nthe number of frames to hide because they're bad/invalid in some way,\nnot worrying about the AGC/AWB. For many sensors, the correct value\nfor this is zero. But the ov5647 needs updating as it must return 2.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/raspberrypi/cam_helper.cpp        |  6 ++---\n src/ipa/raspberrypi/cam_helper_ov5647.cpp | 10 ++++++++\n src/ipa/raspberrypi/raspberrypi.cpp       | 28 +++++++++++++++++++++++\n 3 files changed, 41 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp\nindex c8ac3232..6efa0d7f 100644\n--- a/src/ipa/raspberrypi/cam_helper.cpp\n+++ b/src/ipa/raspberrypi/cam_helper.cpp\n@@ -82,10 +82,10 @@ bool CamHelper::SensorEmbeddedDataPresent() const\n unsigned int CamHelper::HideFramesStartup() const\n {\n \t/*\n-\t * By default, hide 6 frames completely at start-up while AGC etc. sort\n-\t * themselves out (converge).\n+\t * The number of frames when a camera first starts that shouldn't be\n+\t * displayed as they are invalid in some way.\n \t */\n-\treturn 6;\n+\treturn 0;\n }\n \n unsigned int CamHelper::HideFramesModeSwitch() const\ndiff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\nindex dc5d8275..0b841cd1 100644\n--- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n+++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp\n@@ -19,6 +19,7 @@ public:\n \tuint32_t GainCode(double gain) const override;\n \tdouble Gain(uint32_t gain_code) const override;\n \tvoid GetDelays(int &exposure_delay, int &gain_delay) const override;\n+\tunsigned int HideFramesStartup() const override;\n \tunsigned int HideFramesModeSwitch() const override;\n \tunsigned int MistrustFramesStartup() const override;\n \tunsigned int MistrustFramesModeSwitch() const override;\n@@ -54,6 +55,15 @@ void CamHelperOv5647::GetDelays(int &exposure_delay, int &gain_delay) const\n \tgain_delay = 2;\n }\n \n+unsigned int CamHelperOv5647::HideFramesStartup() const\n+{\n+\t/*\n+\t * On startup, we get a couple of under-exposed frames which\n+\t * we don't want shown.\n+\t */\n+\treturn 2;\n+}\n+\n unsigned int CamHelperOv5647::HideFramesModeSwitch() const\n {\n \t/*\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex ba63480e..8dd796ed 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -194,6 +194,34 @@ int IPARPi::start(const IPAOperationData &data, IPAOperationData *result)\n \tif (firstStart_) {\n \t\tdropFrame = helper_->HideFramesStartup();\n \t\tmistrustCount_ = helper_->MistrustFramesStartup();\n+\n+\t\t/*\n+\t\t * Query the AGC/AWB for how many frames they may take to\n+\t\t * converge sufficiently. Where these numbers are non-zero\n+\t\t * we must allow for the frames with bad statistics\n+\t\t * (mistrustCount_) that they won't see. But if zero (i.e.\n+\t\t * no convergence necessary), no frames need to be dropped.\n+\t\t */\n+\t\tunsigned int agcConvergenceFrames = 0;\n+\t\tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n+\t\t\tcontroller_.GetAlgorithm(\"agc\"));\n+\t\tif (agc) {\n+\t\t\tagcConvergenceFrames = agc->GetConvergenceFrames();\n+\t\t\tif (agcConvergenceFrames)\n+\t\t\t\tagcConvergenceFrames += mistrustCount_;\n+\t\t}\n+\n+\t\tunsigned int awbConvergenceFrames = 0;\n+\t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n+\t\t\tcontroller_.GetAlgorithm(\"awb\"));\n+\t\tif (awb) {\n+\t\t\tawbConvergenceFrames = awb->GetConvergenceFrames();\n+\t\t\tif (awbConvergenceFrames)\n+\t\t\t\tawbConvergenceFrames += mistrustCount_;\n+\t\t}\n+\n+\t\tdropFrame = std::max({ dropFrame, agcConvergenceFrames, awbConvergenceFrames });\n+\t\tLOG(IPARPI, Debug) << \"Drop \" << dropFrame << \" frames on startup\";\n \t} else {\n \t\tdropFrame = helper_->HideFramesModeSwitch();\n \t\tmistrustCount_ = helper_->MistrustFramesModeSwitch();\n",
    "prefixes": [
        "libcamera-devel",
        "v3",
        "6/6"
    ]
}