2 * Copyright (C) 2009 Kay Sievers <kay@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:
24 #include <sys/types.h>
26 #include <sys/ioctl.h>
27 #include <linux/videodev2.h>
29 int main (int argc, char *argv[])
31 static const struct option options[] = {
32 { "help", no_argument, NULL, 'h' },
37 struct v4l2_capability v2cap;
42 option = getopt_long(argc, argv, "h", options, NULL);
48 printf("Usage: v4l_id [--help] <device file>\n\n");
54 device = argv[optind];
58 fd = open (device, O_RDONLY);
62 if (ioctl (fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
63 printf("ID_V4L_VERSION=2\n");
64 printf("ID_V4L_PRODUCT=%s\n", v2cap.card);
65 printf("ID_V4L_CAPABILITIES=:");
66 if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0)
68 if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0)
69 printf("video_output:");
70 if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0)
71 printf("video_overlay:");
72 if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0)
74 if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0)
76 if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0)