Hi Paulo, On Monday 02 March 2009 10:55:18 Paulo Assis wrote: > Laurent, > > Laurent Pinchart escreveu: > > Hi Paulo, > > > > On Thursday 26 February 2009 21:53:58 Paulo Assis wrote: > >> Hi, > >> In order to proper add dynamic controls to the uvc driver, I need at > >> least the vid string for the selected device. > >> I tried libwebcam approach by using /sys/class/video4linux, but this > >> proved highly distribution dependent and has caused a lot of trouble, > > > > Really ? The /sys tree shouldn't be distribution dependent. What kind of > > problems have you run into ? > > Here is a little example for video0: > > In Ubuntu I can get the values from: > /sys/class/video4linux/video0/device/input/ <-(here I list the > contents and there is always only one dir with some index lets say input6) > so vid I can get from input6/id/vendor and pid from input6/id/product > > In Mandriva 2009 vid:pid is set in: > /sys/class/video4linux/video0/device/input/event6 > > libwebcam (not sure what distro was used for development) gets this > values from: > /sys/class/video4linux/video0/device/idVendor and > /sys/class/video4linux/video0/device/idProduct
Those methods are definitely not portable. Here is what you should do. 1. Read the /sys/class/video4linux/video0 link and store its target. 2. In the link target read from 1, read the device link and store its target. 3. If the video device is a USB device, the parent directory of the link target read from 2 will contain two files called idVendor and idProduct that store the device vendor and product IDs. > >> so no I'm parsing the values passed in the device card field of > >> v4l2_capability struct. UVC sets this to "UVC Camera (vid:pid)" and > >> since I only need these fields for the uvc driver there shouldn't be a > >> problem, right? > >> Or are there any plans to change this field in the future ? > > > > There are no plans, but the card field isn't meant to convey that > > information. The format might change in the future without notice. > > This may prove to be a problem, but for now it seems my best option. > I've set the code so that in case parsing these values fails, dynamic > controls are added anyway, since you need to run the process with root user > so that it can succeed, only logitech owners will bother doing with it > (although it produces a really ugly output :-) ). Please try the above method, it should work properly across distributions. > The best solution for users is setting a udev script so that these > controls are added upon device connection, but this seems to be a bit > difficult for a lot of people, so they rather start guvcview with root > privileges once. The udev script should really be packaged by distributors (probably part of a libwebcam or uvcdynctrl package). Best regards, Laurent Pinchart _______________________________________________ Linux-uvc-devel mailing list [email protected] https://lists.berlios.de/mailman/listinfo/linux-uvc-devel
