Patch Detail
Show a patch.
GET /api/1.1/patches/13045/?format=api
{ "id": 13045, "url": "https://patchwork.libcamera.org/api/1.1/patches/13045/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13045/", "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": "<20210719191438.189046-2-nfraprado@collabora.com>", "date": "2021-07-19T19:14:36", "name": "[libcamera-devel,1/3] libcamera: pipeline: vimc: Add internal request queue", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "d2e05e57c6820bdef6f0fde5a812a0338cdc1e9f", "submitter": { "id": 84, "url": "https://patchwork.libcamera.org/api/1.1/people/84/?format=api", "name": "Nícolas F. R. A. Prado", "email": "nfraprado@collabora.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13045/mbox/", "series": [ { "id": 2256, "url": "https://patchwork.libcamera.org/api/1.1/series/2256/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2256", "date": "2021-07-19T19:14:35", "name": "libcamera: pipeline: Add internal request queue", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2256/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13045/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13045/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 2D914C322B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Jul 2021 19:14:59 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ECE5068539;\n\tMon, 19 Jul 2021 21:14:58 +0200 (CEST)", "from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 239A368539\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Jul 2021 21:14:57 +0200 (CEST)", "from localhost.localdomain (unknown\n\t[IPv6:2804:14c:1a9:2434:2e2f:cb19:fca8:1dff])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits))\n\t(No client certificate requested) (Authenticated sender: nfraprado)\n\tby bhuna.collabora.co.uk (Postfix) with ESMTPSA id 949251F42E0E;\n\tMon, 19 Jul 2021 20:14:55 +0100 (BST)" ], "From": "=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 19 Jul 2021 16:14:36 -0300", "Message-Id": "<20210719191438.189046-2-nfraprado@collabora.com>", "X-Mailer": "git-send-email 2.32.0", "In-Reply-To": "<20210719191438.189046-1-nfraprado@collabora.com>", "References": "<20210719191438.189046-1-nfraprado@collabora.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 1/3] libcamera: pipeline: vimc: Add\n\tinternal request queue", "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>", "Cc": "kernel@collabora.com, =?utf-8?q?Andr=C3=A9_Almeida?=\n\t<andrealmeid@collabora.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add an internal queue that stores requests until there are V4L2 buffer\nslots available. This avoids the need to cancel requests when there is a\nshortage of said buffers.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n---\n src/libcamera/pipeline/vimc/vimc.cpp | 65 +++++++++++++++++++++++-----\n 1 file changed, 55 insertions(+), 10 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex a698427c4361..c9092bec9a74 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -9,6 +9,7 @@\n #include <iomanip>\n #include <map>\n #include <math.h>\n+#include <queue>\n #include <tuple>\n \n #include <linux/media-bus-format.h>\n@@ -53,6 +54,9 @@ public:\n \tint init();\n \tvoid bufferReady(FrameBuffer *buffer);\n \n+\tvoid queuePendingRequests();\n+\tvoid cancelPendingRequests();\n+\n \tMediaDevice *media_;\n \tstd::unique_ptr<CameraSensor> sensor_;\n \tstd::unique_ptr<V4L2Subdevice> debayer_;\n@@ -62,6 +66,8 @@ public:\n \tStream stream_;\n \n \tstd::unique_ptr<ipa::vimc::IPAProxyVimc> ipa_;\n+\n+\tstd::queue<Request *> pendingRequests_;\n };\n \n class VimcCameraConfiguration : public CameraConfiguration\n@@ -94,9 +100,9 @@ public:\n \n \tbool match(DeviceEnumerator *enumerator) override;\n \n-private:\n \tint processControls(VimcCameraData *data, Request *request);\n \n+private:\n \tVimcCameraData *cameraData(const Camera *camera)\n \t{\n \t\treturn static_cast<VimcCameraData *>(\n@@ -335,6 +341,7 @@ int PipelineHandlerVimc::start(Camera *camera, [[maybe_unused]] const ControlLis\n void PipelineHandlerVimc::stop(Camera *camera)\n {\n \tVimcCameraData *data = cameraData(camera);\n+\tdata->cancelPendingRequests();\n \tdata->video_->streamOff();\n \tdata->ipa_->stop();\n \tdata->video_->releaseBuffers();\n@@ -383,21 +390,16 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n int PipelineHandlerVimc::queueRequestDevice(Camera *camera, Request *request)\n {\n \tVimcCameraData *data = cameraData(camera);\n-\tFrameBuffer *buffer = request->findBuffer(&data->stream_);\n-\tif (!buffer) {\n+\n+\tif (!request->findBuffer(&data->stream_)) {\n \t\tLOG(VIMC, Error)\n \t\t\t<< \"Attempt to queue request with invalid stream\";\n \n \t\treturn -ENOENT;\n \t}\n \n-\tint ret = processControls(data, request);\n-\tif (ret < 0)\n-\t\treturn ret;\n-\n-\tret = data->video_->queueBuffer(buffer);\n-\tif (ret < 0)\n-\t\treturn ret;\n+\tdata->pendingRequests_.push(request);\n+\tdata->queuePendingRequests();\n \n \treturn 0;\n }\n@@ -531,6 +533,49 @@ void VimcCameraData::bufferReady(FrameBuffer *buffer)\n \n \tpipe_->completeBuffer(request, buffer);\n \tpipe_->completeRequest(request);\n+\n+\tqueuePendingRequests();\n+}\n+\n+void VimcCameraData::queuePendingRequests()\n+{\n+\tPipelineHandlerVimc *pipe = static_cast<PipelineHandlerVimc *>(pipe_);\n+\n+\twhile (!pendingRequests_.empty()) {\n+\t\tRequest *request = pendingRequests_.front();\n+\t\tFrameBuffer *buffer = request->findBuffer(&stream_);\n+\n+\t\tint ret = pipe->processControls(this, request);\n+\t\tif (ret < 0) {\n+\t\t\tbuffer->cancel();\n+\t\t\tpipe_->completeBuffer(request, buffer);\n+\t\t\tpipe_->completeRequest(request);\n+\t\t\tpendingRequests_.pop();\n+\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\t/* If we're missing V4L2 buffer slots, try again later */\n+\t\tret = video_->queueBuffer(buffer);\n+\t\tif (ret < 0)\n+\t\t\tbreak;\n+\n+\t\tpendingRequests_.pop();\n+\t}\n+}\n+\n+void VimcCameraData::cancelPendingRequests()\n+{\n+\twhile (!pendingRequests_.empty()) {\n+\t\tRequest *request = pendingRequests_.front();\n+\t\tFrameBuffer *buffer = request->findBuffer(&stream_);\n+\n+\t\tbuffer->cancel();\n+\t\tpipe_->completeBuffer(request, buffer);\n+\t\tpipe_->completeRequest(request);\n+\n+\t\tpendingRequests_.pop();\n+\t}\n }\n \n REGISTER_PIPELINE_HANDLER(PipelineHandlerVimc)\n", "prefixes": [ "libcamera-devel", "1/3" ] }