From patchwork Mon Jan 18 16:17:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 8056061 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D16109F440 for ; Mon, 18 Jan 2016 16:19:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0618A204AD for ; Mon, 18 Jan 2016 16:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F318204B0 for ; Mon, 18 Jan 2016 16:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932169AbcARQTH (ORCPT ); Mon, 18 Jan 2016 11:19:07 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:46324 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932123AbcARQTG (ORCPT ); Mon, 18 Jan 2016 11:19:06 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O1500V0HPBTN320@mailout3.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Jan 2016 01:19:05 +0900 (KST) X-AuditID: cbfee61a-f79266d000003652-23-569d1079d2c9 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 7B.31.13906.9701D965; Tue, 19 Jan 2016 01:19:05 +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:19:05 +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 14/15] mediactl: libv4l2subdev: Enable opening/closing pipelines Date: Mon, 18 Jan 2016 17:17:39 +0100 Message-id: <1453133860-21571-15-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+NgFprLLMWRmVeSWpSXmKPExsVy+t9jQd1KgblhBls7NSymT5nFaPHm+HQm i1OTnzFZ9F59zmjROXEJu0XPhq2sFp+2fGNyYPd4OmEyu8fsjpmsHvNOBnq833eVzaNvyypG j8+b5DxOff3MHsAexWWTkpqTWZZapG+XwJXx52tIwTmJijU7LzA1MP4W7mLk4JAQMJFY21bR xcgJZIpJXLi3nq2LkYtDSGAWo8T5DXfZQRJCAj8ZJS5/dAOx2QQMJX6+eM0EYosIyEs86b0B 1sAssIVR4u6dRWANwgIBElcffWUGsVkEVCU+3b0G1sAr4Clxd/piFojFChJzJtmAhDmBwm9u 7meD2OUhceDuVuYJjLwLGBlWMUqkFiQXFCel5xrmpZbrFSfmFpfmpesl5+duYgQH2jOpHYwH d7kfYhTgYFTi4XU4OztMiDWxrLgy9xCjBAezkgjvIY65YUK8KYmVValF+fFFpTmpxYcYpTlY lMR5ay9FhgkJpCeWpGanphakFsFkmTg4pRoYOxMPH5l0mn/Z8sWqDG4ejuYbWtZue+X/6qnL v/SzjOFK5ZKS/nf3/9NInXbncJDTvPKP8VfqPxsFzWNpMni55W9j8pWPWwKXTfrU7vIlNeaX Bs8Urixxpje/Njz86stafsU0eR6fUsmXyUF7fGec6rsTyJHRtSvfytH3zYvVCmdnflJdUjN7 nRJLcUaioRZzUXEiAFfx+rgwAgAA 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 functions for opening and closing media entity pipelines at one go. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libv4l2subdev.c | 60 +++++++++++++++++++++++++++++++++++++++ utils/media-ctl/v4l2subdev.h | 18 ++++++++++++ 2 files changed, 78 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 14e9423..6e626fe 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -118,6 +118,66 @@ void v4l2_subdev_close(struct media_entity *entity) entity->sd->fd = -1; } +int v4l2_subdev_open_pipeline(struct media_device *media) +{ + struct media_entity *entity = media->pipeline; + int ret; + + if (entity == NULL) + return 0; + + /* + * Stop walking the pipeline on the last last but one entity, because + * the sink entity sub-device was opened by libv4l2 core and its + * file descriptor needs to be preserved. + */ + while (entity->next) { + media_dbg(media, "Opening sub-device: %s\n", entity->devname); + ret = v4l2_subdev_open(entity); + if (ret < 0) + return ret; + + if (entity->sd->fd < 0) + goto err_open_subdev; + + entity = entity->next; + } + + return 0; + +err_open_subdev: + v4l2_subdev_release_pipeline(media); + + return -EINVAL; +} + +void v4l2_subdev_release_pipeline(struct media_device *media) +{ + struct media_entity *entity = media->pipeline; + + if (entity == NULL) + return; + /* + * Stop walking the pipeline on the last last but one entity, because + * the sink entity sub-device should be released by the client that + * instantiated it. + */ + while (entity->next) { + if (!entity->sd) { + entity = entity->next; + continue; + } + + if (entity->sd->fd >= 0) { + media_dbg(media, "Releasing sub-device: %s\n", entity->devname); + v4l2_subdev_release(entity, true); + } + + entity = entity->next; + } +} + + int v4l2_subdev_get_format(struct media_entity *entity, struct v4l2_mbus_framefmt *format, unsigned int pad, enum v4l2_subdev_format_whence which) diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 607ec50..94f6bf1 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -100,6 +100,24 @@ int v4l2_subdev_open(struct media_entity *entity); void v4l2_subdev_close(struct media_entity *entity); /** + * @brief Open media device pipeline + * @param media - media device. + * + * Open all sub-devices in the media device pipeline. + * + * @return 0 on success, or a negative error code on failure. + */ +int v4l2_subdev_open_pipeline(struct media_device *media); + +/** + * @brief Release media device pipeline sub-devices + * @param media - media device. + * + * Release all sub-devices in the media device pipeline. + */ +void v4l2_subdev_release_pipeline(struct media_device *media); + +/** * @brief Retrieve the format on a pad. * @param entity - subdev-device media entity. * @param format - format to be filled.