From nobody Mon Jul 05 23:57:04 2021 X-Original-To: usb@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7B7B47CA0E6 for ; Mon, 5 Jul 2021 23:57:31 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GJjKl35v5z4nNc; Mon, 5 Jul 2021 23:57:31 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Received: from [192.168.0.30] (unknown [176.120.233.129]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: wulf) by smtp.freebsd.org (Postfix) with ESMTPSA id CEE8910EA; Mon, 5 Jul 2021 23:57:30 +0000 (UTC) (envelope-from wulf@FreeBSD.org) Subject: Re: eGalax USB touchscreen issues To: Mark Kane Cc: usb@freebsd.org, hps@selasky.org References: <324d49ca-1c0e-659d-194d-ece4d5f7f5e2@FreeBSD.org> <0ae3fec48e2c351d2c006f4ba4932cd7@kane.mn> <166dd4d4-24cd-c24b-d75e-9a34fa734358@FreeBSD.org> <36983ce5-8358-5a04-2377-46067d3c3c79@FreeBSD.org> <59ba07a0ecbdac36746fe18ea5f0559f@kane.mn> From: Vladimir Kondratyev Message-ID: <92c855bf-a73a-bae5-fcdc-c5a88008739b@FreeBSD.org> Date: Tue, 6 Jul 2021 02:57:04 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 List-Id: FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-usb List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-usb@freebsd.org X-BeenThere: freebsd-usb@freebsd.org MIME-Version: 1.0 In-Reply-To: <59ba07a0ecbdac36746fe18ea5f0559f@kane.mn> Content-Type: multipart/mixed; boundary="------------408055B6BAAF669D2B49145A" Content-Language: en-US X-ThisMailContainsUnwantedMimeParts: N This is a multi-part message in MIME format. --------------408055B6BAAF669D2B49145A Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 04.06.2021 03:37, Mark Kane wrote: > On 2021-06-02 20:14, Vladimir Kondratyev wrote: >>> For now, report descriptor is not broken but it still does not match my >>> expectations. Could you post output of >>> >>> install sysutils/hid-tools >>> sudo kldload hidraw.ko >>> sudo hid-decode /dev/hidraw# >>> >>> Where # is number corresponding your touchscreen >> >> One more patch :-) with relaxed as compared to MS specs requirements to >> usages presence. > > Thanks for the updated patches, I think we're getting very close :). > With latest patch: > I am sorry for my long silence. Please try updated patch. -- WBR Vladimir Kondratyev --------------408055B6BAAF669D2B49145A Content-Type: text/x-patch; charset=UTF-8; name="hpen.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="hpen.patch" diff --git a/sys/dev/hid/hms.c b/sys/dev/hid/hms.c index 94267b3fcd5..0f60eec86a4 100644 --- a/sys/dev/hid/hms.c +++ b/sys/dev/hid/hms.c @@ -109,6 +109,7 @@ static const struct hidmap_item hms_map_wheel_rev[] = { /* A match on these entries will load hms */ static const struct hid_device_id hms_devs[] = { + { HID_TLC(HUP_GENERIC_DESKTOP, HUG_POINTER) }, { HID_TLC(HUP_GENERIC_DESKTOP, HUG_MOUSE) }, }; diff --git a/sys/dev/hid/hpen.c b/sys/dev/hid/hpen.c index 1d505e14089..d93c0cce9b5 100644 --- a/sys/dev/hid/hpen.c +++ b/sys/dev/hid/hpen.c @@ -72,7 +72,7 @@ static hidmap_cb_t hpen_final_pen_cb; HIDMAP_ABS_CB(HUP_DIGITIZERS, HUD_##usage, &cb) /* Generic map digitizer page map according to hut1_12v2.pdf */ -static const struct hidmap_item hpen_map_digi[] = { +static const struct hidmap_item hpen_map[] = { { HPEN_MAP_ABS_GD(X, ABS_X), .required = true }, { HPEN_MAP_ABS_GD(Y, ABS_Y), .required = true }, { HPEN_MAP_ABS( TIP_PRESSURE, ABS_PRESSURE) }, @@ -88,28 +88,21 @@ static const struct hidmap_item hpen_map_digi[] = { { HPEN_MAP_BUT( ERASER, BTN_TOUCH) }, { HPEN_MAP_BUT( TABLET_PICK, BTN_STYLUS2) }, { HPEN_MAP_BUT( SEC_BARREL_SWITCH,BTN_STYLUS2) }, - { HIDMAP_FINAL_CB( &hpen_final_digi_cb) }, }; -/* Microsoft-standardized pen support */ static const struct hidmap_item hpen_map_pen[] = { - { HPEN_MAP_ABS_GD(X, ABS_X), .required = true }, - { HPEN_MAP_ABS_GD(Y, ABS_Y), .required = true }, - { HPEN_MAP_ABS( TIP_PRESSURE, ABS_PRESSURE), .required = true }, - { HPEN_MAP_ABS( X_TILT, ABS_TILT_X) }, - { HPEN_MAP_ABS( Y_TILT, ABS_TILT_Y) }, - { HPEN_MAP_ABS_CB(BATTERY_STRENGTH, hpen_battery_strenght_cb) }, - { HPEN_MAP_BUT( TIP_SWITCH, BTN_TOUCH), .required = true }, - { HPEN_MAP_BUT( IN_RANGE, BTN_TOOL_PEN), .required = true }, - { HPEN_MAP_BUT( BARREL_SWITCH, BTN_STYLUS) }, - { HPEN_MAP_BUT( INVERT, BTN_TOOL_RUBBER), .required = true }, - { HPEN_MAP_BUT( ERASER, BTN_TOUCH), .required = true }, { HIDMAP_FINAL_CB( &hpen_final_pen_cb) }, }; +static const struct hidmap_item hpen_map_digi[] = { + { HIDMAP_FINAL_CB( &hpen_final_digi_cb) }, +}; + 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 @@ -138,24 +131,26 @@ static int hpen_final_digi_cb(HIDMAP_CB_ARGS) { struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); - - if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) + if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) { evdev_support_prop(evdev, INPUT_PROP_POINTER); + /* Do not execute callback at interrupt handler and detach */ + return (ENOSYS); + } - /* Do not execute callback at interrupt handler and detach */ - return (ENOSYS); + return (0); } static int hpen_final_pen_cb(HIDMAP_CB_ARGS) { struct evdev_dev *evdev = HIDMAP_CB_GET_EVDEV(); - - if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) + if (HIDMAP_CB_GET_STATE() == HIDMAP_CB_IS_ATTACHING) { evdev_support_prop(evdev, INPUT_PROP_DIRECT); + /* Do not execute callback at interrupt handler and detach */ + return (ENOSYS); + } - /* Do not execute callback at interrupt handler and detach */ - return (ENOSYS); + return (0); } static void @@ -186,7 +181,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) @@ -194,15 +189,31 @@ hpen_probe(device_t dev) hidmap_set_dev(hm, dev); + error = HIDMAP_ADD_MAP(hm, hpen_map, NULL); + if (error != 0) + return (error); + /* 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"; + break; + case HUD_TOUCHSCREEN: + error = HIDMAP_ADD_MAP(hm, hpen_map_pen, NULL); + suffix = "TouchScreen"; + break; + case HUD_DIGITIZER: + error = HIDMAP_ADD_MAP(hm, hpen_map_digi, NULL); + suffix = "Digitizer"; + break; + 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); } --------------408055B6BAAF669D2B49145A--