From patchwork Fri Oct 16 06:27:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junghak Sung X-Patchwork-Id: 7411101 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 6AD07BEEA4 for ; Fri, 16 Oct 2015 06:28:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C62320A64 for ; Fri, 16 Oct 2015 06:28:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B12A20A63 for ; Fri, 16 Oct 2015 06:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753347AbbJPG2I (ORCPT ); Fri, 16 Oct 2015 02:28:08 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:58724 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753282AbbJPG2G (ORCPT ); Fri, 16 Oct 2015 02:28:06 -0400 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 <0NWA01O1NVA9ED20@mailout4.samsung.com> for linux-media@vger.kernel.org; Fri, 16 Oct 2015 15:27:45 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 58.18.05272.1E890265; Fri, 16 Oct 2015 15:27:45 +0900 (KST) X-AuditID: cbfee68e-f791c6d000001498-48-562098e1ccc7 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id EC.26.18629.1E890265; Fri, 16 Oct 2015 15:27:45 +0900 (KST) Received: from localhost.localdomain ([10.252.83.96]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NWA001RRVA8KE70@mmp1.samsung.com>; Fri, 16 Oct 2015 15:27:45 +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 v7 4/7] media: videobuf2: Separate vb2_poll() Date: Fri, 16 Oct 2015 15:27:40 +0900 Message-id: <1444976863-3657-5-git-send-email-jh1009.sung@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1444976863-3657-1-git-send-email-jh1009.sung@samsung.com> References: <1444976863-3657-1-git-send-email-jh1009.sung@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRmVeSWpSXmKPExsWyRsSkUPfhDIUwg8VtVhanJj9jsph0fwKL xfbjr9gtOicuYbfo2bCV1WL1swqLA327mCymvP3JbvFv2lNmizP7V7JZHP90kMVixuSXbA48 HrM7ZrJ6HP66kMXj8a+XbB5b+u+ye/RtWcXo8XmTnMepr5/ZA9ijuGxSUnMyy1KL9O0SuDI2 /PrKXvBct2LD3bMsDYzTVboYOTkkBEwkdq2ewQxhi0lcuLeerYuRi0NIYAWjxItj65lhiua/ XQqVWMoose7QBlYI5zujxK/vU4EyHBxsAjoSkzcbgsRFBGYwSvQeX8UE4jALLGeUOP36FDvI KGEBR4k187azgzSwCKhKPPzMDRLmFXCT2HvhDdgcCQEFiTmTbEDCnALuEqtPbmUGCQsBlRw9 VQsyUULgErvE81M3wSayCAhIfJt8iAWiVVZi0wGomyUlDq64wTKBUXgBI8MqRtHUguSC4qT0 Ii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EwenVANjQ9Cj6NcJ R5nntuqeCvlzZW/u4bOffvx/UzFN+9N+ldVu/sK1qgceWVWcOmitI2h3kjXHmHvyL36Pg7Lb wnQ+fEzTEHskWaFZ4a28+H7JZDvjv5IeU3ddtZLKUb7+QcdYta7tQLnn9HSvlo+1i5Rs+ivf 37aK1yx+sG9Rlbg0T3mpmOLCha1KLMUZiYZazEXFiQCsj1hn3AIAAA== 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 525f4c7..8ea4d9e 100644 --- a/drivers/media/v4l2-core/videobuf2-v4l2.c +++ b/drivers/media/v4l2-core/videobuf2-v4l2.c @@ -746,7 +746,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 @@ -758,33 +758,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. @@ -793,16 +780,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; } } @@ -811,21 +798,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)) { /* @@ -833,7 +820,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); } @@ -850,10 +837,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);