|
|
|
Re: hal, udev and video4linux probers | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
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
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.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[])
{
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;
}
# do not edit this file, it will be overwritten on update
ACTION=="add|change", SUBSYSTEM=="video4linux", ENV{MAJOR}=="?*", IMPORT{program}="v4l_id $tempnode"
[Home] [Linux DVB] [Video Technology] [Asterisk] [Photo] [DCCP] [Netdev] [Plasma TVs] [Video Projectors] [PDAs] [Xorg] [Util Linux NG] [Xfree86] [Devices] [Big List of Linux Books] [iPod Nano] [LCD TVs] [Webcams] [Fedora Women] [HDTV] [ALSA Devel] [Linux USB]
![]() |
![]() |