public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: zinitix: don't use finger_mask as bitmask when reporting contacts
@ 2026-04-08  3:14 Thanh Nguyen
  2026-04-08  4:51 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Thanh Nguyen @ 2026-04-08  3:14 UTC (permalink / raw)
  To: linux-input; +Cc: linux-kernel, dmitry.torokhov, 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.

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 (")

Link: https://bugzilla.kernel.org/show_bug.cgi?id=221278

Signed-off-by: Thanh Nguyen <thanhnguyxn07@gmail.com>
---
 drivers/input/touchscreen/zinitix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
index 716d6fa60..b80525443 100644
--- a/drivers/input/touchscreen/zinitix.c
+++ b/drivers/input/touchscreen/zinitix.c
@@ -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);
 	}
-- 
2.51.0.windows.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Input: zinitix: don't use finger_mask as bitmask when reporting contacts
  2026-04-08  3:14 [PATCH] Input: zinitix: don't use finger_mask as bitmask when reporting contacts Thanh Nguyen
@ 2026-04-08  4:51 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2026-04-08  4:51 UTC (permalink / raw)
  To: Thanh Nguyen, Linus Walleij; +Cc: linux-input, linux-kernel

Hi Thanh,

On Tue, Apr 07, 2026 at 10:14:40PM -0500, Thanh Nguyen wrote:
> 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 (")

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...

> 
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=221278
> 
> Signed-off-by: Thanh Nguyen <thanhnguyxn07@gmail.com>
> ---
>  drivers/input/touchscreen/zinitix.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/zinitix.c b/drivers/input/touchscreen/zinitix.c
> index 716d6fa60..b80525443 100644
> --- a/drivers/input/touchscreen/zinitix.c
> +++ b/drivers/input/touchscreen/zinitix.c
> @@ -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);
>  	}

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-04-08  4:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-08  3:14 [PATCH] Input: zinitix: don't use finger_mask as bitmask when reporting contacts Thanh Nguyen
2026-04-08  4:51 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox