From patchwork Fri Oct 24 14:23:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 5147651 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 EAF389F30B for ; Fri, 24 Oct 2014 14:24:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16BEF2026D for ; Fri, 24 Oct 2014 14:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D7E72021B for ; Fri, 24 Oct 2014 14:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756121AbaJXOYV (ORCPT ); Fri, 24 Oct 2014 10:24:21 -0400 Received: from mga14.intel.com ([192.55.52.115]:33868 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755833AbaJXOYU (ORCPT ); Fri, 24 Oct 2014 10:24:20 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 24 Oct 2014 07:18:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="405404303" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by FMSMGA003.fm.intel.com with ESMTP; 24 Oct 2014 07:16:14 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 260252018D; Fri, 24 Oct 2014 17:24:00 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 9EFD620108; Fri, 24 Oct 2014 17:23:58 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com Subject: [yavta PATCH 1/1] yavta: Add --queue-late option for delay queueing buffers over streaming start Date: Fri, 24 Oct 2014 17:23:58 +0300 Message-Id: <1414160638-27974-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.0.231.g7484e3b Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Queue buffers to the device after VIDIOC_STREAMON, not before. This does not affect queueing behaviour otherwise. Signed-off-by: Sakari Ailus --- yavta.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/yavta.c b/yavta.c index 20bbe29..7f9e814 100644 --- a/yavta.c +++ b/yavta.c @@ -1429,7 +1429,6 @@ static int video_prepare_capture(struct device *dev, int nbufs, unsigned int off const char *filename, enum buffer_fill_mode fill) { unsigned int padding; - unsigned int i; int ret; /* Allocate and map buffers. */ @@ -1443,6 +1442,14 @@ static int video_prepare_capture(struct device *dev, int nbufs, unsigned int off return ret; } + return 0; +} + +static int video_queue_all_buffers(struct device *dev, enum buffer_fill_mode fill) +{ + unsigned int i; + int ret; + /* Queue the buffers. */ for (i = 0; i < dev->nbufs; ++i) { ret = video_queue_buffer(dev, i, fill); @@ -1554,7 +1561,7 @@ static void video_save_image(struct device *dev, struct v4l2_buffer *buf, static int video_do_capture(struct device *dev, unsigned int nframes, unsigned int skip, unsigned int delay, const char *pattern, - int do_requeue_last, enum buffer_fill_mode fill) + int do_requeue_last, int do_queue_late, enum buffer_fill_mode fill) { struct v4l2_plane planes[VIDEO_MAX_PLANES]; struct v4l2_buffer buf; @@ -1572,6 +1579,9 @@ static int video_do_capture(struct device *dev, unsigned int nframes, if (ret < 0) goto done; + if (do_queue_late) + video_queue_all_buffers(dev, fill); + size = 0; clock_gettime(CLOCK_MONOTONIC, &start); last.tv_sec = start.tv_sec; @@ -1712,6 +1722,7 @@ static void usage(const char *argv0) printf(" --no-query Don't query capabilities on open\n"); printf(" --offset User pointer buffer offset from page start\n"); printf(" --premultiplied Color components are premultiplied by alpha value\n"); + printf(" --queue-late Queue buffers after streamon, not before\n"); printf(" --requeue-last Requeue the last buffers before streamoff\n"); printf(" --timestamp-source Set timestamp source on output buffers [eof, soe]\n"); printf(" --skip n Skip the first n frames\n"); @@ -1733,6 +1744,7 @@ static void usage(const char *argv0) #define OPT_LOG_STATUS 267 #define OPT_BUFFER_SIZE 268 #define OPT_PREMULTIPLIED 269 +#define OPT_QUEUE_LATE 270 static struct option opts[] = { {"buffer-size", 1, 0, OPT_BUFFER_SIZE}, @@ -1757,6 +1769,7 @@ static struct option opts[] = { {"pause", 0, 0, 'p'}, {"premultiplied", 0, 0, OPT_PREMULTIPLIED}, {"quality", 1, 0, 'q'}, + {"queue-late", 0, 0, OPT_QUEUE_LATE}, {"get-control", 1, 0, 'r'}, {"requeue-last", 0, 0, OPT_REQUEUE_LAST}, {"realtime", 2, 0, 'R'}, @@ -1788,7 +1801,7 @@ int main(int argc, char *argv[]) int do_list_controls = 0, do_get_control = 0, do_set_control = 0; int do_sleep_forever = 0, do_requeue_last = 0; int do_rt = 0, do_log_status = 0; - int no_query = 0; + int no_query = 0, do_queue_late = 0; char *endptr; int c; @@ -1971,6 +1984,9 @@ int main(int argc, char *argv[]) case OPT_PREMULTIPLIED: fmt_flags |= V4L2_PIX_FMT_FLAG_PREMUL_ALPHA; break; + case OPT_QUEUE_LATE: + do_queue_late = 1; + break; case OPT_REQUEUE_LAST: do_requeue_last = 1; break; @@ -2107,6 +2123,11 @@ int main(int argc, char *argv[]) return 1; } + if (!do_queue_late && video_queue_all_buffers(&dev, fill_mode)) { + video_close(&dev); + return 1; + } + if (do_pause) { printf("Press enter to start capture\n"); getchar(); @@ -2122,7 +2143,7 @@ int main(int argc, char *argv[]) } if (video_do_capture(&dev, nframes, skip, delay, filename, - do_requeue_last, fill_mode) < 0) { + do_requeue_last, do_queue_late, fill_mode) < 0) { video_close(&dev); return 1; }