From owner-dev-commits-src-main@freebsd.org Wed Dec 23 22:29:37 2020 Return-Path: Delivered-To: dev-commits-src-main@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 C9A584CD536; Wed, 23 Dec 2020 22:29:37 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4D1SYs5LnDz4ZTt; Wed, 23 Dec 2020 22:29:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A7FCB25CC2; Wed, 23 Dec 2020 22:29:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 0BNMTbuT083058; Wed, 23 Dec 2020 22:29:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 0BNMTbHL083057; Wed, 23 Dec 2020 22:29:37 GMT (envelope-from git) Date: Wed, 23 Dec 2020 22:29:37 GMT Message-Id: <202012232229.0BNMTbHL083057@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 18a3b77e226e - wmt(4): Refactor 'Contact Count Maximum' parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 18a3b77e226ef0f39f92579e0e261146d99a3bdb Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "Commit messages for the main branch of the src repository." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Dec 2020 22:29:37 -0000 The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=18a3b77e226ef0f39f92579e0e261146d99a3bdb commit 18a3b77e226ef0f39f92579e0e261146d99a3bdb Author: Vladimir Kondratyev AuthorDate: 2020-12-23 22:18:18 +0000 Commit: Vladimir Kondratyev CommitDate: 2020-12-23 22:26:06 +0000 wmt(4): Refactor 'Contact Count Maximum' parsing That is done mainly to reduce diff with upstream. Obtained from: sysutils/iichid --- sys/dev/usb/input/wmt.c | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/sys/dev/usb/input/wmt.c b/sys/dev/usb/input/wmt.c index 1377d8d1af40..927d019ea099 100644 --- a/sys/dev/usb/input/wmt.c +++ b/sys/dev/usb/input/wmt.c @@ -255,7 +255,6 @@ struct wmt_softc { if (USAGE_SUPPORTED((caps), (usage))) static enum wmt_type wmt_hid_parse(struct wmt_softc *, const void *, uint16_t); -static void wmt_cont_max_parse(struct wmt_softc *, const void *, uint16_t); static int wmt_set_input_mode(struct wmt_softc *, enum wmt_input_mode); static usb_callback_t wmt_intr_callback; @@ -340,6 +339,7 @@ wmt_attach(device_t dev) { struct usb_attach_arg *uaa = device_get_ivars(dev); struct wmt_softc *sc = device_get_softc(dev); + uint32_t cont_count_max; int nbuttons, btn; size_t i; int err; @@ -352,9 +352,16 @@ wmt_attach(device_t dev) err = usbd_req_get_report(uaa->device, NULL, sc->buf, sc->cont_max_rlen, uaa->info.bIfaceIndex, UHID_FEATURE_REPORT, sc->cont_max_rid); - if (err == USB_ERR_NORMAL_COMPLETION) - wmt_cont_max_parse(sc, sc->buf, sc->cont_max_rlen); - else + if (err == USB_ERR_NORMAL_COMPLETION) { + cont_count_max = hid_get_data_unsigned(sc->buf + 1, + sc->cont_max_rlen - 1, &sc->cont_max_loc); + /* + * Feature report is a primary source of + * 'Contact Count Maximum' + */ + if (cont_count_max > 0) + sc->ai[WMT_SLOT].max = cont_count_max - 1; + } else DPRINTF("usbd_req_get_report error=(%s)\n", usbd_errstr(err)); } else @@ -391,6 +398,13 @@ wmt_attach(device_t dev) DPRINTF("Failed to set input mode: %d\n", err); } + /* Cap contact count maximum to MAX_MT_SLOTS */ + if (sc->ai[WMT_SLOT].max >= MAX_MT_SLOTS) { + DPRINTF("Hardware reported %d contacts while only %d is " + "supported\n", (int)sc->ai[WMT_SLOT].max+1, MAX_MT_SLOTS); + sc->ai[WMT_SLOT].max = MAX_MT_SLOTS - 1; + } + if (/*usb_test_quirk(hw, UQ_MT_TIMESTAMP) ||*/ wmt_timestamps) sc->do_timestamps = true; @@ -972,10 +986,6 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, uint16_t d_len) if (cont_count_max < 1) cont_count_max = cont; - /* Cap contact count maximum to MAX_MT_SLOTS */ - if (cont_count_max > MAX_MT_SLOTS) - cont_count_max = MAX_MT_SLOTS; - /* Set number of MT protocol type B slots */ sc->ai[WMT_SLOT] = (struct wmt_absinfo) { .min = 0, @@ -1009,27 +1019,6 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, uint16_t d_len) return (type); } -static void -wmt_cont_max_parse(struct wmt_softc *sc, const void *r_ptr, uint16_t r_len) -{ - uint32_t cont_count_max; - - cont_count_max = hid_get_data_unsigned((const uint8_t *)r_ptr + 1, - r_len - 1, &sc->cont_max_loc); - if (cont_count_max > MAX_MT_SLOTS) { - DPRINTF("Hardware reported %d contacts while only %d is " - "supported\n", (int)cont_count_max, MAX_MT_SLOTS); - cont_count_max = MAX_MT_SLOTS; - } - /* Feature report is a primary source of 'Contact Count Maximum' */ - if (cont_count_max > 0 && - cont_count_max != sc->ai[WMT_SLOT].max + 1) { - sc->ai[WMT_SLOT].max = cont_count_max - 1; - device_printf(sc->dev, "%d feature report contacts", - cont_count_max); - } -} - static int wmt_set_input_mode(struct wmt_softc *sc, enum wmt_input_mode mode) {