git: 00b6fafcc1f1 - stable/13 - hmt(4): Do not require input report HID usages to be a member of TLC

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Mon, 27 Nov 2023 15:23:04 UTC
The branch stable/13 has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=00b6fafcc1f174c7819bf3ff0d19e2244267ed76

commit 00b6fafcc1f174c7819bf3ff0d19e2244267ed76
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2023-11-02 06:20:20 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2023-11-27 15:20:49 +0000

    hmt(4): Do not require input report HID usages to be a member of TLC
    
    Some touchpads places button usages (in HID report descriptor) in to
    the 2-nd level collection rather than in to the top level one. That
    confuses current code. Remove collection level check in HID report
    descriptor parser to fix device detection.
    
    Reported by:    Peter Much <pmc@citylink.dinoex.sub.org>
    PR:             267094
    
    (cherry picked from commit 1d46c8e5c2702c141c6be982b3ca44e74d1cb8f1)
---
 sys/dev/hid/hmt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c
index 5cc4f1167237..e7adf8d0e7d1 100644
--- a/sys/dev/hid/hmt.c
+++ b/sys/dev/hid/hmt.c
@@ -744,14 +744,13 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 			else
 				break;
 
-			if (hi.collevel == 1 && left_btn == 2 &&
+			if (left_btn == 2 &&
 			    hi.usage == HID_USAGE2(HUP_BUTTON, 1)) {
 				has_int_button = true;
 				sc->int_btn_loc = hi.loc;
 				break;
 			}
-			if (hi.collevel == 1 &&
-			    hi.usage >= HID_USAGE2(HUP_BUTTON, left_btn) &&
+			if (hi.usage >= HID_USAGE2(HUP_BUTTON, left_btn) &&
 			    hi.usage <= HID_USAGE2(HUP_BUTTON, HMT_BTN_MAX)) {
 				btn = (hi.usage & 0xFFFF) - left_btn;
 				setbit(sc->buttons, btn);
@@ -760,13 +759,13 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 					sc->max_button = btn + 1;
 				break;
 			}
-			if (hi.collevel == 1 && hi.usage ==
+			if (hi.usage ==
 			    HID_USAGE2(HUP_DIGITIZERS, HUD_CONTACTCOUNT)) {
 				cont_count_found = true;
 				sc->cont_count_loc = hi.loc;
 				break;
 			}
-			if (hi.collevel == 1 && hi.usage ==
+			if (hi.usage ==
 			    HID_USAGE2(HUP_DIGITIZERS, HUD_SCAN_TIME)) {
 				scan_time_found = true;
 				sc->scan_time_loc = hi.loc;