2 * Copyright (C) 2009 Kay Sievers <kay.sievers@vrfy.org>
3 * Copyright (c) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details:
28 #include <sys/types.h>
30 #include <sys/ioctl.h>
31 #include <linux/videodev.h>
32 #include <linux/videodev2.h>
34 int main (int argc, char *argv[])
36 static const struct option options[] = {
37 { "help", no_argument, NULL, 'h' },
42 struct video_capability v1cap;
43 struct v4l2_capability v2cap;
48 option = getopt_long(argc, argv, "h", options, NULL);
54 printf("Usage: v4l_id [--help] <device file>\n\n");
59 device = argv[optind];
63 fd = open (device, O_RDONLY);
67 if (ioctl (fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
68 printf("ID_V4L_VERSION=2\n");
69 printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
70 printf("ID_V4L_CAPABILITIES=:");
71 if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0)
73 if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0)
74 printf("video_output:");
75 if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0)
76 printf("video_overlay:");
77 if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0)
79 if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0)
81 if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0)
84 } else if (ioctl (fd, VIDIOCGCAP, &v1cap) == 0) {
85 printf("ID_V4L_VERSION=1\n");
86 printf("ID_V4L_PRODUCT=%s\n", v1cap.name);
87 printf("ID_V4L_CAPABILITIES=:");
88 if ((v1cap.type & VID_TYPE_CAPTURE) > 0)
90 if ((v1cap.type & VID_TYPE_OVERLAY) > 0)
91 printf("video_overlay:");
94 if ((v1cap.type & VID_TYPE_TUNER) > 0)