From owner-svn-src-head@FreeBSD.ORG Sat Jul 13 22:39:57 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1E908FB4; Sat, 13 Jul 2013 22:39:57 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E9D79124E; Sat, 13 Jul 2013 22:39:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6DMduQY098701; Sat, 13 Jul 2013 22:39:56 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6DMduZn098699; Sat, 13 Jul 2013 22:39:56 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201307132239.r6DMduZn098699@svn.freebsd.org> From: Hans Petter Selasky Date: Sat, 13 Jul 2013 22:39:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253332 - head/sys/dev/usb/input X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jul 2013 22:39:57 -0000 Author: hselasky Date: Sat Jul 13 22:39:56 2013 New Revision: 253332 URL: http://svnweb.freebsd.org/changeset/base/253332 Log: Allow regular off-the-shelf keyboards to be overclocked like so-called "Gamers Keyboards" by adding a tunable, "hw.usb.ukbd.pollrate", which can fix the polling rate of the attached USB keyboards in the range 1..1000Hz. A similar feature already exists in the USB mouse driver. Use with care! Might leave you without keyboard input. This feature is only available when the USB_DEBUG option is set in the kernel configuration file. Correct "unit" type to "int" while at it. Modified: head/sys/dev/usb/input/ukbd.c Modified: head/sys/dev/usb/input/ukbd.c ============================================================================== --- head/sys/dev/usb/input/ukbd.c Sat Jul 13 22:06:41 2013 (r253331) +++ head/sys/dev/usb/input/ukbd.c Sat Jul 13 22:39:56 2013 (r253332) @@ -92,14 +92,18 @@ __FBSDID("$FreeBSD$"); #ifdef USB_DEBUG static int ukbd_debug = 0; static int ukbd_no_leds = 0; +static int ukbd_pollrate = 0; -static SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB ukbd"); +static SYSCTL_NODE(_hw_usb, OID_AUTO, ukbd, CTLFLAG_RW, 0, "USB keyboard"); SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_TUN, &ukbd_debug, 0, "Debug level"); TUNABLE_INT("hw.usb.ukbd.debug", &ukbd_debug); SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, no_leds, CTLFLAG_RW | CTLFLAG_TUN, &ukbd_no_leds, 0, "Disables setting of keyboard leds"); TUNABLE_INT("hw.usb.ukbd.no_leds", &ukbd_no_leds); +SYSCTL_INT(_hw_usb_ukbd, OID_AUTO, pollrate, CTLFLAG_RW | CTLFLAG_TUN, + &ukbd_pollrate, 0, "Force this polling rate, 1-1000Hz"); +TUNABLE_INT("hw.usb.ukbd.pollrate", &ukbd_pollrate); #endif #define UKBD_EMULATE_ATSCANCODE 1 @@ -1165,13 +1169,15 @@ ukbd_attach(device_t dev) { struct ukbd_softc *sc = device_get_softc(dev); struct usb_attach_arg *uaa = device_get_ivars(dev); - int32_t unit = device_get_unit(dev); + int unit = device_get_unit(dev); keyboard_t *kbd = &sc->sc_kbd; void *hid_ptr = NULL; usb_error_t err; uint16_t n; uint16_t hid_len; - +#ifdef USB_DEBUG + int rate; +#endif UKBD_LOCK_ASSERT(); kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0); @@ -1272,6 +1278,19 @@ ukbd_attach(device_t dev) genkbd_diag(kbd, bootverbose); } +#ifdef USB_DEBUG + /* check for polling rate override */ + rate = ukbd_pollrate; + if (rate > 0) { + if (rate > 1000) + rate = 1; + else + rate = 1000 / rate; + + /* set new polling interval in ms */ + usbd_xfer_set_interval(sc->sc_xfer[UKBD_INTR_DT], rate); + } +#endif /* start the keyboard */ usbd_transfer_start(sc->sc_xfer[UKBD_INTR_DT]);