Skip to contentSkip to conversation

HID: multitouch: Release all touch slots on reset_resume

PATCH Applied Dmitry Torokhov 3 participants 3 messages Mar 11, 2016 – Mar 14, 2016 HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: multitouch: Release all touch slots on reset_resume

From: Benson Leung <[email protected]>

When resetting a device (especially after power loss) it is unlikely that the firmware will keep the contact tracking data for the previous touches and will be able to reconcile it with the new contacts, so let's release all slots on reset resume as start anew.

---
 drivers/hid/hid-multitouch.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/hid/hid-multitouch.c +22 -0
index 6adb788..e24e33c 100644
@@ -1148,8 +1148,30 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 }
 
 #ifdef CONFIG_PM
+static void mt_release_contacts(struct hid_device *hid)
+{
+	struct hid_input *hidinput;
+
+	list_for_each_entry(hidinput, &hid->inputs, list) {
+		struct input_dev *input_dev = hidinput->input;
+		struct input_mt *mt = input_dev->mt;
+		int i;
+
+		if (mt) {
+			for (i = 0; i < mt->num_slots; i++) {
+				input_mt_slot(input_dev, i);
+				input_mt_report_slot_state(input_dev,
+							   MT_TOOL_FINGER,
+							   false);
+			}
+			input_sync(input_dev);
+		}
+	}
+}
+
 static int mt_reset_resume(struct hid_device *hdev)
 {
+	mt_release_contacts(hdev);
 	mt_set_maxcontacts(hdev);
 	mt_set_input_mode(hdev);
 	return 0;
Signature · 5 lines
2.7.0.rc3.207.g0ac5344


-- 
Dmitry
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dmitry Torokhov

From: Benson Leung <[email protected]>

When resetting a device (especially after power loss) it is unlikely that the firmware will keep the contact tracking data for the previous touches and will be able to reconcile it with the new contacts, so let's release all slots on reset resume as start anew.

---

Seems good to me:

Cheers,
Benjamin

Quoted 44 lines
 drivers/hid/hid-multitouch.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/hid/hid-multitouch.c +22 -0
index 6adb788..e24e33c 100644
@@ -1148,8 +1148,30 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 }
 
 #ifdef CONFIG_PM
+static void mt_release_contacts(struct hid_device *hid)
+{
+	struct hid_input *hidinput;
+
+	list_for_each_entry(hidinput, &hid->inputs, list) {
+		struct input_dev *input_dev = hidinput->input;
+		struct input_mt *mt = input_dev->mt;
+		int i;
+
+		if (mt) {
+			for (i = 0; i < mt->num_slots; i++) {
+				input_mt_slot(input_dev, i);
+				input_mt_report_slot_state(input_dev,
+							   MT_TOOL_FINGER,
+							   false);
+			}
+			input_sync(input_dev);
+		}
+	}
+}
+
 static int mt_reset_resume(struct hid_device *hdev)
 {
+	mt_release_contacts(hdev);
 	mt_set_maxcontacts(hdev);
 	mt_set_input_mode(hdev);
 	return 0;
Signature · 5 lines
2.7.0.rc3.207.g0ac5344


-- 
Dmitry
maintainer Applied
#2 lore raw
In reply to Dmitry Torokhov
Quoted 9 lines · Dmitry Torokhov

From: Benson Leung <[email protected]>

When resetting a device (especially after power loss) it is unlikely that the firmware will keep the contact tracking data for the previous touches and will be able to reconcile it with the new contacts, so let's release all slots on reset resume as start anew.

Applied to for-4.6/multitouch.

Signature · 2 lines
Jiri Kosina
SUSE Labs