Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e87f22a authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina
Browse files

HID: multitouch: detect serial protocol



Microsoft's documentation about multitouch protocols tells that
if a device presents one touch per report, then it should be treated
as a serial protocol.

Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@enac.fr>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 8d179a9e
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -81,6 +81,9 @@ struct mt_device {
	__u8 num_received;	/* how many contacts we received */
	__u8 num_received;	/* how many contacts we received */
	__u8 num_expected;	/* expected last contact index */
	__u8 num_expected;	/* expected last contact index */
	__u8 maxcontacts;
	__u8 maxcontacts;
	__u8 touches_by_report;	/* how many touches are present in one report:
				* 1 means we should use a serial protocol
				* > 1 means hybrid (multitouch) protocol */
	bool curvalid;		/* is the current contact valid? */
	bool curvalid;		/* is the current contact valid? */
	struct mt_slot *slots;
	struct mt_slot *slots;
};
};
@@ -365,6 +368,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
			input_mt_init_slots(hi->input, td->maxcontacts);
			input_mt_init_slots(hi->input, td->maxcontacts);
			td->last_slot_field = usage->hid;
			td->last_slot_field = usage->hid;
			td->last_field_index = field->index;
			td->last_field_index = field->index;
			td->touches_by_report++;
			return 1;
			return 1;
		case HID_DG_WIDTH:
		case HID_DG_WIDTH:
			hid_map_usage(hi, usage, bit, max,
			hid_map_usage(hi, usage, bit, max,
@@ -670,6 +674,15 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
	if (ret)
	if (ret)
		goto fail;
		goto fail;


	if (!id && td->touches_by_report == 1) {
		/* the device has been sent by hid-generic */
		mtclass = &td->mtclass;
		mtclass->quirks |= MT_QUIRK_ALWAYS_VALID;
		mtclass->quirks &= ~MT_QUIRK_NOT_SEEN_MEANS_UP;
		mtclass->quirks &= ~MT_QUIRK_VALID_IS_INRANGE;
		mtclass->quirks &= ~MT_QUIRK_VALID_IS_CONFIDENCE;
	}

	td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
	td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
				GFP_KERNEL);
				GFP_KERNEL);
	if (!td->slots) {
	if (!td->slots) {