linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F.
@ 2020-12-07  9:07 jingle.wu
  2020-12-10  6:14 ` Dmitry Torokhov
  0 siblings, 1 reply; 7+ messages in thread
From: jingle.wu @ 2020-12-07  9:07 UTC (permalink / raw)
  To: linux-kernel, linux-input, dmitry.torokhov
  Cc: phoenix, josh.chen, dave.wang, jingle.wu

The 0x5F is new trackpoint report type of some module.

Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>
---
 drivers/input/mouse/elan_i2c_core.c  | 2 ++
 drivers/input/mouse/elan_i2c_smbus.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 61ed3f5ca219..8f0c4663167c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -52,6 +52,7 @@
 #define ETP_REPORT_ID		0x5D
 #define ETP_REPORT_ID2		0x60	/* High precision report */
 #define ETP_TP_REPORT_ID	0x5E
+#define ETP_TP_REPORT_ID2	0x5F
 #define ETP_REPORT_ID_OFFSET	2
 #define ETP_TOUCH_INFO_OFFSET	3
 #define ETP_FINGER_DATA_OFFSET	4
@@ -1076,6 +1077,7 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
 		elan_report_absolute(data, report, true);
 		break;
 	case ETP_TP_REPORT_ID:
+	case ETP_TP_REPORT_ID2:
 		elan_report_trackpoint(data, report);
 		break;
 	default:
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index 1820f1cfc1dc..1226d47ec3cf 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -45,6 +45,7 @@
 #define ETP_SMBUS_CALIBRATE_QUERY	0xC5
 
 #define ETP_SMBUS_REPORT_LEN		32
+#define ETP_SMBUS_REPORT_LEN2		7
 #define ETP_SMBUS_REPORT_OFFSET		2
 #define ETP_SMBUS_HELLOPACKET_LEN	5
 #define ETP_SMBUS_IAP_PASSWORD		0x1234
@@ -497,7 +498,7 @@ static int elan_smbus_get_report(struct i2c_client *client,
 		return len;
 	}
 
-	if (len != ETP_SMBUS_REPORT_LEN) {
+	if ((len != ETP_SMBUS_REPORT_LEN) && (len != ETP_SMBUS_REPORT_LEN2))  {
 		dev_err(&client->dev,
 			"wrong report length (%d vs %d expected)\n",
 			len, ETP_SMBUS_REPORT_LEN);
-- 
2.17.1


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

* Re: [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F.
  2020-12-07  9:07 [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F jingle.wu
@ 2020-12-10  6:14 ` Dmitry Torokhov
  2020-12-11  2:38   ` jingle
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Torokhov @ 2020-12-10  6:14 UTC (permalink / raw)
  To: jingle.wu; +Cc: linux-kernel, linux-input, phoenix, josh.chen, dave.wang

Hi Jingle,

On Mon, Dec 07, 2020 at 05:07:51PM +0800, jingle.wu wrote:
> The 0x5F is new trackpoint report type of some module.
> 
> Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>
> ---
>  drivers/input/mouse/elan_i2c_core.c  | 2 ++
>  drivers/input/mouse/elan_i2c_smbus.c | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
> index 61ed3f5ca219..8f0c4663167c 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -52,6 +52,7 @@
>  #define ETP_REPORT_ID		0x5D
>  #define ETP_REPORT_ID2		0x60	/* High precision report */
>  #define ETP_TP_REPORT_ID	0x5E
> +#define ETP_TP_REPORT_ID2	0x5F
>  #define ETP_REPORT_ID_OFFSET	2
>  #define ETP_TOUCH_INFO_OFFSET	3
>  #define ETP_FINGER_DATA_OFFSET	4

I think we might need to move this into elan_i2c.h so that we can
reference it from elan_i2c_smbus.c.

> @@ -1076,6 +1077,7 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
>  		elan_report_absolute(data, report, true);
>  		break;
>  	case ETP_TP_REPORT_ID:
> +	case ETP_TP_REPORT_ID2:
>  		elan_report_trackpoint(data, report);
>  		break;
>  	default:
> diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
> index 1820f1cfc1dc..1226d47ec3cf 100644
> --- a/drivers/input/mouse/elan_i2c_smbus.c
> +++ b/drivers/input/mouse/elan_i2c_smbus.c
> @@ -45,6 +45,7 @@
>  #define ETP_SMBUS_CALIBRATE_QUERY	0xC5
>  
>  #define ETP_SMBUS_REPORT_LEN		32
> +#define ETP_SMBUS_REPORT_LEN2		7
>  #define ETP_SMBUS_REPORT_OFFSET		2
>  #define ETP_SMBUS_HELLOPACKET_LEN	5
>  #define ETP_SMBUS_IAP_PASSWORD		0x1234
> @@ -497,7 +498,7 @@ static int elan_smbus_get_report(struct i2c_client *client,
>  		return len;
>  	}
>  
> -	if (len != ETP_SMBUS_REPORT_LEN) {
> +	if ((len != ETP_SMBUS_REPORT_LEN) && (len != ETP_SMBUS_REPORT_LEN2))  {

I would prefer if we validated report length versus the packet type
before accepting it.

>  		dev_err(&client->dev,
>  			"wrong report length (%d vs %d expected)\n",
>  			len, ETP_SMBUS_REPORT_LEN);
> -- 
> 2.17.1
> 

Thanks.

-- 
Dmitry

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

* RE: [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F.
  2020-12-10  6:14 ` Dmitry Torokhov
@ 2020-12-11  2:38   ` jingle
  2020-12-11  3:04     ` 'Dmitry Torokhov'
  0 siblings, 1 reply; 7+ messages in thread
From: jingle @ 2020-12-11  2:38 UTC (permalink / raw)
  To: 'Dmitry Torokhov'
  Cc: linux-kernel, linux-input, phoenix, josh.chen, dave.wang

HI Dmitry:

I would prefer if we validated report length versus the packet type before
accepting it.

-> If the tracking point report is 0x5F, the report length is 7, but the
touchpad report length is 32.
-> So, report length will be different with this module.

THANKS
JINGLE


-----Original Message-----
From: Dmitry Torokhov [mailto:dmitry.torokhov@gmail.com] 
Sent: Thursday, December 10, 2020 2:14 PM
To: jingle.wu
Cc: linux-kernel@vger.kernel.org; linux-input@vger.kernel.org;
phoenix@emc.com.tw; josh.chen@emc.com.tw; dave.wang@emc.com.tw
Subject: Re: [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type
0x5F.

Hi Jingle,

On Mon, Dec 07, 2020 at 05:07:51PM +0800, jingle.wu wrote:
> The 0x5F is new trackpoint report type of some module.
> 
> Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>
> ---
>  drivers/input/mouse/elan_i2c_core.c  | 2 ++  
> drivers/input/mouse/elan_i2c_smbus.c | 3 ++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/mouse/elan_i2c_core.c 
> b/drivers/input/mouse/elan_i2c_core.c
> index 61ed3f5ca219..8f0c4663167c 100644
> --- a/drivers/input/mouse/elan_i2c_core.c
> +++ b/drivers/input/mouse/elan_i2c_core.c
> @@ -52,6 +52,7 @@
>  #define ETP_REPORT_ID		0x5D
>  #define ETP_REPORT_ID2		0x60	/* High precision report */
>  #define ETP_TP_REPORT_ID	0x5E
> +#define ETP_TP_REPORT_ID2	0x5F
>  #define ETP_REPORT_ID_OFFSET	2
>  #define ETP_TOUCH_INFO_OFFSET	3
>  #define ETP_FINGER_DATA_OFFSET	4

I think we might need to move this into elan_i2c.h so that we can reference
it from elan_i2c_smbus.c.

> @@ -1076,6 +1077,7 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
>  		elan_report_absolute(data, report, true);
>  		break;
>  	case ETP_TP_REPORT_ID:
> +	case ETP_TP_REPORT_ID2:
>  		elan_report_trackpoint(data, report);
>  		break;
>  	default:
> diff --git a/drivers/input/mouse/elan_i2c_smbus.c 
> b/drivers/input/mouse/elan_i2c_smbus.c
> index 1820f1cfc1dc..1226d47ec3cf 100644
> --- a/drivers/input/mouse/elan_i2c_smbus.c
> +++ b/drivers/input/mouse/elan_i2c_smbus.c
> @@ -45,6 +45,7 @@
>  #define ETP_SMBUS_CALIBRATE_QUERY	0xC5
>  
>  #define ETP_SMBUS_REPORT_LEN		32
> +#define ETP_SMBUS_REPORT_LEN2		7
>  #define ETP_SMBUS_REPORT_OFFSET		2
>  #define ETP_SMBUS_HELLOPACKET_LEN	5
>  #define ETP_SMBUS_IAP_PASSWORD		0x1234
> @@ -497,7 +498,7 @@ static int elan_smbus_get_report(struct i2c_client
*client,
>  		return len;
>  	}
>  
> -	if (len != ETP_SMBUS_REPORT_LEN) {
> +	if ((len != ETP_SMBUS_REPORT_LEN) && (len != ETP_SMBUS_REPORT_LEN2))

> +{

I would prefer if we validated report length versus the packet type before
accepting it.

>  		dev_err(&client->dev,
>  			"wrong report length (%d vs %d expected)\n",
>  			len, ETP_SMBUS_REPORT_LEN);
> --
> 2.17.1
> 

Thanks.

-- 
Dmitry


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

* Re: [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F.
  2020-12-11  2:38   ` jingle
@ 2020-12-11  3:04     ` 'Dmitry Torokhov'
  0 siblings, 0 replies; 7+ messages in thread
From: 'Dmitry Torokhov' @ 2020-12-11  3:04 UTC (permalink / raw)
  To: jingle; +Cc: linux-kernel, linux-input, phoenix, josh.chen, dave.wang

Hi Jingle,

On Fri, Dec 11, 2020 at 10:38:22AM +0800, jingle wrote:
> HI Dmitry:

Please do not top post on the kernel mailing lists.

> 
> I would prefer if we validated report length versus the packet type before
> accepting it.
> 
> -> If the tracking point report is 0x5F, the report length is 7, but the
> touchpad report length is 32.
> -> So, report length will be different with this module.

Right, but we could check the report type when we receive the data and
refuse it if length does not match what is expected for the report type
received. This can happen before we pass the data on to the
elan_i2c_core.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F.
  2020-12-11  7:15 jingle.wu
@ 2020-12-11 21:48 ` Dmitry Torokhov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Torokhov @ 2020-12-11 21:48 UTC (permalink / raw)
  To: jingle.wu; +Cc: linux-kernel, linux-input, phoenix, josh.chen, dave.wang

On Fri, Dec 11, 2020 at 03:15:11PM +0800, jingle.wu wrote:
> The 0x5F is new trackpoint report type of some module.
> 
> Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>

Applied with few minor edits.

-- 
Dmitry

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

* [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F.
@ 2020-12-11  7:15 jingle.wu
  2020-12-11 21:48 ` Dmitry Torokhov
  0 siblings, 1 reply; 7+ messages in thread
From: jingle.wu @ 2020-12-11  7:15 UTC (permalink / raw)
  To: linux-kernel, linux-input, dmitry.torokhov
  Cc: phoenix, josh.chen, dave.wang, jingle.wu

The 0x5F is new trackpoint report type of some module.

Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>
---
 drivers/input/mouse/elan_i2c.h       | 6 ++++++
 drivers/input/mouse/elan_i2c_core.c  | 5 +----
 drivers/input/mouse/elan_i2c_smbus.c | 8 ++++++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h
index 36e3cd908671..d5f9cd76eefb 100644
--- a/drivers/input/mouse/elan_i2c.h
+++ b/drivers/input/mouse/elan_i2c.h
@@ -28,6 +28,12 @@
 
 #define ETP_FEATURE_REPORT_MK	BIT(0)
 
+#define ETP_REPORT_ID		0x5D
+#define ETP_REPORT_ID2		0x60	/* High precision report */
+#define ETP_TP_REPORT_ID	0x5E
+#define ETP_TP_REPORT_ID2	0x5F
+#define ETP_REPORT_ID_OFFSET	2
+
 /* IAP Firmware handling */
 #define ETP_PRODUCT_ID_FORMAT_STRING	"%d.0"
 #define ETP_FW_NAME		"elan_i2c_" ETP_PRODUCT_ID_FORMAT_STRING ".bin"
diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 61ed3f5ca219..0f46e2f6c9e8 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -49,10 +49,6 @@
 
 #define ETP_MAX_FINGERS		5
 #define ETP_FINGER_DATA_LEN	5
-#define ETP_REPORT_ID		0x5D
-#define ETP_REPORT_ID2		0x60	/* High precision report */
-#define ETP_TP_REPORT_ID	0x5E
-#define ETP_REPORT_ID_OFFSET	2
 #define ETP_TOUCH_INFO_OFFSET	3
 #define ETP_FINGER_DATA_OFFSET	4
 #define ETP_HOVER_INFO_OFFSET	30
@@ -1076,6 +1072,7 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
 		elan_report_absolute(data, report, true);
 		break;
 	case ETP_TP_REPORT_ID:
+	case ETP_TP_REPORT_ID2:
 		elan_report_trackpoint(data, report);
 		break;
 	default:
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index 1820f1cfc1dc..6dc148b9d959 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -45,6 +45,7 @@
 #define ETP_SMBUS_CALIBRATE_QUERY	0xC5
 
 #define ETP_SMBUS_REPORT_LEN		32
+#define ETP_SMBUS_REPORT_LEN2		7
 #define ETP_SMBUS_REPORT_OFFSET		2
 #define ETP_SMBUS_HELLOPACKET_LEN	5
 #define ETP_SMBUS_IAP_PASSWORD		0x1234
@@ -497,10 +498,13 @@ static int elan_smbus_get_report(struct i2c_client *client,
 		return len;
 	}
 
-	if (len != ETP_SMBUS_REPORT_LEN) {
+	if (report[ETP_REPORT_ID_OFFSET] == ETP_TP_REPORT_ID2)
+		report_len = ETP_SMBUS_REPORT_LEN2;
+
+	if (len != report_len) {
 		dev_err(&client->dev,
 			"wrong report length (%d vs %d expected)\n",
-			len, ETP_SMBUS_REPORT_LEN);
+			len, report_len);
 		return -EIO;
 	}
 
-- 
2.17.1


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

* [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F.
@ 2020-12-07  8:50 jingle.wu
  0 siblings, 0 replies; 7+ messages in thread
From: jingle.wu @ 2020-12-07  8:50 UTC (permalink / raw)
  To: linux-kernel, linux-input, dmitry.torohov
  Cc: phoenix, josh.chen, dave.wang, jingle.wu

The 0x5F is new trackpoint report type of some module.

Signed-off-by: Jingle Wu <jingle.wu@emc.com.tw>
---
 drivers/input/mouse/elan_i2c_core.c  | 2 ++
 drivers/input/mouse/elan_i2c_smbus.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c
index 61ed3f5ca219..8f0c4663167c 100644
--- a/drivers/input/mouse/elan_i2c_core.c
+++ b/drivers/input/mouse/elan_i2c_core.c
@@ -52,6 +52,7 @@
 #define ETP_REPORT_ID		0x5D
 #define ETP_REPORT_ID2		0x60	/* High precision report */
 #define ETP_TP_REPORT_ID	0x5E
+#define ETP_TP_REPORT_ID2	0x5F
 #define ETP_REPORT_ID_OFFSET	2
 #define ETP_TOUCH_INFO_OFFSET	3
 #define ETP_FINGER_DATA_OFFSET	4
@@ -1076,6 +1077,7 @@ static irqreturn_t elan_isr(int irq, void *dev_id)
 		elan_report_absolute(data, report, true);
 		break;
 	case ETP_TP_REPORT_ID:
+	case ETP_TP_REPORT_ID2:
 		elan_report_trackpoint(data, report);
 		break;
 	default:
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index 1820f1cfc1dc..1226d47ec3cf 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -45,6 +45,7 @@
 #define ETP_SMBUS_CALIBRATE_QUERY	0xC5
 
 #define ETP_SMBUS_REPORT_LEN		32
+#define ETP_SMBUS_REPORT_LEN2		7
 #define ETP_SMBUS_REPORT_OFFSET		2
 #define ETP_SMBUS_HELLOPACKET_LEN	5
 #define ETP_SMBUS_IAP_PASSWORD		0x1234
@@ -497,7 +498,7 @@ static int elan_smbus_get_report(struct i2c_client *client,
 		return len;
 	}
 
-	if (len != ETP_SMBUS_REPORT_LEN) {
+	if ((len != ETP_SMBUS_REPORT_LEN) && (len != ETP_SMBUS_REPORT_LEN2))  {
 		dev_err(&client->dev,
 			"wrong report length (%d vs %d expected)\n",
 			len, ETP_SMBUS_REPORT_LEN);
-- 
2.17.1


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

end of thread, other threads:[~2020-12-11 22:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07  9:07 [PATCH 1/2] Input: elan_i2c - Add new trackpoint report type 0x5F jingle.wu
2020-12-10  6:14 ` Dmitry Torokhov
2020-12-11  2:38   ` jingle
2020-12-11  3:04     ` 'Dmitry Torokhov'
  -- strict thread matches above, loose matches on Subject: below --
2020-12-11  7:15 jingle.wu
2020-12-11 21:48 ` Dmitry Torokhov
2020-12-07  8:50 jingle.wu

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