From patchwork Thu Feb 16 02:19:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9576314 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF87960209 for ; Thu, 16 Feb 2017 02:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE80328471 for ; Thu, 16 Feb 2017 02:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2FAC28587; Thu, 16 Feb 2017 02:26:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A37028471 for ; Thu, 16 Feb 2017 02:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GiW3mfbJrswF0v+4J4TVoP3EP2nw4ToeTEvJUBOnjkg=; b=AlWO+b4s7WfSaxg1f3i8VsQNCO vkDwHzkGaU95iYFXJo62uhVmpHJBi9M3P7/IN+Qag38MBNUcN8BAr6C/glgkxuBe8WPIrekpYCgpK fArbb2tasiYAeaDZDNzSMQTW4qVKMZqsXoh048A/tTocTpUwHxTKvBx+PrtAHNBquiyEwkspBgxWD WQ8UVyhNBQAzwQPoyzZDBHCgkusz4ypLLGX6MKDvyTmjStEGHAvMyEiD4OOKHnJIWAUA+QfAz60wL KP9OdwZaCX3+mvUg1OfFaA17BSliyIFxus9eW7JQ5ezRH/0XGQvT/RF/Vp2d9yzOgzVMJUD4tZJ9D lAp1Cx8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ceBlv-0007tC-1X; Thu, 16 Feb 2017 02:26:15 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ceBgg-0003Ck-Cb for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2017 02:20:55 +0000 Received: by mail-pf0-x243.google.com with SMTP id e4so368484pfg.0 for ; Wed, 15 Feb 2017 18:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6HauPciIg/I8MLCDJHFAXWRga19bkVDjLUYiiYYTDZA=; b=M/hrW2NxUjf12yf90S9qnqjp3FC7ZsiGHaL8Zed+ToMkYfW1gN63H1uACX9NeEMtVh GnN9VkwbmfiStlyiVwPI+Gykfmu6j0njlgMS7u8icPO2l6j22jFmYX8W3hahGzYKsLgM df9bm6ZCuyDwk4XeiglDyA64Y2MxyF5lq77TLJTNYN/Crak9fh2R/q+aC6rL3FEHhrFd sR8o1VpcriNxKwbgAcGvb3ZiJGNb8CLrfZGt4RtLrO0DDypuGf2MmMar05iPjOJNL6xh iFlGXpEKPR/BA2Kzu5JuHY8Hv7vfeyxWtHTVCXO9EfDyUZF8DsKecRWAaiK0/KXZRNyN Fldg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6HauPciIg/I8MLCDJHFAXWRga19bkVDjLUYiiYYTDZA=; b=lG0CjKgoLi93YZPXUQJjL2njheVxX5LL7te59438cNh8PvQz4O18/8Zvl+88vHm0IJ Jinyz0FfT131EIZtyaQkshkgjrEKJFBbZWb9I3QhlEBr/KshwTJVLDTeBodWtD+40YQJ NmtpnhMSVymCNFyXE2R45LZdYnBtULBqbNd1HTo5eiUkTVgmiiUuUcJNHCQz+6XU+B8N 6VKuXv0O1rYXRDiGSubr6jQ/LaKMgZXzYcsQo2QYRaCK+Z2myCqOZCc7wxp5yGbL3Gpp BBoLj1fQP+3Uf598y38O72AZQfNs3j9U1w71D9ackbW5tefgDtLsjbMQdl82tZPH1+Hs EVjw== X-Gm-Message-State: AMke39lMl0pbXFxLnFTo+tKj6TyJ0d+X8DnZwe1yHx8FtuJ61H5P74YcbdD281pQZsr9/g== X-Received: by 10.84.160.197 with SMTP id v5mr48008798plg.161.1487211629912; Wed, 15 Feb 2017 18:20:29 -0800 (PST) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id t6sm9869352pgt.8.2017.02.15.18.20.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Feb 2017 18:20:28 -0800 (PST) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: robh+dt@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, kernel@pengutronix.de, fabio.estevam@nxp.com, linux@armlinux.org.uk, mchehab@kernel.org, hverkuil@xs4all.nl, nick@shmanahar.org, markus.heiser@darmarIT.de, p.zabel@pengutronix.de, laurent.pinchart+renesas@ideasonboard.com, bparrot@ti.com, geert@linux-m68k.org, arnd@arndb.de, sudipm.mukherjee@gmail.com, minghsiu.tsai@mediatek.com, tiffany.lin@mediatek.com, jean-christophe.trotin@st.com, horms+renesas@verge.net.au, niklas.soderlund+renesas@ragnatech.se, robert.jarzmik@free.fr, songjun.wu@microchip.com, andrew-ct.chen@mediatek.com, gregkh@linuxfoundation.org, shuah@kernel.org, sakari.ailus@linux.intel.com, pavel@ucw.cz Subject: [PATCH v4 14/36] [media] v4l2-mc: add a function to inherit controls from a pipeline Date: Wed, 15 Feb 2017 18:19:16 -0800 Message-Id: <1487211578-11360-15-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487211578-11360-1-git-send-email-steve_longerbeam@mentor.com> References: <1487211578-11360-1-git-send-email-steve_longerbeam@mentor.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170215_182050_690268_7CB3022A X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, devicetree@vger.kernel.org, Steve Longerbeam , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP v4l2_pipeline_inherit_controls() will add the v4l2 controls from all subdev entities in a pipeline to a given video device. Signed-off-by: Steve Longerbeam Reviewed-by: Pavel Machek --- drivers/media/v4l2-core/v4l2-mc.c | 48 +++++++++++++++++++++++++++++++++++++++ include/media/v4l2-mc.h | 25 ++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 303980b..09d4d97 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -238,6 +239,53 @@ int v4l_vb2q_enable_media_source(struct vb2_queue *q) } EXPORT_SYMBOL_GPL(v4l_vb2q_enable_media_source); +int __v4l2_pipeline_inherit_controls(struct video_device *vfd, + struct media_entity *start_entity) +{ + struct media_device *mdev = start_entity->graph_obj.mdev; + struct media_entity *entity; + struct media_graph graph; + struct v4l2_subdev *sd; + int ret; + + ret = media_graph_walk_init(&graph, mdev); + if (ret) + return ret; + + media_graph_walk_start(&graph, start_entity); + + while ((entity = media_graph_walk_next(&graph))) { + if (!is_media_entity_v4l2_subdev(entity)) + continue; + + sd = media_entity_to_v4l2_subdev(entity); + + ret = v4l2_ctrl_add_handler(vfd->ctrl_handler, + sd->ctrl_handler, + NULL); + if (ret) + break; + } + + media_graph_walk_cleanup(&graph); + return ret; +} +EXPORT_SYMBOL_GPL(__v4l2_pipeline_inherit_controls); + +int v4l2_pipeline_inherit_controls(struct video_device *vfd, + struct media_entity *start_entity) +{ + struct media_device *mdev = start_entity->graph_obj.mdev; + int ret; + + mutex_lock(&mdev->graph_mutex); + ret = __v4l2_pipeline_inherit_controls(vfd, start_entity); + mutex_unlock(&mdev->graph_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(v4l2_pipeline_inherit_controls); + /* ----------------------------------------------------------------------------- * Pipeline power management * diff --git a/include/media/v4l2-mc.h b/include/media/v4l2-mc.h index 2634d9d..9848e77 100644 --- a/include/media/v4l2-mc.h +++ b/include/media/v4l2-mc.h @@ -171,6 +171,17 @@ void v4l_disable_media_source(struct video_device *vdev); */ int v4l_vb2q_enable_media_source(struct vb2_queue *q); +/** + * v4l2_pipeline_inherit_controls - Add the v4l2 controls from all + * subdev entities in a pipeline to + * the given video device. + * @vfd: the video device + * @start_entity: Starting entity + */ +int __v4l2_pipeline_inherit_controls(struct video_device *vfd, + struct media_entity *start_entity); +int v4l2_pipeline_inherit_controls(struct video_device *vfd, + struct media_entity *start_entity); /** * v4l2_pipeline_pm_use - Update the use count of an entity @@ -231,6 +242,20 @@ static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q) return 0; } +static inline int __v4l2_pipeline_inherit_controls( + struct video_device *vfd, + struct media_entity *start_entity) +{ + return 0; +} + +static inline int v4l2_pipeline_inherit_controls( + struct video_device *vfd, + struct media_entity *start_entity) +{ + return 0; +} + static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use) { return 0;