Patch Detail
Show a patch.
GET /api/patches/15476/?format=api
{ "id": 15476, "url": "https://patchwork.libcamera.org/api/patches/15476/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15476/", "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": "<20220317140827.1835029-7-naush@raspberrypi.com>", "date": "2022-03-17T14:08:27", "name": "[libcamera-devel,v2,6/6] libcamera: v4l2_videodevice: Empty the V4L2 buffer cache on streamOff()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "410257105047434d75e8289b9623c54c64e26147", "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/15476/mbox/", "series": [ { "id": 2972, "url": "https://patchwork.libcamera.org/api/series/2972/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2972", "date": "2022-03-17T14:08:21", "name": "Raspberry Pi: Efficient start/stop/start sequences", "version": 2, "mbox": "https://patchwork.libcamera.org/series/2972/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15476/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15476/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\r\n\t[92.243.16.209])\r\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 18AD8C3264\r\n\tfor <parsemail@patchwork.libcamera.org>;\r\n\tThu, 17 Mar 2022 14:08:41 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C8A7F632EC;\r\n\tThu, 17 Mar 2022 15:08:40 +0100 (CET)", "from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com\r\n\t[IPv6:2a00:1450:4864:20::42e])\r\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D4A48632E6\r\n\tfor <libcamera-devel@lists.libcamera.org>;\r\n\tThu, 17 Mar 2022 15:08:37 +0100 (CET)", "by mail-wr1-x42e.google.com with SMTP id u10so7524542wra.9\r\n\tfor <libcamera-devel@lists.libcamera.org>;\r\n\tThu, 17 Mar 2022 07:08:37 -0700 (PDT)", "from naush-laptop.pitowers.org\r\n\t([2a00:1098:3142:14:371b:8e01:111f:5322])\r\n\tby smtp.gmail.com with ESMTPSA id\r\n\tz5-20020a05600c0a0500b0037fa93193a8sm5287831wmp.44.2022.03.17.07.08.36\r\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\r\n\tThu, 17 Mar 2022 07:08:36 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\r\n\ts=mail; t=1647526120;\r\n\tbh=Y82iiUEJJo6jzF5KeFHe8+WlpcmdbOvrdS0L5r4/L2g=;\r\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\r\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\r\n\tFrom;\r\n\tb=gcAI3qjDpD6hbkXDzSoUZLkCcpRPXVcPb9YWM7bJHiL5g0QEnRYxSitkWIDnwkDfv\r\n\tLVUNOW8PccHO/W3aQp0ztowMfd6CXhETN0BYM46CvBR0MT7dhc6JWuFWXn+ZRUoDgM\r\n\tuergrUqBtVZVFyPCctDDYmJcAXPru7YkU5K+U/NbYxshy1hxQzfb6MK1qLaHO0f5uz\r\n\ti5I2iwLgZu7I7bs0uy1JGZm+cspaqHOs0CL9zO2XRcSDlNe9f5d/hJ0bHI4KQJF5tV\r\n\trRZEf+HbAx5pCqd11c20SOERy35Z/KH7mlIHf/Zqq7X6a8yuiQjjrl/hLNVbJvizoq\r\n\tHv5LdWmdPwldA==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n\td=raspberrypi.com; s=google;\r\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\r\n\t:mime-version:content-transfer-encoding;\r\n\tbh=QA3Po4T5fYY/+GjRjk1tO1oLz80EHEdU9NtOOneB35c=;\r\n\tb=lqaOCxgdmHWzlpwF8s+fQi9xBt+4+pyvDScYb5BZ/4u9I2LZGrN1oYOKOXdinkVJE4\r\n\tJvLuPS+Nk+7K2ehoM8sYRdxcS6cNGqM6nOcsjXYSlkueQ8eMcb2vA4J/Crd8jSt8Rr6y\r\n\tIDS/LhYT5CwLBDQgEZsV3jOCmWzuNmffOVNHHmWjGHmzfk3lK18tSReRuc1EbtvHHD5J\r\n\tyiIK18u7480Z0xOOhLbJpP290M+NuATNvXMVGYoINenuFdV2KpXDdzlvlkDJtbKDJe/k\r\n\tySGeELsmX5pEbC70EGH9u8qMJ4oFy0ZkTu+UAG4Us0SeDh+WM92WJKrF7dgn5JJk1Sth\r\n\tkGsA==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \r\n\tunprotected) header.d=raspberrypi.com\r\n\theader.i=@raspberrypi.com\r\n\theader.b=\"lqaOCxgd\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\r\n\td=1e100.net; s=20210112;\r\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r\n\t:references:mime-version:content-transfer-encoding;\r\n\tbh=QA3Po4T5fYY/+GjRjk1tO1oLz80EHEdU9NtOOneB35c=;\r\n\tb=5oYggDB6uYdkACuqqF/6Mr8CLqIl0FPepYuBiPmIf2XYrmNRzGDzGQiSAOlx1Si1eb\r\n\tlRwjTdeKajbGbFVNr+sXOf2hkW3oL1CKB0dgpgyOxd54HasAh9Cp14XAQKgbP4qLMgWu\r\n\tGI4eshT2YskRsmXwTVWH1HA+dmpVpdD4iZr52bMJkln9glNI4knNb7p9vNgCPYDI3obB\r\n\tvyfJ83TgWEN9vR6RnBVyIWEWI+MF3J55WU08BlzqLRkHGd7oWaFWtxZSkVjZJypPzVAk\r\n\tzL+1/EGabEG0umAgMvKbcgXQqtumgT68KZ2lZF4VAL3Ala/KcpfjuI/DiVlGjvUiBdO9\r\n\t6gFw==", "X-Gm-Message-State": "AOAM532On3EFS13qUkU6QVTod9E8M+IWWibh1RclLJMUXnnPywEvlfZX\r\n\t5ozD8m5pBa/Jq6xUgF0Tu5J2YaxSgINlRg==", "X-Google-Smtp-Source": "ABdhPJzudLNbX4j7rMGyPo6Nkzk+nNl8AUraXgS8Xl6wtVkwmYXiGUhGWYZYAlXYROnw8g5H+I3Euw==", "X-Received": "by 2002:a05:6000:381:b0:203:84bf:3faa with SMTP id\r\n\tu1-20020a056000038100b0020384bf3faamr4242565wrf.324.1647526117363; \r\n\tThu, 17 Mar 2022 07:08:37 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 17 Mar 2022 14:08:27 +0000", "Message-Id": "<20220317140827.1835029-7-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220317140827.1835029-1-naush@raspberrypi.com>", "References": "<20220317140827.1835029-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 6/6] libcamera: v4l2_videodevice: Empty\r\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>,\r\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>,\r\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "From": "Naushir Patuck via libcamera-devel\r\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 entires 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>\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\r\nindex 2d2ccc477c91..37747c0b2f27 100644\r\n--- a/include/libcamera/internal/v4l2_videodevice.h\r\n+++ b/include/libcamera/internal/v4l2_videodevice.h\r\n@@ -126,6 +126,7 @@ public:\r\n \r\n \tint get(const FrameBuffer &buffer);\r\n \tvoid put(unsigned int index);\r\n+\tbool isEmpty() const;\r\n \r\n private:\r\n \tclass Entry\r\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\r\nindex 5f36ee20710d..9da82697e7f0 100644\r\n--- a/src/libcamera/v4l2_videodevice.cpp\r\n+++ b/src/libcamera/v4l2_videodevice.cpp\r\n@@ -262,6 +262,19 @@ void V4L2BufferCache::put(unsigned int index)\r\n \tcache_[index].free_ = true;\r\n }\r\n \r\n+/**\r\n+ * \\brief Check if all the entries in the cache are unused\r\n+ */\r\n+bool V4L2BufferCache::isEmpty() const\r\n+{\r\n+\tfor (auto const &entry : cache_) {\r\n+\t\tif (!entry.free_)\r\n+\t\t\treturn false;\r\n+\t}\r\n+\r\n+\treturn true;\r\n+}\r\n+\r\n V4L2BufferCache::Entry::Entry()\r\n \t: free_(true), lastUsed_(0)\r\n {\r\n@@ -1832,10 +1845,13 @@ int V4L2VideoDevice::streamOff()\r\n \tfor (auto it : queuedBuffers_) {\r\n \t\tFrameBuffer *buffer = it.second;\r\n \r\n+\t\tcache_->put(it.first);\r\n \t\tbuffer->metadata_.status = FrameMetadata::FrameCancelled;\r\n \t\tbufferReady.emit(buffer);\r\n \t}\r\n \r\n+\tASSERT(cache_->isEmpty());\r\n+\r\n \tqueuedBuffers_.clear();\r\n \tfdBufferNotifier_->setEnabled(false);\r\n \tstreaming_ = false;", "prefixes": [ "libcamera-devel", "v2", "6/6" ] }