From patchwork Mon Dec 15 16:07:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 5495501 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 E34A49F30B for ; Mon, 15 Dec 2014 16:08:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF8A22041C for ; Mon, 15 Dec 2014 16:08:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 98377209EA for ; Mon, 15 Dec 2014 16:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750939AbaLOQIV (ORCPT ); Mon, 15 Dec 2014 11:08:21 -0500 Received: from mga03.intel.com ([134.134.136.65]:29814 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750765AbaLOQIU (ORCPT ); Mon, 15 Dec 2014 11:08:20 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 15 Dec 2014 08:05:25 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,580,1413270000"; d="scan'208";a="654214876" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga002.jf.intel.com with ESMTP; 15 Dec 2014 08:07:36 -0800 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id BA8F520347; Mon, 15 Dec 2014 18:07:35 +0200 (EET) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 6DF2620133; Mon, 15 Dec 2014 18:07:34 +0200 (EET) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com Subject: [yavta PATCH 1/2] yavta: Implement data_offset support for single and multi plane buffers Date: Mon, 15 Dec 2014 18:07:33 +0200 Message-Id: <1418659654-9578-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Support data_offset for single and multi plane buffers. Also add an option to write the data in the buffer before data offset (--buffer-prefix). Signed-off-by: Sakari Ailus --- yavta.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/yavta.c b/yavta.c index 77e5a41..47b817c 100644 --- a/yavta.c +++ b/yavta.c @@ -80,6 +80,8 @@ struct device void *pattern[VIDEO_MAX_PLANES]; unsigned int patternsize[VIDEO_MAX_PLANES]; + + bool write_buffer_prefix; }; static bool video_is_mplane(struct device *dev) @@ -1546,13 +1548,22 @@ static void video_save_image(struct device *dev, struct v4l2_buffer *buf, for (i = 0; i < dev->num_planes; i++) { unsigned int length; + unsigned int data_offset = 0; - if (video_is_mplane(dev)) + if (video_is_mplane(dev)) { length = buf->m.planes[i].bytesused; - else + data_offset = buf->m.planes[i].data_offset; + } else { length = buf->bytesused; + } + + if (!dev->write_buffer_prefix) + length -= data_offset; + else + data_offset = 0; - ret = write(fd, dev->buffers[buf->index].mem[i], length); + ret = write(fd, dev->buffers[buf->index].mem[i] + data_offset, + length); if (ret < 0) { printf("write error: %s (%d)\n", strerror(errno), errno); break; @@ -1618,7 +1629,7 @@ static int video_do_capture(struct device *dev, unsigned int nframes, if (video_is_capture(dev)) video_verify_buffer(dev, &buf); - size += buf.bytesused; + size += buf.bytesused - buf.data_offset; fps = (buf.timestamp.tv_sec - last.tv_sec) * 1000000 + buf.timestamp.tv_usec - last.tv_usec; @@ -1717,6 +1728,7 @@ static void usage(const char *argv0) printf("-t, --time-per-frame num/denom Set the time per frame (eg. 1/25 = 25 fps)\n"); printf("-u, --userptr Use the user pointers streaming method\n"); printf("-w, --set-control 'ctrl value' Set control 'ctrl' to 'value'\n"); + printf(" --buffer-prefix Write portions of buffer before data_offset\n"); printf(" --buffer-size Buffer size in bytes\n"); printf(" --enum-formats Enumerate formats\n"); printf(" --enum-inputs Enumerate inputs\n"); @@ -1749,10 +1761,12 @@ static void usage(const char *argv0) #define OPT_BUFFER_SIZE 268 #define OPT_PREMULTIPLIED 269 #define OPT_QUEUE_LATE 270 +#define OPT_BUFFER_PREFIX 271 static struct option opts[] = { {"buffer-size", 1, 0, OPT_BUFFER_SIZE}, {"buffer-type", 1, 0, 'B'}, + {"buffer-prefix", 1, 0, OPT_BUFFER_PREFIX}, {"capture", 2, 0, 'c'}, {"check-overrun", 0, 0, 'C'}, {"delay", 1, 0, 'd'}, @@ -2016,6 +2030,8 @@ int main(int argc, char *argv[]) case OPT_USERPTR_OFFSET: userptr_offset = atoi(optarg); break; + case OPT_BUFFER_PREFIX: + dev.write_buffer_prefix = true; default: printf("Invalid option -%c\n", c); printf("Run %s -h for help.\n", argv[0]);