[{"id":33908,"web_url":"https://patchwork.libcamera.org/comment/33908/","msgid":"<6en2ryzz2kw2wn7nmt7uyjjhyv26n6obpeczjgfhwganhomxeu@can5fewf3cnv>","date":"2025-04-03T10:31:02","subject":"Re: [PATCH v4 1/3] libcamera: media_device: Add helper to return\n\tmatching entities","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"On Wed, Apr 02, 2025 at 04:39:16PM +0900, Paul Elder wrote:\n> From: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> Provide a helper on the MediaDevice to return a list of all\n> available entities which match a given function in the graph.\n> \n> As a drive by, also fix a whitespace error in the documentation of\n> MediaDevice::setupLink.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\nLooks good to me.\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> \n\n> ---\n>  include/libcamera/internal/media_device.h |  2 ++\n>  src/libcamera/media_device.cpp            | 24 ++++++++++++++++++++++-\n>  2 files changed, 25 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h\n> index e412d3a0b7e3..b3a48b98d64b 100644\n> --- a/include/libcamera/internal/media_device.h\n> +++ b/include/libcamera/internal/media_device.h\n> @@ -55,6 +55,8 @@ public:\n>  \n>  \tSignal<> disconnected;\n>  \n> +\tstd::vector<MediaEntity *> locateEntities(unsigned int function);\n> +\n>  protected:\n>  \tstd::string logPrefix() const override;\n>  \n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index 75abd91d736a..353f34a81eca 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -794,7 +794,7 @@ void MediaDevice::fixupEntityFlags(struct media_v2_entity *entity)\n>   * low-level link setup as it performs no checks on the validity of the \\a\n>   * flags, and assumes that the supplied \\a flags are valid for the link (e.g.\n>   * immutable links cannot be disabled).\n> -*\n> + *\n>   * \\sa MediaLink::setEnabled(bool enable)\n>   *\n>   * \\return 0 on success or a negative error code otherwise\n> @@ -829,4 +829,26 @@ int MediaDevice::setupLink(const MediaLink *link, unsigned int flags)\n>  \treturn 0;\n>  }\n>  \n> +/**\n> + * \\brief Identify all entities of a common function in the MediaDevice\n> + * \\param[in] function The entity function to search for\n> + *\n> + * Search all entities within the graph of the MediaDevice and return\n> + * a vector of those which match the given function.\n> + *\n> + * \\return A vector of matching entities\n> + */\n> +std::vector<MediaEntity *> MediaDevice::locateEntities(unsigned int function)\n> +{\n> +\tstd::vector<MediaEntity *> found;\n> +\n> +\t/* Gather all the entities matching the function they expose. */\n> +\tfor (MediaEntity *entity : entities()) {\n> +\t\tif (entity->function() == function)\n> +\t\t\tfound.push_back(entity);\n> +\t}\n> +\n> +\treturn found;\n> +}\n> +\n>  } /* namespace libcamera */\n> -- \n> 2.47.2\n>","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 B3376C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  3 Apr 2025 10:31:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 628426899A;\n\tThu,  3 Apr 2025 12:31:07 +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 DA20F61867\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Apr 2025 12:31:05 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:6d9d:9854:3fc1:4bb2])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 826506D5;\n\tThu,  3 Apr 2025 12:29:11 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Gr5cWZds\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743676151;\n\tbh=Jf/FcmXaN1oc2yCNPFi5MAlLVfdJcC5B9PkRSlUYCUE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Gr5cWZdsXjPmhMsLwXmGojQOCvfO6TF61Rcjah3AXQdUWqJFk0A+Kw8+AC/npHIK8\n\tO3s3Zhz6PXgSxZxrMpeASeeCz27xtZ9U3atVpbRSlfSeQ5lC/BeHAVLk5yDCiZ1L9E\n\tufQkUFW1kRos81YrApOEw3ycrsFIi9DWLz473vnk=","Date":"Thu, 3 Apr 2025 12:31:02 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>, \n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>","Subject":"Re: [PATCH v4 1/3] libcamera: media_device: Add helper to return\n\tmatching entities","Message-ID":"<6en2ryzz2kw2wn7nmt7uyjjhyv26n6obpeczjgfhwganhomxeu@can5fewf3cnv>","References":"<20250402073919.183330-1-paul.elder@ideasonboard.com>\n\t<20250402073919.183330-2-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250402073919.183330-2-paul.elder@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]