From patchwork Mon Jan 18 16:17:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 8055971 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 A4E02BEEE5 for ; Mon, 18 Jan 2016 16:18:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D0B3204AF for ; Mon, 18 Jan 2016 16:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E1D420397 for ; Mon, 18 Jan 2016 16:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755847AbcARQSZ (ORCPT ); Mon, 18 Jan 2016 11:18:25 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:51738 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755675AbcARQSY (ORCPT ); Mon, 18 Jan 2016 11:18:24 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O1501N1RPAIDD20@mailout4.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Jan 2016 01:18:22 +0900 (KST) X-AuditID: cbfee61b-f793c6d00000236c-a2-569d104e6067 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 49.59.09068.E401D965; Tue, 19 Jan 2016 01:18:22 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O15003TLP9I9Y00@mmp2.samsung.com>; Tue, 19 Jan 2016 01:18:22 +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, hverkuil@xs4all.nl, Jacek Anaszewski Subject: [PATCH 05/15] mediactl: Add media device graph helpers Date: Mon, 18 Jan 2016 17:17:30 +0100 Message-id: <1453133860-21571-6-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> References: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPLMWRmVeSWpSXmKPExsVy+t9jQV0/gblhBvd+61hMnzKL0eLN8elM FqcmP2Oy6L36nNGic+ISdoueDVtZLT5t+cbkwO7xdMJkdo/ZHTNZPeadDPR4v+8qm0ffllWM Hp83yXmc+vqZPYA9issmJTUnsyy1SN8ugStj8+3T7AWfVSqerWtla2D8LtvFyMkhIWAiceDa NWYIW0ziwr31bF2MXBxCArMYJRoPr2QBSQgJ/GSUeHEbrIhNwFDi54vXTCC2iIC8xJPeG2AN zAJbGCXu3lnEDpIQFrCXOPelGcxmEVCVaNn5CMzmFfCQmNrwGKiBA2ibgsScSTYgYU4BT4k3 N/ezQezykDhwdyvzBEbeBYwMqxglUguSC4qT0nON8lLL9YoTc4tL89L1kvNzNzGCg+2Z9A7G w7vcDzEKcDAq8fA6nJ0dJsSaWFZcmXuIUYKDWUmE9xDH3DAh3pTEyqrUovz4otKc1OJDjNIc LErivPsuRYYJCaQnlqRmp6YWpBbBZJk4OKUaGKU337D4HFstdzGk9eOZTAd7c/9JM89orHgY bLjh+/zDiz1Sbb4sWNf/8FW4/s1bh79IWL24IiV+JHvH+SkFs1Qf66xKr76qPadR49e07mMf zNdNu14gtHFBwApOl2MXL/Dv5dmWOo3lhED5Ro41q1zMT/xUuBTItN/a4bfx/AtFwTvMtIum bXdRYinOSDTUYi4qTgQA8pduCjICAAA= 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, 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 61b5f50..0be1845 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