From patchwork Thu Mar 10 18:17:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 8559301 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 2F7059F38C for ; Thu, 10 Mar 2016 18:18:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BE8D2201BB for ; Thu, 10 Mar 2016 18:17:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 72EFA2012B for ; Thu, 10 Mar 2016 18:17:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753460AbcCJSRx (ORCPT ); Thu, 10 Mar 2016 13:17:53 -0500 Received: from mailout.easymail.ca ([64.68.201.169]:44714 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753173AbcCJSRw (ORCPT ); Thu, 10 Mar 2016 13:17:52 -0500 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 304FFE4F5; Thu, 10 Mar 2016 13:17:51 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at mailout.easymail.ca X-Spam-Score: -3.692 X-Spam-Level: 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 Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (easymail-mailout.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WOM+ftiOHJ08; Thu, 10 Mar 2016 13:17:50 -0500 (EST) Received: from mail.gonehiking.org (c-73-181-52-62.hsd1.co.comcast.net [73.181.52.62]) by mailout.easymail.ca (Postfix) with ESMTPA id 97A9BE4DA; Thu, 10 Mar 2016 13:17:50 -0500 (EST) Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id F08539F105; Thu, 10 Mar 2016 11:17:49 -0700 (MST) From: Shuah Khan To: mchehab@osg.samsung.com, hans.verkuil@cisco.com, chehabrafael@gmail.com, javier@osg.samsung.com, inki.dae@samsung.com, jh1009.sung@samsung.com, sakari.ailus@linux.intel.com Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] media: v4l2-mc add v4l_change_media_source() to invoke change_source Date: Thu, 10 Mar 2016 11:17:48 -0700 Message-Id: <1457633868-4861-1-git-send-email-shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a common routine to invoke media device change_source handler. Signed-off-by: Shuah Khan --- Changes since v1: - Fixed !CONFIG_MEDIA_CONTROLLER compile error for v4l_change_media_source() drivers/media/v4l2-core/v4l2-mc.c | 14 ++++++++++++++ include/media/v4l2-mc.h | 25 ++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index ae661ac..478b2768 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -217,6 +217,20 @@ void v4l_disable_media_source(struct video_device *vdev) } EXPORT_SYMBOL_GPL(v4l_disable_media_source); +int v4l_change_media_source(struct video_device *vdev) +{ + struct media_device *mdev = vdev->entity.graph_obj.mdev; + int ret; + + if (!mdev || !mdev->change_source) + return 0; + ret = mdev->change_source(&vdev->entity, &vdev->pipe); + if (ret) + return -EBUSY; + return 0; +} +EXPORT_SYMBOL_GPL(v4l_change_media_source); + int v4l_vb2q_enable_media_source(struct vb2_queue *q) { struct v4l2_fh *fh = q->owner; diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index 98a938a..50b9348 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -154,8 +154,26 @@ int v4l_enable_media_source(struct video_device *vdev); */ void v4l_disable_media_source(struct video_device *vdev); +/** + * v4l_change_media_source() - Hold media source for exclusive use + * if free + * + * @vdev: pointer to struct video_device + * + * This interface calls change_source handler to change + * the current source it is holding. The change_source + * disables the current source and starts pipeline to + * the new source. This interface should be used when + * user changes source using s_input handler to keep + * the previously granted permission for exclusive use + * with a new input source. + * + * Return: returns zero on success or a negative error code. + */ +int v4l_change_media_source(struct video_device *vdev); + /* - * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use + * v4l_vb2q_enable_media_source - Hold media source for exclusive use * if free. * @q - pointer to struct vb2_queue * @@ -219,6 +237,11 @@ static inline int v4l_enable_media_source(struct video_device *vdev) return 0; } +static inline int v4l_change_media_source(struct video_device *vdev) +{ + return 0; +} + static inline void v4l_disable_media_source(struct video_device *vdev) { }