From patchwork Thu Feb 26 15:59:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5894431 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 44B19BF440 for ; Thu, 26 Feb 2015 16:00:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5735D203AE for ; Thu, 26 Feb 2015 16:00:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56FC6203AC for ; Thu, 26 Feb 2015 16:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754442AbbBZQA2 (ORCPT ); Thu, 26 Feb 2015 11:00:28 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:53148 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754419AbbBZQAU (ORCPT ); Thu, 26 Feb 2015 11:00:20 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NKD004Y4Z4IEGB0@mailout2.samsung.com> for linux-media@vger.kernel.org; Fri, 27 Feb 2015 01:00:18 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-e7-54ef4312c176 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 1F.F4.09430.2134FE45; Fri, 27 Feb 2015 01:00:18 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NKD00448Z32VO60@mmp2.samsung.com>; Fri, 27 Feb 2015 01:00:18 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, gjasny@googlemail.com, hdegoede@redhat.com, kyungmin.park@samsung.com, Jacek Anaszewski Subject: [v4l-utils PATCH/RFC v5 05/14] mediactl: Add media device graph helpers Date: Thu, 26 Feb 2015 16:59:15 +0100 Message-id: <1424966364-3647-6-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1424966364-3647-1-git-send-email-j.anaszewski@samsung.com> References: <1424966364-3647-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOLMWRmVeSWpSXmKPExsVy+t9jQV0h5/chBs/O6FtMnzKL0eLN8elM Fr1XnzNanG16w27ROXEJu0XPhq2sFp+2fGNyYPd4OmEyu8fsjpmsHvNOBnq833eVzaNvyypG j8+b5ALYorhsUlJzMstSi/TtErgyHjz+z1bwWaXixImJjA2M32W7GDk5JARMJGaf3MsMYYtJ XLi3nq2LkYtDSGA6o8Tp7RNYIJx2JonuCb1gVWwChhI/X7xmArFFBOQlnvTeAOtgFtjNKPFs +R5WkISwQIDE7F0v2LsYOThYBFQllq2MBwnzCrhLvPn+mwkkLCGgIDFnkg1ImFPAQ2Lql0+M ILYQUMnXd8vZJjDyLmBkWMUomlqQXFCclJ5rpFecmFtcmpeul5yfu4kRHFzPpHcwrmqwOMQo wMGoxMM70+h9iBBrYllxZe4hRgkOZiURXn1roBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFeJfu2 ECGB9MSS1OzU1ILUIpgsEwenVANj1/5lr/rPXrhR42J323Rnz+zT+7aza34zfZB4xvN+FK8J i6XBifOlHx65vn1wXY6TI9Crp2ib7FdDx/I3upcL7/+8KODxtJ+x9oTGw0dvP3ErTV/nzvN8 bfYWWc9dTq5ny5NviKdVnXr9MMUhca+Nu+PfX+EL/LxDLE7sNZEyXrvWfUXP93tsSizFGYmG WsxFxYkAvZARXSoCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add new graph helpers useful for video pipeline discovering. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 48 +++++++++++++++++++++++++++++++++++++++++ utils/media-ctl/mediactl.h | 36 +++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index bbaf387..a294ada 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -35,6 +35,7 @@ #include #include +#include #include #include "mediactl.h" @@ -87,6 +88,29 @@ struct media_entity *media_get_entity_by_name(struct media_device *media, return NULL; } +struct media_entity *media_get_entity_by_devname(struct media_device *media, + const char *devname, + size_t length) +{ + unsigned int i; + + /* A match is impossible if the entity devname is longer than the + * maximum size we can get from the kernel. + */ + if (length >= FIELD_SIZEOF(struct media_entity, devname)) + return NULL; + + for (i = 0; i < media->entities_count; ++i) { + struct media_entity *entity = &media->entities[i]; + + if (strncmp(entity->devname, devname, length) == 0 && + entity->devname[length] == '\0') + return entity; + } + + return NULL; +} + struct media_entity *media_get_entity_by_id(struct media_device *media, __u32 id) { @@ -145,6 +169,11 @@ const char *media_entity_get_devname(struct media_entity *entity) return entity->devname[0] ? entity->devname : NULL; } +const char *media_entity_get_name(struct media_entity *entity) +{ + return entity->info.name; +} + struct media_entity *media_get_default_entity(struct media_device *media, unsigned int type) { @@ -177,6 +206,25 @@ const struct media_entity_desc *media_entity_get_info(struct media_entity *entit return &entity->info; } +int media_get_backlinks_by_entity(struct media_entity *entity, + struct media_link **backlinks, + int *num_backlinks) +{ + int num_bklinks = 0, i; + + if (entity == NULL || backlinks == NULL || num_backlinks == NULL) + return -EINVAL; + + for (i = 0; i < entity->num_links; ++i) + if ((entity->links[i].flags & MEDIA_LNK_FL_ENABLED) && + (entity->links[i].sink->entity == entity)) + backlinks[num_bklinks++] = &entity->links[i]; + + *num_backlinks = num_bklinks; + + return 0; +} + /* ----------------------------------------------------------------------------- * Open/close */ diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h index 3faee71..9db40a8 100644 --- a/utils/media-ctl/mediactl.h +++ b/utils/media-ctl/mediactl.h @@ -231,6 +231,15 @@ const struct media_link *media_entity_get_link(struct media_entity *entity, const char *media_entity_get_devname(struct media_entity *entity); /** + * @brief Get the name for an entity + * @param entity - media entity. + * + * This function returns the name of the entity. + * + * @return A pointer to the string with entity name + */ +const char *media_entity_get_name(struct media_entity *entity); + * @brief Get the type of an entity. * @param entity - the entity. * @@ -255,6 +264,19 @@ struct media_entity *media_get_entity_by_name(struct media_device *media, const char *name, size_t length); /** + * @brief Find an entity by the corresponding device node name. + * @param media - media device. + * @param devname - device node name. + * @param length - size of @a devname. + * + * Search for an entity with a device node name equal to @a devname. + * + * @return A pointer to the entity if found, or NULL otherwise. + */ +struct media_entity *media_get_entity_by_devname(struct media_device *media, + const char *devname, size_t length); + +/** * @brief Find an entity by its ID. * @param media - media device. * @param id - entity ID. @@ -434,4 +456,18 @@ int media_parse_setup_link(struct media_device *media, */ int media_parse_setup_links(struct media_device *media, const char *p); +/** + * @brief Get entity's enabled backlinks + * @param entity - media entity. + * @param backlinks - array of pointers to matching backlinks. + * @param num_backlinks - number of matching backlinks. + * + * Get links that are connected to the entity sink pads. + * + * @return 0 on success, or a negative error code on failure. + */ +int media_get_backlinks_by_entity(struct media_entity *entity, + struct media_link **backlinks, + int *num_backlinks); + #endif