5fd2783
From: Hans de Goede <hdegoede@redhat.com>
5fd2783
Date: Fri, 27 Jun 2014 18:50:33 +0200
dbc4a9b
Subject: [PATCH] psmouse: Add support for detecting FocalTech PS/2 touchpads
5fd2783
5fd2783
The Asus X450 and X550 laptops use a PS/2 touchpad from a new manufacturer
5fd2783
called FocalTech:
5fd2783
5fd2783
https://bugzilla.kernel.org/show_bug.cgi?id=77391
5fd2783
https://bugzilla.redhat.com/show_bug.cgi?id=1110011
5fd2783
5fd2783
The protocol for these devices is not known at this time, but even without
5fd2783
knowing the protocol they need some special handling. They get upset by some
5fd2783
of our other PS/2 device probing, and once upset generate random mouse events
5fd2783
making things unusable even with an external mouse.
5fd2783
5fd2783
This patch adds detection of these devices based on their pnp ids, and when
5fd2783
they are detected, treats them as a bare ps/2 mouse. Doing things this way
5fd2783
they at least work in their ps/2 mouse emulation mode.
5fd2783
5fd2783
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
5fd2783
---
5fd2783
 drivers/input/mouse/Makefile       |  2 +-
5fd2783
 drivers/input/mouse/focaltech.c    | 44 ++++++++++++++++++++++++++++++++++++++
5fd2783
 drivers/input/mouse/focaltech.h    | 21 ++++++++++++++++++
5fd2783
 drivers/input/mouse/psmouse-base.c | 10 +++++++++
5fd2783
 4 files changed, 76 insertions(+), 1 deletion(-)
5fd2783
 create mode 100644 drivers/input/mouse/focaltech.c
5fd2783
 create mode 100644 drivers/input/mouse/focaltech.h
5fd2783
5fd2783
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
5fd2783
index c25efdb3f288..dda507f8b3a2 100644
5fd2783
--- a/drivers/input/mouse/Makefile
5fd2783
+++ b/drivers/input/mouse/Makefile
5fd2783
@@ -23,7 +23,7 @@ obj-$(CONFIG_MOUSE_SYNAPTICS_I2C)	+= synaptics_i2c.o
5fd2783
 obj-$(CONFIG_MOUSE_SYNAPTICS_USB)	+= synaptics_usb.o
5fd2783
 obj-$(CONFIG_MOUSE_VSXXXAA)		+= vsxxxaa.o
5fd2783
 
5fd2783
-psmouse-objs := psmouse-base.o synaptics.o
5fd2783
+psmouse-objs := psmouse-base.o synaptics.o focaltech.o
5fd2783
 
5fd2783
 psmouse-$(CONFIG_MOUSE_PS2_ALPS)	+= alps.o
5fd2783
 psmouse-$(CONFIG_MOUSE_PS2_ELANTECH)	+= elantech.o
5fd2783
diff --git a/drivers/input/mouse/focaltech.c b/drivers/input/mouse/focaltech.c
5fd2783
new file mode 100644
5fd2783
index 000000000000..d83a23554d63
5fd2783
--- /dev/null
5fd2783
+++ b/drivers/input/mouse/focaltech.c
5fd2783
@@ -0,0 +1,44 @@
5fd2783
+/*
5fd2783
+ * Focaltech TouchPad PS/2 mouse driver
5fd2783
+ *
5fd2783
+ * Copyright (c) 2014 Red Hat Inc.
5fd2783
+ *
5fd2783
+ * This program is free software; you can redistribute it and/or modify
5fd2783
+ * it under the terms of the GNU General Public License as published by
5fd2783
+ * the Free Software Foundation; either version 2 of the License, or
5fd2783
+ * (at your option) any later version.
5fd2783
+ *
5fd2783
+ * Red Hat authors:
5fd2783
+ *
5fd2783
+ * Hans de Goede <hdegoede@redhat.com>
5fd2783
+ */
5fd2783
+
5fd2783
+/*
5fd2783
+ * The Focaltech PS/2 touchpad protocol is unknown. This drivers deals with
5fd2783
+ * detection only, to avoid further detection attempts confusing the touchpad
5fd2783
+ * this way it at least works in PS/2 mouse compatibility mode.
5fd2783
+ */
5fd2783
+
5fd2783
+#include <linux/device.h>
5fd2783
+#include <linux/libps2.h>
5fd2783
+#include "psmouse.h"
5fd2783
+
5fd2783
+static const char * const focaltech_pnp_ids[] = {
5fd2783
+	"FLT0101",
5fd2783
+	"FLT0102",
5fd2783
+	"FLT0103",
5fd2783
+	NULL
5fd2783
+};
5fd2783
+
5fd2783
+int focaltech_detect(struct psmouse *psmouse, bool set_properties)
5fd2783
+{
5fd2783
+	if (!psmouse_matches_pnp_id(psmouse, focaltech_pnp_ids))
5fd2783
+		return -ENODEV;
5fd2783
+
5fd2783
+	if (set_properties) {
5fd2783
+		psmouse->vendor = "FocalTech";
5fd2783
+		psmouse->name = "FocalTech Touchpad in mouse emulation mode";
5fd2783
+	}
5fd2783
+
5fd2783
+	return 0;
5fd2783
+}
5fd2783
diff --git a/drivers/input/mouse/focaltech.h b/drivers/input/mouse/focaltech.h
5fd2783
new file mode 100644
5fd2783
index 000000000000..0d0fc49451fe
5fd2783
--- /dev/null
5fd2783
+++ b/drivers/input/mouse/focaltech.h
5fd2783
@@ -0,0 +1,21 @@
5fd2783
+/*
5fd2783
+ * Focaltech TouchPad PS/2 mouse driver
5fd2783
+ *
5fd2783
+ * Copyright (c) 2014 Red Hat Inc.
5fd2783
+ *
5fd2783
+ * This program is free software; you can redistribute it and/or modify
5fd2783
+ * it under the terms of the GNU General Public License as published by
5fd2783
+ * the Free Software Foundation; either version 2 of the License, or
5fd2783
+ * (at your option) any later version.
5fd2783
+ *
5fd2783
+ * Red Hat authors:
5fd2783
+ *
5fd2783
+ * Hans de Goede <hdegoede@redhat.com>
5fd2783
+ */
5fd2783
+
5fd2783
+#ifndef _FOCALTECH_H
5fd2783
+#define _FOCALTECH_H
5fd2783
+
5fd2783
+int focaltech_detect(struct psmouse *psmouse, bool set_properties);
5fd2783
+
5fd2783
+#endif
5fd2783
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
dbc4a9b
index 02e68c3008a3..2c8c8e2172a2 100644
5fd2783
--- a/drivers/input/mouse/psmouse-base.c
5fd2783
+++ b/drivers/input/mouse/psmouse-base.c
5fd2783
@@ -35,6 +35,7 @@
5fd2783
 #include "elantech.h"
5fd2783
 #include "sentelic.h"
5fd2783
 #include "cypress_ps2.h"
5fd2783
+#include "focaltech.h"
5fd2783
 
5fd2783
 #define DRIVER_DESC	"PS/2 mouse driver"
5fd2783
 
dbc4a9b
@@ -722,6 +723,13 @@ static int psmouse_extensions(struct psmouse *psmouse,
5fd2783
 {
5fd2783
 	bool synaptics_hardware = false;
5fd2783
 
5fd2783
+/* Always check for focaltech, this is safe as it uses pnp-id matching */
5fd2783
+	if (psmouse_do_detect(focaltech_detect, psmouse, set_properties) == 0) {
5fd2783
+		/* Not supported yet, use bare protocol */
5fd2783
+		psmouse_max_proto = max_proto = PSMOUSE_PS2;
5fd2783
+		goto reset_to_defaults;
5fd2783
+	}
5fd2783
+
5fd2783
 /*
5fd2783
  * We always check for lifebook because it does not disturb mouse
5fd2783
  * (it only checks DMI information).
dbc4a9b
@@ -873,6 +881,8 @@ static int psmouse_extensions(struct psmouse *psmouse,
5fd2783
 		}
5fd2783
 	}
5fd2783
 
5fd2783
+reset_to_defaults:
5fd2783
+
5fd2783
 /*
5fd2783
  * Reset to defaults in case the device got confused by extended
5fd2783
  * protocol probes. Note that we follow up with full reset because
5fd2783
-- 
c47527a
2.1.0
5fd2783