From patchwork Wed Jul 13 09:39:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 971402 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6D9dXS0001143 for ; Wed, 13 Jul 2011 09:39:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965216Ab1GMJjY (ORCPT ); Wed, 13 Jul 2011 05:39:24 -0400 Received: from smtp-vbr5.xs4all.nl ([194.109.24.25]:3972 "EHLO smtp-vbr5.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965209Ab1GMJjV (ORCPT ); Wed, 13 Jul 2011 05:39:21 -0400 Received: from tschai.lan (215.80-203-102.nextgentel.com [80.203.102.215]) (authenticated bits=0) by smtp-vbr5.xs4all.nl (8.13.8/8.13.8) with ESMTP id p6D9dGws048541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Jul 2011 11:39:18 +0200 (CEST) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [RFCv1 PATCH 3/6] videobuf2: only start streaming in poll() if so requested by the poll mask. Date: Wed, 13 Jul 2011 11:39:01 +0200 Message-Id: <7fc8ed81f08a0ac8092c5b6a8badc3427df9bc1e.1310549521.git.hans.verkuil@cisco.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1310549944-23756-1-git-send-email-hverkuil@xs4all.nl> References: <1310549944-23756-1-git-send-email-hverkuil@xs4all.nl> In-Reply-To: References: X-Virus-Scanned: by XS4ALL Virus Scanner Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 13 Jul 2011 09:39:33 +0000 (UTC) From: Hans Verkuil Signed-off-by: Hans Verkuil Acked-by: Marek Szyprowski Acked-by: Pawel Osciak --- drivers/media/video/videobuf2-core.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 3015e60..1892bb8 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -1365,6 +1365,7 @@ static int __vb2_cleanup_fileio(struct vb2_queue *q); */ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) { + unsigned long req_events = poll_requested_events(wait); unsigned long flags; unsigned int ret; struct vb2_buffer *vb = NULL; @@ -1373,12 +1374,14 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) * Start file I/O emulator only if streaming API has not been used yet. */ if (q->num_buffers == 0 && q->fileio == NULL) { - if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)) { + if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) && + (req_events & (POLLIN | POLLRDNORM))) { ret = __vb2_init_fileio(q, 1); if (ret) return POLLERR; } - if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) { + if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE) && + (req_events & (POLLOUT | POLLWRNORM))) { ret = __vb2_init_fileio(q, 0); if (ret) return POLLERR;