From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Fri, 08 May 2009 20:06:44 +0000 Subject: Re: hal, udev and video4linux probers Message-Id: <1241813204.21272.11.camel@poy> MIME-Version: 1 Content-Type: multipart/mixed; boundary="=-vOtAhpDtWp04dcd7ZeT+" List-Id: References: <8ceb98f20905081004l52ac4b95h1c23d9e8ed209e37@mail.gmail.com> In-Reply-To: <8ceb98f20905081004l52ac4b95h1c23d9e8ed209e37@mail.gmail.com> To: linux-hotplug@vger.kernel.org --=-vOtAhpDtWp04dcd7ZeT+ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, 2009-05-08 at 19:04 +0200, Filippo Argiolas wrote: > Probably a dedicated Devicekit-video thing > would be overengineered for a simple task like this, so udev-extras > should be the new place for it. If you want, try this: $ gcc -Wall -o v4l_id v4l_id.c $ cp v4l_id /lib/udev $ cp 70-v4l_id.rules /lib/udev/rules.d/ After you un-plugged/plugged a device, you will see the properties at the device: /sbin/udevadm info --query=env --name=video0 ... ID_V4L_VERSION=2 ID_V4L_PRODUCT=UVC Camera (17ef:4807) ID_V4L_VIDEO_CAPTURE=1 ... > Being honest I'm not so sure I will use libudev, I'm currently looking > for a way to do the device probing directly from gstreamer, but it > would be nice to preserve that v4l probing stuff somewhere with HAL > going away (furthermore, I doubt we're the only users of that prober). No sure, how else you can get that information. :) You can query that properties at program startup with libudev, by "enumerate"-ing all video4linux devices. You can listen to events for new devices with a "monitor", which retrieves all new video4linux devices as soon as they are connected. If the prober is what you are looking for, let me know, and I will put it in udev-extras. Cheers, Kay --=-vOtAhpDtWp04dcd7ZeT+ Content-Description: Content-Disposition: inline; filename="v4l_id.c" Content-Type: text/x-csrc; charset="UTF-8" Content-Transfer-Encoding: 7bit #include #include #include #include #include #include #include #include #include #include #include #include int main (int argc, char *argv[]) { int fd; char *device; struct video_capability v1cap; struct v4l2_capability v2cap; device = argv[1]; if (device == NULL) return 1; fd = open (device, O_RDONLY); if (fd < 0) return 2; if (ioctl (fd, VIDIOC_QUERYCAP, &v2cap) == 0) { printf("ID_V4L_VERSION=2\n"); printf("ID_V4L_PRODUCT=%s\n", v2cap.card); if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0) printf("ID_V4L_VIDEO_CAPTURE=1\n"); if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0) printf("ID_V4L_VIDEO_OUTPUT=1\n"); if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0) printf("ID_V4L_VIDEO_OVERLAY=1\n"); if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0) printf("ID_V4L_AUDIO=1\n"); if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0) printf("ID_V4L_TUNER=1\n"); if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0) printf("ID_V4L_RADIO=1\n"); } else if (ioctl (fd, VIDIOCGCAP, &v1cap) == 0) { printf("ID_V4L_VERSION=1\n"); printf("ID_V4L_PRODUCT=%s\n", v1cap.name); if ((v1cap.type & VID_TYPE_CAPTURE) > 0) printf("ID_V4L_VIDEO_CAPTURE=1\n"); if ((v1cap.type & VID_TYPE_OVERLAY) > 0) printf("ID_V4L_VIDEO_OVERLAY=1\n"); if (v1cap.audios > 0) printf("ID_V4L_AUDIO=1\n"); if ((v1cap.type & VID_TYPE_TUNER) > 0) printf("ID_V4L_TUNER=1\n"); } close (fd); return 0; } --=-vOtAhpDtWp04dcd7ZeT+ Content-Description: Content-Disposition: inline; filename="70-v4l_id.rules" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit # do not edit this file, it will be overwritten on update ACTION=="add|change", SUBSYSTEM=="video4linux", ENV{MAJOR}=="?*", IMPORT{program}="v4l_id $tempnode" --=-vOtAhpDtWp04dcd7ZeT+--