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: 32664 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84) (envelope-from ) id 1aLCWN-0005NV-GA; Mon, 18 Jan 2016 16:19:11 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.76/mailfrontend-7) with esmtp id 1aLCWL-0000mU-1f; Mon, 18 Jan 2016 17:19:11 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932169AbcARQTH (ORCPT + 1 other); 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-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.1.18.161216 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, NO_URI_HTTPS 0, REFERENCES 0, SINGLE_URI_IN_BODY 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __SINGLE_URI_TEXT 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS ' 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.