From patchwork Thu Jan 3 01:31:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 135 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B52360B31 for ; Thu, 3 Jan 2019 02:30:13 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DB2C5505 for ; Thu, 3 Jan 2019 02:30:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479013; bh=RlOXKbKm8+KitLdKWLBObLMVtawU6o7AeJEx4iDz/0g=; h=From:To:Subject:Date:From; b=V+eVZBuTxhlN13BWO+eL9c073GbR9RQYYQV/itnZlwodNpTrC/zQX17mJ3CK/351P V9SeUoWLV7TKN3gLo19pvJWbawbulTdCYnF14d0nXB0QQHDDvvn7t70WPWPRVjGdNJ BRpiWhmd67WkG/sen9pHgv/m9y4QpQqAHRWeat3A= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:02 +0200 Message-Id: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/9] libcamera: camera_manager: Remove put() method X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:13 -0000 The method is declared but not implemented. Remove it. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/camera_manager.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 9d032d71c4c0..43a7811b3ea2 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -26,7 +26,6 @@ public: std::vector list() const; Camera *get(const std::string &name); - void put(Camera *camera); private: DeviceEnumerator *enumerator_; From patchwork Thu Jan 3 01:31:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 136 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AC8B660B31 for ; Thu, 3 Jan 2019 02:30:13 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 42625573 for ; Thu, 3 Jan 2019 02:30:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479013; bh=byHHidKhAAguBZcw0G+6sv9198cVu0/ZIR4B94sLKzY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DHUQ2sTSbafw8TFqKpw2rJddEN6UNdlldZPcVhFtmBdOTqbxBN2geTmut40Huvwcc OYX3kUgHQBC5JJXXL8OJZnHz0qK/o7A3H4GRb6xY4MCik8MZIzSFK+eraZ4ssAXYry dIsr8VV8w9AGHDUaSeUrI6lJNLQrnbxF21rHkS+I= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:03 +0200 Message-Id: <20190103013110.6849-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/9] libcamera: camera_manager: Sort includes alphabetically X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:13 -0000 Alphabetically sorted includes help finding where to insert new include statements, and avoiding duplicates. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- include/libcamera/camera_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 43a7811b3ea2..2768a5bd2384 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -7,8 +7,8 @@ #ifndef __LIBCAMERA_CAMERA_MANAGER_H__ #define __LIBCAMERA_CAMERA_MANAGER_H__ -#include #include +#include namespace libcamera { From patchwork Thu Jan 3 01:31:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 137 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE2F960B31 for ; Thu, 3 Jan 2019 02:30:13 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E969505 for ; Thu, 3 Jan 2019 02:30:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479013; bh=LQnKMhLoY8BFTytp7fVO5B6tjq6CUQWIt/xY4agalnc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AFHPRNeYWuBeoaMUeapTqCSLYBLoilGooFos/R1BhV1tT9N5+wJfBwSBz6+ut1Zyc lgpuA0qZmS4y7ppebFJQrkzrM3JrDFpCvT8NGaW0FXs8CmlPSpboLv804QIREk06O5 vPhNhf4+n172xdyGRtHmoReJMUNgTBgHP//HA+tk= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:04 +0200 Message-Id: <20190103013110.6849-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/9] libcamera: device_enumerator: Fix indentation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:14 -0000 Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index d70056a165fd..00568c7052c0 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -45,17 +45,17 @@ private: }; #define REGISTER_PIPELINE_HANDLER(handler) \ - class handler##Factory : public PipelineHandlerFactory { \ - public: \ - handler##Factory() \ - { \ - PipelineHandlerFactory::registerType(#handler, this); \ - } \ - virtual PipelineHandler *create() { \ - return new handler(); \ - } \ - }; \ - static handler##Factory global_##handler##Factory; +class handler##Factory : public PipelineHandlerFactory { \ +public: \ + handler##Factory() \ + { \ + PipelineHandlerFactory::registerType(#handler, this); \ + } \ + virtual PipelineHandler *create() { \ + return new handler(); \ + } \ +}; \ +static handler##Factory global_##handler##Factory; } /* namespace libcamera */ From patchwork Thu Jan 3 01:31:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 138 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4935E60B32 for ; Thu, 3 Jan 2019 02:30:14 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DBA9F573 for ; Thu, 3 Jan 2019 02:30:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479014; bh=fMsj/nBSFi2DFbLtAD/Y9dIHUHne5/wSU3qpkwCgbmw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bokjB5vrU7xL6CIC7pKwaPp7garmA9VcrFYonrIn7Mf/Vn7tw0/oyt+ak8wfbdALC wgNlLL2ZApA7x86jehSxtKV0d85xvTi7A3ljNYTXhhUgycr3Ea3CZJRd7Uf6zCYZ2d vTKG08vWrSb+L4ZIgSk4BAYnTY2EHziWvtJpUhiQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:05 +0200 Message-Id: <20190103013110.6849-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/9] libcamera: device_enumerator: Downgrade skipped device errors to warnings X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:14 -0000 When a device is skipped by the udev-based enumerator a message is logged. Downgrade its severity to warning as the error isn't fatal. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/device_enumerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index 7eef450e0c65..bc55a12f2a4e 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -302,8 +302,8 @@ int DeviceEnumeratorUdev::enumerate() dev = udev_device_new_from_syspath(udev_, syspath); if (!dev) { - LOG(Error) << "Failed to get device for '" << - syspath << "', skipping"; + LOG(Warning) << "Failed to get device for '" << + syspath << "', skipping"; continue; } From patchwork Thu Jan 3 01:31:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 139 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D44EF60B32 for ; Thu, 3 Jan 2019 02:30:14 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3595C505 for ; Thu, 3 Jan 2019 02:30:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479014; bh=/61PXmC3P9b4GEltJ+1ghHqGyn0VzoCbmbsoA0zglmM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tIwIBmiLB09KnkmD+eQNmzg/TGwHySL6HazKuU60AtgUqpgZW4L+Lp9Hp0DD8qLAZ u+AcKBqxDGaxICeaom0aHDqn2YYxq4O63RtcQggeisOCpcUJf04/Qi1iFgtYqKpHDp BYgzRNheAkVjOK+PbBw2QeYFJfajk85fFX/NXCAU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:06 +0200 Message-Id: <20190103013110.6849-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/9] libcamera: device_enumerator: Fix wording of log message X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:15 -0000 The log message still refers to the DeviceInfo class that has been removed. Replace it with a reference to MediaDevice. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/device_enumerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index bc55a12f2a4e..ecd51bc1d108 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -153,7 +153,7 @@ DeviceEnumerator::~DeviceEnumerator() { for (MediaDevice *dev : devices_) { if (dev->busy()) - LOG(Error) << "Removing device info while still in use"; + LOG(Error) << "Removing media device while still in use"; delete dev; } From patchwork Thu Jan 3 01:31:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 140 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0320D60B39 for ; Thu, 3 Jan 2019 02:30:15 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 873BA573 for ; Thu, 3 Jan 2019 02:30:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479014; bh=7ciHPqbwUpPkROtxXUA2DqAc9svbXM2Z8aWCLFd6h4c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Skv9S2E1ePh5zK/HFSmi0jNF2ILXjkc9cUu/bGSkD0prUtz0nOpDXzmlkXBPr90ex IWZNVlO4+ry4Ukqe9ZnGTO+RYU/JSkbLn1auUURiHEWhXH/HEiK3lzCrqC1y8LZ9On PeUY0zlWFUluNRYuhWDVH8u949hVsNwEDZXN/Ttc= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:07 +0200 Message-Id: <20190103013110.6849-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/9] libcamera: device_enumerator: Constify argument to search function X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:15 -0000 The DeviceEnumerator::search() function doesn't need to modify its DeviceMatch argument, make it const. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/device_enumerator.cpp | 2 +- src/libcamera/include/device_enumerator.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index ecd51bc1d108..a301420f39e1 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -215,7 +215,7 @@ int DeviceEnumerator::addDevice(const std::string &devnode) * * \return pointer to the matching MediaDevice, nullptr if no match is found */ -MediaDevice *DeviceEnumerator::search(DeviceMatch &dm) const +MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm) const { for (MediaDevice *dev : devices_) { if (dev->busy()) diff --git a/src/libcamera/include/device_enumerator.h b/src/libcamera/include/device_enumerator.h index 0d104667323b..29737da7a225 100644 --- a/src/libcamera/include/device_enumerator.h +++ b/src/libcamera/include/device_enumerator.h @@ -41,7 +41,7 @@ public: virtual int init() = 0; virtual int enumerate() = 0; - MediaDevice *search(DeviceMatch &dm) const; + MediaDevice *search(const DeviceMatch &dm) const; protected: int addDevice(const std::string &devnode); From patchwork Thu Jan 3 01:31:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 141 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6026860B40 for ; Thu, 3 Jan 2019 02:30:15 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DC747A04 for ; Thu, 3 Jan 2019 02:30:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479015; bh=Bpz1KlYHEkF+A3MezwnvwYB0mhvamttFcxt2xdw1Ob8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ast0pS7jhTd3T+0M3hSZ2fOmGoIX6TQQulAiL7hrUKauCOUjUAqK2HICMjfTJUM+p k+dcsIgfF2JzZ7pjYcErTlsXrbJmHBSIsLKOsHb38cGYZjkNmSW8RojNPyD1SnfvnN YYjPYs/hcHiHkLZVTgw+DotP8MNTNmSSZK0oTi7s= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:08 +0200 Message-Id: <20190103013110.6849-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 7/9] libcamera: device_enumerator: Improve documentation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:16 -0000 Miscellaneous documentation improvements for the DeviceEnumerator and related classes. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/device_enumerator.cpp | 166 +++++++++++++++------------- 1 file changed, 88 insertions(+), 78 deletions(-) diff --git a/src/libcamera/device_enumerator.cpp b/src/libcamera/device_enumerator.cpp index a301420f39e1..81f6927b44e1 100644 --- a/src/libcamera/device_enumerator.cpp +++ b/src/libcamera/device_enumerator.cpp @@ -17,27 +17,25 @@ /** * \file device_enumerator.h - * \brief Enumerating and matching of media devices + * \brief Enumeration and matching of media devices * - * The purpose of device enumeration and matching is to find media - * devices in the system and map one or more media devices to a pipeline - * handler. During enumeration information about each media device is - * gathered, transformed and stored. + * The purpose of device enumeration and matching is to find media devices in + * the system and map them to pipeline handlers. * - * The core of the enumeration is DeviceEnumerator which is responsible - * for all interactions with the operating system and the entry point - * for other parts of libcamera. + * At the code of the enumeration is the DeviceEnumerator class, responsible + * for enumerating all media devices in the system. It handles all interactions + * with the operating system in a platform-specific way. For each media device + * found an instance of MediaDevice is created to store information about the + * device gathered from the kernel through the Media Controller API. * - * The DeviceEnumerator can enumerate all or specific media devices in - * the system. When a new media device is added the enumerator creates a + * The DeviceEnumerator can enumerate all or specific media devices in the + * system. When a new media device is added the enumerator creates a * corresponding MediaDevice instance. * - * The last functionality provided is the ability to search among the - * enumerate media devices for one matching information known to the - * searcher. This is done by populating and passing a DeviceMatch object - * to the DeviceEnumerator. + * The enumerator supports searching among enumerated devices based on criteria + * expressed in a DeviceMatch object. * - * \todo Add sysfs based device enumerator + * \todo Add sysfs based device enumerator. * \todo Add support for hot-plug and hot-unplug. */ @@ -47,18 +45,17 @@ namespace libcamera { * \class DeviceMatch * \brief Description of a media device search pattern * - * The DeviceMatch class describes a media device using properties from - * the v4l2 struct media_device_info, entity names in the media graph or - * other properties which can be used to identify a media device. + * The DeviceMatch class describes a media device using properties from the + * Media Controller struct media_device_info, entity names in the media graph + * or other properties that can be used to identify a media device. * - * The description of a media device can then be passed to an enumerator - * to try and find a matching media device. + * The description is meant to be filled by pipeline managers and passed to a + * device enumerator to find matching media devices. */ /** * \brief Construct a media device search pattern - * - * \param[in] driver The Linux device driver name who created the media device + * \param[in] driver The Linux device driver name that created the media device */ DeviceMatch::DeviceMatch(const std::string &driver) : driver_(driver) @@ -67,7 +64,6 @@ DeviceMatch::DeviceMatch(const std::string &driver) /** * \brief Add a media entity name to the search pattern - * * \param[in] entity The name of the entity in the media graph */ void DeviceMatch::add(const std::string &entity) @@ -79,8 +75,9 @@ void DeviceMatch::add(const std::string &entity) * \brief Compare a search pattern with a media device * \param[in] device The media device * - * Matching is performed on the Linux device driver name and entity names - * from the media graph. + * Matching is performed on the Linux device driver name and entity names from + * the media graph. A match is found if both the driver name matches and the + * media device contains all the entities listed in the search pattern. * * \return true if the media device matches the search pattern, false otherwise */ @@ -108,43 +105,44 @@ bool DeviceMatch::match(const MediaDevice *device) const /** * \class DeviceEnumerator - * \brief Enumerate, interrogate, store and search media device information - * - * The DeviceEnumerator class is responsible for all interactions with - * the operation system when searching and interrogating media devices. + * \brief Enumerate, store and search media devices * - * It is possible to automatically search and add all media devices in - * the system or specify which media devices should be interrogated - * in order for a specialized application to open as few resources - * as possible to get hold of a specific camera. - * - * Once one or many media devices have been enumerated it is possible - * to search among them to try and find a matching device using a - * DeviceMatch object. + * The DeviceEnumerator class is responsible for all interactions with the + * operating system related to media devices. It enumerates all media devices + * in the system, and for each device found creates an instance of the + * MediaDevice class and stores it internally. The list of media devices can + * then be searched using DeviceMatch search patterns. * + * The enumerator also associates media device entities with device node paths. */ /** * \brief Create a new device enumerator matching the systems capabilities * - * Create a enumerator based on resource available to the system. Not all - * different enumerator types are guaranteed to support all features. + * Depending on how the operating system handles device detection, hot-plug + * notification and device node lookup, different device enumerator + * implementations may be needed. This function creates the best enumerator for + * the operating system based on the available resources. Not all different + * enumerator types are guaranteed to support all features. */ DeviceEnumerator *DeviceEnumerator::create() { DeviceEnumerator *enumerator; - /* TODO: add compile time checks to only try udev enumerator if libudev is available */ + /** + * \todo Add compile time checks to only try udev enumerator if libudev + * is available. + */ enumerator = new DeviceEnumeratorUdev(); if (!enumerator->init()) return enumerator; /* - * NOTE: Either udev is not available or initialization of it - * failed, use/fallback on sysfs enumerator + * Either udev is not available or udev initialization failed. Fall back + * on the sysfs enumerator. */ - /* TODO: add a sysfs based enumerator */ + /** \todo Add a sysfs-based enumerator. */ return nullptr; } @@ -160,13 +158,38 @@ DeviceEnumerator::~DeviceEnumerator() } /** - * \brief Add a media device to the enumerator + * \fn DeviceEnumerator::init() + * \brief Initialize the enumerator + * \return 0 on success, or a negative error code otherwise + * \retval -EBUSY the enumerator has already been initialized + * \retval -ENODEV the enumerator can't enumerate devices + */ + +/** + * \fn DeviceEnumerator::enumerate() + * \brief Enumerate all media devices in the system + * + * This function finds and add all media devices in the system to the + * enumerator. It shall be implemented by all subclasses of DeviceEnumerator + * using system-specific methods. + * + * Individual media devices that can't be properly enumerated shall be skipped + * with a warning message logged, without returning an error. Only errors that + * prevent enumeration altogether shall be fatal. * + * \return 0 on success, or a negative error code on fatal errors. + */ + +/** + * \brief Add a media device to the enumerator * \param[in] devnode path to the media device to add * - * Opens the media device and quires its topology and other information. + * Create a media device for the \a devnode, open it, populate its media graph, + * and look up device nodes associated with all entities. Store the media device + * in the internal list for later matching with pipeline handlers. * - * \return 0 on success none zero otherwise + * \return 0 on success, or a negative error code if the media device can't be + * created or populated */ int DeviceEnumerator::addDevice(const std::string &devnode) { @@ -205,15 +228,14 @@ int DeviceEnumerator::addDevice(const std::string &devnode) /** * \brief Search available media devices for a pattern match - * * \param[in] dm Search pattern * - * Search in the enumerated media devices that are not already in use - * for a match described in \a dm. If a match is found and the caller - * intends to use it the caller is responsible to mark the MediaDevice - * object as in use and to release it when it's done with it. + * Search in the enumerated media devices that are not already in use for a + * match described in \a dm. If a match is found and the caller intends to use + * it the caller is responsible for acquiring the MediaDevice object and + * releasing it when done with it. * - * \return pointer to the matching MediaDevice, nullptr if no match is found + * \return pointer to the matching MediaDevice, or nullptr if no match is found */ MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm) const { @@ -229,10 +251,21 @@ MediaDevice *DeviceEnumerator::search(const DeviceMatch &dm) const } /** - * \class DeviceEnumeratorUdev - * \brief Udev implementation of device enumeration + * \fn DeviceEnumerator::lookupDevnode(int major, int minor) + * \brief Lookup device node path from device number + * \param major The device major number + * \param minor The device minor number * - * Implementation of system enumeration functions using libudev. + * Translate a device number given as \a major and \a minor to a device node + * path. + * + * \return the device node path on success, or an empty string if the lookup + * fails + */ + +/** + * \class DeviceEnumeratorUdev + * \brief Device enumerator based on libudev */ DeviceEnumeratorUdev::DeviceEnumeratorUdev() @@ -246,13 +279,6 @@ DeviceEnumeratorUdev::~DeviceEnumeratorUdev() udev_unref(udev_); } -/** - * \brief Initialize the enumerator - * - * \retval 0 Initialized - * \retval -EBUSY Busy (already initialized) - * \retval -ENODEV Failed to talk to udev - */ int DeviceEnumeratorUdev::init() { if (udev_) @@ -265,14 +291,6 @@ int DeviceEnumeratorUdev::init() return 0; } -/** - * \brief Enumerate all media devices using udev - * - * Find, enumerate and add all media devices in the system to the - * enumerator. - * - * \return 0 on success none zero otherwise - */ int DeviceEnumeratorUdev::enumerate() { struct udev_enumerate *udev_enum = nullptr; @@ -323,14 +341,6 @@ done: return ret >= 0 ? 0 : ret; } -/** - * \brief Lookup device node from device number using udev - * - * Translate a device number (major, minor) to a device node path. - * - * \return device node path or empty string if lookup fails. - * - */ std::string DeviceEnumeratorUdev::lookupDevnode(int major, int minor) { struct udev_device *device; From patchwork Thu Jan 3 01:31:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 142 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CCB6A60B31 for ; Thu, 3 Jan 2019 02:30:15 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B196505 for ; Thu, 3 Jan 2019 02:30:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479015; bh=mSIEpG/QTxfe8yGjk2dU822k2Iy4YNqZtFVYTE1x6s4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mwVgE5tzhLz6JdScZ5aX5dDfirZkrrNQiYSywoT4FYbvRpUFcCC+JdkSwbnxmp7vZ kbG3ZXjFsxg0a3oiMSxFYUNva0nnxOAN1IuZpWKBYpxYAI62yK/204EDVlp4oxxtF7 L01Eph/gouxB28lLAib+OOuhrUBz6GyU8TJh7xf8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:09 +0200 Message-Id: <20190103013110.6849-8-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 8/9] libcamera: pipeline_handler: Remove unneeded forward declaration X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:16 -0000 There's no need to forward-declare the PipelineManagerFactory class. Remove it. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/pipeline_handler.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libcamera/include/pipeline_handler.h b/src/libcamera/include/pipeline_handler.h index 00568c7052c0..fdf8b8db2e0a 100644 --- a/src/libcamera/include/pipeline_handler.h +++ b/src/libcamera/include/pipeline_handler.h @@ -16,7 +16,6 @@ namespace libcamera { class DeviceEnumerator; -class PipelineHandlerFactory; class PipelineHandler { From patchwork Thu Jan 3 01:31:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 143 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2CAC060B36 for ; Thu, 3 Jan 2019 02:30:16 +0100 (CET) Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BC76B573 for ; Thu, 3 Jan 2019 02:30:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1546479015; bh=sYqxjfIaQ4VBgXBP5C/eJWIC3HtEuedHBuw6g1fAucM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EnmqHEmAZ4+gsu8F5nEjmAYSbgBDn4IDZwIAPMaYxp7qjMSy2zcu455LlL3UpPbum 4sZ+fKbeyqttwNCmIMpgy/V23GzAO+gAGRjIfY7njhKwfmZa5RTQn1Y8jECEN+icTb Np0C+B98CUe2pfglJn6cpxi61WL1HBEV75PWWNV4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jan 2019 03:31:10 +0200 Message-Id: <20190103013110.6849-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> References: <20190103013110.6849-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 9/9] libcamera: pipeline_handler: Improve documentation X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 01:30:16 -0000 Miscellaneous documentation improvements for the PipelineHandler and related classes. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/pipeline_handler.cpp | 125 ++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 37 deletions(-) diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index a737f222b465..093821d4c471 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -11,48 +11,98 @@ /** * \file pipeline_handler.h - * \brief Create pipelines and cameras from one or more media devices + * \brief Create pipelines and cameras from a set of media devices * * Each pipeline supported by libcamera needs to be backed by a pipeline - * handler implementation which describes the one or many media devices - * needed for a pipeline to function properly. + * handler implementation that operate on a set of media devices. The pipeline + * handler is responsible for matching the media devices it requires with the + * devices present in the system, and once all those devices can be acquired, + * create corresponding Camera instances. * - * The pipeline handler is responsible for providing a description of the - * media devices it requires to operate. Once all media devices can be - * provided the pipeline handler can acquire them and create camera - * devices that utilize the acquired media devices. - * - * To make it a bit less bit complicated to write pipe line handlers a - * macro REGISTER_PIPELINE_HANDLER() is provided which allows a pipeline - * handler implementation to register itself with the library with ease. + * Every subclass of PipelineHandler shall be registered with libcamera using + * the REGISTER_PIPELINE_HANDLER() macro. */ namespace libcamera { /** * \class PipelineHandler - * \brief Find a set of media devices and provide cameras + * \brief Create and manage cameras based on a set of media devices * - * The responsibility of a PipelineHandler is to describe all media - * devices it would need in order to provide cameras to the system. + * The PipelineHandler matches the media devices provided by a DeviceEnumerator + * with the pipelines it supports and creates corresponding Camera devices. + */ + +/** + * \fn PipelineHandler::match(DeviceEnumerator *enumerator) + * \brief Match media devices and create camera instances + * + * This function is the main entry point of the pipeline handler. It is called + * by the device enumerator with the enumerator passed as an argument. It shall + * acquire from the enumerator all the media devices it needs for a single + * pipeline and create one or multiple Camera instances. + * + * If all media devices needed by the pipeline handler are found, they must all + * be acquired by a call to MediaDevice::acquire(). This function shall then + * create the corresponding Camera instances, store them internally, and return + * true. Otherwise it shall not acquire any media device (or shall release all + * the media devices is has acquired by calling MediaDevice::release()) and + * return false. + * + * If multiple instances of a pipeline are available in the system, the + * PipelineHandler class will be instanciated once per instance, and its match() + * function called for every instance. Each call shall acquire media devices for + * one pipeline instance, until all compatible media devices are exhausted. + * + * If this function returns true, a new instance of the pipeline handler will + * be created and its match() function called, + * + * \return true if media devices have been acquired and camera instances + * created, or false otherwise + */ + +/** + * \fn PipelineHandler::count() + * \brief Retrieve the number of cameras handled by this pipeline handler + * \return the number of cameras that were created by the match() function + */ + +/** + * \fn PipelineHandler::camera(unsigned int id) + * \brief Retrieve one of the cameras handled by this pipeline handler + * \param[in] id the camera index + * \return a pointer to the Camera identified by \a id */ /** * \class PipelineHandlerFactory - * \brief Keep a registry and create instances of available pipeline handlers - * - * The responsibility of the PipelineHandlerFactory is to keep a list - * of all pipelines in the system. Each pipeline handler should register - * it self with the factory using the REGISTER_PIPELINE_HANDLER() macro. + * \brief Registration of PipelineHandler classes and creation of instances + * + * To facilitate discovery and instantiation of PipelineHandler classes, the + * PipelineHandlerFactory class maintains a registry of pipeline handler + * classes. Each PipelineHandler subclass shall register itself using the + * REGISTER_PIPELINE_HANDLER() macro, which will create a corresponding + * instance of a PipelineHandlerFactory subclass and register it with the + * static list of factories. */ /** - * \brief Add a pipeline handler to the global list + * \fn PipelineHandlerFactory::create() + * \brief Create an instance of the PipelineHandler corresponding to the factory * - * \param[in] name Name of the pipeline handler to add - * \param[in] factory Factory to use to construct the pipeline + * This virtual function is implemented by the REGISTER_PIPELINE_HANDLER() macro. + * + * \return a pointer to a newly constructed instance of the PipelineHandler + * subclass corresponding to the factory + */ + +/** + * \brief Add a pipeline handler class to the registry + * \param[in] name Name of the pipeline handler class + * \param[in] factory Factory to use to construct the pipeline handler * - * The caller is responsible to guarantee the uniqueness of the pipeline name. + * The caller is responsible to guarantee the uniqueness of the pipeline handler + * name. */ void PipelineHandlerFactory::registerType(const std::string &name, PipelineHandlerFactory *factory) @@ -68,15 +118,16 @@ void PipelineHandlerFactory::registerType(const std::string &name, } /** - * \brief Create a new pipeline handler and try to match the media devices it requires - * - * \param[in] name Name of the pipeline handler to try + * \brief Create an instance of a pipeline handler if it matches media devices + * present in the system + * \param[in] name Name of the pipeline handler to instantiate * \param[in] enumerator Device enumerator to search for a match for the handler * - * Try to match the media devices pipeline \a name requires against the ones - * registered in \a enumerator. + * This function matches the media devices required by pipeline \a name against + * the devices enumerated by \a enumerator. * - * \return Pipeline handler if a match was found, nullptr otherwise + * \return the newly created pipeline handler instance if a match was found, or + * nullptr otherwise */ PipelineHandler *PipelineHandlerFactory::create(const std::string &name, DeviceEnumerator *enumerator) @@ -100,9 +151,10 @@ PipelineHandler *PipelineHandlerFactory::create(const std::string &name, } /** - * \brief List all names of piepline handlers from the global list + * \brief Retrieve the names of all pipeline handlers registered with the + * factory * - * \return List of registerd pipeline handler names + * \return a list of all registered pipeline handler names */ std::vector PipelineHandlerFactory::handlers() { @@ -116,12 +168,12 @@ std::vector PipelineHandlerFactory::handlers() } /** - * \brief Static global list of pipeline handlers + * \brief Retrieve the list of all pipeline handler factories * * The static factories map is defined inside the function to ensures it gets * initialized on first use, without any dependency on link order. * - * \return Global list of pipeline handlers + * \return the list of pipeline handler factories */ std::map &PipelineHandlerFactory::registry() { @@ -131,12 +183,11 @@ std::map &PipelineHandlerFactory::registr /** * \def REGISTER_PIPELINE_HANDLER - * \brief Register a pipeline handler with the global list - * + * \brief Register a pipeline handler with the pipeline handler factory * \param[in] handler Class name of PipelineHandler derived class to register * - * Register a specific pipeline handler with the global list and make it - * available to try and match devices. + * Register a PipelineHandler subclass with the factory and make it available to + * try and match devices. */ } /* namespace libcamera */