From patchwork Sun Feb 27 18:12:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 593511 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 p1RICZGo025165 for ; Sun, 27 Feb 2011 18:12:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347Ab1B0SMa (ORCPT ); Sun, 27 Feb 2011 13:12:30 -0500 Received: from perceval.ideasonboard.com ([95.142.166.194]:34570 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752332Ab1B0SM2 (ORCPT ); Sun, 27 Feb 2011 13:12:28 -0500 Received: from localhost.localdomain (unknown [91.178.64.100]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9F166359C4; Sun, 27 Feb 2011 18:12:27 +0000 (UTC) From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: pawel@osciak.com, m.szyprowski@samsung.com, hverkuil@xs4all.nl Subject: [RFC/PATCH 1/2] v4l: videobuf2: Handle buf_queue errors Date: Sun, 27 Feb 2011 19:12:32 +0100 Message-Id: <1298830353-9797-2-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1298830353-9797-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1298830353-9797-1-git-send-email-laurent.pinchart@ideasonboard.com> 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]); Sun, 27 Feb 2011 18:12:36 +0000 (UTC) diff --git a/drivers/media/video/videobuf2-core.c b/drivers/media/video/videobuf2-core.c index cc7ab0a..1d81536 100644 --- a/drivers/media/video/videobuf2-core.c +++ b/drivers/media/video/videobuf2-core.c @@ -798,13 +798,22 @@ static int __qbuf_mmap(struct vb2_buffer *vb, struct v4l2_buffer *b) /** * __enqueue_in_driver() - enqueue a vb2_buffer in driver for processing */ -static void __enqueue_in_driver(struct vb2_buffer *vb) +static int __enqueue_in_driver(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; + int ret; vb->state = VB2_BUF_STATE_ACTIVE; atomic_inc(&q->queued_count); - q->ops->buf_queue(vb); + ret = q->ops->buf_queue(vb); + if (ret == 0) + return 0; + + vb->state = VB2_BUF_STATE_ERROR; + atomic_dec(&q->queued_count); + wake_up_all(&q->done_wq); + + return ret; } /** @@ -890,8 +899,13 @@ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) * If already streaming, give the buffer to driver for processing. * If not, the buffer will be given to driver on next streamon. */ - if (q->streaming) - __enqueue_in_driver(vb); + if (q->streaming) { + ret = __enqueue_in_driver(vb); + if (ret < 0) { + dprintk(1, "qbuf: buffer queue failed\n"); + return ret; + } + } dprintk(1, "qbuf of buffer %d succeeded\n", vb->v4l2_buf.index); return 0; @@ -1101,6 +1115,7 @@ EXPORT_SYMBOL_GPL(vb2_dqbuf); int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) { struct vb2_buffer *vb; + int ret; if (q->fileio) { dprintk(1, "streamon: file io in progress\n"); @@ -1139,8 +1154,13 @@ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) * If any buffers were queued before streamon, * we can now pass them to driver for processing. */ - list_for_each_entry(vb, &q->queued_list, queued_entry) - __enqueue_in_driver(vb); + list_for_each_entry(vb, &q->queued_list, queued_entry) { + ret = __enqueue_in_driver(vb); + if (ret < 0) { + dprintk(1, "streamon: buffer queue failed\n"); + return ret; + } + } dprintk(3, "Streamon successful\n"); return 0; diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 597efe6..3a92f75 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -225,7 +225,7 @@ struct vb2_ops { int (*start_streaming)(struct vb2_queue *q); int (*stop_streaming)(struct vb2_queue *q); - void (*buf_queue)(struct vb2_buffer *vb); + int (*buf_queue)(struct vb2_buffer *vb); }; /**