From patchwork Mon Aug 3 21:17:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 9155 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id F0C74BD87A for ; Mon, 3 Aug 2020 21:18:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E049D6199D; Mon, 3 Aug 2020 23:18:00 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9CC99605A9 for ; Mon, 3 Aug 2020 23:17:59 +0200 (CEST) X-Halon-ID: 9c7cf789-d5ce-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac52a8.dip0.t-ipconnect.de [84.172.82.168]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 9c7cf789-d5ce-11ea-86ee-0050569116f7; Mon, 03 Aug 2020 23:16:35 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 3 Aug 2020 23:17:25 +0200 Message-Id: <20200803211733.1037019-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200803211733.1037019-1-niklas.soderlund@ragnatech.se> References: <20200803211733.1037019-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 1/9] libcamera: device_enumerator: Add method to lookup sysfs path X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an implementation to lookup a device nodes sysfs interface path based on the assumption that device name under /dev matches the one under /sysfs. Subclasses of the DeviceEnumerator may override this to create more clever methods to lookup the path. Signed-off-by: Niklas Söderlund --- include/libcamera/internal/device_enumerator.h | 2 ++ src/libcamera/device_enumerator.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/libcamera/internal/device_enumerator.h b/include/libcamera/internal/device_enumerator.h index a9850400229d2b53..11961f4f9304f6d7 100644 --- a/include/libcamera/internal/device_enumerator.h +++ b/include/libcamera/internal/device_enumerator.h @@ -45,6 +45,8 @@ public: std::shared_ptr search(const DeviceMatch &dm); + virtual std::string lookupSysfsPath(const std::string &deviceNode); + Signal<> devicesAdded; protected: diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index 647974b17341f44b..ef2451ac29159bf0 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -318,4 +318,18 @@ std::shared_ptr DeviceEnumerator::search(const DeviceMatch &dm) return nullptr; } +/** + * \brief Lookup a nodes sysfs path + * \param[in] deviceNode device node to lookup + * + * Lookup \a deviceNode sysfs interface. + * + * \return Path in sysfs + */ +std::string DeviceEnumerator::lookupSysfsPath(const std::string &deviceNode) +{ + std::string dev = basename(deviceNode.c_str()); + return "/sys/class/video4linux/" + dev; +} + } /* namespace libcamera */