From patchwork Mon Sep 16 14:02:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 21281 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 B44D7C3257 for ; Mon, 16 Sep 2024 14:02:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 93941634FF; Mon, 16 Sep 2024 16:02:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qcBXRs1b"; dkim-atps=neutral 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 CC7A5634FC for ; Mon, 16 Sep 2024 16:02:48 +0200 (CEST) Received: from charm.lan (unknown [IPv6:2001:4bc9:a45:b0af:726e:a88f:9f07:34be]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A325582A; Mon, 16 Sep 2024 16:01:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726495287; bh=uiBSR0tOq4Y0tvXZp5jRAZLAjaMTGxsDzQBGB7knc9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qcBXRs1bcdyUCByUrZopEXojRDCMcZ1xKFtBe58XCCRtEyy8sDqV9+X/DhsG36CUi k/dUGTI6bIblEbxFkJH4s8t6Q7IjO6B9ZVDla1k+SYlzv4aD9PCCsMIHpkyeCnakxr hFCejMd+uGU1uNw82HMLqrlKqM58563BzGx51x8g= From: Kieran Bingham To: libcamera devel Cc: Kieran Bingham Subject: [PATCH 1/4] libcamera: media_device: Add helper to return matching entities Date: Mon, 16 Sep 2024 16:02:38 +0200 Message-ID: <20240916140241.47845-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240916140241.47845-1-kieran.bingham@ideasonboard.com> References: <20240916140241.47845-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 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" Provide a helper on the MediaDevice to return a list of all available entities which match a given function in the graph. As a drive by, also fix a whitespace error in the documentation of MediaDevice::setupLink. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Jacopo Mondi Reviewed-by: Daniel Scally --- include/libcamera/internal/media_device.h | 2 ++ src/libcamera/media_device.cpp | 24 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h index e412d3a0b7e3..b3a48b98d64b 100644 --- a/include/libcamera/internal/media_device.h +++ b/include/libcamera/internal/media_device.h @@ -55,6 +55,8 @@ public: Signal<> disconnected; + std::vector locateEntities(unsigned int function); + protected: std::string logPrefix() const override; diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index d71dad74df70..d1e0dee2ff0f 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -793,7 +793,7 @@ void MediaDevice::fixupEntityFlags(struct media_v2_entity *entity) * low-level link setup as it performs no checks on the validity of the \a * flags, and assumes that the supplied \a flags are valid for the link (e.g. * immutable links cannot be disabled). -* + * * \sa MediaLink::setEnabled(bool enable) * * \return 0 on success or a negative error code otherwise @@ -828,4 +828,26 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags) return 0; } +/** + * \brief Identify all entities of a common function in the MediaDevice + * \param[in] function The entity function to search for + * + * Search all entities within the graph of the MediaDevice and return + * a vector of those which match the given function. + * + * \return A vector of matching entities + */ +std::vector MediaDevice::locateEntities(unsigned int function) +{ + std::vector found; + + /* Gather all the entities matching the function they expose. */ + for (MediaEntity *entity : entities()) { + if (entity->function() == function) + found.push_back(entity); + } + + return found; +} + } /* namespace libcamera */