0

I am working on USB HIDs on linux platform. Keyboards, mouse etc., are examples of Human Interface Devices. Whenever a HID is inserted to a system, at first device enumeration occurs. Then an entry in the form of hidraw appears in the /dev directory.

In linux, "usbhid and hid" are the modules which are called when an HID device is inserted. When I disabled these modules (using rmmod and system restart), the devices were not enumerated and no hidraw entry appeared on /dev(as expected).

Now my question is there any way to know if any USB HID device is connected to a system with the above two modules being disabled i.e does any interrupt or signal generate upon hardware insertion.

I am planning to execute some code when such signal or interrupt occurs(in C). Any kind of help is appreciated.

Thanks,

pattu777
  • 11
  • 2
  • 4

2 Answers2

0

Insertion of the device is detected through the voltage level changes occuring on the D+ and the D- lines. I do not think that insertion of USB device generates any interrupt. The voltage level changes are read by the hub(root or any hub further down on the line) and according reported to the core. The USB core driver would be notified about the same. So may be you can write a user-space driver which targets a specific device (using Vendor and Product ID) and through this you can carry out your functionality.

adkuv123
  • 36
  • 2
  • I wrote an user space program using libudev to continously look for hid devices. But it didn't work when the usbhid module was disabled. Again I don't want to rely on PID and VID as they can be modified. Can you provide me some link regarding how usb core driver handles voltage change. – pattu777 May 21 '12 at 08:13
  • http://www.lvr.com/usbcenum.htm This link explains Enumeration..... http://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_113_Simplified%20Description%20of%20USB%20Device%20Enumeration.pdf I will go through the USB HCI code and check how it handles this....My guess is the Host Controller must be having the required hardware to detect change on lines after which it must be generating an interrupt to the core....Need to confirm this.... – adkuv123 May 21 '12 at 12:36
0

If you are doing this in user mode, you get get a notification using udev (which use netlink internally).

You can match a device using the vendorId and productId field in the rulefile.

SUBSYSTEMS=="usb", ATTRS{idVendor}=="abcd", ATTRS{idProduct}=="1234"
J-16 SDiZ
  • 26,473
  • 4
  • 65
  • 84