Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Aug 2021 14:55:39 +0300
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        Mark Kane <mark@kane.mn>
Cc:        usb@freebsd.org, hps@selasky.org
Subject:   Re: eGalax USB touchscreen issues
Message-ID:  <858ac67e-14e2-730c-4a16-ca218e2c0bee@FreeBSD.org>
In-Reply-To: <5e8cd8d75deff98e8db3352001ce8432@kane.mn>
References:  <324d49ca-1c0e-659d-194d-ece4d5f7f5e2@FreeBSD.org> <0ae3fec48e2c351d2c006f4ba4932cd7@kane.mn> <166dd4d4-24cd-c24b-d75e-9a34fa734358@FreeBSD.org> <eccaff2a99153fb44ffa8df3c93d7eb6@kane.mn> <36983ce5-8358-5a04-2377-46067d3c3c79@FreeBSD.org> <c9e68dbb-5382-976d-7302-d816d8636153@FreeBSD.org> <59ba07a0ecbdac36746fe18ea5f0559f@kane.mn> <92c855bf-a73a-bae5-fcdc-c5a88008739b@FreeBSD.org> <5e8cd8d75deff98e8db3352001ce8432@kane.mn>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On 05.08.2021 04:34, Mark Kane wrote:
> On 2021-07-05 18:57, Vladimir Kondratyev wrote:
>> I am sorry for my long silence.
>>
>> Please try updated patch.
> 
> Thanks for the updated patch and apologies for my late reply as well.
> Events are now heard on input7 and X sees input7 but has a libinput error:
> 
> [    41.168] (II) config/udev: Adding input device eGalax Inc. USB
> TouchController TouchScreen (/dev/input/event7)
> [    41.168] (**) eGalax Inc. USB TouchController TouchScreen: Applying
> InputClass "evdev tablet catchall"
> [    41.168] (**) eGalax Inc. USB TouchController TouchScreen: Applying
> InputClass "libinput tablet catchall"
> [    41.168] (II) Using input driver 'libinput' for 'eGalax Inc. USB
> TouchController TouchScreen'
> [    41.168] (**) eGalax Inc. USB TouchController TouchScreen: always
> reports core events
> [    41.168] (**) Option "Device" "/dev/input/event7"
> [    41.168] (**) Option "_source" "server/udev"
> [    41.172] (II) event7  - eGalax Inc. USB TouchController TouchScreen:
> is tagged by udev as: Tablet
> [    41.214] (EE) event7  - eGalax Inc. USB TouchController TouchScreen:
> libinput bug: missing tablet capabilities: btn-stylus resolution.
> Ignoring this device.



> #     Event code 13 ((null))
> #     Event code 14 ((null))
> #     Event code 15 (SYN_MAX)
> #   Event type 1 (EV_KEY)
> #     Event code 320 (BTN_TOOL_PEN)
> #     Event code 330 (BTN_TOUCH)
> #   Event type 3 (EV_ABS)
> #     Event code 0 (ABS_X)
> #       Value        0
> #       Min          0
> #       Max       4095
> #       Fuzz         0
> #       Flat         0
> #       Resolution   0

Resolution is really missing. Your device report descriptor uses wrong
value for inches.
I looked at it one more time and found out that it conforms old MS's
multitouch specs and uses so called "serial packet reporting mode" which
is absent in modern specs.

I added support of it to hmt(4) driver. Patch is attached. Please test
it. It consist of 2 parts:

- sys/dev/hid/hid.c - workarounds resolution issue. It can be used with
     previous patch

- sys/dev/hid/hmt.c - adds support for serial mode to hmt. It should be
used with previous patch reverted. (but keep sys/dev/hid/hid.c)

-- 
WBR
Vladimir Kondratyev

[-- Attachment #2 --]
diff --git a/sys/dev/hid/hid.c b/sys/dev/hid/hid.c
index 699bfa4a8bb..fbbd998b5bf 100644
--- a/sys/dev/hid/hid.c
+++ b/sys/dev/hid/hid.c
@@ -856,6 +856,7 @@ hid_item_resolution(struct hid_item *hi)
 		divisor = 10;
 		break;
 	case HUM_INCH:
+	case HUM_INCH + 0x20:
 		multiplier = 10;
 		divisor = 254;
 		break;
diff --git a/sys/dev/hid/hmt.c b/sys/dev/hid/hmt.c
index b1111e0c77c..86e34b8a590 100644
--- a/sys/dev/hid/hmt.c
+++ b/sys/dev/hid/hmt.c
@@ -204,6 +204,8 @@ struct hmt_softc {
 	uint8_t			report_id;
 	uint32_t		max_button;
 	bool			has_int_button;
+	bool			has_cont_count;
+	bool			has_scan_time;
 	bool			is_clickpad;
 	bool			do_timestamps;
 #ifdef IICHID_SAMPLING
@@ -371,7 +373,8 @@ hmt_attach(device_t dev)
 		sc->cont_count_max = MAX_MT_SLOTS;
 	}
 
-	if (hid_test_quirk(hw, HQ_MT_TIMESTAMP) || hmt_timestamps)
+	if (sc->has_scan_time &&
+	    (hid_test_quirk(hw, HQ_MT_TIMESTAMP) || hmt_timestamps))
 		sc->do_timestamps = true;
 #ifdef IICHID_SAMPLING
 	if (hid_test_quirk(hw, HQ_IICHID_SAMPLING))
@@ -513,6 +516,12 @@ hmt_intr(void *context, void *buf, hid_size_t len)
 	}
 
 	/*
+	 * "In serial mode, each packet contains information that describes a
+	 * single physical contact point. Multiple contacts are streamed
+	 * serially. In this mode, devices report all contact information in a
+	 * series of packets. The device sends a separate packet for each
+	 * concurrent contact."
+	 *
 	 * "In Parallel mode, devices report all contact information in a
 	 * single packet. Each physical contact is represented by a logical
 	 * collection that is embedded in the top-level collection."
@@ -521,7 +530,10 @@ hmt_intr(void *context, void *buf, hid_size_t len)
 	 * report with contactid=0 but contactids are zero-based, find
 	 * contactcount first.
 	 */
-	cont_count = hid_get_udata(buf, len, &sc->cont_count_loc);
+	if (sc->has_cont_count)
+		cont_count = hid_get_udata(buf, len, &sc->cont_count_loc);
+	else
+		cont_count = 1;
 	/*
 	 * "In Hybrid mode, the number of contacts that can be reported in one
 	 * report is less than the maximum number of contacts that the device
@@ -753,7 +765,6 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 				sc->cont_count_loc = hi.loc;
 				break;
 			}
-			/* Scan time is required but clobbered by evdev */
 			if (hi.collevel == 1 && hi.usage ==
 			    HID_USAGE2(HUP_DIGITIZERS, HUD_SCAN_TIME)) {
 				scan_time_found = true;
@@ -804,7 +815,7 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 	hid_end_parse(hd);
 
 	/* Check for required HID Usages */
-	if (!cont_count_found || !scan_time_found || cont == 0)
+	if ((!cont_count_found && cont != 1) || cont == 0)
 		return (HMT_TYPE_UNSUPPORTED);
 	for (i = 0; i < HMT_N_USAGES; i++) {
 		if (hmt_hid_map[i].required && isclr(sc->caps, i))
@@ -841,7 +852,9 @@ hmt_hid_parse(struct hmt_softc *sc, const void *d_ptr, hid_size_t d_len,
 	sc->report_id = report_id;
 	sc->nconts_per_report = cont;
 	sc->has_int_button = has_int_button;
+	sc->has_cont_count = cont_count_found;
 	sc->cont_count_max = cont_count_max;
+	sc->has_scan_time = scan_time_found;
 
 	return (type);
 }
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?858ac67e-14e2-730c-4a16-ca218e2c0bee>