From owner-svn-src-all@freebsd.org Fri Feb 21 08:48:25 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34300256D1A; Fri, 21 Feb 2020 08:48:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48P4qY0MLvz3xkm; Fri, 21 Feb 2020 08:48:25 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DDCF282FD; Fri, 21 Feb 2020 08:48:24 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01L8mOS7019533; Fri, 21 Feb 2020 08:48:24 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01L8mO99019532; Fri, 21 Feb 2020 08:48:24 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202002210848.01L8mO99019532@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Fri, 21 Feb 2020 08:48:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r358214 - stable/11/sys/dev/usb/input X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/dev/usb/input X-SVN-Commit-Revision: 358214 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Feb 2020 08:48:25 -0000 Author: hselasky Date: Fri Feb 21 08:48:24 2020 New Revision: 358214 URL: https://svnweb.freebsd.org/changeset/base/358214 Log: MFC r304699: Fix key delay and repeat, part 1. kbdcontrol -r fast is documented to give a non-emulated atkbd's fastest rate of 250.34, but is misimplemented to request this as 0.0. ukbd supports many nonstandard rates, although it is currently too inaccurate by a factor of several hundred for non-huge nonstandard rates to be useful. It mapped 0.0 to 200.0. A repeat delay of 0 means a rate of infinity which is quite fast, but physical constraints limit this to a few MHz and the inaccuracies made it almost usable. Convert 0.0 to the documented 250.34. Also convert negative args and small args to the 250.34 minimal ones, like atkbd does. This is for KDSETREPEAT -- the 2 versions of the deprecated KDSETRAD have bounds checking. Keep not doing any bounds checking or conversions for upper limits since nonstandard large delays are useful for testing. The inaccuracies are dependent on HZ and the timeout implementation. With the old timeout implementation and HZ = 1000, 200.0 probably worked better to emulate 250.34 than 250.34 itself. HZ = 100 gives roundoff errors that accidentally reduce the inaaccuracies, and event timers reduce the inaccuracies even more, so 200.0 was giving more like itself (perhaps 215.15 on average but sometimes close to 10 msec repeat which is noticebly too fast). This commit makes 0.0 noticeably too slow, like 250.34 always was. Modified: stable/11/sys/dev/usb/input/ukbd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/input/ukbd.c ============================================================================== --- stable/11/sys/dev/usb/input/ukbd.c Fri Feb 21 08:41:44 2020 (r358213) +++ stable/11/sys/dev/usb/input/ukbd.c Fri Feb 21 08:48:24 2020 (r358214) @@ -1954,17 +1954,14 @@ ukbd_ioctl_locked(keyboard_t *kbd, u_long cmd, caddr_t if (!KBD_HAS_DEVICE(kbd)) { return (0); } - if (((int *)arg)[1] < 0) { - return (EINVAL); - } - if (((int *)arg)[0] < 0) { - return (EINVAL); - } - if (((int *)arg)[0] < 200) /* fastest possible value */ - kbd->kb_delay1 = 200; - else - kbd->kb_delay1 = ((int *)arg)[0]; - kbd->kb_delay2 = ((int *)arg)[1]; + /* + * Convert negative, zero and tiny args to the same limits + * as atkbd. We could support delays of 1 msec, but + * anything much shorter than the shortest atkbd value + * of 250.34 is almost unusable as well as incompatible. + */ + kbd->kb_delay1 = imax(((int *)arg)[0], 250); + kbd->kb_delay2 = imax(((int *)arg)[1], 34); #ifdef EVDEV_SUPPORT if (sc->sc_evdev != NULL) evdev_push_repeats(sc->sc_evdev, kbd);