git: 95add157e341 - main - hmt(4): Store Contact Count in separate variable.

Vladimir Kondratyev wulf at FreeBSD.org
Mon Aug 16 21:02:47 UTC 2021


The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=95add157e341f2c1ce47eaa19b3c5771705ea20d

commit 95add157e341f2c1ce47eaa19b3c5771705ea20d
Author:     Vladimir Kondratyev <wulf at FreeBSD.org>
AuthorDate: 2021-08-16 20:11:36 +0000
Commit:     Vladimir Kondratyev <wulf at FreeBSD.org>
CommitDate: 2021-08-16 20:11:36 +0000

    hmt(4): Store Contact Count in separate variable.
    
    No functional changes.
    
    MFC after:      1 week
---
 sys/dev/hid/hmt.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c
index fd50ea4de829..2eb02811a5a4 100644
--- a/sys/dev/hid/hmt.c
+++ b/sys/dev/hid/hmt.c
@@ -185,6 +185,7 @@ struct hmt_softc {
 	device_t		dev;
 	enum hmt_type		type;
 
+	int32_t			cont_count_max;
 	struct hid_absinfo	ai[HMT_N_USAGES];
 	struct hid_location	locs[MAX_MT_SLOTS][HMT_N_USAGES];
 	struct hid_location	cont_count_loc;
@@ -332,7 +333,7 @@ hmt_attach(device_t dev)
 			 * 'Contact Count Maximum'
 			 */
 			if (cont_count_max > 0)
-				sc->ai[HMT_SLOT].max = cont_count_max - 1;
+				sc->cont_count_max = cont_count_max;
 		} else
 			DPRINTF("hid_get_report error=%d\n", err);
 	} else
@@ -368,12 +369,19 @@ hmt_attach(device_t dev)
 	}
 
 	/* Cap contact count maximum to MAX_MT_SLOTS */
-	if (sc->ai[HMT_SLOT].max >= MAX_MT_SLOTS) {
+	if (sc->cont_count_max > MAX_MT_SLOTS) {
 		DPRINTF("Hardware reported %d contacts while only %d is "
-		    "supported\n", (int)sc->ai[HMT_SLOT].max+1, MAX_MT_SLOTS);
-		sc->ai[HMT_SLOT].max = MAX_MT_SLOTS - 1;
+		    "supported\n", sc->cont_count_max, MAX_MT_SLOTS);
+		sc->cont_count_max = MAX_MT_SLOTS;
 	}
 
+	/* Set number of MT protocol type B slots */
+	sc->ai[HMT_SLOT] = (struct hid_absinfo) {
+		.min = 0,
+		.max = sc->cont_count_max - 1,
+		.res = 0,
+	};
+
 	if (hid_test_quirk(hw, HQ_MT_TIMESTAMP) || hmt_timestamps)
 		sc->do_timestamps = true;
 #ifdef IICHID_SAMPLING
@@ -445,7 +453,7 @@ hmt_attach(device_t dev)
 	    sc->is_clickpad ? ", click-pad" : "");
 	device_printf(sc->dev,
 	    "%d contacts with [%s%s%s%s%s] properties. Report range [%d:%d] - [%d:%d]\n",
-	    (int)sc->ai[HMT_SLOT].max + 1,
+	    (int)sc->cont_count_max,
 	    isset(sc->caps, HMT_IN_RANGE) ? "R" : "",
 	    isset(sc->caps, HMT_CONFIDENCE) ? "C" : "",
 	    isset(sc->caps, HMT_WIDTH) ? "W" : "",
@@ -834,13 +842,6 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 	if (cont_count_max < 1)
 		cont_count_max = cont;
 
-	/* Set number of MT protocol type B slots */
-	sc->ai[HMT_SLOT] = (struct hid_absinfo) {
-		.min = 0,
-		.max = cont_count_max - 1,
-		.res = 0,
-	};
-
 	/* Report touch orientation if both width and height are supported */
 	if (isset(sc->caps, HMT_WIDTH) && isset(sc->caps, HMT_HEIGHT)) {
 		setbit(sc->caps, HMT_ORIENTATION);
@@ -857,6 +858,7 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 		    hid_feature, sc->thqa_cert_rid);
 
 	sc->report_id = report_id;
+	sc->cont_count_max = cont_count_max;
 	sc->nconts_per_report = cont;
 	sc->has_int_button = has_int_button;
 


More information about the dev-commits-src-all mailing list