Skip to content

Commit ec87231

Browse files
authored
kernel: add touch_count sysfs for touchscreen drivers (#70)
* feat: add touch_count sysfs attribute for s6sy761 and edt-ft5x06 Expose a touch_count sysfs attribute on both the Samsung (s6sy761) and FocalTech (edt-ft5x06) touchscreen drivers, incrementing on each finger release. This is needed by comma.sh to detect tap-based factory reset during early boot. Also fix comma.sh to reference input0 instead of input2 to match mainline kernel input device numbering. Tested on device: 1 tap=1, 3 taps=3, 5 taps=5. * fix: use glob for touch_count input device lookup Use /sys/class/input/input*/device/touch_count so comma.sh works on both mainline (input0) and vendor kernel (input2). * move
1 parent 63cef14 commit ec87231

3 files changed

Lines changed: 89 additions & 1 deletion

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
2+
index bf498bd4d..98871ecc8 100644
3+
--- a/drivers/input/touchscreen/edt-ft5x06.c
4+
+++ b/drivers/input/touchscreen/edt-ft5x06.c
5+
@@ -146,6 +146,7 @@ struct edt_ft5x06_ts_data {
6+
enum edt_ver version;
7+
unsigned int crc_errors;
8+
unsigned int header_errors;
9+
+ u64 touch_count;
10+
};
11+
12+
struct edt_i2c_chip_data {
13+
@@ -337,6 +338,8 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id)
14+
type != TOUCH_EVENT_UP))
15+
touchscreen_report_pos(tsdata->input, &tsdata->prop,
16+
x, y, true);
17+
+ else if (type == TOUCH_EVENT_UP)
18+
+ tsdata->touch_count++;
19+
}
20+
21+
input_mt_report_pointer_emulation(tsdata->input, true);
22+
@@ -566,6 +569,17 @@ static ssize_t crc_errors_show(struct device *dev,
23+
24+
static DEVICE_ATTR_RO(crc_errors);
25+
26+
+static ssize_t touch_count_show(struct device *dev,
27+
+ struct device_attribute *attr, char *buf)
28+
+{
29+
+ struct i2c_client *client = to_i2c_client(dev);
30+
+ struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client);
31+
+
32+
+ return sysfs_emit(buf, "%llu\n", tsdata->touch_count);
33+
+}
34+
+
35+
+static DEVICE_ATTR_RO(touch_count);
36+
+
37+
static struct attribute *edt_ft5x06_attrs[] = {
38+
&edt_ft5x06_attr_gain.dattr.attr,
39+
&edt_ft5x06_attr_offset.dattr.attr,
40+
@@ -577,6 +591,7 @@ static struct attribute *edt_ft5x06_attrs[] = {
41+
&dev_attr_fw_version.attr,
42+
&dev_attr_header_errors.attr,
43+
&dev_attr_crc_errors.attr,
44+
+ &dev_attr_touch_count.attr,
45+
NULL
46+
};
47+
ATTRIBUTE_GROUPS(edt_ft5x06);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
2+
index e1518a75a..2d38133d9 100644
3+
--- a/drivers/input/touchscreen/s6sy761.c
4+
+++ b/drivers/input/touchscreen/s6sy761.c
5+
@@ -108,6 +108,8 @@ struct s6sy761_data {
6+
7+
u16 devid;
8+
u8 tx_channel;
9+
+
10+
+ u64 touch_count;
11+
};
12+
13+
/*
14+
@@ -165,6 +167,7 @@ static void s6sy761_report_release(struct s6sy761_data *sdata,
15+
{
16+
input_mt_slot(sdata->input, tid);
17+
input_mt_report_slot_state(sdata->input, MT_TOOL_FINGER, false);
18+
+ sdata->touch_count++;
19+
20+
input_sync(sdata->input);
21+
}
22+
@@ -282,8 +285,19 @@ static ssize_t s6sy761_sysfs_devid(struct device *dev,
23+
24+
static DEVICE_ATTR(devid, 0444, s6sy761_sysfs_devid, NULL);
25+
26+
+static ssize_t s6sy761_sysfs_touch_count(struct device *dev,
27+
+ struct device_attribute *attr, char *buf)
28+
+{
29+
+ struct s6sy761_data *sdata = dev_get_drvdata(dev);
30+
+
31+
+ return sprintf(buf, "%llu\n", sdata->touch_count);
32+
+}
33+
+
34+
+static DEVICE_ATTR(touch_count, 0444, s6sy761_sysfs_touch_count, NULL);
35+
+
36+
static struct attribute *s6sy761_sysfs_attrs[] = {
37+
&dev_attr_devid.attr,
38+
+ &dev_attr_touch_count.attr,
39+
NULL
40+
};
41+
ATTRIBUTE_GROUPS(s6sy761_sysfs);

‎userspace/root/usr/comma/comma.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if [ ! -f /tmp/booted ]; then
6161
echo "launching system reset, reset trigger present"
6262
rm -f $RESET_TRIGGER
6363
$RESET
64-
elif (( "$(cat /sys/class/input/input2/device/touch_count)" > 4 )); then
64+
elif (( "$(cat /sys/class/input/input*/device/touch_count 2>/dev/null | head -1)" > 4 )); then
6565
echo "launching system reset, got taps"
6666
$RESET --tap-reset
6767
elif ! mountpoint -q /data; then

0 commit comments

Comments
 (0)