From patchwork Thu Sep 18 21:57:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 4934331 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E7A6D9F2EC for ; Thu, 18 Sep 2014 21:57:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7977720103 for ; Thu, 18 Sep 2014 21:58:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B90320115 for ; Thu, 18 Sep 2014 21:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932710AbaIRV5y (ORCPT ); Thu, 18 Sep 2014 17:57:54 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:34613 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932706AbaIRV5x (ORCPT ); Thu, 18 Sep 2014 17:57:53 -0400 Received: from lanttu.localdomain (salottisipuli.retiisi.org.uk [IPv6:2001:1bc8:102:7fc9::83:2]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id E2FBC600A3; Fri, 19 Sep 2014 00:57:50 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com Subject: [PATCH 3/3] omap3isp: Return buffers back to videobuf2 if pipeline streamon fails Date: Fri, 19 Sep 2014 00:57:49 +0300 Message-Id: <1411077469-29178-4-git-send-email-sakari.ailus@iki.fi> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1411077469-29178-1-git-send-email-sakari.ailus@iki.fi> References: <1411077469-29178-1-git-send-email-sakari.ailus@iki.fi> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 When the video buffer queue was stopped before the stream source was started in omap3isp_streamon(), the buffers were not returned back to videobuf2. Signed-off-by: Sakari Ailus --- drivers/media/platform/omap3isp/isp.c | 4 ++-- drivers/media/platform/omap3isp/ispvideo.c | 16 ++++++++++------ drivers/media/platform/omap3isp/ispvideo.h | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index 72265e5..2aa0a8e 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -1062,9 +1062,9 @@ int omap3isp_pipeline_set_stream(struct isp_pipeline *pipe, void omap3isp_pipeline_cancel_stream(struct isp_pipeline *pipe) { if (pipe->input) - omap3isp_video_cancel_stream(pipe->input); + omap3isp_video_cancel_stream(pipe->input, VB2_BUF_STATE_ERROR); if (pipe->output) - omap3isp_video_cancel_stream(pipe->output); + omap3isp_video_cancel_stream(pipe->output, VB2_BUF_STATE_ERROR); } /* diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index b233c8e..73c0194 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -443,8 +443,10 @@ static int isp_video_start_streaming(struct vb2_queue *queue, ret = omap3isp_pipeline_set_stream(pipe, ISP_PIPELINE_STREAM_CONTINUOUS); - if (ret < 0) + if (ret < 0) { + omap3isp_video_cancel_stream(video, VB2_BUF_STATE_QUEUED); return ret; + } spin_lock_irqsave(&video->irqlock, flags); if (list_empty(&video->dmaqueue)) @@ -566,10 +568,12 @@ struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video) * omap3isp_video_cancel_stream - Cancel stream on a video node * @video: ISP video object * - * Cancelling a stream mark all buffers on the video node as erroneous and makes - * sure no new buffer can be queued. + * Cancelling a stream mark all buffers on the video node as erroneous + * and makes sure no new buffer can be queued. Buffers are returned + * back to videobuf2 in the given state. */ -void omap3isp_video_cancel_stream(struct isp_video *video) +void omap3isp_video_cancel_stream(struct isp_video *video, + enum vb2_buffer_state state) { unsigned long flags; @@ -581,7 +585,7 @@ void omap3isp_video_cancel_stream(struct isp_video *video) buf = list_first_entry(&video->dmaqueue, struct isp_buffer, irqlist); list_del(&buf->irqlist); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_ERROR); + vb2_buffer_done(&buf->vb, state); } video->error = true; @@ -1166,7 +1170,7 @@ isp_video_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) /* Stop the stream. */ omap3isp_pipeline_set_stream(pipe, ISP_PIPELINE_STREAM_STOPPED); - omap3isp_video_cancel_stream(video); + omap3isp_video_cancel_stream(video, VB2_BUF_STATE_ERROR); mutex_lock(&video->queue_lock); vb2_streamoff(&vfh->queue, type); diff --git a/drivers/media/platform/omap3isp/ispvideo.h b/drivers/media/platform/omap3isp/ispvideo.h index 0b7efed..7e4732a 100644 --- a/drivers/media/platform/omap3isp/ispvideo.h +++ b/drivers/media/platform/omap3isp/ispvideo.h @@ -201,7 +201,8 @@ int omap3isp_video_register(struct isp_video *video, struct v4l2_device *vdev); void omap3isp_video_unregister(struct isp_video *video); struct isp_buffer *omap3isp_video_buffer_next(struct isp_video *video); -void omap3isp_video_cancel_stream(struct isp_video *video); +void omap3isp_video_cancel_stream(struct isp_video *video, + enum vb2_buffer_state state); void omap3isp_video_resume(struct isp_video *video, int continuous); struct media_pad *omap3isp_video_remote_pad(struct isp_video *video);