Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] Input: appletouch - fix offset caused by smoothing
@ 2026-06-07 16:03 Icenowy Zheng
  2026-06-07 16:17 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Icenowy Zheng @ 2026-06-07 16:03 UTC (permalink / raw)
  To: Dmitry Torokhov, Kees Cook, Johan Hovold, Clinton Sprain,
	Henrik Rydberg
  Cc: linux-input, linux-kernel, Icenowy Zheng, stable

The smoothing code introduces 4 sensors of margin on each side of the
input, which is not compensated and leads to a offset of 4 * factor added
to the calculated coordinate values.

However, the maximum value reported as ABS axis parameters are
calculated with the sensor count multiplied by the factor, which leads
to the coordinate values going beyond the maximum value and get ignored
by libinput.

Fix this by subtracting the index by 4 when accumlating the smoothed
values. This makes the reported coordinates in-range again, and libinput
stops to drop touch events in the right and down side of the trackpad.

Fixes: 739204bc9577 ("Input: appletouch - implement sensor data smoothing")
Cc: stable@vger.kernel.org
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
---
 drivers/input/mouse/appletouch.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
index eebeb57515e1c..174762d59f87b 100644
--- a/drivers/input/mouse/appletouch.c
+++ b/drivers/input/mouse/appletouch.c
@@ -415,7 +415,7 @@ static int atp_calculate_abs(struct atp *dev, int offset, int nb_sensors,
 		 * by scale. Mostly noise.
 		 */
 		if ((dev->smooth[i] >> ATP_SCALE) > 0) {
-			pcum += dev->smooth[i] * i;
+			pcum += dev->smooth[i] * (i - 4);
 			psum += dev->smooth[i];
 		}
 	}
-- 
2.52.0


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

end of thread, other threads:[~2026-06-07 16:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-07 16:03 [PATCH] Input: appletouch - fix offset caused by smoothing Icenowy Zheng
2026-06-07 16:17 ` sashiko-bot

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