History log of /linux-master/drivers/input/mouse/synaptics.c
Revision Date Author Comments
# c1f342f3 15-Nov-2023 José Pekkarinen <jose.pekkarinen@foxhound.fi>

Input: psmouse - enable Synaptics InterTouch for ThinkPad L14 G1

Observed on dmesg of my laptop I see the following
output:

[ 19.898700] psmouse serio1: synaptics: queried max coordinates: x [..5678], y [..4694]
[ 19.936057] psmouse serio1: synaptics: queried min coordinates: x [1266..], y [1162..]
[ 19.936076] psmouse serio1: synaptics: Your touchpad (PNP: LEN0411 PNP0f13) says it can support a different bus. If i2c-hid and hid-rmi are not used, you might want to try setting psmouse.synaptics_intertouch to 1 and report this to linux-input@vger.kernel.org.
[ 20.008901] psmouse serio1: synaptics: Touchpad model: 1, fw: 10.32, id: 0x1e2a1, caps: 0xf014a3/0x940300/0x12e800/0x500000, board id: 3471, fw id: 2909640
[ 20.008925] psmouse serio1: synaptics: serio: Synaptics pass-through port at isa0060/serio1/input0
[ 20.053344] input: SynPS/2 Synaptics TouchPad as /devices/platform/i8042/serio1/input/input7
[ 20.397608] mousedev: PS/2 mouse device common for all mice

This patch will add its pnp id to the smbus list to
produce the setup of intertouch for the device.

Signed-off-by: José Pekkarinen <jose.pekkarinen@foxhound.fi>
Link: https://lore.kernel.org/r/20231114063607.71772-1-jose.pekkarinen@foxhound.fi
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 5030b2fe 13-Oct-2023 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics-rmi4 - handle reset delay when using SMBus trsnsport

Touch controllers need some time after receiving reset command for the
firmware to finish re-initializing and be ready to respond to commands
from the host. The driver already had handling for the post-reset delay
for I2C and SPI transports, this change adds the handling to
SMBus-connected devices.

SMBus devices are peculiar because they implement legacy PS/2
compatibility mode, so reset is actually issued by psmouse driver on the
associated serio port, after which the control is passed to the RMI4
driver with SMBus companion device.

Note that originally the delay was added to psmouse driver in
92e24e0e57f7 ("Input: psmouse - add delay when deactivating for SMBus
mode"), but that resulted in an unwanted delay in "fast" reconnect
handler for the serio port, so it was decided to revert the patch and
have the delay being handled in the RMI4 driver, similar to the other
transports.

Tested-by: Jeffery Miller <jefferymiller@google.com>
Link: https://lore.kernel.org/r/ZR1yUFJ8a9Zt606N@penguin
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e2cb5cc8 13-Oct-2023 Jeffery Miller <jefferymiller@google.com>

Input: psmouse - fix fast_reconnect function for PS/2 mode

When the SMBus connection is attempted psmouse_smbus_init() sets
the fast_reconnect pointer to psmouse_smbus_reconnecti(). If SMBus
initialization fails, elantech_setup_ps2() and synaptics_init_ps2() will
fallback to PS/2 mode, replacing the psmouse private data. This can cause
issues on resume, since psmouse_smbus_reconnect() expects to find an
instance of struct psmouse_smbus_dev in psmouse->private.

The issue was uncovered when in 92e24e0e57f7 ("Input: psmouse - add
delay when deactivating for SMBus mode") psmouse_smbus_reconnect()
started attempting to use more of the data structure. The commit was
since reverted, not because it was at fault, but because there was found
a better way of doing what it was attempting to do.

Fix the problem by resetting the fast_reconnect pointer in psmouse
structure in elantech_setup_ps2() and synaptics_init_ps2() when the PS/2
mode is used.

Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
Tested-by: Thorsten Leemhuis <linux@leemhuis.info>
Signed-off-by: Jeffery Miller <jefferymiller@google.com>
Fixes: bf232e460a35 ("Input: psmouse-smbus - allow to control psmouse_deactivate")
Link: https://lore.kernel.org/r/20231005002249.554877-1-jefferymiller@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 100e1695 11-May-2023 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: libps2 - attach ps2dev instances as serio port's drvdata

In preparation of having unified interrupt handler for PS/2 devices,
instead of attaching instances of psmouse and atkbd structures as serio's
driver data, switch to attaching ps2dev instances.

Reviewed-by: Raul Rangel <rrangel@chromium.org>
Link: https://lore.kernel.org/r/20230511185252.386941-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 3c44e2b6 16-Dec-2022 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Revert "Input: synaptics - switch touchpad on HP Laptop 15-da3001TU to RMI mode"

This reverts commit ac5408991ea6b06e29129b4d4861097c4c3e0d59 because
it causes loss of keyboard on HP 15-da1xxx.

Fixes: ac5408991ea6 ("Input: synaptics - switch touchpad on HP Laptop 15-da3001TU to RMI mode")
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/824effa5-8b9a-c28a-82bb-9b0ab24623e1@kernel.org
Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1206358
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ac540899 15-Oct-2022 Aman Dhoot <amandhoot12@gmail.com>

Input: synaptics - switch touchpad on HP Laptop 15-da3001TU to RMI mode

The device works fine in native RMI mode, there is no reason to use legacy
PS/2 mode with it.

Signed-off-by: Aman Dhoot <amandhoot12@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 7984b435 14-Sep-2022 Lyude Paul <lyude@redhat.com>

Input: synaptics - enable InterTouch for the ThinkPad P1 G3

Noticed this while trying to debug some unrelated issues: this laptop has
the ability to use rmi4 but doesn't by default. So let's fix that.

Tested locally, including mouse buttons, on my ThinkPad P1 G3. This might
also enable the X1 Extreme G3, but I don't have such a system to test
locally (presumably Mark can chime in if that's the case).

Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20220909202127.141761-1-lyude@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# a9f08ad7 18-Aug-2022 Wolfram Sang <wsa+renesas@sang-engineering.com>

Input: move from strlcpy with unused retval to strscpy

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Link: https://lore.kernel.org/r/20220818210022.6865-1-wsa+renesas@sang-engineering.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 2fd003ee 24-Sep-2022 Mark Pearson <markpearson@lenovo.com>

Input: synaptics - disable Intertouch for Lenovo T14 and P14s AMD G1

Since intertouch was enabled for the T14 and P14s AMD G1 laptops there
have been a number of reports of touchpads not working well.

Debugging this with Synaptics they noted that intertouch should not be
enabled as SMBUS host notify is not available on these laptops.

Reverting the previous commit (e4ce4d3a939d97bea045eafa13ad1195695f91ce)
to restore functionality back to what it was.

Note - we are working with Synaptics to see if there is a better
solution, but nothing is confirmed as yet.

Signed-off-by: Mark Pearson <markpearson@lenovo.com>
Link: https://lore.kernel.org/r/20220920193936.8709-1-markpearson@lenovo.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e4ce4d3a 20-Mar-2022 Matthew Haughton <snafu109@gmail.com>

Input: synaptics - enable InterTouch on ThinkPad T14/P14s Gen 1 AMD

Confirmed LEN2064 on my P14s works with psmouse.synaptics_intertouch=1
By all accounts T14 and P14s are the same hardware which only differ by
model identifier.

Signed-off-by: Matthew Haughton <snafu109@gmail.com>
Link: https://lore.kernel.org/r/20220318113949.32722-1-snafu109@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# a1ba9c29 19-Jan-2021 Lee Jones <lee.jones@linaro.org>

Input: synaptics - replace NOOP with suitable commentary

Fixes the following W=1 kernel build warning(s):

drivers/input/mouse/synaptics.c: In function ‘synaptics_process_packet’:
drivers/input/mouse/synaptics.c:1110:6: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20210114152323.2382283-2-lee.jones@linaro.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 58e5183a 19-Nov-2020 Lee Jones <lee.jones@linaro.org>

Input: synaptics - demote non-conformant kernel-doc header

Fixes the following W=1 kernel build warning(s):

drivers/input/mouse/synaptics.c:1781: warning: Function parameter or member 'psmouse' not described in 'synaptics_setup_intertouch'
drivers/input/mouse/synaptics.c:1781: warning: Function parameter or member 'info' not described in 'synaptics_setup_intertouch'
drivers/input/mouse/synaptics.c:1781: warning: Function parameter or member 'leave_breadcrumbs' not described in 'synaptics_setup_intertouch'

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20201112110204.2083435-13-lee.jones@linaro.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 470d154a6 05-Oct-2020 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - enable InterTouch for ThinkPad T14 Gen 1

With the new RMI4 F3A support, we're now able to enable full RMI4
support for this model.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20201005114919.371592-1-hdegoede@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 127e4a1b 04-Oct-2020 Jason A. Donenfeld <Jason@zx2c4.com>

Input: synaptics - enable InterTouch for ThinkPad P1/X1E gen 2

With the new RMI4 F3A support, we're now able to enable full RMI4
support for this model. We also tidy up the comments a bit, as the X1E
is essentially the same computer as the P1.

Acked-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Link: https://lore.kernel.org/r/20200930225046.173190-3-Jason@zx2c4.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 261bfb33 04-Oct-2020 Vincent Huang <vincent.huang@tw.synaptics.com>

Input: synaptics-rmi4 - rename f30_data to gpio_data

f30_data in rmi_device_platform_data could be also referenced by RMI
function 3A, so rename it and the structure name to avoid confusion.

Signed-off-by: Vincent Huang <vincent.huang@tw.synaptics.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andrew Duggan <aduggan@synaptics.com>
Link: https://lore.kernel.org/r/20200930094147.635556-2-vincent.huang@tw.synaptics.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# dcb00fc7 06-Jul-2020 Ilya Katsnelson <me@0upti.me>

Input: synaptics - enable InterTouch for ThinkPad X1E 1st gen

Tested on my own laptop, touchpad feels slightly more responsive with
this on, though it might just be placebo.

Signed-off-by: Ilya Katsnelson <me@0upti.me>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20200703143457.132373-1-me@0upti.me
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 642aa86e 27-May-2020 Dennis Kadioglu <denk@eclipso.email>

Input: synaptics - add a second working PNP_ID for Lenovo T470s

The Lenovo Thinkpad T470s I own has a different touchpad with "LEN007a"
instead of the already included PNP ID "LEN006c". However, my touchpad
seems to work well without any problems using RMI. So this patch adds the
other PNP ID.

Signed-off-by: Dennis Kadioglu <denk@eclipso.email>
Link: https://lore.kernel.org/r/ff770543cd53ae818363c0fe86477965@mail.eclipso.de
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 1369d0ab 07-Mar-2020 Yussuf Khalil <dev@pp3345.net>

Input: synaptics - enable RMI on HP Envy 13-ad105ng

This laptop (and perhaps other variants of the same model) reports an
SMBus-capable Synaptics touchpad. Everything (including suspend and
resume) works fine when RMI is enabled via the kernel command line, so
let's add it to the whitelist.

Signed-off-by: Yussuf Khalil <dev@pp3345.net>
Link: https://lore.kernel.org/r/20200307213508.267187-1-dev@pp3345.net
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 5179a9df 13-Feb-2020 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - remove the LEN0049 dmi id from topbuttonpad list

The Yoga 11e is using LEN0049, but it doesn't have a trackstick.

Thus, there is no need to create a software top buttons row.

However, it seems that the device works under SMBus, so keep it as part
of the smbus_pnp_ids.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200115013023.9710-1-benjamin.tissoires@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# b8a3d819 13-Feb-2020 Gaurav Agrawal <agrawalgaurav@gnome.org>

Input: synaptics - enable SMBus on ThinkPad L470

Add touchpad LEN2044 to the list, as it is capable of working with
psmouse.synaptics_intertouch=1

Signed-off-by: Gaurav Agrawal <agrawalgaurav@gnome.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/CADdtggVzVJq5gGNmFhKSz2MBwjTpdN5YVOdr4D3Hkkv=KZRc9g@mail.gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# bf502391 13-Feb-2020 Lyude Paul <lyude@redhat.com>

Input: synaptics - switch T470s to RMI4 by default

This supports RMI4 and everything seems to work, including the touchpad
buttons. So, let's enable this by default.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200204194322.112638-1-lyude@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# fc1156f3 22-Nov-2019 Hans Verkuil <hverkuil-cisco@xs4all.nl>

Input: synaptics - switch another X1 Carbon 6 to RMI/SMbus

Some Lenovo X1 Carbon Gen 6 laptops report LEN0091. Add this
to the smbus_pnp_ids list.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20191119105118.54285-2-hverkuil-cisco@xs4all.nl
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 87916634 22-Nov-2019 Lyude Paul <lyude@redhat.com>

Revert "Input: synaptics - enable RMI mode for X1 Extreme 2nd Generation"

This reverts commit 68b9c5066e39af41d3448abfc887c77ce22dd64d.

Ugh, I really dropped the ball on this one :\. So as it turns out RMI4
works perfectly fine on the X1 Extreme Gen 2 except for one thing I
didn't notice because I usually use the trackpoint: clicking with the
touchpad. Somehow this is broken, in fact we don't even seem to indicate
BTN_LEFT as a valid event type for the RMI4 touchpad. And, I don't even
see any RMI4 events coming from the touchpad when I press down on it.
This only seems to work for PS/2 mode.

Since that means we have a regression, and PS/2 mode seems to work fine
for the time being - revert this for now. We'll have to do a more
thorough investigation on this.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20191119234534.10725-1-lyude@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 768ea88bc 15-Nov-2019 Lyude Paul <lyude@redhat.com>

Input: synaptics - enable RMI mode for X1 Extreme 2nd Generation

Just got one of these for debugging some unrelated issues, and noticed
that Lenovo seems to have gone back to using RMI4 over smbus with
Synaptics touchpads on some of their new systems, particularly this one.
So, let's enable RMI mode for the X1 Extreme 2nd Generation.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20191115221814.31903-1-lyude@redhat.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 26332247 09-Aug-2019 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Input: synaptics - fix a typo

This should be 'synaptics', not 'synpatics'

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 25f8c834 12-Jul-2019 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - enable RMI mode for HP Spectre X360

The 2016 kabylake HP Spectre X360 (model number 13-w013dx) works much better
with psmouse.synaptics_intertouch=1 kernel parameter, so let's enable RMI4
mode automatically.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204115
Reported-by: Nate Graham <pointedstick@zoho.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# d38b6cf5 14-Jul-2019 Joe Perches <joe@perches.com>

Input: synaptics - fix misuse of strlcpy

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 1976d7d2 12-Jul-2019 Nick Black <dankamongmen@gmail.com>

Input: synaptics - whitelist Lenovo T580 SMBus intertouch

Adds the Lenovo T580 to the SMBus intertouch list for Synaptics
touchpads. I've tested with this for a week now, and it seems a great
improvement. It's also nice to have the complaint gone from dmesg.

Signed-off-by: Nick Black <dankamongmen@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# abbe3acd 01-Jul-2019 Cole Rogers <colerogers@disroot.org>

Input: synaptics - enable SMBUS on T480 thinkpad trackpad

Thinkpad t480 laptops had some touchpad features disabled, resulting in the
loss of pinch to activities in GNOME, on wayland, and other touch gestures
being slower. This patch adds the touchpad of the t480 to the smbus_pnp_ids
whitelist to enable the extra features. In my testing this does not break
suspend (on fedora, with wayland, and GNOME, using the rc-6 kernel), while
also fixing the feature on a T480.

Signed-off-by: Cole Rogers <colerogers@disroot.org>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

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 the free software foundation

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 the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 9843f3e0 12-Jun-2019 Alexander Mikhaylenko <exalm7659@gmail.com>

Input: synaptics - enable SMBus on ThinkPad E480 and E580

They are capable of using intertouch and it works well with
psmouse.synaptics_intertouch=1, so add them to the list.

Without it, scrolling and gestures are jumpy, three-finger pinch gesture
doesn't work and three- or four-finger swipes sometimes get stuck.

Signed-off-by: Alexander Mikhaylenko <exalm7659@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 7a717122 21-Dec-2018 Mantas Mikulėnas <grawity@gmail.com>

Input: synaptics - enable SMBus for HP EliteBook 840 G4

dmesg reports that "Your touchpad (PNP: SYN3052 SYN0100 SYN0002 PNP0f13)
says it can support a different bus."

I've tested the offered psmouse.synaptics_intertouch=1 with 4.18.x and
4.19.x and it seems to work well. No problems seen with suspend/resume.

Also, it appears that RMI/SMBus mode is actually required for 3-4 finger
multitouch gestures to work -- otherwise they are not reported at all.

Information from dmesg in both modes:

psmouse serio3: synaptics: Touchpad model: 1, fw: 8.2, id: 0x1e2b1,
caps: 0xf00123/0x840300/0x2e800/0x0, board id: 3139, fw id: 2000742

psmouse serio3: synaptics: Trying to set up SMBus access
rmi4_smbus 6-002c: registering SMbus-connected sensor
rmi4_f01 rmi4-00.fn01: found RMI device,
manufacturer: Synaptics, product: TM3139-001, fw id: 2000742

Signed-off-by: Mantas Mikulėnas <grawity@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ca504728 08-Dec-2018 Yussuf Khalil <dev@pp3345.net>

Input: synaptics - enable RMI on ThinkPad T560

Before commit 7fd6d98b89f3 ("i2c: i801: Allow ACPI AML access I/O
ports not reserved for SMBus"), enabling RMI on the T560 would cause
the touchpad to stop working after resuming from suspend. Now that
this issue is fixed, RMI can be enabled safely and works fine.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Yussuf Khalil <dev@pp3345.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 5a6dab15 03-Dec-2018 Teika Kazura <teika@gmx.com>

Input: synaptics - enable SMBus for HP 15-ay000

SMBus works fine for the touchpad with id SYN3221, used in the HP 15-ay000
series,

This device has been reported in these messages in the "linux-input"
mailing list:
* https://marc.info/?l=linux-input&m=152016683003369&w=2
* https://www.spinics.net/lists/linux-input/msg52525.html

Reported-by: Nitesh Debnath <niteshkd1999@gmail.com>
Reported-by: Teika Kazura <teika@gmx.com>
Signed-off-by: Teika Kazura <teika@gmx.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 9df39bed 25-Nov-2018 Lyude Paul <lyude@redhat.com>

Input: synaptics - add PNP ID for ThinkPad P50 to SMBus

Noticed the other day the trackpoint felt different on my P50, then
realized it was because rmi4 wasn't loading for this machine
automatically. Suspend/resume, hibernate, and everything else seem to
work perfectly fine on here.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# f39f8688 16-Oct-2018 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - avoid using uninitialized variable when probing

synaptics_detect() does not check whether sending commands to the
device succeeds and instead relies on getting unique data from the
device. Let's make sure we seed entire buffer with zeroes to make sure
we will not use garbage on stack that just happen to be 0x47.

Reported-by: syzbot+13cb3b01d0784e4ffc3f@syzkaller.appspotmail.com
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# bf232e46 22-May-2018 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: psmouse-smbus - allow to control psmouse_deactivate

This seems to be Synaptics specific, as some Elan touchpads are not
correctly switching to SMBus if we call deactivate before switching to
SMBus on cold boot and on resume.

Tested with the T480s

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: KT Liao <kt.liao@emc.com.tw>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ad8fb554 22-May-2018 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - add Lenovo 80 series ids to SMBus

This time, Lenovo decided to go with different pieces in its latest
series of Thinkpads.

For those we have been able to test:
- the T480 is using Synaptics with an IBM trackpoint
-> it behaves properly with or without intertouch, there is no point
not using RMI4
- the X1 Carbon 6th gen is using Synaptics with an IBM trackpoint
-> the touchpad doesn't behave properly under PS/2 so we have to
switch it to RMI4 if we do not want to have disappointed users
- the X280 is using Synaptics with an ALPS trackpoint
-> the recent fixes in the trackpoint handling fixed it so upstream
now works fine with or without RMI4, and there is no point not
using RMI4
- the T480s is using an Elan touchpad, so that's a different story

Cc: <stable@vger.kernel.org> # v4.14.x, v4.15.x, v4.16.x
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: KT Liao <kt.liao@emc.com.tw>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 5717a09a 03-Feb-2018 Aaron Ma <aaron.ma@canonical.com>

Input: synaptics - add Intertouch support on X1 Carbon 6th and X280

Synaptics devices reported it has Intertouch support,
and it fails via PS/2 as following logs:

psmouse serio2: Failed to reset mouse on synaptics-pt/serio0
psmouse serio2: Failed to enable mouse on synaptics-pt/serio0

Set these new devices to use SMBus to fix this issue, then they report
SMBus version 3 is using, patch:
https://patchwork.kernel.org/patch/9989547/ enabled SMBus ver 3 and
makes synaptics devices work fine on SMBus mode.

Signed-off-by: Aaron Ma <aaron.ma@canonical.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 15e2cffe 03-Feb-2018 Edvard Holst <edvard.holst@gmail.com>

Input: synaptics - Lenovo Thinkpad X1 Carbon G5 (2017) with Elantech trackpoints should use RMI

Lenovo use two different trackpoints in the fifth generation Thinkpad X1
Carbon. Both are accessible over SMBUS/RMI but the pnpIDs are missing.
This patch is for the Elantech trackpoint specifically which also
reports SMB version 3 so rmi_smbus needs to be updated in order to
handle it.

For the record, I was not the first one to come up with this patch as it
has been floating around the internet for a while now. However, I have
spent significant time with testing and my efforts to find the original
author of the patch have been unsuccessful.

Signed-off-by: Edvard Holst <edvard.holst@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 9b207102 18-Aug-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - Lenovo Carbon X1 Gen5 (2017) devices should use RMI

The touchpad on Lenovo Carbon X1 Gen 5 (2017 - Kabylake) is accessible over
SMBUS/RMI, so let's activate it by default.

Cc: stable@vger.kernel.org
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 5444a992 07-Mar-2018 Arkadiusz Hiler <arkadiusz.hiler@intel.com>

Revert "Input: synaptics - Lenovo Thinkpad T460p devices should use RMI"

This reverts commit 48282969826b3d3c76e908182f69724d86d995fe which
caused the following issues:

1. On T460p with BIOS version 2.22 touchpad and trackpoint stop working
after suspend-resume cycle. Due to strange state of the device another
suspend is impossible.

The following dmesg errors can be observed:
thinkpad_acpi: EC reports that Thermal Table has changed
rmi4_smbus 7-002c: failed to get SMBus version number!
rmi4_physical rmi4-00: rmi_driver_reset_handler: Failed to read current IRQ mask.
rmi4_f01 rmi4-00.fn01: Failed to restore normal operation: -16.
rmi4_f01 rmi4-00.fn01: Resume failed with code -16.
rmi4_physical rmi4-00: Failed to suspend functions: -16
rmi4_smbus 7-002c: Failed to resume device: -16
PM: resume devices took 0.640 seconds
rmi4_f03 rmi4-00.fn03: rmi_f03_pt_write: Failed to write to F03 TX register (-16).
rmi4_physical rmi4-00: rmi_driver_clear_irq_bits: Failed to change enabled interrupts!
rmi4_physical rmi4-00: rmi_driver_set_irq_bits: Failed to change enabled interrupts!
psmouse: probe of serio3 failed with error -1

2. On another T460p with BIOS version 2.15 two finger scrolling gesture
on the touchpad stops working after suspend-resume cycle (about 75%
reproducibility, when it still works, the scrolling gesture becomes
laggy). Nothing suspicious appears in the dmesg.

Analysis form Richard Schütz:

"RMI is unreliable on the ThinkPad T460p because the device is affected
by the firmware behavior addressed in a7ae81952cda ("i2c: i801: Allow
ACPI SystemIO OpRegion to conflict with PCI BAR")."

The affected devices often show:

i801_smbus 0000:00:1f.4: BIOS is accessing SMBus registers
i801_smbus 0000:00:1f.4: Driver SMBus register access inhibited

Reported-by: Richard Schütz <rschuetz@uni-koblenz.de>
Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Tested-by: Martin Peres <martin.peres@linux.intel.com>
Tested-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# cdc2466d 03-Apr-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - handle errors from input_mt_init_slots()

input_mt_init_slots() may fail, we need to handle this condition.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 29aa6194 03-Apr-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - switch to using input_set_capability

Instead of manipulating capability bits directly, use
input_set_capability().

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 08be954b 02-Jan-2018 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: psmouse - move sliced command implementation to libps2

In preparation to adding some debugging statements to PS/2 control
sequences let's move psmouse_sliced_command() into libps2 and rename it
to ps2_sliced_command().

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 19eb4ed1 16-Jan-2018 Peter Hutterer <peter.hutterer@who-t.net>

Input: synaptics - reset the ABS_X/Y fuzz after initializing MT axes

input_mt_init_slots() resets the ABS_X/Y fuzz to 0 and expects the driver
to call input_mt_report_pointer_emulation(). That is based on the MT
position bits which are already defuzzed - hence a fuzz of 0.

In the case of synaptics semi-mt devices, we report the ABS_X/Y axes
manually. This results in the MT position being defuzzed but the
single-touch emulation missing that defuzzing.

Work around this by re-initializing the ABS_X/Y axes after the MT axis to
get the same fuzz value back.

https://bugs.freedesktop.org/show_bug.cgi?id=104533

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 48282969 10-Jan-2018 王振杰 <zhenjie.wang@sjtu.edu.cn>

Input: synaptics - Lenovo Thinkpad T460p devices should use RMI

The tpouchpad/trackpoint on Lenovo Thinkpad T460p work with smbus/RMI.

Signed-off-by: Zhenjie Wang <zhenjie.wang@sjtu.edu.cn>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 2b30297d 09-Oct-2017 Andrew Duggan <aduggan@synaptics.com>

Input: synaptics - disable kernel tracking on SMBus devices

In certain situations kernel tracking seems to be getting confused
and incorrectly reporting the slot of a contact. On example is when
the user does a three finger click or tap and then places two fingers
on the touchpad in the same area. The kernel tracking code seems to
continue to think that there are three contacts on the touchpad and
incorrectly alternates the slot of one of the contacts. The result that
is the input subsystem reports a stream of button press and release
events as the reported slot changes.

Kernel tracking was originally enabled to prevent cursor jumps, but it
is unclear how much of an issue kernel jumps actually are. This patch
simply disabled kernel tracking for now.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1482640

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Tested-by: Kamil Páral <kparal@redhat.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 3f9db52d 28-Aug-2017 Anthony Martin <ality@pbrane.org>

Input: synaptics - fix device info appearing different on reconnect

User-modified input settings no longer survive a suspend/resume cycle.
Starting with 4.12, the touchpad is reinitialized on every reconnect
because the hardware appears to be different. This can be reproduced
by running the following as root:

echo -n reconnect >/sys/devices/platform/i8042/serio1/drvctl

A line like the following will show up in dmesg:

[30378.295794] psmouse serio1: synaptics: hardware appears to be
different: id(149271-149271), model(114865-114865),
caps(d047b3-d047b1), ext(b40000-b40000).

Note the single bit difference in caps: bit 1 (SYN_CAP_MULTIFINGER).

This happens because we modify our stored copy of the device info
capabilities when we enable advanced gesture mode but this change is
not reflected in the actual hardware capabilities.

It worked in the past because synaptics_query_hardware used to modify
the stored synaptics_device_info struct instead of filling in a new
one, as it does now.

Fix it by no longer faking the SYN_CAP_MULTIFINGER bit when setting
advanced gesture mode. This necessitated a small refactoring.

Fixes: 6c53694fb222 ("Input: synaptics - split device info into a separate structure")
Signed-off-by: Anthony Martin <ality@pbrane.org>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 2fef826e 26-May-2017 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - tell users to report when they should be using rmi-smbus

Users should really consider switching to rmi-smbus instead of plain PS/2.
Notify them that they should report a missing pnpID in the file.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# f4101ff8 26-May-2017 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - warn the users when there is a better mode

The Synaptics touchpads are now either using i2c-hid or rmi-smbus.
Warn the users if they are missing the rmi-smbus modules and have no
chance of reporting correct data.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# f4947d79 23-May-2017 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - keep PS/2 around when RMI4_SMB is not enabled

Or the user might have the touchpad unbound from PS/2 but never picked
up by rmi-smbus.ko

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 27555511 29-May-2017 Eric Biggers <ebiggers@google.com>

Input: synaptics - clear device info before filling in

synaptics_query_hardware() was being passed a 'struct synaptics_device_info'
in uninitialized stack memory, then not always initializing all fields.
This caused garbage to show up in certain fields, making the touchpad
unusable.

Fix by zeroing the device info, so all fields default to 0.

Fixes: 6c53694fb222 ("Input: synaptics - split device info into a separate structure")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# f6c4442b 24-Mar-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - use u8 instead of unsigned char

The rest of the kernel uses u8, u16, etc for data coming form hardware,
let's switch ti using u8 here as well.

Also turn pkt_type into an enum.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 212baf03 23-Mar-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - do not abuse -1 as return value

Let's stop using -1 as a universal return value and instead propagate
errors from underlying calls up the stack.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 991d29fe0 23-Mar-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - use BIT() and GENMASK() macros

Use standard infrastructure, such as BIT and GENMASK, instead of rolling
bitmasks by hand.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 2c6ecbba 23-Mar-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - add synaptics_query_int()

Factor out querying and parsing 3-byte response into an integer value.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e839ffab 02-Mar-2017 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - add support for Intertouch devices

Most of the Synaptics devices are connected through PS/2 and a different
bus (SMBus or HID over I2C). The secondary bus capability is indicated by
the InterTouch bit in extended capability 0x0C.

We only enable the InterTouch device to be created for the laptops
registered with the top software button property or those we know that are
functional. In the future, we might change the default to always rely on
the InterTouch bus. Currently, users can enable/disable the feature with
the psmouse parameter synaptics_intertouch.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 6c53694f 05-Mar-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - split device info into a separate structure

In preparation for SMBus/Intertouch device support, move static device
information that we query form the touchpad upon initialization into
separate structure. This will allow us to query the device without
allocating memory first.

Also stop using "unsigned long", everything fits into 32 bit chunks.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 996b9eed 23-Mar-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - do not mix logical and bitwise operations

Let's stop using !!x to reduce value of trackstick button expression to 0/1
and use shift instead. This removes the following sparse warning:

CHECK drivers/input/mouse/synaptics.c
drivers/input/mouse/synaptics.c:943:79: warning: dubious: !x | y

Also, the bits we are testing are not capabilities, so lets drop "_CAP"
suffix from macro names.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# bf23cfc3 09-Feb-2017 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - use SERIO_OOB_DATA to handle trackstick buttons

Instead of using custom method of "passing" extended buttons from the
touchpad to trackstick, let's switch to the newly introduced SERIO_OOB_DATA
channel.

Tested-By: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 82be788c 17-Mar-2016 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - handle spurious release of trackstick buttons, again

Looks like the fimware 8.2 still has the extra buttons spurious release
bug.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=114321
Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 62d78461 02-Oct-2015 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Revert "Input: synaptics - fix handling of disabling gesture mode"

This reverts commit e51e38494a8ecc18650efb0c840600637891de2c: we
actually do want the device to work in extended W mode, as this is the
mode that allows us receiving multiple contact information.

Cc: stable@vger.kernel.org


# e51e3849 20-Aug-2015 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - fix handling of disabling gesture mode

Bit 2 of the mode byte has dual meaning: it can disable reporting of
gestures when touchpad works in Relative mode or normal Absolute mode,
or it can enable so called Extended W-Mode when touchpad uses enhanced
Absolute mode (W-mode). The extended W-Mode confuses our driver and
causes missing button presses on some Thinkpads (x250, T450s), so let's
make sure we do not enable it.

Also, according to the spec W mode "... bit is defined only in Absolute
mode on pads whose capExtended capability bit is set. In Relative mode and
in TouchPads without this capability, the bit is reserved and should be
left at 0.", so let's make sure we respect this requirement as well.

Reported-by: Nick Bowler <nbowler@draconx.ca>
Suggested-by: Gabor Balla <gaborwho@gmail.com>
Tested-by: Gabor Balla <gaborwho@gmail.com>
Tested-by: Nick Bowler <nbowler@draconx.ca>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ab80ee38 24-Jul-2015 Jiri Kosina <jkosina@suse.com>

Input: synaptics - dump ext10 capabilities as well

Make extended capabilities obtained through $10 query also available in
touchpad identification.

Signed-off-by: Jiri Kosina <jkosina@suse.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# dbf3c370 10-Jul-2015 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Revert "Input: synaptics - allocate 3 slots to keep stability in image sensors"

This reverts commit 63c4fda3c0bb841b1aad1298fc7fe94058fc79f8 as it
causes issues with detecting 3-finger taps.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=100481
Cc: stable@vger.kernel.org
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>


# 7f2ca8b5 08-Jun-2015 Peter Hutterer <peter.hutterer@who-t.net>

Input: synaptics - add min/max quirk for Lenovo S540

https://bugzilla.redhat.com/show_bug.cgi?id=1223051#c2

Cc: stable@vger.kernel.org
Tested-by: tommy.gagnes@gmail.com
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 63c4fda3 05-Apr-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - allocate 3 slots to keep stability in image sensors

When slowly dropping 1, 2 and then 3 fingers on an image sensor touchpad,
we can see that the first finger gets reassigned a new slot while it did
not move. This is due to the kernel tracking algorithm which can not assign
correctly the 3 touches, being out of slots.

Declaring that we support 3 slots allows to actually forward:
slot 0 -> down, slot 1 -> up, slot 2 -> down

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Henrik Rydberg <rydberg@bitmath.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 58fd9af6 05-Apr-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: Revert "Revert "synaptics - use dmax in input_mt_assign_slots""

This reverts commit 09d042a2eb90 ("Revert "Input: synaptics - use dmax in
input_mt_assign_slots"")

Now that balanced slots assignments seem to be fixed, let's re-enable the
use in synaptics.c and wait for users to complain if there are still
problems.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Henrik Rydberg <rydberg@bitmath.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 85734b1a 25-Mar-2015 Filip Ayazi <filipayazi@gmail.com>

Input: synaptics - fix min-max quirk value for E440

Commit 98dc070373 ("Input: synaptics - add quirk for Thinkpad E440") had
a typo in ymax, this changes the value to the one reported by
touchpad-edge-detector and mentioned in the commit.

Signed-off-by: Filip Ayazi <filipayazi@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 98dc0703 23-Mar-2015 Ramiro Morales <cramm0@gmail.com>

Input: synaptics - add quirk for Thinkpad E440

Its ClickPad shares PNP ID "LEN2006" with the one in model E540 which is
already handled by the driver (both are Haswell iterations of the Edge
line, launched in 2014) but the dimensions it reports are different:

$ sudo ./touchpad-edge-detector /dev/input/event3
Touchpad SynPS/2 Synaptics TouchPad on /dev/input/event3
Move one finger around the touchpad to detect the actual edges
Kernel says: x [1472..5044], y [1408..3398]
Touchpad sends: x [1024..5045], y [2457..4832] /^C

Fortunately we can use the board ID, which is also different, to
distinguish among them.

$ dmesg | grep -i synaptics
psmouse serio1: synaptics: Touchpad model: 1, fw: 8.1, id: 0x1e2b1,
caps: 0xd001a3/0x940300/0x127c00, board id: 2691, fw id: 1494646
psmouse serio1: synaptics: serio: Synaptics pass-through port at
isa0060/serio1/input0
input: SynPS/2 Synaptics TouchPad as
/devices/platform/i8042/serio1/input/input4

Board ID in E540 is 2722:

psmouse serio1: synaptics: Touchpad model: 1, fw: 8.1, id: 0x1e2b1,
caps: 0xd001a3/0x940300/0x127c00, board id: 2722, fw id: 1484859

(from https://launchpadlibrarian.net/179702965/BootDmesg.txt)

Signed-off-by: Ramiro Morales <cramm0@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 09d042a2 16-Mar-2015 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Revert "Input: synaptics - use dmax in input_mt_assign_slots"

This reverts commit 6ab17a8484f03c188a93713369912f1545eb26e9 since it,
according to Benjamin, causes issues with slot assignment:

E: 15.669119 0000 0000 0000 # ------------ SYN_REPORT (0) ----------
E: 15.954242 0003 002f 0000 # EV_ABS / ABS_MT_SLOT 0
E: 15.954242 0003 0039 0505 # EV_ABS / ABS_MT_TRACKING_ID 505
E: 15.954242 0003 0035 3851 # EV_ABS / ABS_MT_POSITION_X 3851
E: 15.954242 0003 0036 4076 # EV_ABS / ABS_MT_POSITION_Y 4076
E: 15.954242 0003 003a 0034 # EV_ABS / ABS_MT_PRESSURE 34
E: 15.954242 0001 014a 0001 # EV_KEY / BTN_TOUCH 1
E: 15.954242 0003 0000 3851 # EV_ABS / ABS_X 3851
E: 15.954242 0003 0001 4076 # EV_ABS / ABS_Y 4076
E: 15.954242 0003 0018 0034 # EV_ABS / ABS_PRESSURE 34
E: 15.954242 0001 0145 0001 # EV_KEY / BTN_TOOL_FINGER 1
E: 15.954242 0000 0000 0000 # ------------ SYN_REPORT (0) ----------
... (bunch of regular events)...
E: 16.020614 0000 0000 0000 # ------------ SYN_REPORT (0) ----------
E: 16.043601 0003 0035 3873 # EV_ABS / ABS_MT_POSITION_X 3873
E: 16.043601 0003 0036 3903 # EV_ABS / ABS_MT_POSITION_Y 3903
E: 16.043601 0003 003a 0050 # EV_ABS / ABS_MT_PRESSURE 50
E: 16.043601 0003 0035 3032 # EV_ABS / ABS_MT_POSITION_X 3032
E: 16.043601 0003 0036 3832 # EV_ABS / ABS_MT_POSITION_Y 3832
E: 16.043601 0003 003a 0044 # EV_ABS / ABS_MT_PRESSURE 44
E: 16.043601 0003 0000 3032 # EV_ABS / ABS_X 3032
E: 16.043601 0003 0001 3832 # EV_ABS / ABS_Y 3832
E: 16.043601 0003 0018 0044 # EV_ABS / ABS_PRESSURE 44
E: 16.043601 0001 0145 0000 # EV_KEY / BTN_TOOL_FINGER 0
E: 16.043601 0001 014d 0001 # EV_KEY / BTN_TOOL_DOUBLETAP 1
E: 16.043601 0000 0000 0000 # ------------ SYN_REPORT (0) ----------
E: 16.068837 0003 002f 0001 # EV_ABS / ABS_MT_SLOT 1
E: 16.068837 0003 0039 0506 # EV_ABS / ABS_MT_TRACKING_ID 506
E: 16.068837 0003 0035 3912 # EV_ABS / ABS_MT_POSITION_X 3912
E: 16.068837 0003 0036 3743 # EV_ABS / ABS_MT_POSITION_Y 3743
E: 16.068837 0003 003a 0056 # EV_ABS / ABS_MT_PRESSURE 56
E: 16.068837 0003 002f 0000 # EV_ABS / ABS_MT_SLOT 0
E: 16.068837 0003 0035 3026 # EV_ABS / ABS_MT_POSITION_X 3026
E: 16.068837 0003 0036 3708 # EV_ABS / ABS_MT_POSITION_Y 3708
E: 16.068837 0003 003a 0052 # EV_ABS / ABS_MT_PRESSURE 52
E: 16.068837 0003 0000 3026 # EV_ABS / ABS_X 3026
E: 16.068837 0003 0001 3708 # EV_ABS / ABS_Y 3708
E: 16.068837 0003 0018 0052 # EV_ABS / ABS_PRESSURE 52
E: 16.068837 0000 0000 0000 # ------------ SYN_REPORT (0) ----------

Slot 0 and 1 gets inverted in the second report above, which
introduces a cursor jump. The problem is that this cursor jump is
often enough to leave the current widget, and X sends the
scrolling events to whoever is now under the cursor.

Reported-by: Benjamin Tissoires <btissoir@redhat.com>
Reported-by: Hans de Goede <hdegoede@redhat.com>


# 8f004f3f 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - remove X250 from the topbuttonpad list

Lenovo X250 has a PnpID of LEN0046, but it does not have the top software
button requirement.

For the record, Lenovo T450s and W541 have a PnpID of LEN200f and LEN004a,
so they are not on the top software button list.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: Daniel Martin <consume.noise@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 860e6f7f 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - remove X1 Carbon 3rd gen from the topbuttonpad list

Lenovo decided to switch back to physical buttons for the trackstick on
their latest series. The PNPId list was provided before they reverted back
to physical buttons, so it contains the new models too. We can know from
the touchpad capabilities that the touchpad has physical buttons, so
removing the ids from the list is not mandatory. It is still nicer to
remove the wrong ids, so start by removing the X1 Carbon 3rd gen, with the
PNPId of LEN0048.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# cdd9dc19 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - re-route tracksticks buttons on the Lenovo 2015 series

The 2015 series of the Lenovo thinkpads added back the hardware buttons on
top of the touchpad for the trackstick.

Unfortunately, they are wired to the touchpad, and not the trackstick.
Thus, they are seen as extra buttons from the kernel point of view.

This leads to a problem in user space because extra buttons on synaptics
devices used to be used as scroll up/down buttons. So in the end, the
experience for the user is scroll events for buttons left and right when
using the trackstick. Yay!

Fortunately, the firmware advertises such behavior in the extended
capability $10, and so we can re-route the buttons through the pass-through
interface.

Hallelujah-expressed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 3adde1f5 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - remove TOPBUTTONPAD property for Lenovos 2015

The 2015 series of the Lenovo thinkpads added back the hardware buttons on
top of the touchpad for the trackstick.

Unfortunately, Lenovo used the PNPIDs that are supposed to be "5 buttons"
touchpads, so the new laptops also have the INPUT_PROP_TOPBUTTONPAD. Yay!

Instead of manually removing each of the new ones, or hoping that we know
all the current ones, we can consider that the PNPIDs list that were given
contains touchpads that have the trackstick buttons, either physically
wired to them, or emulated with the top software button property.

Thanks to the extra buttons capability in query $10, we can reliably detect
the physical buttons from the software ones, and so we can remove the
TOPBUTTONPAD property even if it was declared as such.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 06aa374b 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - retrieve the extended capabilities in query $10

Newer Synaptics touchpads need to get information from the query $10.
Retrieve it if available.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# b57a7128 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - do not retrieve the board id on old firmwares

The board id capability has been added in firmware 7.5.

Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ebc80840 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - handle spurious release of trackstick buttons

The Fimware 8.1 has a bug in which the extra buttons are only sent when the
ExtBit is 1. This should be fixed in a future FW update which should have
a bump of the minor version.

Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# dc5465dc 08-Mar-2015 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - fix middle button on Lenovo 2015 products

On the X1 Carbon 3rd gen (with a 2015 broadwell cpu), the physical middle
button of the trackstick (attached to the touchpad serio device, of course)
seems to get lost.

Actually, the touchpads reports 3 extra buttons, which falls in the switch
below to the '2' case. Let's handle the case of odd numbers also, so that
the middle button finds its way back.

Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 02e07492 08-Mar-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - skip quirks when post-2013 dimensions

Post-2013 Lenovo laptops provide correct min/max dimensions, which are
different with the ones currently quirked. According to
https://bugzilla.kernel.org/show_bug.cgi?id=91541 the following board ids
are assigned in the post-2013 touchpads:

t440p/t440s: LEN0036 -> 2964/2962
t540p: LEN0034 -> 2964

Using 2961 as the common minimum makes these 3 laptops OK. We may need
to update those values later if other pnp_ids has a lower board_id.

Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 5b3089dd 08-Mar-2015 Daniel Martin <daniel.martin@secunet.com>

Input: synaptics - support min/max board id in min_max_pnpid_table

Add a min/max range for board ids to the min/max coordinates quirk. This
makes it possible to restrict quirks to specific models based upon their
board id. The define ANY_BOARD_ID (0) serves as a wild card.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541

Cc: stable@vger.kernel.org
Signed-off-by: Daniel Martin <daniel.martin@secunet.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# b05f4d1c 08-Mar-2015 Daniel Martin <consume.noise@gmail.com>

Input: synaptics - remove obsolete min/max quirk for X240

The firmware of the X240 (LEN0035, 2013/12) exposes the same values
x [1232..5710], y [1156..4696]
as the quirk applies.

Cc: stable@vger.kernel.org
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ac097930 08-Mar-2015 Daniel Martin <consume.noise@gmail.com>

Input: synaptics - query min dimensions for fw v8.1

Query the min dimensions even if the check
SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 fails, but we know that the
firmware version 8.1 is safe.

With that we don't need quirks for post-2013 models anymore as they expose
correct min and max dimensions.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=91541

Cc: stable@vger.kernel.org
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
re-order the tests to check SYN_CAP_MIN_DIMENSIONS even on FW 8.1
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 9aff6598 08-Mar-2015 Daniel Martin <consume.noise@gmail.com>

Input: synaptics - log queried and quirked dimension values

Logging the dimension values we queried and the values we use from a quirk
to overwrite can be helpful for debugging.

This partly relates to bug:
https://bugzilla.kernel.org/show_bug.cgi?id=91541

Cc: stable@vger.kernel.org
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 8b04baba 08-Mar-2015 Daniel Martin <consume.noise@gmail.com>

Input: synaptics - split synaptics_resolution(), query first

Split the function synaptics_resolution() into synaptics_resolution() and
synaptics_quirks(). synaptics_resolution() will be called before
synaptics_quirks() to query dimensions and resolutions before overwriting
them with quirks.

Cc: stable@vger.kernel.org
Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# de4e374b 29-Dec-2014 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - switch ForcePad detection to PNP IDs

According to Synaptics devices with ForcePads use SYN300D and SYN3014 as
PNP IDs, so let's switch from DMI-bases detection scheme to PNP-based
one, which should be more reliable.

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 290b799c 29-Dec-2014 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: psmouse - use IS_ENABLED instead of homegrown code

Instead of having various protocols provide <protocol>_supported()
functions, let's use IS_ENABLED() macro that works well in "if" statements.

Acked-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 6ab17a84 03-Feb-2015 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - use dmax in input_mt_assign_slots

When tapping a clickpad with two fingers, there is a chance that the sensor
sees first only one finger, and at the next scan only the second one. In
this case, the sensors says that there has been only one finger on the
clickpad, which moved really fast between two scans.

We can try to counter this by adding a limit to what an actual finger can
move between 2 scans. A distance of 1cm between two scans for one finger
seems reasonable. However, this is not really accurate because the
resolution in X and in Y differs. But heh, that's how the in-kernel
tracking works right now, and its job is quite good, even with this
approximation.

This parameter solves most of the jumps observed, not all of them however.
But this is a hardware defect, and we might not be able to get something
better without much heavier computations.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=76722

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 448c7f38 01-Feb-2015 Henrik Rydberg <rydberg@bitmath.org>

Input: MT - add support for balanced slot assignment

Some devices are not fast enough to differentiate between a fast-moving
contact and a new contact. This problem cannot be fully resolved because
information is truly missing, but it is possible to safe-guard against
obvious mistakes by restricting movement with a maximum displacement.

The new problem formulation for dmax > 0 cannot benefit from the speedup
for positive definite matrices, but since the convergence is faster, the
result is about the same. For a handful of contacts, the latency difference
is truly negligible.

Suggested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Henrik Rydberg <rydberg@bitmath.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 8543cf1c 19-Jan-2015 Peter Hutterer <peter.hutterer@who-t.net>

Input: synaptics - adjust min/max for Lenovo ThinkPad X1 Carbon 2nd

LEN0037 found in the Lenovo ThinkPad X1 Carbon 2nd (2014 model)

Cc: stable@vger.kernel.org
Reported-and-tested-by: Bjoern Olausson <bjoern@olausson.de>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# aa104b1a 29-Dec-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - remove duplicated code

synaptics_profile_sensor_process() and synaptics_report_mt_data() now
share the exact same code. Remove one implementation and rely on the
other where it was used.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e9e8520f 29-Dec-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - use in-kernel tracking for reporting mt data

The current code tries to consider all states and transitions to properly
detect which finger is attached to which slot. The code is quite huge
and difficult to read.

If the sensor manages to group the touch points but is not reliable in
giving tracking ids, we can simply use the kernel tracking method. Note
that it is already used by Cr-48 Chromebooks.

Incidentaly, this fixes a bug reported by Peter Hutterer:
"""
on the Lenovo T440, run:
evemu-record /dev/input/event4 | grep BTN_

then put one, two, three, two fingers down
when you go from 3 to 2 fingers the driver sends a spurious BTN_TOUCH 0
event:

E: 0.000000 0001 014a 0001 # EV_KEY / BTN_TOUCH 1
E: 0.000000 0001 0145 0001 # EV_KEY / BTN_TOOL_FINGER 1
E: 0.770008 0001 0145 0000 # EV_KEY / BTN_TOOL_FINGER 0
E: 0.770008 0001 014d 0001 # EV_KEY / BTN_TOOL_DOUBLETAP 1
E: 1.924716 0001 014d 0000 # EV_KEY / BTN_TOOL_DOUBLETAP 0
E: 1.924716 0001 014e 0001 # EV_KEY / BTN_TOOL_TRIPLETAP 1

.. changing from 3 to 2 fingers now

E: 3.152641 0001 014a 0000 # EV_KEY / BTN_TOUCH 0
E: 3.152641 0001 014d 0001 # EV_KEY / BTN_TOOL_DOUBLETAP 1
E: 3.152641 0001 014e 0000 # EV_KEY / BTN_TOOL_TRIPLETAP 0
E: 3.176948 0001 014a 0001 # EV_KEY / BTN_TOUCH 1

quick look in the kernel shows it's caused by hw.z going to 0 for a packet,
so probably a firmware bug. either way, it makes it hard to track BTN_TOUCH
as signal that at least one finger is down.
"""

The in-kernel tracking is enough to remove this spurious BTN_TOUCH 0.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# bce4f9e7 16-Nov-2014 Ben Sagal <bensagal@gmail.com>

Input: synaptics - adjust min/max on Thinkpad E540

The LEN2006 Synaptics touchpad (as found in Thinkpad E540) returns wrong
min max values.

touchpad-edge-detector output:
> Touchpad SynPS/2 Synaptics TouchPad on /dev/input/event6
> Move one finger around the touchpad to detect the actual edges
> Kernel says: x [1472..5674], y [1408..4684]
> Touchpad sends: x [1264..5675], y [1171..4688]

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88211
Cc: stable@vger.kernel.org
Signed-off-by: Binyamin Sagal <bensagal@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e4742b1e 06-Nov-2014 Takashi Iwai <tiwai@suse.de>

Input: synaptics - add min/max quirk for Lenovo T440s

The new Lenovo T440s laptop has a different PnP ID "LEN0039", and it
needs the similar min/max quirk to make its clickpad working.

BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=903748
Reported-and-tested-by: Joschi Brauchle <joschibrauchle@gmx.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# aa9724099 02-Sep-2014 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - gate forcepad support by DMI check

Unfortunately, ForcePad capability is not actually exported over PS/2, so
we have to resort to DMI checks.

Cc: stable@vger.kernel.org
Reported-by: Nicole Faerber <nicole.faerber@kernelconcepts.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 2c75ada6 11-Sep-2014 Hans de Goede <hdegoede@redhat.com>

Input: psmouse - add psmouse_matches_pnp_id helper function

The matches_pnp_id function from the synaptics driver is useful for other
drivers too. Make it a generic psmouse helper function.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 5715fc76 30-Aug-2014 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - add support for ForcePads

ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of
physical buttons, instead they generate primary button click when user
presses somewhat hard on the surface of the touchpad. Unfortunately they
also report primary button click whenever there are 2 or more contacts
on the pad, messing up all multi-finger gestures (2-finger scrolling,
multi-finger tapping, etc). To cope with this behavior we introduce a
delay (currently 50 msecs) in reporting primary press in case more
contacts appear.

Cc: stable@vger.kernel.org
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e08d9afa 14-Jul-2014 Henrik Rydberg <rydberg@euromail.se>

Input: synaptics - use firmware data for Cr-48

The profile sensor clickpad in a Cr-48 Chromebook does a reasonable job
of tracking individual fingers. This tracking isn't perfect, but,
experiments show that it works better than just passing "semi-mt" data
to userspace, and making userspace try to deduce where the fingers are
given a bounding box.

This patch tries to report correct two-finger positions instead of the
{(min_x, min_y), (max_x, max_y)} for profile sensor clickpads on Cr-48
chromebooks. Note that this device's firmware always reports the higher
(smaller y) finger in the "sgm" packet, and the lower (larger y) finger
in the "agm" packet. Thus, when a new finger arrives on the pad, the
kernel driver uses input core's contact tracking facilities to match
contacts with slots.

Inspired by patch by Daniel Kurtz <djkurtz@chromium.org> and Chung-yih
Wang <cywang@chromium.org>

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Reviewed-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# ae84197f 25-Jul-2014 Dmitry Torokhov <dtor@chromium.org>

Input: synaptics - properly initialize slots for semi-MT

Semi-MT devices are pointers too, so let's tell that to
input_mt_init_slots(), as well as let it set up the devices as semi-MT,
instead of us doing it manually.

Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e76aed9d 14-Jul-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - add min/max quirk for pnp-id LEN2002 (Edge E531)

https://bugzilla.redhat.com/show_bug.cgi?id=1114768

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# d49cb7ae 07-Jun-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - fix resolution for manually provided min/max

commit 421e08c41fda fixed the reported min/max for the X and Y axis,
but unfortunately, it broke the resolution of those same axis.

On the t540p, the resolution is the same regarding X and Y. It is not
a problem for xf86-input-synaptics because this driver is only interested
in the ratio between X and Y.
Unfortunately, xf86-input-cmt uses directly the resolution, and having a
null resolution leads to some divide by 0 errors, which are translated by
-infinity in the resulting coordinates.

Reported-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 0f68f39c 19-May-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - change min/max quirk table to pnp-id matching

Most of the affected models share pnp-ids for the touchpad. So switching
to pnp-ids give us 2 advantages:
1) It shrinks the quirk list
2) It will lower the new quirk addition frequency, ie the recently added W540
quirk would not have been necessary since it uses the same LEN0034 pnp ids
as other models already added before it

As an added bonus it actually puts the quirk on the actual psmouse, rather
then on the machine, which is technically more correct.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# e2f61102 19-May-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - add a matches_pnp_id helper function

This is a preparation patch for simplifying the min/max quirk table.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 6d396ede 19-May-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - T540p - unify with other LEN0034 models

The T540p has a touchpad with pnp-id LEN0034, all the models with this
pnp-id have the same min/max values, except the T540p where the values are
slightly off. Fix them to be identical.

This is a preparation patch for simplifying the quirk table.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 0b5fe736 14-May-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - add min/max quirk for the ThinkPad W540

https://bugzilla.redhat.com/show_bug.cgi?id=1096436

Cc: stable@vger.kernel.org
Tested-and-reported-by: ajayr@bigfoot.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 27a38856 23-Apr-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - add min/max quirk for ThinkPad Edge E431

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 46a2986e 19-Apr-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - add min/max quirk for ThinkPad T431s, L440, L540, S1 Yoga and X1

We expect that all the Haswell series will need such quirks, sigh.

The T431s seems to be T430 hardware in a T440s case, using the T440s touchpad,
with the same min/max issue.

The X1 Carbon 3rd generation name says 2nd while it is a 3rd generation.

The X1 and T431s share a PnPID with the T540p, but the reported ranges are
closer to those of the T440s.

HdG: Squashed 5 quirk patches into one. T431s + L440 + L540 are written by me,
S1 Yoga and X1 are written by Benjamin Tissoires.

Hdg: Standardized S1 Yoga and X1 values, Yoga uses the same touchpad as the
X240, X1 uses the same touchpad as the T440.

Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 43e19888 19-Apr-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - report INPUT_PROP_TOPBUTTONPAD property

Check PNP ID of the PS/2 AUX port and report INPUT_PROP_TOPBUTTONPAD
property for for touchpads with top button areas.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 8a0435d9 28-Mar-2014 Hans de Goede <hdegoede@redhat.com>

Input: synaptics - add manual min/max quirk for ThinkPad X240

This extends Benjamin Tissoires manual min/max quirk table with support for
the ThinkPad X240.

Cc: stable@vger.kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 421e08c4 28-Mar-2014 Benjamin Tissoires <benjamin.tissoires@redhat.com>

Input: synaptics - add manual min/max quirk

The new Lenovo Haswell series (-40's) contains a new Synaptics touchpad.
However, these new Synaptics devices report bad axis ranges.
Under Windows, it is not a problem because the Windows driver uses RMI4
over SMBus to talk to the device. Under Linux, we are using the PS/2
fallback interface and it occurs the reported ranges are wrong.

Of course, it would be too easy to have only one range for the whole
series, each touchpad seems to be calibrated in a different way.

We can not use SMBus to get the actual range because I suspect the firmware
will switch into the SMBus mode and stop talking through PS/2 (this is the
case for hybrid HID over I2C / PS/2 Synaptics touchpads).

So as a temporary solution (until RMI4 land into upstream), start a new
list of quirks with the min/max manually set.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
CC: stable@vger.kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# c963156c 12-Aug-2013 Sachin Kamat <sachin.kamat@linaro.org>

Input: synaptics - fix incorrect placement of __initconst

__initconst should be placed between the variable name and equal
sign for the variable to be placed in the intended section.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# eeb06558 04-Jun-2013 Eric Miao <eric.miao@canonical.com>

Input: synaptics - fix sync lost after resume on some laptops

In summary, the symptom is intermittent key events lost after resume
on some machines with synaptics touchpad (seems this is synaptics _only_),
and key events loss is due to serio port reconnect after psmouse sync lost.
Removing psmouse and inserting it back during the suspend/resume process
is able to work around the issue, so the difference between psmouse_connect()
and psmouse_reconnect() is the key to the root cause of this problem.

After comparing the two different paths, synaptics driver has its own
implementation of synaptics_reconnect(), and the missing psmouse_probe()
seems significant, the patch below added psmouse_probe() to the reconnect
process, and has been verified many times that the issue could not be reliably
reproduced.

There are two PS/2 commands in psmouse_probe():

1. PSMOUSE_CMD_GETID
2. PSMOUSE_CMD_RESET_DIS

Only the PSMOUSE_CMD_GETID seems to be significant. The
PSMOUSE_CMD_RESET_DIS is irrelevant to this issue after trying
several times. So we have only implemented this patch to issue
the PSMOUSE_CMD_GETID so far.

Tested-by: Daniel Manrique <daniel.manrique@canonical.com>
Signed-off-by: James M Leddy <james.leddy@canonical.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 0b85bf78 15-Feb-2013 Henrik Rydberg <rydberg@euromail.se>

Input: synaptics - initialize pointer emulation usage

To properly setup event parameters for emulated events, pass
the appropriate flag to the slot initialization function. Also,
all MT-related events should be setup before initialization.

Incidentally, this solves the issue of doubly filtered pointer
events.

Reported-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 48064bdc 13-Feb-2013 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - fix 1->3 contact transition reporting

Investigating the following gesture highlighted two slight implementation
errors with choosing which slots to report in which slot when multiple
contacts are present:

Action SGM AGM (MTB slot:Contact)
1. Touch contact 0 (0:0)
2. Touch contact 1 (0:0, 1:1)
3. Lift contact 0 (1:1)
4. Touch contacts 2,3 (0:2, 1:3)

In step 4, slot 1 was not being cleared first, which means the same
tracking ID was being used for reporting both the old contact 1 and the
new contact 3. This could result in "drumroll", where the old contact 1
would appear to suddenly jump to new finger 3 position.

Similarly, if contacts 2 & 3 are not detected at the same sample, step 4
is split into two:

Action SGM AGM (MTB slot:contact)
1. Touch contact 0 (0:0)
2. Touch contact 1 (0:0, 1:1)
3. Lift contact 0 (1:1)
4. Touch contact 2 (0:2, 1:1)
5. Touch contact 3 (0:2, 1:3)

In this case, there was also a bug. In step 4, when contact 1 moves from
SGM to AGM and contact 2 is first reported in SGM, slot 0 was actually
empty. So slot 0 can be used to report the new SGM (contact 0),
immediately. Since it was empty, contact 2 in slot 0 will get a new
tracking ID.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 824efd37 28-Sep-2012 Seth Forshee <seth.forshee@canonical.com>

Input: synaptics - adjust threshold for treating position values as negative

Commit c039450 (Input: synaptics - handle out of bounds values from the
hardware) caused any hardware reported values over 7167 to be treated as
a wrapped-around negative value. It turns out that some firmware uses
the value 8176 to indicate a finger near the edge of the touchpad whose
actual position cannot be determined. This value now gets treated as
negative, which can cause pointer jumps and broken edge scrolling on
these machines.

I only know of one touchpad which reports negative values, and this
hardware never reports any value lower than -8 (i.e. 8184). Moving the
threshold for treating a value as negative up to 8176 should work fine
then for any hardware we currently know about, and since we're dealing
with unspecified behavior it's probably the best we can do. The special
8176 value is also likely to result in sudden jumps in position, so
let's also clamp this to the maximum specified value for the axis.

BugLink: http://bugs.launchpad.net/bugs/1046512
https://bugzilla.kernel.org/show_bug.cgi?id=46371

Cc: stable@vger.kernel.org
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Alan Swanson <swanson@ukfsn.org>
Tested-by: Arteom <arutemus@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# b4adbbef 11-Aug-2012 Henrik Rydberg <rydberg@euromail.se>

Input: MT - Add flags to input_mt_init_slots()

Preparing to move more repeated code into the mt core, add a flags
argument to the input_mt_slots_init() function.

Reviewed-and-tested-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Tested-by: Ping Cheng <pingc@wacom.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>


# c0394506 25-Jul-2012 Seth Forshee <seth.forshee@canonical.com>

Input: synaptics - handle out of bounds values from the hardware

The touchpad on the Acer Aspire One D250 will report out of range values
in the extreme lower portion of the touchpad. These appear as abrupt
changes in the values reported by the hardware from very low values to
very high values, which can cause unexpected vertical jumps in the
position of the mouse pointer.

What seems to be happening is that the value is wrapping to a two's
compliment negative value of higher resolution than the 13-bit value
reported by the hardware, with the high-order bits being truncated. This
patch adds handling for these values by converting them to the
appropriate negative values.

The only tricky part about this is deciding when to treat a number as
negative. It stands to reason that if out of range values can be
reported on the low end then it could also happen on the high end, so
not all out of range values should be treated as negative. The approach
taken here is to split the difference between the maximum legitimate
value for the axis and the maximum possible value that the hardware can
report, treating values greater than this number as negative and all
other values as positive. This can be tweaked later if hardware is found
that operates outside of these parameters.

BugLink: http://bugs.launchpad.net/bugs/1001251
Cc: stable@vger.kernel.org
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# c6bd9d46 07-Jul-2012 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - print firmware ID and board number at init

Read the Firmware ID and Board Number from a synaptics device at init
and display them in the system log.

Device behavior is very board and firmware dependent.
It may prove useful for users to include this information when providing
bug reports or other feedback.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>


# 1a49a0a0 10-May-2012 JJ Ding <dgdunix@gmail.com>

Input: synaptics - fix compile warning

Move synaptics_invert_y() inside CONFIG_MOUSE_PS2_SYNAPTICS to get rid of
a compile warning when we don't select synaptics support.

drivers/input/mouse/synaptics.c:53:12: warning: ‘synaptics_invert_y’ defined but not used [-Wunused-function]

Signed-off-by: JJ Ding <dgdunix@gmail.com>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 899c612d 20-Apr-2012 Benjamin Herrenschmidt <benh@kernel.crashing.org>

Input: synaptics - fix regression with "image sensor" trackpads

commit 7968a5dd492ccc38345013e534ad4c8d6eb60ed1
Input: synaptics - add support for Relative mode

Accidentally broke support for advanced gestures (multitouch)
on some trackpads such as the one in my ThinkPad X220 by
incorretly changing the condition for enabling them. This
restores it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
CC: stable@kernel.org [3.3]
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 8521478f 12-Dec-2011 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - fix touchpad not working after S2R on Vostro V13

Synaptics touchpads on several Dell laptops, particularly Vostro V13
systems, may not respond properly to PS/2 commands and queries immediately
after resuming from suspend to RAM. This leads to unresponsive touchpad
after suspend/resume cycle.

Adding a 1-second delay after resetting the device allows touchpad to
finish initializing (calibrating?) and start reacting properly.

Reported-by: Daniel Manrique <daniel.manrique@canonical.com>
Tested-by: Daniel Manrique <daniel.manrique@canonical.com>
Cc: stable@kernel.org
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 83551c01 11-Nov-2011 Daniel Drake <dsd@laptop.org>

Input: synaptics - update OLPC XO exclusion

We have determined that the jumpiness previously seen when using
the synaptics kernel mouse driver on OLPC XO was due to not using
the synaptics X11 userspace driver - the xf86-input-evdev driver was
interpreting 'finger near pad' signals as movements. Newer versions
of xf86-input-evdev fix this issue.

Additionally, the synaptics kernel driver is now usable on this
platform, but only when run in relative mode.

Update the comment and refine the check to allow the synaptics driver
to run on OLPC XO in relative mode.

We will continue investigating the EC issue as time becomes available.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 7968a5dd 08-Nov-2011 Daniel Drake <dsd@laptop.org>

Input: synaptics - add support for Relative mode

Currently, the synaptics driver puts the device into Absolute mode.
As explained in the synaptics documentation section 3.2, in this mode,
the device sends a continuous stream of packets at the maximum rate
to the host when the user's fingers are near or on the pad or
pressing buttons, and continues streaming for 1 second afterwards.
These packets are even sent when there is no new information to report,
even when they are duplicates of the previous packet.

For embedded systems this is a bit much - it results in a huge
and uninterrupted stream of interrupts at high rate.

This patch adds support for Relative mode, which can be selected as
a new psmouse protocol. In this mode, the device does not send duplicate
packets and acts like a standard PS/2 mouse. However, synaptics-specific
functionality is still available, such as the ability to set the packet
rate, and rather than disabling gestures and taps at the hardware level
unconditionally, a 'synaptics_disable_gesture' sysfs attribute has
been added to allow control of this functionality.

This solves a long standing OLPC issue: synaptics hardware enables
tap to click by default (even in the default relative mode), but we
have found this to be inappropriate for young children and first
time computer users. Enabling the synaptics driver disables tap-to-click,
but we have previously been unable to use this because it also enables
Absolute mode, which is too "spammy" for our desires and actually
overloads our EC with its continuous stream of packets. Now we can enable
the synaptics driver, disabling tap to click while retaining the less
noisy Relative mode.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# b5d21704 10-Oct-2011 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: psmouse - switch to using dev_*() for messages

This will ensure our reporting is consistent with the rest of the system
and we do not refer to obsolete source file names.

Reviewed-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Reviewed-by: JJ Ding <dgdunix@gmail.com>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 6b4b49fe 24-Aug-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - process finger (<=5) transitions

Synaptics image sensor touchpads track up to 5 fingers, but only report 2.
They use a special "TYPE=2" (AGM-CONTACT) packet type that reports
the number of tracked fingers and which finger is reported in the SGM
and AGM packets.

With this new packet type, it is possible to tell userspace when 4 or 5
fingers are touching.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 4dc772d2 24-Aug-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - process finger (<=3) transitions

Synaptics image sensor touchpads track 5 fingers, but only report 2.
This patch attempts to deal with some idiosyncrasies of these touchpads:

* When there are 3 or more fingers, only two are reported.
* The touchpad tracks the 5 fingers in slot[0] through slot[4].
* It always reports the lowest and highest valid slots in SGM and AGM
packets, respectively.
* The number of fingers is only reported in the SGM packet. However,
the number of fingers can change either before or after an AGM
packet.
* Thus, if an SGM reports a different number of fingers than the last
SGM, it is impossible to tell whether the intervening AGM corresponds
to the old number of fingers or the new number of fingers.
* For example, when going from 2->3 fingers, it is not possible to tell
whether tell AGM contains slot[1] (old 2nd finger) or slot[2] (new
3rd finger).
* When fingers are added one at at time, from 1->2->3, it is possible to
track which slots are contained in the SGM and AGM packets:
1 finger: SGM = slot[0], no AGM
2 fingers: SGM = slot[0], AGM = slot[1]
3 fingers: SGM = slot[0], AGM = slot[2]
* It is also possible to track which slot is contained in the SGM when 1
of 2 fingers is removed. This is because the touchpad sends a special
(0,0,0) AGM packet whenever all fingers are removed except slot[0]:
Last AGM == (0,0,0): SGM contains slot[1]
Else: SGM contains slot[0]
* However, once there are 3 fingers, if exactly 1 finger is removed, it
is impossible to tell which 2 slots are contained in SGM and AGM.
The (SGM,AGM) could be (0,1), (0,2), or (1,2). There is no way to know.
* Similarly, if two fingers are simultaneously removed (3->1), then it
is only possible to know if SGM still contains slot[0].
* Since it is not possible to reliably track which slot is being
reported, we invalidate the tracking_id every time the number of
fingers changes until this ambiguity is resolved when:
a) All fingers are removed.
b) 4 or 5 fingers are touched, generates an AGM-CONTACT packet.
c) All fingers are removed except slot[0]. In this special case, the
ambiguity is resolved since by the (0,0,0) AGM packet.

Behavior of the driver:

When 2 or more fingers are present on the touchpad, the kernel reports
up to two MT-B slots containing the position data for two of the fingers
reported by the touchpad. If the identity of a finger cannot be tracked
when the number-of-fingers changes, the corresponding MT-B slot will be
invalidated (track_id set to -1), and a new track_id will be assigned in
a subsequent input event report.

The driver always reports the total number of fingers using one of the
EV_KEY/BTN_TOOL_*TAP events. This could differ from the number of valid
MT-B slots for two reasons:
a) There are more than 2 fingers on the pad.
b) During ambiguous number-of-fingers transitions, the correct track_id
for one or both of the slots cannot be determined, so the slots are
invalidated.

Thus, this is a hybrid singletouch/MT-B scheme. Userspace can detect
this behavior by noting that the driver supports more EV_KEY/BTN_TOOL_*TAP
events than its maximum EV_ABS/ABS_MT_SLOT.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a6ca40c1 24-Aug-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - decode AGM packet types

A Synaptics image sensor tracks 5 fingers, but can only report 2.

The algorithm for choosing which 2 fingers to report and in which packet:
Touchpad maintains 5 slots, numbered 0 to 4
Initially all slots are empty
As new fingers are detected, assign them to the lowest available slots
The touchpad always reports:
SGM: lowest numbered non-empty slot
AGM: highest numbered non-empty slot, if there is one

In addition, these touchpads have a special AGM packet type which reports
the number of fingers currently being tracked, and which finger is in
each of the two slots. Unfortunately, these "TYPE=2" packets are only used
when more than 3 fingers are being tracked. When less than 4 fingers
are present, the 'w' value must be used to track how many fingers are
present, and knowing which fingers are being reported is much more
difficult, if not impossible.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 3cdfee9e 24-Aug-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - add image sensor support

Synaptics makes (at least) two kinds of touchpad sensors:
* Older pads use a profile sensor that could only infer the location
of individual fingers based on the projection of their profiles
onto row and column sensors.
* Newer pads use an image sensor that can track true finger position
using a two-dimensional sensor grid.

Both sensor types support an "Advanced Gesture Mode":
When multiple fingers are detected, the touchpad sends alternating
"Advanced Gesture Mode" (AGM) and "Simple Gesture Mode" (SGM)
packets.
The AGM packets have w=2, and contain reduced resolution finger data
The SGM packets have w={0,1} and contain full resolution finger data

Profile sensors try to report the "upper" (larger y value) finger in
the SGM packet, and the lower (smaller y value) in the AGM packet.
However, due to the nature of the profile sensor, they easily get
confused when fingers cross, and can start reporting the x-coordinate
of one with the y-coordinate of the other. Thus, for profile
sensors, "semi-mt" was created, which reports a "bounding box"
created by pairing min and max coordinates of the two pairs of
reported fingers.

Image sensors can report the actual coordinates of two of the fingers
present. This patch detects if the touchpad is an image sensor and
reports finger data using the MT-B protocol.

NOTE: This patch only adds partial support for 2-finger gestures.
The proper interpretation of the slot contents when more than
two fingers are present is left to later patches. Also,
handling of 'number of fingers' transitions is incomplete.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 85615476 24-Aug-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - refactor initialization of abs position axes

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 7afdb842 24-Aug-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - refactor agm packet parsing

When a Synaptics touchpad is in "AGM" mode, and multiple fingers are
detected, the touchpad sends alternating "Advanced Gesture Mode" (AGM) and
"Simple Gesture Mode" (SGM) packets.
The AGM packets have w=2, and contain reduced resolution finger data.
The SGM packets have w={0,1} and contain full resolution finger data.

Refactor the parsing of agm packets to its own function, and rename the
synaptics_data.mt field to .agm to indicate that it contains the contents of
the last agm packet.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 6de58dd6 24-Aug-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - refactor y inversion

Synaptics touchpads report increasing y from bottom to top.
This is inverted from normal userspace "top of screen is 0" coordinates.
Thus, the kernel driver reports inverted y coordinates to userspace.

This patch refactors this inversion.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a66413fb 09-Jul-2011 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - set minimum coordinates as reported by firmware

Newer Synaptics firmware allows to query minimum coordinates reported by
the device, let's use this data.

Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Henrik Rydberg <rydberg@euromail.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 28d5fd86 06-Jul-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - process button bits in AGM packets

AGM packets contain valid button bits, too.
This patch refactors packet processing to parse button bits in AGM packets.
However, they aren't actually used or reported.

The point is to more completely process AGM packets,
and prepare for future patches that may actually use AGM packet button bits.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# bea9f0ff 06-Jul-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - rename set_slot to be more descriptive

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a9f0b79e 06-Jul-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - fuzz position for touchpad with reduced filtering

Synaptics touchpads indicate via a capability bit when they perform reduced
filtering on position data. In such a case, use a non-zero fuzz value.
Fuzz = 8 was chosen empirically by observing the raw position data
reported by a clickpad indicating it had reduced filtering.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 8be3c650 06-Jul-2011 Daniel Kurtz <djkurtz@chromium.org>

Input: synaptics - set resolution for MT_POSITION_X/Y axes

Set resolution for MT_POSITION_X and MT_POSITION_Y to match ABS_X and
ABS_Y, respectively.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 70874867 31-Mar-2011 Jan Beulich <JBeulich@novell.com>

Input: synaptics - fix crash in synaptics_module_init()

'struct dmi_system_id' arrays must always have a terminator to keep
dmi_check_system() from looking at data (and possibly crashing) it
isn't supposed to look at.

The issue went unnoticed until ef8313bb1a22e7d2125d9d758aa8a81f1de91d81,
but was introduced about a year earlier with
7705d548cbe33f18ea7713b9a07aa11047aaeca4 (which also similarly changed
lifebook.c, but the problem there got eliminated shortly afterwards).

The first hunk therefore is a stable candidate back to 2.6.33, while
the full change is needed only on 2.6.38.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: stable@kernel.org
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# c63fe0a4 28-Jan-2011 Alexandre Peixoto Ferreira <alexandref75@gmail.com>

Input: synaptics - retry failed resets when reconnecting

On some machines, like Dell Studio XPS 16 (1640), touchpad fails to
respond to the standard query after first reset but may start
responding later, so let's repeat reset sequence several (3) times.

Signed-off-by: Alexandre Peixoto Ferreira <alexandref75@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# baddf589 28-Jan-2011 Alexandre Peixoto Ferreira <alexandref75@gmail.com>

Input: synaptics - fix reconnect logic on MT devices

synaptics_set_advanced_gesture_mode() affect capabilities bits we should
perform comparison after calling this function, otherwise they will never
match and we will be forced to perform full reconnect.

Signed-off-by: Alexandre Peixoto Ferreira <alexandref75@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ef8313bb 23-Dec-2010 Andres Salomon <dilinger@queued.net>

Input: psmouse - disable the synaptics extension on OLPC machines

OLPC has switched to a Synaptics touchpad. It turns out that it's
pretty useless in absolute mode. This patch looks for an OLPC
system (via DMI tables), and refuses to init Synaptics mode in
that scenario (falling back to relative mode).

Signed-off-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 7ee99161 23-Dec-2010 Andres Salomon <dilinger@queued.net>

Input: psmouse - fix up Synaptics comment

Minor comment fixup for typos and grammar. Noticed while adding a
separate workaround.

Signed-off-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 4f56ce92 18-Dec-2010 Henrik Rydberg <rydberg@euromail.se>

Input: synaptics - ignore bogus mt packet

In multitouch mode, at least one device (fw: 7.4 id: 0x1c0b1) sometimes
sends a final main packet with x == 1. Since the normal values are above
1472, this is clearly bogus. At the same time, a two-finger touch is
signaled, even though only one finger was on the pad to begin with. This
patch ignores the packet altogether, removing the problem.

Acked-by: Chris Bagwell <chris@cnpbagwell.com>
Acked-by: Chase Douglas <chase.douglas@canonical.com>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>


# fec6e525 21-Dec-2010 Henrik Rydberg <rydberg@euromail.se>

Input: synaptics - add multi-finger and semi-mt support

The Synaptics 2.7 series of touchpads support a mode for reporting two
sets of X/Y/Pressure data (advanced gesture mode). By default, these
devices report only single finger data, depriving userspace of the
nowadays ubiquitous two-finger scroll gesture.

Enabling advanced gesture mode also enables the multi-finger report,
although the device does not claim that capability. Up to three
fingers can be reported this way.

While two or three fingers are touching, the normal packet is
prepended by a reduced finger packet of lower resolution. From the two
packets (which do not represent the actual fingers), the bounding
rectangle of the individual contacts can be extracted. This
information is sufficient to perform scaling gestures and a limited
form of rotation gesture. The behavior has been coined semi-mt
capability, and is signaled to userspace via the INPUT_PROP_SEMI_MT
device property.

Work to decode the advanced gesture packet: Takashi Iwai.
Cleanup and testing of the original patch: Chase Douglas.
Minor cleanup and testing: Chris Bagwell.
Finalization and semi-mt support: Henrik Rydberg.

Reported-by: Tobyn Bertram
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>


# c14890a8 16-Dec-2010 Henrik Rydberg <rydberg@euromail.se>

Input: synaptics - report clickpad property

With the new input property interface, it is possible to report the
special quirks of a device using ioctl/sysfs. This patch sets up the
device as a pointer, and reports the clickpad functionality via the
INPUT_PROP_BUTTONPAD property.

Acked-by: Chase Douglas <chase.douglas@canonical.com>
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>


# a8b3c0f5 04-Oct-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - simplify pass-through port handling

There was too much knowledge about internals if serio in the pass-through
handling, clean it up.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 6792cbbb 29-Sep-2010 Davidlohr Bueso <dave@gnu.org>

Input: return -ENOMEM in select drivers when memory allocation fails

Instead of using -1 let's start using proper error codes.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 987a6c02 02-Aug-2010 Daniel Mack <daniel@caiaq.de>

Input: switch to input_abs_*() access functions

Change all call sites in drivers/input to not access the ABS axis
information directly anymore. Make them use the access helpers instead.

Also use input_set_abs_params() when possible.
Did some code refactoring as I was on it.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 3619b8fe 21-Jul-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - relax capability ID checks on newer hardware

Older firmwares fixed the middle byte of the Synaptics capabilities
query to 0x47, but starting with firmware 7.5 the middle byte
represents submodel ID, sometimes also called "dash number".

Reported-and-tested-by: Miroslav Šulc <fordfrog@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 58fb0218 19-Jul-2010 Chris Bagwell <chris@cnpbagwell.com>

Input: synaptics - set min/max for finger width

Reporting this will allow GUI config apps to correctly scale
width sensitive config values (such as palm detect) to correct
range. Current user apps are detecting kernels min/max=0/0 and
making an assumption that it means 0/16 or 0/15.

Synaptics touchpad interface guides show 4/15 are correct values
but driver forces to 0 when no fingers on touchpad.

Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 2a8e7710 19-Jul-2010 Chris Bagwell <chris@cnpbagwell.com>

Input: synaptics - only report width on hardware that supports it

Synaptics devices report fixed value of 5 for finger/palm widths
on devices that do not support capability and driver further
hardcodes to 5. Stop reporting this fixed value when its not
supported since its not useful.

This will aid applications so they can better auto-enable support
for multi-touch emulation and palm detection logic using finger
width only for devices that support width detection.

I can find no applications that currently require existence on
ABS_TOOL_WIDTH. Since only synaptics and bcm input devices
currently support this tool, it seems they must handle it
gracefully.

Signed-off-by: Chris Bagwell <chris@cnpbagwell.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# bbddd199 14-Jul-2010 Takashi Iwai <tiwai@suse.de>

Input: synaptics - fix wrong dimensions check

The commit 83ba9ea8a04b72dfee2515428c15e7414ba4fc61 ommitted the return
line for the old synaptics model accidentally. This resulted in a wrong
check, namely, the dimensions are checked for the old devices that don't
support the query properly.

This patch adds the return line back.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a62f0d27 19-May-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: psmouse - small formatting changes to better follow coding style

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 83ba9ea8 11-May-2010 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - set dimensions as reported by firmware

Newer Synaptics firmware allows to query maximim dimensions reported by
device, let's use this data.

Tested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 5f57d67d 19-Apr-2010 Takashi Iwai <tiwai@suse.de>

Input: Add support of Synaptics Clickpad device

The new type of touchpads can be detected via a new query command
0x0c. The clickpad flags are in cap[0]:4 and cap[1]:0 bits.

When the device is detected, the driver now reports only the left
button as the supported buttons so that X11 driver can detect that
the device is Clickpad. A Clickpad device gives the button events
only as the middle button. The kernel driver morphs to the left
button. The real handling of Clickpad is done rather in X driver
side.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 5a0e3ad6 24-Mar-2010 Tejun Heo <tj@kernel.org>

include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h

percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.

2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).

* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>


# e4e6efd2 07-Jan-2010 Daniel Drake <dsd@laptop.org>

Input: psmouse - fix Synaptics detection when protocol is disabled

For configurations where Synaptics hardware is present but the Synaptics
extensions support is not compiled in, the mouse is reprobed and a new
device is allocated on every suspend/resume.

During probe, psmouse_switch_protocol() calls psmouse_extensions() with
set_properties=1. This calls the dummy synaptics_init() which returns an
error code, instructing us not to use the synaptics extensions.

During resume, psmouse_reconnect() calls psmouse_extensions() with
set_properties=0, in which case call to synaptics_init() is bypassed and
PSMOUSE_SYNAPTICS is returned. Since the result is different from previous
attempt psmouse_reconnect() fails and full re-probe happens.

Fix this by tweaking the set_properties=0 codepath in psmouse_extensions()
to be more careful about offering PSMOUSE_SYNAPTICS extensions.

Signed-off-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 9961e259 04-Dec-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: psmouse - remove identification strings from DMI tables

The driver does not reference identification strings in DMI tables and
since these strings are no longer required by DMI core we can safely
remove them and save some memory.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 7705d548 04-Dec-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: psmouse - do not carry DMI data around

DMI tables use considerable amount of memory. Mark them as __initconst
so they will be discarded once module is loaded.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 5f5eeff4 12-Oct-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: synaptics - add another Protege M300 to rate blacklist

Apparently some of Toshiba Protege M300 identify themselves as
"Portable PC" in DMI so we need to add that to the DMI table as
well. We need DMI data so we can automatically lower Synaptics
reporting rate from 80 to 40 pps to avoid over-taxing their
keyboard controllers.

Tested-by: Rod Davison <roddavison@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# b7802c5c 09-Sep-2009 Dmitry Torokhov <dmitry.torokhov@gmail.com>

Input: psmouse - use boolean type

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# ec20a022 11-Jun-2009 Tero Saarni <tero.saarni@gmail.com>

Input: synaptics - add support for reporting x/y resolution

Synaptics uses anisotropic coordinate system. On some wide touchpads
vertical resolution can be twice as high as horizontal which causes
unequal sensitivity on x/y directions. Add support for reading the
resolution with EVIOCGABS ioctl.

Signed-off-by: Tero Saarni <tero.saarni@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 4d368456 28-Feb-2009 Andy Whitcroft <apw@canonical.com>

Input: synaptics - ensure we reset the device on resume

When resuming from suspend newer Synaptics touchpads do not recover
correctly. Analysis of the resume sequence as applied in Linux was
compared to that of other operating systems. This indicated that the
other OSs were resetting the mouse before attempting to detect it (for
all Synaptics touchpads, old and new). Applying this same modification
fixes these newer Synaptics touchpads and brings the driver into line
with common OS reset behaviour.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# e42b6646 20-Nov-2008 Peter Hutterer <peter.hutterer@who-t.net>

Input: synaptics - report multi-taps only if supported by the device

According to Section 2.4.4 of the Synaptics TouchPad Interfacing
Guide, bit 2 specifies if multi-finger detection is provided by
the touchpad. Thus, only set BTN_TOOL_DOUBLETAP and
BTN_TOOL_TRIPLETAP if the device actually supports it.

Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1855256c 03-Oct-2007 Jeff Garzik <jeff@garzik.org>

drivers/firmware: const-ify DMI API and internals

Three main sets of changes:

1) dmi_get_system_info() return value should have been marked const,
since callers should not be changing that data.

2) const-ify DMI internals, since DMI firmware tables should,
whenever possible, be marked const to ensure we never ever write to
that data area.

3) const-ify DMI API, to enable marking tables const where possible
in low-level drivers.

And if we're really lucky, this might enable some additional
optimizations on the part of the compiler.

The bulk of the changes are #2 and #3, which are interrelated. #1 could
have been a separate patch, but it was so small compared to the others,
it was easier to roll it into this changeset.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 4bdd488f 02-May-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: synaptics - don't complain about failed resets

On many laptops (Compaq, HP) the touchpad is so slow responding
to reset that keyboard controller times out. The device is reset
nonetheless and works fine. Kill the "synaptics reset failed"
error; if device is not working then other parts of
synaptics_query_hardware() will fail anyway.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 887cc127 11-Apr-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: synaptics - export model bits

Encode synaptics model in psmouse->model so it will be
exported via sysfs as input_dev->id.version and become
visible for applications.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 55e3d922 09-Mar-2007 Andres Salomon <dilinger@debian.org>

Input: psmouse - allow disabing certain protocol extensions

Allow ALPS, LOGIPS2PP, LIFEBOOK, TRACKPOINT and TOUCHKIT protocol
extensions of psmouse to be disabled during compilation. This will
allow users save some memory when they are sure that they will only
use a certain type of mice.

Signed-off-by: Andres Salomon <dilinger@debian.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# a1cec061 17-Feb-2007 Dmitry Torokhov <dtor@insightbb.com>

Input: psmouse - properly reset mouse on shutdown/suspend

Some people report that they need psmouse module unloaded
for suspend to ram/disk to work properly. Let's make port
cleanup behave the same way as driver unload.

This fixes "bad state" roblem on various HP laptops, such
as nx7400.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 7d12e780 05-Oct-2006 David Howells <dhowells@redhat.com>

IRQ: Maintain regs pointer globally rather than passing to IRQ handlers

Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.

The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).

Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.

Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.

I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.

This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:

struct pt_regs *old_regs = set_irq_regs(regs);

And put the old one back at the end:

set_irq_regs(old_regs);

Don't pass regs through to generic_handle_irq() or __do_IRQ().

In timer_interrupt(), this sort of change will be necessary:

- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);

I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().

Some notes on the interrupt handling in the drivers:

(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.

(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.

(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.

Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)


# e38de678 10-Sep-2006 Helge Deller <deller@gmx.de>

Input: constify psmouse driver

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 53a2670c 01-Apr-2006 Richard Thrippleton <ret28@cam.ac.uk>

Input: synaptics - limit rate to 40pps on Toshiba Protege M300

Toshiba Protege M300 also requires the same workaround as Satellites
and Dynabooks - Synaptics report rate should be lowered to 40pps
(from 80), otherwise KBC starts losing keypresses.

Signed-off-by: Richard Thrippleton <ret28@cam.ac.uk>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# b39787a9 13-Mar-2006 Eric Sesterhenn <snakebyte@gmx.de>

Input: use kzalloc() throughout the code

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# f0d5c6f4 13-Jan-2006 Dmitry Torokhov <dtor_core@ameritech.net>

Input: psmouse - attempt to re-synchronize mouse every 5 seconds

This should help driver to deal vith KVMs that reset mice when
switching between boxes.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 2e5b636b 15-Sep-2005 Dmitry Torokhov <dtor_core@ameritech.net>

[PATCH] drivers/input/mouse: convert to dynamic input_dev allocation

Input: convert drivers/input/mouse to dynamic input_dev allocation

This is required for input_dev sysfs integration

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 33fdfa97 23-Jul-2005 Sergey Vlasov <vsu@altlinux.ru>

Input: synaptics - fix setting packet size on passthrough port.

Synaptics driver used child->type to select either 3-byte or 4-byte
packet size for the pass-through port; this gives wrong results for
the newer protocols. Change the check to use child->pktsize instead.

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 9ba5eaaf 11-Jul-2005 Simon Horman <horms@valinux.co.jp>

Input: synaptics - limit rate to 40pps on Toshiba Dynabooks

Toshiba Dynabooks require the same workaround as Satellites -
Synaptics report rate should be lowered to 40pps (from 80),
otherwise KBC starts losing keypresses.

Signed-off-by: Simon Horman <horms@valinux.co.jp>
Signed-off-by: Vojtech Pavlik <vojtech@suse.cz>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 409b7506 28-May-2005 Dmitry Torokhov <dtor_core@ameritech.net>

Input: synaptics - reduce verboseness of synaptics driver - there
is no reason one driver should take 10 lines in dmesg.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!