Skip to contentSkip to conversation

Input: zinitix: don't use finger_mask as bitmask when reporting contacts

PATCH In review Thanh Nguyen 2 participants 2 messages Apr 8

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

PATCH 1/1 Input: zinitix: don't use finger_mask as bitmask when reporting contacts

The zinitix touchscreen driver was treating touch_event.finger_mask as a

bitmask to iterate through finger slots. However, on some devices (e.g.,

Samsung Galaxy A3 2015), finger_mask behaves as a finger count rather than

a bitmask, causing multitouch to malfunction.

Instead of relying on finger_mask as a bitmask, iterate through all

possible finger slots and check if SUB_BIT_EXIST is set for each slot.

This restores proper multitouch functionality on affected devices.

Fixes e941dc13fd (")
---
 drivers/input/touchscreen/zinitix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/touchscreen/zinitix.c +4 -4
index 716d6fa60..b80525443 100644
@@ -445,7 +445,6 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
 	struct bt541_ts_data *bt541 = bt541_handler;
 	struct i2c_client *client = bt541->client;
 	struct touch_event touch_event;
-	unsigned long finger_mask;
 	__le16 icon_events;
 	int error;
 	int i;
@@ -470,11 +469,12 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
 		zinitix_report_keys(bt541, le16_to_cpu(icon_events));
 	}
 
-	finger_mask = touch_event.finger_mask;
-	for_each_set_bit(i, &finger_mask, MAX_SUPPORTED_FINGER_NUM) {
+	/* Process all finger slots and check if they exist, rather than relying on finger_mask as a bitmask.
+	 * On some devices (e.g., Samsung A3 2015), finger_mask behaves as finger count rather than bitmask.
+	 * Only process contacts that are actually reported as existing. */
+	for (i = 0; i < MAX_SUPPORTED_FINGER_NUM; i++) {
 		const struct point_coord *p = &touch_event.point_coord[i];
 
-		/* Only process contacts that are actually reported */
 		if (p->sub_status & SUB_BIT_EXIST)
 			zinitix_report_finger(bt541, i, p);
 	}
Signature · 1 line
2.51.0.windows.2
maintainer
#1 lore raw

Hi Thanh,

Quoted 8 lines · Thanh Nguyen

The zinitix touchscreen driver was treating touch_event.finger_mask as a

bitmask to iterate through finger slots. However, on some devices (e.g.,

Samsung Galaxy A3 2015), finger_mask behaves as a finger count rather than

a bitmask, causing multitouch to malfunction.

Quoted 7 lines

Instead of relying on finger_mask as a bitmask, iterate through all

possible finger slots and check if SUB_BIT_EXIST is set for each slot.

This restores proper multitouch functionality on affected devices.

Fixes e941dc13fd (")

So this is effectively a revert of e941dc13fd37 ("Input: zinitix - do not report shadow fingers") and Linus reported that on his device ignoring finger count/mask field results in "shadow" contains being reported, so we obviously can not apply this as is.

So the question is whether this is a mask or a count? Could it be that it is actually a count of reported slots and we need to stop the loop after we process the "count" number of slots because the rest is simply on-stack garbage?

Cc-ing Linus who authored the commit in question...

Quoted 26 lines
---
 drivers/input/touchscreen/zinitix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/input/touchscreen/zinitix.c +0 -3
index 716d6fa60..b80525443 100644
@@ -445,7 +445,6 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
 	struct bt541_ts_data *bt541 = bt541_handler;
 	struct i2c_client *client = bt541->client;
 	struct touch_event touch_event;
-	unsigned long finger_mask;
 	__le16 icon_events;
 	int error;
 	int i;
@@ -470,11 +469,12 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
 		zinitix_report_keys(bt541, le16_to_cpu(icon_events));
 	}
 
-	finger_mask = touch_event.finger_mask;
-	for_each_set_bit(i, &finger_mask, MAX_SUPPORTED_FINGER_NUM) {

drivers/input/touchscreen/zinitix.c static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) · line 480

Quoted 10 lines
drivers/input/touchscreen/zinitix.c +4 -1
+	/* Process all finger slots and check if they exist, rather than relying on finger_mask as a bitmask.
+	 * On some devices (e.g., Samsung A3 2015), finger_mask behaves as finger count rather than bitmask.
+	 * Only process contacts that are actually reported as existing. */
+	for (i = 0; i < MAX_SUPPORTED_FINGER_NUM; i++) {
 		const struct point_coord *p = &touch_event.point_coord[i];
 
-		/* Only process contacts that are actually reported */
 		if (p->sub_status & SUB_BIT_EXIST)
 			zinitix_report_finger(bt541, i, p);
 	}

Thanks.

Signature · 1 line
Dmitry