linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Christophe Tordeux <christophe@tordeux.net>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org
Subject: Re: [PATCH 01/01] drivers:input:byd fix greedy detection of Sentelic FSP by the BYD touchpad driver
Date: Fri, 7 Oct 2016 16:37:26 -0700	[thread overview]
Message-ID: <20161007233726.GB21386@dtor-ws> (raw)
In-Reply-To: <20161007044148.ssgxygdvmiwjsb55@sherka.pkbd.org>

Hi Christophe,

On Fri, Oct 07, 2016 at 12:41:48PM +0800, Christophe Tordeux wrote:
> From: Christophe TORDEUX <christophe@tordeux.net>
> 
> With kernel v4.6 and later, the Sentelic touchpad STL3888_C0 and
> probably other Sentelic FSP touchpads are detected as a BYD touchpad and
> lose multitouch features.
> 
> During the BYD handshake in the byd_detect function, the BYD driver
> mistakenly interprets a standard PS/2 protocol status request answer
> from the Sentelic touchpad as a successful handshake with a BYD
> touchpad. This is clearly a bug of the BYD driver.
> 
> Description of the patch: In byd_detect function, remove positive
> detection result based on standard PS/2 protocol status request answer.
> Replace it with positive detection based on handshake answers as they
> can be inferred from the BYD touchpad datasheets found on BYD website.
> 
> Signed-off-by: Christophe TORDEUX <christophe@tordeux.net>

What devices was this tested on? Do you have both BYD and Sentelic
devices?

I am really concerned about docs on BYD side as they seem to contradict
each other... I wonder how accurate they are.

Thanks.

> 
> ---
> Resubmitting this patch because I got no feedback on my first 
> submission.
> Fixes kernel bug 175421 which is impacting multiple users.
> 
> ---
>  drivers/input/mouse/byd.c | 76 
>  ++++++++++++++++++++++++++++++++++++++---------
>  1 file changed, 62 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
> index b27aa63..b5acca0 100644
> --- a/drivers/input/mouse/byd.c
> +++ b/drivers/input/mouse/byd.c
> @@ -35,6 +35,18 @@
>   * BYD pad constants
>   */
>  
> +/* Handshake answer of BTP6034 */
> +#define BYD_MODEL_BTP6034	0x00E801
> +/* Handshake answer of BTP6740 */
> +#define BYD_MODEL_BTP6740	0x001155
> +/* Handshake answers of BTP8644, BTP10463 and BTP11484 */
> +#define BYD_MODEL_BTP8644	0x011155
> +
> +/* Handshake SETRES byte of BTP6034 and BTP6740 */
> +#define BYD_SHAKE_BYTE_A	0x00
> +/* Handshake SETRES byte of BTP8644, BTP10463 and BTP11484 */
> +#define BYD_SHAKE_BYTE_B	0x03
> +
>  /*
>   * True device resolution is unknown, however experiments show the
>   * resolution is about 111 units/mm.
> @@ -434,23 +446,59 @@ static void byd_disconnect(struct psmouse *psmouse)
>  	}
>  }
>  
> +u32 byd_try_model(u32 model)
> +{
> +	size_t i;
> +
> +	u32 byd_model[] = {
> +		BYD_MODEL_BTP6034,
> +		BYD_MODEL_BTP6740,
> +		BYD_MODEL_BTP8644
> +	};
> +
> +	for (i=0; i < ARRAY_SIZE(byd_model); i++) {
> +		if (model ==  byd_model[i])
> +			return model;
> +	}
> +
> +	return 0;
> +}
> +
>  int byd_detect(struct psmouse *psmouse, bool set_properties)
>  {
>  	struct ps2dev *ps2dev = &psmouse->ps2dev;
> -	u8 param[4] = {0x03, 0x00, 0x00, 0x00};
> -
> -	if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> -		return -1;
> -	if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> -		return -1;
> -	if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> -		return -1;
> -	if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> -		return -1;
> -	if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
> -		return -1;
> -
> -	if (param[1] != 0x03 || param[2] != 0x64)
> +	size_t i;
> +
> +	u8 byd_shbyte[] = {
> +		BYD_SHAKE_BYTE_A,
> +		BYD_SHAKE_BYTE_B
> +	};
> +
> +	bool detect = false;
> +	for (i=0; i < ARRAY_SIZE(byd_shbyte); i++) {
> +		u32 model;
> +		u8 param[4] = {byd_shbyte[i], 0x00, 0x00, 0x00};
> +
> +		if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> +			return -1;
> +		if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> +			return -1;
> +		if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> +			return -1;
> +		if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> +			return -1;
> +		if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
> +			return -1;
> +
> +		model = param[2];
> +		model += param[1] << 8;
> +		model += param[0] << 16;
> +		model = byd_try_model(model);
> +		if (model)
> +			detect = true;
> +	}
> +
> +	if (!detect)
>  		return -ENODEV;
>  
>  	psmouse_dbg(psmouse, "BYD touchpad detected\n");



-- 
Dmitry

  reply	other threads:[~2016-10-07 23:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-07  4:41 [PATCH 01/01] drivers:input:byd fix greedy detection of Sentelic FSP by the BYD touchpad driver Christophe Tordeux
2016-10-07 23:37 ` Dmitry Torokhov [this message]
2016-10-08  1:51   ` Christophe Tordeux
  -- strict thread matches above, loose matches on Subject: below --
2016-09-25  3:31 Christophe TORDEUX

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=20161007233726.GB21386@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=christophe@tordeux.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).