Skip to contentSkip to conversation

Input: elan_i2c - High resolution report for new pattern 2

PATCH New Dave Wang 1 participant 1 message Jan 14, 2020

Subsystems (2)
lore
Share & tools
lore

Dave Wang

author
#0 lore raw

PATCH 2/3 Input: elan_i2c - High resolution report for new pattern 2

Due to the higer resolution touchpads would be produced, The mainly modifications were as below:
1. the former resolution bits were not enough. Extend the resolution bits from 12 to 16 bits.
2. Increase the report ID 0x60 for higher resoltion of touchpads.
3. Move the position of mk value in report packet.

---
 drivers/input/mouse/elan_i2c.h       |   4 +-
 drivers/input/mouse/elan_i2c_core.c  | 131 +++++++++++++++++++++++----
 drivers/input/mouse/elan_i2c_i2c.c   |  35 +++++--
 drivers/input/mouse/elan_i2c_smbus.c |  29 ++++--
 4 files changed, 165 insertions(+), 34 deletions(-)
drivers/input/mouse/elan_i2c.h +3 -1
index a9074ac9364f..aa0c6cfd2690 100644
@@ -78,7 +78,9 @@ struct elan_transport_ops {
 	int (*finish_fw_update)(struct i2c_client *client,
 				struct completion *reset_done);
 
-	int (*get_report)(struct i2c_client *client, u8 *report);
+	int (*get_report_length)(struct i2c_client *client, int *report_len);
+	int (*get_report)(struct i2c_client *client, u8 *report,
+					int report_len);
 	int (*get_pressure_adjustment)(struct i2c_client *client,
 				       int *adjustment);
 	int (*get_pattern)(struct i2c_client *client, u8 *pattern);
drivers/input/mouse/elan_i2c_core.c +114 -17

241 lines not on this page · raw message

drivers/input/mouse/elan_i2c_i2c.c +29 -6
index 249d48057423..188b4915fe82 100644
@@ -55,6 +55,7 @@
 #define ETP_I2C_MIN_BASELINE_CMD	0x0318
 
 #define ETP_I2C_REPORT_LEN		34
+#define ETP_I2C_REPORT_LEN_ID2		39
 #define ETP_I2C_DESC_LENGTH		30
 #define ETP_I2C_REPORT_DESC_LENGTH	158
 #define ETP_I2C_INF_LENGTH		2
@@ -393,7 +394,7 @@ static int elan_i2c_get_max(struct i2c_client *client,
 		return error;
 	}
 
-	*max_x = le16_to_cpup((__le16 *)val) & 0x0fff;
+	*max_x = le16_to_cpup((__le16 *)val) & 0xffff;
 
 	error = elan_i2c_read_cmd(client, ETP_I2C_MAX_Y_AXIS_CMD, val);
 	if (error) {
@@ -401,7 +402,7 @@ static int elan_i2c_get_max(struct i2c_client *client,
 		return error;
 	}
 
-	*max_y = le16_to_cpup((__le16 *)val) & 0x0fff;
+	*max_y = le16_to_cpup((__le16 *)val) & 0xffff;
 
 	return 0;
 }
@@ -663,20 +664,41 @@ static int elan_i2c_finish_fw_update(struct i2c_client *client,
 	return 0;
 }
 
-static int elan_i2c_get_report(struct i2c_client *client, u8 *report)
+static int elan_i2c_get_report_length(struct i2c_client *client,
+					int *report_len)
+{
+	int error;
+	u8 pattern_ver;
+
+	error = elan_i2c_get_pattern(client, &pattern_ver);
+	if (error) {
+		dev_err(&client->dev, "failed to get pattern version\n");
+		return error;
+	}
+
+	if (pattern_ver <= 0x01)
+		*report_len = ETP_I2C_REPORT_LEN;
+	else
+		*report_len = ETP_I2C_REPORT_LEN_ID2;
+
+	return 0;
+}
+
+static int elan_i2c_get_report(struct i2c_client *client,
+					u8 *report, int report_len)
 {
 	int len;
 
-	len = i2c_master_recv(client, report, ETP_I2C_REPORT_LEN);
+	len = i2c_master_recv(client, report, report_len);
 	if (len < 0) {
 		dev_err(&client->dev, "failed to read report data: %d\n", len);
 		return len;
 	}
 
-	if (len != ETP_I2C_REPORT_LEN) {
+	if (len != report_len) {
 		dev_err(&client->dev,
 			"wrong report length (%d vs %d expected)\n",
-			len, ETP_I2C_REPORT_LEN);
+			len, report_len);
 		return -EIO;
 	}
 
@@ -713,5 +735,6 @@ const struct elan_transport_ops elan_i2c_ops = {
 
 	.get_pattern		= elan_i2c_get_pattern,
 
+	.get_report_length	= elan_i2c_get_report_length,
 	.get_report		= elan_i2c_get_report,
 };
drivers/input/mouse/elan_i2c_smbus.c +19 -10
index 8c3185d54c73..de14345c5f34 100644
@@ -153,9 +153,9 @@ static int elan_smbus_get_version(struct i2c_client *client,
 	u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
 
 	error = i2c_smbus_read_block_data(client,
-					  iap ? ETP_SMBUS_IAP_VERSION_CMD :
-						ETP_SMBUS_FW_VERSION_CMD,
-					  val);
+			iap ? ETP_SMBUS_IAP_VERSION_CMD :
+			ETP_SMBUS_FW_VERSION_CMD,
+			val);
 	if (error < 0) {
 		dev_err(&client->dev, "failed to get %s version: %d\n",
 			iap ? "IAP" : "FW", error);
@@ -174,7 +174,7 @@ static int elan_smbus_get_sm_version(struct i2c_client *client,
 	u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
 
 	error = i2c_smbus_read_block_data(client,
-					  ETP_SMBUS_SM_VERSION_CMD, val);
+					ETP_SMBUS_SM_VERSION_CMD, val);
 	if (error < 0) {
 		dev_err(&client->dev, "failed to get SM version: %d\n", error);
 		return error;
@@ -192,7 +192,7 @@ static int elan_smbus_get_product_id(struct i2c_client *client, u16 *id)
 	u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
 
 	error = i2c_smbus_read_block_data(client,
-					  ETP_SMBUS_UNIQUEID_CMD, val);
+					ETP_SMBUS_UNIQUEID_CMD, val);
 	if (error < 0) {
 		dev_err(&client->dev, "failed to get product ID: %d\n", error);
 		return error;
@@ -209,9 +209,9 @@ static int elan_smbus_get_checksum(struct i2c_client *client,
 	u8 val[I2C_SMBUS_BLOCK_MAX] = {0};
 
 	error = i2c_smbus_read_block_data(client,
-					  iap ? ETP_SMBUS_FW_CHECKSUM_CMD :
-						ETP_SMBUS_IAP_CHECKSUM_CMD,
-					  val);
+				iap ? ETP_SMBUS_FW_CHECKSUM_CMD :
+					ETP_SMBUS_IAP_CHECKSUM_CMD,
+					val);
 	if (error < 0) {
 		dev_err(&client->dev, "failed to get %s checksum: %d\n",
 			iap ? "IAP" : "FW", error);
@@ -415,7 +415,7 @@ static int elan_smbus_prepare_fw_update(struct i2c_client *client)
 
 
 static int elan_smbus_write_fw_block(struct i2c_client *client,
-				     const u8 *page, u16 checksum, int idx)
+					 const u8 *page, u16 checksum, int idx)
 {
 	struct device *dev = &client->dev;
 	int error;
@@ -469,7 +469,15 @@ static int elan_smbus_write_fw_block(struct i2c_client *client,
 	return 0;
 }
 
-static int elan_smbus_get_report(struct i2c_client *client, u8 *report)
+static int elan_smbus_get_report_length(struct i2c_client *client,
+					int *report_len)
+{
+	*report_len = ETP_SMBUS_REPORT_LEN;
+	return 0;
+}
+
+static int elan_smbus_get_report(struct i2c_client *client,
+				u8 *report, int report_len)
 {
 	int len;
 
@@ -534,6 +542,7 @@ const struct elan_transport_ops elan_smbus_ops = {
 	.write_fw_block		= elan_smbus_write_fw_block,
 	.finish_fw_update	= elan_smbus_finish_fw_update,
 
+	.get_report_length	= elan_smbus_get_report_length,
 	.get_report		= elan_smbus_get_report,
 	.get_pattern		= elan_smbus_get_pattern,
 };
Signature · 1 line
2.17.1