Show a patch.

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

{
    "id": 18785,
    "url": "https://patchwork.libcamera.org/api/patches/18785/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18785/",
    "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": "<20230704225746.3838484-2-kieran.bingham@ideasonboard.com>",
    "date": "2023-07-04T22:57:45",
    "name": "[libcamera-devel,v2,1/2] v4l2: Use SystemDevices properties to identify cameras",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "24e347d7aff282ecf15e6af90f0aba68b6ce2c30",
    "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/18785/mbox/",
    "series": [
        {
            "id": 3952,
            "url": "https://patchwork.libcamera.org/api/series/3952/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3952",
            "date": "2023-07-04T22:57:44",
            "name": "libcamera: Remove CameraManager::get(dev_t)",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/3952/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18785/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18785/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 BFEABC3240\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Jul 2023 22:58:49 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6E899628BD;\n\tWed,  5 Jul 2023 00:58:49 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E6B99628BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Jul 2023 00:58:46 +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 37A0C1B6D;\n\tWed,  5 Jul 2023 00:58:02 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1688511529;\n\tbh=kV4tfNggj3HKOynGd/A+ySk8XG12Kz098H+dD3UmRJw=;\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:\n\tFrom;\n\tb=cxj1QlEJL/pCnSGJF1l6uqwMjk3x80NAmihlM1Td9Q3uzBSPHIbpQRyYRoRDNQH2J\n\tMLhShU0BqIBYZMUOt1bEX8UbgC92JL8r398RVMa5aN+rzrCnqgolcaS0x3pUyg9e6l\n\tseEgmENYEPHgr4gelLk0nY0j4phPFhtkjQ8ZDPAdzrQaY2wCQVMUSXVo9dGZL+iqxm\n\tuGb4OR/6jjGjXmCfBfzSROo4DDczx/rZnbEoj+CMsFt2egozib6RNbArMfA3blFG5w\n\t4jMcQVROfj0eehuy50imwEDa1CadN/C7ek1JFXwl+NBL/d5qYvDhpHYQS97fowi73P\n\tgkgFYj+TWrqJw==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1688511482;\n\tbh=kV4tfNggj3HKOynGd/A+ySk8XG12Kz098H+dD3UmRJw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=MStTEzH/rKEjSX7IeEPo6fJaO5DSeWe11EzBeG1FReRMCcijMJPMTx80+ALnWSeKi\n\ts0uuDDrOUarn505yMprmdDXHoW8p1BWYKIdiDVc3unt5Q38+jDkkp2fG8Nd5eads+/\n\t1rL6Elpj/X05GJIMVSWHpoi7cnAKh16aw8KKhoTE="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"MStTEzH/\"; dkim-atps=neutral",
        "To": "libcamera devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Tue,  4 Jul 2023 23:57:45 +0100",
        "Message-Id": "<20230704225746.3838484-2-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20230704225746.3838484-1-kieran.bingham@ideasonboard.com>",
        "References": "<20230704225746.3838484-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 1/2] v4l2: Use SystemDevices properties\n\tto identify cameras",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The CameraManager->get(dev_t) helper was implemented only to support the\nV4L2 Adaptation layer, and has been deprecated now that a new camera\nproperty - SystemDevices has been introduced.\n\nRework the implementation of getCameraIndex() to use the SystemDevices\nproperty and remove reliance on the now deprecated call.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/v4l2/v4l2_compat_manager.cpp | 29 ++++++++++++++++++++++++-----\n 1 file changed, 24 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\nindex 0f7575c54b22..948dadad646d 100644\n--- a/src/v4l2/v4l2_compat_manager.cpp\n+++ b/src/v4l2/v4l2_compat_manager.cpp\n@@ -24,6 +24,7 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/camera_manager.h>\n+#include <libcamera/property_ids.h>\n \n #include \"v4l2_camera_file.h\"\n \n@@ -113,14 +114,32 @@ int V4L2CompatManager::getCameraIndex(int fd)\n \tif (ret < 0)\n \t\treturn -1;\n \n-\tstd::shared_ptr<Camera> target = cm_->get(statbuf.st_rdev);\n-\tif (!target)\n-\t\treturn -1;\n+\tconst dev_t devnum = statbuf.st_rdev;\n \n+\t/*\n+\t * Iterate each known camera and identify if it reports this nodes\n+\t * device number in its list of SystemDevices.\n+\t */\n \tauto cameras = cm_->cameras();\n \tfor (auto [index, camera] : utils::enumerate(cameras)) {\n-\t\tif (camera == target)\n-\t\t\treturn index;\n+\t\tSpan<const int64_t> devices = camera->properties()\n+\t\t\t\t\t\t      .get(properties::SystemDevices)\n+\t\t\t\t\t\t      .value_or(Span<int64_t>{});\n+\n+\t\t/*\n+\t\t * While there may be multiple Cameras that could reference the\n+\t\t * same device node, we take a first match as a best effort for\n+\t\t * now.\n+\t\t *\n+\t\t * \\todo Consider reworking the V4L2 adaptation layer to stop\n+\t\t * trying to map video nodes directly to a camera and instead\n+\t\t * hide all devices that may be used by libcamera and expose a\n+\t\t * consistent 1:1 mapping with each Camera instance.\n+\t\t */\n+\t\tfor (const int64_t dev : devices) {\n+\t\t\tif (dev == static_cast<int64_t>(devnum))\n+\t\t\t\treturn index;\n+\t\t}\n \t}\n \n \treturn -1;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "1/2"
    ]
}