qv4l2: add -r option to qv4l2 to open the initial device in raw mode
authorHans Verkuil <hans.verkuil@cisco.com>
Thu, 6 Jan 2011 09:58:49 +0000 (10:58 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 6 Jan 2011 10:01:07 +0000 (11:01 +0100)
By default qv4l2 opens the device node in wrapped mode (i.e. using libv4l2).
By adding the new -r option the device node is opened in raw mode, bypassing
libv4l2.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/qv4l2/qv4l2.cpp

index bd1db3e3f7f1022b272d20632830d0de00c141d7..1dfd8ba2d6f9bf17dc6de68be58d317df748805e 100644 (file)
@@ -546,11 +546,31 @@ ApplicationWindow *g_mw;
 int main(int argc, char **argv)
 {
        QApplication a(argc, argv);
+       QString device = "/dev/video0";
+       bool raw = false;
+       bool help = false;
+       int i;
 
        a.setWindowIcon(QIcon(":/qv4l2.png"));
        g_mw = new ApplicationWindow();
        g_mw->setWindowTitle("V4L2 Test Bench");
-       g_mw->setDevice(a.argc() > 1 ? a.argv()[1] : "/dev/video0", false);
+       for (i = 1; i < argc; i++) {
+               const char *arg = a.argv()[i];
+
+               if (!strcmp(arg, "-r"))
+                       raw = true;
+               else if (!strcmp(arg, "-h"))
+                       help = true;
+               else if (arg[0] != '-')
+                       device = arg;
+       }
+       if (help) {
+               printf("qv4l2 [-r] [-h] [device node]\n\n"
+                      "-h\tthis help message\n"
+                      "-r\topen device node in raw mode\n");
+               return 0;
+       }
+       g_mw->setDevice(device, raw);
        g_mw->show();
        a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
        return a.exec();