[PATCH] ideadpad: Runtime check for hw touchpad control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check if disabling the i8042 AUX port has any effect on
VPCCMD_R_TOUCHPAD, and use that information to decide whether or not
ideapad_sync_touchpad_state() should do something.

Signed-off-by: João Paulo Rechi Vita <jprvita@xxxxxxxxxxxx>
---
 drivers/platform/x86/ideapad-laptop.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c
index 06a837a..08dd487 100644
--- a/drivers/platform/x86/ideapad-laptop.c
+++ b/drivers/platform/x86/ideapad-laptop.c
@@ -93,6 +93,7 @@ struct ideapad_private {
 	struct dentry *debug;
 	unsigned long cfg;
 	bool has_hw_rfkill_switch;
+	bool has_hw_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_hw_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,18 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
 	{}
 };
 
+static bool ideapad_has_touchpad_ctrl(struct ideapad_private *priv)
+{
+	unsigned char param;
+	unsigned long value_disabled, value_enabled;
+
+	i8042_command(&param, I8042_CMD_AUX_DISABLE);
+	read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value_disabled);
+	i8042_command(&param, I8042_CMD_AUX_ENABLE);
+	read_ec_data(priv->adev->handle, VPCCMD_R_TOUCHPAD, &value_enabled);
+	return (value_disabled != value_enabled);
+}
+
 static int ideapad_acpi_add(struct platform_device *pdev)
 {
 	int ret, i;
@@ -978,6 +994,7 @@ static int ideapad_acpi_add(struct platform_device *pdev)
 			ideapad_register_rfkill(priv, i);
 
 	ideapad_sync_rfk_state(priv);
+	priv->has_hw_tp_ctrl = ideapad_has_touchpad_ctrl(priv);
 	ideapad_sync_touchpad_state(priv);
 
 	if (acpi_video_get_backlight_type() == acpi_backlight_vendor) {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux