Show a patch.

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

{
    "id": 13237,
    "url": "https://patchwork.libcamera.org/api/patches/13237/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13237/",
    "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-7-laurent.pinchart@ideasonboard.com>",
    "date": "2021-08-05T22:24:32",
    "name": "[libcamera-devel,06/10] libcamera: pipeline: simple: Open all video devices at match() time",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "09861c88230826ab9dcc83e202d227ff769c54b8",
    "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/13237/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/13237/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13237/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 CF089C323B\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 4D3A16880D;\n\tFri,  6 Aug 2021 00:25:01 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B47CA68822\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 5BFD7E1A\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=\"UPGz/zFT\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628202297;\n\tbh=qtwKVVw6o3QY11H21TZbG8ItJRpU+4xczObphMxatmc=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=UPGz/zFTrZ3+Z+n44zntNRs6Yl8RoLOKrYtXt+SYrh3iyi0HgsqK/8uYbMTHOTCK1\n\tVVsS6gKkBRL0LE1wOIi1YtK2DKz3p5JKNVqDBosRZvn1yt7ApYVCAGRrJJliAFbr6K\n\tBhuebcnahO7L7M7dmdgWuPfb10cX0t00eCTpVbsA=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  6 Aug 2021 01:24:32 +0300",
        "Message-Id": "<20210805222436.6263-7-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 06/10] libcamera: pipeline: simple: Open\n\tall video devices at match() time",
        "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": "Move opening of video devices at match() time, the same way as subdevs\nare opened, to make the handling of V4L2 video devices and subdevices\nmore consistent.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 67 ++++++++++++------------\n 1 file changed, 33 insertions(+), 34 deletions(-)",
    "diff": "diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 6b808bfbe6fa..17ef3f43ad41 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -82,14 +82,12 @@ LOG_DEFINE_CATEGORY(SimplePipeline)\n  * handled by this heuristic.\n  *\n  * Once the camera data instances have been created, the match() function\n- * creates a V4L2Subdevice instance for each entity used by any of the cameras\n- * and stores the instances in SimplePipelineHandler::subdevs_, accessible by\n- * the SimpleCameraData class through the SimplePipelineHandler::subdev()\n- * function. This avoids duplication of subdev instances between different\n- * cameras when the same entity is used in multiple paths. A similar mechanism\n- * is used for V4L2VideoDevice instances, but instances are in this case created\n- * on demand when accessed through SimplePipelineHandler::video() instead of all\n- * in one go at initialization time.\n+ * creates a V4L2VideoDevice or V4L2Subdevice instance for each entity used by\n+ * any of the cameras and stores them in SimplePipelineHandler::entities_,\n+ * accessible by the SimpleCameraData class through the\n+ * SimplePipelineHandler::subdev() and SimplePipelineHandler::video() functions.\n+ * This avoids duplication of subdev instances between different cameras when\n+ * the same entity is used in multiple paths.\n  *\n  * Finally, all camera data instances are initialized to gather information\n  * about the possible pipeline configurations for the corresponding camera. If\n@@ -397,10 +395,7 @@ int SimpleCameraData::init()\n \tint ret;\n \n \tvideo_ = pipe->video(entities_.back().entity);\n-\tif (!video_) {\n-\t\tLOG(SimplePipeline, Error) << \"Failed to open video device\";\n-\t\treturn -ENODEV;\n-\t}\n+\tASSERT(video_);\n \n \t/*\n \t * Setup links first as some subdev drivers take active links into\n@@ -1069,24 +1064,44 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \n \t/*\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 * V4L2VideoDevice and V4L2Subdevice instances for the corresponding\n+\t * entities.\n \t */\n \tfor (MediaEntity *entity : entities) {\n+\t\tstd::unique_ptr<V4L2VideoDevice> video;\n \t\tstd::unique_ptr<V4L2Subdevice> subdev;\n+\t\tint ret;\n \n-\t\tif (entity->type() == MediaEntity::Type::V4L2Subdevice) {\n+\t\tswitch (entity->type()) {\n+\t\tcase MediaEntity::Type::V4L2VideoDevice:\n+\t\t\tvideo = std::make_unique<V4L2VideoDevice>(entity);\n+\t\t\tret = video->open();\n+\t\t\tif (ret < 0) {\n+\t\t\t\tLOG(SimplePipeline, Error)\n+\t\t\t\t\t<< \"Failed to open \" << video->deviceNode()\n+\t\t\t\t\t<< \": \" << strerror(-ret);\n+\t\t\t\treturn false;\n+\t\t\t}\n+\n+\t\t\tvideo->bufferReady.connect(this, &SimplePipelineHandler::bufferReady);\n+\t\t\tbreak;\n+\n+\t\tcase MediaEntity::Type::V4L2Subdevice:\n \t\t\tsubdev = std::make_unique<V4L2Subdevice>(entity);\n-\t\t\tint ret = subdev->open();\n+\t\t\tret = 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\tbreak;\n+\n+\t\tdefault:\n+\t\t\tbreak;\n \t\t}\n \n-\t\tentities_[entity] = { nullptr, std::move(subdev) };\n+\t\tentities_[entity] = { std::move(video), std::move(subdev) };\n \t}\n \n \t/* Initialize each pipeline and register a corresponding camera. */\n@@ -1113,27 +1128,11 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \n V4L2VideoDevice *SimplePipelineHandler::video(const MediaEntity *entity)\n {\n-\t/*\n-\t * Return the V4L2VideoDevice corresponding to the media entity, either\n-\t * as a previously constructed device if available from the cache, or\n-\t * by constructing a new one.\n-\t */\n-\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-\tdata.video = std::make_unique<V4L2VideoDevice>(entity);\n-\tif (data.video->open() < 0)\n-\t\treturn nullptr;\n-\n-\tdata.video->bufferReady.connect(this, &SimplePipelineHandler::bufferReady);\n-\n-\treturn data.video.get();\n+\treturn iter->second.video.get();\n }\n \n V4L2Subdevice *SimplePipelineHandler::subdev(const MediaEntity *entity)\n",
    "prefixes": [
        "libcamera-devel",
        "06/10"
    ]
}