Skip to contentSkip to conversation

ideapad: DMI quirk for touchpad control

PATCH In review João Paulo Rechi Vita 3 participants 5 messages Jun 6, 2016 – Jun 10, 2016 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ideapad: DMI quirk for touchpad control

Don't try to control the touchpad on laptops that do not support it, as it leads to sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.

---
 drivers/platform/x86/ideapad-laptop.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/platform/x86/ideapad-laptop.c +26 -0
index 06a837a..6270948 100644
@@ -93,6 +93,7 @@ struct ideapad_private {
 	struct dentry *debug;
 	unsigned long cfg;
 	bool has_hw_rfkill_switch;
+	bool has_tp_ctrl;
 };
 
 static bool no_bt_rfkill;
@@ -773,6 +774,9 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
 {
 	unsigned long value;
 
+	if (!priv->has_tp_ctrl)
+		return;
+
 	/* Without reading from EC touchpad LED doesn't switch state */
 	if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
 		/* Some IdeaPads don't really turn off touchpad - they only
@@ -930,6 +934,27 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
 	{}
 };
 
+/*
+ * Avoid sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.
+ */
+static const struct dmi_system_id no_tp_ctrl_list[] = {
+	{
+		.ident = "Lenovo 80HE", /* Yoga 3 Pro 2 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "80HE"),
+		},
+	},
+	{
+		.ident = "Lenovo 80MK", /* Yoga 900 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "80MK"),
+		},
+	},
+	{}
+};
+
 static int ideapad_acpi_add(struct platform_device *pdev)
 {
 	int ret, i;
@@ -953,6 +978,7 @@ static int ideapad_acpi_add(struct platform_device *pdev)
 	priv->adev = adev;
 	priv->platform_device = pdev;
 	priv->has_hw_rfkill_switch = !dmi_check_system(no_hw_rfkill_list);
+	priv->has_tp_ctrl = !dmi_check_system(no_tp_ctrl_list);
 
 	ret = ideapad_sysfs_init(priv);
 	if (ret)
Signature · 1 line
2.5.0
#1 lore raw
Quoted 3 lines · João Paulo Rechi Vita

Don't try to control the touchpad on laptops that do not support it, as it leads to sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.

Other than some minor comment clarity/grammar, this looks like a reasonable approach to get the new models working without risking breakage to the older models. I'll correct.

Maxim, Ike? OK with this approach?

Quoted 68 lines
---
 drivers/platform/x86/ideapad-laptop.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/platform/x86/ideapad-laptop.c +26 -0
index 06a837a..6270948 100644
@@ -93,6 +93,7 @@ struct ideapad_private {
 	struct dentry *debug;
 	unsigned long cfg;
 	bool has_hw_rfkill_switch;
+	bool has_tp_ctrl;
 };
 
 static bool no_bt_rfkill;
@@ -773,6 +774,9 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
 {
 	unsigned long value;
 
+	if (!priv->has_tp_ctrl)
+		return;
+
 	/* Without reading from EC touchpad LED doesn't switch state */
 	if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
 		/* Some IdeaPads don't really turn off touchpad - they only
@@ -930,6 +934,27 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
 	{}
 };
 
+/*
+ * Avoid sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.
+ */
+static const struct dmi_system_id no_tp_ctrl_list[] = {
+	{
+		.ident = "Lenovo 80HE", /* Yoga 3 Pro 2 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "80HE"),
+		},
+	},
+	{
+		.ident = "Lenovo 80MK", /* Yoga 900 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "80MK"),
+		},
+	},
+	{}
+};
+
 static int ideapad_acpi_add(struct platform_device *pdev)
 {
 	int ret, i;
@@ -953,6 +978,7 @@ static int ideapad_acpi_add(struct platform_device *pdev)
 	priv->adev = adev;
 	priv->platform_device = pdev;
 	priv->has_hw_rfkill_switch = !dmi_check_system(no_hw_rfkill_list);
+	priv->has_tp_ctrl = !dmi_check_system(no_tp_ctrl_list);
 
 	ret = ideapad_sysfs_init(priv);
 	if (ret)
Signature · 1 line
2.5.0
Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#2 lore raw

2016-06-09 1:07 GMT+03:00 Darren Hart <[email protected]>:

Quoted 10 lines · João Paulo Rechi Vita
Quoted 3 lines

Don't try to control the touchpad on laptops that do not support it, as it leads to sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.

Other than some minor comment clarity/grammar, this looks like a reasonable approach to get the new models working without risking breakage to the older models. I'll correct.

Maxim, Ike? OK with this approach?

Looks good for me.

Quoted 72 lines
Quoted 65 lines
---
 drivers/platform/x86/ideapad-laptop.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/platform/x86/ideapad-laptop.c +26 -1
index 06a837a..6270948 100644
@@ -93,6 +93,7 @@ struct ideapad_private {
      struct dentry *debug;
      unsigned long cfg;
      bool has_hw_rfkill_switch;
+     bool has_tp_ctrl;
 };
 
 static bool no_bt_rfkill;
@@ -773,6 +774,9 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
 {
      unsigned long value;
 
+     if (!priv->has_tp_ctrl)
+             return;
+
      /* Without reading from EC touchpad LED doesn't switch state */
      if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
              /* Some IdeaPads don't really turn off touchpad - they only
@@ -930,6 +934,27 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
      {}
 };
 
+/*
+ * Avoid sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.
+ */
+static const struct dmi_system_id no_tp_ctrl_list[] = {
+     {
+             .ident = "Lenovo 80HE", /* Yoga 3 Pro 2 */
+             .matches = {
+                     DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+                     DMI_MATCH(DMI_PRODUCT_NAME, "80HE"),
+             },
+     },
+     {
+             .ident = "Lenovo 80MK", /* Yoga 900 */
+             .matches = {
+                     DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+                     DMI_MATCH(DMI_PRODUCT_NAME, "80MK"),
+             },
+     },
+     {}
+};
+
 static int ideapad_acpi_add(struct platform_device *pdev)
 {
      int ret, i;
@@ -953,6 +978,7 @@ static int ideapad_acpi_add(struct platform_device *pdev)
      priv->adev = adev;
      priv->platform_device = pdev;
      priv->has_hw_rfkill_switch = !dmi_check_system(no_hw_rfkill_list);
+     priv->has_tp_ctrl = !dmi_check_system(no_tp_ctrl_list);
 
      ret = ideapad_sysfs_init(priv);
      if (ret)
--
Quoted 3 lines

2.5.0

--
Darren Hart
Intel Open Source Technology Center

#3 lore raw
In reply to João Paulo Rechi Vita
Quoted 42 lines · João Paulo Rechi Vita

Don't try to control the touchpad on laptops that do not support it, as it leads to sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.

---
 drivers/platform/x86/ideapad-laptop.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/platform/x86/ideapad-laptop.c +11 -0
index 06a837a..6270948 100644
@@ -93,6 +93,7 @@ struct ideapad_private {
 	struct dentry *debug;
 	unsigned long cfg;
 	bool has_hw_rfkill_switch;
+	bool has_tp_ctrl;
 };
 
 static bool no_bt_rfkill;
@@ -773,6 +774,9 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
 {
 	unsigned long value;
 
+	if (!priv->has_tp_ctrl)
+		return;
+
 	/* Without reading from EC touchpad LED doesn't switch state */
 	if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
 		/* Some IdeaPads don't really turn off touchpad - they only
@@ -930,6 +934,27 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
 	{}
 };
 
+/*
+ * Avoid sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.
+ */
+static const struct dmi_system_id no_tp_ctrl_list[] = {
+	{
+		.ident = "Lenovo 80HE", /* Yoga 3 Pro 2 */
+		.matches = {

drivers/platform/x86/ideapad-laptop.c static const struct dmi_system_id no_hw_rfkill_list[] = { · line 953

Quoted 10 lines
drivers/platform/x86/ideapad-laptop.c +10 -0
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "80HE"),
+		},
+	},
+	{
+		.ident = "Lenovo 80MK", /* Yoga 900 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "80MK"),
+		},

Upon closer inspection, is there a reason you chose to match on PRODUCT_NAME instead of PRODUCT_VERSION like the no_hw_rfkill_list? The PRODUCT_VERSION tends to have the user recognizable name which you placed in a comment instead of in the .ident. For both consistency and legibility, it seems like it would be better to match on DMI_PRODUCT_VERSION and use that in the .ident.

Signature · 2 lines
Darren Hart
Intel Open Source Technology Center
#4 lore raw
Quoted 51 lines · Darren Hart
Quoted 50 lines · João Paulo Rechi Vita

Don't try to control the touchpad on laptops that do not support it, as it leads to sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.

---
 drivers/platform/x86/ideapad-laptop.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
drivers/platform/x86/ideapad-laptop.c +19 -0
index 06a837a..6270948 100644
@@ -93,6 +93,7 @@ struct ideapad_private {
      struct dentry *debug;
      unsigned long cfg;
      bool has_hw_rfkill_switch;
+     bool has_tp_ctrl;
 };
 
 static bool no_bt_rfkill;
@@ -773,6 +774,9 @@ static void ideapad_sync_touchpad_state(struct ideapad_private *priv)
 {
      unsigned long value;
 
+     if (!priv->has_tp_ctrl)
+             return;
+
      /* Without reading from EC touchpad LED doesn't switch state */
      if (!read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value)) {
              /* Some IdeaPads don't really turn off touchpad - they only
@@ -930,6 +934,27 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
      {}
 };
 
+/*
+ * Avoid sending wrong KEY_TOUCHPAD_ON / KEY_TOUCHPAD_OFF events to userspace.
+ */
+static const struct dmi_system_id no_tp_ctrl_list[] = {
+     {
+             .ident = "Lenovo 80HE", /* Yoga 3 Pro 2 */
+             .matches = {
+                     DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+                     DMI_MATCH(DMI_PRODUCT_NAME, "80HE"),
+             },
+     },
+     {
+             .ident = "Lenovo 80MK", /* Yoga 900 */
+             .matches = {
+                     DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
Quoted 9 lines

drivers/platform/x86/ideapad-laptop.c static const struct dmi_system_id no_hw_rfkill_list[] = { · line 953

Quoted 2 lines
drivers/platform/x86/ideapad-laptop.c +2 -0
+                     DMI_MATCH(DMI_PRODUCT_NAME, "80MK"),
+             },

Upon closer inspection, is there a reason you chose to match on PRODUCT_NAME instead of PRODUCT_VERSION like the no_hw_rfkill_list? The PRODUCT_VERSION tends to have the user recognizable name which you placed in a comment instead of in the .ident. For both consistency and legibility, it seems like it would be better to match on DMI_PRODUCT_VERSION and use that in the .ident.

The reason I chose PRODUCT_NAME is because on these laptops this seems to more specifically identify the machine. 80MK is the model name I see on the machine's box and at the website at the time. Now the website shows 80UE. So maybe this is a way to avoid the kind of clashing that led to reverting the previous quirk by Hans? If that does not make much sense I can change it to match against PRODUCT_VERSION, which on my Yoga 900 shows "Lenovo YOGA 900-13ISK".

Also, let me know if you have a explicit suggestion to make the commit message clearer, or feel free to fix it when you pick the patch.

--
João Paulo Rechi Vita
http://about.me/jprvita