diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-05-09 13:44:20 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2009-05-09 13:44:20 +0200 |
commit | 8dff60dac643f713ea3a9e2e09af0829d3215551 (patch) | |
tree | 5002f0bdbe943a4ce0d09cf325b691e82304e764 | |
parent | 6ab989b75d0c5b19967efe7001dd718a684ed592 (diff) |
add v4l_id
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | v4l_id/.gitignore | 1 | ||||
-rw-r--r-- | v4l_id/70-v4l_id.rules | 3 | ||||
-rw-r--r-- | v4l_id/Makefile.am | 6 | ||||
-rw-r--r-- | v4l_id/v4l_id.c | 101 |
6 files changed, 114 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 502dcbb..2c24739 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,7 @@ SUBDIRS = \ modem-modeswitch \ usb-db \ keymap \ + v4l_id \ udev-acl ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index 3e7ea79..afe6740 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT([udev-extras], - [20090506], + [20090509], [linux-hotplug@vger.kernel.org]) AC_PREREQ(2.60) AM_INIT_AUTOMAKE([check-news foreign 1.9 subdir-objects dist-bzip2]) @@ -56,6 +56,7 @@ rules.d/Makefile modem-modeswitch/Makefile udev-acl/Makefile keymap/Makefile +v4l_id/Makefile usb-db/Makefile ]) diff --git a/v4l_id/.gitignore b/v4l_id/.gitignore new file mode 100644 index 0000000..dffced9 --- /dev/null +++ b/v4l_id/.gitignore @@ -0,0 +1 @@ +v4l_id diff --git a/v4l_id/70-v4l_id.rules b/v4l_id/70-v4l_id.rules new file mode 100644 index 0000000..29e8b28 --- /dev/null +++ b/v4l_id/70-v4l_id.rules @@ -0,0 +1,3 @@ +# do not edit this file, it will be overwritten on update + +ACTION=="add|change", SUBSYSTEM=="video4linux", ENV{MAJOR}=="?*", IMPORT{program}="v4l_id $tempnode" diff --git a/v4l_id/Makefile.am b/v4l_id/Makefile.am new file mode 100644 index 0000000..0943496 --- /dev/null +++ b/v4l_id/Makefile.am @@ -0,0 +1,6 @@ +include $(top_srcdir)/Makefile.am.inc + +udevhomedir = $(udev_prefix)/lib/udev +udevhome_PROGRAMS = v4l_id + +v4l_id_SOURCES = v4l_id.c diff --git a/v4l_id/v4l_id.c b/v4l_id/v4l_id.c new file mode 100644 index 0000000..9cebcdb --- /dev/null +++ b/v4l_id/v4l_id.c @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2009 Kay Sievers <kay.sievers@vrfy.org> + * Copyright (c) 2009 Filippo Argiolas + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details: + */ + +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <ctype.h> +#include <stdlib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <errno.h> +#include <fcntl.h> +#include <getopt.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/ioctl.h> +#include <linux/videodev.h> +#include <linux/videodev2.h> + +int main (int argc, char *argv[]) +{ + static const struct option options[] = { + { "help", no_argument, NULL, 'h' }, + {} + }; + int fd; + char *device; + struct video_capability v1cap; + struct v4l2_capability v2cap; + + while (1) { + int option; + + option = getopt_long(argc, argv, "h", options, NULL); + if (option == -1) + break; + + switch (option) { + case 'h': + printf("Usage: v4l_id [--help] <device file>\n\n"); + default: + return 1; + } + } + device = argv[optind]; + + if (device == NULL) + return 2; + fd = open (device, O_RDONLY); + if (fd < 0) + return 3; + + if (ioctl (fd, VIDIOC_QUERYCAP, &v2cap) == 0) { + printf("ID_V4L_VERSION=2\n"); + printf("ID_V4L_PRODUCT=%s\n", v2cap.card); + printf("ID_V4L_CAPABILITIES=:"); + if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0) + printf("capture:"); + if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0) + printf("video_output:"); + if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0) + printf("video_overlay:"); + if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0) + printf("audio:"); + if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0) + printf("tuner:"); + if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0) + printf("radio:"); + printf("\n"); + } else if (ioctl (fd, VIDIOCGCAP, &v1cap) == 0) { + printf("ID_V4L_VERSION=1\n"); + printf("ID_V4L_PRODUCT=%s\n", v1cap.name); + printf("ID_V4L_CAPABILITIES=:"); + if ((v1cap.type & VID_TYPE_CAPTURE) > 0) + printf("capture:"); + if ((v1cap.type & VID_TYPE_OVERLAY) > 0) + printf("video_overlay:"); + if (v1cap.audios > 0) + printf("audio:"); + if ((v1cap.type & VID_TYPE_TUNER) > 0) + printf("tuner:"); + printf("\n"); + } + + close (fd); + return 0; +} |