Unverified Commit 6227cc32 authored by Vishnu Sankar's avatar Vishnu Sankar Committed by Ilpo Järvinen
Browse files

platform/x86: thinkpad_acpi: Add sysfs control for TrackPoint double-tap



Add a sysfs attribute to enable or disable TrackPoint double-tap hotkey
events at the kernel level.

The TrackPoint firmware enables double-tap support automatically. This
interface allows userspace to control whether double-tap events are
forwarded to userspace.

The attribute is available at:

  /sys/devices/platform/thinkpad_acpi/doubletap_enable

  0 - Disable double-tap hotkey events
  1 - Enable double-tap hotkey events (default)

Filtering is implemented by suppressing ACPI hotkey delivery without
injecting synthetic input events.

Signed-off-by: default avatarVishnu Sankar <vishnuocv@gmail.com>
Suggested-by: default avatarMark Pearson <mpearson-lenovo@squebb.ca>
Link: https://patch.msgid.link/20260311143144.482145-3-vishnuocv@gmail.com


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 9a98ebe6
Loading
Loading
Loading
Loading
+35 −7
Original line number Diff line number Diff line
@@ -374,7 +374,7 @@ static struct {
	u32 hotkey_poll_active:1;
	u32 has_adaptive_kbd:1;
	u32 kbd_lang:1;
	u32 trackpoint_doubletap:1;
	u32 trackpoint_doubletap_enable:1;
	struct quirk_entry *quirks;
} tp_features;

@@ -3019,6 +3019,31 @@ static const struct attribute_group adaptive_kbd_attr_group = {
	.attrs = adaptive_kbd_attributes,
};

/* sysfs doubletap enable --------------------------------------------- */
static ssize_t doubletap_enable_show(struct device *dev,
				     struct device_attribute *attr,
				     char *buf)
{
	return sysfs_emit(buf, "%d\n", tp_features.trackpoint_doubletap_enable);
}

static ssize_t doubletap_enable_store(struct device *dev,
				      struct device_attribute *attr,
				      const char *buf, size_t count)
{
	bool enable;
	int err;

	err = kstrtobool(buf, &enable);
	if (err)
		return err;

	tp_features.trackpoint_doubletap_enable = enable;
	return count;
}

static DEVICE_ATTR_RW(doubletap_enable);

/* --------------------------------------------------------------------- */

static struct attribute *hotkey_attributes[] = {
@@ -3033,6 +3058,7 @@ static struct attribute *hotkey_attributes[] = {
	&dev_attr_hotkey_recommended_mask.attr,
	&dev_attr_hotkey_tablet_mode.attr,
	&dev_attr_hotkey_radio_sw.attr,
	&dev_attr_doubletap_enable.attr,
#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL
	&dev_attr_hotkey_source_mask.attr,
	&dev_attr_hotkey_poll_freq.attr,
@@ -3558,8 +3584,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)

	hotkey_poll_setup_safe(true);

	/* Enable doubletap by default */
	tp_features.trackpoint_doubletap = 1;
	/* Enable TrackPoint doubletap event reporting by default. */
	tp_features.trackpoint_doubletap_enable = 1;

	return 0;
}
@@ -3864,9 +3890,9 @@ static bool hotkey_notify_8xxx(const u32 hkey, bool *send_acpi_ev)
{
	switch (hkey) {
	case TP_HKEY_EV_TRACK_DOUBLETAP:
		if (tp_features.trackpoint_doubletap)
			tpacpi_input_send_key(hkey, send_acpi_ev);

		/* Only send event if doubletap is enabled */
		if (!tp_features.trackpoint_doubletap_enable)
			*send_acpi_ev = false;
		return true;
	default:
		return false;
@@ -11486,7 +11512,9 @@ static bool tpacpi_driver_event(const unsigned int hkey_event)
		mutex_unlock(&tpacpi_inputdev_send_mutex);
		return true;
	case TP_HKEY_EV_DOUBLETAP_TOGGLE:
		tp_features.trackpoint_doubletap = !tp_features.trackpoint_doubletap;
		/* Toggle kernel-level doubletap event filtering */
		tp_features.trackpoint_doubletap_enable =
			!tp_features.trackpoint_doubletap_enable;
		return true;
	case TP_HKEY_EV_PROFILE_TOGGLE:
	case TP_HKEY_EV_PROFILE_TOGGLE2: