From patchwork Tue Jan 26 15:45:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 8124261 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C99369F1C0 for ; Tue, 26 Jan 2016 15:46:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14CD72025A for ; Tue, 26 Jan 2016 15:46:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF2CE20253 for ; Tue, 26 Jan 2016 15:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755969AbcAZPqa (ORCPT ); Tue, 26 Jan 2016 10:46:30 -0500 Received: from ns.mm-sol.com ([37.157.136.199]:48623 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751763AbcAZPqa (ORCPT ); Tue, 26 Jan 2016 10:46:30 -0500 Received: from mms-0439.ent.mm-sol.com (unknown [172.18.0.3]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 761DEC99D; Tue, 26 Jan 2016 17:46:28 +0200 (EET) From: Todor Tomov To: laurent.pinchart@ideasonboard.com, linux-media@vger.kernel.org Cc: Todor Tomov Subject: [yavta PATCH] Fix requeue of last buffers Date: Tue, 26 Jan 2016 17:45:06 +0200 Message-Id: <1453823106-24777-1-git-send-email-ttomov@mm-sol.com> X-Mailer: git-send-email 1.9.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 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 capturing n image with p buffers, dequeued buffers don't need to be requeued in the last p iterations. Currently requeue in iteration n - p + 1 is skipped only. So skip requeue on all last p iterations. Also handle correctly the case when n < p. Signed-off-by: Todor Tomov --- yavta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yavta.c b/yavta.c index 49361ad..12f1608 100644 --- a/yavta.c +++ b/yavta.c @@ -1696,7 +1696,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, fflush(stdout); - if (i == nframes - dev->nbufs && !do_requeue_last) + if (i + dev->nbufs >= nframes && !do_requeue_last) continue; ret = video_queue_buffer(dev, buf.index, fill);