From patchwork Thu Mar 10 05:07:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 8553961 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 26ED29F2B4 for ; Thu, 10 Mar 2016 05:07:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C2C020123 for ; Thu, 10 Mar 2016 05:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 442EF20148 for ; Thu, 10 Mar 2016 05:07:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935072AbcCJFHU (ORCPT ); Thu, 10 Mar 2016 00:07:20 -0500 Received: from mailout.easymail.ca ([64.68.201.169]:33751 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935061AbcCJFHR (ORCPT ); Thu, 10 Mar 2016 00:07:17 -0500 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 42209E960; Thu, 10 Mar 2016 00:07:16 -0500 (EST) X-Quarantine-ID: X-Virus-Scanned: Debian amavisd-new at mailout.easymail.ca X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Score: -3.691 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 ot4y4TLbNOSD; Thu, 10 Mar 2016 00:07:16 -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 CDBC2E936; Thu, 10 Mar 2016 00:07:15 -0500 (EST) Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 7649B9F373; Wed, 9 Mar 2016 22:07:15 -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 3/4] media: au0828 add media device change_source handler Date: Wed, 9 Mar 2016 22:07:09 -0700 Message-Id: <2d5a07078a83766aaf3f28be1616e7a4a3062ea3.1457585839.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: 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 media device change_source handler. Using the change_source handler, driver can disable current source and enable new one in one step when user selects a new input. Signed-off-by: Shuah Khan --- drivers/media/usb/au0828/au0828-core.c | 64 ++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index 5dc82e8..01dba5a 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -258,8 +258,8 @@ create_link: } } -static int au0828_enable_source(struct media_entity *entity, - struct media_pipeline *pipe) +static int __au0828_enable_source(struct media_entity *entity, + struct media_pipeline *pipe) { struct media_entity *source, *find_source; struct media_entity *sink; @@ -268,11 +268,6 @@ static int au0828_enable_source(struct media_entity *entity, struct media_device *mdev = entity->graph_obj.mdev; struct au0828_dev *dev; - if (!mdev) - return -ENODEV; - - mutex_lock(&mdev->graph_mutex); - dev = mdev->source_priv; /* @@ -399,28 +394,36 @@ static int au0828_enable_source(struct media_entity *entity, dev->active_source->name, dev->active_sink->name, dev->active_link_owner->name, ret); end: - mutex_unlock(&mdev->graph_mutex); pr_debug("au0828_enable_source() end %s %d %d\n", entity->name, entity->function, ret); return ret; } -static void au0828_disable_source(struct media_entity *entity) +static int au0828_enable_source(struct media_entity *entity, + struct media_pipeline *pipe) { - int ret = 0; struct media_device *mdev = entity->graph_obj.mdev; - struct au0828_dev *dev; + int ret; if (!mdev) - return; + return -ENODEV; mutex_lock(&mdev->graph_mutex); + ret = __au0828_enable_source(entity, pipe); + mutex_unlock(&mdev->graph_mutex); + return ret; +} + +static void __au0828_disable_source(struct media_entity *entity) +{ + int ret = 0; + struct media_device *mdev = entity->graph_obj.mdev; + struct au0828_dev *dev; + dev = mdev->source_priv; - if (!dev->active_link) { - ret = -ENODEV; - goto end; - } + if (!dev->active_link) + return; /* link is active - stop pipeline from source (tuner) */ if (dev->active_link->sink->entity == dev->active_sink && @@ -430,7 +433,7 @@ static void au0828_disable_source(struct media_entity *entity) * has active pipeline */ if (dev->active_link_owner != entity) - goto end; + return; __media_entity_pipeline_stop(entity); ret = __media_entity_setup_link(dev->active_link, 0); if (ret) @@ -445,10 +448,34 @@ static void au0828_disable_source(struct media_entity *entity) dev->active_source = NULL; dev->active_sink = NULL; } +} -end: +static void au0828_disable_source(struct media_entity *entity) +{ + struct media_device *mdev = entity->graph_obj.mdev; + + if (!mdev) + return; + + mutex_lock(&mdev->graph_mutex); + __au0828_disable_source(entity); mutex_unlock(&mdev->graph_mutex); } +static int au0828_change_source(struct media_entity *entity, + struct media_pipeline *pipe) +{ + struct media_device *mdev = entity->graph_obj.mdev; + int ret; + + if (!mdev) + return -ENODEV; + + mutex_lock(&mdev->graph_mutex); + __au0828_disable_source(entity); + ret = __au0828_enable_source(entity, pipe); + mutex_unlock(&mdev->graph_mutex); + return ret; +} #endif static int au0828_media_device_register(struct au0828_dev *dev, @@ -520,6 +547,7 @@ static int au0828_media_device_register(struct au0828_dev *dev, dev->media_dev->source_priv = (void *) dev; dev->media_dev->enable_source = au0828_enable_source; dev->media_dev->disable_source = au0828_disable_source; + dev->media_dev->change_source = au0828_change_source; #endif return 0; }