Skip to contentSkip to conversation

synaptics: match PNP-Id is not sufficient for min/max quirks

PATCH In review Benjamin Tissoires 4 participants 12 messages Feb 6, 2015 – Mar 9, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover synaptics: match PNP-Id is not sufficient for min/max quirks

Hi,

Here is the v4 of Daniel's patch series regarding
https://bugzilla.kernel.org/show_bug.cgi?id=91541

I am resending the whole series to add the "cc: stable@" flags and to fix v3 5/5 which did not applied properly on top of input.git/for-next.

Cheers,
Benjamin

Benjamin Tissoires (1):
Input: synaptics - Skip quirks when post-2013 dimensions

Daniel Martin (5):
Input: synaptics - Split synaptics_resolution(), query first
Input: synaptics - Log queried and quirked dimension values
Input: synaptics - Query min dimensions for fw v8.1
Input: synaptics - Remove obsolete min/max quirk for X240
Input: synaptics - Support min/max board id in min_max_pnpid_table

 drivers/input/mouse/synaptics.c | 79 +++++++++++++++++++++++++++++++++--------
 1 file changed, 64 insertions(+), 15 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH v4 1/6 Input: synaptics - Split synaptics_resolution(), query first

From: Daniel Martin <[email protected]>

Split the function synaptics_resolution() into
synaptics_resolution() and synaptics_quirks().

synaptics_resolution() will be called before synaptics_quirks() to query dimensions and resolutions before overwriting them with quirks.

---

v2: Removed SYN_ID_MAJOR() check from synaptics_quirks().

 drivers/input/mouse/synaptics.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)
drivers/input/mouse/synaptics.c +25 -12
index 7e705ee..8c2b343 100644
@@ -346,7 +346,6 @@ static int synaptics_resolution(struct psmouse *psmouse)
 {
 	struct synaptics_data *priv = psmouse->private;
 	unsigned char resp[3];
-	int i;
 
 	if (SYN_ID_MAJOR(priv->identity) < 4)
 		return 0;
@@ -358,17 +357,6 @@ static int synaptics_resolution(struct psmouse *psmouse)
 		}
 	}
 
-	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
-		if (psmouse_matches_pnp_id(psmouse,
-					   min_max_pnpid_table[i].pnp_ids)) {
-			priv->x_min = min_max_pnpid_table[i].x_min;
-			priv->x_max = min_max_pnpid_table[i].x_max;
-			priv->y_min = min_max_pnpid_table[i].y_min;
-			priv->y_max = min_max_pnpid_table[i].y_max;
-			return 0;
-		}
-	}
-
 	if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 &&
 	    SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) {
 		if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp)) {
@@ -394,6 +382,29 @@ static int synaptics_resolution(struct psmouse *psmouse)
 	return 0;
 }
 
+/*
+ * Apply quirk(s) if the hardware matches
+ */
+
+static int synaptics_quirks(struct psmouse *psmouse)
+{
+	struct synaptics_data *priv = psmouse->private;
+	int i;
+
+	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
+		if (psmouse_matches_pnp_id(psmouse,
+					   min_max_pnpid_table[i].pnp_ids)) {
+			priv->x_min = min_max_pnpid_table[i].x_min;
+			priv->x_max = min_max_pnpid_table[i].x_max;
+			priv->y_min = min_max_pnpid_table[i].y_min;
+			priv->y_max = min_max_pnpid_table[i].y_max;
+			break;
+		}
+	}
+
+	return 0;
+}
+
 static int synaptics_query_hardware(struct psmouse *psmouse)
 {
 	if (synaptics_identify(psmouse))
@@ -408,6 +419,8 @@ static int synaptics_query_hardware(struct psmouse *psmouse)
 		return -1;
 	if (synaptics_resolution(psmouse))
 		return -1;
+	if (synaptics_quirks(psmouse))
+		return -1;
 
 	return 0;
 }
Signature · 1 line
2.1.0
maintainer
#2 lore raw

Re: [PATCH v4 1/6] Input: synaptics - Split synaptics_resolution(), query first

Quoted 48 lines · Benjamin Tissoires

From: Daniel Martin <[email protected]>

Split the function synaptics_resolution() into
synaptics_resolution() and synaptics_quirks().

synaptics_resolution() will be called before synaptics_quirks() to query dimensions and resolutions before overwriting them with quirks.

---

v2: Removed SYN_ID_MAJOR() check from synaptics_quirks().

 drivers/input/mouse/synaptics.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)
drivers/input/mouse/synaptics.c +0 -12
index 7e705ee..8c2b343 100644
@@ -346,7 +346,6 @@ static int synaptics_resolution(struct psmouse *psmouse)
 {
 	struct synaptics_data *priv = psmouse->private;
 	unsigned char resp[3];
-	int i;
 
 	if (SYN_ID_MAJOR(priv->identity) < 4)
 		return 0;
@@ -358,17 +357,6 @@ static int synaptics_resolution(struct psmouse *psmouse)
 		}
 	}
 
-	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
-		if (psmouse_matches_pnp_id(psmouse,
-					   min_max_pnpid_table[i].pnp_ids)) {
-			priv->x_min = min_max_pnpid_table[i].x_min;
-			priv->x_max = min_max_pnpid_table[i].x_max;
-			priv->y_min = min_max_pnpid_table[i].y_min;
-			priv->y_max = min_max_pnpid_table[i].y_max;
-			return 0;
-		}
-	}
-
 	if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 &&
 	    SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) {
 		if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp)) {

drivers/input/mouse/synaptics.c static int synaptics_resolution(struct psmouse *psmouse) · line 389

Quoted 8 lines
drivers/input/mouse/synaptics.c +5 -0
@@ -394,6 +382,29 @@ static int synaptics_resolution(struct psmouse *psmouse)
 	return 0;
 }
 
+/*
+ * Apply quirk(s) if the hardware matches
+ */
+
+static int synaptics_quirks(struct psmouse *psmouse)

This function does not seem to ever failing and does not access the hardware so I switched it to be void.

Thanks.

Quoted 33 lines
drivers/input/mouse/synaptics.c +20 -0
+{
+	struct synaptics_data *priv = psmouse->private;
+	int i;
+
+	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
+		if (psmouse_matches_pnp_id(psmouse,
+					   min_max_pnpid_table[i].pnp_ids)) {
+			priv->x_min = min_max_pnpid_table[i].x_min;
+			priv->x_max = min_max_pnpid_table[i].x_max;
+			priv->y_min = min_max_pnpid_table[i].y_min;
+			priv->y_max = min_max_pnpid_table[i].y_max;
+			break;
+		}
+	}
+
+	return 0;
+}
+
 static int synaptics_query_hardware(struct psmouse *psmouse)
 {
 	if (synaptics_identify(psmouse))
@@ -408,6 +419,8 @@ static int synaptics_query_hardware(struct psmouse *psmouse)
 		return -1;
 	if (synaptics_resolution(psmouse))
 		return -1;
+	if (synaptics_quirks(psmouse))
+		return -1;
 
 	return 0;
 }
Signature · 1 line
2.1.0
Signature · 1 line
Dmitry
#3 lore raw

PATCH v4 2/6 Input: synaptics - Log queried and quirked dimension values

In reply to Benjamin Tissoires

From: Daniel Martin <[email protected]>

Logging the dimension values we queried (info) and the values we use from a quirk to overwrite (warn) can be helpful for debugging.

This partly relates to bug:

    https://bugzilla.kernel.org/show_bug.cgi?id=91541
---
 drivers/input/mouse/synaptics.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/input/mouse/synaptics.c +13 -0
index 8c2b343..0485e6b 100644
@@ -365,6 +365,10 @@ static int synaptics_resolution(struct psmouse *psmouse)
 		} else {
 			priv->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);
 			priv->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);
+			psmouse_info(psmouse,
+				     "queried max coordinates: "
+				     "x [..%d], y [..%d]\n",
+				     priv->x_max, priv->y_max);
 		}
 	}
 
@@ -376,6 +380,10 @@ static int synaptics_resolution(struct psmouse *psmouse)
 		} else {
 			priv->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);
 			priv->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);
+			psmouse_info(psmouse,
+				     "queried min coordinates: "
+				     "x [%d..], y [%d..]\n",
+				     priv->x_min, priv->y_min);
 		}
 	}
 
@@ -398,6 +406,11 @@ static int synaptics_quirks(struct psmouse *psmouse)
 			priv->x_max = min_max_pnpid_table[i].x_max;
 			priv->y_min = min_max_pnpid_table[i].y_min;
 			priv->y_max = min_max_pnpid_table[i].y_max;
+			psmouse_warn(psmouse,
+				     "quirked min/max coordinates: "
+				     "x [%d..%d], y [%d..%d]\n",
+				     priv->x_min, priv->x_max,
+				     priv->y_min, priv->y_max);
 			break;
 		}
 	}
Signature · 1 line
2.1.0
maintainer
#4 lore raw

Re: [PATCH v4 2/6] Input: synaptics - Log queried and quirked dimension values

Quoted 4 lines · Benjamin Tissoires

From: Daniel Martin <[email protected]>

Logging the dimension values we queried (info) and the values we use from a quirk to overwrite (warn) can be helpful for debugging.

Warnings should be sed when something goes wrong, not during normal operations. Switched all to info and merged split strings.

Thanks.

Quoted 51 lines

This partly relates to bug:

    https://bugzilla.kernel.org/show_bug.cgi?id=91541
---
 drivers/input/mouse/synaptics.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/input/mouse/synaptics.c +13 -0
index 8c2b343..0485e6b 100644
@@ -365,6 +365,10 @@ static int synaptics_resolution(struct psmouse *psmouse)
 		} else {
 			priv->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);
 			priv->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);
+			psmouse_info(psmouse,
+				     "queried max coordinates: "
+				     "x [..%d], y [..%d]\n",
+				     priv->x_max, priv->y_max);
 		}
 	}
 
@@ -376,6 +380,10 @@ static int synaptics_resolution(struct psmouse *psmouse)
 		} else {
 			priv->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);
 			priv->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);
+			psmouse_info(psmouse,
+				     "queried min coordinates: "
+				     "x [%d..], y [%d..]\n",
+				     priv->x_min, priv->y_min);
 		}
 	}
 
@@ -398,6 +406,11 @@ static int synaptics_quirks(struct psmouse *psmouse)
 			priv->x_max = min_max_pnpid_table[i].x_max;
 			priv->y_min = min_max_pnpid_table[i].y_min;
 			priv->y_max = min_max_pnpid_table[i].y_max;
+			psmouse_warn(psmouse,
+				     "quirked min/max coordinates: "
+				     "x [%d..%d], y [%d..%d]\n",
+				     priv->x_min, priv->x_max,
+				     priv->y_min, priv->y_max);
 			break;
 		}
 	}
Signature · 1 line
2.1.0
Signature · 1 line
Dmitry
#5 lore raw

PATCH v4 3/6 Input: synaptics - Query min dimensions for fw v8.1

In reply to Benjamin Tissoires

From: Daniel Martin <[email protected]>

Query the min dimensions even if the check

    SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7

fails, but we know that the firmware version 8.1 is safe.

With that we don't need quirks for post-2013 models anymore as they expose correct min and max dimensions.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541

re-order the tests to check SYN_CAP_MIN_DIMENSIONS even on FW 8.1

---
v2: Don't use a list for safe firmwares.

 drivers/input/mouse/synaptics.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/input/mouse/synaptics.c +7 -2
index 0485e6b..19dc87f 100644
@@ -372,8 +372,13 @@ static int synaptics_resolution(struct psmouse *psmouse)
 		}
 	}
 
-	if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 &&
-	    SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c)) {
+	if (SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c) &&
+	    (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 ||
+	     /* Firmware v8.1 doesn't stand the previous checks, though has
+	      * been proven to report correct min coordinates.
+	      *     https://bugzilla.kernel.org/show_bug.cgi?id=91541 */
+	     (SYN_ID_MAJOR(priv->identity) == 8 &&
+	      SYN_ID_MINOR(priv->identity) == 1))) {
 		if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) {
 			psmouse_warn(psmouse,
 				     "device claims to have min coordinates query, but I'm not able to read it.\n");
Signature · 1 line
2.1.0
#6 lore raw

Re: [PATCH v4 3/6] Input: synaptics - Query min dimensions for fw v8.1

Quoted 28 lines · Benjamin Tissoires

From: Daniel Martin <[email protected]>

Query the min dimensions even if the check

     SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7

fails, but we know that the firmware version 8.1 is safe.

With that we don't need quirks for post-2013 models anymore as they expose correct min and max dimensions.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541

re-order the tests to check SYN_CAP_MIN_DIMENSIONS even on FW 8.1

---
v2: Don't use a list for safe firmwares.

  drivers/input/mouse/synaptics.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/input/mouse/synaptics.c +0 -0
index 0485e6b..19dc87f 100644
@@ -372,8 +372,13 @@ static int synaptics_resolution(struct psmouse *psmouse)
  		}
  	}

drivers/input/mouse/synaptics.c static int synaptics_resolution(struct psmouse *psmouse) · line 381

Quoted 10 lines
drivers/input/mouse/synaptics.c +7 -2
 
-	if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 &&
-	    SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c)) {
+	if (SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c) &&
+	    (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 ||
+	     /* Firmware v8.1 doesn't stand the previous checks, though has
+	      * been proven to report correct min coordinates.
+	      *     https://bugzilla.kernel.org/show_bug.cgi?id=91541 */
+	     (SYN_ID_MAJOR(priv->identity) == 8 &&
+	      SYN_ID_MINOR(priv->identity) == 1))) {

Hmm... this can be actually read as:
+ SYN_ID_FULL(priv->identity) == 0x801)) {

Cheers,
Benjamin

Quoted 4 lines
drivers/input/mouse/synaptics.c +0 -0
  		if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) {
  			psmouse_warn(psmouse,
  				     "device claims to have min coordinates query, but I'm not able to read it.\n");
Acked-by
#7 lore raw

Re: [PATCH v4 3/6] Input: synaptics - Query min dimensions for fw v8.1

Hi,

Quoted 32 lines · Benjamin Tissoires
Quoted 29 lines · Benjamin Tissoires

From: Daniel Martin <[email protected]>

Query the min dimensions even if the check

     SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7

fails, but we know that the firmware version 8.1 is safe.

With that we don't need quirks for post-2013 models anymore as they expose correct min and max dimensions.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541

re-order the tests to check SYN_CAP_MIN_DIMENSIONS even on FW 8.1

---
v2: Don't use a list for safe firmwares.

  drivers/input/mouse/synaptics.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/input/mouse/synaptics.c +0 -0
index 0485e6b..19dc87f 100644
@@ -372,8 +372,13 @@ static int synaptics_resolution(struct psmouse *psmouse)
          }
      }
 
Quoted 12 lines

drivers/input/mouse/synaptics.c static int synaptics_resolution(struct psmouse *psmouse) · line 381

Quoted 9 lines
drivers/input/mouse/synaptics.c +7 -2
-    if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 &&
-        SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c)) {
+    if (SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c) &&
+        (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 ||
+         /* Firmware v8.1 doesn't stand the previous checks, though has
+          * been proven to report correct min coordinates.
+          *     https://bugzilla.kernel.org/show_bug.cgi?id=91541 */
+         (SYN_ID_MAJOR(priv->identity) == 8 &&
+          SYN_ID_MINOR(priv->identity) == 1))) {

Hmm... this can be actually read as:
+ SYN_ID_FULL(priv->identity) == 0x801)) {

And "checks" should be just "check" as the firmware check only is or-ed together with the >= 7 check (which is intentional but the comment suggests wrongly that it overrides both check_s_ .

Other then that the entire series looks good and is:

Regards,

Hans

Quoted 8 lines

Cheers,
Benjamin

Quoted 4 lines
drivers/input/mouse/synaptics.c +0 -0
          if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) {
              psmouse_warn(psmouse,
                       "device claims to have min coordinates query, but I'm not able to read it.\n");
maintainer
#8 lore raw

Re: [PATCH v4 3/6] Input: synaptics - Query min dimensions for fw v8.1

Quoted 48 lines · Hans de Goede

Hi,

Quoted 32 lines · Benjamin Tissoires
Quoted 29 lines · Benjamin Tissoires

From: Daniel Martin <[email protected]>

Query the min dimensions even if the check

     SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7

fails, but we know that the firmware version 8.1 is safe.

With that we don't need quirks for post-2013 models anymore as they expose correct min and max dimensions.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541

re-order the tests to check SYN_CAP_MIN_DIMENSIONS even on FW 8.1

---
v2: Don't use a list for safe firmwares.

  drivers/input/mouse/synaptics.c | 9 +++++++--
  1 file changed, 7 insertions(+), 2 deletions(-)
drivers/input/mouse/synaptics.c +0 -0
index 0485e6b..19dc87f 100644
@@ -372,8 +372,13 @@ static int synaptics_resolution(struct psmouse *psmouse)
          }
      }
 
Quoted 12 lines

drivers/input/mouse/synaptics.c static int synaptics_resolution(struct psmouse *psmouse) · line 381

Quoted 9 lines
drivers/input/mouse/synaptics.c +7 -2
-    if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 &&
-        SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c)) {
+    if (SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c) &&
+        (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 ||
+         /* Firmware v8.1 doesn't stand the previous checks, though has
+          * been proven to report correct min coordinates.
+          *     https://bugzilla.kernel.org/show_bug.cgi?id=91541 */
+         (SYN_ID_MAJOR(priv->identity) == 8 &&
+          SYN_ID_MINOR(priv->identity) == 1))) {

Hmm... this can be actually read as:
+ SYN_ID_FULL(priv->identity) == 0x801)) {

Quoted 7 lines

And "checks" should be just "check" as the firmware check only is or-ed together with the >= 7 check (which is intentional but the comment suggests wrongly that it overrides both check_s_ .

Other then that the entire series looks good and is:

Adjusted to use SYN_ID_FULL and adjusted the comment as well.

Quoted 14 lines

Regards,

Hans

Quoted 8 lines

Cheers,
Benjamin

Quoted 4 lines
drivers/input/mouse/synaptics.c +0 -0
          if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) {
              psmouse_warn(psmouse,
                       "device claims to have min coordinates query, but I'm not able to read it.\n");
Signature · 1 line
Dmitry
#9 lore raw

PATCH v4 4/6 Input: synaptics - Remove obsolete min/max quirk for X240

In reply to Benjamin Tissoires

From: Daniel Martin <[email protected]>

The firmware of the X240 (LEN0035, 2013/12) exposes the same values

    x [1232..5710], y [1156..4696]

as the quirk applies.

---
 drivers/input/mouse/synaptics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/synaptics.c +1 -1
index 19dc87f..359e26d 100644
@@ -134,7 +134,7 @@ static const struct min_max_quirk min_max_pnpid_table[] = {
 		1024, 5052, 2258, 4832
 	},
 	{
-		(const char * const []){"LEN0035", "LEN0042", NULL},
+		(const char * const []){"LEN0042", NULL},
 		1232, 5710, 1156, 4696
 	},
 	{
Signature · 1 line
2.1.0
#10 lore raw

PATCH v4 5/6 Input: synaptics - Support min/max board id in min_max_pnpid_table

In reply to Benjamin Tissoires

From: Daniel Martin <[email protected]>

Add a min/max range for board ids to the min/max coordinates quirk. This makes it possible to restrict quirks to specific models based upon their board id. The define ANY_BOARD_ID (0) serves as a wildcard.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541

---
 drivers/input/mouse/synaptics.c | 44 +++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 13 deletions(-)
drivers/input/mouse/synaptics.c +31 -13
index 359e26d..b02000f 100644
@@ -123,32 +123,41 @@ void synaptics_reset(struct psmouse *psmouse)
 
 static bool cr48_profile_sensor;
 
+#define ANY_BOARD_ID 0
 struct min_max_quirk {
 	const char * const *pnp_ids;
+	struct {
+		unsigned long int min, max;
+	} board_id;
 	int x_min, x_max, y_min, y_max;
 };
 
 static const struct min_max_quirk min_max_pnpid_table[] = {
 	{
 		(const char * const []){"LEN0033", NULL},
+		{ANY_BOARD_ID, ANY_BOARD_ID},
 		1024, 5052, 2258, 4832
 	},
 	{
 		(const char * const []){"LEN0042", NULL},
+		{ANY_BOARD_ID, ANY_BOARD_ID},
 		1232, 5710, 1156, 4696
 	},
 	{
 		(const char * const []){"LEN0034", "LEN0036", "LEN0037",
 					"LEN0039", "LEN2002", "LEN2004",
 					NULL},
+		{ANY_BOARD_ID, ANY_BOARD_ID},
 		1024, 5112, 2024, 4832
 	},
 	{
 		(const char * const []){"LEN2001", NULL},
+		{ANY_BOARD_ID, ANY_BOARD_ID},
 		1024, 5022, 2508, 4832
 	},
 	{
 		(const char * const []){"LEN2006", NULL},
+		{ANY_BOARD_ID, ANY_BOARD_ID},
 		1264, 5675, 1171, 4688
 	},
 	{ }
@@ -405,19 +414,28 @@ static int synaptics_quirks(struct psmouse *psmouse)
 	int i;
 
 	for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
-		if (psmouse_matches_pnp_id(psmouse,
-					   min_max_pnpid_table[i].pnp_ids)) {
-			priv->x_min = min_max_pnpid_table[i].x_min;
-			priv->x_max = min_max_pnpid_table[i].x_max;
-			priv->y_min = min_max_pnpid_table[i].y_min;
-			priv->y_max = min_max_pnpid_table[i].y_max;
-			psmouse_warn(psmouse,
-				     "quirked min/max coordinates: "
-				     "x [%d..%d], y [%d..%d]\n",
-				     priv->x_min, priv->x_max,
-				     priv->y_min, priv->y_max);
-			break;
-		}
+		if (!psmouse_matches_pnp_id(psmouse,
+					    min_max_pnpid_table[i].pnp_ids))
+			continue;
+
+		if (min_max_pnpid_table[i].board_id.min != ANY_BOARD_ID &&
+		    priv->board_id < min_max_pnpid_table[i].board_id.min)
+			continue;
+
+		if (min_max_pnpid_table[i].board_id.max != ANY_BOARD_ID &&
+		    priv->board_id > min_max_pnpid_table[i].board_id.max)
+			continue;
+
+		priv->x_min = min_max_pnpid_table[i].x_min;
+		priv->x_max = min_max_pnpid_table[i].x_max;
+		priv->y_min = min_max_pnpid_table[i].y_min;
+		priv->y_max = min_max_pnpid_table[i].y_max;
+		psmouse_warn(psmouse,
+			     "quirked min/max coordinates: "
+			     "x [%d..%d], y [%d..%d]\n",
+			     priv->x_min, priv->x_max,
+			     priv->y_min, priv->y_max);
+		break;
 	}
 
 	return 0;
Signature · 1 line
2.1.0
#11 lore raw

PATCH v4 6/6 Input: synaptics - Skip quirks when post-2013 dimensions

In reply to Benjamin Tissoires

post-2013 Lenovo laptops provide correct min/max dimensions, which are different with the ones currently quirked. According to https://bugzilla.kernel.org/show_bug.cgi?id=91541
The following board ids are assigned in the post-2013 touchpads:

t440p/t440s: LEN0036 -> 2964/2962
t540p:       LEN0034 -> 2964

Using 2961 as the common minimum makes these 3 laptops OK. We may need to update those values later if other pnp_ids has a lower board_id.

---
 drivers/input/mouse/synaptics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/synaptics.c +1 -1
index b02000f..d5c120b 100644
@@ -147,7 +147,7 @@ static const struct min_max_quirk min_max_pnpid_table[] = {
 		(const char * const []){"LEN0034", "LEN0036", "LEN0037",
 					"LEN0039", "LEN2002", "LEN2004",
 					NULL},
-		{ANY_BOARD_ID, ANY_BOARD_ID},
+		{ANY_BOARD_ID, 2961},
 		1024, 5112, 2024, 4832
 	},
 	{
Signature · 1 line
2.1.0