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

Commit 55978fa9 authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Jiri Kosina
Browse files

HID: multitouch: use the callback "report" instead of sequential events



Nexio 42" devices requires to rely on the HID field Contact
Count to compute the valid values. However, this field is
most of the time at the end of the report, meaning that we
need to get the all report parsed before processing it.

This patch does not introduce functional changes.

Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 6d85d037
Loading
Loading
Loading
Loading
+38 −6
Original line number Original line Diff line number Diff line
@@ -85,6 +85,7 @@ struct mt_device {
					   multitouch fields */
					   multitouch fields */
	unsigned last_field_index;	/* last field index of the report */
	unsigned last_field_index;	/* last field index of the report */
	unsigned last_slot_field;	/* the last field of a slot */
	unsigned last_slot_field;	/* the last field of a slot */
	unsigned mt_report_id;	/* the report ID of the multitouch device */
	__s8 inputmode;		/* InputMode HID feature, -1 if non-existent */
	__s8 inputmode;		/* InputMode HID feature, -1 if non-existent */
	__s8 inputmode_index;	/* InputMode HID feature index in the report */
	__s8 inputmode_index;	/* InputMode HID feature index in the report */
	__s8 maxcontact_report_id;	/* Maximum Contact Number HID feature,
	__s8 maxcontact_report_id;	/* Maximum Contact Number HID feature,
@@ -428,6 +429,7 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
			mt_store_field(usage, td, hi);
			mt_store_field(usage, td, hi);
			td->last_field_index = field->index;
			td->last_field_index = field->index;
			td->touches_by_report++;
			td->touches_by_report++;
			td->mt_report_id = field->report->id;
			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,
@@ -577,6 +579,16 @@ static void mt_sync_frame(struct mt_device *td, struct input_dev *input)


static int mt_event(struct hid_device *hid, struct hid_field *field,
static int mt_event(struct hid_device *hid, struct hid_field *field,
				struct hid_usage *usage, __s32 value)
				struct hid_usage *usage, __s32 value)
{
	/* we will handle the hidinput part later, now remains hiddev */
	if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
		hid->hiddev_hid_event(hid, field, usage, value);

	return 1;
}

static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field,
				struct hid_usage *usage, __s32 value)
{
{
	struct mt_device *td = hid_get_drvdata(hid);
	struct mt_device *td = hid_get_drvdata(hid);
	__s32 quirks = td->mtclass.quirks;
	__s32 quirks = td->mtclass.quirks;
@@ -635,8 +647,7 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
			break;
			break;


		default:
		default:
			/* fallback to the generic hidinput handling */
			return;
			return 0;
		}
		}


		if (usage->usage_index + 1 == field->report_count) {
		if (usage->usage_index + 1 == field->report_count) {
@@ -650,12 +661,32 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
		}
		}


	}
	}
}


	/* we have handled the hidinput part, now remains hiddev */
static void mt_report(struct hid_device *hid, struct hid_report *report)
	if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
{
		hid->hiddev_hid_event(hid, field, usage, value);
	struct mt_device *td = hid_get_drvdata(hid);
	struct hid_field *field;
	unsigned count;
	int r, n;


	return 1;
	if (report->id != td->mt_report_id)
		return;

	if (!(hid->claimed & HID_CLAIMED_INPUT))
		return;

	for (r = 0; r < report->maxfield; r++) {
		field = report->field[r];
		count = field->report_count;

		if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
			continue;

		for (n = 0; n < count; n++)
			mt_process_mt_event(hid, field, &field->usage[n],
					field->value[n]);
	}
}
}


static void mt_set_input_mode(struct hid_device *hdev)
static void mt_set_input_mode(struct hid_device *hdev)
@@ -1193,6 +1224,7 @@ static struct hid_driver mt_driver = {
	.feature_mapping = mt_feature_mapping,
	.feature_mapping = mt_feature_mapping,
	.usage_table = mt_grabbed_usages,
	.usage_table = mt_grabbed_usages,
	.event = mt_event,
	.event = mt_event,
	.report = mt_report,
#ifdef CONFIG_PM
#ifdef CONFIG_PM
	.reset_resume = mt_reset_resume,
	.reset_resume = mt_reset_resume,
	.resume = mt_resume,
	.resume = mt_resume,