Skip to contentSkip to conversation

Add: (1) Detection for newer Elantech touchpads, so that kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware version 4 touchpad right click function.

PATCH In review Duson Lin 2 participants 3 messages Dec 9, 2013 – Dec 10, 2013

Subsystems (2)
lore
Share & tools
lore

Duson Lin

author
#0 lore raw

PATCH 1/1 Add: (1) Detection for newer Elantech touchpads, so that kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware version 4 touchpad right click function.

Modify:
(1) crc_enabled only support for v3 and v4 touchpad, so initialize crc_enabled as false first and check this hardware flag when hw_version as 3 or 4.

---
 drivers/input/mouse/elantech.c |   30 ++++++++++++++----------------
 drivers/input/mouse/elantech.h |    2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)
drivers/input/mouse/elantech.c +14 -16
index 8551dca..b3627cf 100644
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer <[email protected]>
  *
@@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
 	unsigned char *packet = psmouse->packet;
 
 	input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+	input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
 	input_mt_report_pointer_emulation(dev, true);
 	input_sync(dev);
 }
@@ -1047,9 +1048,7 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 			 */
 			psmouse_warn(psmouse, "couldn't query resolution data.\n");
 		}
-		/* v4 is clickpad, with only one button. */
 		__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
-		__clear_bit(BTN_RIGHT, dev->keybit);
 		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
 		/* For X to recognize me as touchpad. */
 		input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
@@ -1186,19 +1185,12 @@ static struct attribute_group elantech_attr_group = {
 
 static bool elantech_is_signature_valid(const unsigned char *param)
 {
-	static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10 };
-	int i;
-
 	if (param[0] == 0)
 		return false;
 
 	if (param[1] == 0)
 		return true;
 
-	for (i = 0; i < ARRAY_SIZE(rates); i++)
-		if (param[2] == rates[i])
-			return false;
-
 	return true;
 }
 
@@ -1298,6 +1290,14 @@ static int elantech_set_properties(struct elantech_data *etd)
 {
 	/* This represents the version of IC body. */
 	int ver = (etd->fw_version & 0x0f0000) >> 16;
+	/*
+	 * The signatures of v3 and v4 packets change depending on the
+	 * value of this hardware flag. But the v1 and v2 have not crc
+	 * check mechanism and the same hardware flag are also defined
+	 * as other function. So crc_enabled must be initialized as false 
+	 * first and checking by different hw_version.
+	 */
+	etd->crc_enabled = false;
 
 	/* Early version of Elan touchpads doesn't obey the rule. */
 	if (etd->fw_version < 0x020030 || etd->fw_version == 0x020600)
@@ -1309,10 +1309,14 @@ static int elantech_set_properties(struct elantech_data *etd)
 			etd->hw_version = 2;
 			break;
 		case 5:
+			etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
 			etd->hw_version = 3;
 			break;
 		case 6:
 		case 7:
+		case 8:
+		case 10:
+			etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
 			etd->hw_version = 4;
 			break;
 		default:
@@ -1343,12 +1347,6 @@ static int elantech_set_properties(struct elantech_data *etd)
 			etd->reports_pressure = true;
 	}
 
-	/*
-	 * The signatures of v3 and v4 packets change depending on the
-	 * value of this hardware flag.
-	 */
-	etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
-
 	return 0;
 }
 
drivers/input/mouse/elantech.h +1 -1
index 036a04a..c963ac8 100644
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer <[email protected]>
  *
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

Hi Duson.

Quoted 3 lines · Duson Lin

Modify:
(1) crc_enabled only support for v3 and v4 touchpad, so initialize crc_enabled as false first and check this hardware flag when hw_version as 3 or 4.

It looks to me there are several fixes rolled up together in this patch:

1. Support for the new hardware signatures (8 and 10, although I already applied patch for 8)
2. Fix to handle CRC check
3. Changes to report BTN_RIGHT.

Could you please split them up please?

Also, I am not sure if we can simply start reporting BTN_RIGHT as present, even on devices that don't actually have the right button, as this will interfere with userspace providing emulation for multiple buttons.

Is it possible to determine if a given model had right button or not?

Thanks.

Quoted 113 lines
---
 drivers/input/mouse/elantech.c |   30 ++++++++++++++----------------
 drivers/input/mouse/elantech.h |    2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)
drivers/input/mouse/elantech.c +14 -16
index 8551dca..b3627cf 100644
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer <[email protected]>
  *
@@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse *psmouse)
 	unsigned char *packet = psmouse->packet;
 
 	input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+	input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
 	input_mt_report_pointer_emulation(dev, true);
 	input_sync(dev);
 }
@@ -1047,9 +1048,7 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 			 */
 			psmouse_warn(psmouse, "couldn't query resolution data.\n");
 		}
-		/* v4 is clickpad, with only one button. */
 		__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
-		__clear_bit(BTN_RIGHT, dev->keybit);
 		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
 		/* For X to recognize me as touchpad. */
 		input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
@@ -1186,19 +1185,12 @@ static struct attribute_group elantech_attr_group = {
 
 static bool elantech_is_signature_valid(const unsigned char *param)
 {
-	static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10 };
-	int i;
-
 	if (param[0] == 0)
 		return false;
 
 	if (param[1] == 0)
 		return true;
 
-	for (i = 0; i < ARRAY_SIZE(rates); i++)
-		if (param[2] == rates[i])
-			return false;
-
 	return true;
 }
 
@@ -1298,6 +1290,14 @@ static int elantech_set_properties(struct elantech_data *etd)
 {
 	/* This represents the version of IC body. */
 	int ver = (etd->fw_version & 0x0f0000) >> 16;
+	/*
+	 * The signatures of v3 and v4 packets change depending on the
+	 * value of this hardware flag. But the v1 and v2 have not crc
+	 * check mechanism and the same hardware flag are also defined
+	 * as other function. So crc_enabled must be initialized as false 
+	 * first and checking by different hw_version.
+	 */
+	etd->crc_enabled = false;
 
 	/* Early version of Elan touchpads doesn't obey the rule. */
 	if (etd->fw_version < 0x020030 || etd->fw_version == 0x020600)
@@ -1309,10 +1309,14 @@ static int elantech_set_properties(struct elantech_data *etd)
 			etd->hw_version = 2;
 			break;
 		case 5:
+			etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
 			etd->hw_version = 3;
 			break;
 		case 6:
 		case 7:
+		case 8:
+		case 10:
+			etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
 			etd->hw_version = 4;
 			break;
 		default:
@@ -1343,12 +1347,6 @@ static int elantech_set_properties(struct elantech_data *etd)
 			etd->reports_pressure = true;
 	}
 
-	/*
-	 * The signatures of v3 and v4 packets change depending on the
-	 * value of this hardware flag.
-	 */
-	etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
-
 	return 0;
 }
 
drivers/input/mouse/elantech.h +1 -1
index 036a04a..c963ac8 100644
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer <[email protected]>
  *
Signature · 1 line
1.7.10.4
Signature · 1 line
Dmitry
author
#2 lore raw

Hi Dmitry

Quoted 2 lines

-----Original Message-----
From: [email protected]

[mailto:[email protected]]

Quoted 5 lines

On Behalf Of Dmitry Torokhov
Sent: Monday, December 09, 2013 2:32 PM
To: Duson Lin
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] Add: (1) Detection for newer Elantech touchpads, so

that

Quoted 1 line

kernel doesn't fall-back to default PS/2 driver. (2) Enable hardware

version 4

Quoted 8 lines

touchpad right click function.

Hi Duson.

Quoted 2 lines · Duson Lin

Modify:
(1) crc_enabled only support for v3 and v4 touchpad, so initialize

crc_enabled as

Quoted 11 lines

false first and

Quoted 1 line

check this hardware flag when hw_version as 3 or 4.

It looks to me there are several fixes rolled up together in this patch:

1. Support for the new hardware signatures (8 and 10, although I already applied patch for 8)
2. Fix to handle CRC check
3. Changes to report BTN_RIGHT.

Could you please split them up please?

OK, I will split them up.

Quoted 7 lines

Also, I am not sure if we can simply start reporting BTN_RIGHT as present, even on devices that don't actually have the right button, as this will interfere with userspace providing emulation for multiple buttons.

Is it possible to determine if a given model had right button or not?

It is hard to determine if a given model had right button, but depend on per-discuss in Hans de Goede's mailing list, it is possible to determine if given model need right click function.
Thanks.
Duosn

Quoted 9 lines

Review

Quoted 9 lines
---
 drivers/input/mouse/elantech.c |   30 ++++++++++++++----------------
 drivers/input/mouse/elantech.h |    2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)
(quoted diff) +0 -0

b/drivers/input/mouse/elantech.c

Quoted 12 lines

drivers/input/mouse/elantech.c static void elantech_input_sync_v4(struct psmouse

Quoted 11 lines

index 8551dca..b3627cf 100644

drivers/input/mouse/elantech.c +1 -1
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer <[email protected]>
  *
@@ -486,6 +486,7 @@ static void elantech_input_sync_v4(struct psmouse

*psmouse)

Quoted 8 lines

drivers/input/mouse/elantech.c static int elantech_set_input_params(struct

Quoted 8 lines
drivers/input/mouse/elantech.c +1 -0
 	unsigned char *packet = psmouse->packet;
 
 	input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+	input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
 	input_mt_report_pointer_emulation(dev, true);
 	input_sync(dev);
 }
@@ -1047,9 +1048,7 @@ static int elantech_set_input_params(struct

psmouse

Quoted 3 lines

*psmouse)

Quoted 2 lines
drivers/input/mouse/elantech.c +0 -0
 			 */
 			psmouse_warn(psmouse, "couldn't query resolution

data.\n");

Quoted 8 lines

drivers/input/mouse/elantech.c static struct attribute_group

Quoted 8 lines
drivers/input/mouse/elantech.c +0 -2
 		}
-		/* v4 is clickpad, with only one button. */
 		__set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
-		__clear_bit(BTN_RIGHT, dev->keybit);
 		__set_bit(BTN_TOOL_QUADTAP, dev->keybit);
 		/* For X to recognize me as touchpad. */
 		input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
@@ -1186,19 +1185,12 @@ static struct attribute_group

elantech_attr_group = {

Quoted 4 lines

drivers/input/mouse/elantech.c static struct attribute_group elantech_attr_group = {

Quoted 4 lines
drivers/input/mouse/elantech.c +0 -1
 static bool elantech_is_signature_valid(const unsigned char *param)
 {
-	static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10

};

Quoted 29 lines

drivers/input/mouse/elantech.c static int elantech_set_properties(struct

Quoted 16 lines
drivers/input/mouse/elantech.c +0 -6
-	int i;
-
 	if (param[0] == 0)
 		return false;
 
 	if (param[1] == 0)
 		return true;
 
-	for (i = 0; i < ARRAY_SIZE(rates); i++)
-		if (param[2] == rates[i])
-			return false;
-
 	return true;
 }
 
@@ -1298,6 +1290,14 @@ static int elantech_set_properties(struct

elantech_data *etd)

Quoted 12 lines
drivers/input/mouse/elantech.c +8 -0
 {
 	/* This represents the version of IC body. */
 	int ver = (etd->fw_version & 0x0f0000) >> 16;
+	/*
+	 * The signatures of v3 and v4 packets change depending on the
+	 * value of this hardware flag. But the v1 and v2 have not crc
+	 * check mechanism and the same hardware flag are also defined
+	 * as other function. So crc_enabled must be initialized as false
+	 * first and checking by different hw_version.
+	 */
+	etd->crc_enabled = false;
 
Quoted 8 lines

drivers/input/mouse/elantech.c static int elantech_set_properties(struct

Quoted 3 lines
drivers/input/mouse/elantech.c +0 -0
 	/* Early version of Elan touchpads doesn't obey the rule. */
 	if (etd->fw_version < 0x020030 || etd->fw_version == 0x020600)
@@ -1309,10 +1309,14 @@ static int elantech_set_properties(struct

elantech_data *etd)

drivers/input/mouse/elantech.c static int elantech_set_properties(struct elantech_data *etd)

Quoted 4 lines
drivers/input/mouse/elantech.c +1 -0
 			etd->hw_version = 2;
 			break;
 		case 5:
+			etd->crc_enabled = ((etd->fw_version & 0x4000) ==

0x4000);

Quoted 7 lines

drivers/input/mouse/elantech.c static int elantech_set_properties(struct elantech_data *etd)

Quoted 7 lines
drivers/input/mouse/elantech.c +3 -0
 			etd->hw_version = 3;
 			break;
 		case 6:
 		case 7:
+		case 8:
+		case 10:
+			etd->crc_enabled = ((etd->fw_version & 0x4000) ==

0x4000);

Quoted 17 lines

drivers/input/mouse/elantech.c static int elantech_set_properties(struct

Quoted 4 lines
drivers/input/mouse/elantech.c +0 -0
 			etd->hw_version = 4;
 			break;
 		default:
@@ -1343,12 +1347,6 @@ static int elantech_set_properties(struct

elantech_data *etd)

Quoted 12 lines
drivers/input/mouse/elantech.c +0 -6
 			etd->reports_pressure = true;
 	}
 
-	/*
-	 * The signatures of v3 and v4 packets change depending on the
-	 * value of this hardware flag.
-	 */
-	etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
-
 	return 0;
 }
 
Quoted 1 line

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/input/mouse/elantech.h

Quoted 20 lines
Quoted 11 lines

index 036a04a..c963ac8 100644

drivers/input/mouse/elantech.h +1 -2
@@ -1,5 +1,5 @@
 /*
- * Elantech Touchpad driver (v6)
+ * Elantech Touchpad driver (v7)
  *
  * Copyright (C) 2007-2009 Arjan Opmeer <[email protected]>
  *
--
Quoted 2 lines

1.7.10.4

--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html