Phone-Devel Archive on lore.kernel.org.
 help / color / Atom feed
* [PATCH v2] input: s6sy761: fix coordinate read bit shift
@ 2021-03-05 18:58 Caleb Connolly
  2021-03-06 10:33 ` Andi Shyti
  2021-03-07 23:13 ` Dmitry Torokhov
  0 siblings, 2 replies; 3+ messages in thread
From: Caleb Connolly @ 2021-03-05 18:58 UTC (permalink / raw)
  To: caleb, andi, Dmitry Torokhov, Rob Herring
  Cc: ~postmarketos/upstreaming, phone-devel, linux-input, linux-kernel

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>
---
Changes since v1:
 * Use Andi's explanation in the commit message
 * Add Fixes: tag

drivers/input/touchscreen/s6sy761.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/s6sy761.c b/drivers/input/touchscreen/s6sy761.c
index b63d7fdf0cd2..85a1f465c097 100644
--- a/drivers/input/touchscreen/s6sy761.c
+++ b/drivers/input/touchscreen/s6sy761.c
@@ -145,8 +145,8 @@ static void s6sy761_report_coordinates(struct s6sy761_data *sdata,
 	u8 major = event[4];
 	u8 minor = event[5];
 	u8 z = event[6] & S6SY761_MASK_Z;
-	u16 x = (event[1] << 3) | ((event[3] & S6SY761_MASK_X) >> 4);
-	u16 y = (event[2] << 3) | (event[3] & S6SY761_MASK_Y);
+	u16 x = (event[1] << 4) | ((event[3] & S6SY761_MASK_X) >> 4);
+	u16 y = (event[2] << 4) | (event[3] & S6SY761_MASK_Y);
 
 	input_mt_slot(sdata->input, tid);
 
-- 
2.29.2



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

* Re: [PATCH v2] input: s6sy761: fix coordinate read bit shift
  2021-03-05 18:58 [PATCH v2] input: s6sy761: fix coordinate read bit shift Caleb Connolly
@ 2021-03-06 10:33 ` Andi Shyti
  2021-03-07 23:13 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Andi Shyti @ 2021-03-06 10:33 UTC (permalink / raw)
  To: Caleb Connolly
  Cc: andi, Dmitry Torokhov, Rob Herring, ~postmarketos/upstreaming,
	phone-devel, linux-input, linux-kernel

Hi Caleb,

On Fri, Mar 05, 2021 at 06:58:10PM +0000, Caleb Connolly wrote:
> 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>

Thanks,
Andi

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

* Re: [PATCH v2] input: s6sy761: fix coordinate read bit shift
  2021-03-05 18:58 [PATCH v2] input: s6sy761: fix coordinate read bit shift Caleb Connolly
  2021-03-06 10:33 ` Andi Shyti
@ 2021-03-07 23:13 ` Dmitry Torokhov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2021-03-07 23:13 UTC (permalink / raw)
  To: Caleb Connolly
  Cc: andi, Rob Herring, ~postmarketos/upstreaming, phone-devel,
	linux-input, linux-kernel

On Fri, Mar 05, 2021 at 06:58:10PM +0000, Caleb Connolly wrote:
> 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>

Applied, thank you.

-- 
Dmitry

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 18:58 [PATCH v2] input: s6sy761: fix coordinate read bit shift Caleb Connolly
2021-03-06 10:33 ` Andi Shyti
2021-03-07 23:13 ` Dmitry Torokhov

Phone-Devel Archive on lore.kernel.org.

Archives are clonable:
	git clone --mirror https://lore.kernel.org/phone-devel/0 phone-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 phone-devel phone-devel/ https://lore.kernel.org/phone-devel \
		phone-devel@vger.kernel.org
	public-inbox-index phone-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.phone-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git