From patchwork Tue Nov 3 10:16:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junghak Sung X-Patchwork-Id: 7541371 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 875DBBEEA4 for ; Tue, 3 Nov 2015 10:17:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7F94B2028D for ; Tue, 3 Nov 2015 10:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AADF32052C for ; Tue, 3 Nov 2015 10:17:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbbKCKRE (ORCPT ); Tue, 3 Nov 2015 05:17:04 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:41299 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752048AbbKCKQ4 (ORCPT ); Tue, 3 Nov 2015 05:16:56 -0500 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX802ZGRHVWEL40@mailout1.samsung.com> for linux-media@vger.kernel.org; Tue, 03 Nov 2015 19:16:44 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.112]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id DC.66.05274.C8988365; Tue, 3 Nov 2015 19:16:44 +0900 (KST) X-AuditID: cbfee68d-f79ae6d00000149a-72-5638898c414b Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 2C.D3.18629.C8988365; Tue, 3 Nov 2015 19:16:44 +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 <0NX8008Z8HVVS340@mmp2.samsung.com>; Tue, 03 Nov 2015 19:16:44 +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 v9 3/6] media: videobuf2: Separate vb2_poll() Date: Tue, 03 Nov 2015 19:16:39 +0900 Message-id: <1446545802-28496-4-git-send-email-jh1009.sung@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1446545802-28496-1-git-send-email-jh1009.sung@samsung.com> References: <1446545802-28496-1-git-send-email-jh1009.sung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRmVeSWpSXmKPExsWyRsSkQLen0yLMoPOPtMWpyc+YLCbdn8Bi sf34K3aLzolL2C16NmxltVj9rMLiQN8uJospb3+yW/yb9pTZ4sz+lWwWxz8dZLGYMfklmwOP x+yOmaweh78uZPF4/Oslm8eW/rvsHn1bVjF6fN4k53Hq62f2APYoLpuU1JzMstQifbsEroxt s5qZCp7rVty/r9zAOF2li5GTQ0LARGLzhkvsELaYxIV769lAbCGBFYwSB79xdzFygNWcWFzc xcgFFJ7FKDFp2UVmCOc7o0TvtIWMIEVsAjoSkzcbgsRFBGYAxY+vYgJxmAWWM0qcfn0KbIOw gKPEhLatrCANLAKqEls3SYOEeQXcJc5/+MwEsUxBYs4kGxCTU8BDov9vKcQ57hIvph9hA5ko IXCJXWLP1DVgd7IICEh8m3yIBaJVVmLTAWaIVyQlDq64wTKBUXgBI8MqRtHUguSC4qT0IkO9 4sTc4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hh3LTusLJ79 anX/Mq+tqyf9LpV5UpYskuEwc3+KXJX597j8dwssPQ/cKJlubHnK+7O01r8ZyY08JQGOF1ZV iEd8m3AwQe+77Ya/3yJDf08/e96n/NIbk53rhWXPPTTXMdFmTujTun/0383/X9TEurZe+zRf bMaxSSx3NGaLWEyeDwyG8F8a2o1KLMUZiYZazEXFiQDmf11n2gIAAA== 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 d254452..0ca9f23 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c @@ -745,7 +745,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 @@ -757,33 +757,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. @@ -792,16 +779,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; } } @@ -810,21 +797,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)) { /* @@ -832,7 +819,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); } @@ -849,10 +836,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);