All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] HID fixes
@ 2018-09-04 13:31 Benjamin Tissoires
  2018-09-04 13:31 ` [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration Benjamin Tissoires
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2018-09-04 13:31 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov
  Cc: Benjamin Tissoires, linux-input, linux-kernel

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(-)

-- 
2.14.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration
  2018-09-04 13:31 [PATCH 0/4] HID fixes Benjamin Tissoires
@ 2018-09-04 13:31 ` Benjamin Tissoires
  2018-09-04 19:31   ` Jiri Kosina
  2018-09-04 13:31 ` [PATCH 2/4] HID: input: do not append a suffix if the name already has it Benjamin Tissoires
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Benjamin Tissoires @ 2018-09-04 13:31 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov
  Cc: Benjamin Tissoires, linux-input, linux-kernel, stable

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

Link: https://bugzilla.kernel.org/show_bug.cgi?id=200899

Cc: stable@vger.kernel.org # v4.18+
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/hid-multitouch.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 40fbb7c52723..88da991ef256 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -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;
 			}
 		}
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] HID: input: do not append a suffix if the name already has it
  2018-09-04 13:31 [PATCH 0/4] HID fixes Benjamin Tissoires
  2018-09-04 13:31 ` [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration Benjamin Tissoires
@ 2018-09-04 13:31 ` Benjamin Tissoires
  2018-09-04 13:31 ` [PATCH 3/4] HID: core: fix grouping by application Benjamin Tissoires
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2018-09-04 13:31 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov
  Cc: Benjamin Tissoires, linux-input, linux-kernel

Or it creates some weird input names like:
"MI Dongle MI Wireless Mouse Mouse"

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/hid-input.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index ac201817a2dd..1e9ba8f7a16b 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -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);
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] HID: core: fix grouping by application
  2018-09-04 13:31 [PATCH 0/4] HID fixes Benjamin Tissoires
  2018-09-04 13:31 ` [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration Benjamin Tissoires
  2018-09-04 13:31 ` [PATCH 2/4] HID: input: do not append a suffix if the name already has it Benjamin Tissoires
@ 2018-09-04 13:31 ` Benjamin Tissoires
  2018-09-04 13:31 ` [PATCH 4/4] HID: multitouch: simplify the application retrieval Benjamin Tissoires
  2018-09-04 19:33 ` [PATCH 0/4] HID fixes Jiri Kosina
  4 siblings, 0 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2018-09-04 13:31 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov
  Cc: Benjamin Tissoires, linux-input, linux-kernel, stable

commit 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.

link: https://bugzilla.kernel.org/show_bug.cgi?id=200847
link: https://bugzilla.kernel.org/show_bug.cgi?id=200849
link: https://bugs.archlinux.org/task/59699
link: https://github.com/NixOS/nixpkgs/issues/45165

Cc: stable@vger.kernel.org # v4.18+
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

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(-)

diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 1e9ba8f7a16b..907b08e50a9b 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -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;
 	}
 
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 88da991ef256..da954f3f4da7 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -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);
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 834e6461a690..d44a78362942 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -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 {
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] HID: multitouch: simplify the application retrieval
  2018-09-04 13:31 [PATCH 0/4] HID fixes Benjamin Tissoires
                   ` (2 preceding siblings ...)
  2018-09-04 13:31 ` [PATCH 3/4] HID: core: fix grouping by application Benjamin Tissoires
@ 2018-09-04 13:31 ` Benjamin Tissoires
  2018-09-04 19:33 ` [PATCH 0/4] HID fixes Jiri Kosina
  4 siblings, 0 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2018-09-04 13:31 UTC (permalink / raw)
  To: Jiri Kosina, Dmitry Torokhov
  Cc: Benjamin Tissoires, linux-input, linux-kernel

Now 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()

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/hid-multitouch.c | 72 ++++++++++++++++++++------------------------
 1 file changed, 32 insertions(+), 40 deletions(-)

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index da954f3f4da7..f7c6de2b6730 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -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) {
-- 
2.14.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration
  2018-09-04 13:31 ` [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration Benjamin Tissoires
@ 2018-09-04 19:31   ` Jiri Kosina
  2018-09-05  7:01     ` Benjamin Tissoires
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Kosina @ 2018-09-04 19:31 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Dmitry Torokhov, linux-input, linux-kernel, stable

On Tue, 4 Sep 2018, Benjamin Tissoires wrote:

> 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!

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] HID fixes
  2018-09-04 13:31 [PATCH 0/4] HID fixes Benjamin Tissoires
                   ` (3 preceding siblings ...)
  2018-09-04 13:31 ` [PATCH 4/4] HID: multitouch: simplify the application retrieval Benjamin Tissoires
@ 2018-09-04 19:33 ` Jiri Kosina
  4 siblings, 0 replies; 8+ messages in thread
From: Jiri Kosina @ 2018-09-04 19:33 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: Dmitry Torokhov, linux-input, linux-kernel

On Tue, 4 Sep 2018, Benjamin Tissoires wrote:

> 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,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration
  2018-09-04 19:31   ` Jiri Kosina
@ 2018-09-05  7:01     ` Benjamin Tissoires
  0 siblings, 0 replies; 8+ messages in thread
From: Benjamin Tissoires @ 2018-09-05  7:01 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Dmitry Torokhov, open list:HID CORE LAYER, lkml, 3.8+

On Tue, Sep 4, 2018 at 9:31 PM Jiri Kosina <jikos@kernel.org> wrote:
>
> On Tue, 4 Sep 2018, Benjamin Tissoires wrote:
>
> > 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 :)

Oops, thanks for fixing it. Lazy me :)

Cheers,
Benjamin

>
> I'll fix that up manually.
>
> Thanks!
>
> --
> Jiri Kosina
> SUSE Labs
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-09-05  7:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-04 13:31 [PATCH 0/4] HID fixes Benjamin Tissoires
2018-09-04 13:31 ` [PATCH 1/4] HID: multitouch: fix Elan panels with 2 input modes declaration Benjamin Tissoires
2018-09-04 19:31   ` Jiri Kosina
2018-09-05  7:01     ` Benjamin Tissoires
2018-09-04 13:31 ` [PATCH 2/4] HID: input: do not append a suffix if the name already has it Benjamin Tissoires
2018-09-04 13:31 ` [PATCH 3/4] HID: core: fix grouping by application Benjamin Tissoires
2018-09-04 13:31 ` [PATCH 4/4] HID: multitouch: simplify the application retrieval Benjamin Tissoires
2018-09-04 19:33 ` [PATCH 0/4] HID fixes Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.