linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens
@ 2020-12-11  6:53 Michał Mirosław
  2020-12-11  6:53 ` [PATCH RESEND v8 2/4] input: elants: support old touch report format Michał Mirosław
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11  6:53 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

This series cleans up the driver a bit and implements changes needed to
support EKTF3624-based touchscreen used in Asus TF300T, Google Nexus 7
and similar Tegra3-based tablets.

---
v2: extended with Dmitry's patches (replaced v1 patches 3 and 4)
v3: rebased for v5.7-rc1
v4: rebased onto v5.7-rc2+ (current Linus' master)
    update "remove unused axes" and "refactor
      elants_i2c_execute_command()" patches after review
    add David's patch converting DT binding to YAML
v5: rebased onto dtor/input/for-linus
v6: rebased onto newer dtor/input/for-linus
    remove yet unused constants from patch 1
    added a new drive-by cleanup (last patch)
v7: rebased onto current dtor/input/for-next
v8: rebased onto current dtor/input/for-linus
v8-resend: rebased again, no changes though
---

Dmitry Osipenko (1):
  input: elants: support 0x66 reply opcode for reporting touches

Michał Mirosław (3):
  input: elants: document some registers and values
  input: elants: support old touch report format
  input: elants: read touchscreen size for EKTF3624

 drivers/input/touchscreen/elants_i2c.c | 149 +++++++++++++++++++++----
 1 file changed, 127 insertions(+), 22 deletions(-)

-- 
2.20.1


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

* [PATCH RESEND v8 1/4] input: elants: document some registers and values
  2020-12-11  6:53 [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens Michał Mirosław
  2020-12-11  6:53 ` [PATCH RESEND v8 2/4] input: elants: support old touch report format Michał Mirosław
@ 2020-12-11  6:53 ` Michał Mirosław
  2020-12-11  7:11   ` Dmitry Torokhov
  2020-12-11  6:53 ` [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624 Michał Mirosław
  2020-12-11  6:53 ` [PATCH RESEND v8 4/4] input: elants: support 0x66 reply opcode for reporting touches Michał Mirosław
  3 siblings, 1 reply; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11  6:53 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

Add information found in downstream kernels, to make the code less
magic.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/input/touchscreen/elants_i2c.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 50c348297e38..d51cb910fba1 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -82,7 +82,7 @@
 
 #define HEADER_REPORT_10_FINGER	0x62
 
-/* Header (4 bytes) plus 3 fill 10-finger packets */
+/* Header (4 bytes) plus 3 full 10-finger packets */
 #define MAX_PACKET_SIZE		169
 
 #define BOOT_TIME_DELAY_MS	50
@@ -97,6 +97,10 @@
 #define E_INFO_PHY_SCAN		0xD7
 #define E_INFO_PHY_DRIVER	0xD8
 
+/* FW write command, 0x54 0x?? 0x0, 0x01 */
+#define E_POWER_STATE_SLEEP	0x50
+#define E_POWER_STATE_RESUME	0x58
+
 #define MAX_RETRIES		3
 #define MAX_FW_UPDATE_RETRIES	30
 
@@ -269,8 +273,8 @@ static int elants_i2c_calibrate(struct elants_data *ts)
 {
 	struct i2c_client *client = ts->client;
 	int ret, error;
-	static const u8 w_flashkey[] = { 0x54, 0xC0, 0xE1, 0x5A };
-	static const u8 rek[] = { 0x54, 0x29, 0x00, 0x01 };
+	static const u8 w_flashkey[] = { CMD_HEADER_WRITE, 0xC0, 0xE1, 0x5A };
+	static const u8 rek[] = { CMD_HEADER_WRITE, 0x29, 0x00, 0x01 };
 	static const u8 rek_resp[] = { CMD_HEADER_REK, 0x66, 0x66, 0x66 };
 
 	disable_irq(client->irq);
@@ -1388,7 +1392,9 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct elants_data *ts = i2c_get_clientdata(client);
-	const u8 set_sleep_cmd[] = { 0x54, 0x50, 0x00, 0x01 };
+	const u8 set_sleep_cmd[] = {
+		CMD_HEADER_WRITE, E_POWER_STATE_SLEEP, 0x00, 0x01
+	};
 	int retry_cnt;
 	int error;
 
@@ -1425,7 +1431,9 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct elants_data *ts = i2c_get_clientdata(client);
-	const u8 set_active_cmd[] = { 0x54, 0x58, 0x00, 0x01 };
+	const u8 set_active_cmd[] = {
+		CMD_HEADER_WRITE, E_POWER_STATE_RESUME, 0x00, 0x01
+	};
 	int retry_cnt;
 	int error;
 
-- 
2.20.1


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

* [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2020-12-11  6:53 [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens Michał Mirosław
@ 2020-12-11  6:53 ` Michał Mirosław
  2020-12-11  7:29   ` Dmitry Torokhov
  2020-12-11  6:53 ` [PATCH RESEND v8 1/4] input: elants: document some registers and values Michał Mirosław
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11  6:53 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

Support ELAN touchpad sensor with older firmware as found on eg. Asus
Transformer Pads.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/input/touchscreen/elants_i2c.c | 36 ++++++++++++++++++--------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index d51cb910fba1..f1bf3e000e96 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -69,6 +69,7 @@
 #define CMD_HEADER_REK		0x66
 
 /* FW position data */
+#define PACKET_SIZE_OLD		40
 #define PACKET_SIZE		55
 #define MAX_CONTACT_NUM		10
 #define FW_POS_HEADER		0
@@ -853,7 +854,8 @@ static int elants_i2c_fw_update(struct elants_data *ts)
  * Event reporting.
  */
 
-static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf)
+static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf,
+				size_t report_len)
 {
 	struct input_dev *input = ts->input;
 	unsigned int n_fingers;
@@ -866,7 +868,8 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf)
 			buf[FW_POS_STATE];
 
 	dev_dbg(&ts->client->dev,
-		"n_fingers: %u, state: %04x\n",  n_fingers, finger_state);
+		"n_fingers: %u, state: %04x, report_len: %zu\n",
+		n_fingers, finger_state, report_len);
 
 	/* Note: all fingers have the same tool type */
 	tool_type = buf[FW_POS_TOOL_TYPE] & BIT(0) ?
@@ -880,8 +883,16 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf)
 			pos = &buf[FW_POS_XY + i * 3];
 			x = (((u16)pos[0] & 0xf0) << 4) | pos[1];
 			y = (((u16)pos[0] & 0x0f) << 8) | pos[2];
-			p = buf[FW_POS_PRESSURE + i];
-			w = buf[FW_POS_WIDTH + i];
+			if (report_len == PACKET_SIZE_OLD) {
+				w = buf[FW_POS_WIDTH + i / 2];
+				w >>= 4 * (~i & 1);	// little-endian-nibbles
+				w |= w << 4;
+				w |= !w;
+				p = w;
+			} else {
+				p = buf[FW_POS_PRESSURE + i];
+				w = buf[FW_POS_WIDTH + i];
+			}
 
 			dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n",
 				i, x, y, p, w);
@@ -913,7 +924,8 @@ static u8 elants_i2c_calculate_checksum(u8 *buf)
 	return checksum;
 }
 
-static void elants_i2c_event(struct elants_data *ts, u8 *buf)
+static void elants_i2c_event(struct elants_data *ts, u8 *buf,
+			     size_t report_len)
 {
 	u8 checksum = elants_i2c_calculate_checksum(buf);
 
@@ -927,7 +939,7 @@ static void elants_i2c_event(struct elants_data *ts, u8 *buf)
 			 "%s: unknown packet type: %02x\n",
 			 __func__, buf[FW_POS_HEADER]);
 	else
-		elants_i2c_mt_event(ts, buf);
+		elants_i2c_mt_event(ts, buf, report_len);
 }
 
 static irqreturn_t elants_i2c_irq(int irq, void *_dev)
@@ -985,7 +997,8 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
 			break;
 
 		case QUEUE_HEADER_SINGLE:
-			elants_i2c_event(ts, &ts->buf[HEADER_SIZE]);
+			elants_i2c_event(ts, &ts->buf[HEADER_SIZE],
+					 ts->buf[FW_HDR_LENGTH]);
 			break;
 
 		case QUEUE_HEADER_NORMAL:
@@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
 			}
 
 			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
-			if (report_len != PACKET_SIZE) {
+			if (report_len != PACKET_SIZE &&
+			    report_len != PACKET_SIZE_OLD) {
 				dev_err(&client->dev,
-					"mismatching report length: %*ph\n",
+					"unsupported report length: %*ph\n",
 					HEADER_SIZE, ts->buf);
 				break;
 			}
 
 			for (i = 0; i < report_count; i++) {
 				u8 *buf = ts->buf + HEADER_SIZE +
-							i * PACKET_SIZE;
-				elants_i2c_event(ts, buf);
+					  i * report_len;
+				elants_i2c_event(ts, buf, report_len);
 			}
 			break;
 
-- 
2.20.1


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

* [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624
  2020-12-11  6:53 [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens Michał Mirosław
  2020-12-11  6:53 ` [PATCH RESEND v8 2/4] input: elants: support old touch report format Michał Mirosław
  2020-12-11  6:53 ` [PATCH RESEND v8 1/4] input: elants: document some registers and values Michał Mirosław
@ 2020-12-11  6:53 ` Michał Mirosław
  2020-12-11  7:22   ` Dmitry Torokhov
  2020-12-11  6:53 ` [PATCH RESEND v8 4/4] input: elants: support 0x66 reply opcode for reporting touches Michał Mirosław
  3 siblings, 1 reply; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11  6:53 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

EKTF3624 as present in Asus TF300T tablet has touchscreen size encoded
in different registers.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/input/touchscreen/elants_i2c.c | 84 ++++++++++++++++++++++++--
 1 file changed, 79 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index f1bf3e000e96..c24d8cdc4251 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -35,7 +35,7 @@
 #include <linux/input/mt.h>
 #include <linux/input/touchscreen.h>
 #include <linux/acpi.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/gpio/consumer.h>
 #include <linux/regulator/consumer.h>
 #include <asm/unaligned.h>
@@ -43,6 +43,10 @@
 /* Device, Driver information */
 #define DEVICE_NAME	"elants_i2c"
 
+/* Device IDs */
+#define EKTH3500	0
+#define EKTF3624	1
+
 /* Convert from rows or columns into resolution */
 #define ELAN_TS_RESOLUTION(n, m)   (((n) - 1) * (m))
 
@@ -94,6 +98,8 @@
 #define E_ELAN_INFO_REK		0xD0
 #define E_ELAN_INFO_TEST_VER	0xE0
 #define E_ELAN_INFO_FW_ID	0xF0
+#define E_INFO_X_RES		0x60
+#define E_INFO_Y_RES		0x63
 #define E_INFO_OSR		0xD6
 #define E_INFO_PHY_SCAN		0xD7
 #define E_INFO_PHY_DRIVER	0xD8
@@ -157,6 +163,7 @@ struct elants_data {
 
 	bool wake_irq_enabled;
 	bool keep_power_in_suspend;
+	u8 chip_id;
 
 	/* Must be last to be used for DMA operations */
 	u8 buf[MAX_PACKET_SIZE] ____cacheline_aligned;
@@ -434,7 +441,58 @@ static int elants_i2c_query_bc_version(struct elants_data *ts)
 	return 0;
 }
 
-static int elants_i2c_query_ts_info(struct elants_data *ts)
+static int elants_i2c_query_ts_info_ektf(struct elants_data *ts)
+{
+	struct i2c_client *client = ts->client;
+	int error;
+	u8 resp[4];
+	u16 phy_x, phy_y;
+	const u8 get_xres_cmd[] = {
+		CMD_HEADER_READ, E_INFO_X_RES, 0x00, 0x00
+	};
+	const u8 get_yres_cmd[] = {
+		CMD_HEADER_READ, E_INFO_Y_RES, 0x00, 0x00
+	};
+
+	/* Get X/Y size in mm */
+	error = elants_i2c_execute_command(client, get_xres_cmd,
+					   sizeof(get_xres_cmd),
+					   resp, sizeof(resp), 1,
+					   "get X size");
+	if (error)
+		return error;
+
+	phy_x = resp[2] | ((resp[3] & 0xF0) << 4);
+
+	error = elants_i2c_execute_command(client, get_yres_cmd,
+					   sizeof(get_yres_cmd),
+					   resp, sizeof(resp), 1,
+					   "get Y size");
+	if (error)
+		return error;
+
+	phy_y = resp[2] | ((resp[3] & 0xF0) << 4);
+
+	if (!phy_x || !phy_y) {
+		dev_warn(&client->dev,
+			 "invalid size data: %d x %d mm\n",
+			 phy_x, phy_y);
+		return 0;
+	}
+
+	dev_dbg(&client->dev, "phy_x=%d, phy_y=%d\n", phy_x, phy_y);
+
+	/* calculate resolution from size */
+	ts->x_max = 2240-1;
+	ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, phy_x);
+
+	ts->y_max = 1408-1;
+	ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, phy_y);
+
+	return 0;
+}
+
+static int elants_i2c_query_ts_info_ekth(struct elants_data *ts)
 {
 	struct i2c_client *client = ts->client;
 	int error;
@@ -588,8 +646,20 @@ static int elants_i2c_initialize(struct elants_data *ts)
 		error = elants_i2c_query_fw_version(ts);
 	if (!error)
 		error = elants_i2c_query_test_version(ts);
-	if (!error)
-		error = elants_i2c_query_ts_info(ts);
+
+	switch (ts->chip_id) {
+	case EKTH3500:
+		if (!error)
+			error = elants_i2c_query_ts_info_ekth(ts);
+		break;
+	case EKTF3624:
+		if (!error)
+			error = elants_i2c_query_ts_info_ektf(ts);
+		break;
+	default:
+		unreachable();
+		break;
+	}
 
 	if (error)
 		ts->iap_mode = ELAN_IAP_RECOVERY;
@@ -1266,6 +1336,9 @@ static int elants_i2c_probe(struct i2c_client *client,
 	ts->client = client;
 	i2c_set_clientdata(client, ts);
 
+	if (client->dev.of_node)
+		ts->chip_id = (uintptr_t)of_device_get_match_data(&client->dev);
+
 	ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
 	if (IS_ERR(ts->vcc33)) {
 		error = PTR_ERR(ts->vcc33);
@@ -1495,7 +1568,8 @@ MODULE_DEVICE_TABLE(acpi, elants_acpi_id);
 
 #ifdef CONFIG_OF
 static const struct of_device_id elants_of_match[] = {
-	{ .compatible = "elan,ekth3500" },
+	{ .compatible = "elan,ekth3500", .data = (void *)EKTH3500 },
+	{ .compatible = "elan,ektf3624", .data = (void *)EKTF3624 },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, elants_of_match);
-- 
2.20.1


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

* [PATCH RESEND v8 4/4] input: elants: support 0x66 reply opcode for reporting touches
  2020-12-11  6:53 [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens Michał Mirosław
                   ` (2 preceding siblings ...)
  2020-12-11  6:53 ` [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624 Michał Mirosław
@ 2020-12-11  6:53 ` Michał Mirosław
  2020-12-11  7:36   ` Dmitry Torokhov
  3 siblings, 1 reply; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11  6:53 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

From: Dmitry Osipenko <digetx@gmail.com>

eKTF3624 touchscreen firmware uses two variants of the reply opcodes for
reporting touch events: one is 0x63 (used by older firmware) and other is
0x66 (used by newer firmware). The 0x66 variant is equal to 0x63 of
eKTH3500, while 0x63 needs small adjustment of the touch pressure value.

Nexus 7 tablet device has eKTF3624 touchscreen and it uses 0x66 opcode for
reporting touch events, let's support it now. Other devices, eg. ASUS TF300T,
use 0x63.

Note: CMD_HEADER_REK is used for replying to calibration requests, it has
the same 0x66 opcode number which eKTF3624 uses for reporting touches.
The calibration replies are handled separately from the the rest of the
commands in the driver by entering into ELAN_WAIT_RECALIBRATION state
and thus this change shouldn't change the old behavior.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/input/touchscreen/elants_i2c.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index c24d8cdc4251..1cbda6f20d07 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -61,6 +61,15 @@
 #define QUEUE_HEADER_NORMAL	0X63
 #define QUEUE_HEADER_WAIT	0x64
 
+/*
+ * Depending on firmware version, eKTF3624 touchscreens may utilize one of
+ * these opcodes for the touch events: 0x63 and 0x66. The 0x63 is used by
+ * older firmware version and differs from 0x66 such that touch pressure
+ * value needs to be adjusted. The 0x66 opcode of newer firmware is equal
+ * to 0x63 of eKTH3500.
+ */
+#define QUEUE_HEADER_NORMAL2	0x66
+
 /* Command header definition */
 #define CMD_HEADER_WRITE	0x54
 #define CMD_HEADER_READ		0x53
@@ -1052,7 +1061,6 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
 		switch (ts->buf[FW_HDR_TYPE]) {
 		case CMD_HEADER_HELLO:
 		case CMD_HEADER_RESP:
-		case CMD_HEADER_REK:
 			break;
 
 		case QUEUE_HEADER_WAIT:
@@ -1072,6 +1080,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
 			break;
 
 		case QUEUE_HEADER_NORMAL:
+		case QUEUE_HEADER_NORMAL2:
 			report_count = ts->buf[FW_HDR_COUNT];
 			if (report_count == 0 || report_count > 3) {
 				dev_err(&client->dev,
-- 
2.20.1


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

* Re: [PATCH RESEND v8 1/4] input: elants: document some registers and values
  2020-12-11  6:53 ` [PATCH RESEND v8 1/4] input: elants: document some registers and values Michał Mirosław
@ 2020-12-11  7:11   ` Dmitry Torokhov
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Torokhov @ 2020-12-11  7:11 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> Add information found in downstream kernels, to make the code less
> magic.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> Tested-by: Dmitry Osipenko <digetx@gmail.com>

Applied, thank you.

-- 
Dmitry

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

* Re: [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624
  2020-12-11  6:53 ` [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624 Michał Mirosław
@ 2020-12-11  7:22   ` Dmitry Torokhov
  2020-12-11 16:38     ` Michał Mirosław
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Torokhov @ 2020-12-11  7:22 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

Hi Michał,

On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> +
> +	if (!phy_x || !phy_y) {
> +		dev_warn(&client->dev,
> +			 "invalid size data: %d x %d mm\n",
> +			 phy_x, phy_y);
> +		return 0;

Given we are not treating this as hard error mind dropping this "return"
and making the below an "else" branch?

> +	}
> +
> +	dev_dbg(&client->dev, "phy_x=%d, phy_y=%d\n", phy_x, phy_y);
> +
> +	/* calculate resolution from size */
> +	ts->x_max = 2240-1;
> +	ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, phy_x);
> +
> +	ts->y_max = 1408-1;
> +	ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, phy_y);
> +
> +	return 0;
> +}
> +

>  
> +	if (client->dev.of_node)
> +		ts->chip_id = (uintptr_t)of_device_get_match_data(&client->dev);

Why don't we add EKTH3500 tag to the ACPI entry and make this
unconditional device_get_match_data()?

> +
>  	ts->vcc33 = devm_regulator_get(&client->dev, "vcc33");
>  	if (IS_ERR(ts->vcc33)) {
>  		error = PTR_ERR(ts->vcc33);
> @@ -1495,7 +1568,8 @@ MODULE_DEVICE_TABLE(acpi, elants_acpi_id);
>  
>  #ifdef CONFIG_OF
>  static const struct of_device_id elants_of_match[] = {
> -	{ .compatible = "elan,ekth3500" },
> +	{ .compatible = "elan,ekth3500", .data = (void *)EKTH3500 },
> +	{ .compatible = "elan,ektf3624", .data = (void *)EKTF3624 },
>  	{ /* sentinel */ }
>  };
>  MODULE_DEVICE_TABLE(of, elants_of_match);
> -- 
> 2.20.1
> 

Thanks.

-- 
Dmitry

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2020-12-11  6:53 ` [PATCH RESEND v8 2/4] input: elants: support old touch report format Michał Mirosław
@ 2020-12-11  7:29   ` Dmitry Torokhov
  2020-12-11 16:09     ` Michał Mirosław
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Torokhov @ 2020-12-11  7:29 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

Hi Michał,
On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
>  			}
>  
>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
> -			if (report_len != PACKET_SIZE) {
> +			if (report_len != PACKET_SIZE &&
> +			    report_len != PACKET_SIZE_OLD) {
>  				dev_err(&client->dev,
> -					"mismatching report length: %*ph\n",
> +					"unsupported report length: %*ph\n",
>  					HEADER_SIZE, ts->buf);

Do I understand this correctly that the old packets are only observed on
EKTF3624? If so can we expand the check so that we only accept packets
with "old" size when we know we are dealing with this device?

Thanks.

-- 
Dmitry

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

* Re: [PATCH RESEND v8 4/4] input: elants: support 0x66 reply opcode for reporting touches
  2020-12-11  6:53 ` [PATCH RESEND v8 4/4] input: elants: support 0x66 reply opcode for reporting touches Michał Mirosław
@ 2020-12-11  7:36   ` Dmitry Torokhov
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Torokhov @ 2020-12-11  7:36 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

On Fri, Dec 11, 2020 at 07:53:57AM +0100, Michał Mirosław wrote:
> From: Dmitry Osipenko <digetx@gmail.com>
> 
> eKTF3624 touchscreen firmware uses two variants of the reply opcodes for
> reporting touch events: one is 0x63 (used by older firmware) and other is
> 0x66 (used by newer firmware). The 0x66 variant is equal to 0x63 of
> eKTH3500, while 0x63 needs small adjustment of the touch pressure value.
> 
> Nexus 7 tablet device has eKTF3624 touchscreen and it uses 0x66 opcode for
> reporting touch events, let's support it now. Other devices, eg. ASUS TF300T,
> use 0x63.
> 
> Note: CMD_HEADER_REK is used for replying to calibration requests, it has
> the same 0x66 opcode number which eKTF3624 uses for reporting touches.
> The calibration replies are handled separately from the the rest of the
> commands in the driver by entering into ELAN_WAIT_RECALIBRATION state
> and thus this change shouldn't change the old behavior.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> Tested-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/input/touchscreen/elants_i2c.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index c24d8cdc4251..1cbda6f20d07 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -61,6 +61,15 @@
>  #define QUEUE_HEADER_NORMAL	0X63
>  #define QUEUE_HEADER_WAIT	0x64
>  
> +/*
> + * Depending on firmware version, eKTF3624 touchscreens may utilize one of
> + * these opcodes for the touch events: 0x63 and 0x66. The 0x63 is used by
> + * older firmware version and differs from 0x66 such that touch pressure
> + * value needs to be adjusted. The 0x66 opcode of newer firmware is equal
> + * to 0x63 of eKTH3500.
> + */
> +#define QUEUE_HEADER_NORMAL2	0x66
> +
>  /* Command header definition */
>  #define CMD_HEADER_WRITE	0x54
>  #define CMD_HEADER_READ		0x53
> @@ -1052,7 +1061,6 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
>  		switch (ts->buf[FW_HDR_TYPE]) {
>  		case CMD_HEADER_HELLO:
>  		case CMD_HEADER_RESP:
> -		case CMD_HEADER_REK:
>  			break;
>  
>  		case QUEUE_HEADER_WAIT:
> @@ -1072,6 +1080,7 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
>  			break;
>  
>  		case QUEUE_HEADER_NORMAL:
> +		case QUEUE_HEADER_NORMAL2:

I think here I would also prefer that we only accepted this for the
devices where we expect to see such packets:

		case CMD_HEADER_REK:
			/* comment from above why this is done ... */
			if (ts->chip_id != EKTF3624)
				break;
			fallthrough;
		case QUEUE_HEADER_NORMAL2:

...

Given this comments I wonder if it would not make sense to combine the 3
patches into one adding support for EKTF3624...


>  			report_count = ts->buf[FW_HDR_COUNT];
>  			if (report_count == 0 || report_count > 3) {
>  				dev_err(&client->dev,
> -- 
> 2.20.1
> 

Thanks.

-- 
Dmitry

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2020-12-11  7:29   ` Dmitry Torokhov
@ 2020-12-11 16:09     ` Michał Mirosław
  2020-12-11 16:39       ` Dmitry Osipenko
  0 siblings, 1 reply; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11 16:09 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
> Hi Michał,
> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> > @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
> >  			}
> >  
> >  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
> > -			if (report_len != PACKET_SIZE) {
> > +			if (report_len != PACKET_SIZE &&
> > +			    report_len != PACKET_SIZE_OLD) {
> >  				dev_err(&client->dev,
> > -					"mismatching report length: %*ph\n",
> > +					"unsupported report length: %*ph\n",
> >  					HEADER_SIZE, ts->buf);
> Do I understand this correctly that the old packets are only observed on
> EKTF3624? If so can we expand the check so that we only accept packets
> with "old" size when we know we are dealing with this device?

We only have EKTF3624 and can't be sure there are no other chips needing this.

Best Regards
Michał Mirosław

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

* Re: [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624
  2020-12-11  7:22   ` Dmitry Torokhov
@ 2020-12-11 16:38     ` Michał Mirosław
  0 siblings, 0 replies; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11 16:38 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

On Thu, Dec 10, 2020 at 11:22:09PM -0800, Dmitry Torokhov wrote:
> Hi Michał,
> 
> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> > +
> > +	if (!phy_x || !phy_y) {
> > +		dev_warn(&client->dev,
> > +			 "invalid size data: %d x %d mm\n",
> > +			 phy_x, phy_y);
> > +		return 0;
> 
> Given we are not treating this as hard error mind dropping this "return"
> and making the below an "else" branch?

It is an error, still, and saves a bit of indentation in the following
normal-path code. But I see that there is already a similar code with
an 'else' branch.

Best Regards,
Michał Mirosław

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2020-12-11 16:09     ` Michał Mirosław
@ 2020-12-11 16:39       ` Dmitry Osipenko
  2020-12-11 17:04         ` Michał Mirosław
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Osipenko @ 2020-12-11 16:39 UTC (permalink / raw)
  To: Michał Mirosław, Dmitry Torokhov
  Cc: Johnny Chuang, linux-input, linux-kernel

11.12.2020 19:09, Michał Mirosław пишет:
> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
>> Hi Michał,
>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
>>>  			}
>>>  
>>>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
>>> -			if (report_len != PACKET_SIZE) {
>>> +			if (report_len != PACKET_SIZE &&
>>> +			    report_len != PACKET_SIZE_OLD) {
>>>  				dev_err(&client->dev,
>>> -					"mismatching report length: %*ph\n",
>>> +					"unsupported report length: %*ph\n",
>>>  					HEADER_SIZE, ts->buf);
>> Do I understand this correctly that the old packets are only observed on
>> EKTF3624? If so can we expand the check so that we only accept packets
>> with "old" size when we know we are dealing with this device?
> 
> We only have EKTF3624 and can't be sure there are no other chips needing this.

In practice this older packet format should be seen only on 3624, but
nevertheless we could make it more explicit by adding the extra chip_id
checks.

It won't be difficult to change it in the future if will be needed.

I think the main point that Dmitry Torokhov conveys here is that we
should minimize the possible impact on the current EKT3500 code since we
don't have definitive answers regarding the firmware differences among
the hardware variants.

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2020-12-11 16:39       ` Dmitry Osipenko
@ 2020-12-11 17:04         ` Michał Mirosław
  2020-12-11 18:48           ` Dmitry Torokhov
  0 siblings, 1 reply; 19+ messages in thread
From: Michał Mirosław @ 2020-12-11 17:04 UTC (permalink / raw)
  To: Dmitry Osipenko; +Cc: Dmitry Torokhov, Johnny Chuang, linux-input, linux-kernel

On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote:
> 11.12.2020 19:09, Michał Mirosław пишет:
> > On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
> >> Hi Michał,
> >> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> >>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
> >>>  			}
> >>>  
> >>>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
> >>> -			if (report_len != PACKET_SIZE) {
> >>> +			if (report_len != PACKET_SIZE &&
> >>> +			    report_len != PACKET_SIZE_OLD) {
> >>>  				dev_err(&client->dev,
> >>> -					"mismatching report length: %*ph\n",
> >>> +					"unsupported report length: %*ph\n",
> >>>  					HEADER_SIZE, ts->buf);
> >> Do I understand this correctly that the old packets are only observed on
> >> EKTF3624? If so can we expand the check so that we only accept packets
> >> with "old" size when we know we are dealing with this device?
> > 
> > We only have EKTF3624 and can't be sure there are no other chips needing this.
> 
> In practice this older packet format should be seen only on 3624, but
> nevertheless we could make it more explicit by adding the extra chip_id
> checks.
> 
> It won't be difficult to change it in the future if will be needed.
> 
> I think the main point that Dmitry Torokhov conveys here is that we
> should minimize the possible impact on the current EKT3500 code since we
> don't have definitive answers regarding the firmware differences among
> the hardware variants.

The only possible impact here is that older firmware instead of breaking
would suddenly work. Maybe we can accept such a risk?

Best Regards
Michał Mirosław

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2020-12-11 17:04         ` Michał Mirosław
@ 2020-12-11 18:48           ` Dmitry Torokhov
  2021-01-07 22:06             ` Dmitry Osipenko
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Torokhov @ 2020-12-11 18:48 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Dmitry Osipenko, Johnny Chuang, linux-input, linux-kernel

On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote:
> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote:
> > 11.12.2020 19:09, Michał Mirosław пишет:
> > > On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
> > >> Hi Michał,
> > >> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> > >>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
> > >>>  			}
> > >>>  
> > >>>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
> > >>> -			if (report_len != PACKET_SIZE) {
> > >>> +			if (report_len != PACKET_SIZE &&
> > >>> +			    report_len != PACKET_SIZE_OLD) {
> > >>>  				dev_err(&client->dev,
> > >>> -					"mismatching report length: %*ph\n",
> > >>> +					"unsupported report length: %*ph\n",
> > >>>  					HEADER_SIZE, ts->buf);
> > >> Do I understand this correctly that the old packets are only observed on
> > >> EKTF3624? If so can we expand the check so that we only accept packets
> > >> with "old" size when we know we are dealing with this device?
> > > 
> > > We only have EKTF3624 and can't be sure there are no other chips needing this.
> > 
> > In practice this older packet format should be seen only on 3624, but
> > nevertheless we could make it more explicit by adding the extra chip_id
> > checks.
> > 
> > It won't be difficult to change it in the future if will be needed.
> > 
> > I think the main point that Dmitry Torokhov conveys here is that we
> > should minimize the possible impact on the current EKT3500 code since we
> > don't have definitive answers regarding the firmware differences among
> > the hardware variants.
> 
> The only possible impact here is that older firmware instead of breaking
> would suddenly work. Maybe we can accept such a risk?

These are not controllers we'll randomly find in devices: Windows boxes
use I2C HID, Chrome devices use "new" firmware, so that leaves random
ARM where someone needs to consciously add proper compatible before the
driver will engage with the controller.

I would prefer we were conservative and not accept potentially invalid
data.

Thanks.

-- 
Dmitry

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2020-12-11 18:48           ` Dmitry Torokhov
@ 2021-01-07 22:06             ` Dmitry Osipenko
  2021-01-22 20:10               ` Dmitry Osipenko
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Osipenko @ 2021-01-07 22:06 UTC (permalink / raw)
  To: Dmitry Torokhov, Michał Mirosław
  Cc: Johnny Chuang, linux-input, linux-kernel

11.12.2020 21:48, Dmitry Torokhov пишет:
> On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote:
>> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote:
>>> 11.12.2020 19:09, Michał Mirosław пишет:
>>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
>>>>> Hi Michał,
>>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
>>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
>>>>>>  			}
>>>>>>  
>>>>>>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
>>>>>> -			if (report_len != PACKET_SIZE) {
>>>>>> +			if (report_len != PACKET_SIZE &&
>>>>>> +			    report_len != PACKET_SIZE_OLD) {
>>>>>>  				dev_err(&client->dev,
>>>>>> -					"mismatching report length: %*ph\n",
>>>>>> +					"unsupported report length: %*ph\n",
>>>>>>  					HEADER_SIZE, ts->buf);
>>>>> Do I understand this correctly that the old packets are only observed on
>>>>> EKTF3624? If so can we expand the check so that we only accept packets
>>>>> with "old" size when we know we are dealing with this device?
>>>>
>>>> We only have EKTF3624 and can't be sure there are no other chips needing this.
>>>
>>> In practice this older packet format should be seen only on 3624, but
>>> nevertheless we could make it more explicit by adding the extra chip_id
>>> checks.
>>>
>>> It won't be difficult to change it in the future if will be needed.
>>>
>>> I think the main point that Dmitry Torokhov conveys here is that we
>>> should minimize the possible impact on the current EKT3500 code since we
>>> don't have definitive answers regarding the firmware differences among
>>> the hardware variants.
>>
>> The only possible impact here is that older firmware instead of breaking
>> would suddenly work. Maybe we can accept such a risk?
> 
> These are not controllers we'll randomly find in devices: Windows boxes
> use I2C HID, Chrome devices use "new" firmware, so that leaves random
> ARM where someone needs to consciously add proper compatible before the
> driver will engage with the controller.
> 
> I would prefer we were conservative and not accept potentially invalid
> data.
> 
> Thanks.
> 

Michał, will you be able to make v9 with all the review comments addressed?

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2021-01-07 22:06             ` Dmitry Osipenko
@ 2021-01-22 20:10               ` Dmitry Osipenko
  2021-01-22 22:37                 ` Michał Mirosław
  0 siblings, 1 reply; 19+ messages in thread
From: Dmitry Osipenko @ 2021-01-22 20:10 UTC (permalink / raw)
  To: Dmitry Torokhov, Michał Mirosław
  Cc: Johnny Chuang, linux-input, linux-kernel

08.01.2021 01:06, Dmitry Osipenko пишет:
> 11.12.2020 21:48, Dmitry Torokhov пишет:
>> On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote:
>>> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote:
>>>> 11.12.2020 19:09, Michał Mirosław пишет:
>>>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
>>>>>> Hi Michał,
>>>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
>>>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
>>>>>>>  			}
>>>>>>>  
>>>>>>>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
>>>>>>> -			if (report_len != PACKET_SIZE) {
>>>>>>> +			if (report_len != PACKET_SIZE &&
>>>>>>> +			    report_len != PACKET_SIZE_OLD) {
>>>>>>>  				dev_err(&client->dev,
>>>>>>> -					"mismatching report length: %*ph\n",
>>>>>>> +					"unsupported report length: %*ph\n",
>>>>>>>  					HEADER_SIZE, ts->buf);
>>>>>> Do I understand this correctly that the old packets are only observed on
>>>>>> EKTF3624? If so can we expand the check so that we only accept packets
>>>>>> with "old" size when we know we are dealing with this device?
>>>>>
>>>>> We only have EKTF3624 and can't be sure there are no other chips needing this.
>>>>
>>>> In practice this older packet format should be seen only on 3624, but
>>>> nevertheless we could make it more explicit by adding the extra chip_id
>>>> checks.
>>>>
>>>> It won't be difficult to change it in the future if will be needed.
>>>>
>>>> I think the main point that Dmitry Torokhov conveys here is that we
>>>> should minimize the possible impact on the current EKT3500 code since we
>>>> don't have definitive answers regarding the firmware differences among
>>>> the hardware variants.
>>>
>>> The only possible impact here is that older firmware instead of breaking
>>> would suddenly work. Maybe we can accept such a risk?
>>
>> These are not controllers we'll randomly find in devices: Windows boxes
>> use I2C HID, Chrome devices use "new" firmware, so that leaves random
>> ARM where someone needs to consciously add proper compatible before the
>> driver will engage with the controller.
>>
>> I would prefer we were conservative and not accept potentially invalid
>> data.
>>
>> Thanks.
>>
> 
> Michał, will you be able to make v9 with all the review comments addressed?
> 

I'll make a v9 over this weekend.

Michał, please let me know if you already started to work on this or
have any objections.

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2021-01-22 20:10               ` Dmitry Osipenko
@ 2021-01-22 22:37                 ` Michał Mirosław
  2021-01-23 14:07                   ` Dmitry Osipenko
  0 siblings, 1 reply; 19+ messages in thread
From: Michał Mirosław @ 2021-01-22 22:37 UTC (permalink / raw)
  To: Dmitry Osipenko; +Cc: Dmitry Torokhov, Johnny Chuang, linux-input, linux-kernel

On Fri, Jan 22, 2021 at 11:10:52PM +0300, Dmitry Osipenko wrote:
> 08.01.2021 01:06, Dmitry Osipenko пишет:
> > 11.12.2020 21:48, Dmitry Torokhov пишет:
> >> On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote:
> >>> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote:
> >>>> 11.12.2020 19:09, Michał Mirosław пишет:
> >>>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
> >>>>>> Hi Michał,
> >>>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
> >>>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
> >>>>>>>  			}
> >>>>>>>  
> >>>>>>>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
> >>>>>>> -			if (report_len != PACKET_SIZE) {
> >>>>>>> +			if (report_len != PACKET_SIZE &&
> >>>>>>> +			    report_len != PACKET_SIZE_OLD) {
> >>>>>>>  				dev_err(&client->dev,
> >>>>>>> -					"mismatching report length: %*ph\n",
> >>>>>>> +					"unsupported report length: %*ph\n",
> >>>>>>>  					HEADER_SIZE, ts->buf);
> >>>>>> Do I understand this correctly that the old packets are only observed on
> >>>>>> EKTF3624? If so can we expand the check so that we only accept packets
> >>>>>> with "old" size when we know we are dealing with this device?
> >>>>>
> >>>>> We only have EKTF3624 and can't be sure there are no other chips needing this.
> >>>>
> >>>> In practice this older packet format should be seen only on 3624, but
> >>>> nevertheless we could make it more explicit by adding the extra chip_id
> >>>> checks.
> >>>>
> >>>> It won't be difficult to change it in the future if will be needed.
> >>>>
> >>>> I think the main point that Dmitry Torokhov conveys here is that we
> >>>> should minimize the possible impact on the current EKT3500 code since we
> >>>> don't have definitive answers regarding the firmware differences among
> >>>> the hardware variants.
> >>>
> >>> The only possible impact here is that older firmware instead of breaking
> >>> would suddenly work. Maybe we can accept such a risk?
> >>
> >> These are not controllers we'll randomly find in devices: Windows boxes
> >> use I2C HID, Chrome devices use "new" firmware, so that leaves random
> >> ARM where someone needs to consciously add proper compatible before the
> >> driver will engage with the controller.
> >>
> >> I would prefer we were conservative and not accept potentially invalid
> >> data.
> >>
> >> Thanks.
> >>
> > 
> > Michał, will you be able to make v9 with all the review comments addressed?
> > 
> 
> I'll make a v9 over this weekend.
> 
> Michał, please let me know if you already started to work on this or
> have any objections.

Hi,

Sorry for staying quiet so long. I have to revive my Transformer before
I can test anything, so please go ahead.

Best Regards
Michał Mirosław

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

* Re: [PATCH RESEND v8 2/4] input: elants: support old touch report format
  2021-01-22 22:37                 ` Michał Mirosław
@ 2021-01-23 14:07                   ` Dmitry Osipenko
  0 siblings, 0 replies; 19+ messages in thread
From: Dmitry Osipenko @ 2021-01-23 14:07 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Dmitry Torokhov, Johnny Chuang, linux-input, linux-kernel

23.01.2021 01:37, Michał Mirosław пишет:
> On Fri, Jan 22, 2021 at 11:10:52PM +0300, Dmitry Osipenko wrote:
>> 08.01.2021 01:06, Dmitry Osipenko пишет:
>>> 11.12.2020 21:48, Dmitry Torokhov пишет:
>>>> On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote:
>>>>> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote:
>>>>>> 11.12.2020 19:09, Michał Mirosław пишет:
>>>>>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote:
>>>>>>>> Hi Michał,
>>>>>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote:
>>>>>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev)
>>>>>>>>>  			}
>>>>>>>>>  
>>>>>>>>>  			report_len = ts->buf[FW_HDR_LENGTH] / report_count;
>>>>>>>>> -			if (report_len != PACKET_SIZE) {
>>>>>>>>> +			if (report_len != PACKET_SIZE &&
>>>>>>>>> +			    report_len != PACKET_SIZE_OLD) {
>>>>>>>>>  				dev_err(&client->dev,
>>>>>>>>> -					"mismatching report length: %*ph\n",
>>>>>>>>> +					"unsupported report length: %*ph\n",
>>>>>>>>>  					HEADER_SIZE, ts->buf);
>>>>>>>> Do I understand this correctly that the old packets are only observed on
>>>>>>>> EKTF3624? If so can we expand the check so that we only accept packets
>>>>>>>> with "old" size when we know we are dealing with this device?
>>>>>>>
>>>>>>> We only have EKTF3624 and can't be sure there are no other chips needing this.
>>>>>>
>>>>>> In practice this older packet format should be seen only on 3624, but
>>>>>> nevertheless we could make it more explicit by adding the extra chip_id
>>>>>> checks.
>>>>>>
>>>>>> It won't be difficult to change it in the future if will be needed.
>>>>>>
>>>>>> I think the main point that Dmitry Torokhov conveys here is that we
>>>>>> should minimize the possible impact on the current EKT3500 code since we
>>>>>> don't have definitive answers regarding the firmware differences among
>>>>>> the hardware variants.
>>>>>
>>>>> The only possible impact here is that older firmware instead of breaking
>>>>> would suddenly work. Maybe we can accept such a risk?
>>>>
>>>> These are not controllers we'll randomly find in devices: Windows boxes
>>>> use I2C HID, Chrome devices use "new" firmware, so that leaves random
>>>> ARM where someone needs to consciously add proper compatible before the
>>>> driver will engage with the controller.
>>>>
>>>> I would prefer we were conservative and not accept potentially invalid
>>>> data.
>>>>
>>>> Thanks.
>>>>
>>>
>>> Michał, will you be able to make v9 with all the review comments addressed?
>>>
>>
>> I'll make a v9 over this weekend.
>>
>> Michał, please let me know if you already started to work on this or
>> have any objections.
> 
> Hi,
> 
> Sorry for staying quiet so long. I have to revive my Transformer before
> I can test anything, so please go ahead.

No problems, hope it's nothing serious and you'll have some spare time
to revive it soon!

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

* [PATCH RESEND v8 1/4] input: elants: document some registers and values
  2020-11-09 17:28 [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens Michał Mirosław
@ 2020-11-09 17:28 ` Michał Mirosław
  0 siblings, 0 replies; 19+ messages in thread
From: Michał Mirosław @ 2020-11-09 17:28 UTC (permalink / raw)
  To: Dmitry Torokhov, Johnny Chuang
  Cc: Peter Hutterer, Dmitry Osipenko, linux-input, linux-kernel

Add information found in downstream kernels, to make the code less
magic.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/input/touchscreen/elants_i2c.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index 50c348297e38..d51cb910fba1 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -82,7 +82,7 @@
 
 #define HEADER_REPORT_10_FINGER	0x62
 
-/* Header (4 bytes) plus 3 fill 10-finger packets */
+/* Header (4 bytes) plus 3 full 10-finger packets */
 #define MAX_PACKET_SIZE		169
 
 #define BOOT_TIME_DELAY_MS	50
@@ -97,6 +97,10 @@
 #define E_INFO_PHY_SCAN		0xD7
 #define E_INFO_PHY_DRIVER	0xD8
 
+/* FW write command, 0x54 0x?? 0x0, 0x01 */
+#define E_POWER_STATE_SLEEP	0x50
+#define E_POWER_STATE_RESUME	0x58
+
 #define MAX_RETRIES		3
 #define MAX_FW_UPDATE_RETRIES	30
 
@@ -269,8 +273,8 @@ static int elants_i2c_calibrate(struct elants_data *ts)
 {
 	struct i2c_client *client = ts->client;
 	int ret, error;
-	static const u8 w_flashkey[] = { 0x54, 0xC0, 0xE1, 0x5A };
-	static const u8 rek[] = { 0x54, 0x29, 0x00, 0x01 };
+	static const u8 w_flashkey[] = { CMD_HEADER_WRITE, 0xC0, 0xE1, 0x5A };
+	static const u8 rek[] = { CMD_HEADER_WRITE, 0x29, 0x00, 0x01 };
 	static const u8 rek_resp[] = { CMD_HEADER_REK, 0x66, 0x66, 0x66 };
 
 	disable_irq(client->irq);
@@ -1388,7 +1392,9 @@ static int __maybe_unused elants_i2c_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct elants_data *ts = i2c_get_clientdata(client);
-	const u8 set_sleep_cmd[] = { 0x54, 0x50, 0x00, 0x01 };
+	const u8 set_sleep_cmd[] = {
+		CMD_HEADER_WRITE, E_POWER_STATE_SLEEP, 0x00, 0x01
+	};
 	int retry_cnt;
 	int error;
 
@@ -1425,7 +1431,9 @@ static int __maybe_unused elants_i2c_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct elants_data *ts = i2c_get_clientdata(client);
-	const u8 set_active_cmd[] = { 0x54, 0x58, 0x00, 0x01 };
+	const u8 set_active_cmd[] = {
+		CMD_HEADER_WRITE, E_POWER_STATE_RESUME, 0x00, 0x01
+	};
 	int retry_cnt;
 	int error;
 
-- 
2.20.1


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

end of thread, other threads:[~2021-01-23 14:08 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11  6:53 [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens Michał Mirosław
2020-12-11  6:53 ` [PATCH RESEND v8 2/4] input: elants: support old touch report format Michał Mirosław
2020-12-11  7:29   ` Dmitry Torokhov
2020-12-11 16:09     ` Michał Mirosław
2020-12-11 16:39       ` Dmitry Osipenko
2020-12-11 17:04         ` Michał Mirosław
2020-12-11 18:48           ` Dmitry Torokhov
2021-01-07 22:06             ` Dmitry Osipenko
2021-01-22 20:10               ` Dmitry Osipenko
2021-01-22 22:37                 ` Michał Mirosław
2021-01-23 14:07                   ` Dmitry Osipenko
2020-12-11  6:53 ` [PATCH RESEND v8 1/4] input: elants: document some registers and values Michał Mirosław
2020-12-11  7:11   ` Dmitry Torokhov
2020-12-11  6:53 ` [PATCH RESEND v8 3/4] input: elants: read touchscreen size for EKTF3624 Michał Mirosław
2020-12-11  7:22   ` Dmitry Torokhov
2020-12-11 16:38     ` Michał Mirosław
2020-12-11  6:53 ` [PATCH RESEND v8 4/4] input: elants: support 0x66 reply opcode for reporting touches Michał Mirosław
2020-12-11  7:36   ` Dmitry Torokhov
  -- strict thread matches above, loose matches on Subject: below --
2020-11-09 17:28 [PATCH RESEND v8 0/4] input: elants: Support Asus TF300T and Nexus 7 touchscreens Michał Mirosław
2020-11-09 17:28 ` [PATCH RESEND v8 1/4] input: elants: document some registers and values Michał Mirosław

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).