Patch Detail
Show a patch.
GET /api/patches/13236/?format=api
{ "id": 13236, "url": "https://patchwork.libcamera.org/api/patches/13236/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13236/", "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": "<20210805222436.6263-6-laurent.pinchart@ideasonboard.com>", "date": "2021-08-05T22:24:31", "name": "[libcamera-devel,05/10] libcamera: pipeline: simple: Store all entity devices in common map", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e037363ac34dad0d6cd6c51aadb3dae8fd9bcd7e", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13236/mbox/", "series": [ { "id": 2314, "url": "https://patchwork.libcamera.org/api/series/2314/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2314", "date": "2021-08-05T22:24:26", "name": "Concurrent camera support in simple pipeline handler", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2314/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13236/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13236/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 C2DACC323A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 5 Aug 2021 22:25:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 66E1968895;\n\tFri, 6 Aug 2021 00:25:00 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 655BD68822\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 6 Aug 2021 00:24:57 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E5A54FB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 6 Aug 2021 00:24:57 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VHxV8Dfp\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628202297;\n\tbh=tA70Jm1PhQtLiTq4CyO7ypsCxUHXhDkeVN832Xlpx54=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=VHxV8DfpUKQ6zhWRGxjaX/SH1w1ZmPXvH0qIQjfr3RHFlI2m/4ALhFii92P/GVt3p\n\tKT4V0FOEvtYL4ogk1fKwGvlIrIAN32Kr3CuCJpADazfX9Qt+DpVOKcqP+vDe7lWxma\n\tOtyrR5qTpyKNMzglnOXNCsqnsbOkJ1Iq5dqKPErI=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 6 Aug 2021 01:24:31 +0300", "Message-Id": "<20210805222436.6263-6-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.31.1", "In-Reply-To": "<20210805222436.6263-1-laurent.pinchart@ideasonboard.com>", "References": "<20210805222436.6263-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 05/10] libcamera: pipeline: simple: Store\n\tall entity devices in common map", "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": "Merge the SimplePipelineHandler videos_ and subdevs_ maps, which\nrespectively store V4L2 video devices and subdevices associated with\nentities, into a single entities_ map that contains an EntityData\nstructure. This gathers all data about entities in a single place,\nallowing for easy extension of entity data in the future.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 63 +++++++++++++-----------\n 1 file changed, 35 insertions(+), 28 deletions(-)", "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 99ecd640349c..6b808bfbe6fa 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -265,6 +265,11 @@ protected:\n private:\n \tstatic constexpr unsigned int kNumInternalBuffers = 3;\n \n+\tstruct EntityData {\n+\t\tstd::unique_ptr<V4L2VideoDevice> video;\n+\t\tstd::unique_ptr<V4L2Subdevice> subdev;\n+\t};\n+\n \tSimpleCameraData *cameraData(const Camera *camera)\n \t{\n \t\treturn static_cast<SimpleCameraData *>(\n@@ -278,8 +283,7 @@ private:\n \tvoid converterOutputDone(FrameBuffer *buffer);\n \n \tMediaDevice *media_;\n-\tstd::map<const MediaEntity *, std::unique_ptr<V4L2VideoDevice>> videos_;\n-\tstd::map<const MediaEntity *, V4L2Subdevice> subdevs_;\n+\tstd::map<const MediaEntity *, EntityData> entities_;\n \n \tstd::unique_ptr<SimpleConverter> converter_;\n \n@@ -1064,24 +1068,25 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \t\treturn false;\n \n \t/*\n-\t * Create and open V4L2Subdevice instances for all entities\n-\t * corresponding to a V4L2 subdevice.\n+\t * Insert all entities in the global entities list. Create and open\n+\t * V4L2Subdevice instances for each entity corresponding to a V4L2\n+\t * subdevice.\n \t */\n \tfor (MediaEntity *entity : entities) {\n-\t\tif (entity->type() != MediaEntity::Type::V4L2Subdevice)\n-\t\t\tcontinue;\n+\t\tstd::unique_ptr<V4L2Subdevice> subdev;\n \n-\t\tauto elem = subdevs_.emplace(std::piecewise_construct,\n-\t\t\t\t\t std::forward_as_tuple(entity),\n-\t\t\t\t\t std::forward_as_tuple(entity));\n-\t\tV4L2Subdevice *subdev = &elem.first->second;\n-\t\tint ret = subdev->open();\n-\t\tif (ret < 0) {\n-\t\t\tLOG(SimplePipeline, Error)\n-\t\t\t\t<< \"Failed to open \" << subdev->deviceNode()\n-\t\t\t\t<< \": \" << strerror(-ret);\n-\t\t\treturn false;\n+\t\tif (entity->type() == MediaEntity::Type::V4L2Subdevice) {\n+\t\t\tsubdev = std::make_unique<V4L2Subdevice>(entity);\n+\t\t\tint ret = subdev->open();\n+\t\t\tif (ret < 0) {\n+\t\t\t\tLOG(SimplePipeline, Error)\n+\t\t\t\t\t<< \"Failed to open \" << subdev->deviceNode()\n+\t\t\t\t\t<< \": \" << strerror(-ret);\n+\t\t\t\treturn false;\n+\t\t\t}\n \t\t}\n+\n+\t\tentities_[entity] = { nullptr, std::move(subdev) };\n \t}\n \n \t/* Initialize each pipeline and register a corresponding camera. */\n@@ -1114,28 +1119,30 @@ V4L2VideoDevice *SimplePipelineHandler::video(const MediaEntity *entity)\n \t * by constructing a new one.\n \t */\n \n-\tauto iter = videos_.find(entity);\n-\tif (iter != videos_.end())\n-\t\treturn iter->second.get();\n+\tauto iter = entities_.find(entity);\n+\tif (iter == entities_.end())\n+\t\treturn nullptr;\n+\n+\tEntityData &data = iter->second;\n+\tif (data.video)\n+\t\treturn data.video.get();\n \n-\tstd::unique_ptr<V4L2VideoDevice> video =\n-\t\tstd::make_unique<V4L2VideoDevice>(entity);\n-\tif (video->open() < 0)\n+\tdata.video = std::make_unique<V4L2VideoDevice>(entity);\n+\tif (data.video->open() < 0)\n \t\treturn nullptr;\n \n-\tvideo->bufferReady.connect(this, &SimplePipelineHandler::bufferReady);\n+\tdata.video->bufferReady.connect(this, &SimplePipelineHandler::bufferReady);\n \n-\tauto element = videos_.emplace(entity, std::move(video));\n-\treturn element.first->second.get();\n+\treturn data.video.get();\n }\n \n V4L2Subdevice *SimplePipelineHandler::subdev(const MediaEntity *entity)\n {\n-\tauto iter = subdevs_.find(entity);\n-\tif (iter == subdevs_.end())\n+\tauto iter = entities_.find(entity);\n+\tif (iter == entities_.end())\n \t\treturn nullptr;\n \n-\treturn &iter->second;\n+\treturn iter->second.subdev.get();\n }\n \n /* -----------------------------------------------------------------------------\n", "prefixes": [ "libcamera-devel", "05/10" ] }