Commit 1b8d383b authored by André Almeida's avatar André Almeida
Browse files

v4l2-compliance: create --loopback option


Signed-off-by: André Almeida's avatarAndré Almeida <andrealmeid@collabora.com>
parent 771679c0
......@@ -18,6 +18,7 @@
Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*/
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
......@@ -69,6 +70,7 @@ enum Option {
OptSetSWRadioDevice = 'S',
OptSetTouchDevice = 't',
OptTrace = 'T',
OptSetLoopback = 'l',
OptSetSubDevDevice = 'u',
OptVerbose = 'v',
OptSetVbiDevice = 'V',
......@@ -143,6 +145,7 @@ static struct option long_options[] = {
{"exit-on-fail", no_argument, 0, OptExitOnFail},
{"exit-on-warn", no_argument, 0, OptExitOnWarn},
{"trace", no_argument, 0, OptTrace},
{"loopback", required_argument, 0, OptSetLoopback},
#ifndef NO_LIBV4L2
{"wrapper", no_argument, 0, OptUseWrapper},
#endif
......@@ -1436,6 +1439,7 @@ int main(int argc, char **argv)
{
int i;
struct node node;
struct node node_2;
media_type type = MEDIA_TYPE_UNKNOWN;
struct node expbuf_node;
std::string media_bus_info;
......@@ -1445,6 +1449,16 @@ int main(int argc, char **argv)
int ch;
std::string device("/dev/video0");
std::string expbuf_device; /* --expbuf-device device */
/* loopback vars */
bool is_loop = false;
std::string loopback;
std::string loop_d1;
std::string loop_d2;
unsigned int d1 = 0, d2 = 0;
std::string s1;
std::string s2;
struct utsname uts;
int v1, v2, v3;
unsigned frame_count = 60;
......@@ -1543,6 +1557,30 @@ int main(int argc, char **argv)
case OptMediaBusInfo:
media_bus_info = optarg;
break;
case OptSetLoopback:
loopback = optarg;
std::cout << "command: " << loopback << std::endl;
if (2 != sscanf(loopback.c_str(), "%d:%d", &d1, &d2)) {
printf("ERROR");
exit(1);
}
s1 = std::to_string(d1);
s2 = std::to_string(d2);
std::cout << "d1: " << d1 << " d2: " << d2 << std::endl;
loop_d1 = make_devname(s1.c_str(), "video", media_bus_info);
loop_d2 = make_devname(s2.c_str(), "video", media_bus_info);
std::cout << "d1: " << loop_d1 << " d2: " << loop_d2 << std::endl;
node_2.device = loop_d2.c_str();
node_2.s_trace(options[OptTrace]);
node_2.s_direct(true);
node_2.subdev_open(device.c_str(), false);
is_loop = true;
break;
case OptSetExpBufDevice:
expbuf_device = make_devname(optarg, "video", media_bus_info);
break;
......@@ -1650,6 +1688,7 @@ int main(int argc, char **argv)
return 1;
}
}
std::cout << "is_loop: " << is_loop << std::endl;
if (optind < argc) {
fprintf(stderr, "unknown arguments: ");
while (optind < argc)
......@@ -1709,6 +1748,16 @@ int main(int argc, char **argv)
testNode(node, node, expbuf_node, type, frame_count, all_fmt_frame_count);
/*
if (is_loop) {
printf("loopback:\n");
printf("node1: %s\n", node.device);
printf("node2: %s\n", node_2.device);
testNode(node, node_2, expbuf_node, type, frame_count, all_fmt_frame_count);
}
else
*/
if (!expbuf_device.empty())
expbuf_node.close();
if (media_fd >= 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment