From patchwork Wed Oct 12 14:35:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 9373321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E24360839 for ; Wed, 12 Oct 2016 14:46:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F9B629D54 for ; Wed, 12 Oct 2016 14:46:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 740B229D9F; Wed, 12 Oct 2016 14:46:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B2B129D54 for ; Wed, 12 Oct 2016 14:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933677AbcJLOqo (ORCPT ); Wed, 12 Oct 2016 10:46:44 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:45639 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933642AbcJLOqn (ORCPT ); Wed, 12 Oct 2016 10:46:43 -0400 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OEX01FZBV7FY8A0@mailout1.samsung.com> for linux-media@vger.kernel.org; Wed, 12 Oct 2016 23:35:39 +0900 (KST) X-AuditID: cbfee61a-f79786d000004c78-30-57fe4a3b7261 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 50.E8.19576.B3A4EF75; Wed, 12 Oct 2016 23:35:39 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OEX00HXUV70WM50@mmp1.samsung.com>; Wed, 12 Oct 2016 23:35:39 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, hverkuil@xs4all.nl, mchehab@kernel.org, m.szyprowski@samsung.com, s.nawrocki@samsung.com, Jacek Anaszewski Subject: [PATCH v4l-utils v7 3/7] mediactl: Add media_entity_get_backlinks() Date: Wed, 12 Oct 2016 16:35:18 +0200 Message-id: <1476282922-11544-4-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1476282922-11544-1-git-send-email-j.anaszewski@samsung.com> References: <1476282922-11544-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsVy+t9jAV1rr3/hBt9/W1icmvyMyaL36nNG i54NW1kt1h65y26xbNMfJovDb9pZLT5t+cbkwO6xaVUnm8e8k4EefVtWMXp83iTncerrZ/YA 1ig3m4zUxJTUIoXUvOT8lMy8dFul0BA3XQslhbzE3FRbpQhd35AgJYWyxJxSIM/IAA04OAe4 Byvp2yW4Zcy5sZm54JdwxbQPdxkbGI8KdDFyckgImEhs2vmaBcIWk7hwbz1bFyMXh5DAUkaJ ud/6GSGcn4wSV2+vYgWpYhMwlPj54jUTiC0iIC/xpPcGG4jNLLCaUeLishQQW1jAR+Jx60Ww GhYBVYlJ7x4xg9i8Ah4SD/ZMZ4XYJidx8thkMJtTwFPi0+eXYHOEgGrO7DvEOoGRdwEjwypG idSC5ILipPRcw7zUcr3ixNzi0rx0veT83E2M4JB+JrWD8eAu90OMAhyMSjy8Al//hAuxJpYV V+YeYpTgYFYS4Q12+xcuxJuSWFmVWpQfX1Sak1p8iNEU6LCJzFKiyfnAeMsriTc0MTcxNzaw MLe0NDFSEudtnP0sXEggPbEkNTs1tSC1CKaPiYNTqoFR3Dror6my6OwJWQIWM/d0fs940fTn Of9iVtnJaQXxq9gfSyVufv7p3B1R/uwStaObdTlLvrl4FVe+iVa9fP/zr+KayFn3mfJ6+kpZ ZmukXf8a4mOg6fM0am7K45PLhd2eXlpd+LbtVoSrreDe1RViiSKZXAVnTy++OOPCh5lBX15/ +pHZqVOtxFKckWioxVxUnAgAeU9grX8CAAA= X-MTR: 20000000000000000@CPGS Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a new graph helper useful for discovering video pipeline. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 21 +++++++++++++++++++++ utils/media-ctl/mediactl.h | 15 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 91ed003..155b65f 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -36,6 +36,7 @@ #include #include +#include #include #include "mediactl.h" @@ -172,6 +173,26 @@ const struct media_entity_desc *media_entity_get_info(struct media_entity *entit return &entity->info; } +int media_entity_get_backlinks(struct media_entity *entity, + struct media_link **backlinks, + unsigned int *num_backlinks) +{ + unsigned int num_bklinks = 0; + int 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 336cbf9..b1f33cd 100644 --- a/utils/media-ctl/mediactl.h +++ b/utils/media-ctl/mediactl.h @@ -434,6 +434,20 @@ 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_entity_get_backlinks(struct media_entity *entity, + struct media_link **backlinks, + unsigned int *num_backlinks); + +/** * @brief Get v4l2_subdev for the entity * @param entity - media entity * @@ -443,4 +457,5 @@ int media_parse_setup_links(struct media_device *media, const char *p); */ struct v4l2_subdev *media_entity_get_v4l2_subdev(struct media_entity *entity); + #endif