Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usbhid detach on linux doesn't work #15

Open
pyalot opened this issue May 7, 2013 · 5 comments
Open

usbhid detach on linux doesn't work #15

pyalot opened this issue May 7, 2013 · 5 comments

Comments

@pyalot
Copy link
Contributor

pyalot commented May 7, 2013

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

@pyalot
Copy link
Contributor Author

pyalot commented May 8, 2013

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.

@benvanik
Copy link
Owner

benvanik commented May 8, 2013

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.

@pyalot
Copy link
Contributor Author

pyalot commented May 8, 2013

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:

  1. The old solution of setting the ignore_device option no longer works, that was compiled out of udev in 2009
  2. The solution of detatching upon attach doesn't work for many people
  3. 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.

@benvanik
Copy link
Owner

benvanik commented May 8, 2013

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

@pyalot
Copy link
Contributor Author

pyalot commented May 9, 2013

sudo udevadm control --reload-rules

Didn't work either

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants