HID fixes
Subsystems (2)
cover HID fixes
Hi Jiri,
there is no real link between those 4 commit but the fact that I wrote them today ;)
2 patches should at least be scheduled for v4.19: 1/4 and 3/4 Both are stable fixes for mistakes I made in v4.18.
Patch 2 and 4 are just nice to have, so v4.20 should be fine.
Cheers,
Benjamin
Benjamin Tissoires (4):
HID: multitouch: fix Elan panels with 2 input modes declaration
HID: input: do not append a suffix if the name already has it
HID: core: fix grouping by application
HID: multitouch: simplify the application retrieval
drivers/hid/hid-input.c | 18 ++++++--- drivers/hid/hid-multitouch.c | 91 ++++++++++++++++++++++++-------------------- include/linux/hid.h | 1 + 3 files changed, 62 insertions(+), 48 deletions(-)
Signature · 1 line
2.14.3
PATCH 1/4 HID: multitouch: fix Elan panels with 2 input modes declaration
When implementing commit 7f81c8db5489 ("HID: multitouch: simplify the settings of the various features"), I wrongly removed a test that made sure we never try to set the second InputMode feature to something else than 0.
This broke badly some recent Elan panels that now forget to send the click button in some area of the touchpad.
Fixes 7f81c8db5489
--- drivers/hid/hid-multitouch.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/hid/hid-multitouch.c +14 -2
@@ -1375,7 +1375,8 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,struct hid_usage *usage, enum latency_mode latency, bool surface_switch, - bool button_switch) + bool button_switch, + bool *inputmode_found) { struct mt_device *td = hid_get_drvdata(hdev);struct mt_class *cls = &td->mtclass;
@@ -1387,6 +1388,14 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev,switch (usage->hid) {case HID_DG_INPUTMODE : +/* +* Some elan panels wrongly declare 2 input mode features, +* and silently ignore when we set the value in the second +* field. Skip the second feature and hope for the best. +*/ +if (*inputmode_found) +return false; +if (cls->quirks &MT_QUIRK_FORCE_GET_FEATURE ) { report_len =hid_report_len (report); buf =hid_alloc_report_buf (report,GFP_KERNEL );
@@ -1402,6 +1411,7 @@ static bool mt_need_to_apply_feature(struct hid_device *hdev, } field->value[index] = td->inputmode_value; + *inputmode_found = true;return true;case HID_DG_CONTACTMAX :
@@ -1439,6 +1449,7 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency,struct hid_usage *usage;int i, j;bool update_report; +bool inputmode_found = false; rep_enum = &hdev->report_enum[HID_FEATURE_REPORT ];list_for_each_entry (rep, &rep_enum->report_list, list) {
@@ -1457,7 +1468,8 @@ static void mt_set_modes(struct hid_device *hdev, enum latency_mode latency, usage, latency, surface_switch, - button_switch)) + button_switch, + &inputmode_found)) update_report = true; } }
Signature · 1 line
2.14.3
Jiri Kosina
maintainerRe: [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration
Quoted 9 lines · Benjamin Tissoires
When implementing commit
7f81c8db5489("HID: multitouch: simplify the settings of the various features"), I wrongly removed a test that made sure we never try to set the second InputMode feature to something else than 0.This broke badly some recent Elan panels that now forget to send the click button in some area of the touchpad.
Fixes
7f81c8db5489
Please make sure that the 'Fixes:' tag is always in proper format. There are tools depending on that :)
I'll fix that up manually.
Thanks!
Signature · 2 lines
Jiri Kosina SUSE Labs
Re: [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration
Quoted 8 lines · Jiri Kosina
Quoted 5 lines · Benjamin Tissoires
When implementing commit
7f81c8db5489("HID: multitouch: simplify the settings of the various features"), I wrongly removed a test that made sure we never try to set the second InputMode feature to something else than 0.
Quoted 7 lines
Quoted 4 lines
This broke badly some recent Elan panels that now forget to send the click button in some area of the touchpad.
Fixes
7f81c8db5489Please make sure that the 'Fixes:' tag is always in proper format. There are tools depending on that :)
Oops, thanks for fixing it. Lazy me :)
Cheers,
Benjamin
Quoted 9 lines
I'll fix that up manually.
Thanks!
--
Jiri Kosina
SUSE Labs
PATCH 2/4 HID: input: do not append a suffix if the name already has it
In reply to Benjamin TissoiresOr it creates some weird input names like:
"MI Dongle MI Wireless Mouse Mouse"
--- drivers/hid/hid-input.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/hid/hid-input.c +10 -4
@@ -1516,6 +1516,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid,struct hid_input *hidinput =kzalloc (sizeof (*hidinput),GFP_KERNEL );struct input_dev *input_dev =input_allocate_device ();const char *suffix =NULL ; +size_t suffix_len, name_len;if (!hidinput || !input_dev) goto fail;
@@ -1559,10 +1560,15 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid, }if (suffix) { - hidinput->name =kasprintf (GFP_KERNEL ,"%s %s" , - hid->name, suffix); -if (!hidinput->name) - goto fail; + name_len =strlen (hid->name); + suffix_len =strlen (suffix); +if ((name_len < suffix_len) || +strcmp (hid->name + name_len - suffix_len, suffix)) { + hidinput->name =kasprintf (GFP_KERNEL ,"%s %s" , + hid->name, suffix); +if (!hidinput->name) + goto fail; + } }input_set_drvdata (input_dev, hid);
Signature · 1 line
2.14.3
PATCH 3/4 HID: core: fix grouping by application
In reply to Benjamin Tissoirescommit f07b3c1da92d ("HID: generic: create one input report per application type") was effectively the same as MULTI_INPUT:hidinput->report was never set, so hidinput_match_application() always returned null.
Fix that by testing against the real application.
Note that this breaks some old eGalax touchscreens that expect MULTI_INPUT instead of HID_QUIRK_INPUT_PER_APP. Enable this quirk for backward compatibility on all non-Win8 touchscreens.
---
This replaces https://patchwork.kernel.org/patch/10583471/
A proper fix is better than a revert.
drivers/hid/hid-input.c | 4 ++-- drivers/hid/hid-multitouch.c | 3 +++ include/linux/hid.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/hid/hid-input.c +2 -2
@@ -1588,6 +1588,7 @@ static struct hid_input *hidinput_allocate(struct hid_device *hid, input_dev->dev.parent = &hid->dev; hidinput->input = input_dev; + hidinput->application = application;list_add_tail (&hidinput->list, &hid->inputs);INIT_LIST_HEAD (&hidinput->reports);
@@ -1683,8 +1684,7 @@ static struct hid_input *hidinput_match_application(struct hid_report *report)struct hid_input *hidinput;list_for_each_entry (hidinput, &hid->inputs, list) { -if (hidinput->report && - hidinput->report->application == report->application) +if (hidinput->application == report->application)return hidinput; }
drivers/hid/hid-multitouch.c +3 -0
@@ -1697,6 +1697,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)*/ hdev->quirks |=HID_QUIRK_INPUT_PER_APP ; +if (id->group !=HID_GROUP_MULTITOUCH_WIN_8 ) + hdev->quirks |=HID_QUIRK_MULTI_INPUT ; +timer_setup (&td->release_timer, mt_expired_timeout,0 ); ret =hid_parse (hdev);
include/linux/hid.h +1 -0
@@ -526,6 +526,7 @@ struct hid_input {const char *name;bool registered;struct list_head reports;/* the list of reports */ +unsigned int application;/* application usage for this input */ };enum hid_type {
Signature · 1 line
2.14.3
PATCH 4/4 HID: multitouch: simplify the application retrieval
In reply to Benjamin TissoiresNow that the application is simply stored in struct hid_input, we can overwrite it in mt_input_mapping() for the faulty egalax and have a simpler suffix processing in mt_input_configured()
--- drivers/hid/hid-multitouch.c | 72 ++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 40 deletions(-)
drivers/hid/hid-multitouch.c +32 -40
@@ -1319,6 +1319,13 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,return mt_touch_input_mapping (hdev, hi, field, usage, bit, max, application); +/* +* some egalax touchscreens have "application == DG_TOUCHSCREEN" +* for the stylus. Overwrite the hid_input application +*/ +if (field->physical ==HID_DG_STYLUS ) + hi->application =HID_DG_STYLUS ; +/* let hid-core decide for the others */ return 0 ; }
@@ -1507,14 +1514,12 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)struct mt_device *td =hid_get_drvdata (hdev);char *name;const char *suffix =NULL ; -unsigned int application =0 ;struct mt_report_data *rdata;struct mt_application *mt_application =NULL ;struct hid_report *report;int ret;list_for_each_entry (report, &hi->reports, hidinput_list) { - application = report->application; rdata =mt_find_report_data (td, report);if (!rdata) {hid_err (hdev,"failed to allocate data for report\n" );
@@ -1529,46 +1534,33 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)if (ret)return ret; } - -/* -* some egalax touchscreens have "application == DG_TOUCHSCREEN" -* for the stylus. Check this first, and then rely on -* the application field. -*/ -if (report->field[0 ]->physical ==HID_DG_STYLUS ) { - suffix ="Pen" ; -/* force BTN_STYLUS to allow tablet matching in udev */ -__set_bit (BTN_STYLUS , hi->input->keybit); - } } -if (!suffix) { -switch (application) { -case HID_GD_KEYBOARD : -case HID_GD_KEYPAD : -case HID_GD_MOUSE : -case HID_DG_TOUCHPAD : -case HID_GD_SYSTEM_CONTROL : -case HID_CP_CONSUMER_CONTROL : -case HID_GD_WIRELESS_RADIO_CTLS : -case HID_GD_SYSTEM_MULTIAXIS : -/* already handled by hid core */ -break ; -case HID_DG_TOUCHSCREEN : -/* we do not set suffix = "Touchscreen" */ - hi->input->name = hdev->name; -break ; -case HID_DG_STYLUS : -/* force BTN_STYLUS to allow tablet matching in udev */ -__set_bit (BTN_STYLUS , hi->input->keybit); -break ; -case HID_VD_ASUS_CUSTOM_MEDIA_KEYS : - suffix ="Custom Media Keys" ; -break ; -default : - suffix ="UNKNOWN" ; -break ; - } +switch (hi->application) { +case HID_GD_KEYBOARD : +case HID_GD_KEYPAD : +case HID_GD_MOUSE : +case HID_DG_TOUCHPAD : +case HID_GD_SYSTEM_CONTROL : +case HID_CP_CONSUMER_CONTROL : +case HID_GD_WIRELESS_RADIO_CTLS : +case HID_GD_SYSTEM_MULTIAXIS : +/* already handled by hid core */ +break ; +case HID_DG_TOUCHSCREEN : +/* we do not set suffix = "Touchscreen" */ + hi->input->name = hdev->name; +break ; +case HID_DG_STYLUS : +/* force BTN_STYLUS to allow tablet matching in udev */ +__set_bit (BTN_STYLUS , hi->input->keybit); +break ; +case HID_VD_ASUS_CUSTOM_MEDIA_KEYS : + suffix ="Custom Media Keys" ; +break ; +default : + suffix ="UNKNOWN" ; +break ; }if (suffix) {
Signature · 1 line
2.14.3
Jiri Kosina
maintainerQuoted 9 lines · Benjamin Tissoires
Hi Jiri,
there is no real link between those 4 commit but the fact that I wrote them today ;)
2 patches should at least be scheduled for v4.19: 1/4 and 3/4 Both are stable fixes for mistakes I made in v4.18.
Patch 2 and 4 are just nice to have, so v4.20 should be fine.
And I've queued the patches exactly like that. Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs