usbhid detach on linux doesn't work
pyalot opened this issue · 5 comments
On ubuntu 12.04 adding the 40-oculus.rules file, unplugging the device, restarting the udev service and plugging the device in does not prevent te usbhid driver to latch onto the device.
uname -a: Linux wintermute 3.2.0-41-generic-pae #66-Ubuntu SMP Thu Apr 25 03:50:20 UTC 2013 i686 i686 i386 GNU/Linux
usb-devices section for the oculus rift:
T: Bus=08 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 6 Spd=12 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=2833 ProdID=0001 Rev=00.16
S: Manufacturer=Oculus VR, Inc.
S: Product=Tracker DK
S: SerialNumber=8D8723894855
C: #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid
I believe what's happening is that changes to usbhid cause it to immediately reattach after being detatched if no other driver has claimed the device.
I'd suggest the proper way to handle this would be to write a kernel module driver that claims the device before usbhid does.
The whole point of the .rules file is to do this (detach from usbhid upon attaching). I believe I'm using Ubuntu 12.04 and it works for me. Are you using the installation script or manually copying the file? The file must be chowned or it will not work.
The whole point of the .rules file is to do this (detach from usbhid upon attaching).
Yes, but that's the part not working.
Are you using the installation script
Yes.
manually copying the file
Also tried that, didn't work either.
The file must be chowned or it will not work.
The install script does not perform a chown. However all files in /lib/udev/rules.d/ are owned by root, and if you execute the install script as root, after the copy the 40-oculus.rules file is equally owned by root. Doesn't work regardless.
I've looked around for a solution to this problem and there are a couple of points:
- The old solution of setting the ignore_device option no longer works, that was compiled out of udev in 2009
- The solution of detatching upon attach doesn't work for many people
- The recommended solution is to have a driver run as root detatch the kernel driver by API call and immediately attach to the device to prevent usbhid claiming it.
I have encountered the very same problem with userland USB drivers since ubuntu 10.04 I believe where they changed something (no idea what). If you do not immediately attach a driver after gotten rid of the last driver, then some driver will claim the device again immediately after you release the file handle.
Odd that it works for me, then.
I see someone else who has tried this after adding a rule as I do:
sudo udevadm control --reload-rules
sudo udevadm control --reload-rules
Didn't work either