linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Custom device names for v4l2 devices
@ 2013-03-08  2:11 vkalia
  2013-03-11 17:55 ` vkalia
  0 siblings, 1 reply; 4+ messages in thread
From: vkalia @ 2013-03-08  2:11 UTC (permalink / raw)
  To: linux-media

Hi

Names of V4L2 device nodes keep on varying depending on target, on some
targets, the device node assigned to my device is /dev/video21 and on some
it is /dev/video15. In order to determine my device, i am opening it,
reading the capabilities, enumerating its formats and then chose the one
matching my requirements. This is impacting start-up latency. One way to
resolve this without impacting start-up latency is to give custom name to
my V4L2 device node (/dev/custom_name instead of /dev/video21). This needs
following change in V4L2 framework. Please review this patch. If you have
faced similar problem please let me know.

--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -676,7 +676,8 @@ int __video_register_device(struct video_device *vdev,
int type, int nr,
 	vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
 	if (vdev->parent)
 		vdev->dev.parent = vdev->parent;
-	dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
+	if (!dev_name(&vdev->dev))
+		dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
 	ret = device_register(&vdev->dev);
 	if (ret < 0) {
 		printk(KERN_ERR "%s: device_register failed\n", __func__);


Thanks
Vinay


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Custom device names for v4l2 devices
  2013-03-08  2:11 Custom device names for v4l2 devices vkalia
@ 2013-03-11 17:55 ` vkalia
  2013-03-11 21:28   ` Laurent Pinchart
  0 siblings, 1 reply; 4+ messages in thread
From: vkalia @ 2013-03-11 17:55 UTC (permalink / raw)
  Cc: linux-media, vrajesh, laurent.pinchart

Please suggest.

Thanks
Vinay

> Hi
>
> Names of V4L2 device nodes keep on varying depending on target, on some
> targets, the device node assigned to my device is /dev/video21 and on some
> it is /dev/video15. In order to determine my device, i am opening it,
> reading the capabilities, enumerating its formats and then chose the one
> matching my requirements. This is impacting start-up latency. One way to
> resolve this without impacting start-up latency is to give custom name to
> my V4L2 device node (/dev/custom_name instead of /dev/video21). This needs
> following change in V4L2 framework. Please review this patch. If you have
> faced similar problem please let me know.
>
> --- a/drivers/media/video/v4l2-dev.c
> +++ b/drivers/media/video/v4l2-dev.c
> @@ -676,7 +676,8 @@ int __video_register_device(struct video_device *vdev,
> int type, int nr,
>  	vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
>  	if (vdev->parent)
>  		vdev->dev.parent = vdev->parent;
> -	dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
> +	if (!dev_name(&vdev->dev))
> +		dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
>  	ret = device_register(&vdev->dev);
>  	if (ret < 0) {
>  		printk(KERN_ERR "%s: device_register failed\n", __func__);
>
>
> Thanks
> Vinay
>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Custom device names for v4l2 devices
  2013-03-11 17:55 ` vkalia
@ 2013-03-11 21:28   ` Laurent Pinchart
  2013-03-14 15:45     ` David Dillow
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2013-03-11 21:28 UTC (permalink / raw)
  To: vkalia; +Cc: linux-media, vrajesh

Hi Vinay,

On Monday 11 March 2013 10:55:37 vkalia@codeaurora.org wrote:
> > Names of V4L2 device nodes keep on varying depending on target, on some
> > targets, the device node assigned to my device is /dev/video21 and on some
> > it is /dev/video15. In order to determine my device, i am opening it,
> > reading the capabilities, enumerating its formats and then chose the one
> > matching my requirements. This is impacting start-up latency. One way to
> > resolve this without impacting start-up latency is to give custom name to
> > my V4L2 device node (/dev/custom_name instead of /dev/video21). This needs
> > following change in V4L2 framework. Please review this patch. If you have
> > faced similar problem please let me know.

Shouldn't this be implemented in userspace as udev rules instead ?

> > --- a/drivers/media/video/v4l2-dev.c
> > +++ b/drivers/media/video/v4l2-dev.c
> > @@ -676,7 +676,8 @@ int __video_register_device(struct video_device *vdev,
> > int type, int nr,
> > 
> >  	vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
> >  	if (vdev->parent)
> >  	
> >  		vdev->dev.parent = vdev->parent;
> > 
> > -	dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
> > +	if (!dev_name(&vdev->dev))
> > +		dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
> > 
> >  	ret = device_register(&vdev->dev);
> >  	if (ret < 0) {
> >  	
> >  		printk(KERN_ERR "%s: device_register failed\n", __func__);

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Custom device names for v4l2 devices
  2013-03-11 21:28   ` Laurent Pinchart
@ 2013-03-14 15:45     ` David Dillow
  0 siblings, 0 replies; 4+ messages in thread
From: David Dillow @ 2013-03-14 15:45 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: vkalia, linux-media, vrajesh

On Mon, 2013-03-11 at 22:28 +0100, Laurent Pinchart wrote:
> Hi Vinay,
> 
> On Monday 11 March 2013 10:55:37 vkalia@codeaurora.org wrote:
> > > Names of V4L2 device nodes keep on varying depending on target, on some
> > > targets, the device node assigned to my device is /dev/video21 and on some
> > > it is /dev/video15. In order to determine my device, i am opening it,
> > > reading the capabilities, enumerating its formats and then chose the one
> > > matching my requirements. This is impacting start-up latency. One way to
> > > resolve this without impacting start-up latency is to give custom name to
> > > my V4L2 device node (/dev/custom_name instead of /dev/video21). This needs
> > > following change in V4L2 framework. Please review this patch. If you have
> > > faced similar problem please let me know.
> 
> Shouldn't this be implemented in userspace as udev rules instead ?

Indeed, this is possible; I use it to provide consistent names for my
MythTV installation. If you have different V4L devices, you could have a
utility that probes the capabilities when the device is discovered and
use its output to add appropriate symlinks -- for example 

IMPORT{program}="your/utility/here $tempnode"
ENV{YOUR_EXPORTED_VAR_VBI_SUPPORT}=="yes", SYMLINK+="v4l/hd-capable/video"

That that would need some tweaks to handle multiple devices (ie, naming)
that I didn't go look up the escapes for.

Here's my set from home to give you more grist for the mill:

$ cat /etc/udev/rules.d/60-persistent-capture.rules
# Give a persistent name for MythTV to use
#
ACTION=="remove", GOTO="name_video_end"
SUBSYSTEM!="video4linux", GOTO="name_video_end"

IMPORT{program}="v4l_id $tempnode"
#IMPORT{program}="path_id %p"

SUBSYSTEMS=="usb", IMPORT{program}="usb_id --export %p"

KERNEL=="video*", ENV{ID_SERIAL}=="Hauppauge_Hauppauge_Device_4034580546", SYMLINK+="v4l/HVR850/video"
KERNEL=="vbi*", ENV{ID_SERIAL}=="Hauppauge_Hauppauge_Device_4034580546", SYMLINK+="v4l/HVR850/vbi"

# These no longer work; we stopped getting a PCI device path from the kernel it seems...
#KERNEL=="video*", ENV{ID_PATH}=="pci-0000:04:00.0", SYMLINK+="v4l/WinTV/video"
#KERNEL=="vbi*", ENV{ID_PATH}=="pci-0000:04:00.0", SYMLINK+="v4l/WinTV/vbi"

# Key off of the product name now that we cannot tie it to the PCI path
KERNEL=="video*", ENV{ID_V4L_PRODUCT}=="Hauppauge WinTV 34xxx models", SYMLINK+="v4l/WinTV/video"
KERNEL=="vbi*", ENV{ID_V4L_PRODUCT}=="Hauppauge WinTV 34xxx models", SYMLINK+="v4l/WinTV/vbi"

LABEL="name_video_end"



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-14 15:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-08  2:11 Custom device names for v4l2 devices vkalia
2013-03-11 17:55 ` vkalia
2013-03-11 21:28   ` Laurent Pinchart
2013-03-14 15:45     ` David Dillow

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).