From patchwork Tue Jun 7 15:05:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 857382 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p57F5e6V010205 for ; Tue, 7 Jun 2011 15:06:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755328Ab1FGPFi (ORCPT ); Tue, 7 Jun 2011 11:05:38 -0400 Received: from smtp-vbr1.xs4all.nl ([194.109.24.21]:3827 "EHLO smtp-vbr1.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755309Ab1FGPFh (ORCPT ); Tue, 7 Jun 2011 11:05:37 -0400 Received: from tschai.lan (215.80-203-102.nextgentel.com [80.203.102.215]) (authenticated bits=0) by smtp-vbr1.xs4all.nl (8.13.8/8.13.8) with ESMTP id p57F5QqW037616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Jun 2011 17:05:34 +0200 (CEST) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [RFCv3 PATCH 12/18] vb2_poll: don't start DMA, leave that to the first read(). Date: Tue, 7 Jun 2011 17:05:17 +0200 Message-Id: X-Mailer: git-send-email 1.7.1 In-Reply-To: <1307459123-17810-1-git-send-email-hverkuil@xs4all.nl> References: <1307459123-17810-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]); Tue, 07 Jun 2011 15:06:04 +0000 (UTC) From: Hans Verkuil The vb2_poll function would start read-DMA if called without any streaming in progress. This unfortunately does not work if the application just wants to poll for exceptions. This information of what the application is polling for is sadly unavailable in the driver. Andy Walls suggested to just return POLLIN | POLLRDNORM and let the first call to read() start the DMA. This initial read() call will return EAGAIN since no actual data is available yet, but it does start the DMA. Applications must handle EAGAIN in any case since there can be other reasons for EAGAIN as well. Signed-off-by: Hans Verkuil --- drivers/media/video/videobuf2-core.c | 17 +++-------------- 1 files changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index 6ba1461..ad75c95 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -1372,27 +1372,16 @@ 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 flags; - unsigned int ret; struct vb2_buffer *vb = NULL; /* * 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)) { - ret = __vb2_init_fileio(q, 1); - if (ret) - return POLLERR; - } - if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) { - ret = __vb2_init_fileio(q, 0); - if (ret) - return POLLERR; - /* - * Write to OUTPUT queue can be done immediately. - */ + if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ)) + return POLLIN | POLLRDNORM; + if (V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_WRITE)) return POLLOUT | POLLWRNORM; - } } /*