Show a patch.

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

{
    "id": 10493,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10493/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10493/",
    "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": "<20201124175934.238358-1-naush@raspberrypi.com>",
    "date": "2020-11-24T17:59:34",
    "name": "[libcamera-devel] pipeline: raspberrypi: Fix erroneous bayer buffer requeue on buffer matching",
    "commit_ref": "c286b00aa1eb9331c3bab2b35905dcf2e4ccde66",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "99ad23a1bb490ce73c61ac54a7d8ebeacf59a6cc",
    "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/10493/mbox/",
    "series": [
        {
            "id": 1480,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1480/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1480",
            "date": "2020-11-24T17:59:34",
            "name": "[libcamera-devel] pipeline: raspberrypi: Fix erroneous bayer buffer requeue on buffer matching",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1480/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10493/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10493/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 4A988BE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 Nov 2020 18:00:20 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BA66F63404;\n\tTue, 24 Nov 2020 19:00:19 +0100 (CET)",
            "from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com\n\t[IPv6:2a00:1450:4864:20::32a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 46C20615AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Nov 2020 19:00:16 +0100 (CET)",
            "by mail-wm1-x32a.google.com with SMTP id 1so3799455wme.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Nov 2020 10:00:16 -0800 (PST)",
            "from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tb4sm7837855wmc.1.2020.11.24.10.00.14\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 24 Nov 2020 10:00:14 -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=\"H3MbiZGB\"; 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:mime-version\n\t:content-transfer-encoding;\n\tbh=1KEnbMAGlC/hMLbCIc6/64SDhdPwTO3l32TBGTeXeKo=;\n\tb=H3MbiZGB+jFJXlvi1dIM0pnEX6Nnt26HIli+auppZsc4oaEl1+53nQUBv4AgBoshNJ\n\taYypTgHQRyc6q2bYCnxt7wBum8AQrQWUaJB5g4S+lVRCuslHZU+IMJg8dHizRqRTpWx1\n\t+jz0zItAHpohIrjy9vM53PlfA5Kb0yttujZnsnsp4kqvs/1UHPJ+IVa+QNmlmDqvNlS5\n\tQHC/MinQCn4LyT9ZpwNC89L1PbbODKgb9W5z9B3JU7xrMTjZdqGFEDQwGDKFMc+zBKUr\n\t+896TGlwkStB7XSmfQ0/q9WwhT38IDbS3pwsahC1U8uak5CPBRZYsRA7WZHBMRFKQScS\n\txsgA==",
        "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:mime-version\n\t:content-transfer-encoding;\n\tbh=1KEnbMAGlC/hMLbCIc6/64SDhdPwTO3l32TBGTeXeKo=;\n\tb=Hx7PXIeElr2469GvQJFLXXy1YOAZ8TqgFbEDW4eGqGpEnmYEZuMkNqQTBGT+PTtRrG\n\thscbZvShG3T/fUXwKjSxbIwpW5Dkt7TEdzWDi2/q32YXl6uNGxo2sDWDi2AVyuSVuF19\n\tAbMFv0r/ovzbD3ddn0wbGJAUrxlAoJNkwpbmeblbr/n4RKJNVtzi+PdWsSHEhXFNS031\n\tNCxXKOeuRWpVdoK4P0PEz1E/pxFh3TrUghd9YvJBRwrgCJ5Wr6yGq/FAIpsojFWxhpLC\n\thSZFLJwYTmWPl7xIbZCDSiRT9JdDvUaQjkDa5iekrotqW1y5S6bQjJqzrQrGhxdsE9Fx\n\tgkwA==",
        "X-Gm-Message-State": "AOAM532c9aI8Y7bHNhcyyT20CqcdD9Q+mCIMokMlGsmb08m6qeQiv90W\n\tx4/GUFZAef/CR8GeMWekRExT88bn2mbRIw==",
        "X-Google-Smtp-Source": "ABdhPJxg6EIAXtIs7IlsGnjYE8mYTLG0bB5Q3letmQBKbWKLU1EQS4AaoeE6H45nx8qjqPjmFgsEBw==",
        "X-Received": "by 2002:a1c:6306:: with SMTP id x6mr6004123wmb.154.1606240815604;\n\tTue, 24 Nov 2020 10:00:15 -0800 (PST)",
        "From": "Naushir Patuck <naush@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 24 Nov 2020 17:59:34 +0000",
        "Message-Id": "<20201124175934.238358-1-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH] pipeline: raspberrypi: Fix erroneous\n\tbayer buffer requeue on buffer matching",
        "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": "With the recent change in the bayer/embedded buffer matching code,\na condition would make the bayer buffer be requeued back to the device,\neven though it could potentially be queued for matching. This would\ncause unnecessary frame drops as sync would be lost.\n\nThe fix is to ensure the bayer buffer only gets requeued if the embedded\ndata buffer queue is not empty, i.e. the buffer truly is orphaned.\nAdditionally, we do this test before deciding to flush any of the two\nqueues of all their buffers.\n\nFixes: 909882b (pipeline: raspberrypi: Rework bayer/embedded data buffer matching)\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n .../pipeline/raspberrypi/raspberrypi.cpp      | 38 +++++++++++--------\n 1 file changed, 23 insertions(+), 15 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 7271573a..fd306066 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1679,8 +1679,23 @@ bool RPiCameraData::findMatchingBuffers(FrameBuffer *&bayerBuffer, FrameBuffer *\n \t\t}\n \n \t\tif (!embeddedBuffer) {\n+\t\t\tbool flushedBuffers = false;\n+\n \t\t\tLOG(RPI, Debug) << \"Could not find matching embedded buffer\";\n \n+\t\t\tif (!embeddedQueue_.empty()) {\n+\t\t\t\t/*\n+\t\t\t\t * Not found a matching embedded buffer for the bayer buffer in\n+\t\t\t\t * the front of the queue. This buffer is now orphaned, so requeue\n+\t\t\t\t * it back to the device.\n+\t\t\t\t */\n+\t\t\t\tunicam_[Unicam::Image].queueBuffer(bayerQueue_.front());\n+\t\t\t\tbayerQueue_.pop();\n+\t\t\t\tbayerRequeueCount++;\n+\t\t\t\tLOG(RPI, Warning) << \"Dropping unmatched input frame in stream \"\n+\t\t\t\t\t\t  << unicam_[Unicam::Image].name();\n+\t\t\t}\n+\n \t\t\t/*\n \t\t\t * If we have requeued all available embedded data buffers in this loop,\n \t\t\t * then we are fully out of sync, so might as well requeue all the pending\n@@ -1695,20 +1710,9 @@ bool RPiCameraData::findMatchingBuffers(FrameBuffer *&bayerBuffer, FrameBuffer *\n \t\t\t\t\tunicam_[Unicam::Image].queueBuffer(bayerQueue_.front());\n \t\t\t\t\tbayerQueue_.pop();\n \t\t\t\t}\n-\t\t\t\treturn false;\n+\t\t\t\tflushedBuffers = true;\n \t\t\t}\n \n-\t\t\t/*\n-\t\t\t * Not found a matching embedded buffer for the bayer buffer in\n-\t\t\t * the front of the queue. This buffer is now orphaned, so requeue\n-\t\t\t * it back to the device.\n-\t\t\t */\n-\t\t\tunicam_[Unicam::Image].queueBuffer(bayerQueue_.front());\n-\t\t\tbayerQueue_.pop();\n-\t\t\tbayerRequeueCount++;\n-\t\t\tLOG(RPI, Warning) << \"Dropping unmatched input frame in stream \"\n-\t\t\t\t\t  << unicam_[Unicam::Image].name();\n-\n \t\t\t/*\n \t\t\t * Similar to the above, if we have requeued all available bayer buffers in\n \t\t\t * the loop, then we are fully out of sync, so might as well requeue all the\n@@ -1723,11 +1727,15 @@ bool RPiCameraData::findMatchingBuffers(FrameBuffer *&bayerBuffer, FrameBuffer *\n \t\t\t\t\tunicam_[Unicam::Embedded].queueBuffer(embeddedQueue_.front());\n \t\t\t\t\tembeddedQueue_.pop();\n \t\t\t\t}\n-\t\t\t\treturn false;\n+\t\t\t\tflushedBuffers = true;\n \t\t\t}\n \n-\t\t\t/* If the embedded queue has become empty, we cannot do any more. */\n-\t\t\tif (embeddedQueue_.empty())\n+\t\t\t/*\n+\t\t\t * If the embedded queue has become empty, we cannot do any more.\n+\t\t\t * Similarly, if we have flushed any one of our queues, we cannot do\n+\t\t\t * any more. Return from here without a buffer pair.\n+\t\t\t */\n+\t\t\tif (embeddedQueue_.empty() || flushedBuffers)\n \t\t\t\treturn false;\n \t\t} else {\n \t\t\t/*\n",
    "prefixes": [
        "libcamera-devel"
    ]
}