Re: [Libmtp-discuss] udev and libmtp: detect a new mtp device based on its USB interface descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 03, 2010 at 10:25:43AM +0100, lan.liu@xxxxxxxxx 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....

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

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

Ciao, Marcus
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux