Show a patch.

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

{
    "id": 15504,
    "url": "https://patchwork.libcamera.org/api/patches/15504/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15504/",
    "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": "<20220322092257.2713521-8-naush@raspberrypi.com>",
    "date": "2022-03-22T09:22:56",
    "name": "[libcamera-devel,v4,7/8] libcamera: v4l2_videodevice: Empty the V4L2 buffer cache on streamOff()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "e7fa881c0358ac6df00af49cf896672dc0184a05",
    "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/15504/mbox/",
    "series": [
        {
            "id": 2982,
            "url": "https://patchwork.libcamera.org/api/series/2982/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2982",
            "date": "2022-03-22T09:22:49",
            "name": "Raspberry Pi: Efficient start/stop/start sequences",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/2982/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15504/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15504/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 74255C3266\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Mar 2022 09:23:10 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0A095604E9;\n\tTue, 22 Mar 2022 10:23:10 +0100 (CET)",
            "from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 20DD4632E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Mar 2022 10:23:06 +0100 (CET)",
            "by mail-wm1-x32b.google.com with SMTP id\n\tm26-20020a05600c3b1a00b0038c8b999f58so1033279wms.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Mar 2022 02:23:06 -0700 (PDT)",
            "from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:9e9a:99af:e5a6:319b])\n\tby smtp.gmail.com with ESMTPSA id\n\tr14-20020a05600c35ce00b0038c9f469979sm1471695wmq.40.2022.03.22.02.23.04\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Mar 2022 02:23:05 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647940990;\n\tbh=kfT4ZWkCPG3/gdZFNdt4nHwbshCKHdwdNoIP/9MpcQo=;\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=KdcIFFaJg/Ye3SeZBBuqFnmZtgei1ezxNcLix2igg5wLBit3QJaZNVouts3puL+f3\n\tqJ9RU0HGaGlsFbPRWaE26sq14SIAX46399WKW17JvUp22SQzpzevkOxI0ow3dcD/dN\n\tZ90yZ+1axuDgCT9UWurRC+XHYvkLjuwtjvvz5ovTF3SBZiMUA/zSnqGC63R9k6QKMh\n\tiUaGJp0yylR+pDG69+cDY3PQMuK4QEIgdjwLjY/ycnwYUuzLbpP0jZDlKhg4entJ0K\n\t8obfoRS4KO9qRR8gVm/Xytlv6HEV49+v8JQKWHPlHnmei2kalKGq9qy+Af2kbRoIWp\n\toCENUQN7AYv4g==",
            "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=TdgSbJYfrkGKhFpU5Csv2hwqt6vlahDqMHurCng86MM=;\n\tb=DbbwHCmYLyz/BFn+zYVIYC/ai9PJfZRRla5bZXCIII4iUCJRjExAZUdmtRzRv8GvzG\n\tOTQFktlF1mLJRYY0T5Vt5F7tL/cOnICdSrYtDHwFd+1SLBIRD8FUgakH/xMLdzSQiiNt\n\tlHGVAneleOk12bZRR3CA79sp7Z4EbHrjhAl7iaEOFSDN6AmnALZiBkmlld9oq7r5SkxY\n\tQ4Q+8xfv0M1ge4ramwAsZLSmsYRfHGiXMNpiS0H+2BO29EcIfX7Xkuid0+aFtMvdM26h\n\tqZoYxeOAIdtvHCZhmbcyDWhx3uTrRxTnAShHYO9ePj5eO2kzXDJojSU2tf0N1mk72RDv\n\tOWBA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"DbbwHCmY\"; dkim-atps=neutral",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=TdgSbJYfrkGKhFpU5Csv2hwqt6vlahDqMHurCng86MM=;\n\tb=UsWoWX4c3befrl7SVgOEhe4uocOOPjaUs3MAf125TuvIbVY4knQjz27L/aBJKfyLWH\n\tS4JrMn0SNn0kpporRaUkBsZ57qw3zptS5i2TFmreW74KT3iA6VUTFWDRWcpgKQ2xasdi\n\tIrfRrMMvchdOSrjUtesTMkFzs+1Y26644Kg+DwK2cXS5DXrrZPI88nTMfHUwsKcADAgv\n\taR/VCjl64a8DOEkcoEo9s9LYPujR2BPdAgXk91b+w0A5qvFbAI/TbyddfkvWdrRy4GpI\n\tBoBM08MBFi4feoIugCalKfkmzPXY/7NTAo4OvQUXce+EuBo/CIAK4nnNfjy1uabECeck\n\tc7EQ==",
        "X-Gm-Message-State": "AOAM5310UjhP9kwZBAgns94MExsd7l5Suan+0ayBlvO9CW+F4orX27TO\n\tlcmT9IXUK6+hAQCHtua9Z7NEoysjBS0Gqw==",
        "X-Google-Smtp-Source": "ABdhPJzbDNnj7MqqKrq3iGw0zqRPh0kul1HrO7Ep96KVUpUOVnWNvFtpXQb1ucyHygh+hTPKjBX9NQ==",
        "X-Received": "by 2002:a05:600c:2244:b0:38c:a3ff:ef67 with SMTP id\n\ta4-20020a05600c224400b0038ca3ffef67mr2694603wmm.122.1647940985582; \n\tTue, 22 Mar 2022 02:23:05 -0700 (PDT)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 22 Mar 2022 09:22:56 +0000",
        "Message-Id": "<20220322092257.2713521-8-naush@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220322092257.2713521-1-naush@raspberrypi.com>",
        "References": "<20220322092257.2713521-1-naush@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 7/8] libcamera: v4l2_videodevice: Empty\n\tthe V4L2 buffer cache on streamOff()",
        "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": "When streamOff() is called, ensure the cache entries for the remaining queued\nbuffers are freed since this will not happen via the dequeueBuffer() mechanism.\n\nAdditionally, add a V4L2BufferCache::isEmpty() function and assert that the\ncache is empty at the end of the streamOff() call.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_videodevice.h |  1 +\n src/libcamera/v4l2_videodevice.cpp            | 16 ++++++++++++++++\n 2 files changed, 17 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 32e022543385..60d62212bfe1 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -124,6 +124,7 @@ public:\n \tV4L2BufferCache(const std::vector<std::unique_ptr<FrameBuffer>> &buffers);\n \t~V4L2BufferCache();\n \n+\tbool isEmpty() const;\n \tint get(const FrameBuffer &buffer);\n \tvoid put(unsigned int index);\n \ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 1516be129d73..a384de7507ba 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -201,6 +201,19 @@ V4L2BufferCache::~V4L2BufferCache()\n \t\tLOG(V4L2, Debug) << \"Cache misses: \" << missCounter_;\n }\n \n+/**\n+ * \\brief Check if all the entries in the cache are unused\n+ */\n+bool V4L2BufferCache::isEmpty() const\n+{\n+\tfor (auto const &entry : cache_) {\n+\t\tif (!entry.free_)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\n+\n /**\n  * \\brief Find the best V4L2 buffer for a FrameBuffer\n  * \\param[in] buffer The FrameBuffer\n@@ -1842,10 +1855,13 @@ int V4L2VideoDevice::streamOff()\n \tfor (auto it : queuedBuffers_) {\n \t\tFrameBuffer *buffer = it.second;\n \n+\t\tcache_->put(it.first);\n \t\tbuffer->metadata_.status = FrameMetadata::FrameCancelled;\n \t\tbufferReady.emit(buffer);\n \t}\n \n+\tASSERT(cache_->isEmpty());\n+\n \tqueuedBuffers_.clear();\n \tfdBufferNotifier_->setEnabled(false);\n \tstate_ = State::Stopped;\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "7/8"
    ]
}