Patch Detail
Show a patch.
GET /api/1.1/patches/21560/?format=api
{ "id": 21560, "url": "https://patchwork.libcamera.org/api/1.1/patches/21560/?format=api", "web_url": "https://patchwork.libcamera.org/patch/21560/", "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": "<20241009093303.2996819-2-chenghaoyang@chromium.org>", "date": "2024-10-09T09:26:39", "name": "[1/1] libcamera: mtkisp7: v4l2: Add a requestBufferReady signal", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b263928a765147b4c95851d9298c9c925083da49", "submitter": { "id": 117, "url": "https://patchwork.libcamera.org/api/1.1/people/117/?format=api", "name": "Cheng-Hao Yang", "email": "chenghaoyang@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/21560/mbox/", "series": [ { "id": 4672, "url": "https://patchwork.libcamera.org/api/1.1/series/4672/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4672", "date": "2024-10-09T09:26:38", "name": "Add requestBufferReady signal in V4L2VideoDevice", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4672/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/21560/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/21560/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 080FAC32DE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 9 Oct 2024 09:33:17 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AADCA6353B;\n\tWed, 9 Oct 2024 11:33:16 +0200 (CEST)", "from mail-pl1-x629.google.com (mail-pl1-x629.google.com\n\t[IPv6:2607:f8b0:4864:20::629])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 476FA6536C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 9 Oct 2024 11:33:14 +0200 (CEST)", "by mail-pl1-x629.google.com with SMTP id\n\td9443c01a7336-20c544d345cso5468005ad.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 09 Oct 2024 02:33:14 -0700 (PDT)", "from chenghaoyang-low.c.googlers.com.com\n\t(199.211.81.34.bc.googleusercontent.com. [34.81.211.199])\n\tby smtp.gmail.com with ESMTPSA id\n\td9443c01a7336-20c13939b27sm67313145ad.136.2024.10.09.02.33.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 09 Oct 2024 02:33:11 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"cpsOxVsr\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1728466392; x=1729071192;\n\tdarn=lists.libcamera.org; \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\t:message-id:reply-to;\n\tbh=VmCu62yS5Rb1RA+QKSraMXKAV3NXX4xRRST9jf3Qxkg=;\n\tb=cpsOxVsrpOitJQnZowp0uoTrTPwbLyweC2ZBnRjX/JRSdo4O4Olh09h2ENSERaKwSp\n\tLjqh1cG3yFzqBljxwMSgqH2QucpdYevbtMC0EDHlMUk36Shd6cYmmDIfpIayyrlhpAks\n\tx7uLHvJm8x0sPP2Z6l3U8hdbKxxai9Ikr+PSs=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1728466392; x=1729071192;\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:message-id:reply-to;\n\tbh=VmCu62yS5Rb1RA+QKSraMXKAV3NXX4xRRST9jf3Qxkg=;\n\tb=ve/JbQbc/0nN3Vp8gPLDqdh0xLOhA1Jzl6mwRD1FxdheoBqJckfYJU1Judab4W2I4+\n\tACo9AKw/9/dM2qRZMFxFW6pQtm73lTSNGrS5LWtST1Sz4FW43Pg3uFMu5x9Guyxhx2u8\n\tWUT0tQAXB7Z7dDPFK6umacZcBOIH0A51PwuNhyFdeL62OmIELRlUIHcA0sbcq7gyaALY\n\twR5A8S7V0ucu2nSzvDJOjvRXkeJID84sT6el/bmh+m9DHEKRv2YUdpHWfgZHBjwcZGvB\n\teQvaKr8RaE8HxDxeaDOGvPRvNLhyZbUJQl5E5M4VxvghLg2c4PXjEUj9neO7Dfawuv6z\n\tAirw==", "X-Gm-Message-State": "AOJu0YxsdjSCR6ERFM6J1NWui3mzskRTBiNt/uXkxQj6QDOarcWWYoYQ\n\tQ2maYYk2WLfg25IjQuzEqhPZah/fDgonKpNGEhZxnWT/Yc0G5snPtC5p1x4EhF15LGXsAQDQjYA\n\t=", "X-Google-Smtp-Source": "AGHT+IGnkPRhugvQWAC6Guzw4wz9LmTlY6qSqWXuRhCiwXndJHfUBmBvVLfaKuRJFL364+Wo0mC5vA==", "X-Received": "by 2002:a17:902:e749:b0:20b:5aeb:9b8 with SMTP id\n\td9443c01a7336-20c6352ed90mr32185005ad.24.1728466392080; \n\tWed, 09 Oct 2024 02:33:12 -0700 (PDT)", "From": "Harvey Yang <chenghaoyang@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Yunke Cao <yunkec@chromium.org>, Han-Lin Chen <hanlinchen@chromium.com>, \n\tHarvey Yang <chenghaoyang@chromium.org>", "Subject": "[PATCH 1/1] libcamera: mtkisp7: v4l2: Add a requestBufferReady\n\tsignal", "Date": "Wed, 9 Oct 2024 09:26:39 +0000", "Message-ID": "<20241009093303.2996819-2-chenghaoyang@chromium.org>", "X-Mailer": "git-send-email 2.47.0.rc0.187.ge670bccf7e-goog", "In-Reply-To": "<20241009093303.2996819-1-chenghaoyang@chromium.org>", "References": "<20241009093303.2996819-1-chenghaoyang@chromium.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "From: Yunke Cao <yunkec@chromium.org>\n\nWe will be adding a large number buffers for a single media request.\nMatching each single FrameBuffer against all the buffers will be an unnecessary\nhuge effort.\n\nAdd a new signal that emits both the frameBuffer and the mediaRequest,\nmatch the mediaRequest instead in IMGSYS.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.com>\nCo-developed-by: Yunke Cao <yunkec@chromium.org>\nSigned-off-by: Yunke Cao <yunkec@chromium.org>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n include/libcamera/internal/v4l2_videodevice.h | 3 +-\n src/libcamera/v4l2_videodevice.cpp | 33 ++++++++++++++-----\n 2 files changed, 26 insertions(+), 10 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex f021c2a01..c44e9e9c7 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -220,6 +220,7 @@ public:\n \n \tint queueBuffer(FrameBuffer *buffer);\n \tSignal<FrameBuffer *> bufferReady;\n+\tSignal<std::pair<FrameBuffer *, int>> requestBufferReady;\n \n \tint streamOn();\n \tint streamOff();\n@@ -265,7 +266,7 @@ private:\n \tUniqueFD exportDmabufFd(unsigned int index, unsigned int plane);\n \n \tvoid bufferAvailable();\n-\tFrameBuffer *dequeueBuffer();\n+\tstd::pair<FrameBuffer *, int> dequeueBuffer();\n \n \tvoid watchdogExpired();\n \ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 14eba0561..5a1648602 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1773,18 +1773,23 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer)\n *\n * When this slot is called, a Buffer has become available from the device, and\n * will be emitted through the bufferReady Signal.\n+ * If the buffer is queued with a media Request, emit a requestBufferReady\n+ * signal.\n *\n * For Capture video devices the FrameBuffer will contain valid data.\n * For Output video devices the FrameBuffer can be considered empty.\n */\n void V4L2VideoDevice::bufferAvailable()\n {\n-\tFrameBuffer *buffer = dequeueBuffer();\n+\tauto [buffer, mediaRequest] = dequeueBuffer();\n \tif (!buffer)\n \t\treturn;\n \n \t/* Notify anyone listening to the device. */\n \tbufferReady.emit(buffer);\n+\n+\tif (mediaRequest > 0)\n+\t\trequestBufferReady.emit({ buffer, mediaRequest });\n }\n \n /**\n@@ -1793,9 +1798,12 @@ void V4L2VideoDevice::bufferAvailable()\n * This function dequeues the next available buffer from the device. If no\n * buffer is available to be dequeued it will return nullptr immediately.\n *\n- * \\return A pointer to the dequeued buffer on success, or nullptr otherwise\n+ * \\return A pair where the first element is a pointer to the dequeued buffer\n+ * on success, or nullptr otherwise. The second is the media request fd if\n+ * applicable\n+ *\n */\n-FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n+std::pair<FrameBuffer *, int> V4L2VideoDevice::dequeueBuffer()\n {\n \tstruct v4l2_buffer buf = {};\n \tstruct v4l2_plane planes[VIDEO_MAX_PLANES] = {};\n@@ -1815,7 +1823,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n \tif (ret < 0) {\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Failed to dequeue buffer: \" << strerror(-ret);\n-\t\treturn nullptr;\n+\t\treturn { nullptr, -1 };\n \t}\n \n \tLOG(V4L2, Debug) << \"Dequeuing buffer \" << buf.index;\n@@ -1837,7 +1845,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Dequeued unexpected buffer index \" << buf.index;\n \n-\t\treturn nullptr;\n+\t\treturn { nullptr, -1 };\n \t}\n \n \tcache_->put(buf.index);\n@@ -1866,7 +1874,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n \t\t\t + buf.timestamp.tv_usec * 1000ULL;\n \n \tif (V4L2_TYPE_IS_OUTPUT(buf.type))\n-\t\treturn buffer;\n+\t\treturn { buffer, buf.request_fd };\n \n \t/*\n \t * Detect kernel drivers which do not reset the sequence number to zero\n@@ -1896,7 +1904,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n \t\t\t\t<< \" != \" << buffer->planes().size() << \")\";\n \n \t\t\tmetadata.status = FrameMetadata::FrameError;\n-\t\t\treturn buffer;\n+\t\t\treturn { buffer, buf.request_fd };\n \t\t}\n \n \t\t/*\n@@ -1921,7 +1929,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n \t\t\t\t\t\t });\n \n \t\t\t\tmetadata.status = FrameMetadata::FrameError;\n-\t\t\t\treturn buffer;\n+\t\t\t\treturn { buffer, buf.request_fd };\n \t\t\t}\n \n \t\t\tmetadata.planes()[i].bytesused =\n@@ -1940,7 +1948,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n \t\tmetadata.planes()[0].bytesused = buf.bytesused;\n \t}\n \n-\treturn buffer;\n+\treturn { buffer, buf.request_fd };\n }\n \n /**\n@@ -1948,6 +1956,12 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n * \\brief A Signal emitted when a framebuffer completes\n */\n \n+/**\n+ * \\var V4L2VideoDevice::requestBufferReady\n+ * \\brief A Signal emitted when a framebuffer completes, which includes both the\n+ * frameBuffer and the media request fd.\n+ */\n+\n /**\n * \\brief Start the video stream\n * \\return 0 on success or a negative error code otherwise\n@@ -2012,6 +2026,7 @@ int V4L2VideoDevice::streamOff()\n \t\tcache_->put(it.first);\n \t\tmetadata.status = FrameMetadata::FrameCancelled;\n \t\tbufferReady.emit(buffer);\n+\t\trequestBufferReady.emit({ buffer, -1 });\n \t}\n \n \tASSERT(cache_->isEmpty());\n", "prefixes": [ "1/1" ] }