Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qianhui Xu" <xiaqinghuan@mail.ustc.edu.cn>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v3 5/7] Input: novatek-nvt-ts - add NT36536 packet decoding
Date: Wed, 02 Dec 2026 03:54:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-244814@kernel.org> (raw)
In-Reply-To: <20261202034023.1744045-5-xiaqinghuan@mail.ustc.edu.cn>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] Input: novatek-nvt-ts - unconditional ABS_MT_TOUCH_MAJOR in
  nvt_ts_probe()
- [Medium] Input: novatek-nvt-ts - off-by-one checksum offset in
  nvt_ts_nt36xxx_checksum_ok()
--

commit b01eacb36161b3ebd050547d6646c94da403101e
Author: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>

Input: novatek-nvt-ts - add NT36536 packet decoding

This commit adds a per-chip report callback, implements touch packet
decoding with checksum validation for NT36xxx controllers, and skips the
parameter block read when the chip data does not advertise a chip id.

> diff --git a/drivers/input/touchscreen/novatek-nvt-ts-core.c b/drivers/input/touchscreen/novatek-nvt-ts-core.c
> index d0e2c8bf22157..d1035f6058ed6 100644
> --- a/drivers/input/touchscreen/novatek-nvt-ts-core.c
> +++ b/drivers/input/touchscreen/novatek-nvt-ts-core.c
[ ... ]
> @@ -81,6 +86,77 @@ static irqreturn_t nvt_ts_irq(int irq, void *dev_id)
>  	input_mt_sync_frame(data->input);
>  	input_sync(data->input);
>  
> +	return 0;
> +}
> +
> +/*
> + * NT36xxx checksum: the byte at NVT_TS_NT36XXX_CHECKSUM is the two's
> + * complement of the sum of the first 64 bytes of the report.
> + */
> +static bool nvt_ts_nt36xxx_checksum_ok(const u8 *buf)
> +{
> +	u8 sum = 0;
> +	int i;
> +
> +	for (i = 0; i < NVT_TS_NT36XXX_CHECKSUM; i++)
> +		sum += buf[i];
> +
> +	return (u8)(~sum + 1) == buf[NVT_TS_NT36XXX_CHECKSUM];
> +}

[Severity: Medium]
Is NVT_TS_NT36XXX_CHECKSUM off by one here?

Because nvt_ts_spi_read() already strips the 2-byte SPI header via
memcpy(buf, rx + 2, count), buf[0] is the first report byte (index 1 in
the raw 109-byte SPI buffer).  When the touch records were shifted from
offset 1 to offset 0, NVT_TS_NT36XXX_CHECKSUM remained 64 (and
NVT_TS_NT36XXX_PACKET_SIZE remained 109) instead of shifting to 63 (and
108).  As a result, nvt_ts_nt36xxx_checksum_ok() sums buf[0..63]—which
already includes the checksum byte at buf[63]—and compares the result
against buf[64], causing valid touch packets to fail verification with
-EIO.

[ ... ]

> @@ -227,9 +324,22 @@ int nvt_ts_probe(struct device *dev, const struct nvt_ts_bus_ops *bus_ops,
>  	input->open = nvt_ts_start;
>  	input->close = nvt_ts_stop;
>  
> -	input_set_abs_params(input, ABS_MT_POSITION_X, 0, width - 1, 0, 0);
> -	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, height - 1, 0, 0);
> +	if (width)
> +		input_set_abs_params(input, ABS_MT_POSITION_X, 0, width - 1, 0, 0);
> +	else
> +		input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
> +	if (height)
> +		input_set_abs_params(input, ABS_MT_POSITION_Y, 0, height - 1, 0, 0);
> +	else
> +		input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
> +	input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);

[Severity: Medium]
Should ABS_MT_TOUCH_MAJOR only be registered for controllers that report
contact width?

Unconditionally advertising ABS_MT_TOUCH_MAJOR is a regression for
NT11205 and NT36672A: nvt_ts_report_nt11205() only reports slot state
and X/Y coordinates, so ABS_MT_TOUCH_MAJOR stays at 0 across all touches
and userspace input stacks that consume this axis see a permanent zero
contact width.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202034023.1744045-1-xiaqinghuan@mail.ustc.edu.cn?part=5

  reply	other threads:[~2026-12-02  3:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  3:40 [PATCH v3 1/7] Input: novatek-nvt-ts - add transport ops abstraction Qianhui Xu
2026-12-02  3:40 ` [PATCH v3 2/7] Input: novatek-nvt-ts - split bus independent core out Qianhui Xu
2026-12-02  3:40 ` [PATCH v3 3/7] Input: novatek-nvt-ts - add SPI bus support Qianhui Xu
2026-12-02  3:40 ` [PATCH v3 4/7] dt-bindings: input: novatek,nvt-ts - allow SPI wiring Qianhui Xu
2026-12-02  3:40 ` [PATCH v3 5/7] Input: novatek-nvt-ts - add NT36536 packet decoding Qianhui Xu
2026-12-02  3:54   ` sashiko-bot [this message]
2026-12-02  3:40 ` [PATCH v3 6/7] dt-bindings: input: novatek,nvt-ts - add the NT36536 compatible Qianhui Xu
2026-12-02  3:40 ` [PATCH v3 7/7] Input: novatek-nvt-ts - add no-flash firmware download Qianhui Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-244814@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiaqinghuan@mail.ustc.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox