summaryrefslogtreecommitdiff
path: root/yavta.c
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2014-12-15 18:26:47 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2014-12-15 22:10:24 +0200
commit8f6921584eed1b12b9b05f4bb8535a2cf194402d (patch)
tree718029be0148fc03ed01a0aaa6afbf827261714e /yavta.c
parentdea6686773eff15f7688da6c13ec48905afb3871 (diff)
yavta: Implement data_offset support for multi plane buffers
Support data_offset for multi plane buffers. Also add an option to write the data in the buffer before data offset (--buffer-prefix). Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'yavta.c')
-rw-r--r--yavta.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/yavta.c b/yavta.c
index d0bd932..8e8ec19 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)
@@ -1544,14 +1546,22 @@ static void video_save_image(struct device *dev, struct v4l2_buffer *buf,
return;
for (i = 0; i < dev->num_planes; i++) {
+ void *data = dev->buffers[buf->index].mem[i];
unsigned int length;
- if (video_is_mplane(dev))
+ if (video_is_mplane(dev)) {
length = buf->m.planes[i].bytesused;
- else
+
+ if (!dev->write_buffer_prefix) {
+ data += buf->m.planes[i].data_offset;
+ length -= buf->m.planes[i].data_offset;
+ }
+
+ } else {
length = buf->bytesused;
+ }
- ret = write(fd, dev->buffers[buf->index].mem[i], length);
+ ret = write(fd, data, length);
if (ret < 0) {
printf("write error: %s (%d)\n", strerror(errno), errno);
break;
@@ -1716,6 +1726,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");
@@ -1748,10 +1759,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'},
@@ -2015,6 +2028,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]);