Hi Laurent, UVCers,

I have a small suggestion for the linux-uvc driver. Currently, the
driver lets V4L2 automatically select the device node (/dev/videoX).
But we all know that order of loading modules, init times, et.al. may
influence the order, therefore I thought it might by practical to
introduce a module option to request a specific device node.

Caveat: My implementation is by all means incomplete. It will only work
for one device (and actually fail for any subsequent ones AFAICT,
unless you reset the parameter in /sys/), and is totally unflexible. On
the other hand. it doesn't intrude if you don't provide a parameter.

I forsee flexible functionality as you can find e.g. in the pwc webcam
driver[*]. Their implementation also fails if the requested node is not
available, but it provides a type and serial number dependant
selection.


Furthermore, while quick-hacking this code, I noticed that linux-uvc
a) doesn't report its version -> use macro MODULE_VERSION()
b) doesn't provide parameter descriptions (which can be queried with
   "modinfo uvcvideo") -> use macro MODULE_PARM_DESC()
c) doesn't report which device node it actually assigns to the device,
   which is very useful in dmesg (and which other drivers tend to do).

So please consider the attached patch two seperate suggestions:
- general messaging and API documentation improvements
- a stub for requesting a particular device node.

Please let me know if you consider it useful, or have something better
to suggest.

Thanks for listening, and thanks for the ever so valuable driver!

Patch is against SVN r195.
I've tested with Logitech QuickCam Fusion on two machines.

Kind regards,
Moritz

[*] called device hints in pwc-if.c
diff -ur linux-uvc-trunk-r195/uvc_driver.c 
linux-uvc-trunk-r195-device_request/uvc_driver.c
--- linux-uvc-trunk-r195/uvc_driver.c   2008-03-20 10:59:20.000000000 +0100
+++ linux-uvc-trunk-r195-device_request/uvc_driver.c    2008-03-20 
19:47:41.000000000 +0100
@@ -52,6 +52,7 @@
 #endif
 
 static unsigned int uvc_quirks_param = 0;
+static unsigned int uvc_dev_req_param = -1;
 unsigned int uvc_trace_param = 0;
 
 /* ------------------------------------------------------------------------
@@ -1470,11 +1471,16 @@
        dev->video.vdev = vdev;
        video_set_drvdata(vdev, &dev->video);
 
-       if (video_register_device(vdev, VFL_TYPE_GRABBER, -1) < 0) {
+       if (uvc_dev_req_param != -1) {
+               uvc_printk(KERN_INFO, "Explicitly requesting device 
/dev/video%d.\n", uvc_dev_req_param);
+       }
+
+       if (video_register_device(vdev, VFL_TYPE_GRABBER, uvc_dev_req_param) < 
0) {
                dev->video.vdev = NULL;
                video_device_release(vdev);
                return -1;
        }
+       uvc_printk(KERN_INFO, "Registered as /dev/video%d.\n", vdev->minor & 
0x3F);
 
        return 0;
 }
@@ -1902,15 +1908,20 @@
 static void __exit uvc_cleanup(void)
 {
        usb_deregister(&uvc_driver.driver);
+       uvc_printk(KERN_INFO, "Deregistered driver.\n");
 }
 
 module_init(uvc_init);
 module_exit(uvc_cleanup);
 
 module_param_named(quirks, uvc_quirks_param, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(quirks, "Forced quirks mask");
 module_param_named(trace, uvc_trace_param, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(trace, "Trace level mask");
+module_param_named(dev_req, uvc_dev_req_param, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(dev_req, "Requested device /dev/videoX instead of automatic 
selection");
 
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
-
+MODULE_VERSION(DRIVER_VERSION);
_______________________________________________
Linux-uvc-devel mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/linux-uvc-devel

Reply via email to