From patchwork Mon Nov 2 04:43:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junghak Sung X-Patchwork-Id: 7533731 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 67A8FBEEA4 for ; Mon, 2 Nov 2015 04:44:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0F7B205C7 for ; Mon, 2 Nov 2015 04:44:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8B22205DC for ; Mon, 2 Nov 2015 04:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbbKBEoF (ORCPT ); Sun, 1 Nov 2015 23:44:05 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:41811 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751740AbbKBEn6 (ORCPT ); Sun, 1 Nov 2015 23:43:58 -0500 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX602EI87T0YQE0@mailout4.samsung.com> for linux-media@vger.kernel.org; Mon, 02 Nov 2015 13:43:48 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.112]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 3E.79.05272.40AE6365; Mon, 2 Nov 2015 13:43:48 +0900 (KST) X-AuditID: cbfee68e-f791c6d000001498-53-5636ea04ce07 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id CE.D7.23663.40AE6365; Mon, 2 Nov 2015 13:43:48 +0900 (KST) Received: from localhost.localdomain ([10.252.83.96]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NX600C7F7T0BE80@mmp2.samsung.com>; Mon, 02 Nov 2015 13:43:48 +0900 (KST) From: Junghak Sung To: linux-media@vger.kernel.org, mchehab@osg.samsung.com, hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi, pawel@osciak.com Cc: inki.dae@samsung.com, sw0312.kim@samsung.com, nenggun.kim@samsung.com, sangbae90.lee@samsung.com, rany.kwon@samsung.com, Junghak Sung Subject: [RFC PATCH v8 3/6] media: videobuf2: Separate vb2_poll() Date: Mon, 02 Nov 2015 13:43:42 +0900 Message-id: <1446439425-13242-4-git-send-email-jh1009.sung@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1446439425-13242-1-git-send-email-jh1009.sung@samsung.com> References: <1446439425-13242-1-git-send-email-jh1009.sung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRmVeSWpSXmKPExsWyRsSkQJfllVmYwbn1uhanJj9jsph0fwKL xfbjr9gtOicuYbfo2bCV1WL1swqLA327mCymvP3JbvFv2lNmizP7V7JZHP90kMVixuSXbA48 HrM7ZrJ6HP66kMXj8a+XbB5b+u+ye/RtWcXo8XmTnMepr5/ZA9ijuGxSUnMyy1KL9O0SuDJu 9T1iLnihW9G+W7KBcYZKFyMnh4SAiUTfnxusELaYxIV769lAbCGBFYwSv//qwdQ0zNvH3MXI BRSfxSjRvXMnC4TznVHi24c9QBkODjYBHYnJmw1B4iICMxgleo+vYgJxmAWWM0qcfn2KHWSU sICjxJO1l5lBbBYBVYnHq/4wgdi8Au4SR6bNYAMZJCGgIDFnkg1ImFPAQ+L9hF9MEBe5S0yc vYcdZKaEwCV2ifvHrrFCzBGQ+Db5EAtEr6zEpgPMEFdLShxccYNlAqPwAkaGVYyiqQX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v06+h5 BXvMFDhe+cVs15l5o/fvtV02982PGVaLlVpMzV+kms+i/nG+eomozdvDfdIt/lUrhXaLn4s0 q9OWbn9UMPuc4YpFZzRMl2+e/0TXvyyutmnvihU1S7Ydvn/oyvK32kfnfhJu9CiZ0yckZ/+l sjbLhDN3Sf3cd+0GXtOXstzxKvv0SYmlOCPRUIu5qDgRAJ+RJ+XdAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected 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 Separate vb2_poll() into core and v4l2 part. Signed-off-by: Junghak Sung Signed-off-by: Geunyoung Kim Acked-by: Seung-Woo Kim Acked-by: Inki Dae --- drivers/media/v4l2-core/videobuf2-v4l2.c | 80 +++++++++++++++++++----------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-v4l2.c b/drivers/media/v4l2-core/videobuf2-v4l2.c index 21857d6..5be9ed8e 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c @@ -750,7 +750,7 @@ void vb2_queue_release(struct vb2_queue *q) EXPORT_SYMBOL_GPL(vb2_queue_release); /** - * vb2_poll() - implements poll userspace operation + * vb2_core_poll() - implements poll userspace operation * @q: videobuf2 queue * @file: file argument passed to the poll file operation handler * @wait: wait argument passed to the poll file operation handler @@ -762,33 +762,20 @@ EXPORT_SYMBOL_GPL(vb2_queue_release); * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor * will be reported as available for writing. * - * If the driver uses struct v4l2_fh, then vb2_poll() will also check for any - * pending events. - * * The return values from this function are intended to be directly returned * from poll handler in driver. */ -unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) +unsigned int vb2_core_poll(struct vb2_queue *q, struct file *file, + poll_table *wait) { - struct video_device *vfd = video_devdata(file); unsigned long req_events = poll_requested_events(wait); struct vb2_buffer *vb = NULL; - unsigned int res = 0; unsigned long flags; - if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { - struct v4l2_fh *fh = file->private_data; - - if (v4l2_event_pending(fh)) - res = POLLPRI; - else if (req_events & POLLPRI) - poll_wait(file, &fh->wait, wait); - } - if (!q->is_output && !(req_events & (POLLIN | POLLRDNORM))) - return res; + return 0; if (q->is_output && !(req_events & (POLLOUT | POLLWRNORM))) - return res; + return 0; /* * Start file I/O emulator only if streaming API has not been used yet. @@ -797,16 +784,16 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) if (!q->is_output && (q->io_modes & VB2_READ) && (req_events & (POLLIN | POLLRDNORM))) { if (__vb2_init_fileio(q, 1)) - return res | POLLERR; + return POLLERR; } if (q->is_output && (q->io_modes & VB2_WRITE) && (req_events & (POLLOUT | POLLWRNORM))) { if (__vb2_init_fileio(q, 0)) - return res | POLLERR; + return POLLERR; /* * Write to OUTPUT queue can be done immediately. */ - return res | POLLOUT | POLLWRNORM; + return POLLOUT | POLLWRNORM; } } @@ -815,21 +802,21 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) * error flag is set. */ if (!vb2_is_streaming(q) || q->error) - return res | POLLERR; + return POLLERR; /* * For compatibility with vb1: if QBUF hasn't been called yet, then * return POLLERR as well. This only affects capture queues, output * queues will always initialize waiting_for_buffers to false. */ if (q->waiting_for_buffers) - return res | POLLERR; + return POLLERR; /* * For output streams you can write as long as there are fewer buffers * queued than there are buffers available. */ if (q->is_output && q->queued_count < q->num_buffers) - return res | POLLOUT | POLLWRNORM; + return POLLOUT | POLLWRNORM; if (list_empty(&q->done_list)) { /* @@ -837,7 +824,7 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) * return immediately. DQBUF will return -EPIPE. */ if (q->last_buffer_dequeued) - return res | POLLIN | POLLRDNORM; + return POLLIN | POLLRDNORM; poll_wait(file, &q->done_wq, wait); } @@ -854,10 +841,47 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) if (vb && (vb->state == VB2_BUF_STATE_DONE || vb->state == VB2_BUF_STATE_ERROR)) { return (q->is_output) ? - res | POLLOUT | POLLWRNORM : - res | POLLIN | POLLRDNORM; + POLLOUT | POLLWRNORM : + POLLIN | POLLRDNORM; } - return res; + return 0; +} + +/** + * vb2_poll() - implements poll userspace operation + * @q: videobuf2 queue + * @file: file argument passed to the poll file operation handler + * @wait: wait argument passed to the poll file operation handler + * + * This function implements poll file operation handler for a driver. + * For CAPTURE queues, if a buffer is ready to be dequeued, the userspace will + * be informed that the file descriptor of a video device is available for + * reading. + * For OUTPUT queues, if a buffer is ready to be dequeued, the file descriptor + * will be reported as available for writing. + * + * If the driver uses struct v4l2_fh, then vb2_poll() will also check for any + * pending events. + * + * The return values from this function are intended to be directly returned + * from poll handler in driver. + */ +unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) +{ + struct video_device *vfd = video_devdata(file); + unsigned long req_events = poll_requested_events(wait); + unsigned int res = 0; + + if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { + struct v4l2_fh *fh = file->private_data; + + if (v4l2_event_pending(fh)) + res = POLLPRI; + else if (req_events & POLLPRI) + poll_wait(file, &fh->wait, wait); + } + + return res | vb2_core_poll(q, file, wait); } EXPORT_SYMBOL_GPL(vb2_poll);