{"id":18745,"url":"https://patchwork.libcamera.org/api/patches/18745/?format=json","web_url":"https://patchwork.libcamera.org/patch/18745/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230615225133.622612-2-kieran.bingham@ideasonboard.com>","date":"2023-06-15T22:51:32","name":"[libcamera-devel,1/2] v4l2: Use SystemDevices properties to identify cameras","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3408dee7c103e847ac20f3d8b773c1cd65813bb6","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18745/mbox/","series":[{"id":3927,"url":"https://patchwork.libcamera.org/api/series/3927/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3927","date":"2023-06-15T22:51:31","name":"libcamera: Remove CameraManager::get(dev_t)","version":1,"mbox":"https://patchwork.libcamera.org/series/3927/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18745/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18745/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 48CBCC322E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Jun 2023 22:51:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F0EC5628B5;\n\tFri, 16 Jun 2023 00:51:40 +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 09FA261E4F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 16 Jun 2023 00:51:38 +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 36824C7F;\n\tFri, 16 Jun 2023 00:51:06 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1686869501;\n\tbh=0apE+OXO3+ttEexAiaZTI8fAdClf0EQZjcXMlcwSsd4=;\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=fUqppE2hmHfBzN/h9xJYdSrFkCU0SNE1YNG9YQ3KqGXo09OpWM+IY1SlY6YTFnSY9\n\t5D3DCeI+KNqQ8J3qYfiE9UDU96OaNzNR7nQggj8IV7WNcDg3Fdvlbk1lORa6SkWxu5\n\tEnn0wN7YfPXjRBTaAO80F6T50/q7WV+G3yaLp3jZRUktN2TuwGq7ATlkF3cRFJg5Tk\n\tRpPaZw26OCksdWIuNc0mHdtLCySlsHK7TzkGS0uSRAe7KmWnnOzLJTqdWI2I8PNami\n\tJpMMtYSxTMAR5SjeJsDV4lWjs350Qd0WqNRJuhDAEku8T8RRPRpFW8gMrKtU9bwgQ+\n\tVT7YStrkctQ8A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1686869466;\n\tbh=0apE+OXO3+ttEexAiaZTI8fAdClf0EQZjcXMlcwSsd4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=sKiIsAZnUw3ezlOefMTFEmge9cZrLysXCqPa3u/dn1YWdhxvz0u4a6kw98G8dNpeK\n\t+jXDg8mPba086/JBUjNhP2fdG2hUXitAZFbiTbFhr/9VBQYCUT+1EdHw3TRO6FDSNl\n\tOxVzxVNU0IK2OT04udPJYLJYtQUnu+5ospwf9eYw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"sKiIsAZn\"; dkim-atps=neutral","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Thu, 15 Jun 2023 23:51:32 +0100","Message-Id":"<20230615225133.622612-2-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20230615225133.622612-1-kieran.bingham@ideasonboard.com>","References":"<20230615225133.622612-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/2] v4l2: Use SystemDevices properties to\n\tidentify 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 | 28 +++++++++++++++++++++++-----\n 1 file changed, 23 insertions(+), 5 deletions(-)","diff":"diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\nindex 0f7575c54b22..c49124290b42 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,31 @@ 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\tconst auto devices = camera->properties()\n+\t\t\t\t\t     .get(properties::SystemDevices)\n+\t\t\t\t\t     .value_or(std::vector<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}\n \n \treturn -1;\n","prefixes":["libcamera-devel","1/2"]}