diff mbox series

[1/1] input: update max sizes after setting to absolute mode

Message ID 20200427045932.GA21183@hk.localdomain
State New
Headers show
Series [1/1] input: update max sizes after setting to absolute mode | expand

Commit Message

Kutay Uner April 27, 2020, 4:59 a.m. UTC
x_max/y_max values change after we populate info struct. Using old
values causes y scroll to be half of the size of pad area. Updating these
values fixes that problem. This problem affects firmware 0x450f00 at least.

Signed-off-by: Kutay Uner <husnukutay@gmail.com>
---
diff mbox series

Patch

--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1944,6 +1944,22 @@  static int elantech_setup_ps2(struct psmouse *psmouse,
 		goto init_fail;
 	}
 
+	/* elantech_set_absolute_mode(?) causes x_max/y_max to change
+	 * at least on models using this fw. Workaround that by requerying
+	 * and setting those values at both info struct to be safe.
+	 */
+	if (info->fw_version == 0x450f00) {
+		unsigned char param[3];
+
+		if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+			goto init_fail;
+
+		info->x_max = (0x0f & param[0]) << 8 | param[1];
+		info->y_max = (0xf0 & param[0]) << 4 | param[2];
+		etd->info.x_max = info->x_max;
+		etd->info.y_max = info->y_max;
+	}
+
 	if (info->fw_version == 0x381f17) {
 		etd->original_set_rate = psmouse->set_rate;
 		psmouse->set_rate = elantech_set_rate_restore_reg_07;