linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chris Diamand <chris@diamand.org>
To: Richard Pospesel <pospeselr@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	phonesyfreakies@gmail.com
Subject: Re: [PATCH] Input: byd - fix issue where generic PS/2 mice are detected as BYD touchpad
Date: Mon, 11 Jul 2016 21:26:20 +0100	[thread overview]
Message-ID: <20160711202620.GA24346@smaug> (raw)
In-Reply-To: <1467172878-25483-1-git-send-email-pospeselr@gmail.com>

Hi Richard,

Thanks for working on this!

Patch looks mostly good, and seems to have worked judging by the comments on
the bug report. Not many comments from me as it's just moving stuff around.

I think it might be better to keep detect() and init() separate - it seems to
me that a detect() function shouldn't really have any side effects (even if
we're certain it's a BYD touchpad), so doing kzalloc and setting up the timer
in detect() feels a bit wrong.

But as mentioned earlier, we shouldn't do the touchpad initialisation twice.
So maybe do the magic sequence stuff in detect(), and the actual driver init
in init().

> Input: byd - fix issue where generic PS/2 mice are...

You may need a shorter commit title.

> The secret handshake used was not sufficient to determine whether the connected
> device was actually a BYD touchpad.  Added some restrictions on what the first
> byte returned may be (based off of experiments with BYD touchapd).  Moved
> subsequent initialization logic from byd_init to tail of byd_detect, and
> removed byd_init function.
> 
> Fixes bug 1201781.  Tested on laptop with BYD touchpad hardware.
> 
> Applied against commit fcd6eb50eadd83f857eac55f99316f1789707cdb

Probably don't need this in the commit message.

> 
> Signed-off-by: Richard Pospesel <pospeselr@gmail.com>
> 
> ---
> diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
> index ec73f75..92f5556 100644
> --- a/drivers/input/mouse/byd.c
> +++ b/drivers/input/mouse/byd.c
> @@ -2,6 +2,10 @@
>   * BYD TouchPad PS/2 mouse driver
>   *
>   * Copyright (C) 2015 Chris Diamand <chris@diamand.org>
> + * Copyright (C) 2015 Richard Pospesel
> + * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood
> + * Copyright (C) 2015 Martin Wimpress
> + * Copyright (C) 2015 Jay Kuri

I already updated these in 82aaa086019ce0e6fcd3a44c0a2e4329afe988b6, so no
need to include it here. (I think there's a disparity between input-next and
mainline).

>   *
>   * This program is free software; you can redistribute it and/or modify it
>   * under the terms of the GNU General Public License version 2 as published by
> @@ -355,7 +359,7 @@ static int byd_reset_touchpad(struct psmouse *psmouse)
>  		{ PSMOUSE_CMD_ENABLE, 0 },
>  		/*
>  		 * BYD-specific initialization, which enables absolute mode and
> -		 * (if desired), the touchpad's built-in gesture detection.
> +		 * disables the builtin hardware gesture recogniton.
>  		 */
>  		{ 0x10E2, 0x00 },
>  		{ 0x10E0, 0x02 },
> @@ -435,6 +439,10 @@ int byd_detect(struct psmouse *psmouse, bool set_properties)
>  	struct ps2dev *ps2dev = &psmouse->ps2dev;
>  	u8 param[4] = {0x03, 0x00, 0x00, 0x00};
> 
> +	if (psmouse_reset(psmouse))
> +		return -EIO;
> +
> +	/* 'Secret' handshake */
>  	if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
>  		return -1;
>  	if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
> @@ -446,62 +454,68 @@ int byd_detect(struct psmouse *psmouse, bool set_properties)
>  	if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
>  		return -1;
> 
> -	if (param[1] != 0x03 || param[2] != 0x64)
> +	/*
> +	 * BYD touchpad returns 0x03 for resolution ( 8 count / mm ) and
> +	 * 0x64 ( 100 samples / sec ) for sampling rate

Spaces inside brackets?

> +	 * The first byte's value is dependent on the mouse button states:
> +	 *  0 : no button pressed
> +	 *  1 : right button pressed
> +	 *  4 : left button pressed
> +	 *  5 : right and left button pressed
> +	 */
> +	if ((param[0] & 0x05) != param[0] ||

Neat. Took me a while though, would something like this be clearer?

    param[0] & ~(0x00 | 0x01 | 0x04 | 0x05)

Nothing to say on the rest.

Cheers!
Chris

  reply	other threads:[~2016-07-11 20:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-26  2:25 Input: byd - fix issue where generic PS/2 mice are detected as BYD touchpad Richard Pospesel
2016-06-26  2:25 ` [PATCH] made the byd_detect function more restrictive to prevent false positives when actual mouse is a generic PS/2 mouse; byd_detect now tries to go through BYD touchpad configuration steps, which fail when not performed on " Richard Pospesel
2016-06-27 21:34   ` Dmitry Torokhov
2016-06-29  4:01     ` [PATCH] Input: byd - fix issue where generic PS/2 mice are detected as " Richard Pospesel
2016-07-11 20:26       ` Chris Diamand [this message]
2016-07-12  2:57         ` Dmitry Torokhov
2016-07-14 16:46           ` Dmitry Torokhov
     [not found]             ` <CAHc7Qt1AEdCxu+rnrYqMRNQFGac4VuNFG=tfTSeHam4SnB3F3w@mail.gmail.com>
2016-08-02 11:32               ` Chris Diamand
2016-08-18 10:04                 ` Benjamin Tissoires

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=20160711202620.GA24346@smaug \
    --to=chris@diamand.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=phonesyfreakies@gmail.com \
    --cc=pospeselr@gmail.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;
as well as URLs for NNTP newsgroup(s).