Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 May 2021 13:37:34 +0300
From:      Vladimir Kondratyev <wulf@FreeBSD.org>
To:        usb@freebsd.org
Subject:   eGalax USB touchscreen issues
Message-ID:  <324d49ca-1c0e-659d-194d-ece4d5f7f5e2@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------BD6D8EAA76512764C3AA9C0B
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

> Looking at the Linux sources again, it looks like this device should be 
> supported by generic HID.
>
> Wulf, do we support these usages in our kernel HID drivers?
>
> HID APPLICATION COLLECTION (Touch Screen) size(78)
>    HID REPORT: ID 2
>      INPUT:
>        POS:0 SIZE:1 COUNT:2 [VARIABLE]
>          USAGE Tip Switch
>          USAGE In Range
>        POS:2 SIZE:1 COUNT:6 [CONST]
>        POS:8 SIZE:16 COUNT:1 [VARIABLE]
>          USAGE X
>        POS:24 SIZE:16 COUNT:1 [VARIABLE]
>          USAGE Y

Yes, hpen(4) supports them.

It is required to apply some quirks though as TouchScreen usage page is handled with hmt(4) driver by default.
Try attached patch and don't forget to enable usbhid(4) to use it with addition of following lines to /boot/loader.conf:

hw.usb.usbhid.enable=1
usbhid_load="YES"

P.S. I am not subscribed to usb@, so keep me in CC.

-- 
WBR
Vladimir Kondratyev


--------------BD6D8EAA76512764C3AA9C0B
Content-Type: text/x-patch; charset=UTF-8;
 name="hpen.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="hpen.patch"

commit fefbdb3caa8eefcce7cdd8a73b61edacfbf82353
Author: Vladimir Kondratyev <wulf@FreeBSD.org>
Date:   Fri May 28 13:24:04 2021 +0300

    hpen(4): Add support for HID-compatible eGalax USB touchscreens

diff --git a/sys/dev/hid/hpen.c b/sys/dev/hid/hpen.c
index 1d505e14089..c00578aa6e5 100644
--- a/sys/dev/hid/hpen.c
+++ b/sys/dev/hid/hpen.c
@@ -110,6 +110,8 @@ static const struct hidmap_item hpen_map_pen[] = {
 static const struct hid_device_id hpen_devs[] = {
 	{ HID_TLC(HUP_DIGITIZERS, HUD_DIGITIZER) },
 	{ HID_TLC(HUP_DIGITIZERS, HUD_PEN) },
+	{ HID_TLC(HUP_DIGITIZERS, HUD_TOUCHSCREEN),
+	  HID_BVP(BUS_USB, USB_VENDOR_EGALAX, USB_PRODUCT_EGALAX_TPANEL) },
 };
 
 static int
@@ -186,7 +188,7 @@ hpen_probe(device_t dev)
 {
 	struct hidmap *hm = device_get_softc(dev);
 	int error;
-	bool is_pen;
+	const char *suffix;
 
 	error = HIDBUS_LOOKUP_DRIVER_INFO(dev, hpen_devs);
 	if (error != 0)
@@ -195,14 +197,23 @@ hpen_probe(device_t dev)
 	hidmap_set_dev(hm, dev);
 
 	/* Check if report descriptor belongs to a HID tablet device */
-	is_pen = hidbus_get_usage(dev) == HID_USAGE2(HUP_DIGITIZERS, HUD_PEN);
-	error = is_pen
-	    ? HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL)
-	    : HIDMAP_ADD_MAP(hm, hpen_map_digi, NULL);
+	switch (HID_GET_USAGE(hidbus_get_usage(dev))) {
+	case HUD_PEN:
+		error = HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL);
+		suffix = "Pen";
+	case HUD_TOUCHSCREEN:
+		error = HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL);
+		suffix = "TouchScreen";
+	case HUD_DIGITIZER:
+		error = HIDMAP_ADD_MAP(hm, hpen_map_digi, NULL);
+		suffix = "Digitizer";
+	default:
+		KASSERT(1 == 0, ("Unknown usage"));
+	}
 	if (error != 0)
 		return (error);
 
-	hidbus_set_desc(dev, is_pen ? "Pen" : "Digitizer");
+	hidbus_set_desc(dev, suffix);
 
 	return (BUS_PROBE_DEFAULT);
 }

--------------BD6D8EAA76512764C3AA9C0B--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?324d49ca-1c0e-659d-194d-ece4d5f7f5e2>