]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
input: trackpoint - Enable doubletap by default on capable devices
authorVishnu Sankar <vishnuocv@gmail.com>
Wed, 11 Mar 2026 14:31:42 +0000 (23:31 +0900)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 17 Mar 2026 13:27:22 +0000 (15:27 +0200)
Enable doubletap functionality by default on TrackPoint devices that
support it. The feature is detected using firmware ID pattern matching
(PNP: LEN03xxx) with a deny list of incompatible devices.

This provides immediate doubletap functionality without requiring
userspace configuration. The hardware is enabled during device
detection, while event filtering continues to be handled by the
thinkpad_acpi driver as before.

Signed-off-by: Vishnu Sankar <vishnuocv@gmail.com>
Suggested-by: Mark Pearson <mpearson-lenovo@squebb.ca>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://patch.msgid.link/20260311143144.482145-2-vishnuocv@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/input/mouse/trackpoint.c
drivers/input/mouse/trackpoint.h

index b06c7ad721fe95850c3360821c041084e7a7d4ab..3bd8fdf56cd3d2eb819f8df6d35354d2b778091d 100644 (file)
@@ -5,6 +5,7 @@
  * Trademarks are the property of their respective owners.
  */
 
+#include <linux/array_size.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/serio.h>
@@ -12,6 +13,7 @@
 #include <linux/input.h>
 #include <linux/libps2.h>
 #include <linux/proc_fs.h>
+#include <linux/string.h>
 #include <linux/uaccess.h>
 #include "psmouse.h"
 #include "trackpoint.h"
@@ -393,6 +395,44 @@ static int trackpoint_reconnect(struct psmouse *psmouse)
        return 0;
 }
 
+/* List of known incapable device PNP IDs */
+static const char * const dt_incompatible_devices[] = {
+       "LEN0304",
+       "LEN0306",
+       "LEN0317",
+       "LEN031A",
+       "LEN031B",
+       "LEN031C",
+       "LEN031D",
+};
+
+/*
+ * Checks if it's a doubletap capable device.
+ * The PNP ID format is "PNP: LEN030d PNP0f13".
+ */
+static bool trackpoint_is_dt_capable(const char *pnp_id)
+{
+       size_t i;
+
+       if (!pnp_id)
+               return false;
+
+       /* Must start with "PNP: LEN03" */
+       if (!strstarts(pnp_id, "PNP: LEN03"))
+               return false;
+
+       /* Ensure enough length before comparing */
+       if (strlen(pnp_id) < 12)
+               return false;
+
+       /* Check deny-list */
+       for (i = 0; i < ARRAY_SIZE(dt_incompatible_devices); i++) {
+               if (!strncmp(pnp_id + 5, dt_incompatible_devices[i], 7))
+                       return false;
+       }
+       return true;
+}
+
 int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
 {
        struct ps2dev *ps2dev = &psmouse->ps2dev;
@@ -470,6 +510,12 @@ int trackpoint_detect(struct psmouse *psmouse, bool set_properties)
                     psmouse->vendor, firmware_id,
                     (button_info & 0xf0) >> 4, button_info & 0x0f);
 
+       if (trackpoint_is_dt_capable(ps2dev->serio->firmware_id)) {
+               error = trackpoint_write(ps2dev, TP_DOUBLETAP, TP_DOUBLETAP_ENABLE);
+               if (error)
+                       psmouse_warn(psmouse, "Failed to enable doubletap: %d\n", error);
+       }
+
        return 0;
 }
 
index eb5412904fe0750320769040441b58bb7f6a5856..3e03cdb394498463b2de4319d0b49448bfb30713 100644 (file)
@@ -69,6 +69,8 @@
                                        /* (how hard it is to drag */
                                        /* with Z-axis pressed) */
 
+#define TP_DOUBLETAP           0x58    /* TrackPoint doubletap register */
+
 #define TP_MINDRAG             0x59    /* Minimum amount of force needed */
                                        /* to trigger dragging */
 
                                           external device will be forced to 1 */
 #define TP_MASK_EXT_TAG                        0x04
 
+/* Doubletap register values */
+#define TP_DOUBLETAP_ENABLE    0xFF    /* Enable value */
+#define TP_DOUBLETAP_DISABLE   0xFE    /* Disable value */
 
 /* Power on Self Test Results */
 #define TP_POR_SUCCESS         0x3B