From owner-dev-commits-src-branches@freebsd.org Tue Sep 21 23:43:50 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 7908667EF4E; Tue, 21 Sep 2021 23:43:50 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HDdKy0BWpz4qT7; Tue, 21 Sep 2021 23:43:49 +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 29A9C5733; Tue, 21 Sep 2021 23:43:49 +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 18LNhn4M048116; Tue, 21 Sep 2021 23:43:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18LNhnaw048115; Tue, 21 Sep 2021 23:43:49 GMT (envelope-from git) Date: Tue, 21 Sep 2021 23:43:49 GMT Message-Id: <202109212343.18LNhnaw048115@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 470478ff012f - stable/13 - hmt(4): Add support for touchpads with no "button type" or 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 470478ff012fd8a2c083fead60574ec6c798376f Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Sep 2021 23:43:50 -0000 The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=470478ff012fd8a2c083fead60574ec6c798376f commit 470478ff012fd8a2c083fead60574ec6c798376f Author: Vladimir Kondratyev AuthorDate: 2021-09-02 19:33:51 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-09-21 23:41:40 +0000 hmt(4): Add support for touchpads with no "button type" or "maximum number of contacts" usages. Assume touchpad to be a clickpad if it has only internal button. Set number of contacts to 5 for touchpads and to 10 for touchscreens. Check for fetched report length to avoid reading of stalled data. Fixes Dell Precision 7550 laptop. Tested by: Shawn Webb PR: 257992 (cherry picked from commit 9d04336b615d16faa631da2824ee719683540276) --- sys/dev/hid/hmt.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c index cb7afe7290d0..dcf360bcffba 100644 --- a/sys/dev/hid/hmt.c +++ b/sys/dev/hid/hmt.c @@ -300,7 +300,7 @@ hmt_attach(device_t dev) const struct hid_device_info *hw = hid_get_device_info(dev); void *d_ptr; uint8_t *fbuf = NULL; - hid_size_t d_len, fsize; + hid_size_t d_len, fsize, rsize; uint32_t cont_count_max; int nbuttons, btn; size_t i; @@ -321,9 +321,10 @@ hmt_attach(device_t dev) /* Fetch and parse "Contact count maximum" feature report */ if (sc->cont_max_rlen > 1) { - err = hid_get_report(dev, fbuf, sc->cont_max_rlen, NULL, + err = hid_get_report(dev, fbuf, sc->cont_max_rlen, &rsize, HID_FEATURE_REPORT, sc->cont_max_rid); - if (err == 0) { + if (err == 0 && (rsize - 1) * 8 >= + sc->cont_max_loc.pos + sc->cont_max_loc.size) { cont_count_max = hid_get_udata(fbuf + 1, sc->cont_max_rlen - 1, &sc->cont_max_loc); /* @@ -334,23 +335,24 @@ hmt_attach(device_t dev) sc->cont_count_max = cont_count_max; } else DPRINTF("hid_get_report error=%d\n", err); - } else - DPRINTF("Feature report %hhu size invalid: %u\n", - sc->cont_max_rid, sc->cont_max_rlen); + } + if (sc->cont_count_max == 0) + sc->cont_count_max = sc->type == HMT_TYPE_TOUCHSCREEN ? 10 : 5; /* Fetch and parse "Button type" feature report */ if (sc->btn_type_rlen > 1 && sc->btn_type_rid != sc->cont_max_rid) { bzero(fbuf, fsize); - err = hid_get_report(dev, fbuf, sc->btn_type_rlen, NULL, + err = hid_get_report(dev, fbuf, sc->btn_type_rlen, &rsize, HID_FEATURE_REPORT, sc->btn_type_rid); - } - if (sc->btn_type_rlen > 1) { - if (err == 0) - sc->is_clickpad = hid_get_udata(fbuf + 1, - sc->btn_type_rlen - 1, &sc->btn_type_loc) == 0; - else + if (err != 0) DPRINTF("hid_get_report error=%d\n", err); } + if (sc->btn_type_rlen > 1 && err == 0 && (rsize - 1) * 8 >= + sc->btn_type_loc.pos + sc->btn_type_loc.size) + sc->is_clickpad = hid_get_udata(fbuf + 1, sc->btn_type_rlen - 1, + &sc->btn_type_loc) == 0; + else + sc->is_clickpad = sc->max_button == 0 && sc->has_int_button; /* Fetch THQA certificate to enable some devices like WaveShare */ if (sc->thqa_cert_rlen > 1 && sc->thqa_cert_rid != sc->cont_max_rid)