Show a patch.

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

{
    "id": 18625,
    "url": "https://patchwork.libcamera.org/api/patches/18625/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18625/",
    "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": "<20230511225833.361699-5-kieran.bingham@ideasonboard.com>",
    "date": "2023-05-11T22:58:33",
    "name": "[libcamera-devel,v2,4/4] libcamera: pipeline: Register device numbers with camera",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "25ab480a956fe2f5da788ad2cb9e76e355d71e37",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/18625/mbox/",
    "series": [
        {
            "id": 3876,
            "url": "https://patchwork.libcamera.org/api/series/3876/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3876",
            "date": "2023-05-11T22:58:29",
            "name": "libcamera: Add new Camera devices property",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3876/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18625/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18625/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 A117EC3285\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 May 2023 22:58:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 05213633BF;\n\tFri, 12 May 2023 00:58:44 +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 45E98633B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 May 2023 00:58:40 +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 CC37713D2;\n\tFri, 12 May 2023 00:58:31 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1683845924;\n\tbh=Xg9QLFlM9LIiUN/2yhjh8ehnqdh9TxE4uobTVMhhvZU=;\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=fgn3guAUhRhPN1aLsR0txbnbpiIQvyUhTedEGFJcv6AVS7s+G3pPHvBFGY8TArxxx\n\t8XtjGIUrF+OTgpDMP1mwFY7497e5R3C1ti0xlYVnpSzjjPupf0fVbyiQGYQLmb1NeO\n\tDUisN24pZ27swuXZIU9cAK+cRPfgi5BnpuM8VRF2Aq76E0ngG0UamaQWfmLj1lzTJj\n\tEXvEQHECnca6/XbAs0KEyrLIH/CEYXumyabPB2MssXLuN/3iqgF2/ekQuwBOMrJKZt\n\t4EmZrXTSx5EcKNgvXQLHENF2QY1xiSL39wiKkbeqEClFHW65zeV1zvymsZa+lqumZz\n\t+sAsdQwwg+BKA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1683845912;\n\tbh=Xg9QLFlM9LIiUN/2yhjh8ehnqdh9TxE4uobTVMhhvZU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ph64mR//bL8HffA1BuaJceq1b3KSJkKaw6n7aFUAxQB9nc5LW6j8kYkci8rrtDU8D\n\tVXmwzlsC/XrsoNhN4dD0Ejf7vPkVDSGaEFwLzUT/+JzrtrE+bSORiSalRo4gAQSPpS\n\tOuNbUsYMH1MlDImKSdqsb4g9HTqbFM5I+BwiPuTQ="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ph64mR//\"; dkim-atps=neutral",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Thu, 11 May 2023 23:58:33 +0100",
        "Message-Id": "<20230511225833.361699-5-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230511225833.361699-1-kieran.bingham@ideasonboard.com>",
        "References": "<20230511225833.361699-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 4/4] 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": "George Kiagiadakis <george.kiagiadakis@collabora.com>,\n\tRobert Mader <robert.mader@collabora.com>,\n\tWim Taymans <wtaymans@redhat.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\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/internal/camera_manager.h |  3 +--\n src/libcamera/camera_manager.cpp            | 13 ++++++++-----\n src/libcamera/pipeline_handler.cpp          | 12 ++++++++++--\n 3 files changed, 19 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h\nindex 8386e90e0f60..061d2c5083b0 100644\n--- a/include/libcamera/internal/camera_manager.h\n+++ b/include/libcamera/internal/camera_manager.h\n@@ -29,8 +29,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 34f09a4d181b..df5fdede85da 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -15,7 +15,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/camera_manager.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\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,9 @@ void CameraManager::Private::addCamera(std::shared_ptr<Camera> camera,\n \t\t}\n \t}\n \n+\tCamera::Private *data = camera->_d();\n+\tauto devnums = data->properties_.get(properties::Devices).value_or(std::vector<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..0b5fac7ad113 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::Devices, devnums);\n+\n+\tmanager_->_d()->addCamera(std::move(camera));\n }\n \n /**\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "4/4"
    ]
}