V4L/DVB (8078): Introduce "index" attribute for persistent video4linux device nodes

A number of V4L drivers have a mod param to specify their preferred minors.
This is because it is often desirable for applications to have a static /dev
name for a particular device.  However, using minors has several disadvantages:

  1) the requested minor may already be taken
  2) using a mod param is driver specific
  3) it requires every driver to add a param
  4) requires configuration by hand

This patch introduces an "index" attribute that when combined with udev rules
can create static device paths like this:

/dev/v4l/by-path/pci-0000\:00\:1d.2-usb-0\:1\:1.0-video0
/dev/v4l/by-path/pci-0000\:00\:1d.2-usb-0\:1\:1.0-video1
/dev/v4l/by-path/pci-0000\:00\:1d.2-usb-0\:1\:1.0-video2

$ ls -la /dev/v4l/by-path/pci-0000\:00\:1d.2-usb-0\:1\:1.0-video0
lrwxrwxrwx 1 root root 12 2008-04-28 00:02 /dev/v4l/by-path/pci-0000:00:1d.2-usb-0:1:1.0-video0 -> ../../video1

These paths are steady across reboots and should be resistant to rearranging
across Kernel versions.

video_register_device_index is available to drivers to request a
specific index number.

Signed-off-by: Brandon Philips <[email protected]>
Signed-off-by: Kees Cook <[email protected]>
Signed-off-by: Kay Sievers <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
This commit is contained in:
[email protected] 2008-06-20 22:58:53 -03:00 • committed by Mauro Carvalho Chehab
commit 539a7555b3
2 changed files with 100 additions and 2 deletions

View file

@ -96,6 +96,8 @@ struct video_device
int type; /* v4l1 */
int type2; /* v4l2 */
int minor;
/* attribute to diferentiate multiple indexs on one physical device */
int index;
int debug; /* Activates debug level*/
@ -347,6 +349,8 @@ void *priv;
/* Version 2 functions */
extern int video_register_device(struct video_device *vfd, int type, int nr);
int video_register_device_index(struct video_device *vfd, int type, int nr,
int index);
void video_unregister_device(struct video_device *);
extern int video_ioctl2(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);