v4l2-* utils: allow -d11 to refer to /dev/video11
authorHans Verkuil <hans.verkuil@cisco.com>
Sat, 9 Mar 2013 17:59:11 +0000 (18:59 +0100)
committerHans Verkuil <hans.verkuil@cisco.com>
Sat, 9 Mar 2013 17:59:11 +0000 (18:59 +0100)
Lately I have been working with devices with lots of video nodes. Various
v4l2 utilities allow -dX to refer to /dev/videoX, but 'X' was limited to
a single digit. Extend this to support up to three digits. So -d11 would
refer to /dev/video11 and -d128 to /dev/video128 (that really should be
enough!)

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-compliance/v4l2-compliance.cpp
utils/v4l2-ctl/cx18-ctl.c
utils/v4l2-ctl/ivtv-ctl.c
utils/v4l2-ctl/v4l2-ctl-common.cpp
utils/v4l2-ctl/v4l2-ctl.cpp
utils/v4l2-dbg/v4l2-dbg.cpp

index e83459a..b8506f2 100644 (file)
@@ -85,11 +85,11 @@ static void usage(void)
        printf("Usage:\n");
        printf("Common options:\n");
        printf("  -d, --device=<dev> use device <dev> as the video device\n");
-       printf("                     if <dev> is a single digit, then /dev/video<dev> is used\n");
+       printf("                     if <dev> starts with a digit, then /dev/video<dev> is used\n");
        printf("  -r, --radio-device=<dev> use device <dev> as the radio device\n");
-       printf("                     if <dev> is a single digit, then /dev/radio<dev> is used\n");
+       printf("                     if <dev> starts with a digit, then /dev/radio<dev> is used\n");
        printf("  -V, --vbi-device=<dev> use device <dev> as the vbi device\n");
-       printf("                     if <dev> is a single digit, then /dev/vbi<dev> is used\n");
+       printf("                     if <dev> starts with a digit, then /dev/vbi<dev> is used\n");
        printf("  -h, --help         display this help message\n");
        printf("  -n, --no-warnings  turn off warning messages.\n");
        printf("  -T, --trace        trace all called ioctls.\n");
@@ -414,31 +414,28 @@ int main(int argc, char **argv)
                        return 0;
                case OptSetDevice:
                        video_device = optarg;
-                       if (video_device[0] >= '0' && video_device[0] <= '9' && video_device[1] == 0) {
+                       if (video_device[0] >= '0' && video_device[0] <= '9' && strlen(video_device) <= 3) {
                                static char newdev[20];
-                               char dev = video_device[0];
 
-                               sprintf(newdev, "/dev/video%c", dev);
+                               sprintf(newdev, "/dev/video%s", video_device);
                                video_device = newdev;
                        }
                        break;
                case OptSetRadioDevice:
                        radio_device = optarg;
-                       if (radio_device[0] >= '0' && radio_device[0] <= '9' && radio_device[1] == 0) {
+                       if (radio_device[0] >= '0' && radio_device[0] <= '9' && strlen(radio_device) <= 3) {
                                static char newdev[20];
-                               char dev = radio_device[0];
 
-                               sprintf(newdev, "/dev/radio%c", dev);
+                               sprintf(newdev, "/dev/radio%s", radio_device);
                                radio_device = newdev;
                        }
                        break;
                case OptSetVbiDevice:
                        vbi_device = optarg;
-                       if (vbi_device[0] >= '0' && vbi_device[0] <= '9' && vbi_device[1] == 0) {
+                       if (vbi_device[0] >= '0' && vbi_device[0] <= '9' && strlen(vbi_device) <= 3) {
                                static char newdev[20];
-                               char dev = vbi_device[0];
 
-                               sprintf(newdev, "/dev/vbi%c", dev);
+                               sprintf(newdev, "/dev/vbi%s", vbi_device);
                                vbi_device = newdev;
                        }
                        break;
index 20b1e58..ba95fff 100644 (file)
@@ -266,11 +266,10 @@ int main(int argc, char **argv)
                }
                case OptSetDevice:
                        device = optarg;
-                       if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) {
+                       if (device[0] >= '0' && device[0] <= '9' && strlen(device) <= 3) {
                                static char newdev[20];
-                               char dev = device[0];
 
-                               sprintf(newdev, "/dev/video%c", dev);
+                               sprintf(newdev, "/dev/video%s", device);
                                device = newdev;
                        }
                        break;
index 07801b6..8eda123 100644 (file)
@@ -397,11 +397,10 @@ int main(int argc, char **argv)
                }
                case OptSetDevice:
                        device = optarg;
-                       if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) {
+                       if (device[0] >= '0' && device[0] <= '9' && strlen(device) <= 3) {
                                static char newdev[20];
-                               char dev = device[0];
 
-                               sprintf(newdev, "/dev/video%c", dev);
+                               sprintf(newdev, "/dev/video%s", device);
                                device = newdev;
                        }
                        break;
index f83bd05..7e8dd84 100644 (file)
@@ -58,7 +58,7 @@ void common_usage(void)
               "                     set the value of the controls [VIDIOC_S_EXT_CTRLS]\n"
               "  -D, --info         show driver info [VIDIOC_QUERYCAP]\n"
               "  -d, --device=<dev> use device <dev> instead of /dev/video0\n"
-              "                     if <dev> is a single digit, then /dev/video<dev> is used\n"
+              "                     if <dev> starts with a digit, then /dev/video<dev> is used\n"
               "  -h, --help         display this help message\n"
               "  --help-all         all options\n"
               "  --help-io          input/output options\n"
index b3277ff..fbe3cca 100644 (file)
@@ -826,11 +826,10 @@ int main(int argc, char **argv)
                        return 0;
                case OptSetDevice:
                        device = optarg;
-                       if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) {
+                       if (device[0] >= '0' && device[0] <= '9' && strlen(device) <= 3) {
                                static char newdev[20];
-                               char dev = device[0];
 
-                               sprintf(newdev, "/dev/video%c", dev);
+                               sprintf(newdev, "/dev/video%s", device);
                                device = newdev;
                        }
                        break;
index 173bf73..0dac309 100644 (file)
@@ -172,7 +172,7 @@ static void usage(void)
        printf("Usage: v4l2-dbg [options] [values]\n"
               "  -D, --info         Show driver info [VIDIOC_QUERYCAP]\n"
               "  -d, --device=<dev> Use device <dev> instead of /dev/video0\n"
-              "                     If <dev> is a single digit, then /dev/video<dev> is used\n"
+              "                     If <dev> starts with a digit, then /dev/video<dev> is used\n"
               "  -h, --help         Display this help message\n"
               "  --verbose          Turn on verbose ioctl error reporting\n"
               "  -c, --chip=<chip>  The chip identifier to use with other commands\n"
@@ -441,11 +441,10 @@ int main(int argc, char **argv)
 
                case OptSetDevice:
                        device = optarg;
-                       if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) {
+                       if (device[0] >= '0' && device[0] <= '9' && strlen(device) <= 3) {
                                static char newdev[20];
-                               char dev = device[0];
 
-                               sprintf(newdev, "/dev/video%c", dev);
+                               sprintf(newdev, "/dev/video%s", device);
                                device = newdev;
                        }
                        break;