| 
      
      
      From: Linus W. <lin...@gm...> - 2010-12-05 20:10:59
      
     | 
| Inspired by this discussion I have commited the following scheme
for libmtp 1.0.4 which can be checked out and studied from the
CVS repository:
./autogen.sh
./configure --libexecdir=/lib/udev
make install
This will install the new program mtp-probe into /lib/udev/mtp-probe
and the libmtp.rules file will be installed into /lib/udev/rules.d.
I don't know if I should even rename it 60-libmtp.rules as it's named
in most distributions? Should I?
Anyway, the generated udev rules now add these two special
rules after all the per-device unique matching rules:
# Autoprobe PTP devices
ENV{ID_MTP_DEVICE}!="1", ATTR{bDeviceClass}=="06",
PROGRAM="/lib/udev/mtp-probe /sys$env{DEVPATH} $attr{busnum}
$attr{devnum}", RESULT=="1", SYMLINK+="libmtp-%k", MODE="666",
ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
# Autoprobe vendor-specific devices
ENV{ID_MTP_DEVICE}!="1", ATTR{bDeviceClass}=="ff",
PROGRAM="/lib/udev/mtp-probe /sys$env{DEVPATH} $attr{busnum}
$attr{devnum}", RESULT=="1", SYMLINK+="libmtp-%k", MODE="666",
ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"
They basically mean: if you haven't identified the device as
MTP before, then now we do probe all 0xff (custom, vendor
specific) or PTP devices for MTP properties. This will use the
libmtp intrinsic mechanisms already inside libusb-glue.c,
including checking for the string "MTP" on the interface
description, AND trying OS descriptor probing!
If it matches (RESULT=="1") the device will be flagged as MTP
and media player.
Works like a charm on my machine! Try it out. NB: it's easy
to screw up the check with locak udev rules already matching
your device (like libgphoto2 or the generic music-players udev
script), this is intended to catch devices that are not yet
in the device database...
Linus Walleij
 |