From patchwork Wed Jul 22 22:42:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 6847621 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 DB5A49F1D4 for ; Wed, 22 Jul 2015 22:43:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 02DAD20462 for ; Wed, 22 Jul 2015 22:43:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECD1C200F2 for ; Wed, 22 Jul 2015 22:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753174AbbGVWnL (ORCPT ); Wed, 22 Jul 2015 18:43:11 -0400 Received: from resqmta-po-12v.sys.comcast.net ([96.114.154.171]:44387 "EHLO resqmta-po-12v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753079AbbGVWm7 (ORCPT ); Wed, 22 Jul 2015 18:42:59 -0400 Received: from resomta-po-13v.sys.comcast.net ([96.114.154.237]) by resqmta-po-12v.sys.comcast.net with comcast id vaiy1q00457bBgG01aiyGS; Wed, 22 Jul 2015 22:42:58 +0000 Received: from mail.gonehiking.org ([73.181.52.62]) by resomta-po-13v.sys.comcast.net with comcast id vaiu1q00C1LXgTt01aixJV; Wed, 22 Jul 2015 22:42:58 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id A9355120447; Wed, 22 Jul 2015 16:42:56 -0600 (MDT) From: Shuah Khan To: mchehab@osg.samsung.com, hans.verkuil@cisco.com, laurent.pinchart@ideasonboard.com, tiwai@suse.de, sakari.ailus@linux.intel.com, perex@perex.cz, crope@iki.fi, arnd@arndb.de, stefanr@s5r6.in-berlin.de, ruchandani.tina@gmail.com, chehabrafael@gmail.com, dan.carpenter@oracle.com, prabhakar.csengg@gmail.com, chris.j.arges@canonical.com, agoode@google.com, pierre-louis.bossart@linux.intel.com, gtmkramer@xs4all.nl, clemens@ladisch.de, daniel@zonque.org, vladcatoi@gmail.com, misterpib@gmail.com, damien@zamaudio.com, pmatilai@laiskiainen.org, takamichiho@gmail.com, normalperson@yhbt.net, bugzilla.frnkcg@spamgourmet.com, joe@oampo.co.uk, calcprogrammer1@gmail.com, jussi@sonarnerd.net, kyungmin.park@samsung.com, s.nawrocki@samsung.com, kgene@kernel.org, hyun.kwon@xilinx.com, michal.simek@xilinx.com, soren.brinkmann@xilinx.com, pawel@osciak.com, m.szyprowski@samsung.com, gregkh@linuxfoundation.org, skd08@gmail.com, nsekhar@ti.com, boris.brezillon@free-electrons.com, Julia.Lawall@lip6.fr, elfring@users.sourceforge.net, p.zabel@pengutronix.de, ricardo.ribalda@gmail.com Cc: Shuah Khan , linux-media@vger.kernel.org, alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org Subject: [PATCH v2 16/19] media: Change v4l-core to check for tuner availability Date: Wed, 22 Jul 2015 16:42:17 -0600 Message-Id: <690e2d0882325f1f4b67688a42bb8056f46dec7e.1437599281.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1437604978; bh=NQTrcSod9qLZ7iegQ7kRS7hxu97iKhVLmdMLVCqQWrI=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=Ja8fwvpA19AgqLk4YsXFD4ppdYtzeLe9KeB55Sb1a1x/mek7+85tkYezNvWe4z7n+ RP6Rujob/f3HyXjTqZy2LEdNz/btsw16JMpmCe/n2SbWNVLxvtUenIP4YssOPKfGiK 0y4AH9s94ebKoTaRBPRVUC9ObPINVQC7tJ4iKlItgpXDZp/DDhlA3/vnzzEJL+4Y90 hCoAm3e2SHBHfpIDUJ+qfTG2A0983PS7ola+RZZ0N/SV39GKCTa2JBJcCZUTwkp4vB TVdoTLMRh92j5tepBvjP3DHYPfqtS2K89/8iwl6/cYoWtqeq3G6Xh6ezRA2QOJGMrB UiZ43bWmCGujg== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Change s_input, s_fmt, s_tuner, s_frequency, querystd, s_hw_freq_seek, and vb2_streamon interfaces that alter the tuner configuration to check for tuner availability by calling v4l_enable_media_tuner(). If tuner isn't free, return -EBUSY. Signed-off-by: Shuah Khan --- drivers/media/v4l2-core/v4l2-ioctl.c | 29 +++++++++++++++++++++++++++++ drivers/media/v4l2-core/videobuf2-core.c | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 85de455..deffc1b 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -1035,6 +1035,12 @@ static int v4l_querycap(const struct v4l2_ioctl_ops *ops, static int v4l_s_input(const struct v4l2_ioctl_ops *ops, struct file *file, void *fh, void *arg) { + struct video_device *vfd = video_devdata(file); + int ret; + + ret = v4l_enable_media_tuner(vfd); + if (ret) + return ret; return ops->vidioc_s_input(file, fh, *(unsigned int *)arg); } @@ -1433,6 +1439,9 @@ static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, bool is_tx = vfd->vfl_dir != VFL_DIR_RX; int ret; + ret = v4l_enable_media_tuner(vfd); + if (ret) + return ret; v4l_sanitize_format(p); switch (p->type) { @@ -1612,7 +1621,11 @@ static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, { struct video_device *vfd = video_devdata(file); struct v4l2_tuner *p = arg; + int ret; + ret = v4l_enable_media_tuner(vfd); + if (ret) + return ret; p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; return ops->vidioc_s_tuner(file, fh, p); @@ -1650,7 +1663,11 @@ static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops, struct video_device *vfd = video_devdata(file); const struct v4l2_frequency *p = arg; enum v4l2_tuner_type type; + int ret; + ret = v4l_enable_media_tuner(vfd); + if (ret) + return ret; if (vfd->vfl_type == VFL_TYPE_SDR) { if (p->type != V4L2_TUNER_ADC && p->type != V4L2_TUNER_RF) return -EINVAL; @@ -1705,7 +1722,11 @@ static int v4l_s_std(const struct v4l2_ioctl_ops *ops, { struct video_device *vfd = video_devdata(file); v4l2_std_id id = *(v4l2_std_id *)arg, norm; + int ret; + ret = v4l_enable_media_tuner(vfd); + if (ret) + return ret; norm = id & vfd->tvnorms; if (vfd->tvnorms && !norm) /* Check if std is supported */ return -EINVAL; @@ -1719,7 +1740,11 @@ static int v4l_querystd(const struct v4l2_ioctl_ops *ops, { struct video_device *vfd = video_devdata(file); v4l2_std_id *p = arg; + int ret; + ret = v4l_enable_media_tuner(vfd); + if (ret) + return ret; /* * If no signal is detected, then the driver should return * V4L2_STD_UNKNOWN. Otherwise it should return tvnorms with @@ -1738,7 +1763,11 @@ static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, struct video_device *vfd = video_devdata(file); struct v4l2_hw_freq_seek *p = arg; enum v4l2_tuner_type type; + int ret; + ret = v4l_enable_media_tuner(vfd); + if (ret) + return ret; /* s_hw_freq_seek is not supported for SDR for now */ if (vfd->vfl_type == VFL_TYPE_SDR) return -EINVAL; diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index d835814..f2711e4 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2300,10 +2300,15 @@ EXPORT_SYMBOL_GPL(vb2_queue_error); */ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) { + int ret; + if (vb2_fileio_is_active(q)) { dprintk(1, "file io in progress\n"); return -EBUSY; } + ret = v4l_enable_media_tuner(q->owner->vdev); + if (ret) + return ret; return vb2_internal_streamon(q, type); } EXPORT_SYMBOL_GPL(vb2_streamon);