Find Vendor/Product ID from uhid device

Martin Laabs mailinglists at martinlaabs.de
Sun Mar 21 12:03:29 UTC 2010


Hello Hans,

Hans Petter Selasky wrote:

> I would recommend you use libusb in userland to do this. Then you get all the 
> information you need for the ID-match and more.

Unfortunately the linux-js driver creates a new device in /dev/input which 
is IMHO impossible for a userland program. So I have to detect the usb 
devices in kernel space.

  If that is not desirable, we
> can add that information like an IOCTL. usbconfig show_ifdrv might also give 
> you some clues.

Yes - in fact. I.e. the output I am interested in is
ugen2.2.0: uhid0: <Logitech Logitech Extreme 3D, class 0/0, rev 1.10/2.04, 
addr 2>
Now I could figure out that ugen2.2.0 has idVendor=0x046d idProduct=0xc215 
with usbconfig dump_device_desc. After that the driver would check that ids 
against its database and if it would match it would use the /dev/uhid0 
device. (with kopen - see below)

> Doesn't the linux-js joystick driver already have a parser for HID descriptors 
> and more?

No. Unfortunately it has a database of vendor and product IDs of devices it 
supports.

> You might find the following function useful to detach the /dev/uhidX driver. 

Well. As far as I understand the linux-js driver for now it relies on the 
uhid driver. After checking the /dev/uhidX devices agains its 
vendor/product database it opens the /dev/uhidX device via kopen an do its 
manipulations on it. A bit crapy but that way it can support many different 
physical ports without having to much overhead. (Soundcard joystick port, 
serial, parallel and also the usb port)

Do you think it is much effort to add a ioctl to the uhid driver that 
reports the corresponding  usb_device_info struct? This would make porting 
the linux-js driver much more simple for me.
Or is there a (simple accessible) data structure inside the kernel where I 
can get the information which vendor/product id correspond to a uhidX 
attached device?

Thank you,
  Martin Laabs



More information about the freebsd-usb mailing list