2010-11-27 03:57:05

by Li, Yan I

[permalink] [raw]
Subject: [PATCH] Input: Lenovo S10-3t's touchpad support

This is for kernel bug #18122 and MeeGo bug #4807.

Current code detects Clickpad by checking the 8 and 20 bits of 0x0c
cap. However, the code returns true if either of those bits is 1,
while it should only return true when both are 1. This has lead to the
touchpad on Lenovo S10-3t be mistakenly recognized as Clickpad and its
BTN_LEFT and BTN_RIGHT blocked.

So far we've found that the S10-3ts are shipped with two slightly
different models of touchpads, of which the 0x0c cap is either
0x5a0400 or 0x4a0500. They are not Clickpad and return BTN_LEFT and
BTN_RIGHT normally.

This patch fixed this issue by checking both sign bits are 1. Tested
on my S10-3t and worked well.

Signed-off-by: Yan Li <[email protected]>
---
drivers/input/mouse/synaptics.h | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 613a365..0c1083c 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -51,7 +51,11 @@
#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
-#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100)
+/* Synaptics' ClickPad has both 8th and 20th bits set in the 0x0c
+ * cap. Other models (like those shipped with Lenovo S10-3t) may have
+ * either one of them set but not both, and they are *not* ClickPad
+ * although they look similar. */
+#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100 == 0x100100)
#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000)

/* synaptics modes query bits */
--
1.7.2.3


--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net


2010-11-27 07:55:39

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH] Input: Lenovo S10-3t's touchpad support

Hi Yan,

On Sat, Nov 27, 2010 at 11:56:59AM +0800, Yan Li wrote:
> This is for kernel bug #18122 and MeeGo bug #4807.
>
> Current code detects Clickpad by checking the 8 and 20 bits of 0x0c
> cap. However, the code returns true if either of those bits is 1,
> while it should only return true when both are 1. This has lead to the
> touchpad on Lenovo S10-3t be mistakenly recognized as Clickpad and its
> BTN_LEFT and BTN_RIGHT blocked.
>
> So far we've found that the S10-3ts are shipped with two slightly
> different models of touchpads, of which the 0x0c cap is either
> 0x5a0400 or 0x4a0500. They are not Clickpad and return BTN_LEFT and
> BTN_RIGHT normally.

Hmm, this is weird. According to my data:

>> Treat it as a two-bit field.
>> 0x00 == not a clickpad
>> 0x01 == 1 button clickpad
>> 0x02 == 2 button clickpad
>> 0x03 == reserved

Moreover, Takashi's HP returns 0x5a 0x04 0x00 in response to 0x0c query
and _is_ a clickpad.

Christopher, was there any more updates to the protocol by any chance?

>
> This patch fixed this issue by checking both sign bits are 1. Tested
> on my S10-3t and worked well.
>
> Signed-off-by: Yan Li <[email protected]>
> ---
> drivers/input/mouse/synaptics.h | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
> index 613a365..0c1083c 100644
> --- a/drivers/input/mouse/synaptics.h
> +++ b/drivers/input/mouse/synaptics.h
> @@ -51,7 +51,11 @@
> #define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
> #define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
> #define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
> -#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100)
> +/* Synaptics' ClickPad has both 8th and 20th bits set in the 0x0c
> + * cap. Other models (like those shipped with Lenovo S10-3t) may have
> + * either one of them set but not both, and they are *not* ClickPad
> + * although they look similar. */
> +#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100 == 0x100100)

In C comparison operators have higher precedence than bitwise ones. Your
expression reduces to ((ex0c) & 1) which is not correct. The proper
expression would be:

#define SYN_CAP_CLICKPAD(ex0c) (((ex0c) & 0x100100) == 0x100100)

but it really contradicts the data I have...

Thanks.

--
Dmitry

2010-11-30 02:18:45

by Li, Yan I

[permalink] [raw]
Subject: Re: [PATCH] Input: Lenovo S10-3t's touchpad support

On Sat, Nov 27, 2010 at 03:55:28PM +0800, Dmitry Torokhov wrote:
> > So far we've found that the S10-3ts are shipped with two slightly
> > different models of touchpads, of which the 0x0c cap is either
> > 0x5a0400 or 0x4a0500. They are not Clickpad and return BTN_LEFT and
> > BTN_RIGHT normally.
>
> Hmm, this is weird. According to my data:
>
> >> Treat it as a two-bit field.
> >> 0x00 == not a clickpad
> >> 0x01 == 1 button clickpad
> >> 0x02 == 2 button clickpad
> >> 0x03 == reserved

Wait, you said there are "2 button clickpad"? If so the current way
the kernel handles clickpad is totally wrong:

if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
/* Clickpads report only left button */
__clear_bit(BTN_RIGHT, dev->keybit);
__clear_bit(BTN_MIDDLE, dev->keybit);
}

It could only handle those "1 button clickpad", which emits solely
BTN_MIDDLE (and the kernel sends it out as BTN_LEFT instead). It can't
handle "2 button clickpad" correctly.

So I think the touchpad installed on the S10-3t is a "2 button
clickpad" and it emits BTN_LEFT and BTN_RIGHT as usual.

Also IIRC the current X synaptics driver detects clickpad by checking
whether it has one button only, obviously this could not work with 2
button clickpad either.

--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net

2010-11-30 07:12:39

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] Input: Lenovo S10-3t's touchpad support

At Tue, 30 Nov 2010 10:18:40 +0800,
Li, Yan I wrote:
>
> On Sat, Nov 27, 2010 at 03:55:28PM +0800, Dmitry Torokhov wrote:
> > > So far we've found that the S10-3ts are shipped with two slightly
> > > different models of touchpads, of which the 0x0c cap is either
> > > 0x5a0400 or 0x4a0500. They are not Clickpad and return BTN_LEFT and
> > > BTN_RIGHT normally.
> >
> > Hmm, this is weird. According to my data:
> >
> > >> Treat it as a two-bit field.
> > >> 0x00 == not a clickpad
> > >> 0x01 == 1 button clickpad
> > >> 0x02 == 2 button clickpad
> > >> 0x03 == reserved
>
> Wait, you said there are "2 button clickpad"? If so the current way
> the kernel handles clickpad is totally wrong:
>
> if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) {
> /* Clickpads report only left button */
> __clear_bit(BTN_RIGHT, dev->keybit);
> __clear_bit(BTN_MIDDLE, dev->keybit);
> }
>
> It could only handle those "1 button clickpad", which emits solely
> BTN_MIDDLE (and the kernel sends it out as BTN_LEFT instead). It can't
> handle "2 button clickpad" correctly.

The "normal" clickpad also reports that bit. I don't see any
difference between Lenovo and HP machines wrt caps values.
It shows the exact same numbers below:

Synaptics Touchpad, model: 1, fw: 7.4, id: 0x1e0b1, caps:
0xd04771/0xe40000/0x5a0400


Takashi

2010-11-30 07:44:11

by Li, Yan I

[permalink] [raw]
Subject: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

This is for kernel bug #18122 and MeeGo bug #4807, version 2.

Lenovo S10-3t's ClickPad is a 2-button ClickPad that reports BTN_LEFT
and BTN_RIGHT as normal touchpad, unlike the 1-button ClickPad used in
HP mini 210 that reports solely BTN_MIDDLE.

Of c0-cap response, the 1-button ClickPad has the 20-bit set while
2-button ClickPad has the 8-bit set.

This patch makes the kernel only handle 1-button ClickPad specially,
and treat 2-button ClickPad as same as other normal touchpads.

Signed-off-by: Yan Li <[email protected]>
---
drivers/input/mouse/synaptics.h | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 613a365..20468b6 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -51,7 +51,13 @@
#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20)
#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12)
#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16)
-#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100100)
+/* This macro detects 1-button ClickPad. Of ex0c capacity, if the
+ * 20-bit of ex0c is set the touchpad is a 1-button ClickPad, which
+ * needs special handling because it reports only BTN_MIDDLE. If the
+ * 8-bit is set it is a 2-button ClickPad which reports BTN_* events
+ * normally and needs no special handling. Therefore this macro
+ * detects 1-button ClickPad only. */
+#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100000)
#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000)

/* synaptics modes query bits */
--
1.7.2.3


--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net

2010-11-30 07:50:36

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

On Tue, Nov 30, 2010 at 03:44:06PM +0800, Yan Li wrote:
> This is for kernel bug #18122 and MeeGo bug #4807, version 2.
>
> Lenovo S10-3t's ClickPad is a 2-button ClickPad that reports BTN_LEFT
> and BTN_RIGHT as normal touchpad, unlike the 1-button ClickPad used in
> HP mini 210 that reports solely BTN_MIDDLE.
>
> Of c0-cap response, the 1-button ClickPad has the 20-bit set while
> 2-button ClickPad has the 8-bit set.
>
> This patch makes the kernel only handle 1-button ClickPad specially,
> and treat 2-button ClickPad as same as other normal touchpads.
>

As Takashi mentioned, HP Clickpads have the same 0x0c signature than
Lenovos non-clickpads so this is not that simple. We need to wait and
see if Christopher will shed some light here...

Thanks.

--
Dmitry

2010-11-30 08:08:07

by Li, Yan I

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

On Tue, Nov 30, 2010 at 03:50:26PM +0800, Dmitry Torokhov wrote:
> On Tue, Nov 30, 2010 at 03:44:06PM +0800, Yan Li wrote:
> > This is for kernel bug #18122 and MeeGo bug #4807, version 2.
> >
> > Lenovo S10-3t's ClickPad is a 2-button ClickPad that reports BTN_LEFT
> > and BTN_RIGHT as normal touchpad, unlike the 1-button ClickPad used in
> > HP mini 210 that reports solely BTN_MIDDLE.
> >
> > Of c0-cap response, the 1-button ClickPad has the 20-bit set while
> > 2-button ClickPad has the 8-bit set.
> >
> > This patch makes the kernel only handle 1-button ClickPad specially,
> > and treat 2-button ClickPad as same as other normal touchpads.
> >
>
> As Takashi mentioned, HP Clickpads have the same 0x0c signature than
> Lenovos non-clickpads so this is not that simple. We need to wait and
> see if Christopher will shed some light here...

So the only exception is the one reported by tob. These are the bits
I've collected:

Yan's S10-3t: model: 1, fw: 7.4, id: 0x1e0b1, caps: 0xd04771/0xa40000/0x4a0500 (2 button clickpad)
tob's S10-3t: model: 1, fw: 7.4, id: 0x1e0b1, caps: 0xd04771/0xe40000/0x5a0400 (?)
hp Envy 14/mini210:
model: 1, fw: 7.4, id: 0x1e0b1, caps: 0xd04771/0xe40000/0x5a0400 (1 button clickpad)

I asked tob to double-check his model and whether his touchpad emits
BTN_MIDDLE or not but get no reply yet. I've checked 4 S10-3t
purchased at different dates and all of them show same exc0 cap, but I
have to say other models selling in other parts of the world may be
still different.

--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net

2010-11-30 08:09:21

by Li, Yan I

[permalink] [raw]
Subject: Re: [PATCH] Input: Lenovo S10-3t's touchpad support

On Tue, Nov 30, 2010 at 03:12:36PM +0800, Takashi Iwai wrote:
> > It could only handle those "1 button clickpad", which emits solely
> > BTN_MIDDLE (and the kernel sends it out as BTN_LEFT instead). It can't
> > handle "2 button clickpad" correctly.
>
> The "normal" clickpad also reports that bit. I don't see any
> difference between Lenovo and HP machines wrt caps values.
> It shows the exact same numbers below:
>
> Synaptics Touchpad, model: 1, fw: 7.4, id: 0x1e0b1, caps:
> 0xd04771/0xe40000/0x5a0400

My S10-3t shows this:
model: 1, fw: 7.4, id: 0x1e0b1, caps: 0xd04771/0xa40000/0x4a0500

--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net

2010-11-30 15:55:00

by Tobyn Bertram

[permalink] [raw]
Subject: RE: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

I do not have a S10-3t. I have a HP DV7t with a standard 1 button Clickpad.
I am sorry for any confusion.

I think that 2 different Clickpads will need to be defined: 1 button
Clickpads and 2 button Clickpads. Maybe like this?

#define SYN_CAP_CLICKPAD1BTN(ex0c) ((ex0c) & 0x100000)
#define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100)

Tobyn

-----Original Message-----
From: Li, Yan I [mailto:[email protected]]
Sent: Tuesday, November 30, 2010 12:08 AM
To: Dmitry Torokhov; [email protected]
Cc: [email protected]; Takashi Iwai; Ding, Jian-feng;
[email protected]; [email protected]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button
ClickPad

On Tue, Nov 30, 2010 at 03:50:26PM +0800, Dmitry Torokhov wrote:
> On Tue, Nov 30, 2010 at 03:44:06PM +0800, Yan Li wrote:
> > This is for kernel bug #18122 and MeeGo bug #4807, version 2.
> >
> > Lenovo S10-3t's ClickPad is a 2-button ClickPad that reports BTN_LEFT
> > and BTN_RIGHT as normal touchpad, unlike the 1-button ClickPad used in
> > HP mini 210 that reports solely BTN_MIDDLE.
> >
> > Of c0-cap response, the 1-button ClickPad has the 20-bit set while
> > 2-button ClickPad has the 8-bit set.
> >
> > This patch makes the kernel only handle 1-button ClickPad specially,
> > and treat 2-button ClickPad as same as other normal touchpads.
> >
>
> As Takashi mentioned, HP Clickpads have the same 0x0c signature than
> Lenovos non-clickpads so this is not that simple. We need to wait and
> see if Christopher will shed some light here...

So the only exception is the one reported by tob. These are the bits
I've collected:

Yan's S10-3t: model: 1, fw: 7.4, id: 0x1e0b1, caps:
0xd04771/0xa40000/0x4a0500 (2 button clickpad)
tob's S10-3t: model: 1, fw: 7.4, id: 0x1e0b1, caps:
0xd04771/0xe40000/0x5a0400 (?)
hp Envy 14/mini210:
model: 1, fw: 7.4, id: 0x1e0b1, caps:
0xd04771/0xe40000/0x5a0400 (1 button clickpad)

I asked tob to double-check his model and whether his touchpad emits
BTN_MIDDLE or not but get no reply yet. I've checked 4 S10-3t
purchased at different dates and all of them show same exc0 cap, but I
have to say other models selling in other parts of the world may be
still different.

--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net

2010-12-01 04:11:10

by Li, Yan I

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

On Tue, Nov 30, 2010 at 11:48:12PM +0800, Tobyn Bertram wrote:
> I do not have a S10-3t. I have a HP DV7t with a standard 1 button Clickpad.
> I am sorry for any confusion.

Thank you. This clarify the S10-3t touchpad mystery. So I think my v2
patch is valid.

> I think that 2 different Clickpads will need to be defined: 1 button
> Clickpads and 2 button Clickpads. Maybe like this?
>
> #define SYN_CAP_CLICKPAD1BTN(ex0c) ((ex0c) & 0x100000)
> #define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100)

Maybe, although we don't have any code that needs
SYN_CAP_CLICKPAD2BTN() so far, only 1-button clickpad needs special
handling, but it's good to have a more precise name.

--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net

2010-12-01 06:04:22

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

At Wed, 1 Dec 2010 12:11:04 +0800,
Li, Yan I wrote:
>
> On Tue, Nov 30, 2010 at 11:48:12PM +0800, Tobyn Bertram wrote:
> > I do not have a S10-3t. I have a HP DV7t with a standard 1 button Clickpad.
> > I am sorry for any confusion.
>
> Thank you. This clarify the S10-3t touchpad mystery. So I think my v2
> patch is valid.
>
> > I think that 2 different Clickpads will need to be defined: 1 button
> > Clickpads and 2 button Clickpads. Maybe like this?
> >
> > #define SYN_CAP_CLICKPAD1BTN(ex0c) ((ex0c) & 0x100000)
> > #define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100)
>
> Maybe, although we don't have any code that needs
> SYN_CAP_CLICKPAD2BTN() so far, only 1-button clickpad needs special
> handling, but it's good to have a more precise name.

Agreed. Also, it's interesting to see how 2-button clickpad devices
behave in multi-touch mode...


thanks,

Takashi

2010-12-01 07:18:23

by Li, Yan I

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

On Wed, Dec 01, 2010 at 02:41:14PM +0800, Tobyn Bertram wrote:
> The 2-button Clickpad will probably need some code to handle click and drag properly in multi-touch mode.

Talk to a kernel developer and s/he will tell you to implement that
logic in X. :)

In X we already have so much code to handle the complexity and quirks
of 1000 different touchpads in the wild.

--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net

2010-12-01 07:23:13

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

On Wed, Dec 01, 2010 at 03:18:19PM +0800, Li, Yan I wrote:
> On Wed, Dec 01, 2010 at 02:41:14PM +0800, Tobyn Bertram wrote:
> > The 2-button Clickpad will probably need some code to handle click and drag properly in multi-touch mode.
>
> Talk to a kernel developer and s/he will tell you to implement that
> logic in X. :)
>

You knew, you knew ;)

--
Dmitry

2010-12-01 07:47:43

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

On Wed, Dec 01, 2010 at 12:11:04PM +0800, Li, Yan I wrote:
> On Tue, Nov 30, 2010 at 11:48:12PM +0800, Tobyn Bertram wrote:
> > I do not have a S10-3t. I have a HP DV7t with a standard 1 button Clickpad.
> > I am sorry for any confusion.
>
> Thank you. This clarify the S10-3t touchpad mystery. So I think my v2
> patch is valid.
>

Yep, I'll queue it gfor .37.

Thanks,

--
Dmitry

2010-12-01 08:01:28

by Li, Yan I

[permalink] [raw]
Subject: Re: [PATCH v2] Input: Bug 18122 - Support Lenovo S10-3t's 2-button ClickPad

On Wed, Dec 01, 2010 at 03:46:49PM +0800, Dmitry Torokhov wrote:
> On Wed, Dec 01, 2010 at 12:11:04PM +0800, Li, Yan I wrote:
> > On Tue, Nov 30, 2010 at 11:48:12PM +0800, Tobyn Bertram wrote:
> > > I do not have a S10-3t. I have a HP DV7t with a standard 1 button Clickpad.
> > > I am sorry for any confusion.
> >
> > Thank you. This clarify the S10-3t touchpad mystery. So I think my v2
> > patch is valid.
> >
>
> Yep, I'll queue it gfor .37.

Thank you. Here we're testing it extensively. Will report if I seen
any new issues.

--
Best regards,
Li, Yan

MeeGo Team, Opensource Technology Center, SSG, Intel
Office tel.: +86-10-82171695 (inet: 8-758-1695)
OpenPGP key: 5C6C31EF
IRC: yanli on network irc.freenode.net