All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: kt.liao@emc.com.tw, Oliver Haessler <oliver@redhat.com>,
	Benjamin Berg <bberg@redhat.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: [PATCH 7/8] Input: elantech - detect new ICs and setup Host Notify for them
Date: Thu,  5 Apr 2018 15:25:36 +0200	[thread overview]
Message-ID: <20180405132537.3218-8-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <20180405132537.3218-1-benjamin.tissoires@redhat.com>

New ICs are using a different scheme for the alternate bus parameter.
Given that they are new and are only using either PS2 only or PS2 + SMBus
Host Notify, we force those new ICs to use the SMBus solution for enhanced
reporting.

This allows the touchpad found on the Lenovo T480s to report 5 fingers
every 8 ms, instead of having a limit of 2 every 8 ms.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/input/mouse/elantech.c | 11 +++++++----
 drivers/input/mouse/elantech.h | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index a61fbddd6b92..29f55e8e07e9 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1789,11 +1789,11 @@ static int elantech_setup_smbus(struct psmouse *psmouse,
 
 	if (elantech_smbus == ELANTECH_SMBUS_NOT_SET) {
 		/*
-		 * FIXME:
-		 * constraint the I2C capable devices by using FW version,
-		 * board version, or by using DMI matching
+		 * New ICs are enabled by default.
+		 * Old ICs are up to the user to decide.
 		 */
-		return -ENXIO;
+		if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version))
+			return -ENXIO;
 	}
 
 	psmouse_info(psmouse, "Trying to set up SMBus access\n");
@@ -1814,6 +1814,9 @@ static int elantech_setup_smbus(struct psmouse *psmouse,
 static bool elantech_use_host_notify(struct psmouse *psmouse,
 				     struct elantech_device_info *info)
 {
+	if (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version))
+		return true;
+
 	switch (info->bus) {
 	case ETP_BUS_PS2_ONLY:
 		/* expected case */
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index f9b1c485e8d9..119727085a60 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -115,6 +115,21 @@
 #define ETP_BUS_PS2_SMB_ALERT		3
 #define ETP_BUS_PS2_SMB_HST_NTFY	4
 
+/*
+ * New ICs are either using SMBus Host Notify or just plain PS2.
+ *
+ * ETP_FW_VERSION_QUERY is:
+ * Byte 1:
+ *  - bit 0..3: IC BODY
+ * Byte 2:
+ *  - bit 4: HiddenButton
+ *  - bit 5: PS2_SMBUS_NOTIFY
+ *  - bit 6: PS2CRCCheck
+ */
+#define ETP_NEW_IC_SMBUS_HOST_NOTIFY(fw_version)	\
+		((((fw_version) & 0x0f2000) == 0x0f2000) && \
+		 ((fw_version) & 0x0000ff) > 0)
+
 /*
  * The base position for one finger, v4 hardware
  */
-- 
2.14.3

  parent reply	other threads:[~2018-04-05 13:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05 13:25 [PATCH 0/8] Input: support for latest Lenovo thinkpads (series 80) Benjamin Tissoires
2018-04-05 13:25 ` [PATCH 1/8] Input: synaptics - add Lenovo 80 series ids to SMBus Benjamin Tissoires
2018-04-09  3:37   ` Sasha Levin
2018-04-09  9:02     ` Benjamin Tissoires
2018-04-05 13:25 ` [PATCH 2/8] input: elan_i2c_smbus - fix corrupted stack Benjamin Tissoires
2018-04-09  3:37   ` Sasha Levin
2018-04-09  9:01     ` Benjamin Tissoires
2018-04-05 13:25 ` [PATCH 3/8] Input: elan_i2c - add trackstick report Benjamin Tissoires
2018-04-05 23:46   ` Dmitry Torokhov
2018-04-06  6:51     ` Benjamin Tissoires
2018-04-05 13:25 ` [PATCH 4/8] Input: elantech - split device info into a separate structure Benjamin Tissoires
2018-04-06  7:33   ` [RFC PATCH] Input: elantech_query_info() can be static kbuild test robot
2018-04-06  7:33     ` kbuild test robot
2018-04-06  7:33   ` [PATCH 4/8] Input: elantech - split device info into a separate structure kbuild test robot
2018-04-06  7:33     ` kbuild test robot
2018-04-05 13:25 ` [PATCH 5/8] Input: elantech - query the resolution in query_info Benjamin Tissoires
2018-04-05 13:25 ` [PATCH 6/8] Input: elantech - add support for SMBus devices Benjamin Tissoires
2018-04-05 13:25 ` Benjamin Tissoires [this message]
2018-04-05 13:25 ` [PATCH 8/8] input: psmouse-smbus: allow to control psmouse_deactivate Benjamin Tissoires
2018-04-05 23:51 ` [PATCH 0/8] Input: support for latest Lenovo thinkpads (series 80) Dmitry Torokhov
2018-04-06  6:51   ` Benjamin Tissoires
2018-04-10  5:45     ` 廖崇榮
2018-04-10  7:35       ` Benjamin Tissoires
2018-04-11  4:32         ` 廖崇榮

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180405132537.3218-8-benjamin.tissoires@redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=bberg@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kt.liao@emc.com.tw \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.