summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5093e81)
raw | patch | inline | side by side (parent: 5093e81)
author | Nikhil Devshatwar <nikhil.nd@ti.com> | |
Sun, 5 Jan 2014 19:08:37 +0000 (00:38 +0530) | ||
committer | Nikhil Devshatwar <nikhil.nd@ti.com> | |
Tue, 25 Mar 2014 09:02:51 +0000 (14:32 +0530) |
This patch adds a feature to capture from multiple devices
in parallel thread.
At a time, only one thread is allowed to post buffers for the display.
By default, only one capture is assumed, number of captures specified
by command line argument 'multi'
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
in parallel thread.
At a time, only one thread is allowed to post buffers for the display.
By default, only one capture is assumed, number of captures specified
by command line argument 'multi'
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
dmabuftest.c | patch | blob | history | |
util/v4l2.c | patch | blob | history |
diff --git a/dmabuftest.c b/dmabuftest.c
index 120db820e46a4661e22fc7e2a8bd1c1f5b0cd6c7..43a3428a588598f1858c53193dbff50601062855 100644 (file)
--- a/dmabuftest.c
+++ b/dmabuftest.c
/*
* Copyright (C) 2011 Texas Instruments
* Author: Rob Clark <rob.clark@linaro.org>
+ * Adopted for testing VIP capture by: Nikhil Devshatwar <nikhil.nd@ti.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
#define NBUF 6
#define CNT 500000
+#define MAX_CAP 6
+
+pthread_t active_thread;
enum display_area {
FULL,
MSG("Usage: %s [OPTION]...", name);
MSG("Test of buffer passing between v4l2 camera and display.");
MSG("");
+ MSG("viddec3test options:");
+ MSG("\t-h, --help: Print this help and exit.");
+ MSG("\t--multi <num>: Capture from <num> different devices.");
+ MSG("\t\t\tEach device name and format would be parsed in the cmdline");
+ MSG("");
disp_usage();
v4l2_usage();
}
uint32_t width = data->width, height = data->height;
struct buffer **buffers, *capt;
+ pthread_t tid;
int ret, i;
+ tid = pthread_self();
+
buffers = disp_get_vid_buffers(disp, NBUF, fourcc, width, height);
if (!buffers) {
return NULL;
for (i = 1; i < CNT; i++) {
capt = v4l2_dqbuf(v4l2);
- switch(data->area) {
- case FULL:
- ret = disp_post_vid_buffer(disp, capt,
- 0, 0, width, height);
- break;
- case OVERLAY:
- ret = disp_post_vid_buffer(disp, capt,
- 0, 0, width, height);
- break;
- }
- if (ret) {
- return NULL;
+ if(active_thread == tid) {
+ switch(data->area) {
+ case FULL:
+ ret = disp_post_vid_buffer(disp, capt,
+ 0, 0, width, height);
+ break;
+ case OVERLAY:
+ ret = disp_post_vid_buffer(disp, capt,
+ 0, 0, width, height);
+ break;
+ }
+ if (ret) {
+ MSG("Quitting");
+ return NULL;
+ }
}
v4l2_qbuf(v4l2, capt);
}
{
struct display *disp;
struct v4l2 *v4l2;
- pthread_t threads[2];
- struct thr_data tdata[2];
+ pthread_t threads[MAX_CAP];
+ struct thr_data tdata[MAX_CAP];
void *result = NULL;
- int ret = 0, i, dual = 0;
+ int ret = 0, i, multi = 1, idx = 0;
+ char c;
MSG("Opening Display..");
disp = disp_open(argc, argv);
if (!argv[i])
continue;
- if (!strcmp("--dual", argv[i])) {
- dual = 1;
+ if (!strcmp("--multi", argv[i])) {
+ argv[i++] = NULL;
+ sscanf(argv[i], "%d", &multi);
argv[i] = NULL;
+ if(multi < 1 || multi > MAX_CAP) {
+ usage(argv[i]);
+ return 1;
+ }
}
}
- MSG("Opening V4L2..");
- v4l2 = v4l2_open(argc, argv, &tdata[0].fourcc,
- &tdata[0].width, &tdata[0].height);
- if (!v4l2) {
- usage(argv[0]);
- return 1;
- }
- tdata[0].disp = disp;
- tdata[0].v4l2 = v4l2;
- tdata[0].area = FULL;
-
- if(dual) {
- MSG("Opening second V4L2..");
- v4l2 = v4l2_open(argc, argv, &tdata[1].fourcc,
- &tdata[1].width, &tdata[1].height);
+ for (i = 0; i < multi; i++) {
+ MSG("Opening V4L2..");
+ v4l2 = v4l2_open(argc, argv, &tdata[i].fourcc,
+ &tdata[i].width, &tdata[i].height);
if (!v4l2) {
usage(argv[0]);
return 1;
}
- tdata[1].disp = disp;
- tdata[1].v4l2 = v4l2;
- tdata[1].area = OVERLAY;
+ tdata[i].disp = disp;
+ tdata[i].v4l2 = v4l2;
+ tdata[i].area = FULL;
}
if (check_args(argc, argv)) {
return 0;
}
- if(dual) {
- ret = pthread_create(&threads[0], NULL, capture_loop, &tdata[0]);
+ for (i = 0; i < multi; i++) {
+ ret = pthread_create(&threads[i], NULL, capture_loop, &tdata[i]);
if(ret) {
MSG("Failed creating thread");
}
- ret = pthread_create(&threads[1], NULL, capture_loop, &tdata[1]);
- if(ret) {
- MSG("Failed creating thread");
+ MSG("Failed creating thread");
+ }
+ active_thread = threads[0];
+
+ while(1) {
+ c = getchar();
+ if(c == 's') {
+ idx = (idx + 1) % multi;
+ active_thread = threads[idx];
}
- } else {
- capture_loop(&tdata[0]);
}
- pthread_join(threads[0], &result);
- pthread_join(threads[1], &result);
+ for (i = 0; i < multi; i++) {
+ pthread_join(threads[i], &result);
+ }
disp_close(disp);
diff --git a/util/v4l2.c b/util/v4l2.c
index 634983499e5dc7ca7d3fc43355827c1802ac4d6d..f902d50831d594e141e99a3bb3dfa58ed6e48b58 100644 (file)
--- a/util/v4l2.c
+++ b/util/v4l2.c
return -1;
}
- MSG("QBUF: idx=%d, fd=%d", v4l2buf->index, v4l2buf->m.fd);
-
ret = ioctl(v4l2->fd, VIDIOC_QBUF, v4l2buf);
v4l2buf->m.fd = buf->fd[0];
if (ret) {
assert(buf->nbo == 1); /* TODO add multi-planar support */
- MSG("DQBUF: idx=%d, fd=%d", v4l2buf.index, buf->fd[0]);
-
return buf;
}