From patchwork Wed May 25 13:33:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 816262 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 p4PDYZ8o023395 for ; Wed, 25 May 2011 13:34:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932704Ab1EYNed (ORCPT ); Wed, 25 May 2011 09:34:33 -0400 Received: from smtp-vbr5.xs4all.nl ([194.109.24.25]:3011 "EHLO smtp-vbr5.xs4all.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932596Ab1EYNeR (ORCPT ); Wed, 25 May 2011 09:34:17 -0400 Received: from tschai (64-103-25-233.cisco.com [64.103.25.233]) (authenticated bits=0) by smtp-vbr5.xs4all.nl (8.13.8/8.13.8) with ESMTP id p4PDYARa007307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 25 May 2011 15:34:14 +0200 (CEST) (envelope-from hverkuil@xs4all.nl) From: Hans Verkuil To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [RFCv2 PATCH 06/11] vb2_poll: don't start DMA, leave that to the first read(). Date: Wed, 25 May 2011 15:33:50 +0200 Message-Id: <56353a4500047353bd8371ad2ba1aad1e40df016.1306329390.git.hans.verkuil@cisco.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1306330435-11799-1-git-send-email-hverkuil@xs4all.nl> References: <1306330435-11799-1-git-send-email-hverkuil@xs4all.nl> In-Reply-To: <6cea502820c1684f34b9e862a64be2972afb718f.1306329390.git.hans.verkuil@cisco.com> References: <6cea502820c1684f34b9e862a64be2972afb718f.1306329390.git.hans.verkuil@cisco.com> 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, 25 May 2011 13:34:36 +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; - } } /*