Show a patch.

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

{
    "id": 18742,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18742/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18742/",
    "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": "<20230615172608.378258-6-kieran.bingham@ideasonboard.com>",
    "date": "2023-06-15T17:26:08",
    "name": "[libcamera-devel,v4,5/5] libcamera: pipeline: Register device numbers with camera",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "3c3af8b88a22c8234ea3a37d15c0af57a1715b21",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/1.1/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18742/mbox/",
    "series": [
        {
            "id": 3925,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3925/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3925",
            "date": "2023-06-15T17:26:03",
            "name": "libcamera: Add new Camera devices property",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/3925/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18742/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18742/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 1E765C322E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Jun 2023 17:26:22 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B6077628C3;\n\tThu, 15 Jun 2023 19:26:21 +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 87E96628AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Jun 2023 19:26:17 +0200 (CEST)",
            "from Monstersaurus.local\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D9D5F547;\n\tThu, 15 Jun 2023 19:25:45 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1686849981;\n\tbh=Kym629P17wr79W0pAx4/QGQmk2VFgSNpYCF46Cg/OMk=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=qJEqgDISuW44Z4TId2tkGK9FAUxqiC/xGztHrkk/zDuTAeXm6aL42sKr3u8kkTYkd\n\tNnVAqnu84Ydx2j7v7jBD3C/7ylFdBAhk6x7E0u3WlS78l2YS07RMkBK3DBm8xT3G8i\n\t+joebCpWPlKB2a11fel+gTLREw5TPlPxYiYtR8TDcEreQe0+XEq5zoFt7XLVt0Sttu\n\tgtPXtv0NDsrocyXrmEhErDEpq6eBHWkmhgp5D52N/fFCIsQTGCjz7lrA0aC09S6RMo\n\tMwNmVRTQh7252zPGqcgKxGa3IZ0V+lan/0eelO/EjIOAjgl7Xnf7EJjGdfWweznOvR\n\tSEyjs4qY2OAAA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1686849946;\n\tbh=Kym629P17wr79W0pAx4/QGQmk2VFgSNpYCF46Cg/OMk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ib7+rZqndENW9q9w4L+iUjoz0H9KLlGP0/zz4oT9R8YFHAJddzslEv+w8e7PCEnRc\n\tC4FWbKQXgXR51T3HOzvHAwEYCgIqGqxq69WiWxdOJppTRHVSwKwC7cPslhAI1JFNKd\n\t3VZGeDzTWqNFFsfWcZGHIeqlrE14X5DdIL71uIP8="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ib7+rZqn\"; dkim-atps=neutral",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Thu, 15 Jun 2023 18:26:08 +0100",
        "Message-Id": "<20230615172608.378258-6-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230615172608.378258-1-kieran.bingham@ideasonboard.com>",
        "References": "<20230615172608.378258-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v4 5/5] libcamera: pipeline: Register\n\tdevice numbers with camera",
        "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>",
        "From": "Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tAshok Sidipotu <ashok.sidipotu@collabora.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Register the identified device numbers with each camera as the Devices\nproperty.\n\nThis facilitates camera daemons or other systems to identify which\ndevices are being managed by libcamera, and can prevent duplication of\ncamera resources.\n\nAs the Devices property now provides this list of devices, use it\ndirectly from within the CameraManager when adding a Camera rather than\npassing it through the internal API.\n\nTested-by: Ashok Sidipotu <ashok.sidipotu@collabora.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nv4\n - Rename property\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/internal/camera_manager.h |  3 +--\n src/libcamera/camera_manager.cpp            | 14 +++++++++-----\n src/libcamera/pipeline_handler.cpp          | 12 ++++++++++--\n 3 files changed, 20 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h\nindex 84aac499ea13..cdf009a9c626 100644\n--- a/include/libcamera/internal/camera_manager.h\n+++ b/include/libcamera/internal/camera_manager.h\n@@ -35,8 +35,7 @@ public:\n \tPrivate();\n \n \tint start();\n-\tvoid addCamera(std::shared_ptr<Camera> camera,\n-\t\t       const std::vector<dev_t> &devnums) LIBCAMERA_TSA_EXCLUDES(mutex_);\n+\tvoid addCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);\n \tvoid removeCamera(std::shared_ptr<Camera> camera) LIBCAMERA_TSA_EXCLUDES(mutex_);\n \n \t/*\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex cafd7bce574e..31d45c42fde0 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -11,7 +11,9 @@\n #include <libcamera/base/utils.h>\n \n #include <libcamera/camera.h>\n+#include <libcamera/property_ids.h>\n \n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n \n@@ -151,19 +153,17 @@ void CameraManager::Private::cleanup()\n /**\n  * \\brief Add a camera to the camera manager\n  * \\param[in] camera The camera to be added\n- * \\param[in] devnums The device numbers to associate with \\a camera\n  *\n  * This function is called by pipeline handlers to register the cameras they\n  * handle with the camera manager. Registered cameras are immediately made\n  * available to the system.\n  *\n- * \\a devnums are used by the V4L2 compatibility layer to map V4L2 device nodes\n- * to Camera instances.\n+ * Device numbers from the Devices property are used by the V4L2 compatibility\n+ * layer to map V4L2 device nodes to Camera instances.\n  *\n  * \\context This function shall be called from the CameraManager thread.\n  */\n-void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera,\n-\t\t\t\t       const std::vector<dev_t> &devnums)\n+void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera)\n {\n \tASSERT(Thread::current() == this);\n \n@@ -178,6 +178,10 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera,\n \t\t}\n \t}\n \n+\tauto devnums = camera->properties()\n+\t\t\t       .get(properties::SystemDevices)\n+\t\t\t       .value_or(Span<int64_t>{});\n+\n \tcameras_.push_back(std::move(camera));\n \n \tunsigned int index = cameras_.size() - 1;\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 49092ea88a58..9c74c6cfda70 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -17,6 +17,7 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/framebuffer.h>\n+#include <libcamera/property_ids.h>\n \n #include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_manager.h\"\n@@ -612,7 +613,7 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n \t * Walk the entity list and map the devnums of all capture video nodes\n \t * to the camera.\n \t */\n-\tstd::vector<dev_t> devnums;\n+\tstd::vector<int64_t> devnums;\n \tfor (const std::shared_ptr<MediaDevice> &media : mediaDevices_) {\n \t\tfor (const MediaEntity *entity : media->entities()) {\n \t\t\tif (entity->pads().size() == 1 &&\n@@ -624,7 +625,14 @@ void PipelineHandler::registerCamera(std::shared_ptr<Camera> camera)\n \t\t}\n \t}\n \n-\tmanager_->_d()->addCamera(std::move(camera), devnums);\n+\t/*\n+\t * Store the associated devices as a property of the camera to allow\n+\t * systems to identify which devices are managed by libcamera.\n+\t */\n+\tCamera::Private *data = camera->_d();\n+\tdata->properties_.set(properties::SystemDevices, devnums);\n+\n+\tmanager_->_d()->addCamera(std::move(camera));\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "5/5"
    ]
}