mbox series

[v2,0/9] input: elants: Support Asus TF300T touchscreen

Message ID cover.1576079249.git.mirq-linux@rere.qmqm.pl
Headers show
Series input: elants: Support Asus TF300T touchscreen | expand

Message

Michał Mirosław Dec. 11, 2019, 4:03 p.m. UTC
This series cleans up the driver a bit and implements changes needed to
support EKTF3624-based touchscreen used in eg. Asus TF300T tablet. 

---
v2: extended with Dmitry's patches (replaced v1 patches 3 and 4)

Dmitry Osipenko (3):
  input: elants: support 0x66 reply opcode for reporting touches
  dt-bindings: input: elants-i2c: Document common touchscreen properties
  dt-bindings: input: elants-i2c: Document eKTF3624

Michał Mirosław (6):
  input: elants: document some registers and values
  input: elants: support old touch report format
  input: elants: remove unused axes
  input: elants: override touchscreen info with DT properties
  input: elants: refactor elants_i2c_execute_command()
  input: elants: read touchscreen size for EKTF3624

 .../devicetree/bindings/input/elants_i2c.txt  |   6 +-
 drivers/input/touchscreen/elants_i2c.c        | 358 ++++++++++++------
 2 files changed, 239 insertions(+), 125 deletions(-)

Comments

Dmitry Osipenko Dec. 12, 2019, 12:29 a.m. UTC | #1
11.12.2019 19:03, Michał Mirosław пишет:
> This series cleans up the driver a bit and implements changes needed to
> support EKTF3624-based touchscreen used in eg. Asus TF300T tablet. 
> 
> ---
> v2: extended with Dmitry's patches (replaced v1 patches 3 and 4)
> 
> Dmitry Osipenko (3):
>   input: elants: support 0x66 reply opcode for reporting touches
>   dt-bindings: input: elants-i2c: Document common touchscreen properties
>   dt-bindings: input: elants-i2c: Document eKTF3624
> 
> Michał Mirosław (6):
>   input: elants: document some registers and values
>   input: elants: support old touch report format
>   input: elants: remove unused axes
>   input: elants: override touchscreen info with DT properties
>   input: elants: refactor elants_i2c_execute_command()
>   input: elants: read touchscreen size for EKTF3624
> 
>  .../devicetree/bindings/input/elants_i2c.txt  |   6 +-
>  drivers/input/touchscreen/elants_i2c.c        | 358 ++++++++++++------
>  2 files changed, 239 insertions(+), 125 deletions(-)
> 

Hello Michał,

The series works and looks good to me, eKTF3624 touchscreen is working
fine on Nexus 7. Thank you very much!
Dmitry Osipenko Dec. 12, 2019, 12:30 a.m. UTC | #2
11.12.2019 19:03, Michał Mirosław пишет:
> Apply some DRY-ing to elants_i2c_execute_command() callers.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---

Could you please explain why this change is needed?

[snip]
Dmitry Osipenko Dec. 12, 2019, 12:34 a.m. UTC | #3
11.12.2019 19:03, Michał Mirosław пишет:
> Add information found in downstream kernels, to make the code less
> magic.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/input/touchscreen/elants_i2c.c | 29 +++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index d4ad24ea54c8..887888c53996 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -77,7 +77,11 @@
>  
>  #define HEADER_REPORT_10_FINGER	0x62
>  
> -/* Header (4 bytes) plus 3 fill 10-finger packets */
> +/* Power state */
> +#define PWR_STATE_DEEP_SLEEP	0
> +#define PWR_STATE_NORMAL	1
> +
> +/* Header (4 bytes) plus 3 full 10-finger packets */
>  #define MAX_PACKET_SIZE		169
>  
>  #define BOOT_TIME_DELAY_MS	50
> @@ -87,10 +91,21 @@
>  #define E_ELAN_INFO_BC_VER	0x10
>  #define E_ELAN_INFO_TEST_VER	0xE0
>  #define E_ELAN_INFO_FW_ID	0xF0
> +#define E_POWER_MODE		0x40
> +#define E_POWER_STATE		0x50
> +#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

> +/* FW write command, 0x54 0x?? 0x0, 0x01 */
> +#define E_POWER_MODE_BATTERY	0x40
> +#define E_POWER_MODE_AC		0x41

These commands are not utilized yet, but perhaps it's okay to add the
definitions if you're going to add support for power source switching.

> +#define E_POWER_MODE_USB	0x42
> +#define E_POWER_STATE_SLEEP	0x50
> +#define E_POWER_STATE_RESUME	0x58
> +
>  #define MAX_RETRIES		3
>  #define MAX_FW_UPDATE_RETRIES	30
>  
> @@ -231,8 +246,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);
> @@ -1295,7 +1310,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;
>  
> @@ -1332,7 +1349,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;
>  
> 

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Dmitry Osipenko Dec. 12, 2019, 12:34 a.m. UTC | #4
11.12.2019 19:03, Michał Mirosław пишет:
> Driver only ever reports MT events. Clear capabilities of all others.
> 
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/input/touchscreen/elants_i2c.c | 11 -----------
>  1 file changed, 11 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index eadd26d5a06f..ab9d63239ff5 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -1251,17 +1251,6 @@ static int elants_i2c_probe(struct i2c_client *client,
>  	ts->input->name = "Elan Touchscreen";
>  	ts->input->id.bustype = BUS_I2C;
>  
> -	__set_bit(BTN_TOUCH, ts->input->keybit);
> -	__set_bit(EV_ABS, ts->input->evbit);
> -	__set_bit(EV_KEY, ts->input->evbit);
> -
> -	/* Single touch input params setup */
> -	input_set_abs_params(ts->input, ABS_X, 0, ts->x_max, 0, 0);
> -	input_set_abs_params(ts->input, ABS_Y, 0, ts->y_max, 0, 0);
> -	input_set_abs_params(ts->input, ABS_PRESSURE, 0, 255, 0, 0);
> -	input_abs_set_res(ts->input, ABS_X, ts->x_res);
> -	input_abs_set_res(ts->input, ABS_Y, ts->y_res);
> -
>  	/* Multitouch input params setup */
>  	error = input_mt_init_slots(ts->input, MAX_CONTACT_NUM,
>  				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
> 

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Dmitry Osipenko Dec. 12, 2019, 12:39 a.m. UTC | #5
11.12.2019 19:03, Michał Mirosław пишет:
> 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>
> ---
>  drivers/input/touchscreen/elants_i2c.c | 82 ++++++++++++++++++++++++--
>  1 file changed, 77 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
> index 369004678a46..1c3eb49a22e4 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -34,7 +34,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>
> @@ -42,6 +42,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))
>  
> @@ -162,6 +166,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;
> @@ -436,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;
> @@ -587,8 +643,20 @@ static int elants_i2c_initialize(struct elants_data *ts)
>  		error = elants_i2c_query_test_version(ts);
>  	if (!error)
>  		error = elants_i2c_query_bc_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;
> @@ -1185,6 +1253,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);
> @@ -1409,7 +1480,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);
> 

In a comment to v1 I suggested to remove the OF table and use I2C table
for the OF matching, but this variant is okay as well.

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
Dmitry Osipenko Dec. 12, 2019, 12:54 a.m. UTC | #6
11.12.2019 19:03, Michał Mirosław пишет:
> 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>
> ---
>  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 887888c53996..eadd26d5a06f 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -65,6 +65,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
> @@ -792,7 +793,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;
> @@ -804,7 +806,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);
>  
>  	for (i = 0; i < MAX_CONTACT_NUM && n_fingers; i++) {
>  		if (finger_state & 1) {
> @@ -814,8 +817,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;

Did you copy this from the downstream driver as-is? I'm looking at the
Nexus 7 driver and it does the following for older format:

u8 size_idx[] = { 35, 35, 36, 36, 37, 37, 38, 38, 39, 39 };
unsigned int s;

if (i & 1)
	s = buf[size_idx[i]];
else
	s = buf[size_idx[i]] / 16;

w = s & 0xf;
p = s * 16;

> +			} 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);
> @@ -848,7 +859,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);
>  
> @@ -862,7 +874,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)
> @@ -920,7 +932,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:
> @@ -933,17 +946,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;
>  
>
Dmitry Torokhov Dec. 12, 2019, 7:24 p.m. UTC | #7
On Wed, Dec 11, 2019 at 05:03:18PM +0100, Michał Mirosław wrote:
> This series cleans up the driver a bit and implements changes needed to
> support EKTF3624-based touchscreen used in eg. Asus TF300T tablet. 

Johnny, could you please take a look at this patch series?

Thanks!

> 
> ---
> v2: extended with Dmitry's patches (replaced v1 patches 3 and 4)
> 
> Dmitry Osipenko (3):
>   input: elants: support 0x66 reply opcode for reporting touches
>   dt-bindings: input: elants-i2c: Document common touchscreen properties
>   dt-bindings: input: elants-i2c: Document eKTF3624
> 
> Michał Mirosław (6):
>   input: elants: document some registers and values
>   input: elants: support old touch report format
>   input: elants: remove unused axes
>   input: elants: override touchscreen info with DT properties
>   input: elants: refactor elants_i2c_execute_command()
>   input: elants: read touchscreen size for EKTF3624
> 
>  .../devicetree/bindings/input/elants_i2c.txt  |   6 +-
>  drivers/input/touchscreen/elants_i2c.c        | 358 ++++++++++++------
>  2 files changed, 239 insertions(+), 125 deletions(-)
> 
> -- 
> 2.20.1
>
Michał Mirosław Dec. 12, 2019, 7:45 p.m. UTC | #8
On Thu, Dec 12, 2019 at 03:54:13AM +0300, Dmitry Osipenko wrote:
> 11.12.2019 19:03, Michał Mirosław пишет:
> > Support ELAN touchpad sensor with older firmware as found on eg. Asus
> > Transformer Pads.
[...]
> > @@ -814,8 +817,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;
> 
> Did you copy this from the downstream driver as-is? I'm looking at the
> Nexus 7 driver and it does the following for older format:
> 
> u8 size_idx[] = { 35, 35, 36, 36, 37, 37, 38, 38, 39, 39 };
> unsigned int s;
> 
> if (i & 1)
> 	s = buf[size_idx[i]];
> else
> 	s = buf[size_idx[i]] / 16;
> 
> w = s & 0xf;
> p = s * 16;

This is the same thing modulo (w), which is scaled here to declared axis
range (1-255 from 0-15, assuming 0 means "no touch" so it should not occur).

OTOH, I admit, that I don't have any software that can verify those
settings. It might be that eg. one of MT_PRESSURE or MT_TOUCH_MAJOR axes
should be dropped in this case, but with no docs I can't be sure what
the reported values really are.

This is from the original (GPL) code dump labeled 'Asus 10_6_1_27_5':

|  touch_size = ((i & 0x01) ? buf[size_index[i]] : (buf[size_index[i]] >> 4)) & 0x0F;
|  if(touch_size == 0) touch_size = 1;
|  if (touch_size <= 7)
|      touch_size = touch_size << 5;
|  else
|      touch_size = 255;
|    
|    input_report_abs(idev, ABS_MT_TOUCH_MAJOR, touch_size);
|    input_report_abs(idev, ABS_MT_PRESSURE, touch_size);


Best Regards,
Michał Mirosław
Dmitry Osipenko Dec. 13, 2019, 12:06 a.m. UTC | #9
12.12.2019 22:45, Michał Mirosław пишет:
> On Thu, Dec 12, 2019 at 03:54:13AM +0300, Dmitry Osipenko wrote:
>> 11.12.2019 19:03, Michał Mirosław пишет:
>>> Support ELAN touchpad sensor with older firmware as found on eg. Asus
>>> Transformer Pads.
> [...]
>>> @@ -814,8 +817,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;
>>
>> Did you copy this from the downstream driver as-is? I'm looking at the
>> Nexus 7 driver and it does the following for older format:
>>
>> u8 size_idx[] = { 35, 35, 36, 36, 37, 37, 38, 38, 39, 39 };
>> unsigned int s;
>>
>> if (i & 1)
>> 	s = buf[size_idx[i]];
>> else
>> 	s = buf[size_idx[i]] / 16;
>>
>> w = s & 0xf;
>> p = s * 16;
> 
> This is the same thing modulo (w), which is scaled here to declared axis
> range (1-255 from 0-15, assuming 0 means "no touch" so it should not occur).
> 
> OTOH, I admit, that I don't have any software that can verify those
> settings. It might be that eg. one of MT_PRESSURE or MT_TOUCH_MAJOR axes
> should be dropped in this case, but with no docs I can't be sure what
> the reported values really are.
> 
> This is from the original (GPL) code dump labeled 'Asus 10_6_1_27_5':
> 
> |  touch_size = ((i & 0x01) ? buf[size_index[i]] : (buf[size_index[i]] >> 4)) & 0x0F;
> |  if(touch_size == 0) touch_size = 1;
> |  if (touch_size <= 7)
> |      touch_size = touch_size << 5;
> |  else
> |      touch_size = 255;
> |    
> |    input_report_abs(idev, ABS_MT_TOUCH_MAJOR, touch_size);
> |    input_report_abs(idev, ABS_MT_PRESSURE, touch_size);

Okay, I also don't know how to test it properly.

If anyone knows, please let us know :)
Dmitry Osipenko Jan. 7, 2020, 5:33 a.m. UTC | #10
12.12.2019 22:24, Dmitry Torokhov пишет:
> On Wed, Dec 11, 2019 at 05:03:18PM +0100, Michał Mirosław wrote:
>> This series cleans up the driver a bit and implements changes needed to
>> support EKTF3624-based touchscreen used in eg. Asus TF300T tablet. 
> 
> Johnny, could you please take a look at this patch series?
> 
> Thanks!

Hello Johnny,

Could you please let us know whether you or anyone else from Elan are
going to take a look at this patchset anytime soon?
Johnny.Chuang Jan. 8, 2020, 3 p.m. UTC | #11
> 12.12.2019 22:24, Dmitry Torokhov пишет:
> > On Wed, Dec 11, 2019 at 05:03:18PM +0100, Michał Mirosław wrote:
> >> This series cleans up the driver a bit and implements changes needed
> >> to support EKTF3624-based touchscreen used in eg. Asus TF300T tablet.
> >
> > Johnny, could you please take a look at this patch series?
> >
> > Thanks!
> 
> Hello Johnny,
> 
> Could you please let us know whether you or anyone else from Elan are going
> to take a look at this patchset anytime soon?

Hi Dmitry Osipenko,

I'm sorry to reply late. James Chen will take a look at this patch set.
Dmitry Osipenko Jan. 8, 2020, 3:37 p.m. UTC | #12
08.01.2020 18:00, Johnny.Chuang пишет:
>> 12.12.2019 22:24, Dmitry Torokhov пишет:
>>> On Wed, Dec 11, 2019 at 05:03:18PM +0100, Michał Mirosław wrote:
>>>> This series cleans up the driver a bit and implements changes needed
>>>> to support EKTF3624-based touchscreen used in eg. Asus TF300T tablet.
>>>
>>> Johnny, could you please take a look at this patch series?
>>>
>>> Thanks!
>>
>> Hello Johnny,
>>
>> Could you please let us know whether you or anyone else from Elan are going
>> to take a look at this patchset anytime soon?
> 
> Hi Dmitry Osipenko,
> 
> I'm sorry to reply late. James Chen will take a look at this patch set. 
> 

No problems, thank you very much.