From patchwork Thu Feb 26 15:59:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5894481 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 8D1389F37F for ; Thu, 26 Feb 2015 16:01:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B39D4203A4 for ; Thu, 26 Feb 2015 16:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E089A203AB for ; Thu, 26 Feb 2015 16:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754480AbbBZQBK (ORCPT ); Thu, 26 Feb 2015 11:01:10 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:54796 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754485AbbBZQBH (ORCPT ); Thu, 26 Feb 2015 11:01:07 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NKD000GTZ5UM400@mailout3.samsung.com> for linux-media@vger.kernel.org; Fri, 27 Feb 2015 01:01:06 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-6c-54ef43427485 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 30.F0.20081.2434FE45; Fri, 27 Feb 2015 01:01:06 +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:01:06 +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 13/14] mediactl: libv4l2subdev: Enable opening/closing pipelines Date: Thu, 26 Feb 2015 16:59:23 +0100 Message-id: <1424966364-3647-14-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+NgFprGLMWRmVeSWpSXmKPExsVy+t9jQV0n5/chBv+38FpMnzKL0eLN8elM Fr1XnzNanG16w27ROXEJu0XPhq2sFp+2fGNyYPd4OmEyu8fsjpmsHvNOBnq833eVzaNvyypG j8+b5ALYorhsUlJzMstSi/TtErgyDn7gKTgjUXH59if2Bsafwl2MnBwSAiYSj+b8YYKwxSQu 3FvP1sXIxSEkMJ1RYn3fXnaQhJBAO5PEw2OJIDabgKHEzxevwRpEBOQlnvTeAGtgFtjNKPFs +R5WkISwQLLEtBe7GEFsFgFViV8fV7CA2LwCHhIbDz0BGsoBtE1BYs4kG5AwJ1B46pdPjBC7 3CW+vlvONoGRdwEjwypG0dSC5ILipPRcQ73ixNzi0rx0veT83E2M4NB6JrWDcWWDxSFGAQ5G JR7ehOx3IUKsiWXFlbmHGCU4mJVEePWt34cI8aYkVlalFuXHF5XmpBYfYpTmYFES51WybwsR EkhPLEnNTk0tSC2CyTJxcEo1MDpM49jxc/GHDU2KXdbXuc49uiaWvtxn60vuVVNlFotJuGc8 m7zn9oHMezOboratXKHx+8H3uekbzczeep9eo1K/rqrwhdyGafnccdOSYnlWT3Dsr3BPXHH1 rcc7pjcTZDaobsndx7Ri7uOIxeqXIs6t+uvkfDRl5nKth9ccT9ziWxuzLyNJ5RmbEktxRqKh FnNRcSIADteiyCkCAAA= 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 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 379fe64..4475ef7 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -117,6 +117,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 0f1deca..2fdcb76 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -90,6 +90,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.