From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Richard Kjerstadius <kjerstadius@gmail.com>
Cc: linux-input@vger.kernel.org,
Richard Kjerstadius <richard.kjerstadius@teledyne.com>,
linus.walleij@linaro.org, alistair@alistair23.me,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] input: cyttsp5: Fix bitmask for touch buttons
Date: Fri, 3 Feb 2023 16:59:26 -0800 [thread overview]
Message-ID: <Y92t7uqj/F8kFbi8@google.com> (raw)
In-Reply-To: <20230127102903.3317089-1-richard.kjerstadius@teledyne.com>
On Fri, Jan 27, 2023 at 11:29:03AM +0100, Richard Kjerstadius wrote:
> Prior to this patch, the bitmask ends up being 0x3, as opposed to 0x1
> which likely was the intention. The erroneous bit results in the driver
> reporting 2 different button activations in designs with 2 or more
> buttons.
>
> To detect which button has been pressed, cyttsp5_btn_attention() uses a
> for loop to iterate through the input buffer, while shifting and
> applying a bitmask to determine the state for each button.
> Unfortunately, when the bitmask is 0x3 and there are multiple buttons,
> this procedure falls apart.
>
> Consider a design with 3 buttons. Pressing the third button will result
> in a call to cyttsp5_btn_attention() with the input buffer containing
> 0x4 (binary 0100). In the first iteration of the for loop cur_btn_state
> will be:
>
> (0x4 >> 0 * 1) & 0x3 = 0x4 & 0x3 = 0x0
>
> This is correct. However, in the next iteration this happens:
>
> (0x4 >> 1 * 1) & 0x3 = 0x2 & 0x3 = 0x2
>
> Which means that a key event for key 1 is generated, even though it's
> not really active. In the third iteration, the loop detects the button
> that was actually pressed:
>
> (0x4 >> 2 * 1) & 0x3 = 0x1 & 0x3 = 0x1
>
> This key event is the only one that should have been detected, but it is
> accompanied by the preceding key. Ensuring the applied mask is 0x1
> solves this problem.
>
> Signed-off-by: Richard Kjerstadius <richard.kjerstadius@teledyne.com>
Applied, thank you.
--
Dmitry
prev parent reply other threads:[~2023-02-04 0:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 10:29 [PATCH] input: cyttsp5: Fix bitmask for touch buttons Richard Kjerstadius
2023-02-01 8:00 ` Alistair
2023-02-04 0:59 ` Dmitry Torokhov [this message]
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=Y92t7uqj/F8kFbi8@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=alistair@alistair23.me \
--cc=kjerstadius@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard.kjerstadius@teledyne.com \
/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