Re: [PATCH RESEND] HID: input: do not run GET_REPORT unless there's a Resolution Multiplier
flat view
From: Benjamin Tissoires <hidden>
Date: 2020-05-15 07:48:35
Hi Peter, On Fri, May 15, 2020 at 12:49 AM Peter Hutterer [off-list ref] wrote:
hid-multitouch currently runs GET_REPORT for Contact Max and again to retrieve the Win8 blob. If both are within the same report, the Resolution Multiplier code calls GET_FEATURE again and this time, possibly due to timing, it causes the ILITEK-TP device interpret the GET_FEATURE as an instruction to change the mode and effectively stop the device from functioning as expected. Notably: the device doesn't even have a Resolution Multiplier so it shouldn't be affected by any of this at all. Fix this by making sure we only execute GET_REPORT if there is a Resolution Multiplier in the respective report. Signed-off-by: Peter Hutterer <redacted> Tested-by: Wen He <redacted> --- Same patch as before, but this time with diff.noprefix set to false again. Too bad that setting messes up format-patch :( Apologies for the broken one.
Thanks for the quick respin. I was about to apply it, and then I realized that something was off (see inlined)
quoted hunk ↗ jump to hunk
drivers/hid/hid-input.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index dea9cc65bf80..a54824d451bf 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c@@ -1560,21 +1560,12 @@ static bool __hidinput_change_resolution_multipliers(struct hid_device *hid, { struct hid_usage *usage; bool update_needed = false; + bool get_report_completed = false; int i, j; if (report->maxfield == 0) return false; - /* - * If we have more than one feature within this report we - * need to fill in the bits from the others before we can - * overwrite the ones for the Resolution Multiplier. - */ - if (report->maxfield > 1) { - hid_hw_request(hid, report, HID_REQ_GET_REPORT); - hid_hw_wait(hid); - } - for (i = 0; i < report->maxfield; i++) { __s32 value = use_logical_max ? report->field[i]->logical_maximum :@@ -1593,6 +1584,17 @@ static bool __hidinput_change_resolution_multipliers(struct hid_device *hid, if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER) continue; + /* + * If we have more than one feature within this report we + * need to fill in the bits from the others before we can + * overwrite the ones for the Resolution Multiplier. + */ + if (!get_report_completed && report->maxfield > 1) { + hid_hw_request(hid, report, HID_REQ_GET_REPORT);
I think here we said that the reading of this particular feature was mandatory by Microsoft, but what if a device doesn't like it. I wonder if we should not guard this against HID_QUIRK_NO_INIT_REPORTS too, in the event we need to quirk a particular device. (BTW, I prefer this version compared to the first draft you sent me :-P ) Cheers, Benjamin
+ hid_hw_wait(hid);
+ get_report_completed = true;
+ }
+
report->field[i]->value[j] = value;
update_needed = true;
}
--
2.26.2