From rea-fbsd@codelabs.ru Fri Oct 5 08:29:22 2007 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1D60416A419 for ; Fri, 5 Oct 2007 08:29:22 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from pobox.codelabs.ru (pobox.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id B871013C455 for ; Fri, 5 Oct 2007 08:29:21 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25]) by pobox.codelabs.ru with esmtps (TLSv1:CAMELLIA256-SHA:256) id 1IdiYi-0008TL-2Z; Fri, 05 Oct 2007 12:29:20 +0400 Message-Id: <20071005082919.8FBCD1AF41E@void.codelabs.ru> Date: Fri, 5 Oct 2007 12:29:19 +0400 (MSD) From: Eygene Ryabinkin Reply-To: Eygene Ryabinkin To: FreeBSD-gnats-submit@freebsd.org Cc: imp@freebsd.org Subject: [patch] enable boot protocol on the USB keyboards X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 116947 >Category: usb >Synopsis: [ukbd] [patch] [regression] enable boot protocol on the USB keyboards >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-usb >State: patched >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Oct 05 08:30:14 GMT 2007 >Closed-Date: >Last-Modified: Tue Sep 28 01:53:04 UTC 2010 >Originator: Eygene Ryabinkin >Release: FreeBSD 7.0-CURRENT i386 >Organization: Code Labs >Environment: System: FreeBSD XXX 7.0-CURRENT FreeBSD 7.0-CURRENT #12: Fri Oct 5 11:59:33 MSD 2007 root@XXX:/usr/src/sys/i386/compile/XXX i386 >Description: I have two keyboards, MS Natural Ergonomic 4000 v. 1.0 and Logitech UltraX Premium Keyboard, whose F-keys are not recognized since the ukbd.c, version 1.70. And the problem is that 1.70 dropped initialization of the USB boot protocol for the USB keyboards. I understand that it was done after NetBSD's move, but the ukbd.c from NetBSD (revision 1.75) that eliminated boot protocol setting, added report descriptor parsing, so it does not care about the actual protocol device speaks: it just parses current report descriptor. FreeBSD still uses the hardcoded boot protocol descriptor, so device should be initialized to speak the boot protocol. And, as the section 7.2.6 of the HID specification (v. 1.11, 27/06/2001) says, one should not assume that the particular report protocol will be used upon the device initialization and should set the desired protocol explicitely. I understand that the elimination of the usbd_set_protocol() healed the issue in the usb/77940, but this fix contradicts with the USB HID specification and NetBSD's change is not an argument here, because they extensively reworked the HID parser. >How-To-Repeat: Plug one of the mentioned keyboards into the box with FreeBSD 7-CURRENT that was compiled after 21 Jun 2007, boot the box and try to use keys from F1 to F12. They would not work. >Fix: Essentially, the patch below just backs out the change in the 1.70, but it drops the quirk examination, since the quirk was eliminated. It fixes the things for both keyboards of mine and they are working for about 3 months without problems. --- usbd.set-boot-protocol.patch begins here --- --- ukbd.c.orig 2007-10-05 11:50:35.000000000 +0400 +++ ukbd.c 2007-10-05 11:59:18.000000000 +0400 @@ -1423,6 +1423,7 @@ init_keyboard(ukbd_state_t *state, int *type, int flags) { usb_endpoint_descriptor_t *ed; + usbd_status err; *type = KB_OTHER; @@ -1447,6 +1448,14 @@ printf("ukbd: unexpected endpoint\n"); return EINVAL; } + + err = usbd_set_protocol(state->ks_iface, 0); + if (err) { + printf("ukbd: set boot protocol failed\n"); + return EIO; + } else { + DPRINTFN(5, ("boot protocol set\n")); + } /* Ignore if SETIDLE fails since it is not crucial. */ usbd_set_idle(state->ks_iface, 0, 0); --- usbd.set-boot-protocol.patch ends here --- >Release-Note: >Audit-Trail: From: Tom Judge To: bug-followup@FreeBSD.org, rea-fbsd@codelabs.ru Cc: Subject: Re: usb/116947: [ukbd] [patch] [regression] enable boot protocol on the USB keyboards Date: Wed, 23 Sep 2009 22:22:16 +0000 This is a multi-part message in MIME format. --------------070601060402040600080702 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Here is a simple patch against 8.0 Beta 3 to make the Function keys work. This adds a quirk UQ_KBD_BOOTPROTO, than can be set to force the keyboard to use the boot protocol. --------------070601060402040600080702 Content-Type: text/plain; name="usb-natural4000.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="usb-natural4000.patch" Index: quirk/usb_quirk.c =================================================================== --- quirk/usb_quirk.c (revision 196574) +++ quirk/usb_quirk.c (working copy) @@ -122,6 +122,7 @@ {USB_QUIRK_ENTRY(USB_VENDOR_METAGEEK, USB_PRODUCT_METAGEEK_WISPY1B, 0x0000, 0xFFFF, UQ_KBD_IGNORE, UQ_HID_IGNORE, UQ_NONE)}, {USB_QUIRK_ENTRY(USB_VENDOR_TENX, USB_PRODUCT_TENX_UAUDIO0, 0x0101, 0x0101, UQ_AUDIO_SWAP_LR, UQ_NONE)}, /* MS keyboards do weird things */ + {USB_QUIRK_ENTRY(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_NATURAL4000, 0x0000, 0xFFFF, UQ_KBD_BOOTPROTO, UQ_NONE)}, {USB_QUIRK_ENTRY(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLINTELLIMOUSE, 0x0000, 0xFFFF, UQ_MS_LEADING_BYTE, UQ_NONE)}, {USB_QUIRK_ENTRY(USB_VENDOR_METAGEEK, USB_PRODUCT_METAGEEK_WISPY24X, 0x0000, 0xFFFF, UQ_KBD_IGNORE, UQ_HID_IGNORE, UQ_NONE)}, }; @@ -138,6 +139,7 @@ [UQ_BUS_POWERED] = "UQ_BUS_POWERED", [UQ_HID_IGNORE] = "UQ_HID_IGNORE", [UQ_KBD_IGNORE] = "UQ_KBD_IGNORE", + [UQ_KBD_BOOTPROTO] = "UQ_KBD_BOOTPROTO", [UQ_MS_BAD_CLASS] = "UQ_MS_BAD_CLASS", [UQ_MS_LEADING_BYTE] = "UQ_MS_LEADING_BYTE", [UQ_MS_REVZ] = "UQ_MS_REVZ", Index: quirk/usb_quirk.h =================================================================== --- quirk/usb_quirk.h (revision 196574) +++ quirk/usb_quirk.h (working copy) @@ -40,6 +40,7 @@ UQ_BUS_POWERED, /* device is bus powered, despite claim */ UQ_HID_IGNORE, /* device should be ignored by hid class */ UQ_KBD_IGNORE, /* device should be ignored by kbd class */ + UQ_KBD_BOOTPROTO, /* kbd should use the boot proto. */ UQ_MS_BAD_CLASS, /* doesn't identify properly */ UQ_MS_LEADING_BYTE, /* mouse sends an unknown leading byte */ UQ_MS_REVZ, /* mouse has Z-axis reversed */ Index: input/ukbd.c =================================================================== --- input/ukbd.c (revision 196574) +++ input/ukbd.c (working copy) @@ -789,6 +789,17 @@ * according to the BIOS data? */ KBD_PROBE_DONE(kbd); + /* + * Set boot protocol if we need the quirk. + */ + + if (usb_test_quirk(uaa, UQ_KBD_BOOTPROTO)) { + err = usbd_req_set_protocol(sc->sc_udev, &Giant, sc->sc_iface_index, 0); + if (err != USB_ERR_NORMAL_COMPLETION) { + DPRINTF("set protocol error=%s\n", usbd_errstr(err)); + goto detach; + } + } /* figure out if there is an ID byte in the data */ err = usbd_req_get_hid_desc(uaa->device, NULL, &hid_ptr, Index: usbdevs =================================================================== --- usbdevs (revision 196574) +++ usbdevs (working copy) @@ -1751,6 +1751,7 @@ product MICROSOFT WLNOTEBOOK3 0x00d2 Wireless Optical Mouse 3000 (Model 1049) product MICROSOFT WLUSBMOUSE 0x00b9 Wireless USB Mouse product MICROSOFT XBOX360 0x0292 XBOX 360 WLAN +product MICROSOFT NATURAL4000 0x00db Natural Ergonomic Keyboard 4000 /* Microtech products */ product MICROTECH SCSIDB25 0x0004 USB-SCSI-DB25 --------------070601060402040600080702-- From: Hans Petter Selasky To: Tom Judge , bug-followup@freebsd.org Cc: Subject: Re: usb/116947: [ukbd] [patch] [regression] enable boot protocol on the USB keyboards Date: Fri, 12 Feb 2010 10:05:32 +0100 Hi, Your patch has been committed with some modifications to USB P4: http://p4web.freebsd.org/chv.cgi?CH=174616 http://perforce.freebsd.org/chv.cgi?CH=174616 Please verify that everything is correct. --HPS State-Changed-From-To: open->patched State-Changed-By: emaste State-Changed-When: Tue Sep 28 01:52:05 UTC 2010 State-Changed-Why: I just tried -CURRENT with a MS Natural 4000 keyboard and the function keys work, so it appears this has made it through. http://www.freebsd.org/cgi/query-pr.cgi?pr=116947 >Unformatted: