From owner-svn-src-all@freebsd.org Sat Aug 4 12:29:10 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2D14D10696DD; Sat, 4 Aug 2018 12:29:10 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C70977319C; Sat, 4 Aug 2018 12:29:09 +0000 (UTC) (envelope-from wulf@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 886E7773F; Sat, 4 Aug 2018 12:29:09 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w74CT9xj056366; Sat, 4 Aug 2018 12:29:09 GMT (envelope-from wulf@FreeBSD.org) Received: (from wulf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w74CT9Pa056365; Sat, 4 Aug 2018 12:29:09 GMT (envelope-from wulf@FreeBSD.org) Message-Id: <201808041229.w74CT9Pa056365@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wulf set sender to wulf@FreeBSD.org using -f From: Vladimir Kondratyev Date: Sat, 4 Aug 2018 12:29:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337288 - head/sys/dev/usb/input X-SVN-Group: head X-SVN-Commit-Author: wulf X-SVN-Commit-Paths: head/sys/dev/usb/input X-SVN-Commit-Revision: 337288 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.27 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: Sat, 04 Aug 2018 12:29:10 -0000 Author: wulf Date: Sat Aug 4 12:29:08 2018 New Revision: 337288 URL: https://svnweb.freebsd.org/changeset/base/337288 Log: wmt(4): Read Microsoft's "Touch Hardware Quality Assurance" certificate blob if present to enable some devices like WaveShare touchscreens. Unlike Windows we discard content of the blob. We try mimic Windows driver behaviour from the USB device point of view. Submitted by: glebius (initial version) Modified: head/sys/dev/usb/input/wmt.c Modified: head/sys/dev/usb/input/wmt.c ============================================================================== --- head/sys/dev/usb/input/wmt.c Sat Aug 4 12:24:37 2018 (r337287) +++ head/sys/dev/usb/input/wmt.c Sat Aug 4 12:29:08 2018 (r337288) @@ -206,6 +206,8 @@ struct wmt_softc struct hid_location cont_max_loc; uint32_t cont_max_rlen; uint8_t cont_max_rid; + uint32_t thqa_cert_rlen; + uint8_t thqa_cert_rid; uint8_t buf[WMT_BSIZE] __aligned(4); }; @@ -324,6 +326,13 @@ wmt_attach(device_t dev) DPRINTF("Feature report %hhu size invalid or too large: %u\n", sc->cont_max_rid, sc->cont_max_rlen); + /* Fetch THQA certificate to enable some devices like WaveShare */ + if (sc->thqa_cert_rlen > 0 && sc->thqa_cert_rlen <= WMT_BSIZE && + sc->thqa_cert_rid != sc->cont_max_rid) + (void)usbd_req_get_report(uaa->device, NULL, sc->buf, + sc->thqa_cert_rlen, uaa->info.bIfaceIndex, + UHID_FEATURE_REPORT, sc->thqa_cert_rid); + mtx_init(&sc->mtx, "wmt lock", NULL, MTX_DEF); err = usbd_transfer_setup(uaa->device, &uaa->info.bIfaceIndex, @@ -586,6 +595,7 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, int32_t cont_count_max = 0; uint8_t report_id = 0; uint8_t cont_max_rid = 0; + uint8_t thqa_cert_rid = 0; bool touch_coll = false; bool finger_coll = false; bool cont_count_found = false; @@ -593,6 +603,7 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, #define WMT_HI_ABSOLUTE(hi) \ (((hi).flags & (HIO_CONST|HIO_VARIABLE|HIO_RELATIVE)) == HIO_VARIABLE) +#define HUMS_THQA_CERT 0xC5 /* Parse features for maximum contact count */ hd = hid_start_parse(d_ptr, d_len, 1 << hid_feature); @@ -608,6 +619,11 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, touch_coll = false; break; case hid_feature: + if (hi.collevel == 1 && touch_coll && hi.usage == + HID_USAGE2(HUP_MICROSOFT, HUMS_THQA_CERT)) { + thqa_cert_rid = hi.report_ID; + break; + } if (hi.collevel == 1 && touch_coll && WMT_HI_ABSOLUTE(hi) && hi.usage == HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACT_MAX)) { @@ -763,11 +779,15 @@ wmt_hid_parse(struct wmt_softc *sc, const void *d_ptr, sc->cont_max_rlen = wmt_hid_report_size(d_ptr, d_len, hid_feature, cont_max_rid); + if (thqa_cert_rid > 0) + sc->thqa_cert_rlen = wmt_hid_report_size(d_ptr, d_len, + hid_feature, thqa_cert_rid); sc->report_id = report_id; sc->caps = caps; sc->nconts_max = cont; sc->cont_max_rid = cont_max_rid; + sc->thqa_cert_rid = thqa_cert_rid; /* Announce information about the touch device */ device_printf(sc->dev,