Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: s6sy761 - fix coordinate read bit shift

The touch coordinate register contains the following:

byte 3 byte 2 byte 1
+--------+--------+ +-----------------+ +-----------------+
| | | | | | |
| X[3:0] | Y[3:0] | | Y[11:4] | | X[11:4] |
| | | | | | |
+--------+--------+ +-----------------+ +-----------------+

Bytes 2 and 1 need to be shifted left by 4 bits, the least significant
nibble of each is stored in byte 3. Currently they are only
being shifted by 3 causing the reported coordinates to be incorrect.

This matches downstream examples, and has been confirmed on my
device (OnePlus 7 Pro).

Fixes: 0145a7141e59 ("Input: add support for the Samsung S6SY761 touchscreen")
Signed-off-by: Caleb Connolly <caleb@connolly.tech>
Reviewed-by: Andi Shyti <andi@etezian.org>
Link: https://lore.kernel.org/r/20210305185710.225168-1-caleb@connolly.tech
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Caleb Connolly and committed by
Dmitry Torokhov
30b3f687 1bff77f4

+2 -2
+2 -2
drivers/input/touchscreen/s6sy761.c
··· 145 145 u8 major = event[4]; 146 146 u8 minor = event[5]; 147 147 u8 z = event[6] & S6SY761_MASK_Z; 148 - u16 x = (event[1] << 3) | ((event[3] & S6SY761_MASK_X) >> 4); 149 - u16 y = (event[2] << 3) | (event[3] & S6SY761_MASK_Y); 148 + u16 x = (event[1] << 4) | ((event[3] & S6SY761_MASK_X) >> 4); 149 + u16 y = (event[2] << 4) | (event[3] & S6SY761_MASK_Y); 150 150 151 151 input_mt_slot(sdata->input, tid); 152 152