|
From: <la...@no...> - 2010-11-04 10:06:37
|
Hi,
Thanks for your feedback. Please check my reply labeled as '[Lan]', Thanks.
Regards,
Lan Liu
On Wed, Nov 03, 2010 at 10:25:43AM +0100, la...@no...<mailto:la...@no...> wrote:
> Hi,
> Thanks for your feedback. Based on following info, I did some investigation and get a draft solution, for your kindly review.
> For mtp devices shipped by Nokia, it will include string description for its interface descriptor. And this information is already available under sysfs file system when mtp devices plugged with PC.
>
> Following is what I get from 'sysfs' when I plug N8 with PC,'/sys/devices/pci0000:00/0000:00:1d.7/usb1/1-8' is the device path, while the subdirectory '1-8:1.0' is directory for the interface.
> The file 'interface' contains the content of string description for this interface.
The most important question is if the string descriptor content is prefetched, or if it is fetched on accessing....
[Lan] your concern is how we get the string descriptor? Am I right? If yes, this information is provided by kernel and put this information under 'sysfs' file system when devices plugged with PC. I mean, i did not issue any USB request to get this info, this info is pre-fetched. Basically, I just 'grep' the pattern 'MTP' in the file 'interface' if this file exist under the current device path.
> Based on this information, I wrote a bash script, passing it with 2 arguments: device path and the string description to match against(currently, I pass 'MTP', and more general pattern could be passed). If matches, it return 0 and udev rule file can apply corresponding configuration for a mtp device. If not matched, return 1 and do nothing in udev rule file. Just like following:
>
> 40-libgphoto2-2.rules
> PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp" ENV{GPHOTO2_DRIVER}="proprietary", ENV{ID_MEDIA_PLAYER}="1", MODE="0666", GROUP="plugdev"
>
> 45-libmtp8.rules
> PROGRAM="/home/mtp/test/wk43/a.sh /sys$env{DEVPATH} mtp" SYMLINK+="libmtp-%k", MODE="666", GROUP="plugdev"
>
> PS. I change both 40-libgphoto2-2.rules and 45-libmtp8.rules under '/lib/udev/rules.d' directory, because some gvfs application depends on the 'ID_MEDIA_PLAYER' attribute to decide the device icon, its related applications, etc.
This ID setting could be emitted by the libmtp rules too of course.
[Lan] that's fine, thus this script could be invoked only once.
> This solution works with Nokia devices: a whole-new device can be recognized as MTP device even its Vendor id, Product id is not in the device list. So for devices which include string description in their interface descriptor, this solution could work. What's your opinion. Thanks.
The one thing I worry is that by probing this string descriptor of any attached device, it might cause strange behaviour.
(I have one bugreport where gphoto2 --auto-detect resets a USB mouse. :( )
Of course we could only do this for known MTP vendors first.
But in general, you never know unless you try it :)
[Lan] So your concern is it is not recommended to access device while udev daemon is processing this new added device, since it may cause some strange problem. Am I right? The draft solution I suggested did not access the device directly, instead it read the information under /sys/. And currently, I did not notice any difference yet between adding device PID,VID manually into rules file and this draft solution. But I have to say, the limitation for this draft solution is: it does not work with mtp device which does not provide string description for its interface descriptor.
Ciao, Marcus
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Libmtp-discuss mailing list
Lib...@li...<mailto:Lib...@li...>
https://lists.sourceforge.net/lists/listinfo/libmtp-discuss
|