On Saturday 24 November 2012 00:00:44 Niclas Zeising wrote: > Hi! > I have a couple of questions about USB. > I recently bought a new USB keyboard, a Logitech K120. When attaching > this to a FreeBSD system, however, it is detected as a hid device > (attaching to uhid) rather than a keyboard (attaching to ukbd). The > keyboard works fine, but I'm just curious as to why it doesn't use ukbd. > The output from usbconfig for this keyboard is: >
Hi, It seems the UHID driver needs to be synced with UMS and UKBD regarding the detection logic. Can you try the attached patch and report back. --HPS
=== sys/dev/usb/input/uhid.c ================================================================== --- sys/dev/usb/input/uhid.c (revision 243384) +++ sys/dev/usb/input/uhid.c (local) @@ -670,7 +670,11 @@ uhid_probe(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); + void *d_ptr; int error; + uint16_t d_len; + int is_keyboard; + int is_mouse; DPRINTFN(11, "\n"); @@ -684,18 +688,44 @@ if (usb_test_quirk(uaa, UQ_HID_IGNORE)) return (ENXIO); + is_keyboard = (uaa->info.bInterfaceClass == UICLASS_HID) && + (uaa->info.bInterfaceSubClass == UISUBCLASS_BOOT) && + (uaa->info.bInterfaceProtocol == UIPROTO_BOOT_KEYBOARD); + + is_mouse = (uaa->info.bInterfaceClass == UICLASS_HID) && + (uaa->info.bInterfaceSubClass == UISUBCLASS_BOOT) && + (uaa->info.bInterfaceProtocol == UIPROTO_MOUSE); + + if (is_keyboard == 0 && is_mouse == 0) { + /* search a bit more before we conclude */ + + error = usbd_req_get_hid_desc(uaa->device, NULL, + &d_ptr, &d_len, M_TEMP, uaa->info.bIfaceIndex); + + if (error == 0) { + if (hid_is_collection(d_ptr, d_len, + HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE))) { + /* most likely a mouse */ + is_mouse = 1; + } + if (hid_is_collection(d_ptr, d_len, + HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_KEYBOARD))) { + /* most likely a keyboard */ + is_keyboard = 1; + } + free(d_ptr, M_TEMP); + } + } + /* * Don't attach to mouse and keyboard devices, hence then no * "nomatch" event is generated and then ums and ukbd won't * attach properly when loaded. */ - if ((uaa->info.bInterfaceClass == UICLASS_HID) && - (uaa->info.bInterfaceSubClass == UISUBCLASS_BOOT) && - (((uaa->info.bInterfaceProtocol == UIPROTO_BOOT_KEYBOARD) && - !usb_test_quirk(uaa, UQ_KBD_IGNORE)) || - ((uaa->info.bInterfaceProtocol == UIPROTO_MOUSE) && - !usb_test_quirk(uaa, UQ_UMS_IGNORE)))) + if (is_keyboard != 0 && usb_test_quirk(uaa, UQ_KBD_IGNORE) == 0) return (ENXIO); + if (is_mouse != 0 && usb_test_quirk(uaa, UQ_UMS_IGNORE) == 0) + return (ENXIO); return (BUS_PROBE_GENERIC); }
_______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"