linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: hal, udev and video4linux probers
Date: Fri, 08 May 2009 20:06:44 +0000	[thread overview]
Message-ID: <1241813204.21272.11.camel@poy> (raw)
In-Reply-To: <8ceb98f20905081004l52ac4b95h1c23d9e8ed209e37@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]

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

[-- Attachment #2: Type: text/x-csrc, Size: 1597 bytes --]

#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;
}

[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

# do not edit this file, it will be overwritten on update

ACTION=="add|change", SUBSYSTEM=="video4linux", ENV{MAJOR}=="?*", IMPORT{program}="v4l_id $tempnode"

  reply	other threads:[~2009-05-08 20:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-08 17:04 hal, udev and video4linux probers Filippo Argiolas
2009-05-08 20:06 ` Kay Sievers [this message]
2009-05-08 20:25 ` David Zeuthen
2009-05-08 20:38 ` Filippo Argiolas
2009-05-09 11:49 ` Kay Sievers
2009-05-09 14:24 ` Filippo Argiolas
2009-05-09 14:54 ` Filippo Argiolas
2009-05-09 16:19 ` Kay Sievers
2009-05-10 13:58 ` Kay Sievers
2009-05-10 18:50 ` Filippo Argiolas
2009-05-10 23:59 ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1241813204.21272.11.camel@poy \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).