Skip to contentSkip to conversation

input: ilitek_ts_i2c: report key event for palm

PATCH In review Joe Hung (洪銘陽) 3 participants 3 messages Jul 14, 2025 – Jul 23, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: ilitek_ts_i2c: report key event for palm

From ec0d80214fee6acc0b38f33ad0b6b487098963bc Mon Sep 17 00:00:00 2001
From: Joe Hong <[email protected]>
Date: Mon, 14 Jul 2025 17:20:11 +0800
Subject: [PATCH] input: ilitek_ts_i2c: report key event for palm

Add support for reporting user-defined key event while getting palm event.

---
 drivers/input/touchscreen/ilitek_ts_i2c.c | 42 +++++++++++++++++++++++
 1 file changed, 42 insertions(+)
drivers/input/touchscreen/ilitek_ts_i2c.c +42 -0
index 0dd632724a00..fdcb4ab66fbb 100644
@@ -39,8 +39,13 @@
 #define ILITEK_TP_I2C_REPORT_ID				0x48
 
 #define REPORT_COUNT_ADDRESS				61
+#define ALGO_MODE_ADDRESS				62
 #define ILITEK_SUPPORT_MAX_POINT			40
 
+static uint palm_key;
+module_param(palm_key, uint, 0664);
+MODULE_PARM_DESC(palm_key, "Set palm key code when palm is detected");
+
 struct ilitek_protocol_info {
 	u16 ver;
 	u8 ver_major;
@@ -176,6 +181,11 @@ static int ilitek_process_and_report_v6(struct ilitek_ts_data *ts)
 		return -EINVAL;
 	}
 
+	if (palm_key) {
+		input_report_key(ts->input_dev, palm_key,
+				 (buf[ALGO_MODE_ADDRESS] & 0x80) ? 1 : 0);
+	}
+
 	count = DIV_ROUND_UP(report_max_point, packet_max_point);
 	for (i = 1; i < count; i++) {
 		error = ilitek_i2c_write_and_read(ts, NULL, 0, 0,
@@ -472,6 +482,9 @@ static int ilitek_input_dev_init(struct device *dev, struct ilitek_ts_data *ts)
 	input->name = ILITEK_TS_NAME;
 	input->id.bustype = BUS_I2C;
 
+	if (palm_key)
+		__set_bit(palm_key, input->keybit);
+
 	__set_bit(INPUT_PROP_DIRECT, input->propbit);
 
 	input_set_abs_params(input, ABS_MT_POSITION_X,
@@ -537,9 +550,38 @@ static ssize_t product_id_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(product_id);
 
+static ssize_t palm_key_show(struct device *dev,
+			     struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "palm key: [%u]\n", palm_key);
+}
+
+static ssize_t palm_key_store(struct device *dev, struct device_attribute *attr,
+			      const char *buf, size_t count)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct ilitek_ts_data *ts = i2c_get_clientdata(client);
+
+	unsigned long tmp;
+
+	if (kstrtoul(buf, 10, &tmp) || tmp > KEY_MAX)
+		return -EINVAL;
+
+	if (palm_key)
+		__clear_bit(palm_key, ts->input_dev->keybit);
+
+	__set_bit(tmp, ts->input_dev->keybit);
+	palm_key = tmp;
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(palm_key);
+
 static struct attribute *ilitek_sysfs_attrs[] = {
 	&dev_attr_firmware_version.attr,
 	&dev_attr_product_id.attr,
+	&dev_attr_palm_key.attr,
 	NULL
 };
 ATTRIBUTE_GROUPS(ilitek_sysfs);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 4 lines · Joe Hung (洪銘陽)

From ec0d80214fee6acc0b38f33ad0b6b487098963bc Mon Sep 17 00:00:00 2001
From: Joe Hong <[email protected]>
Date: Mon, 14 Jul 2025 17:20:11 +0800
Subject: [PATCH] input: ilitek_ts_i2c: report key event for palm

something wrong on this headers, check your setup

Quoted 12 lines

Add support for reporting user-defined key event while getting palm event.

---
 drivers/input/touchscreen/ilitek_ts_i2c.c | 42 +++++++++++++++++++++++
 1 file changed, 42 insertions(+)
drivers/input/touchscreen/ilitek_ts_i2c.c +0 -0
index 0dd632724a00..fdcb4ab66fbb 100644

drivers/input/touchscreen/ilitek_ts_i2c.c line 47

Quoted 9 lines
drivers/input/touchscreen/ilitek_ts_i2c.c +4 -0
@@ -39,8 +39,13 @@
 #define ILITEK_TP_I2C_REPORT_ID				0x48
 
 #define REPORT_COUNT_ADDRESS				61
+#define ALGO_MODE_ADDRESS				62
 #define ILITEK_SUPPORT_MAX_POINT			40
 
+static uint palm_key;
+module_param(palm_key, uint, 0664);
+MODULE_PARM_DESC(palm_key, "Set palm key code when palm is detected");

I do not think that putting some kind of configuration in a kernel module param is an option

Francesco

#2 lore raw
In reply to Joe Hung (洪銘陽)

Hi Joe,

Quoted 6 lines · Joe Hung (洪銘陽)

From ec0d80214fee6acc0b38f33ad0b6b487098963bc Mon Sep 17 00:00:00 2001
From: Joe Hong <[email protected]>
Date: Mon, 14 Jul 2025 17:20:11 +0800
Subject: [PATCH] input: ilitek_ts_i2c: report key event for palm

Add support for reporting user-defined key event while getting palm event.

Palm contacts should be reported via MT_TOOL_PALM contact type and not a fake key event.

Thanks.

Signature · 1 line
Dmitry