From: "Joe Hung (洪銘陽)" <joe_hung@ilitek.com>
To: "dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>,
"francesco.dolcini@toradex.com" <francesco.dolcini@toradex.com>,
"emanuele.ghidoli@toradex.com" <emanuele.ghidoli@toradex.com>
Cc: linux-input <linux-input@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Luca Hsu (徐嘉鍊)" <luca_hsu@ilitek.com>,
"Joe Hung (洪銘陽)" <joe_hung@ilitek.com>
Subject: [PATCH] input: ilitek_ts_i2c: report key event for palm
Date: Mon, 14 Jul 2025 09:51:42 +0000 [thread overview]
Message-ID: <b372a99d01c14d1690afba4ceedd0936@ilitek.com> (raw)
From ec0d80214fee6acc0b38f33ad0b6b487098963bc Mon Sep 17 00:00:00 2001
From: Joe Hong <joe_hung@ilitek.com>
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.
Signed-off-by: Joe Hong <joe_hung@ilitek.com>
---
drivers/input/touchscreen/ilitek_ts_i2c.c | 42 +++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/input/touchscreen/ilitek_ts_i2c.c b/drivers/input/touchscreen/ilitek_ts_i2c.c
index 0dd632724a00..fdcb4ab66fbb 100644
--- a/drivers/input/touchscreen/ilitek_ts_i2c.c
+++ b/drivers/input/touchscreen/ilitek_ts_i2c.c
@@ -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);
--
2.34.1
next reply other threads:[~2025-07-14 9:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 9:51 Joe Hung (洪銘陽) [this message]
2025-07-23 15:57 ` [PATCH] input: ilitek_ts_i2c: report key event for palm Francesco Dolcini
2025-07-23 16:09 ` dmitry.torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b372a99d01c14d1690afba4ceedd0936@ilitek.com \
--to=joe_hung@ilitek.com \
--cc=dmitry.torokhov@gmail.com \
--cc=emanuele.ghidoli@toradex.com \
--cc=francesco.dolcini@toradex.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca_hsu@ilitek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox