]> err.no Git - systemd/commitdiff
v4l_id: move from udev-extras
authorKay Sievers <kay.sievers@vrfy.org>
Tue, 16 Jun 2009 16:41:05 +0000 (18:41 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Tue, 16 Jun 2009 16:41:05 +0000 (18:41 +0200)
configure.ac
extras/Makefile.am
extras/gudev/docs/.gitignore
extras/v4l_id/.gitignore [new file with mode: 0644]
extras/v4l_id/70-v4l.rules [moved from rules/rules.d/60-persistent-v4l.rules with 90% similarity]
extras/v4l_id/Makefile.am [new file with mode: 0644]
extras/v4l_id/v4l_id.c [new file with mode: 0644]
rules/Makefile.am

index b4d00e84292a601e867dae5eeed66bdfe5424110..960a552e8701a66c7f4bda823931a419346c2e6b 100644 (file)
@@ -106,6 +106,7 @@ AC_CONFIG_FILES([
        extras/rule_generator/Makefile
        extras/scsi_id/Makefile
        extras/usb_id/Makefile
+       extras/v4l_id/Makefile
        extras/udev-acl/Makefile
        extras/gudev/Makefile
        extras/gudev/gudev-1.0.pc
index 629b70e38739ac44728a1cf21db85c804f9d26ed..9528e8afa367c90031317548f32e4f3f83c9a854 100644 (file)
@@ -11,7 +11,8 @@ SUBDIRS = \
        fstab_import \
        rule_generator \
        scsi_id \
-       usb_id
+       usb_id \
+       v4l_id
 
 if ENABLE_EXTRAS
 SUBDIRS += \
index a471783ca9e309f2fc9a70e0b3200e29545066bb..1ac5f7f307dec90ba3804451c7bc9ebae9149494 100644 (file)
@@ -3,12 +3,12 @@ gudev-decl.txt
 gudev-overrides.txt
 gudev-undeclared.txt
 gudev-undocumented.txt
+gudev-unused.txt
 gudev.args
 gudev.hierarchy
 gudev.interfaces
 gudev.prerequisites
 gudev.signals
-gudev.unused
 html.stamp
 html/*
 xml/*
diff --git a/extras/v4l_id/.gitignore b/extras/v4l_id/.gitignore
new file mode 100644 (file)
index 0000000..dffced9
--- /dev/null
@@ -0,0 +1 @@
+v4l_id
similarity index 90%
rename from rules/rules.d/60-persistent-v4l.rules
rename to extras/v4l_id/70-v4l.rules
index 8415cd059b22f31730f466c1e2507b5aff8764a1..a342a71949a3137c581016eafe9cd3614d52083e 100644 (file)
@@ -2,6 +2,9 @@
 
 ACTION!="add|change", GOTO="persistent_v4l_end"
 SUBSYSTEM!="video4linux", GOTO="persistent_v4l_end"
+ENV{MAJOR}=="", GOTO="persistent_v4l_end"
+
+IMPORT{program}="v4l_id $tempnode"
 
 SUBSYSTEMS=="usb", IMPORT{program}="usb_id --export %p"
 KERNEL=="video*", ENV{ID_SERIAL}=="?*", SYMLINK+="v4l/by-id/$env{ID_BUS}-$env{ID_SERIAL}-video-index$attr{index}"
diff --git a/extras/v4l_id/Makefile.am b/extras/v4l_id/Makefile.am
new file mode 100644 (file)
index 0000000..6ff9fcd
--- /dev/null
@@ -0,0 +1,9 @@
+include $(top_srcdir)/Makefile.am.inc
+
+udevhomedir = $(udev_prefix)/lib/udev
+udevhome_PROGRAMS = v4l_id
+
+udevrulesdir = $(udev_prefix)/lib/udev/rules.d
+dist_udevrules_DATA = 70-v4l.rules
+
+v4l_id_SOURCES = v4l_id.c
diff --git a/extras/v4l_id/v4l_id.c b/extras/v4l_id/v4l_id.c
new file mode 100644 (file)
index 0000000..59b4f2f
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2009 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (c) 2009 Filippo Argiolas <filippo.argiolas@gmail.com>
+ *
+ * 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;
+}
index 7f3cd5982d3cb6198e9060d4243313da7b02adca..6f1744fdb33b504ec8a92a9a3ed52c87ca3a2625 100644 (file)
@@ -7,7 +7,6 @@ dist_udevrules_DATA = \
        rules.d/60-persistent-storage-tape.rules \
        rules.d/60-persistent-serial.rules \
        rules.d/60-persistent-input.rules \
-       rules.d/60-persistent-v4l.rules \
        rules.d/80-drivers.rules \
        rules.d/95-udev-late.rules