Skip to contentSkip to conversation

HID: multitouch: enable multi-input as a quirk for some devices

PATCH In review Benjamin Tissoires 3 participants 5 messages May 26, 2020 – May 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: multitouch: enable multi-input as a quirk for some devices

Two touchpad/trackstick combos are currently not behaving properly. They define a mouse emulation collection, as per Win8 requirements, but also define a separate mouse collection for the trackstick.

The way the kernel currently treat the collections is that it merges both in one device. However, given that the first mouse collection already defines X,Y and left, right buttons, when mapping the events from the second mouse collection, hid-multitouch sees that these events are already mapped, and simply ignores them.

To be able to report events from the tracktick, add a new quirked class for it, and manually add the 2 devices we know about.

---
 drivers/hid/hid-multitouch.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/hid/hid-multitouch.c +26 -0
index 03c720b47306..39e4da7468e1 100644
@@ -69,6 +69,7 @@ MODULE_LICENSE("GPL");
 #define MT_QUIRK_ASUS_CUSTOM_UP		BIT(17)
 #define MT_QUIRK_WIN8_PTP_BUTTONS	BIT(18)
 #define MT_QUIRK_SEPARATE_APP_REPORT	BIT(19)
+#define MT_QUIRK_FORCE_MULTI_INPUT	BIT(20)
 
 #define MT_INPUTMODE_TOUCHSCREEN	0x02
 #define MT_INPUTMODE_TOUCHPAD		0x03
@@ -189,6 +190,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
 #define MT_CLS_WIN_8				0x0012
 #define MT_CLS_EXPORT_ALL_INPUTS		0x0013
 #define MT_CLS_WIN_8_DUAL			0x0014
+#define MT_CLS_WIN_8_FORCE_MULTI_INPUT		0x0015
 
 /* vendor specific classes */
 #define MT_CLS_3M				0x0101
@@ -279,6 +281,15 @@ static const struct mt_class mt_classes[] = {
 			MT_QUIRK_CONTACT_CNT_ACCURATE |
 			MT_QUIRK_WIN8_PTP_BUTTONS,
 		.export_all_inputs = true },
+	{ .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+		.quirks = MT_QUIRK_ALWAYS_VALID |
+			MT_QUIRK_IGNORE_DUPLICATES |
+			MT_QUIRK_HOVERING |
+			MT_QUIRK_CONTACT_CNT_ACCURATE |
+			MT_QUIRK_STICKY_FINGERS |
+			MT_QUIRK_WIN8_PTP_BUTTONS |
+			MT_QUIRK_FORCE_MULTI_INPUT,
+		.export_all_inputs = true },
 
 	/*
 	 * vendor specific classes
@@ -1714,6 +1725,11 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	if (id->group != HID_GROUP_MULTITOUCH_WIN_8)
 		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
 
+	if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) {
+		hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP;
+		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
+	}
+
 	timer_setup(&td->release_timer, mt_expired_timeout, 0);
 
 	ret = hid_parse(hdev);
@@ -1926,6 +1942,11 @@ static const struct hid_device_id mt_devices[] = {
 		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
 			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C002) },
 
+	/* Elan devices */
+	{ .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+		HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+			USB_VENDOR_ID_ELAN, 0x313a) },
+
 	/* Elitegroup panel */
 	{ .driver_data = MT_CLS_SERIAL,
 		MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP,
@@ -2056,6 +2077,11 @@ static const struct hid_device_id mt_devices[] = {
 		MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
 			USB_DEVICE_ID_MTP_STM)},
 
+	/* Synaptics devices */
+	{ .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+		HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+			USB_VENDOR_ID_SYNAPTICS, 0xce08) },
+
 	/* TopSeed panels */
 	{ .driver_data = MT_CLS_TOPSEED,
 		MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
Signature · 1 line
2.25.1
Tested-by on v1 1/1
#1 lore raw
Quoted 14 lines · Benjamin Tissoires

Two touchpad/trackstick combos are currently not behaving properly. They define a mouse emulation collection, as per Win8 requirements, but also define a separate mouse collection for the trackstick.

The way the kernel currently treat the collections is that it merges both in one device. However, given that the first mouse collection already defines X,Y and left, right buttons, when mapping the events from the second mouse collection, hid-multitouch sees that these events are already mapped, and simply ignores them.

Quoted 6 lines

To be able to report events from the tracktick, add a new quirked class for it, and manually add the 2 devices we know about.

Quoted 79 lines

---
drivers/hid/hid-multitouch.c | 26 ++++++++++++++++++++++++++

1 file changed, 26 insertions(+)
drivers/hid/hid-multitouch.c +26 -0
index 03c720b47306..39e4da7468e1 100644
@@ -69,6 +69,7 @@ MODULE_LICENSE("GPL");
 #define MT_QUIRK_ASUS_CUSTOM_UP		BIT(17)
 #define MT_QUIRK_WIN8_PTP_BUTTONS	BIT(18)
 #define MT_QUIRK_SEPARATE_APP_REPORT	BIT(19)
+#define MT_QUIRK_FORCE_MULTI_INPUT	BIT(20)
 
 #define MT_INPUTMODE_TOUCHSCREEN	0x02
 #define MT_INPUTMODE_TOUCHPAD		0x03
@@ -189,6 +190,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
 #define MT_CLS_WIN_8				0x0012
 #define MT_CLS_EXPORT_ALL_INPUTS		0x0013
 #define MT_CLS_WIN_8_DUAL			0x0014
+#define MT_CLS_WIN_8_FORCE_MULTI_INPUT		0x0015
 
 /* vendor specific classes */
 #define MT_CLS_3M				0x0101
@@ -279,6 +281,15 @@ static const struct mt_class mt_classes[] = {
 			MT_QUIRK_CONTACT_CNT_ACCURATE |
 			MT_QUIRK_WIN8_PTP_BUTTONS,
 		.export_all_inputs = true },
+	{ .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+		.quirks = MT_QUIRK_ALWAYS_VALID |
+			MT_QUIRK_IGNORE_DUPLICATES |
+			MT_QUIRK_HOVERING |
+			MT_QUIRK_CONTACT_CNT_ACCURATE |
+			MT_QUIRK_STICKY_FINGERS |
+			MT_QUIRK_WIN8_PTP_BUTTONS |
+			MT_QUIRK_FORCE_MULTI_INPUT,
+		.export_all_inputs = true },
 
 	/*
 	 * vendor specific classes
@@ -1714,6 +1725,11 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 	if (id->group != HID_GROUP_MULTITOUCH_WIN_8)
 		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
 
+	if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) {
+		hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP;
+		hdev->quirks |= HID_QUIRK_MULTI_INPUT;
+	}
+
 	timer_setup(&td->release_timer, mt_expired_timeout, 0);
 
 	ret = hid_parse(hdev);
@@ -1926,6 +1942,11 @@ static const struct hid_device_id mt_devices[] = {
 		MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
 			USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C002) },
 
+	/* Elan devices */
+	{ .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+		HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+			USB_VENDOR_ID_ELAN, 0x313a) },
+
 	/* Elitegroup panel */
 	{ .driver_data = MT_CLS_SERIAL,
 		MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP,
@@ -2056,6 +2077,11 @@ static const struct hid_device_id mt_devices[] = {
 		MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
 			USB_DEVICE_ID_MTP_STM)},
 
+	/* Synaptics devices */
+	{ .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+		HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+			USB_VENDOR_ID_SYNAPTICS, 0xce08) },
+
 	/* TopSeed panels */
 	{ .driver_data = MT_CLS_TOPSEED,
 		MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
Signature · 1 line
2.25.1
author Applied
#2 lore raw
Quoted 15 lines · Kai-Heng Feng
Quoted 15 lines · Benjamin Tissoires

Two touchpad/trackstick combos are currently not behaving properly. They define a mouse emulation collection, as per Win8 requirements, but also define a separate mouse collection for the trackstick.

The way the kernel currently treat the collections is that it merges both in one device. However, given that the first mouse collection already defines X,Y and left, right buttons, when mapping the events from the second mouse collection, hid-multitouch sees that these events are already mapped, and simply ignores them.

Quoted 8 lines
Quoted 6 lines

To be able to report events from the tracktick, add a new quirked class for it, and manually add the 2 devices we know about.

Thanks for the very fast testing :)

Pushed to for-5.8/multitouch given that we already are at 5.7-rc7, we might as well postpone it for one week.

Cheers,
Benjamin

Quoted 81 lines
Quoted 80 lines

---
drivers/hid/hid-multitouch.c | 26 ++++++++++++++++++++++++++

1 file changed, 26 insertions(+)
drivers/hid/hid-multitouch.c +26 -1
index 03c720b47306..39e4da7468e1 100644
@@ -69,6 +69,7 @@ MODULE_LICENSE("GPL");
 #define MT_QUIRK_ASUS_CUSTOM_UP               BIT(17)
 #define MT_QUIRK_WIN8_PTP_BUTTONS     BIT(18)
 #define MT_QUIRK_SEPARATE_APP_REPORT  BIT(19)
+#define MT_QUIRK_FORCE_MULTI_INPUT   BIT(20)
 
 #define MT_INPUTMODE_TOUCHSCREEN      0x02
 #define MT_INPUTMODE_TOUCHPAD         0x03
@@ -189,6 +190,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
 #define MT_CLS_WIN_8                          0x0012
 #define MT_CLS_EXPORT_ALL_INPUTS              0x0013
 #define MT_CLS_WIN_8_DUAL                     0x0014
+#define MT_CLS_WIN_8_FORCE_MULTI_INPUT               0x0015
 
 /* vendor specific classes */
 #define MT_CLS_3M                             0x0101
@@ -279,6 +281,15 @@ static const struct mt_class mt_classes[] = {
                      MT_QUIRK_CONTACT_CNT_ACCURATE |
                      MT_QUIRK_WIN8_PTP_BUTTONS,
              .export_all_inputs = true },
+     { .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+             .quirks = MT_QUIRK_ALWAYS_VALID |
+                     MT_QUIRK_IGNORE_DUPLICATES |
+                     MT_QUIRK_HOVERING |
+                     MT_QUIRK_CONTACT_CNT_ACCURATE |
+                     MT_QUIRK_STICKY_FINGERS |
+                     MT_QUIRK_WIN8_PTP_BUTTONS |
+                     MT_QUIRK_FORCE_MULTI_INPUT,
+             .export_all_inputs = true },
 
      /*
       * vendor specific classes
@@ -1714,6 +1725,11 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
      if (id->group != HID_GROUP_MULTITOUCH_WIN_8)
              hdev->quirks |= HID_QUIRK_MULTI_INPUT;
 
+     if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) {
+             hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP;
+             hdev->quirks |= HID_QUIRK_MULTI_INPUT;
+     }
+
      timer_setup(&td->release_timer, mt_expired_timeout, 0);
 
      ret = hid_parse(hdev);
@@ -1926,6 +1942,11 @@ static const struct hid_device_id mt_devices[] = {
              MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
                      USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C002) },
 
+     /* Elan devices */
+     { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+             HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+                     USB_VENDOR_ID_ELAN, 0x313a) },
+
      /* Elitegroup panel */
      { .driver_data = MT_CLS_SERIAL,
              MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP,
@@ -2056,6 +2077,11 @@ static const struct hid_device_id mt_devices[] = {
              MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
                      USB_DEVICE_ID_MTP_STM)},
 
+     /* Synaptics devices */
+     { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+             HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+                     USB_VENDOR_ID_SYNAPTICS, 0xce08) },
+
      /* TopSeed panels */
      { .driver_data = MT_CLS_TOPSEED,
              MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
--

2.25.1

#3 lore raw
Quoted 25 lines · Benjamin Tissoires
Quoted 22 lines · Kai-Heng Feng
Quoted 21 lines · Benjamin Tissoires

Two touchpad/trackstick combos are currently not behaving properly. They define a mouse emulation collection, as per Win8 requirements, but also define a separate mouse collection for the trackstick.

The way the kernel currently treat the collections is that it merges both in one device. However, given that the first mouse collection already defines X,Y and left, right buttons, when mapping the events from the second mouse collection, hid-multitouch sees that these events are already mapped, and simply ignores them.

To be able to report events from the tracktick, add a new quirked class for it, and manually add the 2 devices we know about.

Quoted 7 lines
Quoted 1 line

Thanks for the very fast testing :)

Pushed to for-5.8/multitouch given that we already are at 5.7-rc7, we might as well postpone it for one week.

Apologies for the inconvenience, I hadn't noticed my master branch was not up to date with origin. I forced push the branch to have a better history.

Cheers,
Benjamin

Quoted 84 lines

Cheers,
Benjamin

Quoted 81 lines
Quoted 80 lines

---
drivers/hid/hid-multitouch.c | 26 ++++++++++++++++++++++++++

1 file changed, 26 insertions(+)
drivers/hid/hid-multitouch.c +26 -1
index 03c720b47306..39e4da7468e1 100644
@@ -69,6 +69,7 @@ MODULE_LICENSE("GPL");
 #define MT_QUIRK_ASUS_CUSTOM_UP               BIT(17)
 #define MT_QUIRK_WIN8_PTP_BUTTONS     BIT(18)
 #define MT_QUIRK_SEPARATE_APP_REPORT  BIT(19)
+#define MT_QUIRK_FORCE_MULTI_INPUT   BIT(20)
 
 #define MT_INPUTMODE_TOUCHSCREEN      0x02
 #define MT_INPUTMODE_TOUCHPAD         0x03
@@ -189,6 +190,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
 #define MT_CLS_WIN_8                          0x0012
 #define MT_CLS_EXPORT_ALL_INPUTS              0x0013
 #define MT_CLS_WIN_8_DUAL                     0x0014
+#define MT_CLS_WIN_8_FORCE_MULTI_INPUT               0x0015
 
 /* vendor specific classes */
 #define MT_CLS_3M                             0x0101
@@ -279,6 +281,15 @@ static const struct mt_class mt_classes[] = {
                      MT_QUIRK_CONTACT_CNT_ACCURATE |
                      MT_QUIRK_WIN8_PTP_BUTTONS,
              .export_all_inputs = true },
+     { .name = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+             .quirks = MT_QUIRK_ALWAYS_VALID |
+                     MT_QUIRK_IGNORE_DUPLICATES |
+                     MT_QUIRK_HOVERING |
+                     MT_QUIRK_CONTACT_CNT_ACCURATE |
+                     MT_QUIRK_STICKY_FINGERS |
+                     MT_QUIRK_WIN8_PTP_BUTTONS |
+                     MT_QUIRK_FORCE_MULTI_INPUT,
+             .export_all_inputs = true },
 
      /*
       * vendor specific classes
@@ -1714,6 +1725,11 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
      if (id->group != HID_GROUP_MULTITOUCH_WIN_8)
              hdev->quirks |= HID_QUIRK_MULTI_INPUT;
 
+     if (mtclass->quirks & MT_QUIRK_FORCE_MULTI_INPUT) {
+             hdev->quirks &= ~HID_QUIRK_INPUT_PER_APP;
+             hdev->quirks |= HID_QUIRK_MULTI_INPUT;
+     }
+
      timer_setup(&td->release_timer, mt_expired_timeout, 0);
 
      ret = hid_parse(hdev);
@@ -1926,6 +1942,11 @@ static const struct hid_device_id mt_devices[] = {
              MT_USB_DEVICE(USB_VENDOR_ID_DWAV,
                      USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_C002) },
 
+     /* Elan devices */
+     { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+             HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+                     USB_VENDOR_ID_ELAN, 0x313a) },
+
      /* Elitegroup panel */
      { .driver_data = MT_CLS_SERIAL,
              MT_USB_DEVICE(USB_VENDOR_ID_ELITEGROUP,
@@ -2056,6 +2077,11 @@ static const struct hid_device_id mt_devices[] = {
              MT_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM,
                      USB_DEVICE_ID_MTP_STM)},
 
+     /* Synaptics devices */
+     { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+             HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+                     USB_VENDOR_ID_SYNAPTICS, 0xce08) },
+
      /* TopSeed panels */
      { .driver_data = MT_CLS_TOPSEED,
              MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
--

2.25.1

maintainer
#4 lore raw
In reply to Benjamin Tissoires

Hi

[This is an automated email]

This commit has been processed because it contains a -stable tag. The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.6.14, v5.4.42, v4.19.124, v4.14.181, v4.9.224, v4.4.224.

v5.6.14: Build OK!
v5.4.42: Build OK!
v4.19.124: Failed to apply! Possible dependencies:
69ecd44d68a7 ("HID: multitouch: add support for the Smart Tech panel") 7ffa13be4945 ("HID: multitouch: simplify the application retrieval")

v4.14.181: Failed to apply! Possible dependencies:
127e71bd462b ("HID: multitouch: Combine all left-button events in a frame") 29cc309d8bf1 ("HID: hid-multitouch: forward MSC_TIMESTAMP")
69ecd44d68a7 ("HID: multitouch: add support for the Smart Tech panel") 7f81c8db5489 ("HID: multitouch: simplify the settings of the various features") abb36fe691b2 ("HID: multitouch: fix calculation of last slot field in multi-touch reports") af8dc4d09490 ("HID: multitouch: Properly deal with Win8 PTP reports with 0 touches") d9c57a7090ba ("HID: multitouch: export a quirk for the button handling of touchpads") f146d1c4d7ea ("HID: multitouch: Store per collection multitouch data")

v4.9.224: Failed to apply! Possible dependencies:
0485b1ec280c ("HID: asus: ignore declared dummy usages")
1caccc2565a8 ("HID: asus: support Republic of Gamers special keys") 4f4001bc76fd ("HID: multitouch: fix rare Win 8 cases when the touch up event gets missing") 69ecd44d68a7 ("HID: multitouch: add support for the Smart Tech panel") 76dd1fbebbae ("HID: asus: Add support for T100 keyboard")
957b8dffa4e3 ("HID: multitouch: Support Asus T304UA media keys") 9ce12d8be12c ("HID: asus: Add i2c touchpad support")
a93913e1496d ("HID: asus: fix and generalize ambiguous preprocessor macros") af22a610bc38 ("HID: asus: support backlight on USB keyboards")
c8b1b3dd89ea ("HID: asus: Fix keyboard support")
d9c57a7090ba ("HID: multitouch: export a quirk for the button handling of touchpads") e9d0a26d3481 ("HID: multitouch: change for touch height/width")
f3287a995ac3 ("HID: multitouch: fix LG Melfas touchscreen")
fd91189654a3 ("HID: multitouch: use BIT macro")

v4.4.224: Failed to apply! Possible dependencies:
0485b1ec280c ("HID: asus: ignore declared dummy usages")
1caccc2565a8 ("HID: asus: support Republic of Gamers special keys") 69ecd44d68a7 ("HID: multitouch: add support for the Smart Tech panel") 76dd1fbebbae ("HID: asus: Add support for T100 keyboard")
957b8dffa4e3 ("HID: multitouch: Support Asus T304UA media keys") 9ce12d8be12c ("HID: asus: Add i2c touchpad support")
a93913e1496d ("HID: asus: fix and generalize ambiguous preprocessor macros") af22a610bc38 ("HID: asus: support backlight on USB keyboards") b94f7d5ddf1b ("HID: asus: add support for VivoBook E200HA") c8b1b3dd89ea ("HID: asus: Fix keyboard support")
d9c57a7090ba ("HID: multitouch: export a quirk for the button handling of touchpads") eeb01a57921a ("HID: Asus X205TA keyboard driver")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha