1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 * Copyright (C) 2009 Kay Sievers <kay@vrfy.org>
5 * Copyright (c) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details:
25 #include <sys/ioctl.h>
27 #include <sys/types.h>
29 #include <linux/videodev2.h>
34 int main(int argc
, char *argv
[]) {
35 static const struct option options
[] = {
36 { "help", no_argument
, NULL
, 'h' },
39 _cleanup_close_
int fd
= -1;
41 struct v4l2_capability v2cap
;
44 while ((c
= getopt_long(argc
, argv
, "h", options
, NULL
)) >= 0)
48 printf("%s [-h,--help] <device file>\n\n"
49 "Video4Linux device identification.\n\n"
50 " -h Print this message\n"
51 , program_invocation_short_name
);
57 assert_not_reached("Unhandled option");
60 device
= argv
[optind
];
64 fd
= open(device
, O_RDONLY
);
68 if (ioctl(fd
, VIDIOC_QUERYCAP
, &v2cap
) == 0) {
69 printf("ID_V4L_VERSION=2\n");
70 printf("ID_V4L_PRODUCT=%s\n", v2cap
.card
);
71 printf("ID_V4L_CAPABILITIES=:");
72 if ((v2cap
.capabilities
& V4L2_CAP_VIDEO_CAPTURE
) > 0)
74 if ((v2cap
.capabilities
& V4L2_CAP_VIDEO_OUTPUT
) > 0)
75 printf("video_output:");
76 if ((v2cap
.capabilities
& V4L2_CAP_VIDEO_OVERLAY
) > 0)
77 printf("video_overlay:");
78 if ((v2cap
.capabilities
& V4L2_CAP_AUDIO
) > 0)
80 if ((v2cap
.capabilities
& V4L2_CAP_TUNER
) > 0)
82 if ((v2cap
.capabilities
& V4L2_CAP_RADIO
) > 0)