aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 15:38:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 15:38:20 -0400
commit16a12fa9aed176444fc795b09e796be41902bb08 (patch)
treebd158def3263a8b0d0f0886fd0fcd32728242dc4
parentd25e436c4b68db2895185b24ad1f22499c2f87b0 (diff)
parent0337966d121ebebf73a1c346123e8112796e684e (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input subsystem updates from Dmitry Torokhov: - a big update from Mauro converting input documentation to ReST format - Synaptics PS/2 is now aware of SMBus companion devices, which means that we can now use native RMI4 protocol to handle touchpads, instead of relying on legacy PS/2 mode. - we removed support from BMA180 accelerometer from input devices as it is now handled properly by IIO - update to TSC2007 to corretcly report pressure - other miscellaneous driver fixes. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (152 commits) Input: ar1021_i2c - use BIT to check for a bit Input: twl4030-pwrbutton - use input_set_capability() helper Input: twl4030-pwrbutton - use correct device for irq request Input: ar1021_i2c - enable touch mode during open Input: add uinput documentation dt-bindings: input: add bindings document for ar1021_i2c driver dt-bindings: input: rotary-encoder: fix typo Input: xen-kbdfront - add module parameter for setting resolution ARM: pxa/raumfeld: fix compile error in rotary controller resources Input: xpad - do not suggest writing to Dominic Input: xpad - don't use literal blocks inside footnotes Input: xpad - note that usb/devices is now at /sys/kernel/debug/ Input: docs - freshen up introduction Input: docs - split input docs into kernel- and user-facing Input: docs - note that MT-A protocol is obsolete Input: docs - update joystick documentation a bit Input: docs - remove disclaimer/GPL notice Input: fix "Game console" heading level in joystick documentation Input: rotary-encoder - remove references to platform data from docs Input: move documentation for Amiga CD32 ...
-rw-r--r--Documentation/conf.py2
-rw-r--r--Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt2
-rw-r--r--Documentation/devicetree/bindings/input/pwm-beeper.txt1
-rw-r--r--Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.txt1
-rw-r--r--Documentation/devicetree/bindings/input/rotary-encoder.txt2
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/ad7879.txt19
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/ads7846.txt (renamed from Documentation/devicetree/bindings/input/ads7846.txt)0
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/ar1021.txt16
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/max11801-ts.txt18
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt7
-rw-r--r--Documentation/input/cd32.txt19
-rw-r--r--Documentation/input/conf.py10
-rw-r--r--Documentation/input/devices/alps.rst (renamed from Documentation/input/alps.txt)45
-rw-r--r--Documentation/input/devices/amijoy.rst (renamed from Documentation/input/amijoy.txt)179
-rw-r--r--Documentation/input/devices/appletouch.rst (renamed from Documentation/input/appletouch.txt)45
-rw-r--r--Documentation/input/devices/atarikbd.rst (renamed from Documentation/input/atarikbd.txt)225
-rw-r--r--Documentation/input/devices/bcm5974.rst (renamed from Documentation/input/bcm5974.txt)43
-rw-r--r--Documentation/input/devices/cma3000_d0x.rst (renamed from Documentation/input/cma3000_d0x.txt)74
-rw-r--r--Documentation/input/devices/cs461x.rst (renamed from Documentation/input/cs461x.txt)28
-rw-r--r--Documentation/input/devices/edt-ft5x06.rst (renamed from Documentation/input/edt-ft5x06.txt)0
-rw-r--r--Documentation/input/devices/elantech.rst (renamed from Documentation/input/elantech.txt)306
-rw-r--r--Documentation/input/devices/gpio-tilt.rst103
-rw-r--r--Documentation/input/devices/iforce-protocol.rst381
-rw-r--r--Documentation/input/devices/index.rst19
-rw-r--r--Documentation/input/devices/joystick-parport.rst611
-rw-r--r--Documentation/input/devices/ntrig.rst (renamed from Documentation/input/ntrig.txt)49
-rw-r--r--Documentation/input/devices/rotary-encoder.rst (renamed from Documentation/input/rotary-encoder.txt)117
-rw-r--r--Documentation/input/devices/sentelic.rst901
-rw-r--r--Documentation/input/devices/walkera0701.rst (renamed from Documentation/input/walkera0701.txt)51
-rw-r--r--Documentation/input/devices/xpad.rst (renamed from Documentation/input/xpad.txt)143
-rw-r--r--Documentation/input/devices/yealink.rst (renamed from Documentation/input/yealink.txt)173
-rw-r--r--Documentation/input/event-codes.rst (renamed from Documentation/input/event-codes.txt)134
-rw-r--r--Documentation/input/ff.rst (renamed from Documentation/input/ff.txt)208
-rw-r--r--Documentation/input/gamepad.rst (renamed from Documentation/input/gamepad.txt)94
-rw-r--r--Documentation/input/gameport-programming.rst (renamed from Documentation/input/gameport-programming.txt)83
-rw-r--r--Documentation/input/gpio-tilt.txt103
-rw-r--r--Documentation/input/iforce-protocol.txt258
-rw-r--r--Documentation/input/index.rst20
-rw-r--r--Documentation/input/input-programming.rst (renamed from Documentation/input/input-programming.txt)268
-rw-r--r--Documentation/input/input.rst281
-rw-r--r--Documentation/input/input.txt290
-rw-r--r--Documentation/input/input_kapi.rst17
-rw-r--r--Documentation/input/input_uapi.rst22
-rw-r--r--Documentation/input/interactive.fig42
-rw-r--r--Documentation/input/interactive.svg24
-rw-r--r--Documentation/input/joydev/index.rst18
-rw-r--r--Documentation/input/joydev/joystick-api.rst (renamed from Documentation/input/joystick-api.txt)160
-rw-r--r--Documentation/input/joydev/joystick.rst585
-rw-r--r--Documentation/input/joystick-parport.txt542
-rw-r--r--Documentation/input/joystick.txt586
-rw-r--r--Documentation/input/multi-touch-protocol.rst (renamed from Documentation/input/multi-touch-protocol.txt)206
-rw-r--r--Documentation/input/notifier.rst (renamed from Documentation/input/notifier.txt)10
-rw-r--r--Documentation/input/sentelic.txt873
-rw-r--r--Documentation/input/shape.fig65
-rw-r--r--Documentation/input/shape.svg39
-rw-r--r--Documentation/input/uinput.rst245
-rw-r--r--Documentation/input/userio.rst (renamed from Documentation/input/userio.txt)79
-rw-r--r--MAINTAINERS4
-rw-r--r--arch/arm/mach-pxa/raumfeld.c24
-rw-r--r--drivers/i2c/i2c-boardinfo.c24
-rw-r--r--drivers/i2c/i2c-core.c34
-rw-r--r--drivers/input/gameport/gameport.c9
-rw-r--r--drivers/input/joystick/db9.c4
-rw-r--r--drivers/input/joystick/gamecon.c3
-rw-r--r--drivers/input/joystick/turbografx.c4
-rw-r--r--drivers/input/joystick/xpad.c114
-rw-r--r--drivers/input/keyboard/cros_ec_keyb.c7
-rw-r--r--drivers/input/keyboard/locomokbd.c5
-rw-r--r--drivers/input/keyboard/matrix_keypad.c13
-rw-r--r--drivers/input/keyboard/omap4-keypad.c2
-rw-r--r--drivers/input/keyboard/qt1070.c9
-rw-r--r--drivers/input/keyboard/tca8418_keypad.c2
-rw-r--r--drivers/input/misc/Kconfig2
-rw-r--r--drivers/input/misc/apanel.c3
-rw-r--r--drivers/input/misc/axp20x-pek.c62
-rw-r--r--drivers/input/misc/bma150.c11
-rw-r--r--drivers/input/misc/dm355evm_keys.c79
-rw-r--r--drivers/input/misc/drv260x.c4
-rw-r--r--drivers/input/misc/pm8xxx-vibrator.c78
-rw-r--r--drivers/input/misc/pwm-beeper.c15
-rw-r--r--drivers/input/misc/soc_button_array.c182
-rw-r--r--drivers/input/misc/twl4030-pwrbutton.c5
-rw-r--r--drivers/input/misc/wistron_btns.c5
-rw-r--r--drivers/input/misc/xen-kbdfront.c45
-rw-r--r--drivers/input/misc/yealink.h2
-rw-r--r--drivers/input/mouse/Kconfig16
-rw-r--r--drivers/input/mouse/Makefile2
-rw-r--r--drivers/input/mouse/alps.c76
-rw-r--r--drivers/input/mouse/alps.h6
-rw-r--r--drivers/input/mouse/psmouse-base.c216
-rw-r--r--drivers/input/mouse/psmouse-smbus.c302
-rw-r--r--drivers/input/mouse/psmouse.h102
-rw-r--r--drivers/input/mouse/synaptics.c980
-rw-r--r--drivers/input/mouse/synaptics.h154
-rw-r--r--drivers/input/mouse/synaptics_i2c.c9
-rw-r--r--drivers/input/rmi4/rmi_driver.c13
-rw-r--r--drivers/input/rmi4/rmi_f12.c18
-rw-r--r--drivers/input/rmi4/rmi_f34.c27
-rw-r--r--drivers/input/rmi4/rmi_f34.h7
-rw-r--r--drivers/input/rmi4/rmi_f34v7.c117
-rw-r--r--drivers/input/rmi4/rmi_i2c.c51
-rw-r--r--drivers/input/rmi4/rmi_smbus.c94
-rw-r--r--drivers/input/rmi4/rmi_spi.c44
-rw-r--r--drivers/input/serio/serio.c30
-rw-r--r--drivers/input/sparse-keymap.c39
-rw-r--r--drivers/input/touchscreen/Kconfig18
-rw-r--r--drivers/input/touchscreen/Makefile2
-rw-r--r--drivers/input/touchscreen/ad7879-i2c.c67
-rw-r--r--drivers/input/touchscreen/ad7879-spi.c131
-rw-r--r--drivers/input/touchscreen/ad7879.c152
-rw-r--r--drivers/input/touchscreen/ad7879.h14
-rw-r--r--drivers/input/touchscreen/ads7846.c2
-rw-r--r--drivers/input/touchscreen/ar1021_i2c.c30
-rw-r--r--drivers/input/touchscreen/eeti_ts.c226
-rw-r--r--drivers/input/touchscreen/imx6ul_tsc.c15
-rw-r--r--drivers/input/touchscreen/lpc32xx_ts.c13
-rw-r--r--drivers/input/touchscreen/max11801_ts.c7
-rw-r--r--drivers/input/touchscreen/melfas_mip4.c11
-rw-r--r--drivers/input/touchscreen/silead.c13
-rw-r--r--drivers/input/touchscreen/sur40.c2
-rw-r--r--drivers/input/touchscreen/tps6507x-ts.c33
-rw-r--r--drivers/input/touchscreen/tsc2007.h101
-rw-r--r--drivers/input/touchscreen/tsc2007_core.c (renamed from drivers/input/touchscreen/tsc2007.c)102
-rw-r--r--drivers/input/touchscreen/tsc2007_iio.c140
-rw-r--r--include/linux/i2c.h5
-rw-r--r--include/linux/input/eeti_ts.h10
-rw-r--r--include/linux/input/matrix_keypad.h3
-rw-r--r--include/linux/mfd/cros_ec_commands.h4
-rw-r--r--include/linux/serio.h1
129 files changed, 7608 insertions, 5390 deletions
diff --git a/Documentation/conf.py b/Documentation/conf.py
index 08aef4595059..bacf9d337c89 100644
--- a/Documentation/conf.py
+++ b/Documentation/conf.py
@@ -348,6 +348,8 @@ latex_documents = [
348 'The kernel development community', 'manual'), 348 'The kernel development community', 'manual'),
349 ('driver-api/index', 'driver-api.tex', 'The kernel driver API manual', 349 ('driver-api/index', 'driver-api.tex', 'The kernel driver API manual',
350 'The kernel development community', 'manual'), 350 'The kernel development community', 'manual'),
351 ('input/index', 'linux-input.tex', 'The Linux input driver subsystem',
352 'The kernel development community', 'manual'),
351 ('kernel-documentation', 'kernel-documentation.tex', 'The Linux Kernel Documentation', 353 ('kernel-documentation', 'kernel-documentation.tex', 'The Linux Kernel Documentation',
352 'The kernel development community', 'manual'), 354 'The kernel development community', 'manual'),
353 ('process/index', 'development-process.tex', 'Linux Kernel Development Documentation', 355 ('process/index', 'development-process.tex', 'Linux Kernel Development Documentation',
diff --git a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
index d0ea09ba249f..570dc10f0cd7 100644
--- a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
+++ b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
@@ -24,6 +24,8 @@ Optional Properties:
24- debounce-delay-ms: debounce interval in milliseconds 24- debounce-delay-ms: debounce interval in milliseconds
25- col-scan-delay-us: delay, measured in microseconds, that is needed 25- col-scan-delay-us: delay, measured in microseconds, that is needed
26 before we can scan keypad after activating column gpio 26 before we can scan keypad after activating column gpio
27- drive-inactive-cols: drive inactive columns during scan,
28 default is to turn inactive columns into inputs.
27 29
28Example: 30Example:
29 matrix-keypad { 31 matrix-keypad {
diff --git a/Documentation/devicetree/bindings/input/pwm-beeper.txt b/Documentation/devicetree/bindings/input/pwm-beeper.txt
index 529408b4431a..8fc0e48c20db 100644
--- a/Documentation/devicetree/bindings/input/pwm-beeper.txt
+++ b/Documentation/devicetree/bindings/input/pwm-beeper.txt
@@ -8,6 +8,7 @@ Required properties:
8 8
9Optional properties: 9Optional properties:
10- amp-supply: phandle to a regulator that acts as an amplifier for the beeper 10- amp-supply: phandle to a regulator that acts as an amplifier for the beeper
11- beeper-hz: bell frequency in Hz
11 12
12Example: 13Example:
13 14
diff --git a/Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.txt b/Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.txt
index 4ed467b1e402..64bb990075c3 100644
--- a/Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.txt
+++ b/Documentation/devicetree/bindings/input/qcom,pm8xxx-vib.txt
@@ -7,6 +7,7 @@ PROPERTIES
7 Value type: <string> 7 Value type: <string>
8 Definition: must be one of: 8 Definition: must be one of:
9 "qcom,pm8058-vib" 9 "qcom,pm8058-vib"
10 "qcom,pm8916-vib"
10 "qcom,pm8921-vib" 11 "qcom,pm8921-vib"
11 12
12- reg: 13- reg:
diff --git a/Documentation/devicetree/bindings/input/rotary-encoder.txt b/Documentation/devicetree/bindings/input/rotary-encoder.txt
index e85ce3dea480..f99fe5cdeaec 100644
--- a/Documentation/devicetree/bindings/input/rotary-encoder.txt
+++ b/Documentation/devicetree/bindings/input/rotary-encoder.txt
@@ -12,7 +12,7 @@ Optional properties:
12- rotary-encoder,relative-axis: register a relative axis rather than an 12- rotary-encoder,relative-axis: register a relative axis rather than an
13 absolute one. Relative axis will only generate +1/-1 events on the input 13 absolute one. Relative axis will only generate +1/-1 events on the input
14 device, hence no steps need to be passed. 14 device, hence no steps need to be passed.
15- rotary-encoder,rollover: Automatic rollove when the rotary value becomes 15- rotary-encoder,rollover: Automatic rollover when the rotary value becomes
16 greater than the specified steps or smaller than 0. For absolute axis only. 16 greater than the specified steps or smaller than 0. For absolute axis only.
17- rotary-encoder,steps-per-period: Number of steps (stable states) per period. 17- rotary-encoder,steps-per-period: Number of steps (stable states) per period.
18 The values have the following meaning: 18 The values have the following meaning:
diff --git a/Documentation/devicetree/bindings/input/touchscreen/ad7879.txt b/Documentation/devicetree/bindings/input/touchscreen/ad7879.txt
index e3f22d23fc8f..3c8614c451f2 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ad7879.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ad7879.txt
@@ -35,6 +35,7 @@ Optional properties:
35- adi,conversion-interval: : 0 : convert one time only 35- adi,conversion-interval: : 0 : convert one time only
36 1-255: 515us + val * 35us (up to 9.440ms) 36 1-255: 515us + val * 35us (up to 9.440ms)
37 This property has to be a '/bits/ 8' value 37 This property has to be a '/bits/ 8' value
38- gpio-controller : Switch AUX/VBAT/GPIO pin to GPIO mode
38 39
39Example: 40Example:
40 41
@@ -51,3 +52,21 @@ Example:
51 adi,averaging = /bits/ 8 <1>; 52 adi,averaging = /bits/ 8 <1>;
52 adi,conversion-interval = /bits/ 8 <255>; 53 adi,conversion-interval = /bits/ 8 <255>;
53 }; 54 };
55
56 ad7879@1 {
57 compatible = "adi,ad7879";
58 spi-max-frequency = <5000000>;
59 reg = <1>;
60 spi-cpol;
61 spi-cpha;
62 gpio-controller;
63 interrupt-parent = <&gpio1>;
64 interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
65 touchscreen-max-pressure = <4096>;
66 adi,resistance-plate-x = <120>;
67 adi,first-conversion-delay = /bits/ 8 <3>;
68 adi,acquisition-time = /bits/ 8 <1>;
69 adi,median-filter-size = /bits/ 8 <2>;
70 adi,averaging = /bits/ 8 <1>;
71 adi,conversion-interval = /bits/ 8 <255>;
72 };
diff --git a/Documentation/devicetree/bindings/input/ads7846.txt b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
index 9fc47b006fd1..9fc47b006fd1 100644
--- a/Documentation/devicetree/bindings/input/ads7846.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
diff --git a/Documentation/devicetree/bindings/input/touchscreen/ar1021.txt b/Documentation/devicetree/bindings/input/touchscreen/ar1021.txt
new file mode 100644
index 000000000000..e459e8546f34
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/ar1021.txt
@@ -0,0 +1,16 @@
1* Microchip AR1020 and AR1021 touchscreen interface (I2C)
2
3Required properties:
4- compatible : "microchip,ar1021-i2c"
5- reg : I2C slave address
6- interrupt-parent : the phandle for the interrupt controller
7- interrupts : touch controller interrupt
8
9Example:
10
11 touchscreen@4d {
12 compatible = "microchip,ar1021-i2c";
13 reg = <0x4d>;
14 interrupt-parent = <&gpio3>;
15 interrupts = <11 IRQ_TYPE_LEVEL_HIGH>;
16 };
diff --git a/Documentation/devicetree/bindings/input/touchscreen/max11801-ts.txt b/Documentation/devicetree/bindings/input/touchscreen/max11801-ts.txt
new file mode 100644
index 000000000000..40ac0fe94df6
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/max11801-ts.txt
@@ -0,0 +1,18 @@
1* MAXI MAX11801 Resistive touch screen controller with i2c interface
2
3Required properties:
4- compatible: must be "maxim,max11801"
5- reg: i2c slave address
6- interrupt-parent: the phandle for the interrupt controller
7- interrupts: touch controller interrupt
8
9Example:
10
11&i2c1 {
12 max11801: touchscreen@48 {
13 compatible = "maxim,max11801";
14 reg = <0x48>;
15 interrupt-parent = <&gpio3>;
16 interrupts = <31 IRQ_TYPE_EDGE_FALLING>;
17 };
18};
diff --git a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
index ce85ee508238..6aa625e0cb8d 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/silead_gsl1680.txt
@@ -1,7 +1,12 @@
1* GSL 1680 touchscreen controller 1* GSL 1680 touchscreen controller
2 2
3Required properties: 3Required properties:
4- compatible : "silead,gsl1680" 4- compatible : Must be one of the following, depending on the model:
5 "silead,gsl1680"
6 "silead,gsl1688"
7 "silead,gsl3670"
8 "silead,gsl3675"
9 "silead,gsl3692"
5- reg : I2C slave address of the chip (0x40) 10- reg : I2C slave address of the chip (0x40)
6- interrupt-parent : a phandle pointing to the interrupt controller 11- interrupt-parent : a phandle pointing to the interrupt controller
7 serving the interrupt for this chip 12 serving the interrupt for this chip
diff --git a/Documentation/input/cd32.txt b/Documentation/input/cd32.txt
deleted file mode 100644
index a003d9b41eca..000000000000
--- a/Documentation/input/cd32.txt
+++ /dev/null
@@ -1,19 +0,0 @@
1I have written a small patch that let's me use my Amiga CD32
2joypad connected to the parallel port. Thought I'd share it with you so
3you can add it to the list of supported joysticks (hopefully someone will
4find it useful).
5
6It needs the following wiring:
7
8CD32 pad | Parallel port
9----------------------------
101 (Up) | 2 (D0)
112 (Down) | 3 (D1)
123 (Left) | 4 (D2)
134 (Right) | 5 (D3)
145 (Fire3) | 14 (AUTOFD)
156 (Fire1) | 17 (SELIN)
167 (+5V) | 1 (STROBE)
178 (Gnd) | 18 (Gnd)
189 (Fire2) | 7 (D5)
19
diff --git a/Documentation/input/conf.py b/Documentation/input/conf.py
new file mode 100644
index 000000000000..d2352fdc92ed
--- /dev/null
+++ b/Documentation/input/conf.py
@@ -0,0 +1,10 @@
1# -*- coding: utf-8; mode: python -*-
2
3project = "The Linux input driver subsystem"
4
5tags.add("subproject")
6
7latex_documents = [
8 ('index', 'linux-input.tex', project,
9 'The kernel development community', 'manual'),
10]
diff --git a/Documentation/input/alps.txt b/Documentation/input/devices/alps.rst
index 8d1341ccde64..6779148e428c 100644
--- a/Documentation/input/alps.txt
+++ b/Documentation/input/devices/alps.rst
@@ -1,10 +1,11 @@
1----------------------
1ALPS Touchpad Protocol 2ALPS Touchpad Protocol
2---------------------- 3----------------------
3 4
4Introduction 5Introduction
5------------ 6------------
6Currently the ALPS touchpad driver supports seven protocol versions in use by 7Currently the ALPS touchpad driver supports seven protocol versions in use by
7ALPS touchpads, called versions 1, 2, 3, 4, 5, 6 and 7. 8ALPS touchpads, called versions 1, 2, 3, 4, 5, 6, 7 and 8.
8 9
9Since roughly mid-2010 several new ALPS touchpads have been released and 10Since roughly mid-2010 several new ALPS touchpads have been released and
10integrated into a variety of laptops and netbooks. These new touchpads 11integrated into a variety of laptops and netbooks. These new touchpads
@@ -78,7 +79,7 @@ of the EC response.
78Packet Format 79Packet Format
79------------- 80-------------
80 81
81In the following tables, the following notation is used. 82In the following tables, the following notation is used::
82 83
83 CAPITALS = stick, miniscules = touchpad 84 CAPITALS = stick, miniscules = touchpad
84 85
@@ -88,6 +89,8 @@ extra buttons, stick buttons on a dualpoint, etc.
88PS/2 packet format 89PS/2 packet format
89------------------ 90------------------
90 91
92::
93
91 byte 0: 0 0 YSGN XSGN 1 M R L 94 byte 0: 0 0 YSGN XSGN 1 M R L
92 byte 1: X7 X6 X5 X4 X3 X2 X1 X0 95 byte 1: X7 X6 X5 X4 X3 X2 X1 X0
93 byte 2: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 96 byte 2: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
@@ -99,7 +102,9 @@ are on the touchpad, the M R L bits signal the combined status of both the
99pointingstick and touchpad buttons. 102pointingstick and touchpad buttons.
100 103
101ALPS Absolute Mode - Protocol Version 1 104ALPS Absolute Mode - Protocol Version 1
102-------------------------------------- 105---------------------------------------
106
107::
103 108
104 byte 0: 1 0 0 0 1 x9 x8 x7 109 byte 0: 1 0 0 0 1 x9 x8 x7
105 byte 1: 0 x6 x5 x4 x3 x2 x1 x0 110 byte 1: 0 x6 x5 x4 x3 x2 x1 x0
@@ -111,6 +116,8 @@ ALPS Absolute Mode - Protocol Version 1
111ALPS Absolute Mode - Protocol Version 2 116ALPS Absolute Mode - Protocol Version 2
112--------------------------------------- 117---------------------------------------
113 118
119::
120
114 byte 0: 1 ? ? ? 1 PSM PSR PSL 121 byte 0: 1 ? ? ? 1 PSM PSR PSL
115 byte 1: 0 x6 x5 x4 x3 x2 x1 x0 122 byte 1: 0 x6 x5 x4 x3 x2 x1 x0
116 byte 2: 0 x10 x9 x8 x7 ? fin ges 123 byte 2: 0 x10 x9 x8 x7 ? fin ges
@@ -127,6 +134,8 @@ and PSL bits.
127Dualpoint device -- interleaved packet format 134Dualpoint device -- interleaved packet format
128--------------------------------------------- 135---------------------------------------------
129 136
137::
138
130 byte 0: 1 1 0 0 1 1 1 1 139 byte 0: 1 1 0 0 1 1 1 1
131 byte 1: 0 x6 x5 x4 x3 x2 x1 x0 140 byte 1: 0 x6 x5 x4 x3 x2 x1 x0
132 byte 2: 0 x10 x9 x8 x7 0 fin ges 141 byte 2: 0 x10 x9 x8 x7 0 fin ges
@@ -149,7 +158,7 @@ ALPS protocol version 3 has three different packet formats. The first two are
149associated with touchpad events, and the third is associated with trackstick 158associated with touchpad events, and the third is associated with trackstick
150events. 159events.
151 160
152The first type is the touchpad position packet. 161The first type is the touchpad position packet::
153 162
154 byte 0: 1 ? x1 x0 1 1 1 1 163 byte 0: 1 ? x1 x0 1 1 1 1
155 byte 1: 0 x10 x9 x8 x7 x6 x5 x4 164 byte 1: 0 x10 x9 x8 x7 x6 x5 x4
@@ -165,7 +174,7 @@ The second packet type contains bitmaps representing the x and y axes. In the
165bitmaps a given bit is set if there is a finger covering that position on the 174bitmaps a given bit is set if there is a finger covering that position on the
166given axis. Thus the bitmap packet can be used for low-resolution multi-touch 175given axis. Thus the bitmap packet can be used for low-resolution multi-touch
167data, although finger tracking is not possible. This packet also encodes the 176data, although finger tracking is not possible. This packet also encodes the
168number of contacts (f1 and f0 in the table below). 177number of contacts (f1 and f0 in the table below)::
169 178
170 byte 0: 1 1 x1 x0 1 1 1 1 179 byte 0: 1 1 x1 x0 1 1 1 1
171 byte 1: 0 x8 x7 x6 x5 x4 x3 x2 180 byte 1: 0 x8 x7 x6 x5 x4 x3 x2
@@ -178,7 +187,7 @@ This packet only appears after a position packet with the mt bit set, and
178usually only appears when there are two or more contacts (although 187usually only appears when there are two or more contacts (although
179occasionally it's seen with only a single contact). 188occasionally it's seen with only a single contact).
180 189
181The final v3 packet type is the trackstick packet. 190The final v3 packet type is the trackstick packet::
182 191
183 byte 0: 1 1 x7 y7 1 1 1 1 192 byte 0: 1 1 x7 y7 1 1 1 1
184 byte 1: 0 x6 x5 x4 x3 x2 x1 x0 193 byte 1: 0 x6 x5 x4 x3 x2 x1 x0
@@ -190,7 +199,7 @@ The final v3 packet type is the trackstick packet.
190ALPS Absolute Mode - Protocol Version 4 199ALPS Absolute Mode - Protocol Version 4
191--------------------------------------- 200---------------------------------------
192 201
193Protocol version 4 has an 8-byte packet format. 202Protocol version 4 has an 8-byte packet format::
194 203
195 byte 0: 1 ? x1 x0 1 1 1 1 204 byte 0: 1 ? x1 x0 1 1 1 1
196 byte 1: 0 x10 x9 x8 x7 x6 x5 x4 205 byte 1: 0 x10 x9 x8 x7 x6 x5 x4
@@ -203,7 +212,7 @@ Protocol version 4 has an 8-byte packet format.
203 212
204The last two bytes represent a partial bitmap packet, with 3 full packets 213The last two bytes represent a partial bitmap packet, with 3 full packets
205required to construct a complete bitmap packet. Once assembled, the 6-byte 214required to construct a complete bitmap packet. Once assembled, the 6-byte
206bitmap packet has the following format: 215bitmap packet has the following format::
207 216
208 byte 0: 0 1 x7 x6 x5 x4 x3 x2 217 byte 0: 0 1 x7 x6 x5 x4 x3 x2
209 byte 1: 0 x1 x0 y4 y3 y2 y1 y0 218 byte 1: 0 x1 x0 y4 y3 y2 y1 y0
@@ -238,7 +247,7 @@ decode. It uses the same alps_process_touchpad_packet_v3 call with a
238specialized decode_fields function pointer to correctly interpret the 247specialized decode_fields function pointer to correctly interpret the
239packets. This appears to only be used by the Dolphin devices. 248packets. This appears to only be used by the Dolphin devices.
240 249
241For single-touch, the 6-byte packet format is: 250For single-touch, the 6-byte packet format is::
242 251
243 byte 0: 1 1 0 0 1 0 0 0 252 byte 0: 1 1 0 0 1 0 0 0
244 byte 1: 0 x6 x5 x4 x3 x2 x1 x0 253 byte 1: 0 x6 x5 x4 x3 x2 x1 x0
@@ -247,7 +256,7 @@ For single-touch, the 6-byte packet format is:
247 byte 4: y10 y9 y8 y7 x10 x9 x8 x7 256 byte 4: y10 y9 y8 y7 x10 x9 x8 x7
248 byte 5: 0 z6 z5 z4 z3 z2 z1 z0 257 byte 5: 0 z6 z5 z4 z3 z2 z1 z0
249 258
250For mt, the format is: 259For mt, the format is::
251 260
252 byte 0: 1 1 1 n3 1 n2 n1 x24 261 byte 0: 1 1 1 n3 1 n2 n1 x24
253 byte 1: 1 y7 y6 y5 y4 y3 y2 y1 262 byte 1: 1 y7 y6 y5 y4 y3 y2 y1
@@ -259,7 +268,7 @@ For mt, the format is:
259ALPS Absolute Mode - Protocol Version 6 268ALPS Absolute Mode - Protocol Version 6
260--------------------------------------- 269---------------------------------------
261 270
262For trackstick packet, the format is: 271For trackstick packet, the format is::
263 272
264 byte 0: 1 1 1 1 1 1 1 1 273 byte 0: 1 1 1 1 1 1 1 1
265 byte 1: 0 X6 X5 X4 X3 X2 X1 X0 274 byte 1: 0 X6 X5 X4 X3 X2 X1 X0
@@ -268,7 +277,7 @@ For trackstick packet, the format is:
268 byte 4: Z7 Z6 Z5 Z4 Z3 Z2 Z1 Z0 277 byte 4: Z7 Z6 Z5 Z4 Z3 Z2 Z1 Z0
269 byte 5: 0 1 1 1 1 1 1 1 278 byte 5: 0 1 1 1 1 1 1 1
270 279
271For touchpad packet, the format is: 280For touchpad packet, the format is::
272 281
273 byte 0: 1 1 1 1 1 1 1 1 282 byte 0: 1 1 1 1 1 1 1 1
274 byte 1: 0 0 0 0 x3 x2 x1 x0 283 byte 1: 0 0 0 0 x3 x2 x1 x0
@@ -282,7 +291,7 @@ For touchpad packet, the format is:
282ALPS Absolute Mode - Protocol Version 7 291ALPS Absolute Mode - Protocol Version 7
283--------------------------------------- 292---------------------------------------
284 293
285For trackstick packet, the format is: 294For trackstick packet, the format is::
286 295
287 byte 0: 0 1 0 0 1 0 0 0 296 byte 0: 0 1 0 0 1 0 0 0
288 byte 1: 1 1 * * 1 M R L 297 byte 1: 1 1 * * 1 M R L
@@ -291,7 +300,7 @@ For trackstick packet, the format is:
291 byte 4: Y7 0 Y5 Y4 Y3 1 1 0 300 byte 4: Y7 0 Y5 Y4 Y3 1 1 0
292 byte 5: T&P 0 Z5 Z4 Z3 Z2 Z1 Z0 301 byte 5: T&P 0 Z5 Z4 Z3 Z2 Z1 Z0
293 302
294For touchpad packet, the format is: 303For touchpad packet, the format is::
295 304
296 packet-fmt b7 b6 b5 b4 b3 b2 b1 b0 305 packet-fmt b7 b6 b5 b4 b3 b2 b1 b0
297 byte 0: TWO & MULTI L 1 R M 1 Y0-2 Y0-1 Y0-0 306 byte 0: TWO & MULTI L 1 R M 1 Y0-2 Y0-1 Y0-0
@@ -328,7 +337,7 @@ Spoken by SS4 (73 03 14) and SS5 (73 03 28) hardware.
328 337
329The packet type is given by the APD field, bits 4-5 of byte 3. 338The packet type is given by the APD field, bits 4-5 of byte 3.
330 339
331Touchpad packet (APD = 0x2): 340Touchpad packet (APD = 0x2)::
332 341
333 b7 b6 b5 b4 b3 b2 b1 b0 342 b7 b6 b5 b4 b3 b2 b1 b0
334 byte 0: SWM SWR SWL 1 1 0 0 X7 343 byte 0: SWM SWR SWL 1 1 0 0 X7
@@ -340,7 +349,7 @@ Touchpad packet (APD = 0x2):
340 349
341SWM, SWR, SWL: Middle, Right, and Left button states 350SWM, SWR, SWL: Middle, Right, and Left button states
342 351
343Touchpad 1 Finger packet (APD = 0x0): 352Touchpad 1 Finger packet (APD = 0x0)::
344 353
345 b7 b6 b5 b4 b3 b2 b1 b0 354 b7 b6 b5 b4 b3 b2 b1 b0
346 byte 0: SWM SWR SWL 1 1 X2 X1 X0 355 byte 0: SWM SWR SWL 1 1 X2 X1 X0
@@ -353,7 +362,7 @@ Touchpad 1 Finger packet (APD = 0x0):
353TAPF: ??? 362TAPF: ???
354LFB: ??? 363LFB: ???
355 364
356Touchpad 2 Finger packet (APD = 0x1): 365Touchpad 2 Finger packet (APD = 0x1)::
357 366
358 b7 b6 b5 b4 b3 b2 b1 b0 367 b7 b6 b5 b4 b3 b2 b1 b0
359 byte 0: SWM SWR SWL 1 1 AX6 AX5 AX4 368 byte 0: SWM SWR SWL 1 1 AX6 AX5 AX4
@@ -365,7 +374,7 @@ Touchpad 2 Finger packet (APD = 0x1):
365 374
366CONT: A 3-or-4 Finger packet is to follow 375CONT: A 3-or-4 Finger packet is to follow
367 376
368Touchpad 3-or-4 Finger packet (APD = 0x3): 377Touchpad 3-or-4 Finger packet (APD = 0x3)::
369 378
370 b7 b6 b5 b4 b3 b2 b1 b0 379 b7 b6 b5 b4 b3 b2 b1 b0
371 byte 0: SWM SWR SWL 1 1 AX6 AX5 AX4 380 byte 0: SWM SWR SWL 1 1 AX6 AX5 AX4
diff --git a/Documentation/input/amijoy.txt b/Documentation/input/devices/amijoy.rst
index 7dc4f175943c..8df7b11cd98d 100644
--- a/Documentation/input/amijoy.txt
+++ b/Documentation/input/devices/amijoy.rst
@@ -1,67 +1,101 @@
1~~~~~~~~~~~~~~~~~~~~~~~~~
2Amiga joystick extensions
3~~~~~~~~~~~~~~~~~~~~~~~~~
4
5
1Amiga 4-joystick parport extension 6Amiga 4-joystick parport extension
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8
3Parallel port pins: 9Parallel port pins:
4 10
5 (2) - Up1 (6) - Up2 11
6 (3) - Down1 (7) - Down2 12===== ======== ==== ==========
7 (4) - Left1 (8) - Left2 13Pin Meaning Pin Meaning
8 (5) - Right1 (9) - Right2 14===== ======== ==== ==========
9(13) - Fire1 (11) - Fire2 15 2 Up1 6 Up2
10(18) - Gnd1 (18) - Gnd2 16 3 Down1 7 Down2
17 4 Left1 8 Left2
18 5 Right1 9 Right2
1913 Fire1 11 Fire2
2018 Gnd1 18 Gnd2
21===== ======== ==== ==========
11 22
12Amiga digital joystick pinout 23Amiga digital joystick pinout
13~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14(1) - Up 25
15(2) - Down 26=== ============
16(3) - Left 27Pin Meaning
17(4) - Right 28=== ============
18(5) - n/c 291 Up
19(6) - Fire button 302 Down
20(7) - +5V (50mA) 313 Left
21(8) - Gnd 324 Right
22(9) - Thumb button 335 n/c
346 Fire button
357 +5V (50mA)
368 Gnd
379 Thumb button
38=== ============
23 39
24Amiga mouse pinout 40Amiga mouse pinout
25~~~~~~~~~~~~~~~~~~ 41~~~~~~~~~~~~~~~~~~
26(1) - V-pulse 42
27(2) - H-pulse 43=== ============
28(3) - VQ-pulse 44Pin Meaning
29(4) - HQ-pulse 45=== ============
30(5) - Middle button 461 V-pulse
31(6) - Left button 472 H-pulse
32(7) - +5V (50mA) 483 VQ-pulse
33(8) - Gnd 494 HQ-pulse
34(9) - Right button 505 Middle button
516 Left button
527 +5V (50mA)
538 Gnd
549 Right button
55=== ============
35 56
36Amiga analog joystick pinout 57Amiga analog joystick pinout
37~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 58~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38(1) - Top button 59
39(2) - Top2 button 60=== ==============
40(3) - Trigger button 61Pin Meaning
41(4) - Thumb button 62=== ==============
42(5) - Analog X 631 Top button
43(6) - n/c 642 Top2 button
44(7) - +5V (50mA) 653 Trigger button
45(8) - Gnd 664 Thumb button
46(9) - Analog Y 675 Analog X
686 n/c
697 +5V (50mA)
708 Gnd
719 Analog Y
72=== ==============
47 73
48Amiga lightpen pinout 74Amiga lightpen pinout
49~~~~~~~~~~~~~~~~~~~~~ 75~~~~~~~~~~~~~~~~~~~~~
50(1) - n/c 76
51(2) - n/c 77=== =============
52(3) - n/c 78Pin Meaning
53(4) - n/c 79=== =============
54(5) - Touch button 801 n/c
55(6) - /Beamtrigger 812 n/c
56(7) - +5V (50mA) 823 n/c
57(8) - Gnd 834 n/c
58(9) - Stylus button 845 Touch button
856 /Beamtrigger
867 +5V (50mA)
878 Gnd
889 Stylus button
89=== =============
59 90
60------------------------------------------------------------------------------- 91-------------------------------------------------------------------------------
61 92
93======== === ==== ==== ====== ========================================
62NAME rev ADDR type chip Description 94NAME rev ADDR type chip Description
95======== === ==== ==== ====== ========================================
63JOY0DAT 00A R Denise Joystick-mouse 0 data (left vert, horiz) 96JOY0DAT 00A R Denise Joystick-mouse 0 data (left vert, horiz)
64JOY1DAT 00C R Denise Joystick-mouse 1 data (right vert,horiz) 97JOY1DAT 00C R Denise Joystick-mouse 1 data (right vert,horiz)
98======== === ==== ==== ====== ========================================
65 99
66 These addresses each read a 16 bit register. These in turn 100 These addresses each read a 16 bit register. These in turn
67 are loaded from the MDAT serial stream and are clocked in on 101 are loaded from the MDAT serial stream and are clocked in on
@@ -71,12 +105,17 @@ JOY1DAT 00C R Denise Joystick-mouse 1 data (right vert,horiz)
71 controller ports (8 total) plus 8 miscellaneous control bits 105 controller ports (8 total) plus 8 miscellaneous control bits
72 which are new for LISA and can be read in upper 8 bits of 106 which are new for LISA and can be read in upper 8 bits of
73 LISAID. 107 LISAID.
108
74 Register bits are as follows: 109 Register bits are as follows:
75 Mouse counter usage (pins 1,3 =Yclock, pins 2,4 =Xclock)
76 110
111 - Mouse counter usage (pins 1,3 =Yclock, pins 2,4 =Xclock)
112
113======== === === === === === === === === ====== === === === === === === ===
77 BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 114 BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
115======== === === === === === === === === ====== === === === === === === ===
78JOY0DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 116JOY0DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0
79JOY1DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 117JOY1DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0
118======== === === === === === === === === ====== === === === === === === ===
80 119
81 0=LEFT CONTROLLER PAIR, 1=RIGHT CONTROLLER PAIR. 120 0=LEFT CONTROLLER PAIR, 1=RIGHT CONTROLLER PAIR.
82 (4 counters total). The bit usage for both left and right 121 (4 counters total). The bit usage for both left and right
@@ -86,14 +125,21 @@ JOY1DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0
86 125
87 +-------------------+-----------------------------------------+ 126 +-------------------+-----------------------------------------+
88 | Serial | Bit Name | Description | 127 | Serial | Bit Name | Description |
89 +--------+----------+-----------------------------------------+ 128 +========+==========+=========================================+
90 | 0 | M0H | JOY0DAT Horizontal Clock | 129 | 0 | M0H | JOY0DAT Horizontal Clock |
130 +--------+----------+-----------------------------------------+
91 | 1 | M0HQ | JOY0DAT Horizontal Clock (quadrature) | 131 | 1 | M0HQ | JOY0DAT Horizontal Clock (quadrature) |
132 +--------+----------+-----------------------------------------+
92 | 2 | M0V | JOY0DAT Vertical Clock | 133 | 2 | M0V | JOY0DAT Vertical Clock |
134 +--------+----------+-----------------------------------------+
93 | 3 | M0VQ | JOY0DAT Vertical Clock (quadrature) | 135 | 3 | M0VQ | JOY0DAT Vertical Clock (quadrature) |
136 +--------+----------+-----------------------------------------+
94 | 4 | M1V | JOY1DAT Horizontal Clock | 137 | 4 | M1V | JOY1DAT Horizontal Clock |
138 +--------+----------+-----------------------------------------+
95 | 5 | M1VQ | JOY1DAT Horizontal Clock (quadrature) | 139 | 5 | M1VQ | JOY1DAT Horizontal Clock (quadrature) |
140 +--------+----------+-----------------------------------------+
96 | 6 | M1V | JOY1DAT Vertical Clock | 141 | 6 | M1V | JOY1DAT Vertical Clock |
142 +--------+----------+-----------------------------------------+
97 | 7 | M1VQ | JOY1DAT Vertical Clock (quadrature) | 143 | 7 | M1VQ | JOY1DAT Vertical Clock (quadrature) |
98 +--------+----------+-----------------------------------------+ 144 +--------+----------+-----------------------------------------+
99 145
@@ -104,46 +150,65 @@ JOY1DAT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0
104 150
105 +------------+------+---------------------------------+ 151 +------------+------+---------------------------------+
106 | Directions | Pin# | Counter bits | 152 | Directions | Pin# | Counter bits |
107 +------------+------+---------------------------------+ 153 +============+======+=================================+
108 | Forward | 1 | Y1 xor Y0 (BIT#09 xor BIT#08) | 154 | Forward | 1 | Y1 xor Y0 (BIT#09 xor BIT#08) |
155 +------------+------+---------------------------------+
109 | Left | 3 | Y1 | 156 | Left | 3 | Y1 |
157 +------------+------+---------------------------------+
110 | Back | 2 | X1 xor X0 (BIT#01 xor BIT#00) | 158 | Back | 2 | X1 xor X0 (BIT#01 xor BIT#00) |
159 +------------+------+---------------------------------+
111 | Right | 4 | X1 | 160 | Right | 4 | X1 |
112 +------------+------+---------------------------------+ 161 +------------+------+---------------------------------+
113 162
114------------------------------------------------------------------------------- 163-------------------------------------------------------------------------------
115 164
165======== === ==== ==== ====== =================================================
116NAME rev ADDR type chip Description 166NAME rev ADDR type chip Description
167======== === ==== ==== ====== =================================================
117JOYTEST 036 W Denise Write to all 4 joystick-mouse counters at once. 168JOYTEST 036 W Denise Write to all 4 joystick-mouse counters at once.
169======== === ==== ==== ====== =================================================
118 170
119 Mouse counter write test data: 171 Mouse counter write test data:
172
173========= === === === === === === === === ====== === === === === === === ===
120 BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 174 BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
175========= === === === === === === === === ====== === === === === === === ===
121 JOYxDAT Y7 Y6 Y5 Y4 Y3 Y2 xx xx X7 X6 X5 X4 X3 X2 xx xx 176 JOYxDAT Y7 Y6 Y5 Y4 Y3 Y2 xx xx X7 X6 X5 X4 X3 X2 xx xx
122 JOYxDAT Y7 Y6 Y5 Y4 Y3 Y2 xx xx X7 X6 X5 X4 X3 X2 xx xx 177 JOYxDAT Y7 Y6 Y5 Y4 Y3 Y2 xx xx X7 X6 X5 X4 X3 X2 xx xx
178========= === === === === === === === === ====== === === === === === === ===
123 179
124------------------------------------------------------------------------------- 180-------------------------------------------------------------------------------
125 181
182======= === ==== ==== ====== ========================================
126NAME rev ADDR type chip Description 183NAME rev ADDR type chip Description
184======= === ==== ==== ====== ========================================
127POT0DAT h 012 R Paula Pot counter data left pair (vert, horiz) 185POT0DAT h 012 R Paula Pot counter data left pair (vert, horiz)
128POT1DAT h 014 R Paula Pot counter data right pair (vert,horiz) 186POT1DAT h 014 R Paula Pot counter data right pair (vert,horiz)
187======= === ==== ==== ====== ========================================
129 188
130 These addresses each read a pair of 8 bit pot counters. 189 These addresses each read a pair of 8 bit pot counters.
131 (4 counters total). The bit assignment for both 190 (4 counters total). The bit assignment for both
132 addresses is shown below. The counters are stopped by signals 191 addresses is shown below. The counters are stopped by signals
133 from 2 controller connectors (left-right) with 2 pins each. 192 from 2 controller connectors (left-right) with 2 pins each.
134 193
194====== === === === === === === === === ====== === === === === === === ===
135 BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 195 BIT# 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
196====== === === === === === === === === ====== === === === === === === ===
136 RIGHT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 197 RIGHT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0
137 LEFT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0 198 LEFT Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 X7 X6 X5 X4 X3 X2 X1 X0
199====== === === === === === === === === ====== === === === === === === ===
138 200
139 +--------------------------+-------+ 201 +--------------------------+-------+
140 | CONNECTORS | PAULA | 202 | CONNECTORS | PAULA |
141 +-------+------+-----+-----+-------+ 203 +-------+------+-----+-----+-------+
142 | Loc. | Dir. | Sym | pin | pin | 204 | Loc. | Dir. | Sym | pin | pin |
143 +-------+------+-----+-----+-------+ 205 +=======+======+=====+=====+=======+
144 | RIGHT | Y | RX | 9 | 33 | 206 | RIGHT | Y | RX | 9 | 33 |
207 +-------+------+-----+-----+-------+
145 | RIGHT | X | RX | 5 | 32 | 208 | RIGHT | X | RX | 5 | 32 |
209 +-------+------+-----+-----+-------+
146 | LEFT | Y | LY | 9 | 36 | 210 | LEFT | Y | LY | 9 | 36 |
211 +-------+------+-----+-----+-------+
147 | LEFT | X | LX | 5 | 35 | 212 | LEFT | X | LX | 5 | 35 |
148 +-------+------+-----+-----+-------+ 213 +-------+------+-----+-----+-------+
149 214
@@ -155,30 +220,44 @@ POT1DAT h 014 R Paula Pot counter data right pair (vert,horiz)
155 220
156------------------------------------------------------------------------------- 221-------------------------------------------------------------------------------
157 222
223====== === ==== ==== ====== ================================================
158NAME rev ADDR type chip Description 224NAME rev ADDR type chip Description
159POTGO 034 W Paula Pot port (4 bit) bi-direction and data, and pot counter start. 225====== === ==== ==== ====== ================================================
226POTGO 034 W Paula Pot port (4 bit) bi-direction and data, and pot
227 counter start.
228====== === ==== ==== ====== ================================================
160 229
161------------------------------------------------------------------------------- 230-------------------------------------------------------------------------------
162 231
232====== === ==== ==== ====== ================================================
163NAME rev ADDR type chip Description 233NAME rev ADDR type chip Description
234====== === ==== ==== ====== ================================================
164POTINP 016 R Paula Pot pin data read 235POTINP 016 R Paula Pot pin data read
236====== === ==== ==== ====== ================================================
165 237
166 This register controls a 4 bit bi-direction I/O port 238 This register controls a 4 bit bi-direction I/O port
167 that shares the same 4 pins as the 4 pot counters above. 239 that shares the same 4 pins as the 4 pot counters above.
168 240
169 +-------+----------+---------------------------------------------+ 241 +-------+----------+---------------------------------------------+
170 | BIT# | FUNCTION | DESCRIPTION | 242 | BIT# | FUNCTION | DESCRIPTION |
171 +-------+----------+---------------------------------------------+ 243 +=======+==========+=============================================+
172 | 15 | OUTRY | Output enable for Paula pin 33 | 244 | 15 | OUTRY | Output enable for Paula pin 33 |
245 +-------+----------+---------------------------------------------+
173 | 14 | DATRY | I/O data Paula pin 33 | 246 | 14 | DATRY | I/O data Paula pin 33 |
247 +-------+----------+---------------------------------------------+
174 | 13 | OUTRX | Output enable for Paula pin 32 | 248 | 13 | OUTRX | Output enable for Paula pin 32 |
249 +-------+----------+---------------------------------------------+
175 | 12 | DATRX | I/O data Paula pin 32 | 250 | 12 | DATRX | I/O data Paula pin 32 |
251 +-------+----------+---------------------------------------------+
176 | 11 | OUTLY | Out put enable for Paula pin 36 | 252 | 11 | OUTLY | Out put enable for Paula pin 36 |
253 +-------+----------+---------------------------------------------+
177 | 10 | DATLY | I/O data Paula pin 36 | 254 | 10 | DATLY | I/O data Paula pin 36 |
255 +-------+----------+---------------------------------------------+
178 | 09 | OUTLX | Output enable for Paula pin 35 | 256 | 09 | OUTLX | Output enable for Paula pin 35 |
257 +-------+----------+---------------------------------------------+
179 | 08 | DATLX | I/O data Paula pin 35 | 258 | 08 | DATLX | I/O data Paula pin 35 |
259 +-------+----------+---------------------------------------------+
180 | 07-01 | X | Not used | 260 | 07-01 | X | Not used |
261 +-------+----------+---------------------------------------------+
181 | 00 | START | Start pots (dump capacitors,start counters) | 262 | 00 | START | Start pots (dump capacitors,start counters) |
182 +-------+----------+---------------------------------------------+ 263 +-------+----------+---------------------------------------------+
183
184-------------------------------------------------------------------------------
diff --git a/Documentation/input/appletouch.txt b/Documentation/input/devices/appletouch.rst
index b13de3f89108..c94470e66533 100644
--- a/Documentation/input/appletouch.txt
+++ b/Documentation/input/devices/appletouch.rst
@@ -1,12 +1,17 @@
1.. include:: <isonum.txt>
2
3----------------------------------
1Apple Touchpad Driver (appletouch) 4Apple Touchpad Driver (appletouch)
2---------------------------------- 5----------------------------------
3 Copyright (C) 2005 Stelian Pop <stelian@popies.net> 6
7:Copyright: |copy| 2005 Stelian Pop <stelian@popies.net>
4 8
5appletouch is a Linux kernel driver for the USB touchpad found on post 9appletouch is a Linux kernel driver for the USB touchpad found on post
6February 2005 and October 2005 Apple Aluminium Powerbooks. 10February 2005 and October 2005 Apple Aluminium Powerbooks.
7 11
8This driver is derived from Johannes Berg's appletrackpad driver[1], but it has 12This driver is derived from Johannes Berg's appletrackpad driver [#f1]_,
9been improved in some areas: 13but it has been improved in some areas:
14
10 * appletouch is a full kernel driver, no userspace program is necessary 15 * appletouch is a full kernel driver, no userspace program is necessary
11 * appletouch can be interfaced with the synaptics X11 driver, in order 16 * appletouch can be interfaced with the synaptics X11 driver, in order
12 to have touchpad acceleration, scrolling, etc. 17 to have touchpad acceleration, scrolling, etc.
@@ -16,8 +21,8 @@ Frank Arnold for further improvements, and Alex Harper for some additional
16information about the inner workings of the touchpad sensors. Michael 21information about the inner workings of the touchpad sensors. Michael
17Hanselmann added support for the October 2005 models. 22Hanselmann added support for the October 2005 models.
18 23
19Usage: 24Usage
20------ 25-----
21 26
22In order to use the touchpad in the basic mode, compile the driver and load 27In order to use the touchpad in the basic mode, compile the driver and load
23the module. A new input device will be detected and you will be able to read 28the module. A new input device will be detected and you will be able to read
@@ -27,13 +32,13 @@ In X11, you can configure the touchpad to use the synaptics X11 driver, which
27will give additional functionalities, like acceleration, scrolling, 2 finger 32will give additional functionalities, like acceleration, scrolling, 2 finger
28tap for middle button mouse emulation, 3 finger tap for right button mouse 33tap for middle button mouse emulation, 3 finger tap for right button mouse
29emulation, etc. In order to do this, make sure you're using a recent version of 34emulation, etc. In order to do this, make sure you're using a recent version of
30the synaptics driver (tested with 0.14.2, available from [2]), and configure a 35the synaptics driver (tested with 0.14.2, available from [#f2]_), and configure
31new input device in your X11 configuration file (take a look below for an 36a new input device in your X11 configuration file (take a look below for an
32example). For additional configuration, see the synaptics driver documentation. 37example). For additional configuration, see the synaptics driver documentation::
33 38
34 Section "InputDevice" 39 Section "InputDevice"
35 Identifier "Synaptics Touchpad" 40 Identifier "Synaptics Touchpad"
36 Driver "synaptics" 41 Driver "synaptics"
37 Option "SendCoreEvents" "true" 42 Option "SendCoreEvents" "true"
38 Option "Device" "/dev/input/mice" 43 Option "Device" "/dev/input/mice"
39 Option "Protocol" "auto-dev" 44 Option "Protocol" "auto-dev"
@@ -60,8 +65,8 @@ example). For additional configuration, see the synaptics driver documentation.
60 ... 65 ...
61 EndSection 66 EndSection
62 67
63Fuzz problems: 68Fuzz problems
64-------------- 69-------------
65 70
66The touchpad sensors are very sensitive to heat, and will generate a lot of 71The touchpad sensors are very sensitive to heat, and will generate a lot of
67noise when the temperature changes. This is especially true when you power-on 72noise when the temperature changes. This is especially true when you power-on
@@ -73,13 +78,17 @@ the driver.
73 78
74You can activate debugging using the 'debug' module parameter. A value of 0 79You can activate debugging using the 'debug' module parameter. A value of 0
75deactivates any debugging, 1 activates tracing of invalid samples, 2 activates 80deactivates any debugging, 1 activates tracing of invalid samples, 2 activates
76full tracing (each sample is being traced): 81full tracing (each sample is being traced)::
82
77 modprobe appletouch debug=1 83 modprobe appletouch debug=1
78 or 84
85or::
86
79 echo "1" > /sys/module/appletouch/parameters/debug 87 echo "1" > /sys/module/appletouch/parameters/debug
80 88
81Links:
82------
83 89
84[1]: http://johannes.sipsolutions.net/PowerBook/touchpad/ 90.. Links:
85[2]: http://web.archive.org/web/*/http://web.telia.com/~u89404340/touchpad/index.html 91
92.. [#f1] http://johannes.sipsolutions.net/PowerBook/touchpad/
93
94.. [#f2] `<http://web.archive.org/web/*/http://web.telia.com/~u89404340/touchpad/index.html>`_
diff --git a/Documentation/input/atarikbd.txt b/Documentation/input/devices/atarikbd.rst
index f3a3ba8847ba..745e7a1ff122 100644
--- a/Documentation/input/atarikbd.txt
+++ b/Documentation/input/devices/atarikbd.rst
@@ -1,7 +1,10 @@
1====================================
1Intelligent Keyboard (ikbd) Protocol 2Intelligent Keyboard (ikbd) Protocol
3====================================
2 4
3 5
41. Introduction 6Introduction
7============
5 8
6The Atari Corp. Intelligent Keyboard (ikbd) is a general purpose keyboard 9The Atari Corp. Intelligent Keyboard (ikbd) is a general purpose keyboard
7controller that is flexible enough that it can be used in a variety of 10controller that is flexible enough that it can be used in a variety of
@@ -18,7 +21,8 @@ different applications of the keyboard, joysticks, or mouse. Limited use of
18the controller is possible in applications in which only a unidirectional 21the controller is possible in applications in which only a unidirectional
19communications medium is available by carefully designing the default modes. 22communications medium is available by carefully designing the default modes.
20 23
213. Keyboard 24Keyboard
25========
22 26
23The keyboard always returns key make/break scan codes. The ikbd generates 27The keyboard always returns key make/break scan codes. The ikbd generates
24keyboard scan codes for each key press and release. The key scan make (key 28keyboard scan codes for each key press and release. The key scan make (key
@@ -28,19 +32,25 @@ exists in that position on a particular keyboard. The break code for each key
28is obtained by ORing 0x80 with the make code. 32is obtained by ORing 0x80 with the make code.
29 33
30The special codes 0xF6 through 0xFF are reserved for use as follows: 34The special codes 0xF6 through 0xFF are reserved for use as follows:
35
36=================== ====================================================
37 Code Command
38=================== ====================================================
31 0xF6 status report 39 0xF6 status report
32 0xF7 absolute mouse position record 40 0xF7 absolute mouse position record
33 0xF8-0xFB relative mouse position records (lsbs determined by 41 0xF8-0xFB relative mouse position records (lsbs determined by
34 mouse button states) 42 mouse button states)
35 0xFC time-of-day 43 0xFC time-of-day
36 0xFD joystick report (both sticks) 44 0xFD joystick report (both sticks)
37 0xFE joystick 0 event 45 0xFE joystick 0 event
38 0xFF joystick 1 event 46 0xFF joystick 1 event
47=================== ====================================================
39 48
40The two shift keys return different scan codes in this mode. The ENTER key 49The two shift keys return different scan codes in this mode. The ENTER key
41and the RETurn key are also distinct. 50and the RETurn key are also distinct.
42 51
434. Mouse 52Mouse
53=====
44 54
45The mouse port should be capable of supporting a mouse with resolution of 55The mouse port should be capable of supporting a mouse with resolution of
46approximately 200 counts (phase changes or 'clicks') per inch of travel. The 56approximately 200 counts (phase changes or 'clicks') per inch of travel. The
@@ -53,7 +63,8 @@ key equivalents.
53The mouse buttons can be treated as part of the mouse or as additional 63The mouse buttons can be treated as part of the mouse or as additional
54keyboard keys. 64keyboard keys.
55 65
564.1 Relative Position Reporting 66Relative Position Reporting
67---------------------------
57 68
58In relative position mode, the ikbd will return relative mouse position 69In relative position mode, the ikbd will return relative mouse position
59records whenever a mouse event occurs. A mouse event consists of a mouse 70records whenever a mouse event occurs. A mouse event consists of a mouse
@@ -67,7 +78,8 @@ been 'paused' ( the event will be stored until keyboard communications is
67resumed) (b) while any event is being transmitted. 78resumed) (b) while any event is being transmitted.
68 79
69The relative mouse position record is a three byte record of the form 80The relative mouse position record is a three byte record of the form
70(regardless of keyboard mode): 81(regardless of keyboard mode)::
82
71 %111110xy ; mouse position record flag 83 %111110xy ; mouse position record flag
72 ; where y is the right button state 84 ; where y is the right button state
73 ; and x is the left button state 85 ; and x is the left button state
@@ -81,13 +93,15 @@ If the accumulated motion before the report packet is generated exceeds the
81Note that the sign of the delta y reported is a function of the Y origin 93Note that the sign of the delta y reported is a function of the Y origin
82selected. 94selected.
83 95
844.2 Absolute Position reporting 96Absolute Position reporting
97---------------------------
85 98
86The ikbd can also maintain absolute mouse position. Commands exist for 99The ikbd can also maintain absolute mouse position. Commands exist for
87resetting the mouse position, setting X/Y scaling, and interrogating the 100resetting the mouse position, setting X/Y scaling, and interrogating the
88current mouse position. 101current mouse position.
89 102
904.3 Mouse Cursor Key Mode 103Mouse Cursor Key Mode
104---------------------
91 105
92The ikbd can translate mouse motion into the equivalent cursor keystrokes. 106The ikbd can translate mouse motion into the equivalent cursor keystrokes.
93The number of mouse clicks per keystroke is independently programmable in 107The number of mouse clicks per keystroke is independently programmable in
@@ -99,32 +113,38 @@ break code for the appropriate cursor key. The mouse buttons produce scan
99codes above those normally assigned for the largest envisioned keyboard (i.e. 113codes above those normally assigned for the largest envisioned keyboard (i.e.
100LEFT=0x74 & RIGHT=0x75). 114LEFT=0x74 & RIGHT=0x75).
101 115
1025. Joystick 116Joystick
117========
103 118
1045.1 Joystick Event Reporting 119Joystick Event Reporting
120------------------------
105 121
106In this mode, the ikbd generates a record whenever the joystick position is 122In this mode, the ikbd generates a record whenever the joystick position is
107changed (i.e. for each opening or closing of a joystick switch or trigger). 123changed (i.e. for each opening or closing of a joystick switch or trigger).
108 124
109The joystick event record is two bytes of the form: 125The joystick event record is two bytes of the form::
126
110 %1111111x ; Joystick event marker 127 %1111111x ; Joystick event marker
111 ; where x is Joystick 0 or 1 128 ; where x is Joystick 0 or 1
112 %x000yyyy ; where yyyy is the stick position 129 %x000yyyy ; where yyyy is the stick position
113 ; and x is the trigger 130 ; and x is the trigger
114 131
1155.2 Joystick Interrogation 132Joystick Interrogation
133----------------------
116 134
117The current state of the joystick ports may be interrogated at any time in 135The current state of the joystick ports may be interrogated at any time in
118this mode by sending an 'Interrogate Joystick' command to the ikbd. 136this mode by sending an 'Interrogate Joystick' command to the ikbd.
119 137
120The ikbd response to joystick interrogation is a three byte report of the form 138The ikbd response to joystick interrogation is a three byte report of the form::
139
121 0xFD ; joystick report header 140 0xFD ; joystick report header
122 %x000yyyy ; Joystick 0 141 %x000yyyy ; Joystick 0
123 %x000yyyy ; Joystick 1 142 %x000yyyy ; Joystick 1
124 ; where x is the trigger 143 ; where x is the trigger
125 ; and yyy is the stick position 144 ; and yyy is the stick position
126 145
1275.3 Joystick Monitoring 146Joystick Monitoring
147-------------------
128 148
129A mode is available that devotes nearly all of the keyboard communications 149A mode is available that devotes nearly all of the keyboard communications
130time to reporting the state of the joystick ports at a user specifiable rate. 150time to reporting the state of the joystick ports at a user specifiable rate.
@@ -132,7 +152,8 @@ It remains in this mode until reset or commanded into another mode. The PAUSE
132command in this mode not only stop the output but also temporarily stops 152command in this mode not only stop the output but also temporarily stops
133scanning the joysticks (samples are not queued). 153scanning the joysticks (samples are not queued).
134 154
1355.4 Fire Button Monitoring 155Fire Button Monitoring
156----------------------
136 157
137A mode is provided to permit monitoring a single input bit at a high rate. In 158A mode is provided to permit monitoring a single input bit at a high rate. In
138this mode the ikbd monitors the state of the Joystick 1 fire button at the 159this mode the ikbd monitors the state of the Joystick 1 fire button at the
@@ -142,7 +163,8 @@ until reset or commanded into another mode. The PAUSE command in this mode not
142only stops the output but also temporarily stops scanning the button (samples 163only stops the output but also temporarily stops scanning the button (samples
143are not queued). 164are not queued).
144 165
1455.5 Joystick Key Code Mode 166Joystick Key Code Mode
167----------------------
146 168
147The ikbd may be commanded to translate the use of either joystick into the 169The ikbd may be commanded to translate the use of either joystick into the
148equivalent cursor control keystroke(s). The ikbd provides a single breakpoint 170equivalent cursor control keystroke(s). The ikbd provides a single breakpoint
@@ -152,18 +174,21 @@ for the appropriate cursor motion keys. The trigger or fire buttons of the
152joysticks produce pseudo key scan codes above those used by the largest key 174joysticks produce pseudo key scan codes above those used by the largest key
153matrix envisioned (i.e. JOYSTICK0=0x74, JOYSTICK1=0x75). 175matrix envisioned (i.e. JOYSTICK0=0x74, JOYSTICK1=0x75).
154 176
1556. Time-of-Day Clock 177Time-of-Day Clock
178=================
156 179
157The ikbd also maintains a time-of-day clock for the system. Commands are 180The ikbd also maintains a time-of-day clock for the system. Commands are
158available to set and interrogate the timer-of-day clock. Time-keeping is 181available to set and interrogate the timer-of-day clock. Time-keeping is
159maintained down to a resolution of one second. 182maintained down to a resolution of one second.
160 183
1617. Status Inquiries 184Status Inquiries
185================
162 186
163The current state of ikbd modes and parameters may be found by sending status 187The current state of ikbd modes and parameters may be found by sending status
164inquiry commands that correspond to the ikbd set commands. 188inquiry commands that correspond to the ikbd set commands.
165 189
1668. Power-Up Mode 190Power-Up Mode
191=============
167 192
168The keyboard controller will perform a simple self-test on power-up to detect 193The keyboard controller will perform a simple self-test on power-up to detect
169major controller faults (ROM checksum and RAM test) and such things as stuck 194major controller faults (ROM checksum and RAM test) and such things as stuck
@@ -183,13 +208,17 @@ both buttons are logically connected to it. If a mouse disable command is
183received while port 0 is presumed to be a mouse, the button is logically 208received while port 0 is presumed to be a mouse, the button is logically
184assigned to Joystick1 (until the mouse is reenabled by another mouse command). 209assigned to Joystick1 (until the mouse is reenabled by another mouse command).
185 210
1869. ikbd Command Set 211ikbd Command Set
212================
187 213
188This section contains a list of commands that can be sent to the ikbd. Command 214This section contains a list of commands that can be sent to the ikbd. Command
189codes (such as 0x00) which are not specified should perform no operation 215codes (such as 0x00) which are not specified should perform no operation
190(NOPs). 216(NOPs).
191 217
1929.1 RESET 218RESET
219-----
220
221::
193 222
194 0x80 223 0x80
195 0x01 224 0x01
@@ -208,7 +237,10 @@ ikbd will then scan the key matrix for any stuck (closed) keys. Any keys found
208closed will cause the break scan code to be generated (the break code arriving 237closed will cause the break scan code to be generated (the break code arriving
209without being preceded by the make code is a flag for a key matrix error). 238without being preceded by the make code is a flag for a key matrix error).
210 239
2119.2. SET MOUSE BUTTON ACTION 240SET MOUSE BUTTON ACTION
241-----------------------
242
243::
212 244
213 0x07 245 0x07
214 %00000mss ; mouse button action 246 %00000mss ; mouse button action
@@ -217,14 +249,17 @@ without being preceded by the make code is a flag for a key matrix error).
217 ; position report 249 ; position report
218 ; where y=1, mouse key press causes absolute report 250 ; where y=1, mouse key press causes absolute report
219 ; and x=1, mouse key release causes absolute report 251 ; and x=1, mouse key release causes absolute report
220 ; mss=100, mouse buttons act like keys 252 ; mss=100, mouse buttons act like keys
221 253
222This command sets how the ikbd should treat the buttons on the mouse. The 254This command sets how the ikbd should treat the buttons on the mouse. The
223default mouse button action mode is %00000000, the buttons are treated as part 255default mouse button action mode is %00000000, the buttons are treated as part
224of the mouse logically. 256of the mouse logically.
225When buttons act like keys, LEFT=0x74 & RIGHT=0x75. 257When buttons act like keys, LEFT=0x74 & RIGHT=0x75.
226 258
2279.3 SET RELATIVE MOUSE POSITION REPORTING 259SET RELATIVE MOUSE POSITION REPORTING
260-------------------------------------
261
262::
228 263
229 0x08 264 0x08
230 265
@@ -235,14 +270,17 @@ key mode, mouse position reports may also be generated when either mouse
235button is pressed or released. Otherwise the mouse buttons behave as if they 270button is pressed or released. Otherwise the mouse buttons behave as if they
236were keyboard keys. 271were keyboard keys.
237 272
2389.4 SET ABSOLUTE MOUSE POSITIONING 273SET ABSOLUTE MOUSE POSITIONING
274------------------------------
275
276::
239 277
240 0x09 278 0x09
241 XMSB ; X maximum (in scaled mouse clicks) 279 XMSB ; X maximum (in scaled mouse clicks)
242 XLSB 280 XLSB
243 YMSB ; Y maximum (in scaled mouse clicks) 281 YMSB ; Y maximum (in scaled mouse clicks)
244 YLSB 282 YLSB
245 283
246Set absolute mouse position maintenance. Resets the ikbd maintained X and Y 284Set absolute mouse position maintenance. Resets the ikbd maintained X and Y
247coordinates. 285coordinates.
248In this mode, the value of the internally maintained coordinates does NOT wrap 286In this mode, the value of the internally maintained coordinates does NOT wrap
@@ -250,7 +288,10 @@ between 0 and large positive numbers. Excess motion below 0 is ignored. The
250command sets the maximum positive value that can be attained in the scaled 288command sets the maximum positive value that can be attained in the scaled
251coordinate system. Motion beyond that value is also ignored. 289coordinate system. Motion beyond that value is also ignored.
252 290
2539.5 SET MOUSE KEYCODE MOSE 291SET MOUSE KEYCODE MOSE
292----------------------
293
294::
254 295
255 0x0A 296 0x0A
256 deltax ; distance in X clicks to return (LEFT) or (RIGHT) 297 deltax ; distance in X clicks to return (LEFT) or (RIGHT)
@@ -263,7 +304,10 @@ either axis. When the keyboard is in key scan code mode, mouse motion will
263cause the make code immediately followed by the break code. Note that this 304cause the make code immediately followed by the break code. Note that this
264command is not affected by the mouse motion origin. 305command is not affected by the mouse motion origin.
265 306
2669..6 SET MOUSE THRESHOLD 307SET MOUSE THRESHOLD
308-------------------
309
310::
267 311
268 0x0B 312 0x0B
269 X ; x threshold in mouse ticks (positive integers) 313 X ; x threshold in mouse ticks (positive integers)
@@ -274,7 +318,10 @@ it does NOT affect the resolution of the data returned to the host. This
274command is valid only in RELATIVE MOUSE POSITIONING mode. The thresholds 318command is valid only in RELATIVE MOUSE POSITIONING mode. The thresholds
275default to 1 at RESET (or power-up). 319default to 1 at RESET (or power-up).
276 320
2779.7 SET MOUSE SCALE 321SET MOUSE SCALE
322---------------
323
324::
278 325
279 0x0C 326 0x0C
280 X ; horizontal mouse ticks per internal X 327 X ; horizontal mouse ticks per internal X
@@ -288,7 +335,10 @@ information is available only by interrogating the ikbd in the ABSOLUTE MOUSE
288POSITIONING mode unless the ikbd has been commanded to report on button press 335POSITIONING mode unless the ikbd has been commanded to report on button press
289or release (see SET MOSE BUTTON ACTION). 336or release (see SET MOSE BUTTON ACTION).
290 337
2919.8 INTERROGATE MOUSE POSITION 338INTERROGATE MOUSE POSITION
339--------------------------
340
341::
292 342
293 0x0D 343 0x0D
294 Returns: 344 Returns:
@@ -306,7 +356,10 @@ or release (see SET MOSE BUTTON ACTION).
306The INTERROGATE MOUSE POSITION command is valid when in the ABSOLUTE MOUSE 356The INTERROGATE MOUSE POSITION command is valid when in the ABSOLUTE MOUSE
307POSITIONING mode, regardless of the setting of the MOUSE BUTTON ACTION. 357POSITIONING mode, regardless of the setting of the MOUSE BUTTON ACTION.
308 358
3099.9 LOAD MOUSE POSITION 359LOAD MOUSE POSITION
360-------------------
361
362::
310 363
311 0x0E 364 0x0E
312 0x00 ; filler 365 0x00 ; filler
@@ -318,7 +371,10 @@ POSITIONING mode, regardless of the setting of the MOUSE BUTTON ACTION.
318This command allows the user to preset the internally maintained absolute 371This command allows the user to preset the internally maintained absolute
319mouse position. 372mouse position.
320 373
3219.10 SET Y=0 AT BOTTOM 374SET Y=0 AT BOTTOM
375-----------------
376
377::
322 378
323 0x0F 379 0x0F
324 380
@@ -327,7 +383,10 @@ logical coordinate system internal to the ikbd for all relative or absolute
327mouse motion. This causes mouse motion toward the user to be negative in sign 383mouse motion. This causes mouse motion toward the user to be negative in sign
328and away from the user to be positive. 384and away from the user to be positive.
329 385
3309.11 SET Y=0 AT TOP 386SET Y=0 AT TOP
387--------------
388
389::
331 390
332 0x10 391 0x10
333 392
@@ -336,7 +395,10 @@ system within the ikbd for all relative or absolute mouse motion. (DEFAULT)
336This causes mouse motion toward the user to be positive in sign and away from 395This causes mouse motion toward the user to be positive in sign and away from
337the user to be negative. 396the user to be negative.
338 397
3399.12 RESUME 398RESUME
399------
400
401::
340 402
341 0x11 403 0x11
342 404
@@ -345,7 +407,10 @@ its output has been paused also causes an implicit RESUME this command can be
345thought of as a NO OPERATION command. If this command is received by the ikbd 407thought of as a NO OPERATION command. If this command is received by the ikbd
346and it is not PAUSED, it is simply ignored. 408and it is not PAUSED, it is simply ignored.
347 409
3489.13 DISABLE MOUSE 410DISABLE MOUSE
411-------------
412
413::
349 414
350 0x12 415 0x12
351 416
@@ -356,7 +421,10 @@ ABSOLUTE MOUSE POSITIONING, and SET MOUSE KEYCODE MODE. )
356N.B. If the mouse buttons have been commanded to act like keyboard keys, this 421N.B. If the mouse buttons have been commanded to act like keyboard keys, this
357command DOES affect their actions. 422command DOES affect their actions.
358 423
3599.14 PAUSE OUTPUT 424PAUSE OUTPUT
425------------
426
427::
360 428
361 0x13 429 0x13
362 430
@@ -381,21 +449,30 @@ When the ikbd is in either the JOYSTICK MONITORING mode or the FIRE BUTTON
381MONITORING mode, the PAUSE OUTPUT command also temporarily stops the 449MONITORING mode, the PAUSE OUTPUT command also temporarily stops the
382monitoring process (i.e. the samples are not enqueued for transmission). 450monitoring process (i.e. the samples are not enqueued for transmission).
383 451
3840.15 SET JOYSTICK EVENT REPORTING 452SET JOYSTICK EVENT REPORTING
453----------------------------
454
455::
385 456
386 0x14 457 0x14
387 458
388Enter JOYSTICK EVENT REPORTING mode (DEFAULT). Each opening or closure of a 459Enter JOYSTICK EVENT REPORTING mode (DEFAULT). Each opening or closure of a
389joystick switch or trigger causes a joystick event record to be generated. 460joystick switch or trigger causes a joystick event record to be generated.
390 461
3919.16 SET JOYSTICK INTERROGATION MODE 462SET JOYSTICK INTERROGATION MODE
463-------------------------------
464
465::
392 466
393 0x15 467 0x15
394 468
395Disables JOYSTICK EVENT REPORTING. Host must send individual JOYSTICK 469Disables JOYSTICK EVENT REPORTING. Host must send individual JOYSTICK
396INTERROGATE commands to sense joystick state. 470INTERROGATE commands to sense joystick state.
397 471
3989.17 JOYSTICK INTERROGATE 472JOYSTICK INTERROGATE
473--------------------
474
475::
399 476
400 0x16 477 0x16
401 478
@@ -403,7 +480,10 @@ Return a record indicating the current state of the joysticks. This command
403is valid in either the JOYSTICK EVENT REPORTING mode or the JOYSTICK 480is valid in either the JOYSTICK EVENT REPORTING mode or the JOYSTICK
404INTERROGATION MODE. 481INTERROGATION MODE.
405 482
4069.18 SET JOYSTICK MONITORING 483SET JOYSTICK MONITORING
484-----------------------
485
486::
407 487
408 0x17 488 0x17
409 rate ; time between samples in hundredths of a second 489 rate ; time between samples in hundredths of a second
@@ -419,7 +499,10 @@ between joystick samples.
419N.B. The user should not set the rate higher than the serial communications 499N.B. The user should not set the rate higher than the serial communications
420channel will allow the 2 bytes packets to be transmitted. 500channel will allow the 2 bytes packets to be transmitted.
421 501
4229.19 SET FIRE BUTTON MONITORING 502SET FIRE BUTTON MONITORING
503--------------------------
504
505::
423 506
424 0x18 507 0x18
425 Returns: (as long as in mode) 508 Returns: (as long as in mode)
@@ -432,7 +515,10 @@ is scanned at a rate that causes 8 samples to be made in the time it takes for
432the previous byte to be sent to the host (i.e. scan rate = 8/10 * baud rate). 515the previous byte to be sent to the host (i.e. scan rate = 8/10 * baud rate).
433The sample interval should be as constant as possible. 516The sample interval should be as constant as possible.
434 517
4359.20 SET JOYSTICK KEYCODE MODE 518SET JOYSTICK KEYCODE MODE
519-------------------------
520
521::
436 522
437 0x19 523 0x19
438 RX ; length of time (in tenths of seconds) until 524 RX ; length of time (in tenths of seconds) until
@@ -462,7 +548,10 @@ Note that by setting RX and/or Ry to zero, the velocity feature can be
462disabled. The values of TX and TY then become meaningless, and the generation 548disabled. The values of TX and TY then become meaningless, and the generation
463of cursor 'keystrokes' is set by VX and VY. 549of cursor 'keystrokes' is set by VX and VY.
464 550
4659.21 DISABLE JOYSTICKS 551DISABLE JOYSTICKS
552-----------------
553
554::
466 555
467 0x1A 556 0x1A
468 557
@@ -472,7 +561,10 @@ joystick mode commands are SET JOYSTICK EVENT REPORTING, SET JOYSTICK
472INTERROGATION MODE, SET JOYSTICK MONITORING, SET FIRE BUTTON MONITORING, and 561INTERROGATION MODE, SET JOYSTICK MONITORING, SET FIRE BUTTON MONITORING, and
473SET JOYSTICK KEYCODE MODE.) 562SET JOYSTICK KEYCODE MODE.)
474 563
4759.22 TIME-OF-DAY CLOCK SET 564TIME-OF-DAY CLOCK SET
565---------------------
566
567::
476 568
477 0x1B 569 0x1B
478 YY ; year (2 least significant digits) 570 YY ; year (2 least significant digits)
@@ -487,7 +579,10 @@ Any digit that is not a valid BCD digit should be treated as a 'don't care'
487and not alter that particular field of the date or time. This permits setting 579and not alter that particular field of the date or time. This permits setting
488only some subfields of the time-of-day clock. 580only some subfields of the time-of-day clock.
489 581
4909.23 INTERROGATE TIME-OF-DAT CLOCK 582INTERROGATE TIME-OF-DAT CLOCK
583-----------------------------
584
585::
491 586
492 0x1C 587 0x1C
493 Returns: 588 Returns:
@@ -501,7 +596,10 @@ only some subfields of the time-of-day clock.
501 596
502 All time-of-day is sent in packed BCD format. 597 All time-of-day is sent in packed BCD format.
503 598
5049.24 MEMORY LOAD 599MEMORY LOAD
600-----------
601
602::
505 603
506 0x20 604 0x20
507 ADRMSB ; address in controller 605 ADRMSB ; address in controller
@@ -512,7 +610,10 @@ only some subfields of the time-of-day clock.
512This command permits the host to load arbitrary values into the ikbd 610This command permits the host to load arbitrary values into the ikbd
513controller memory. The time between data bytes must be less than 20ms. 611controller memory. The time between data bytes must be less than 20ms.
514 612
5159.25 MEMORY READ 613MEMORY READ
614-----------
615
616::
516 617
517 0x21 618 0x21
518 ADRMSB ; address in controller 619 ADRMSB ; address in controller
@@ -524,7 +625,10 @@ controller memory. The time between data bytes must be less than 20ms.
524 625
525This command permits the host to read from the ikbd controller memory. 626This command permits the host to read from the ikbd controller memory.
526 627
5279.26 CONTROLLER EXECUTE 628CONTROLLER EXECUTE
629------------------
630
631::
528 632
529 0x22 633 0x22
530 ADRMSB ; address of subroutine in 634 ADRMSB ; address of subroutine in
@@ -533,8 +637,11 @@ This command permits the host to read from the ikbd controller memory.
533This command allows the host to command the execution of a subroutine in the 637This command allows the host to command the execution of a subroutine in the
534ikbd controller memory. 638ikbd controller memory.
535 639
5369.27 STATUS INQUIRIES 640STATUS INQUIRIES
537 641----------------
642
643::
644
538 Status commands are formed by inclusively ORing 0x80 with the 645 Status commands are formed by inclusively ORing 0x80 with the
539 relevant SET command. 646 relevant SET command.
540 647
@@ -568,7 +675,7 @@ off the status report header byte) and later send them back as commands to
568ikbd to restore its state. The 0 pad bytes will be treated as NOPs by the 675ikbd to restore its state. The 0 pad bytes will be treated as NOPs by the
569ikbd. 676ikbd.
570 677
571 Valid STATUS INQUIRY commands are: 678 Valid STATUS INQUIRY commands are::
572 679
573 0x87 mouse button action 680 0x87 mouse button action
574 0x88 mouse mode 681 0x88 mouse mode
@@ -595,14 +702,17 @@ STATUS INQUIRY commands are not valid if the ikbd is in JOYSTICK MONITORING
595mode or FIRE BUTTON MONITORING mode. 702mode or FIRE BUTTON MONITORING mode.
596 703
597 704
59810. SCAN CODES 705SCAN CODES
706==========
599 707
600The key scan codes returned by the ikbd are chosen to simplify the 708The key scan codes returned by the ikbd are chosen to simplify the
601implementation of GSX. 709implementation of GSX.
602 710
603GSX Standard Keyboard Mapping. 711GSX Standard Keyboard Mapping
604 712
713======= ============
605Hex Keytop 714Hex Keytop
715======= ============
60601 Esc 71601 Esc
60702 1 71702 1
60803 2 71803 2
@@ -614,8 +724,8 @@ Hex Keytop
61409 8 72409 8
6150A 9 7250A 9
6160B 0 7260B 0
6170C - 7270C \-
6180D == 7280D \=
6190E BS 7290E BS
6200F TAB 7300F TAB
62110 Q 73110 Q
@@ -643,9 +753,9 @@ Hex Keytop
64326 L 75326 L
64427 ; 75427 ;
64528 ' 75528 '
64629 ` 75629 \`
6472A (LEFT) SHIFT 7572A (LEFT) SHIFT
6482B \ 7582B \\
6492C Z 7592C Z
6502D X 7602D X
6512E C 7612E C
@@ -707,3 +817,4 @@ Hex Keytop
70770 KEYPAD 0 81770 KEYPAD 0
70871 KEYPAD . 81871 KEYPAD .
70972 KEYPAD ENTER 81972 KEYPAD ENTER
820======= ============
diff --git a/Documentation/input/bcm5974.txt b/Documentation/input/devices/bcm5974.rst
index 74d3876d6f34..4aca199b0aa6 100644
--- a/Documentation/input/bcm5974.txt
+++ b/Documentation/input/devices/bcm5974.rst
@@ -1,19 +1,25 @@
1.. include:: <isonum.txt>
2
3------------------------
1BCM5974 Driver (bcm5974) 4BCM5974 Driver (bcm5974)
2------------------------ 5------------------------
3 Copyright (C) 2008-2009 Henrik Rydberg <rydberg@euromail.se> 6
7:Copyright: |copy| 2008-2009 Henrik Rydberg <rydberg@euromail.se>
4 8
5The USB initialization and package decoding was made by Scott Shawcroft as 9The USB initialization and package decoding was made by Scott Shawcroft as
6part of the touchd user-space driver project: 10part of the touchd user-space driver project:
7 Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com) 11
12:Copyright: |copy| 2008 Scott Shawcroft (scott.shawcroft@gmail.com)
8 13
9The BCM5974 driver is based on the appletouch driver: 14The BCM5974 driver is based on the appletouch driver:
10 Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) 15
11 Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net) 16:Copyright: |copy| 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
12 Copyright (C) 2005 Stelian Pop (stelian@popies.net) 17:Copyright: |copy| 2005 Johannes Berg (johannes@sipsolutions.net)
13 Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) 18:Copyright: |copy| 2005 Stelian Pop (stelian@popies.net)
14 Copyright (C) 2005 Peter Osterlund (petero2@telia.com) 19:Copyright: |copy| 2005 Frank Arnold (frank@scirocco-5v-turbo.de)
15 Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) 20:Copyright: |copy| 2005 Peter Osterlund (petero2@telia.com)
16 Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch) 21:Copyright: |copy| 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
22:Copyright: |copy| 2006 Nicolas Boichat (nicolas@boichat.ch)
17 23
18This driver adds support for the multi-touch trackpad on the new Apple 24This driver adds support for the multi-touch trackpad on the new Apple
19Macbook Air and Macbook Pro laptops. It replaces the appletouch driver on 25Macbook Air and Macbook Pro laptops. It replaces the appletouch driver on
@@ -44,22 +50,21 @@ Debug output
44 50
45To ease the development for new hardware version, verbose packet output can 51To ease the development for new hardware version, verbose packet output can
46be switched on with the debug kernel module parameter. The range [1-9] 52be switched on with the debug kernel module parameter. The range [1-9]
47yields different levels of verbosity. Example (as root): 53yields different levels of verbosity. Example (as root)::
48 54
49echo -n 9 > /sys/module/bcm5974/parameters/debug 55 echo -n 9 > /sys/module/bcm5974/parameters/debug
50 56
51tail -f /var/log/debug 57 tail -f /var/log/debug
52 58
53echo -n 0 > /sys/module/bcm5974/parameters/debug 59 echo -n 0 > /sys/module/bcm5974/parameters/debug
54 60
55Trivia 61Trivia
56------ 62------
57 63
58The driver was developed at the ubuntu forums in June 2008 [1], and now has 64The driver was developed at the ubuntu forums in June 2008 [#f1]_, and now has
59a more permanent home at bitmath.org [2]. 65a more permanent home at bitmath.org [#f2]_.
60 66
61Links 67.. Links
62-----
63 68
64[1] http://ubuntuforums.org/showthread.php?t=840040 69.. [#f1] http://ubuntuforums.org/showthread.php?t=840040
65[2] http://bitmath.org/code/ 70.. [#f2] http://bitmath.org/code/
diff --git a/Documentation/input/cma3000_d0x.txt b/Documentation/input/devices/cma3000_d0x.rst
index 29d088db4afd..8bc8e61487b0 100644
--- a/Documentation/input/cma3000_d0x.txt
+++ b/Documentation/input/devices/cma3000_d0x.rst
@@ -1,30 +1,37 @@
1Kernel driver for CMA3000-D0x 1CMA3000-D0x Accelerometer
2============================ 2=========================
3 3
4Supported chips: 4Supported chips:
5* VTI CMA3000-D0x 5* VTI CMA3000-D0x
6
6Datasheet: 7Datasheet:
7 CMA3000-D0X Product Family Specification 8281000A.02.pdf 8 CMA3000-D0X Product Family Specification 8281000A.02.pdf
8 <http://www.vti.fi/en/> 9 <http://www.vti.fi/en/>
9 10
10Author: Hemanth V <hemanthv@ti.com> 11:Author: Hemanth V <hemanthv@ti.com>
11 12
12 13
13Description 14Description
14----------- 15-----------
16
15CMA3000 Tri-axis accelerometer supports Motion detect, Measurement and 17CMA3000 Tri-axis accelerometer supports Motion detect, Measurement and
16Free fall modes. 18Free fall modes.
17 19
18Motion Detect Mode: Its the low power mode where interrupts are generated only 20Motion Detect Mode:
19when motion exceeds the defined thresholds. 21 Its the low power mode where interrupts are generated only
22 when motion exceeds the defined thresholds.
20 23
21Measurement Mode: This mode is used to read the acceleration data on X,Y,Z 24Measurement Mode:
22axis and supports 400, 100, 40 Hz sample frequency. 25 This mode is used to read the acceleration data on X,Y,Z
26 axis and supports 400, 100, 40 Hz sample frequency.
23 27
24Free fall Mode: This mode is intended to save system resources. 28Free fall Mode:
29 This mode is intended to save system resources.
25 30
26Threshold values: Chip supports defining threshold values for above modes 31Threshold values:
27which includes time and g value. Refer product specifications for more details. 32 Chip supports defining threshold values for above modes
33 which includes time and g value. Refer product specifications for
34 more details.
28 35
29CMA3000 chip supports mutually exclusive I2C and SPI interfaces for 36CMA3000 chip supports mutually exclusive I2C and SPI interfaces for
30communication, currently the driver supports I2C based communication only. 37communication, currently the driver supports I2C based communication only.
@@ -38,28 +45,40 @@ Platform data need to be configured for initial default values.
38 45
39Platform Data 46Platform Data
40------------- 47-------------
41fuzz_x: Noise on X Axis
42 48
43fuzz_y: Noise on Y Axis 49fuzz_x:
50 Noise on X Axis
44 51
45fuzz_z: Noise on Z Axis 52fuzz_y:
53 Noise on Y Axis
46 54
47g_range: G range in milli g i.e 2000 or 8000 55fuzz_z:
56 Noise on Z Axis
48 57
49mode: Default Operating mode 58g_range:
59 G range in milli g i.e 2000 or 8000
50 60
51mdthr: Motion detect g range threshold value 61mode:
62 Default Operating mode
63
64mdthr:
65 Motion detect g range threshold value
52 66
53mdfftmr: Motion detect and free fall time threshold value 67mdfftmr:
68 Motion detect and free fall time threshold value
54 69
55ffthr: Free fall g range threshold value 70ffthr:
71 Free fall g range threshold value
56 72
57Input Interface 73Input Interface
58-------------- 74---------------
75
59Input driver version is 1.0.0 76Input driver version is 1.0.0
60Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0 77Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
61Input device name: "cma3000-accelerometer" 78Input device name: "cma3000-accelerometer"
62Supported events: 79
80Supported events::
81
63 Event type 0 (Sync) 82 Event type 0 (Sync)
64 Event type 3 (Absolute) 83 Event type 3 (Absolute)
65 Event code 0 (X) 84 Event code 0 (X)
@@ -87,7 +106,8 @@ Supported events:
87Register/Platform parameters Description 106Register/Platform parameters Description
88---------------------------------------- 107----------------------------------------
89 108
90mode: 109mode::
110
91 0: power down mode 111 0: power down mode
92 1: 100 Hz Measurement mode 112 1: 100 Hz Measurement mode
93 2: 400 Hz Measurement mode 113 2: 400 Hz Measurement mode
@@ -97,19 +117,23 @@ mode:
97 6: 40 Hz Free fall mode 117 6: 40 Hz Free fall mode
98 7: Power off mode 118 7: Power off mode
99 119
100grange: 120grange::
121
101 2000: 2000 mg or 2G Range 122 2000: 2000 mg or 2G Range
102 8000: 8000 mg or 8G Range 123 8000: 8000 mg or 8G Range
103 124
104mdthr: 125mdthr::
126
105 X: X * 71mg (8G Range) 127 X: X * 71mg (8G Range)
106 X: X * 18mg (2G Range) 128 X: X * 18mg (2G Range)
107 129
108mdfftmr: 130mdfftmr::
131
109 X: (X & 0x70) * 100 ms (MDTMR) 132 X: (X & 0x70) * 100 ms (MDTMR)
110 (X & 0x0F) * 2.5 ms (FFTMR 400 Hz) 133 (X & 0x0F) * 2.5 ms (FFTMR 400 Hz)
111 (X & 0x0F) * 10 ms (FFTMR 100 Hz) 134 (X & 0x0F) * 10 ms (FFTMR 100 Hz)
112 135
113ffthr: 136ffthr::
137
114 X: (X >> 2) * 18mg (2G Range) 138 X: (X >> 2) * 18mg (2G Range)
115 X: (X & 0x0F) * 71 mg (8G Range) 139 X: (X & 0x0F) * 71 mg (8G Range)
diff --git a/Documentation/input/cs461x.txt b/Documentation/input/devices/cs461x.rst
index 202e9dbacec3..b1e6d508ad26 100644
--- a/Documentation/input/cs461x.txt
+++ b/Documentation/input/devices/cs461x.rst
@@ -1,36 +1,34 @@
1Preface. 1Crystal SoundFusion CS4610/CS4612/CS461 joystick
2================================================
2 3
3This is a new low-level driver to support analog joystick attached to 4This is a new low-level driver to support analog joystick attached to
4Crystal SoundFusion CS4610/CS4612/CS4615. This code is based upon 5Crystal SoundFusion CS4610/CS4612/CS4615. This code is based upon
5Vortex/Solo drivers as an example of decoration style, and ALSA 6Vortex/Solo drivers as an example of decoration style, and ALSA
60.5.8a kernel drivers as an chipset documentation and samples. 70.5.8a kernel drivers as an chipset documentation and samples.
7 8
8This version does not have cooked mode support; the basic code 9This version does not have cooked mode support; the basic code
9is present here, but have not tested completely. The button analysis 10is present here, but have not tested completely. The button analysis
10is completed in this mode, but the axis movement is not. 11is completed in this mode, but the axis movement is not.
11 12
12Raw mode works fine with analog joystick front-end driver and cs461x 13Raw mode works fine with analog joystick front-end driver and cs461x
13driver as a backend. I've tested this driver with CS4610, 4-axis and 14driver as a backend. I've tested this driver with CS4610, 4-axis and
144-button joystick; I mean the jstest utility. Also I've tried to 154-button joystick; I mean the jstest utility. Also I've tried to
15play in xracer game using joystick, and the result is better than 16play in xracer game using joystick, and the result is better than
16keyboard only mode. 17keyboard only mode.
17 18
18The sensitivity and calibrate quality have not been tested; the two 19The sensitivity and calibrate quality have not been tested; the two
19reasons are performed: the same hardware cannot work under Win95 (blue 20reasons are performed: the same hardware cannot work under Win95 (blue
20screen in VJOYD); I have no documentation on my chip; and the existing 21screen in VJOYD); I have no documentation on my chip; and the existing
21behavior in my case was not raised the requirement of joystick calibration. 22behavior in my case was not raised the requirement of joystick calibration.
22So the driver have no code to perform hardware related calibration. 23So the driver have no code to perform hardware related calibration.
23 24
24The patch contains minor changes of Config.in and Makefile files. All
25needed code have been moved to one separate file cs461x.c like ns558.c
26This driver have the basic support for PCI devices only; there is no 25This driver have the basic support for PCI devices only; there is no
27ISA or PnP ISA cards supported. AFAIK the ns558 have support for Crystal 26ISA or PnP ISA cards supported.
28ISA and PnP ISA series.
29 27
30The driver works with ALSA drivers simultaneously. For example, the xracer 28The driver works with ALSA drivers simultaneously. For example, the xracer
31uses joystick as input device and PCM device as sound output in one time. 29uses joystick as input device and PCM device as sound output in one time.
32There are no sound or input collisions detected. The source code have 30There are no sound or input collisions detected. The source code have
33comments about them; but I've found the joystick can be initialized 31comments about them; but I've found the joystick can be initialized
34separately of ALSA modules. So, you can use only one joystick driver 32separately of ALSA modules. So, you can use only one joystick driver
35without ALSA drivers. The ALSA drivers are not needed to compile or 33without ALSA drivers. The ALSA drivers are not needed to compile or
36run this driver. 34run this driver.
@@ -38,7 +36,7 @@ run this driver.
38There are no debug information print have been placed in source, and no 36There are no debug information print have been placed in source, and no
39specific options required to work this driver. The found chipset parameters 37specific options required to work this driver. The found chipset parameters
40are printed via printk(KERN_INFO "..."), see the /var/log/messages to 38are printed via printk(KERN_INFO "..."), see the /var/log/messages to
41inspect cs461x: prefixed messages to determine possible card detection 39inspect cs461x: prefixed messages to determine possible card detection
42errors. 40errors.
43 41
44Regards, 42Regards,
diff --git a/Documentation/input/edt-ft5x06.txt b/Documentation/input/devices/edt-ft5x06.rst
index 2032f0b7a8fa..2032f0b7a8fa 100644
--- a/Documentation/input/edt-ft5x06.txt
+++ b/Documentation/input/devices/edt-ft5x06.rst
diff --git a/Documentation/input/elantech.txt b/Documentation/input/devices/elantech.rst
index 1ec0db7879d3..c3374a7ce7af 100644
--- a/Documentation/input/elantech.txt
+++ b/Documentation/input/devices/elantech.rst
@@ -10,9 +10,7 @@ Elantech Touchpad Driver
10 received from Woody at Xandros and forwarded to me 10 received from Woody at Xandros and forwarded to me
11 by user StewieGriffin at the eeeuser.com forum 11 by user StewieGriffin at the eeeuser.com forum
12 12
13 13.. Contents
14Contents
15~~~~~~~~
16 14
17 1. Introduction 15 1. Introduction
18 2. Extra knobs 16 2. Extra knobs
@@ -45,8 +43,8 @@ Contents
45 43
46 44
47 45
481. Introduction 46Introduction
49 ~~~~~~~~~~~~ 47~~~~~~~~~~~~
50 48
51Currently the Linux Elantech touchpad driver is aware of four different 49Currently the Linux Elantech touchpad driver is aware of four different
52hardware versions unimaginatively called version 1,version 2, version 3 50hardware versions unimaginatively called version 1,version 2, version 3
@@ -88,11 +86,8 @@ available Elantech documentation the information is provided here anyway for
88completeness sake. 86completeness sake.
89 87
90 88
91///////////////////////////////////////////////////////////////////////////// 89Extra knobs
92 90~~~~~~~~~~~
93
942. Extra knobs
95 ~~~~~~~~~~~
96 91
97Currently the Linux Elantech touchpad driver provides three extra knobs under 92Currently the Linux Elantech touchpad driver provides three extra knobs under
98/sys/bus/serio/drivers/psmouse/serio? for the user. 93/sys/bus/serio/drivers/psmouse/serio? for the user.
@@ -142,18 +137,17 @@ Currently the Linux Elantech touchpad driver provides three extra knobs under
142 Reading the crc_enabled value will show the active value. Echoing 137 Reading the crc_enabled value will show the active value. Echoing
143 "0" or "1" to this file will set the state to "0" or "1". 138 "0" or "1" to this file will set the state to "0" or "1".
144 139
145///////////////////////////////////////////////////////////////////////////// 140Differentiating hardware versions
141~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146 142
1473. Differentiating hardware versions 143To detect the hardware version, read the version number as param[0].param[1].param[2]::
148 =================================
149
150To detect the hardware version, read the version number as param[0].param[1].param[2]
151 144
152 4 bytes version: (after the arrow is the name given in the Dell-provided driver) 145 4 bytes version: (after the arrow is the name given in the Dell-provided driver)
153 02.00.22 => EF013 146 02.00.22 => EF013
154 02.06.00 => EF019 147 02.06.00 => EF019
148
155In the wild, there appear to be more versions, such as 00.01.64, 01.00.21, 149In the wild, there appear to be more versions, such as 00.01.64, 01.00.21,
15602.00.00, 02.00.04, 02.00.06. 15002.00.00, 02.00.04, 02.00.06::
157 151
158 6 bytes: 152 6 bytes:
159 02.00.30 => EF113 153 02.00.30 => EF113
@@ -162,6 +156,7 @@ In the wild, there appear to be more versions, such as 00.01.64, 01.00.21,
162 02.0B.00 => EF215 156 02.0B.00 => EF215
163 04.01.XX => Scroll_EF051 157 04.01.XX => Scroll_EF051
164 04.02.XX => EF051 158 04.02.XX => EF051
159
165In the wild, there appear to be more versions, such as 04.03.01, 04.04.11. There 160In the wild, there appear to be more versions, such as 04.03.01, 04.04.11. There
166appears to be almost no difference, except for EF113, which does not report 161appears to be almost no difference, except for EF113, which does not report
167pressure/width and has different data consistency checks. 162pressure/width and has different data consistency checks.
@@ -170,21 +165,20 @@ Probably all the versions with param[0] <= 01 can be considered as
1704 bytes/firmware 1. The versions < 02.08.00, with the exception of 02.00.30, as 1654 bytes/firmware 1. The versions < 02.08.00, with the exception of 02.00.30, as
1714 bytes/firmware 2. Everything >= 02.08.00 can be considered as 6 bytes. 1664 bytes/firmware 2. Everything >= 02.08.00 can be considered as 6 bytes.
172 167
173/////////////////////////////////////////////////////////////////////////////
174 168
1754. Hardware version 1 169Hardware version 1
176 ================== 170~~~~~~~~~~~~~~~~~~
177 171
1784.1 Registers 172Registers
179 ~~~~~~~~~ 173---------
180 174
181By echoing a hexadecimal value to a register it contents can be altered. 175By echoing a hexadecimal value to a register it contents can be altered.
182 176
183For example: 177For example::
184 178
185 echo -n 0x16 > reg_10 179 echo -n 0x16 > reg_10
186 180
187* reg_10 181* reg_10::
188 182
189 bit 7 6 5 4 3 2 1 0 183 bit 7 6 5 4 3 2 1 0
190 B C T D L A S E 184 B C T D L A S E
@@ -198,7 +192,7 @@ For example:
198 C: 1 = enable corner tap 192 C: 1 = enable corner tap
199 B: 1 = swap left and right button 193 B: 1 = swap left and right button
200 194
201* reg_11 195* reg_11::
202 196
203 bit 7 6 5 4 3 2 1 0 197 bit 7 6 5 4 3 2 1 0
204 1 0 0 H V 1 F P 198 1 0 0 H V 1 F P
@@ -208,40 +202,41 @@ For example:
208 V: 1 = enable vertical scroll area 202 V: 1 = enable vertical scroll area
209 H: 1 = enable horizontal scroll area 203 H: 1 = enable horizontal scroll area
210 204
211* reg_20 205* reg_20::
212 206
213 single finger width? 207 single finger width?
214 208
215* reg_21 209* reg_21::
216 210
217 scroll area width (small: 0x40 ... wide: 0xff) 211 scroll area width (small: 0x40 ... wide: 0xff)
218 212
219* reg_22 213* reg_22::
220 214
221 drag lock time out (short: 0x14 ... long: 0xfe; 215 drag lock time out (short: 0x14 ... long: 0xfe;
222 0xff = tap again to release) 216 0xff = tap again to release)
223 217
224* reg_23 218* reg_23::
225 219
226 tap make timeout? 220 tap make timeout?
227 221
228* reg_24 222* reg_24::
229 223
230 tap release timeout? 224 tap release timeout?
231 225
232* reg_25 226* reg_25::
233 227
234 smart edge cursor speed (0x02 = slow, 0x03 = medium, 0x04 = fast) 228 smart edge cursor speed (0x02 = slow, 0x03 = medium, 0x04 = fast)
235 229
236* reg_26 230* reg_26::
237 231
238 smart edge activation area width? 232 smart edge activation area width?
239 233
240 234
2414.2 Native relative mode 4 byte packet format 235Native relative mode 4 byte packet format
242 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 236-----------------------------------------
237
238byte 0::
243 239
244byte 0:
245 bit 7 6 5 4 3 2 1 0 240 bit 7 6 5 4 3 2 1 0
246 c c p2 p1 1 M R L 241 c c p2 p1 1 M R L
247 242
@@ -251,20 +246,23 @@ byte 0:
251 p1..p2 = byte 1 and 2 odd parity bit 246 p1..p2 = byte 1 and 2 odd parity bit
252 c = 1 when corner tap detected 247 c = 1 when corner tap detected
253 248
254byte 1: 249byte 1::
250
255 bit 7 6 5 4 3 2 1 0 251 bit 7 6 5 4 3 2 1 0
256 dx7 dx6 dx5 dx4 dx3 dx2 dx1 dx0 252 dx7 dx6 dx5 dx4 dx3 dx2 dx1 dx0
257 253
258 dx7..dx0 = x movement; positive = right, negative = left 254 dx7..dx0 = x movement; positive = right, negative = left
259 byte 1 = 0xf0 when corner tap detected 255 byte 1 = 0xf0 when corner tap detected
260 256
261byte 2: 257byte 2::
258
262 bit 7 6 5 4 3 2 1 0 259 bit 7 6 5 4 3 2 1 0
263 dy7 dy6 dy5 dy4 dy3 dy2 dy1 dy0 260 dy7 dy6 dy5 dy4 dy3 dy2 dy1 dy0
264 261
265 dy7..dy0 = y movement; positive = up, negative = down 262 dy7..dy0 = y movement; positive = up, negative = down
266 263
267byte 3: 264byte 3::
265
268 parity checking enabled (reg_11, P = 1): 266 parity checking enabled (reg_11, P = 1):
269 267
270 bit 7 6 5 4 3 2 1 0 268 bit 7 6 5 4 3 2 1 0
@@ -296,14 +294,15 @@ byte 3:
296 positive = down 294 positive = down
297 295
298 296
2994.3 Native absolute mode 4 byte packet format 297Native absolute mode 4 byte packet format
300 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 298-----------------------------------------
301 299
302EF013 and EF019 have a special behaviour (due to a bug in the firmware?), and 300EF013 and EF019 have a special behaviour (due to a bug in the firmware?), and
303when 1 finger is touching, the first 2 position reports must be discarded. 301when 1 finger is touching, the first 2 position reports must be discarded.
304This counting is reset whenever a different number of fingers is reported. 302This counting is reset whenever a different number of fingers is reported.
305 303
306byte 0: 304byte 0::
305
307 firmware version 1.x: 306 firmware version 1.x:
308 307
309 bit 7 6 5 4 3 2 1 0 308 bit 7 6 5 4 3 2 1 0
@@ -322,7 +321,8 @@ byte 0:
322 p1..p3 = byte 1..3 odd parity bit 321 p1..p3 = byte 1..3 odd parity bit
323 n1..n0 = number of fingers on touchpad 322 n1..n0 = number of fingers on touchpad
324 323
325byte 1: 324byte 1::
325
326 firmware version 1.x: 326 firmware version 1.x:
327 327
328 bit 7 6 5 4 3 2 1 0 328 bit 7 6 5 4 3 2 1 0
@@ -337,65 +337,68 @@ byte 1:
337 bit 7 6 5 4 3 2 1 0 337 bit 7 6 5 4 3 2 1 0
338 . . . . x9 x8 y9 y8 338 . . . . x9 x8 y9 y8
339 339
340byte 2: 340byte 2::
341
341 bit 7 6 5 4 3 2 1 0 342 bit 7 6 5 4 3 2 1 0
342 x7 x6 x5 x4 x3 x2 x1 x0 343 x7 x6 x5 x4 x3 x2 x1 x0
343 344
344 x9..x0 = absolute x value (horizontal) 345 x9..x0 = absolute x value (horizontal)
345 346
346byte 3: 347byte 3::
348
347 bit 7 6 5 4 3 2 1 0 349 bit 7 6 5 4 3 2 1 0
348 y7 y6 y5 y4 y3 y2 y1 y0 350 y7 y6 y5 y4 y3 y2 y1 y0
349 351
350 y9..y0 = absolute y value (vertical) 352 y9..y0 = absolute y value (vertical)
351 353
352 354
353///////////////////////////////////////////////////////////////////////////// 355Hardware version 2
354 356~~~~~~~~~~~~~~~~~~
355 357
3565. Hardware version 2
357 ==================
358 358
359 359Registers
3605.1 Registers 360---------
361 ~~~~~~~~~
362 361
363By echoing a hexadecimal value to a register it contents can be altered. 362By echoing a hexadecimal value to a register it contents can be altered.
364 363
365For example: 364For example::
366 365
367 echo -n 0x56 > reg_10 366 echo -n 0x56 > reg_10
368 367
369* reg_10 368* reg_10::
370 369
371 bit 7 6 5 4 3 2 1 0 370 bit 7 6 5 4 3 2 1 0
372 0 1 0 1 0 1 D 0 371 0 1 0 1 0 1 D 0
373 372
374 D: 1 = enable drag and drop 373 D: 1 = enable drag and drop
375 374
376* reg_11 375* reg_11::
377 376
378 bit 7 6 5 4 3 2 1 0 377 bit 7 6 5 4 3 2 1 0
379 1 0 0 0 S 0 1 0 378 1 0 0 0 S 0 1 0
380 379
381 S: 1 = enable vertical scroll 380 S: 1 = enable vertical scroll
382 381
383* reg_21 382* reg_21::
384 383
385 unknown (0x00) 384 unknown (0x00)
386 385
387* reg_22 386* reg_22::
388 387
389 drag and drop release time out (short: 0x70 ... long 0x7e; 388 drag and drop release time out (short: 0x70 ... long 0x7e;
390 0x7f = never i.e. tap again to release) 389 0x7f = never i.e. tap again to release)
391 390
392 391
3935.2 Native absolute mode 6 byte packet format 392Native absolute mode 6 byte packet format
394 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 393-----------------------------------------
3955.2.1 Parity checking and packet re-synchronization 394
395Parity checking and packet re-synchronization
396^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
397
396There is no parity checking, however some consistency checks can be performed. 398There is no parity checking, however some consistency checks can be performed.
397 399
398For instance for EF113: 400For instance for EF113::
401
399 SA1= packet[0]; 402 SA1= packet[0];
400 A1 = packet[1]; 403 A1 = packet[1];
401 B1 = packet[2]; 404 B1 = packet[2];
@@ -410,7 +413,8 @@ For instance for EF113:
410 (((SA1 & 0xC0) != 0x80) && (( C1 & 0xF0) != 0x00)) ) // check Byte 5 413 (((SA1 & 0xC0) != 0x80) && (( C1 & 0xF0) != 0x00)) ) // check Byte 5
411 // error detected 414 // error detected
412 415
413For all the other ones, there are just a few constant bits: 416For all the other ones, there are just a few constant bits::
417
414 if( ((packet[0] & 0x0C) != 0x04) || 418 if( ((packet[0] & 0x0C) != 0x04) ||
415 ((packet[3] & 0x0f) != 0x02) ) 419 ((packet[3] & 0x0f) != 0x02) )
416 // error detected 420 // error detected
@@ -418,10 +422,10 @@ For all the other ones, there are just a few constant bits:
418 422
419In case an error is detected, all the packets are shifted by one (and packet[0] is discarded). 423In case an error is detected, all the packets are shifted by one (and packet[0] is discarded).
420 424
4215.2.2 One/Three finger touch 425One/Three finger touch
422 ~~~~~~~~~~~~~~~~ 426^^^^^^^^^^^^^^^^^^^^^^
423 427
424byte 0: 428byte 0::
425 429
426 bit 7 6 5 4 3 2 1 0 430 bit 7 6 5 4 3 2 1 0
427 n1 n0 w3 w2 . . R L 431 n1 n0 w3 w2 . . R L
@@ -429,19 +433,19 @@ byte 0:
429 L, R = 1 when Left, Right mouse button pressed 433 L, R = 1 when Left, Right mouse button pressed
430 n1..n0 = number of fingers on touchpad 434 n1..n0 = number of fingers on touchpad
431 435
432byte 1: 436byte 1::
433 437
434 bit 7 6 5 4 3 2 1 0 438 bit 7 6 5 4 3 2 1 0
435 p7 p6 p5 p4 x11 x10 x9 x8 439 p7 p6 p5 p4 x11 x10 x9 x8
436 440
437byte 2: 441byte 2::
438 442
439 bit 7 6 5 4 3 2 1 0 443 bit 7 6 5 4 3 2 1 0
440 x7 x6 x5 x4 x3 x2 x1 x0 444 x7 x6 x5 x4 x3 x2 x1 x0
441 445
442 x11..x0 = absolute x value (horizontal) 446 x11..x0 = absolute x value (horizontal)
443 447
444byte 3: 448byte 3::
445 449
446 bit 7 6 5 4 3 2 1 0 450 bit 7 6 5 4 3 2 1 0
447 n4 vf w1 w0 . . . b2 451 n4 vf w1 w0 . . . b2
@@ -460,14 +464,14 @@ byte 3:
460 6 = Another one 464 6 = Another one
461 7 = Another one 465 7 = Another one
462 466
463byte 4: 467byte 4::
464 468
465 bit 7 6 5 4 3 2 1 0 469 bit 7 6 5 4 3 2 1 0
466 p3 p1 p2 p0 y11 y10 y9 y8 470 p3 p1 p2 p0 y11 y10 y9 y8
467 471
468 p7..p0 = pressure (not EF113) 472 p7..p0 = pressure (not EF113)
469 473
470byte 5: 474byte 5::
471 475
472 bit 7 6 5 4 3 2 1 0 476 bit 7 6 5 4 3 2 1 0
473 y7 y6 y5 y4 y3 y2 y1 y0 477 y7 y6 y5 y4 y3 y2 y1 y0
@@ -475,15 +479,15 @@ byte 5:
475 y11..y0 = absolute y value (vertical) 479 y11..y0 = absolute y value (vertical)
476 480
477 481
4785.2.3 Two finger touch 482Two finger touch
479 ~~~~~~~~~~~~~~~~ 483^^^^^^^^^^^^^^^^
480 484
481Note that the two pairs of coordinates are not exactly the coordinates of the 485Note that the two pairs of coordinates are not exactly the coordinates of the
482two fingers, but only the pair of the lower-left and upper-right coordinates. 486two fingers, but only the pair of the lower-left and upper-right coordinates.
483So the actual fingers might be situated on the other diagonal of the square 487So the actual fingers might be situated on the other diagonal of the square
484defined by these two points. 488defined by these two points.
485 489
486byte 0: 490byte 0::
487 491
488 bit 7 6 5 4 3 2 1 0 492 bit 7 6 5 4 3 2 1 0
489 n1 n0 ay8 ax8 . . R L 493 n1 n0 ay8 ax8 . . R L
@@ -491,47 +495,46 @@ byte 0:
491 L, R = 1 when Left, Right mouse button pressed 495 L, R = 1 when Left, Right mouse button pressed
492 n1..n0 = number of fingers on touchpad 496 n1..n0 = number of fingers on touchpad
493 497
494byte 1: 498byte 1::
495 499
496 bit 7 6 5 4 3 2 1 0 500 bit 7 6 5 4 3 2 1 0
497 ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0 501 ax7 ax6 ax5 ax4 ax3 ax2 ax1 ax0
498 502
499 ax8..ax0 = lower-left finger absolute x value 503 ax8..ax0 = lower-left finger absolute x value
500 504
501byte 2: 505byte 2::
502 506
503 bit 7 6 5 4 3 2 1 0 507 bit 7 6 5 4 3 2 1 0
504 ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0 508 ay7 ay6 ay5 ay4 ay3 ay2 ay1 ay0
505 509
506 ay8..ay0 = lower-left finger absolute y value 510 ay8..ay0 = lower-left finger absolute y value
507 511
508byte 3: 512byte 3::
509 513
510 bit 7 6 5 4 3 2 1 0 514 bit 7 6 5 4 3 2 1 0
511 . . by8 bx8 . . . . 515 . . by8 bx8 . . . .
512 516
513byte 4: 517byte 4::
514 518
515 bit 7 6 5 4 3 2 1 0 519 bit 7 6 5 4 3 2 1 0
516 bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0 520 bx7 bx6 bx5 bx4 bx3 bx2 bx1 bx0
517 521
518 bx8..bx0 = upper-right finger absolute x value 522 bx8..bx0 = upper-right finger absolute x value
519 523
520byte 5: 524byte 5::
521 525
522 bit 7 6 5 4 3 2 1 0 526 bit 7 6 5 4 3 2 1 0
523 by7 by8 by5 by4 by3 by2 by1 by0 527 by7 by8 by5 by4 by3 by2 by1 by0
524 528
525 by8..by0 = upper-right finger absolute y value 529 by8..by0 = upper-right finger absolute y value
526 530
527///////////////////////////////////////////////////////////////////////////// 531Hardware version 3
532~~~~~~~~~~~~~~~~~~
528 533
5296. Hardware version 3 534Registers
530 ================== 535---------
531 536
5326.1 Registers 537* reg_10::
533 ~~~~~~~~~
534* reg_10
535 538
536 bit 7 6 5 4 3 2 1 0 539 bit 7 6 5 4 3 2 1 0
537 0 0 0 0 R F T A 540 0 0 0 0 R F T A
@@ -541,8 +544,9 @@ byte 5:
541 F: 1 = disable ABS Position Filter 544 F: 1 = disable ABS Position Filter
542 R: 1 = enable real hardware resolution 545 R: 1 = enable real hardware resolution
543 546
5446.2 Native absolute mode 6 byte packet format 547Native absolute mode 6 byte packet format
545 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 548-----------------------------------------
549
5461 and 3 finger touch shares the same 6-byte packet format, except that 5501 and 3 finger touch shares the same 6-byte packet format, except that
5473 finger touch only reports the position of the center of all three fingers. 5513 finger touch only reports the position of the center of all three fingers.
548 552
@@ -552,19 +556,21 @@ Note on debounce:
552In case the box has unstable power supply or other electricity issues, or 556In case the box has unstable power supply or other electricity issues, or
553when number of finger changes, F/W would send "debounce packet" to inform 557when number of finger changes, F/W would send "debounce packet" to inform
554driver that the hardware is in debounce status. 558driver that the hardware is in debounce status.
555The debouce packet has the following signature: 559The debouce packet has the following signature::
560
556 byte 0: 0xc4 561 byte 0: 0xc4
557 byte 1: 0xff 562 byte 1: 0xff
558 byte 2: 0xff 563 byte 2: 0xff
559 byte 3: 0x02 564 byte 3: 0x02
560 byte 4: 0xff 565 byte 4: 0xff
561 byte 5: 0xff 566 byte 5: 0xff
567
562When we encounter this kind of packet, we just ignore it. 568When we encounter this kind of packet, we just ignore it.
563 569
5646.2.1 One/Three finger touch 570One/Three finger touch
565 ~~~~~~~~~~~~~~~~~~~~~~ 571^^^^^^^^^^^^^^^^^^^^^^
566 572
567byte 0: 573byte 0::
568 574
569 bit 7 6 5 4 3 2 1 0 575 bit 7 6 5 4 3 2 1 0
570 n1 n0 w3 w2 0 1 R L 576 n1 n0 w3 w2 0 1 R L
@@ -572,63 +578,63 @@ byte 0:
572 L, R = 1 when Left, Right mouse button pressed 578 L, R = 1 when Left, Right mouse button pressed
573 n1..n0 = number of fingers on touchpad 579 n1..n0 = number of fingers on touchpad
574 580
575byte 1: 581byte 1::
576 582
577 bit 7 6 5 4 3 2 1 0 583 bit 7 6 5 4 3 2 1 0
578 p7 p6 p5 p4 x11 x10 x9 x8 584 p7 p6 p5 p4 x11 x10 x9 x8
579 585
580byte 2: 586byte 2::
581 587
582 bit 7 6 5 4 3 2 1 0 588 bit 7 6 5 4 3 2 1 0
583 x7 x6 x5 x4 x3 x2 x1 x0 589 x7 x6 x5 x4 x3 x2 x1 x0
584 590
585 x11..x0 = absolute x value (horizontal) 591 x11..x0 = absolute x value (horizontal)
586 592
587byte 3: 593byte 3::
588 594
589 bit 7 6 5 4 3 2 1 0 595 bit 7 6 5 4 3 2 1 0
590 0 0 w1 w0 0 0 1 0 596 0 0 w1 w0 0 0 1 0
591 597
592 w3..w0 = width of the finger touch 598 w3..w0 = width of the finger touch
593 599
594byte 4: 600byte 4::
595 601
596 bit 7 6 5 4 3 2 1 0 602 bit 7 6 5 4 3 2 1 0
597 p3 p1 p2 p0 y11 y10 y9 y8 603 p3 p1 p2 p0 y11 y10 y9 y8
598 604
599 p7..p0 = pressure 605 p7..p0 = pressure
600 606
601byte 5: 607byte 5::
602 608
603 bit 7 6 5 4 3 2 1 0 609 bit 7 6 5 4 3 2 1 0
604 y7 y6 y5 y4 y3 y2 y1 y0 610 y7 y6 y5 y4 y3 y2 y1 y0
605 611
606 y11..y0 = absolute y value (vertical) 612 y11..y0 = absolute y value (vertical)
607 613
6086.2.2 Two finger touch 614Two finger touch
609 ~~~~~~~~~~~~~~~~ 615^^^^^^^^^^^^^^^^
610 616
611The packet format is exactly the same for two finger touch, except the hardware 617The packet format is exactly the same for two finger touch, except the hardware
612sends two 6 byte packets. The first packet contains data for the first finger, 618sends two 6 byte packets. The first packet contains data for the first finger,
613the second packet has data for the second finger. So for two finger touch a 619the second packet has data for the second finger. So for two finger touch a
614total of 12 bytes are sent. 620total of 12 bytes are sent.
615 621
616///////////////////////////////////////////////////////////////////////////// 622Hardware version 4
623~~~~~~~~~~~~~~~~~~
617 624
6187. Hardware version 4 625Registers
619 ================== 626---------
620 627
6217.1 Registers 628* reg_07::
622 ~~~~~~~~~
623* reg_07
624 629
625 bit 7 6 5 4 3 2 1 0 630 bit 7 6 5 4 3 2 1 0
626 0 0 0 0 0 0 0 A 631 0 0 0 0 0 0 0 A
627 632
628 A: 1 = enable absolute tracking 633 A: 1 = enable absolute tracking
629 634
6307.2 Native absolute mode 6 byte packet format 635Native absolute mode 6 byte packet format
631 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 636-----------------------------------------
637
632v4 hardware is a true multitouch touchpad, capable of tracking up to 5 fingers. 638v4 hardware is a true multitouch touchpad, capable of tracking up to 5 fingers.
633Unfortunately, due to PS/2's limited bandwidth, its packet format is rather 639Unfortunately, due to PS/2's limited bandwidth, its packet format is rather
634complex. 640complex.
@@ -647,45 +653,49 @@ position, until we receive a status packet.
647One exception is one finger touch. when a status packet tells us there is only 653One exception is one finger touch. when a status packet tells us there is only
648one finger, the hardware would just send head packets afterwards. 654one finger, the hardware would just send head packets afterwards.
649 655
6507.2.1 Status packet 656Status packet
651 ~~~~~~~~~~~~~ 657^^^^^^^^^^^^^
652 658
653byte 0: 659byte 0::
654 660
655 bit 7 6 5 4 3 2 1 0 661 bit 7 6 5 4 3 2 1 0
656 . . . . 0 1 R L 662 . . . . 0 1 R L
657 663
658 L, R = 1 when Left, Right mouse button pressed 664 L, R = 1 when Left, Right mouse button pressed
659 665
660byte 1: 666byte 1::
661 667
662 bit 7 6 5 4 3 2 1 0 668 bit 7 6 5 4 3 2 1 0
663 . . . ft4 ft3 ft2 ft1 ft0 669 . . . ft4 ft3 ft2 ft1 ft0
664 670
665 ft4 ft3 ft2 ft1 ft0 ftn = 1 when finger n is on touchpad 671 ft4 ft3 ft2 ft1 ft0 ftn = 1 when finger n is on touchpad
666 672
667byte 2: not used 673byte 2::
674
675 not used
668 676
669byte 3: 677byte 3::
670 678
671 bit 7 6 5 4 3 2 1 0 679 bit 7 6 5 4 3 2 1 0
672 . . . 1 0 0 0 0 680 . . . 1 0 0 0 0
673 681
674 constant bits 682 constant bits
675 683
676byte 4: 684byte 4::
677 685
678 bit 7 6 5 4 3 2 1 0 686 bit 7 6 5 4 3 2 1 0
679 p . . . . . . . 687 p . . . . . . .
680 688
681 p = 1 for palm 689 p = 1 for palm
682 690
683byte 5: not used 691byte 5::
684 692
6857.2.2 Head packet 693 not used
686 ~~~~~~~~~~~
687 694
688byte 0: 695Head packet
696^^^^^^^^^^^
697
698byte 0::
689 699
690 bit 7 6 5 4 3 2 1 0 700 bit 7 6 5 4 3 2 1 0
691 w3 w2 w1 w0 0 1 R L 701 w3 w2 w1 w0 0 1 R L
@@ -693,43 +703,43 @@ byte 0:
693 L, R = 1 when Left, Right mouse button pressed 703 L, R = 1 when Left, Right mouse button pressed
694 w3..w0 = finger width (spans how many trace lines) 704 w3..w0 = finger width (spans how many trace lines)
695 705
696byte 1: 706byte 1::
697 707
698 bit 7 6 5 4 3 2 1 0 708 bit 7 6 5 4 3 2 1 0
699 p7 p6 p5 p4 x11 x10 x9 x8 709 p7 p6 p5 p4 x11 x10 x9 x8
700 710
701byte 2: 711byte 2::
702 712
703 bit 7 6 5 4 3 2 1 0 713 bit 7 6 5 4 3 2 1 0
704 x7 x6 x5 x4 x3 x2 x1 x0 714 x7 x6 x5 x4 x3 x2 x1 x0
705 715
706 x11..x0 = absolute x value (horizontal) 716 x11..x0 = absolute x value (horizontal)
707 717
708byte 3: 718byte 3::
709 719
710 bit 7 6 5 4 3 2 1 0 720 bit 7 6 5 4 3 2 1 0
711 id2 id1 id0 1 0 0 0 1 721 id2 id1 id0 1 0 0 0 1
712 722
713 id2..id0 = finger id 723 id2..id0 = finger id
714 724
715byte 4: 725byte 4::
716 726
717 bit 7 6 5 4 3 2 1 0 727 bit 7 6 5 4 3 2 1 0
718 p3 p1 p2 p0 y11 y10 y9 y8 728 p3 p1 p2 p0 y11 y10 y9 y8
719 729
720 p7..p0 = pressure 730 p7..p0 = pressure
721 731
722byte 5: 732byte 5::
723 733
724 bit 7 6 5 4 3 2 1 0 734 bit 7 6 5 4 3 2 1 0
725 y7 y6 y5 y4 y3 y2 y1 y0 735 y7 y6 y5 y4 y3 y2 y1 y0
726 736
727 y11..y0 = absolute y value (vertical) 737 y11..y0 = absolute y value (vertical)
728 738
7297.2.3 Motion packet 739Motion packet
730 ~~~~~~~~~~~~~ 740^^^^^^^^^^^^^
731 741
732byte 0: 742byte 0::
733 743
734 bit 7 6 5 4 3 2 1 0 744 bit 7 6 5 4 3 2 1 0
735 id2 id1 id0 w 0 1 R L 745 id2 id1 id0 w 0 1 R L
@@ -739,35 +749,35 @@ byte 0:
739 w = 1 when delta overflows (> 127 or < -128), in this case 749 w = 1 when delta overflows (> 127 or < -128), in this case
740 firmware sends us (delta x / 5) and (delta y / 5) 750 firmware sends us (delta x / 5) and (delta y / 5)
741 751
742byte 1: 752byte 1::
743 753
744 bit 7 6 5 4 3 2 1 0 754 bit 7 6 5 4 3 2 1 0
745 x7 x6 x5 x4 x3 x2 x1 x0 755 x7 x6 x5 x4 x3 x2 x1 x0
746 756
747 x7..x0 = delta x (two's complement) 757 x7..x0 = delta x (two's complement)
748 758
749byte 2: 759byte 2::
750 760
751 bit 7 6 5 4 3 2 1 0 761 bit 7 6 5 4 3 2 1 0
752 y7 y6 y5 y4 y3 y2 y1 y0 762 y7 y6 y5 y4 y3 y2 y1 y0
753 763
754 y7..y0 = delta y (two's complement) 764 y7..y0 = delta y (two's complement)
755 765
756byte 3: 766byte 3::
757 767
758 bit 7 6 5 4 3 2 1 0 768 bit 7 6 5 4 3 2 1 0
759 id2 id1 id0 1 0 0 1 0 769 id2 id1 id0 1 0 0 1 0
760 770
761 id2..id0 = finger id 771 id2..id0 = finger id
762 772
763byte 4: 773byte 4::
764 774
765 bit 7 6 5 4 3 2 1 0 775 bit 7 6 5 4 3 2 1 0
766 x7 x6 x5 x4 x3 x2 x1 x0 776 x7 x6 x5 x4 x3 x2 x1 x0
767 777
768 x7..x0 = delta x (two's complement) 778 x7..x0 = delta x (two's complement)
769 779
770byte 5: 780byte 5::
771 781
772 bit 7 6 5 4 3 2 1 0 782 bit 7 6 5 4 3 2 1 0
773 y7 y6 y5 y4 y3 y2 y1 y0 783 y7 y6 y5 y4 y3 y2 y1 y0
@@ -778,33 +788,47 @@ byte 5:
778 byte 3 ~ 5 for another 788 byte 3 ~ 5 for another
779 789
780 790
7818. Trackpoint (for Hardware version 3 and 4) 791Trackpoint (for Hardware version 3 and 4)
782 ========================================= 792~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7838.1 Registers 793
784 ~~~~~~~~~ 794Registers
795---------
796
785No special registers have been identified. 797No special registers have been identified.
786 798
7878.2 Native relative mode 6 byte packet format 799Native relative mode 6 byte packet format
788 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 800-----------------------------------------
7898.2.1 Status Packet 801
790 ~~~~~~~~~~~~~ 802Status Packet
803^^^^^^^^^^^^^
804
805byte 0::
791 806
792byte 0:
793 bit 7 6 5 4 3 2 1 0 807 bit 7 6 5 4 3 2 1 0
794 0 0 sx sy 0 M R L 808 0 0 sx sy 0 M R L
795byte 1: 809
810byte 1::
811
796 bit 7 6 5 4 3 2 1 0 812 bit 7 6 5 4 3 2 1 0
797 ~sx 0 0 0 0 0 0 0 813 ~sx 0 0 0 0 0 0 0
798byte 2: 814
815byte 2::
816
799 bit 7 6 5 4 3 2 1 0 817 bit 7 6 5 4 3 2 1 0
800 ~sy 0 0 0 0 0 0 0 818 ~sy 0 0 0 0 0 0 0
801byte 3: 819
820byte 3::
821
802 bit 7 6 5 4 3 2 1 0 822 bit 7 6 5 4 3 2 1 0
803 0 0 ~sy ~sx 0 1 1 0 823 0 0 ~sy ~sx 0 1 1 0
804byte 4: 824
825byte 4::
826
805 bit 7 6 5 4 3 2 1 0 827 bit 7 6 5 4 3 2 1 0
806 x7 x6 x5 x4 x3 x2 x1 x0 828 x7 x6 x5 x4 x3 x2 x1 x0
807byte 5: 829
830byte 5::
831
808 bit 7 6 5 4 3 2 1 0 832 bit 7 6 5 4 3 2 1 0
809 y7 y6 y5 y4 y3 y2 y1 y0 833 y7 y6 y5 y4 y3 y2 y1 y0
810 834
diff --git a/Documentation/input/devices/gpio-tilt.rst b/Documentation/input/devices/gpio-tilt.rst
new file mode 100644
index 000000000000..fa6e64570aa7
--- /dev/null
+++ b/Documentation/input/devices/gpio-tilt.rst
@@ -0,0 +1,103 @@
1Driver for tilt-switches connected via GPIOs
2============================================
3
4Generic driver to read data from tilt switches connected via gpios.
5Orientation can be provided by one or more than one tilt switches,
6i.e. each tilt switch providing one axis, and the number of axes
7is also not limited.
8
9
10Data structures
11---------------
12
13The array of struct gpio in the gpios field is used to list the gpios
14that represent the current tilt state.
15
16The array of struct gpio_tilt_axis describes the axes that are reported
17to the input system. The values set therein are used for the
18input_set_abs_params calls needed to init the axes.
19
20The array of struct gpio_tilt_state maps gpio states to the corresponding
21values to report. The gpio state is represented as a bitfield where the
22bit-index corresponds to the index of the gpio in the struct gpio array.
23In the same manner the values stored in the axes array correspond to
24the elements of the gpio_tilt_axis-array.
25
26
27Example
28-------
29
30Example configuration for a single TS1003 tilt switch that rotates around
31one axis in 4 steps and emits the current tilt via two GPIOs::
32
33 static int sg060_tilt_enable(struct device *dev) {
34 /* code to enable the sensors */
35 };
36
37 static void sg060_tilt_disable(struct device *dev) {
38 /* code to disable the sensors */
39 };
40
41 static struct gpio sg060_tilt_gpios[] = {
42 { SG060_TILT_GPIO_SENSOR1, GPIOF_IN, "tilt_sensor1" },
43 { SG060_TILT_GPIO_SENSOR2, GPIOF_IN, "tilt_sensor2" },
44 };
45
46 static struct gpio_tilt_state sg060_tilt_states[] = {
47 {
48 .gpios = (0 << 1) | (0 << 0),
49 .axes = (int[]) {
50 0,
51 },
52 }, {
53 .gpios = (0 << 1) | (1 << 0),
54 .axes = (int[]) {
55 1, /* 90 degrees */
56 },
57 }, {
58 .gpios = (1 << 1) | (1 << 0),
59 .axes = (int[]) {
60 2, /* 180 degrees */
61 },
62 }, {
63 .gpios = (1 << 1) | (0 << 0),
64 .axes = (int[]) {
65 3, /* 270 degrees */
66 },
67 },
68 };
69
70 static struct gpio_tilt_axis sg060_tilt_axes[] = {
71 {
72 .axis = ABS_RY,
73 .min = 0,
74 .max = 3,
75 .fuzz = 0,
76 .flat = 0,
77 },
78 };
79
80 static struct gpio_tilt_platform_data sg060_tilt_pdata= {
81 .gpios = sg060_tilt_gpios,
82 .nr_gpios = ARRAY_SIZE(sg060_tilt_gpios),
83
84 .axes = sg060_tilt_axes,
85 .nr_axes = ARRAY_SIZE(sg060_tilt_axes),
86
87 .states = sg060_tilt_states,
88 .nr_states = ARRAY_SIZE(sg060_tilt_states),
89
90 .debounce_interval = 100,
91
92 .poll_interval = 1000,
93 .enable = sg060_tilt_enable,
94 .disable = sg060_tilt_disable,
95 };
96
97 static struct platform_device sg060_device_tilt = {
98 .name = "gpio-tilt-polled",
99 .id = -1,
100 .dev = {
101 .platform_data = &sg060_tilt_pdata,
102 },
103 };
diff --git a/Documentation/input/devices/iforce-protocol.rst b/Documentation/input/devices/iforce-protocol.rst
new file mode 100644
index 000000000000..8634beac3fdb
--- /dev/null
+++ b/Documentation/input/devices/iforce-protocol.rst
@@ -0,0 +1,381 @@
1===============
2Iforce Protocol
3===============
4
5:Author: Johann Deneux <johann.deneux@gmail.com>
6
7Home page at `<http://web.archive.org/web/*/http://www.esil.univ-mrs.fr>`_
8
9:Additions: by Vojtech Pavlik.
10
11
12Introduction
13============
14
15This document describes what I managed to discover about the protocol used to
16specify force effects to I-Force 2.0 devices. None of this information comes
17from Immerse. That's why you should not trust what is written in this
18document. This document is intended to help understanding the protocol.
19This is not a reference. Comments and corrections are welcome. To contact me,
20send an email to: johann.deneux@gmail.com
21
22.. warning::
23
24 I shall not be held responsible for any damage or harm caused if you try to
25 send data to your I-Force device based on what you read in this document.
26
27Preliminary Notes
28=================
29
30All values are hexadecimal with big-endian encoding (msb on the left). Beware,
31values inside packets are encoded using little-endian. Bytes whose roles are
32unknown are marked ??? Information that needs deeper inspection is marked (?)
33
34General form of a packet
35------------------------
36
37This is how packets look when the device uses the rs232 to communicate.
38
39== == === ==== ==
402B OP LEN DATA CS
41== == === ==== ==
42
43CS is the checksum. It is equal to the exclusive or of all bytes.
44
45When using USB:
46
47== ====
48OP DATA
49== ====
50
51The 2B, LEN and CS fields have disappeared, probably because USB handles
52frames and data corruption is handled or unsignificant.
53
54First, I describe effects that are sent by the device to the computer
55
56Device input state
57==================
58
59This packet is used to indicate the state of each button and the value of each
60axis::
61
62 OP= 01 for a joystick, 03 for a wheel
63 LEN= Varies from device to device
64 00 X-Axis lsb
65 01 X-Axis msb
66 02 Y-Axis lsb, or gas pedal for a wheel
67 03 Y-Axis msb, or brake pedal for a wheel
68 04 Throttle
69 05 Buttons
70 06 Lower 4 bits: Buttons
71 Upper 4 bits: Hat
72 07 Rudder
73
74Device effects states
75=====================
76
77::
78
79 OP= 02
80 LEN= Varies
81 00 ? Bit 1 (Value 2) is the value of the deadman switch
82 01 Bit 8 is set if the effect is playing. Bits 0 to 7 are the effect id.
83 02 ??
84 03 Address of parameter block changed (lsb)
85 04 Address of parameter block changed (msb)
86 05 Address of second parameter block changed (lsb)
87 ... depending on the number of parameter blocks updated
88
89Force effect
90------------
91
92::
93
94 OP= 01
95 LEN= 0e
96 00 Channel (when playing several effects at the same time, each must
97 be assigned a channel)
98 01 Wave form
99 Val 00 Constant
100 Val 20 Square
101 Val 21 Triangle
102 Val 22 Sine
103 Val 23 Sawtooth up
104 Val 24 Sawtooth down
105 Val 40 Spring (Force = f(pos))
106 Val 41 Friction (Force = f(velocity)) and Inertia
107 (Force = f(acceleration))
108
109
110 02 Axes affected and trigger
111 Bits 4-7: Val 2 = effect along one axis. Byte 05 indicates direction
112 Val 4 = X axis only. Byte 05 must contain 5a
113 Val 8 = Y axis only. Byte 05 must contain b4
114 Val c = X and Y axes. Bytes 05 must contain 60
115 Bits 0-3: Val 0 = No trigger
116 Val x+1 = Button x triggers the effect
117 When the whole byte is 0, cancel the previously set trigger
118
119 03-04 Duration of effect (little endian encoding, in ms)
120
121 05 Direction of effect, if applicable. Else, see 02 for value to assign.
122
123 06-07 Minimum time between triggering.
124
125 08-09 Address of periodicity or magnitude parameters
126 0a-0b Address of attack and fade parameters, or ffff if none.
127 *or*
128 08-09 Address of interactive parameters for X-axis,
129 or ffff if not applicable
130 0a-0b Address of interactive parameters for Y-axis,
131 or ffff if not applicable
132
133 0c-0d Delay before execution of effect (little endian encoding, in ms)
134
135
136Time based parameters
137---------------------
138
139Attack and fade
140^^^^^^^^^^^^^^^
141
142::
143
144 OP= 02
145 LEN= 08
146 00-01 Address where to store the parameters
147 02-03 Duration of attack (little endian encoding, in ms)
148 04 Level at end of attack. Signed byte.
149 05-06 Duration of fade.
150 07 Level at end of fade.
151
152Magnitude
153^^^^^^^^^
154
155::
156
157 OP= 03
158 LEN= 03
159 00-01 Address
160 02 Level. Signed byte.
161
162Periodicity
163^^^^^^^^^^^
164
165::
166
167 OP= 04
168 LEN= 07
169 00-01 Address
170 02 Magnitude. Signed byte.
171 03 Offset. Signed byte.
172 04 Phase. Val 00 = 0 deg, Val 40 = 90 degs.
173 05-06 Period (little endian encoding, in ms)
174
175Interactive parameters
176----------------------
177
178::
179
180 OP= 05
181 LEN= 0a
182 00-01 Address
183 02 Positive Coeff
184 03 Negative Coeff
185 04+05 Offset (center)
186 06+07 Dead band (Val 01F4 = 5000 (decimal))
187 08 Positive saturation (Val 0a = 1000 (decimal) Val 64 = 10000 (decimal))
188 09 Negative saturation
189
190The encoding is a bit funny here: For coeffs, these are signed values. The
191maximum value is 64 (100 decimal), the min is 9c.
192For the offset, the minimum value is FE0C, the maximum value is 01F4.
193For the deadband, the minimum value is 0, the max is 03E8.
194
195Controls
196--------
197
198::
199
200 OP= 41
201 LEN= 03
202 00 Channel
203 01 Start/Stop
204 Val 00: Stop
205 Val 01: Start and play once.
206 Val 41: Start and play n times (See byte 02 below)
207 02 Number of iterations n.
208
209Init
210----
211
212
213Querying features
214^^^^^^^^^^^^^^^^^
215::
216
217 OP= ff
218 Query command. Length varies according to the query type.
219 The general format of this packet is:
220 ff 01 QUERY [INDEX] CHECKSUM
221 responses are of the same form:
222 FF LEN QUERY VALUE_QUERIED CHECKSUM2
223 where LEN = 1 + length(VALUE_QUERIED)
224
225Query ram size
226~~~~~~~~~~~~~~
227
228::
229
230 QUERY = 42 ('B'uffer size)
231
232The device should reply with the same packet plus two additional bytes
233containing the size of the memory:
234ff 03 42 03 e8 CS would mean that the device has 1000 bytes of ram available.
235
236Query number of effects
237~~~~~~~~~~~~~~~~~~~~~~~
238
239::
240
241 QUERY = 4e ('N'umber of effects)
242
243The device should respond by sending the number of effects that can be played
244at the same time (one byte)
245ff 02 4e 14 CS would stand for 20 effects.
246
247Vendor's id
248~~~~~~~~~~~
249
250::
251
252 QUERY = 4d ('M'anufacturer)
253
254Query the vendors'id (2 bytes)
255
256Product id
257~~~~~~~~~~
258
259::
260
261 QUERY = 50 ('P'roduct)
262
263Query the product id (2 bytes)
264
265Open device
266~~~~~~~~~~~
267
268::
269
270 QUERY = 4f ('O'pen)
271
272No data returned.
273
274Close device
275~~~~~~~~~~~~
276
277::
278
279 QUERY = 43 ('C')lose
280
281No data returned.
282
283Query effect
284~~~~~~~~~~~~
285
286::
287
288 QUERY = 45 ('E')
289
290Send effect type.
291Returns nonzero if supported (2 bytes)
292
293Firmware Version
294~~~~~~~~~~~~~~~~
295
296::
297
298 QUERY = 56 ('V'ersion)
299
300Sends back 3 bytes - major, minor, subminor
301
302Initialisation of the device
303^^^^^^^^^^^^^^^^^^^^^^^^^^^^
304
305Set Control
306~~~~~~~~~~~
307
308.. note::
309 Device dependent, can be different on different models!
310
311::
312
313 OP= 40 <idx> <val> [<val>]
314 LEN= 2 or 3
315 00 Idx
316 Idx 00 Set dead zone (0..2048)
317 Idx 01 Ignore Deadman sensor (0..1)
318 Idx 02 Enable comm watchdog (0..1)
319 Idx 03 Set the strength of the spring (0..100)
320 Idx 04 Enable or disable the spring (0/1)
321 Idx 05 Set axis saturation threshold (0..2048)
322
323Set Effect State
324~~~~~~~~~~~~~~~~
325
326::
327
328 OP= 42 <val>
329 LEN= 1
330 00 State
331 Bit 3 Pause force feedback
332 Bit 2 Enable force feedback
333 Bit 0 Stop all effects
334
335Set overall
336~~~~~~~~~~~
337
338::
339
340 OP= 43 <val>
341 LEN= 1
342 00 Gain
343 Val 00 = 0%
344 Val 40 = 50%
345 Val 80 = 100%
346
347Parameter memory
348----------------
349
350Each device has a certain amount of memory to store parameters of effects.
351The amount of RAM may vary, I encountered values from 200 to 1000 bytes. Below
352is the amount of memory apparently needed for every set of parameters:
353
354 - period : 0c
355 - magnitude : 02
356 - attack and fade : 0e
357 - interactive : 08
358
359Appendix: How to study the protocol?
360====================================
361
3621. Generate effects using the force editor provided with the DirectX SDK, or
363use Immersion Studio (freely available at their web site in the developer section:
364www.immersion.com)
3652. Start a soft spying RS232 or USB (depending on where you connected your
366joystick/wheel). I used ComPortSpy from fCoder (alpha version!)
3673. Play the effect, and watch what happens on the spy screen.
368
369A few words about ComPortSpy:
370At first glance, this software seems, hum, well... buggy. In fact, data appear with a
371few seconds latency. Personally, I restart it every time I play an effect.
372Remember it's free (as in free beer) and alpha!
373
374URLS
375====
376
377Check http://www.immerse.com for Immersion Studio,
378and http://www.fcoder.com for ComPortSpy.
379
380
381I-Force is trademark of Immersion Corp.
diff --git a/Documentation/input/devices/index.rst b/Documentation/input/devices/index.rst
new file mode 100644
index 000000000000..95a453782bad
--- /dev/null
+++ b/Documentation/input/devices/index.rst
@@ -0,0 +1,19 @@
1Driver-specific documentation
2=============================
3
4This section provides information about various devices supported by the
5Linux kernel, their protocols, and driver details.
6
7.. toctree::
8 :maxdepth: 2
9 :numbered:
10 :glob:
11
12 *
13
14.. only:: subproject and html
15
16 Indices
17 =======
18
19 * :ref:`genindex`
diff --git a/Documentation/input/devices/joystick-parport.rst b/Documentation/input/devices/joystick-parport.rst
new file mode 100644
index 000000000000..e8ce16ee799a
--- /dev/null
+++ b/Documentation/input/devices/joystick-parport.rst
@@ -0,0 +1,611 @@
1.. include:: <isonum.txt>
2
3.. _joystick-parport:
4
5==============================
6Parallel Port Joystick Drivers
7==============================
8
9:Copyright: |copy| 1998-2000 Vojtech Pavlik <vojtech@ucw.cz>
10:Copyright: |copy| 1998 Andree Borrmann <a.borrmann@tu-bs.de>
11
12
13Sponsored by SuSE
14
15Disclaimer
16==========
17
18Any information in this file is provided as-is, without any guarantee that
19it will be true. So, use it at your own risk. The possible damages that can
20happen include burning your parallel port, and/or the sticks and joystick
21and maybe even more. Like when a lightning kills you it is not our problem.
22
23Introduction
24============
25
26The joystick parport drivers are used for joysticks and gamepads not
27originally designed for PCs and other computers Linux runs on. Because of
28that, PCs usually lack the right ports to connect these devices to. Parallel
29port, because of its ability to change single bits at will, and providing
30both output and input bits is the most suitable port on the PC for
31connecting such devices.
32
33Devices supported
34=================
35
36Many console and 8-bit computer gamepads and joysticks are supported. The
37following subsections discuss usage of each.
38
39NES and SNES
40------------
41
42The Nintendo Entertainment System and Super Nintendo Entertainment System
43gamepads are widely available, and easy to get. Also, they are quite easy to
44connect to a PC, and don't need much processing speed (108 us for NES and
45165 us for SNES, compared to about 1000 us for PC gamepads) to communicate
46with them.
47
48All NES and SNES use the same synchronous serial protocol, clocked from
49the computer's side (and thus timing insensitive). To allow up to 5 NES
50and/or SNES gamepads and/or SNES mice connected to the parallel port at once,
51the output lines of the parallel port are shared, while one of 5 available
52input lines is assigned to each gamepad.
53
54This protocol is handled by the gamecon.c driver, so that's the one
55you'll use for NES, SNES gamepads and SNES mice.
56
57The main problem with PC parallel ports is that they don't have +5V power
58source on any of their pins. So, if you want a reliable source of power
59for your pads, use either keyboard or joystick port, and make a pass-through
60cable. You can also pull the power directly from the power supply (the red
61wire is +5V).
62
63If you want to use the parallel port only, you can take the power is from
64some data pin. For most gamepad and parport implementations only one pin is
65needed, and I'd recommend pin 9 for that, the highest data bit. On the other
66hand, if you are not planning to use anything else than NES / SNES on the
67port, anything between and including pin 4 and pin 9 will work::
68
69 (pin 9) -----> Power
70
71Unfortunately, there are pads that need a lot more of power, and parallel
72ports that can't give much current through the data pins. If this is your
73case, you'll need to use diodes (as a prevention of destroying your parallel
74port), and combine the currents of two or more data bits together::
75
76 Diodes
77 (pin 9) ----|>|-------+------> Power
78 |
79 (pin 8) ----|>|-------+
80 |
81 (pin 7) ----|>|-------+
82 |
83 <and so on> :
84 |
85 (pin 4) ----|>|-------+
86
87Ground is quite easy. On PC's parallel port the ground is on any of the
88pins from pin 18 to pin 25. So use any pin of these you like for the ground::
89
90 (pin 18) -----> Ground
91
92NES and SNES pads have two input bits, Clock and Latch, which drive the
93serial transfer. These are connected to pins 2 and 3 of the parallel port,
94respectively::
95
96 (pin 2) -----> Clock
97 (pin 3) -----> Latch
98
99And the last thing is the NES / SNES data wire. Only that isn't shared and
100each pad needs its own data pin. The parallel port pins are::
101
102 (pin 10) -----> Pad 1 data
103 (pin 11) -----> Pad 2 data
104 (pin 12) -----> Pad 3 data
105 (pin 13) -----> Pad 4 data
106 (pin 15) -----> Pad 5 data
107
108Note that pin 14 is not used, since it is not an input pin on the parallel
109port.
110
111This is everything you need on the PC's side of the connection, now on to
112the gamepads side. The NES and SNES have different connectors. Also, there
113are quite a lot of NES clones, and because Nintendo used proprietary
114connectors for their machines, the cloners couldn't and used standard D-Cannon
115connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo
116A, Turbo B, Select and Start, and is connected through 5 wires, then it is
117either a NES or NES clone and will work with this connection. SNES gamepads
118also use 5 wires, but have more buttons. They will work as well, of course::
119
120 Pinout for NES gamepads Pinout for SNES gamepads and mice
121
122 +----> Power +-----------------------\
123 | 7 | o o o o | x x o | 1
124 5 +---------+ 7 +-----------------------/
125 | x x o \ | | | | |
126 | o o o o | | | | | +-> Ground
127 4 +------------+ 1 | | | +------------> Data
128 | | | | | | +---------------> Latch
129 | | | +-> Ground | +------------------> Clock
130 | | +----> Clock +---------------------> Power
131 | +-------> Latch
132 +----------> Data
133
134 Pinout for NES clone (db9) gamepads Pinout for NES clone (db15) gamepads
135
136 +---------> Clock +-----------------> Data
137 | +-------> Latch | +---> Ground
138 | | +-----> Data | |
139 | | | ___________________
140 _____________ 8 \ o x x x x x x o / 1
141 5 \ x o o o x / 1 \ o x x o x x o /
142 \ x o x o / 15 `~~~~~~~~~~~~~' 9
143 9 `~~~~~~~' 6 | | |
144 | | | | +----> Clock
145 | +----> Power | +----------> Latch
146 +--------> Ground +----------------> Power
147
148Multisystem joysticks
149---------------------
150
151In the era of 8-bit machines, there was something like de-facto standard
152for joystick ports. They were all digital, and all used D-Cannon 9 pin
153connectors (db9). Because of that, a single joystick could be used without
154hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,
155Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these
156joysticks are called "Multisystem".
157
158Now their pinout::
159
160 +---------> Right
161 | +-------> Left
162 | | +-----> Down
163 | | | +---> Up
164 | | | |
165 _____________
166 5 \ x o o o o / 1
167 \ x o x o /
168 9 `~~~~~~~' 6
169 | |
170 | +----> Button
171 +--------> Ground
172
173However, as time passed, extensions to this standard developed, and these
174were not compatible with each other::
175
176
177 Atari 130, 800/XL/XE MSX
178
179 +-----------> Power
180 +---------> Right | +---------> Right
181 | +-------> Left | | +-------> Left
182 | | +-----> Down | | | +-----> Down
183 | | | +---> Up | | | | +---> Up
184 | | | | | | | | |
185 _____________ _____________
186 5 \ x o o o o / 1 5 \ o o o o o / 1
187 \ x o o o / \ o o o o /
188 9 `~~~~~~~' 6 9 `~~~~~~~' 6
189 | | | | | | |
190 | | +----> Button | | | +----> Button 1
191 | +------> Power | | +------> Button 2
192 +--------> Ground | +--------> Output 3
193 +----------> Ground
194
195 Amstrad CPC Commodore C64
196
197 +-----------> Analog Y
198 +---------> Right | +---------> Right
199 | +-------> Left | | +-------> Left
200 | | +-----> Down | | | +-----> Down
201 | | | +---> Up | | | | +---> Up
202 | | | | | | | | |
203 _____________ _____________
204 5 \ x o o o o / 1 5 \ o o o o o / 1
205 \ x o o o / \ o o o o /
206 9 `~~~~~~~' 6 9 `~~~~~~~' 6
207 | | | | | | |
208 | | +----> Button 1 | | | +----> Button
209 | +------> Button 2 | | +------> Power
210 +--------> Ground | +--------> Ground
211 +----------> Analog X
212
213 Sinclair Spectrum +2A/+3 Amiga 1200
214
215 +-----------> Up +-----------> Button 3
216 | +---------> Fire | +---------> Right
217 | | | | +-------> Left
218 | | +-----> Ground | | | +-----> Down
219 | | | | | | | +---> Up
220 | | | | | | | |
221 _____________ _____________
222 5 \ o o x o x / 1 5 \ o o o o o / 1
223 \ o o o o / \ o o o o /
224 9 `~~~~~~~' 6 9 `~~~~~~~' 6
225 | | | | | | | |
226 | | | +----> Right | | | +----> Button 1
227 | | +------> Left | | +------> Power
228 | +--------> Ground | +--------> Ground
229 +----------> Down +----------> Button 2
230
231 And there were many others.
232
233Multisystem joysticks using db9.c
234~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236For the Multisystem joysticks, and their derivatives, the db9.c driver
237was written. It allows only one joystick / gamepad per parallel port, but
238the interface is easy to build and works with almost anything.
239
240For the basic 1-button Multisystem joystick you connect its wires to the
241parallel port like this::
242
243 (pin 1) -----> Power
244 (pin 18) -----> Ground
245
246 (pin 2) -----> Up
247 (pin 3) -----> Down
248 (pin 4) -----> Left
249 (pin 5) -----> Right
250 (pin 6) -----> Button 1
251
252However, if the joystick is switch based (eg. clicks when you move it),
253you might or might not, depending on your parallel port, need 10 kOhm pullup
254resistors on each of the direction and button signals, like this::
255
256 (pin 2) ------------+------> Up
257 Resistor |
258 (pin 1) --[10kOhm]--+
259
260Try without, and if it doesn't work, add them. For TTL based joysticks /
261gamepads the pullups are not needed.
262
263For joysticks with two buttons you connect the second button to pin 7 on
264the parallel port::
265
266 (pin 7) -----> Button 2
267
268And that's it.
269
270On a side note, if you have already built a different adapter for use with
271the digital joystick driver 0.8.0.2, this is also supported by the db9.c
272driver, as device type 8. (See section 3.2)
273
274Multisystem joysticks using gamecon.c
275~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276
277For some people just one joystick per parallel port is not enough, and/or
278want to use them on one parallel port together with NES/SNES/PSX pads. This is
279possible using the gamecon.c. It supports up to 5 devices of the above types,
280including 1 and 2 buttons Multisystem joysticks.
281
282However, there is nothing for free. To allow more sticks to be used at
283once, you need the sticks to be purely switch based (that is non-TTL), and
284not to need power. Just a plain simple six switches inside. If your
285joystick can do more (eg. turbofire) you'll need to disable it totally first
286if you want to use gamecon.c.
287
288Also, the connection is a bit more complex. You'll need a bunch of diodes,
289and one pullup resistor. First, you connect the Directions and the button
290the same as for db9, however with the diodes between::
291
292 Diodes
293 (pin 2) -----|<|----> Up
294 (pin 3) -----|<|----> Down
295 (pin 4) -----|<|----> Left
296 (pin 5) -----|<|----> Right
297 (pin 6) -----|<|----> Button 1
298
299For two button sticks you also connect the other button::
300
301 (pin 7) -----|<|----> Button 2
302
303And finally, you connect the Ground wire of the joystick, like done in
304this little schematic to Power and Data on the parallel port, as described
305for the NES / SNES pads in section 2.1 of this file - that is, one data pin
306for each joystick. The power source is shared::
307
308 Data ------------+-----> Ground
309 Resistor |
310 Power --[10kOhm]--+
311
312And that's all, here we go!
313
314Multisystem joysticks using turbografx.c
315~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316
317The TurboGraFX interface, designed by
318
319 Steffen Schwenke <schwenke@burg-halle.de>
320
321allows up to 7 Multisystem joysticks connected to the parallel port. In
322Steffen's version, there is support for up to 5 buttons per joystick. However,
323since this doesn't work reliably on all parallel ports, the turbografx.c driver
324supports only one button per joystick. For more information on how to build the
325interface, see:
326
327 http://www2.burg-halle.de/~schwenke/parport.html
328
329Sony Playstation
330----------------
331
332The PSX controller is supported by the gamecon.c. Pinout of the PSX
333controller (compatible with DirectPadPro)::
334
335 +---------+---------+---------+
336 9 | o o o | o o o | o o o | 1 parallel
337 \________|_________|________/ port pins
338 | | | | | |
339 | | | | | +--------> Clock --- (4)
340 | | | | +------------> Select --- (3)
341 | | | +---------------> Power --- (5-9)
342 | | +------------------> Ground --- (18-25)
343 | +-------------------------> Command --- (2)
344 +----------------------------> Data --- (one of 10,11,12,13,15)
345
346The driver supports these controllers:
347
348 * Standard PSX Pad
349 * NegCon PSX Pad
350 * Analog PSX Pad (red mode)
351 * Analog PSX Pad (green mode)
352 * PSX Rumble Pad
353 * PSX DDR Pad
354
355Sega
356----
357
358All the Sega controllers are more or less based on the standard 2-button
359Multisystem joystick. However, since they don't use switches and use TTL
360logic, the only driver usable with them is the db9.c driver.
361
362Sega Master System
363~~~~~~~~~~~~~~~~~~
364
365The SMS gamepads are almost exactly the same as normal 2-button
366Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
367parallel port pins, and the following schematic::
368
369 +-----------> Power
370 | +---------> Right
371 | | +-------> Left
372 | | | +-----> Down
373 | | | | +---> Up
374 | | | | |
375 _____________
376 5 \ o o o o o / 1
377 \ o o x o /
378 9 `~~~~~~~' 6
379 | | |
380 | | +----> Button 1
381 | +--------> Ground
382 +----------> Button 2
383
384Sega Genesis aka MegaDrive
385~~~~~~~~~~~~~~~~~~~~~~~~~~
386
387The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension
388to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1). Use
389the following schematic::
390
391 +-----------> Power
392 | +---------> Right
393 | | +-------> Left
394 | | | +-----> Down
395 | | | | +---> Up
396 | | | | |
397 _____________
398 5 \ o o o o o / 1
399 \ o o o o /
400 9 `~~~~~~~' 6
401 | | | |
402 | | | +----> Button 1
403 | | +------> Select
404 | +--------> Ground
405 +----------> Button 2
406
407The Select pin goes to pin 14 on the parallel port::
408
409 (pin 14) -----> Select
410
411The rest is the same as for Multi2 joysticks using db9.c
412
413Sega Saturn
414~~~~~~~~~~~
415
416Sega Saturn has eight buttons, and to transfer that, without hacks like
417Genesis 6 pads use, it needs one more select pin. Anyway, it is still
418handled by the db9.c driver. Its pinout is very different from anything
419else. Use this schematic::
420
421 +-----------> Select 1
422 | +---------> Power
423 | | +-------> Up
424 | | | +-----> Down
425 | | | | +---> Ground
426 | | | | |
427 _____________
428 5 \ o o o o o / 1
429 \ o o o o /
430 9 `~~~~~~~' 6
431 | | | |
432 | | | +----> Select 2
433 | | +------> Right
434 | +--------> Left
435 +----------> Power
436
437Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the
438parallel port::
439
440 (pin 14) -----> Select 1
441 (pin 16) -----> Select 2
442
443The other pins (Up, Down, Right, Left, Power, Ground) are the same as for
444Multi joysticks using db9.c
445
446Amiga CD32
447----------
448
449Amiga CD32 joypad uses the following pinout::
450
451 +-----------> Button 3
452 | +---------> Right
453 | | +-------> Left
454 | | | +-----> Down
455 | | | | +---> Up
456 | | | | |
457 _____________
458 5 \ o o o o o / 1
459 \ o o o o /
460 9 `~~~~~~~' 6
461 | | | |
462 | | | +----> Button 1
463 | | +------> Power
464 | +--------> Ground
465 +----------> Button 2
466
467It can be connected to the parallel port and driven by db9.c driver. It needs the following wiring:
468
469 ============ =============
470 CD32 pad Parallel port
471 ============ =============
472 1 (Up) 2 (D0)
473 2 (Down) 3 (D1)
474 3 (Left) 4 (D2)
475 4 (Right) 5 (D3)
476 5 (Button 3) 14 (AUTOFD)
477 6 (Button 1) 17 (SELIN)
478 7 (+5V) 1 (STROBE)
479 8 (Gnd) 18 (Gnd)
480 9 (Button 2) 7 (D5)
481 ============ =============
482
483The drivers
484===========
485
486There are three drivers for the parallel port interfaces. Each, as
487described above, allows to connect a different group of joysticks and pads.
488Here are described their command lines:
489
490gamecon.c
491---------
492
493Using gamecon.c you can connect up to five devices to one parallel port. It
494uses the following kernel/module command line::
495
496 gamecon.map=port,pad1,pad2,pad3,pad4,pad5
497
498Where ``port`` the number of the parport interface (eg. 0 for parport0).
499
500And ``pad1`` to ``pad5`` are pad types connected to different data input pins
501(10,11,12,13,15), as described in section 2.1 of this file.
502
503The types are:
504
505 ===== =============================
506 Type Joystick/Pad
507 ===== =============================
508 0 None
509 1 SNES pad
510 2 NES pad
511 4 Multisystem 1-button joystick
512 5 Multisystem 2-button joystick
513 6 N64 pad
514 7 Sony PSX controller
515 8 Sony PSX DDR controller
516 9 SNES mouse
517 ===== =============================
518
519The exact type of the PSX controller type is autoprobed when used, so
520hot swapping should work (but is not recommended).
521
522Should you want to use more than one of parallel ports at once, you can use
523gamecon.map2 and gamecon.map3 as additional command line parameters for two
524more parallel ports.
525
526There are two options specific to PSX driver portion. gamecon.psx_delay sets
527the command delay when talking to the controllers. The default of 25 should
528work but you can try lowering it for better performance. If your pads don't
529respond try raising it until they work. Setting the type to 8 allows the
530driver to be used with Dance Dance Revolution or similar games. Arrow keys are
531registered as key presses instead of X and Y axes.
532
533db9.c
534-----
535
536Apart from making an interface, there is nothing difficult on using the
537db9.c driver. It uses the following kernel/module command line::
538
539 db9.dev=port,type
540
541Where ``port`` is the number of the parport interface (eg. 0 for parport0).
542
543Caveat here: This driver only works on bidirectional parallel ports. If
544your parallel port is recent enough, you should have no trouble with this.
545Old parallel ports may not have this feature.
546
547``Type`` is the type of joystick or pad attached:
548
549 ===== ======================================================
550 Type Joystick/Pad
551 ===== ======================================================
552 0 None
553 1 Multisystem 1-button joystick
554 2 Multisystem 2-button joystick
555 3 Genesis pad (3+1 buttons)
556 5 Genesis pad (5+1 buttons)
557 6 Genesis pad (6+2 buttons)
558 7 Saturn pad (8 buttons)
559 8 Multisystem 1-button joystick (v0.8.0.2 pin-out)
560 9 Two Multisystem 1-button joysticks (v0.8.0.2 pin-out)
561 10 Amiga CD32 pad
562 ===== ======================================================
563
564Should you want to use more than one of these joysticks/pads at once, you
565can use db9.dev2 and db9.dev3 as additional command line parameters for two
566more joysticks/pads.
567
568turbografx.c
569------------
570
571The turbografx.c driver uses a very simple kernel/module command line::
572
573 turbografx.map=port,js1,js2,js3,js4,js5,js6,js7
574
575Where ``port`` is the number of the parport interface (eg. 0 for parport0).
576
577``jsX`` is the number of buttons the Multisystem joysticks connected to the
578interface ports 1-7 have. For a standard multisystem joystick, this is 1.
579
580Should you want to use more than one of these interfaces at once, you can
581use turbografx.map2 and turbografx.map3 as additional command line parameters
582for two more interfaces.
583
584PC parallel port pinout
585=======================
586
587::
588
589 .----------------------------------------.
590 At the PC: \ 13 12 11 10 9 8 7 6 5 4 3 2 1 /
591 \ 25 24 23 22 21 20 19 18 17 16 15 14 /
592 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
593
594====== ======= =============
595 Pin Name Description
596====== ======= =============
597 1 /STROBE Strobe
598 2-9 D0-D7 Data Bit 0-7
599 10 /ACK Acknowledge
600 11 BUSY Busy
601 12 PE Paper End
602 13 SELIN Select In
603 14 /AUTOFD Autofeed
604 15 /ERROR Error
605 16 /INIT Initialize
606 17 /SEL Select
607 18-25 GND Signal Ground
608====== ======= =============
609
610
611That's all, folks! Have fun!
diff --git a/Documentation/input/ntrig.txt b/Documentation/input/devices/ntrig.rst
index be1fd981f73f..a6b22ce6c61c 100644
--- a/Documentation/input/ntrig.txt
+++ b/Documentation/input/devices/ntrig.rst
@@ -1,7 +1,11 @@
1.. include:: <isonum.txt>
2
3=========================
1N-Trig touchscreen Driver 4N-Trig touchscreen Driver
2------------------------- 5=========================
3 Copyright (c) 2008-2010 Rafi Rubin <rafi@seas.upenn.edu> 6
4 Copyright (c) 2009-2010 Stephane Chatty 7:Copyright: |copy| 2008-2010 Rafi Rubin <rafi@seas.upenn.edu>
8:Copyright: |copy| 2009-2010 Stephane Chatty
5 9
6This driver provides support for N-Trig pen and multi-touch sensors. Single 10This driver provides support for N-Trig pen and multi-touch sensors. Single
7and multi-touch events are translated to the appropriate protocols for 11and multi-touch events are translated to the appropriate protocols for
@@ -22,16 +26,18 @@ but only for that one device.
22 26
23The following parameters are used to configure filters to reduce noise: 27The following parameters are used to configure filters to reduce noise:
24 28
25activate_slack number of fingers to ignore before processing events 29+-----------------------+-----------------------------------------------------+
26 30|activate_slack |number of fingers to ignore before processing events |
27activation_height size threshold to activate immediately 31+-----------------------+-----------------------------------------------------+
28activation_width 32|activation_height, |size threshold to activate immediately |
29 33|activation_width | |
30min_height size threshold bellow which fingers are ignored 34+-----------------------+-----------------------------------------------------+
31min_width both to decide activation and during activity 35|min_height, |size threshold bellow which fingers are ignored |
32 36|min_width |both to decide activation and during activity |
33deactivate_slack the number of "no contact" frames to ignore before 37+-----------------------+-----------------------------------------------------+
34 propagating the end of activity events 38|deactivate_slack |the number of "no contact" frames to ignore before |
39| |propagating the end of activity events |
40+-----------------------+-----------------------------------------------------+
35 41
36When the last finger is removed from the device, it sends a number of empty 42When the last finger is removed from the device, it sends a number of empty
37frames. By holding off on deactivation for a few frames we can tolerate false 43frames. By holding off on deactivation for a few frames we can tolerate false
@@ -44,15 +50,20 @@ Additional sysfs items
44---------------------- 50----------------------
45 51
46These nodes just provide easy access to the ranges reported by the device. 52These nodes just provide easy access to the ranges reported by the device.
47sensor_logical_height the range for positions reported during activity
48sensor_logical_width
49 53
50sensor_physical_height internal ranges not used for normal events but 54+-----------------------+-----------------------------------------------------+
51sensor_physical_width useful for tuning 55|sensor_logical_height, | the range for positions reported during activity |
56|sensor_logical_width | |
57+-----------------------+-----------------------------------------------------+
58|sensor_physical_height,| internal ranges not used for normal events but |
59|sensor_physical_width | useful for tuning |
60+-----------------------+-----------------------------------------------------+
52 61
53All N-Trig devices with product id of 1 report events in the ranges of 62All N-Trig devices with product id of 1 report events in the ranges of
54X: 0-9600 63
55Y: 0-7200 64* X: 0-9600
65* Y: 0-7200
66
56However not all of these devices have the same physical dimensions. Most 67However not all of these devices have the same physical dimensions. Most
57seem to be 12" sensors (Dell Latitude XT and XT2 and the HP TX2), and 68seem to be 12" sensors (Dell Latitude XT and XT2 and the HP TX2), and
58at least one model (Dell Studio 17) has a 17" sensor. The ratio of physical 69at least one model (Dell Studio 17) has a 17" sensor. The ratio of physical
diff --git a/Documentation/input/rotary-encoder.txt b/Documentation/input/devices/rotary-encoder.rst
index 46a74f0c551a..b07b20a295ac 100644
--- a/Documentation/input/rotary-encoder.txt
+++ b/Documentation/input/devices/rotary-encoder.rst
@@ -1,8 +1,11 @@
1============================================================
1rotary-encoder - a generic driver for GPIO connected devices 2rotary-encoder - a generic driver for GPIO connected devices
2Daniel Mack <daniel@caiaq.de>, Feb 2009 3============================================================
3 4
40. Function 5:Author: Daniel Mack <daniel@caiaq.de>, Feb 2009
5----------- 6
7Function
8--------
6 9
7Rotary encoders are devices which are connected to the CPU or other 10Rotary encoders are devices which are connected to the CPU or other
8peripherals with two wires. The outputs are phase-shifted by 90 degrees 11peripherals with two wires. The outputs are phase-shifted by 90 degrees
@@ -13,7 +16,7 @@ Some encoders have both outputs low in stable states, others also have
13a stable state with both outputs high (half-period mode) and some have 16a stable state with both outputs high (half-period mode) and some have
14a stable state in all steps (quarter-period mode). 17a stable state in all steps (quarter-period mode).
15 18
16The phase diagram of these two outputs look like this: 19The phase diagram of these two outputs look like this::
17 20
18 _____ _____ _____ 21 _____ _____ _____
19 | | | | | | 22 | | | | | |
@@ -40,8 +43,8 @@ For more information, please see
40 https://en.wikipedia.org/wiki/Rotary_encoder 43 https://en.wikipedia.org/wiki/Rotary_encoder
41 44
42 45
431. Events / state machine 46Events / state machine
44------------------------- 47----------------------
45 48
46In half-period mode, state a) and c) above are used to determine the 49In half-period mode, state a) and c) above are used to determine the
47rotational direction based on the last stable state. Events are reported in 50rotational direction based on the last stable state. Events are reported in
@@ -65,62 +68,64 @@ d) Falling edge on channel B, channel A in low state
65 should have happened, unless it flipped back on half the way. The 68 should have happened, unless it flipped back on half the way. The
66 'armed' state tells us about that. 69 'armed' state tells us about that.
67 70
682. Platform requirements 71Platform requirements
69------------------------ 72---------------------
70 73
71As there is no hardware dependent call in this driver, the platform it is 74As there is no hardware dependent call in this driver, the platform it is
72used with must support gpiolib. Another requirement is that IRQs must be 75used with must support gpiolib. Another requirement is that IRQs must be
73able to fire on both edges. 76able to fire on both edges.
74 77
75 78
763. Board integration 79Board integration
77-------------------- 80-----------------
78 81
79To use this driver in your system, register a platform_device with the 82To use this driver in your system, register a platform_device with the
80name 'rotary-encoder' and associate the IRQs and some specific platform 83name 'rotary-encoder' and associate the IRQs and some specific platform
81data with it. 84data with it. Because the driver uses generic device properties, this can
82 85be done either via device tree, ACPI, or using static board files, like in
83struct rotary_encoder_platform_data is declared in 86example below:
84include/linux/rotary-encoder.h and needs to be filled with the number of 87
85steps the encoder has and can carry information about externally inverted 88::
86signals (because of an inverting buffer or other reasons). The encoder 89
87can be set up to deliver input information as either an absolute or relative 90 /* board support file example */
88axes. For relative axes the input event returns +/-1 for each step. For 91
89absolute axes the position of the encoder can either roll over between zero 92 #include <linux/input.h>
90and the number of steps or will clamp at the maximum and zero depending on 93 #include <linux/gpio/machine.h>
91the configuration. 94 #include <linux/property.h>
92 95
93Because GPIO to IRQ mapping is platform specific, this information must 96 #define GPIO_ROTARY_A 1
94be given in separately to the driver. See the example below. 97 #define GPIO_ROTARY_B 2
95 98
96---------<snip>--------- 99 static struct gpiod_lookup_table rotary_encoder_gpios = {
97 100 .dev_id = "rotary-encoder.0",
98/* board support file example */ 101 .table = {
99 102 GPIO_LOOKUP_IDX("gpio-0",
100#include <linux/input.h> 103 GPIO_ROTARY_A, NULL, 0, GPIO_ACTIVE_LOW),
101#include <linux/rotary_encoder.h> 104 GPIO_LOOKUP_IDX("gpio-0",
102 105 GPIO_ROTARY_B, NULL, 1, GPIO_ACTIVE_HIGH),
103#define GPIO_ROTARY_A 1 106 { },
104#define GPIO_ROTARY_B 2 107 },
105 108 };
106static struct rotary_encoder_platform_data my_rotary_encoder_info = { 109
107 .steps = 24, 110 static const struct property_entry rotary_encoder_properties[] __initconst = {
108 .axis = ABS_X, 111 PROPERTY_ENTRY_INTEGER("rotary-encoder,steps-per-period", u32, 24),
109 .relative_axis = false, 112 PROPERTY_ENTRY_INTEGER("linux,axis", u32, ABS_X),
110 .rollover = false, 113 PROPERTY_ENTRY_INTEGER("rotary-encoder,relative_axis", u32, 0),
111 .gpio_a = GPIO_ROTARY_A, 114 { },
112 .gpio_b = GPIO_ROTARY_B, 115 };
113 .inverted_a = 0, 116
114 .inverted_b = 0, 117 static struct platform_device rotary_encoder_device = {
115 .half_period = false, 118 .name = "rotary-encoder",
116 .wakeup_source = false, 119 .id = 0,
117}; 120 };
118 121
119static struct platform_device rotary_encoder_device = { 122 ...
120 .name = "rotary-encoder", 123
121 .id = 0, 124 gpiod_add_lookup_table(&rotary_encoder_gpios);
122 .dev = { 125 device_add_properties(&rotary_encoder_device, rotary_encoder_properties);
123 .platform_data = &my_rotary_encoder_info, 126 platform_device_register(&rotary_encoder_device);
124 } 127
125}; 128 ...
126 129
130Please consult device tree binding documentation to see all properties
131supported by the driver.
diff --git a/Documentation/input/devices/sentelic.rst b/Documentation/input/devices/sentelic.rst
new file mode 100644
index 000000000000..d7ad603dd77e
--- /dev/null
+++ b/Documentation/input/devices/sentelic.rst
@@ -0,0 +1,901 @@
1.. include:: <isonum.txt>
2
3=================
4Sentelic Touchpad
5=================
6
7
8:Copyright: |copy| 2002-2011 Sentelic Corporation.
9
10:Last update: Dec-07-2011
11
12Finger Sensing Pad Intellimouse Mode (scrolling wheel, 4th and 5th buttons)
13============================================================================
14
15A) MSID 4: Scrolling wheel mode plus Forward page(4th button) and Backward
16 page (5th button)
17
181. Set sample rate to 200;
192. Set sample rate to 200;
203. Set sample rate to 80;
214. Issuing the "Get device ID" command (0xF2) and waits for the response;
225. FSP will respond 0x04.
23
24::
25
26 Packet 1
27 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
28 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
29 1 |Y|X|y|x|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 | | |B|F|W|W|W|W|
30 |---------------| |---------------| |---------------| |---------------|
31
32 Byte 1: Bit7 => Y overflow
33 Bit6 => X overflow
34 Bit5 => Y sign bit
35 Bit4 => X sign bit
36 Bit3 => 1
37 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
38 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
39 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
40 Byte 2: X Movement(9-bit 2's complement integers)
41 Byte 3: Y Movement(9-bit 2's complement integers)
42 Byte 4: Bit3~Bit0 => the scrolling wheel's movement since the last data report.
43 valid values, -8 ~ +7
44 Bit4 => 1 = 4th mouse button is pressed, Forward one page.
45 0 = 4th mouse button is not pressed.
46 Bit5 => 1 = 5th mouse button is pressed, Backward one page.
47 0 = 5th mouse button is not pressed.
48
49B) MSID 6: Horizontal and Vertical scrolling
50
51- Set bit 1 in register 0x40 to 1
52
53FSP replaces scrolling wheel's movement as 4 bits to show horizontal and
54vertical scrolling.
55
56::
57
58 Packet 1
59 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
60 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
61 1 |Y|X|y|x|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 | | |B|F|r|l|u|d|
62 |---------------| |---------------| |---------------| |---------------|
63
64 Byte 1: Bit7 => Y overflow
65 Bit6 => X overflow
66 Bit5 => Y sign bit
67 Bit4 => X sign bit
68 Bit3 => 1
69 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
70 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
71 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
72 Byte 2: X Movement(9-bit 2's complement integers)
73 Byte 3: Y Movement(9-bit 2's complement integers)
74 Byte 4: Bit0 => the Vertical scrolling movement downward.
75 Bit1 => the Vertical scrolling movement upward.
76 Bit2 => the Horizontal scrolling movement leftward.
77 Bit3 => the Horizontal scrolling movement rightward.
78 Bit4 => 1 = 4th mouse button is pressed, Forward one page.
79 0 = 4th mouse button is not pressed.
80 Bit5 => 1 = 5th mouse button is pressed, Backward one page.
81 0 = 5th mouse button is not pressed.
82
83C) MSID 7
84
85FSP uses 2 packets (8 Bytes) to represent Absolute Position.
86so we have PACKET NUMBER to identify packets.
87
88 If PACKET NUMBER is 0, the packet is Packet 1.
89 If PACKET NUMBER is 1, the packet is Packet 2.
90 Please count this number in program.
91
92MSID6 special packet will be enable at the same time when enable MSID 7.
93
94Absolute position for STL3886-G0
95================================
96
971. Set bit 2 or 3 in register 0x40 to 1
982. Set bit 6 in register 0x40 to 1
99
100::
101
102 Packet 1 (ABSOLUTE POSITION)
103 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
104 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
105 1 |0|1|V|1|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|d|u|X|X|Y|Y|
106 |---------------| |---------------| |---------------| |---------------|
107
108 Byte 1: Bit7~Bit6 => 00, Normal data packet
109 => 01, Absolute coordination packet
110 => 10, Notify packet
111 Bit5 => valid bit
112 Bit4 => 1
113 Bit3 => 1
114 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
115 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
116 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
117 Byte 2: X coordinate (xpos[9:2])
118 Byte 3: Y coordinate (ypos[9:2])
119 Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
120 Bit3~Bit2 => X coordinate (ypos[1:0])
121 Bit4 => scroll up
122 Bit5 => scroll down
123 Bit6 => scroll left
124 Bit7 => scroll right
125
126 Notify Packet for G0
127 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
128 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
129 1 |1|0|0|1|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |M|M|M|M|M|M|M|M| 4 |0|0|0|0|0|0|0|0|
130 |---------------| |---------------| |---------------| |---------------|
131
132 Byte 1: Bit7~Bit6 => 00, Normal data packet
133 => 01, Absolute coordination packet
134 => 10, Notify packet
135 Bit5 => 0
136 Bit4 => 1
137 Bit3 => 1
138 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
139 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
140 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
141 Byte 2: Message Type => 0x5A (Enable/Disable status packet)
142 Mode Type => 0xA5 (Normal/Icon mode status)
143 Byte 3: Message Type => 0x00 (Disabled)
144 => 0x01 (Enabled)
145 Mode Type => 0x00 (Normal)
146 => 0x01 (Icon)
147 Byte 4: Bit7~Bit0 => Don't Care
148
149Absolute position for STL3888-Ax
150================================
151
152::
153
154 Packet 1 (ABSOLUTE POSITION)
155 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
156 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
157 1 |0|1|V|A|1|L|0|1| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |x|x|y|y|X|X|Y|Y|
158 |---------------| |---------------| |---------------| |---------------|
159
160 Byte 1: Bit7~Bit6 => 00, Normal data packet
161 => 01, Absolute coordination packet
162 => 10, Notify packet
163 => 11, Normal data packet with on-pad click
164 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
165 When both fingers are up, the last two reports have zero valid
166 bit.
167 Bit4 => arc
168 Bit3 => 1
169 Bit2 => Left Button, 1 is pressed, 0 is released.
170 Bit1 => 0
171 Bit0 => 1
172 Byte 2: X coordinate (xpos[9:2])
173 Byte 3: Y coordinate (ypos[9:2])
174 Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
175 Bit3~Bit2 => X coordinate (ypos[1:0])
176 Bit5~Bit4 => y1_g
177 Bit7~Bit6 => x1_g
178
179 Packet 2 (ABSOLUTE POSITION)
180 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
181 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
182 1 |0|1|V|A|1|R|1|0| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |x|x|y|y|X|X|Y|Y|
183 |---------------| |---------------| |---------------| |---------------|
184
185 Byte 1: Bit7~Bit6 => 00, Normal data packet
186 => 01, Absolute coordinates packet
187 => 10, Notify packet
188 => 11, Normal data packet with on-pad click
189 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
190 When both fingers are up, the last two reports have zero valid
191 bit.
192 Bit4 => arc
193 Bit3 => 1
194 Bit2 => Right Button, 1 is pressed, 0 is released.
195 Bit1 => 1
196 Bit0 => 0
197 Byte 2: X coordinate (xpos[9:2])
198 Byte 3: Y coordinate (ypos[9:2])
199 Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
200 Bit3~Bit2 => X coordinate (ypos[1:0])
201 Bit5~Bit4 => y2_g
202 Bit7~Bit6 => x2_g
203
204 Notify Packet for STL3888-Ax
205 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
206 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
207 1 |1|0|1|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|d|u|0|0|0|0|
208 |---------------| |---------------| |---------------| |---------------|
209
210 Byte 1: Bit7~Bit6 => 00, Normal data packet
211 => 01, Absolute coordinates packet
212 => 10, Notify packet
213 => 11, Normal data packet with on-pad click
214 Bit5 => 1
215 Bit4 => when in absolute coordinates mode (valid when EN_PKT_GO is 1):
216 0: left button is generated by the on-pad command
217 1: left button is generated by the external button
218 Bit3 => 1
219 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
220 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
221 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
222 Byte 2: Message Type => 0xB7 (Multi Finger, Multi Coordinate mode)
223 Byte 3: Bit7~Bit6 => Don't care
224 Bit5~Bit4 => Number of fingers
225 Bit3~Bit1 => Reserved
226 Bit0 => 1: enter gesture mode; 0: leaving gesture mode
227 Byte 4: Bit7 => scroll right button
228 Bit6 => scroll left button
229 Bit5 => scroll down button
230 Bit4 => scroll up button
231 * Note that if gesture and additional button (Bit4~Bit7)
232 happen at the same time, the button information will not
233 be sent.
234 Bit3~Bit0 => Reserved
235
236Sample sequence of Multi-finger, Multi-coordinate mode:
237
238 notify packet (valid bit == 1), abs pkt 1, abs pkt 2, abs pkt 1,
239 abs pkt 2, ..., notify packet (valid bit == 0)
240
241Absolute position for STL3888-B0
242================================
243
244::
245
246 Packet 1(ABSOLUTE POSITION)
247 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
248 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
249 1 |0|1|V|F|1|0|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|u|d|X|X|Y|Y|
250 |---------------| |---------------| |---------------| |---------------|
251
252 Byte 1: Bit7~Bit6 => 00, Normal data packet
253 => 01, Absolute coordinates packet
254 => 10, Notify packet
255 => 11, Normal data packet with on-pad click
256 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
257 When both fingers are up, the last two reports have zero valid
258 bit.
259 Bit4 => finger up/down information. 1: finger down, 0: finger up.
260 Bit3 => 1
261 Bit2 => finger index, 0 is the first finger, 1 is the second finger.
262 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
263 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
264 Byte 2: X coordinate (xpos[9:2])
265 Byte 3: Y coordinate (ypos[9:2])
266 Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
267 Bit3~Bit2 => X coordinate (ypos[1:0])
268 Bit4 => scroll down button
269 Bit5 => scroll up button
270 Bit6 => scroll left button
271 Bit7 => scroll right button
272
273 Packet 2 (ABSOLUTE POSITION)
274 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
275 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
276 1 |0|1|V|F|1|1|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|u|d|X|X|Y|Y|
277 |---------------| |---------------| |---------------| |---------------|
278
279 Byte 1: Bit7~Bit6 => 00, Normal data packet
280 => 01, Absolute coordination packet
281 => 10, Notify packet
282 => 11, Normal data packet with on-pad click
283 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
284 When both fingers are up, the last two reports have zero valid
285 bit.
286 Bit4 => finger up/down information. 1: finger down, 0: finger up.
287 Bit3 => 1
288 Bit2 => finger index, 0 is the first finger, 1 is the second finger.
289 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
290 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
291 Byte 2: X coordinate (xpos[9:2])
292 Byte 3: Y coordinate (ypos[9:2])
293 Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
294 Bit3~Bit2 => X coordinate (ypos[1:0])
295 Bit4 => scroll down button
296 Bit5 => scroll up button
297 Bit6 => scroll left button
298 Bit7 => scroll right button
299
300Notify Packet for STL3888-B0::
301
302 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
303 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
304 1 |1|0|1|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|u|d|0|0|0|0|
305 |---------------| |---------------| |---------------| |---------------|
306
307 Byte 1: Bit7~Bit6 => 00, Normal data packet
308 => 01, Absolute coordination packet
309 => 10, Notify packet
310 => 11, Normal data packet with on-pad click
311 Bit5 => 1
312 Bit4 => when in absolute coordinates mode (valid when EN_PKT_GO is 1):
313 0: left button is generated by the on-pad command
314 1: left button is generated by the external button
315 Bit3 => 1
316 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
317 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
318 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
319 Byte 2: Message Type => 0xB7 (Multi Finger, Multi Coordinate mode)
320 Byte 3: Bit7~Bit6 => Don't care
321 Bit5~Bit4 => Number of fingers
322 Bit3~Bit1 => Reserved
323 Bit0 => 1: enter gesture mode; 0: leaving gesture mode
324 Byte 4: Bit7 => scroll right button
325 Bit6 => scroll left button
326 Bit5 => scroll up button
327 Bit4 => scroll down button
328 * Note that if gesture and additional button(Bit4~Bit7)
329 happen at the same time, the button information will not
330 be sent.
331 Bit3~Bit0 => Reserved
332
333Sample sequence of Multi-finger, Multi-coordinate mode:
334
335 notify packet (valid bit == 1), abs pkt 1, abs pkt 2, abs pkt 1,
336 abs pkt 2, ..., notify packet (valid bit == 0)
337
338Absolute position for STL3888-Cx and STL3888-Dx
339===============================================
340
341::
342
343 Single Finger, Absolute Coordinate Mode (SFAC)
344 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
345 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
346 1 |0|1|0|P|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|B|F|X|X|Y|Y|
347 |---------------| |---------------| |---------------| |---------------|
348
349 Byte 1: Bit7~Bit6 => 00, Normal data packet
350 => 01, Absolute coordinates packet
351 => 10, Notify packet
352 Bit5 => Coordinate mode(always 0 in SFAC mode):
353 0: single-finger absolute coordinates (SFAC) mode
354 1: multi-finger, multiple coordinates (MFMC) mode
355 Bit4 => 0: The LEFT button is generated by on-pad command (OPC)
356 1: The LEFT button is generated by external button
357 Default is 1 even if the LEFT button is not pressed.
358 Bit3 => Always 1, as specified by PS/2 protocol.
359 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
360 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
361 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
362 Byte 2: X coordinate (xpos[9:2])
363 Byte 3: Y coordinate (ypos[9:2])
364 Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
365 Bit3~Bit2 => X coordinate (ypos[1:0])
366 Bit4 => 4th mouse button(forward one page)
367 Bit5 => 5th mouse button(backward one page)
368 Bit6 => scroll left button
369 Bit7 => scroll right button
370
371 Multi Finger, Multiple Coordinates Mode (MFMC):
372 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
373 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
374 1 |0|1|1|P|1|F|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|B|F|X|X|Y|Y|
375 |---------------| |---------------| |---------------| |---------------|
376
377 Byte 1: Bit7~Bit6 => 00, Normal data packet
378 => 01, Absolute coordination packet
379 => 10, Notify packet
380 Bit5 => Coordinate mode (always 1 in MFMC mode):
381 0: single-finger absolute coordinates (SFAC) mode
382 1: multi-finger, multiple coordinates (MFMC) mode
383 Bit4 => 0: The LEFT button is generated by on-pad command (OPC)
384 1: The LEFT button is generated by external button
385 Default is 1 even if the LEFT button is not pressed.
386 Bit3 => Always 1, as specified by PS/2 protocol.
387 Bit2 => Finger index, 0 is the first finger, 1 is the second finger.
388 If bit 1 and 0 are all 1 and bit 4 is 0, the middle external
389 button is pressed.
390 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
391 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
392 Byte 2: X coordinate (xpos[9:2])
393 Byte 3: Y coordinate (ypos[9:2])
394 Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
395 Bit3~Bit2 => X coordinate (ypos[1:0])
396 Bit4 => 4th mouse button(forward one page)
397 Bit5 => 5th mouse button(backward one page)
398 Bit6 => scroll left button
399 Bit7 => scroll right button
400
401When one of the two fingers is up, the device will output four consecutive
402MFMC#0 report packets with zero X and Y to represent 1st finger is up or
403four consecutive MFMC#1 report packets with zero X and Y to represent that
404the 2nd finger is up. On the other hand, if both fingers are up, the device
405will output four consecutive single-finger, absolute coordinate(SFAC) packets
406with zero X and Y.
407
408Notify Packet for STL3888-Cx/Dx::
409
410 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
411 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
412 1 |1|0|0|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|u|d|0|0|0|0|
413 |---------------| |---------------| |---------------| |---------------|
414
415 Byte 1: Bit7~Bit6 => 00, Normal data packet
416 => 01, Absolute coordinates packet
417 => 10, Notify packet
418 Bit5 => Always 0
419 Bit4 => 0: The LEFT button is generated by on-pad command(OPC)
420 1: The LEFT button is generated by external button
421 Default is 1 even if the LEFT button is not pressed.
422 Bit3 => 1
423 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
424 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
425 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
426 Byte 2: Message type:
427 0xba => gesture information
428 0xc0 => one finger hold-rotating gesture
429 Byte 3: The first parameter for the received message:
430 0xba => gesture ID (refer to the 'Gesture ID' section)
431 0xc0 => region ID
432 Byte 4: The second parameter for the received message:
433 0xba => N/A
434 0xc0 => finger up/down information
435
436Sample sequence of Multi-finger, Multi-coordinates mode:
437
438 notify packet (valid bit == 1), MFMC packet 1 (byte 1, bit 2 == 0),
439 MFMC packet 2 (byte 1, bit 2 == 1), MFMC packet 1, MFMC packet 2,
440 ..., notify packet (valid bit == 0)
441
442 That is, when the device is in MFMC mode, the host will receive
443 interleaved absolute coordinate packets for each finger.
444
445FSP Enable/Disable packet
446=========================
447
448::
449
450 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
451 BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
452 1 |Y|X|0|0|1|M|R|L| 2 |0|1|0|1|1|0|1|E| 3 | | | | | | | | | 4 | | | | | | | | |
453 |---------------| |---------------| |---------------| |---------------|
454
455 FSP will send out enable/disable packet when FSP receive PS/2 enable/disable
456 command. Host will receive the packet which Middle, Right, Left button will
457 be set. The packet only use byte 0 and byte 1 as a pattern of original packet.
458 Ignore the other bytes of the packet.
459
460 Byte 1: Bit7 => 0, Y overflow
461 Bit6 => 0, X overflow
462 Bit5 => 0, Y sign bit
463 Bit4 => 0, X sign bit
464 Bit3 => 1
465 Bit2 => 1, Middle Button
466 Bit1 => 1, Right Button
467 Bit0 => 1, Left Button
468 Byte 2: Bit7~1 => (0101101b)
469 Bit0 => 1 = Enable
470 0 = Disable
471 Byte 3: Don't care
472 Byte 4: Don't care (MOUSE ID 3, 4)
473 Byte 5~8: Don't care (Absolute packet)
474
475PS/2 Command Set
476================
477
478FSP supports basic PS/2 commanding set and modes, refer to following URL for
479details about PS/2 commands:
480
481http://www.computer-engineering.org/ps2mouse/
482
483Programming Sequence for Determining Packet Parsing Flow
484========================================================
485
4861. Identify FSP by reading device ID(0x00) and version(0x01) register
487
4882. For FSP version < STL3888 Cx, determine number of buttons by reading
489 the 'test mode status' (0x20) register::
490
491 buttons = reg[0x20] & 0x30
492
493 if buttons == 0x30 or buttons == 0x20:
494 # two/four buttons
495 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
496 section A for packet parsing detail(ignore byte 4, bit ~ 7)
497 elif buttons == 0x10:
498 # 6 buttons
499 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
500 section B for packet parsing detail
501 elif buttons == 0x00:
502 # 6 buttons
503 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
504 section A for packet parsing detail
505
5063. For FSP version >= STL3888 Cx:
507 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
508 section A for packet parsing detail (ignore byte 4, bit ~ 7)
509
510Programming Sequence for Register Reading/Writing
511=================================================
512
513Register inversion requirement:
514
515Following values needed to be inverted(the '~' operator in C) before being
516sent to FSP::
517
518 0xe8, 0xe9, 0xee, 0xf2, 0xf3 and 0xff.
519
520Register swapping requirement:
521
522Following values needed to have their higher 4 bits and lower 4 bits being
523swapped before being sent to FSP::
524
525 10, 20, 40, 60, 80, 100 and 200.
526
527Register reading sequence:
528
529 1. send 0xf3 PS/2 command to FSP;
530
531 2. send 0x66 PS/2 command to FSP;
532
533 3. send 0x88 PS/2 command to FSP;
534
535 4. send 0xf3 PS/2 command to FSP;
536
537 5. if the register address being to read is not required to be
538 inverted(refer to the 'Register inversion requirement' section),
539 goto step 6
540
541 a. send 0x68 PS/2 command to FSP;
542
543 b. send the inverted register address to FSP and goto step 8;
544
545 6. if the register address being to read is not required to be
546 swapped(refer to the 'Register swapping requirement' section),
547 goto step 7
548
549 a. send 0xcc PS/2 command to FSP;
550
551 b. send the swapped register address to FSP and goto step 8;
552
553 7. send 0x66 PS/2 command to FSP;
554
555 a. send the original register address to FSP and goto step 8;
556
557 8. send 0xe9(status request) PS/2 command to FSP;
558
559 9. the 4th byte of the response read from FSP should be the
560 requested register value(?? indicates don't care byte)::
561
562 host: 0xe9
563 3888: 0xfa (??) (??) (val)
564
565 * Note that since the Cx release, the hardware will return 1's
566 complement of the register value at the 3rd byte of status request
567 result::
568
569 host: 0xe9
570 3888: 0xfa (??) (~val) (val)
571
572Register writing sequence:
573
574 1. send 0xf3 PS/2 command to FSP;
575
576 2. if the register address being to write is not required to be
577 inverted(refer to the 'Register inversion requirement' section),
578 goto step 3
579
580 a. send 0x74 PS/2 command to FSP;
581
582 b. send the inverted register address to FSP and goto step 5;
583
584 3. if the register address being to write is not required to be
585 swapped(refer to the 'Register swapping requirement' section),
586 goto step 4
587
588 a. send 0x77 PS/2 command to FSP;
589
590 b. send the swapped register address to FSP and goto step 5;
591
592 4. send 0x55 PS/2 command to FSP;
593
594 a. send the register address to FSP and goto step 5;
595
596 5. send 0xf3 PS/2 command to FSP;
597
598 6. if the register value being to write is not required to be
599 inverted(refer to the 'Register inversion requirement' section),
600 goto step 7
601
602 a. send 0x47 PS/2 command to FSP;
603
604 b. send the inverted register value to FSP and goto step 9;
605
606 7. if the register value being to write is not required to be
607 swapped(refer to the 'Register swapping requirement' section),
608 goto step 8
609
610 a. send 0x44 PS/2 command to FSP;
611
612 b. send the swapped register value to FSP and goto step 9;
613
614 8. send 0x33 PS/2 command to FSP;
615
616 a. send the register value to FSP;
617
618 9. the register writing sequence is completed.
619
620 * Since the Cx release, the hardware will return 1's
621 complement of the register value at the 3rd byte of status request
622 result. Host can optionally send another 0xe9 (status request) PS/2
623 command to FSP at the end of register writing to verify that the
624 register writing operation is successful (?? indicates don't care
625 byte)::
626
627 host: 0xe9
628 3888: 0xfa (??) (~val) (val)
629
630Programming Sequence for Page Register Reading/Writing
631======================================================
632
633In order to overcome the limitation of maximum number of registers
634supported, the hardware separates register into different groups called
635'pages.' Each page is able to include up to 255 registers.
636
637The default page after power up is 0x82; therefore, if one has to get
638access to register 0x8301, one has to use following sequence to switch
639to page 0x83, then start reading/writing from/to offset 0x01 by using
640the register read/write sequence described in previous section.
641
642Page register reading sequence:
643
644 1. send 0xf3 PS/2 command to FSP;
645
646 2. send 0x66 PS/2 command to FSP;
647
648 3. send 0x88 PS/2 command to FSP;
649
650 4. send 0xf3 PS/2 command to FSP;
651
652 5. send 0x83 PS/2 command to FSP;
653
654 6. send 0x88 PS/2 command to FSP;
655
656 7. send 0xe9(status request) PS/2 command to FSP;
657
658 8. the response read from FSP should be the requested page value.
659
660
661Page register writing sequence:
662
663 1. send 0xf3 PS/2 command to FSP;
664
665 2. send 0x38 PS/2 command to FSP;
666
667 3. send 0x88 PS/2 command to FSP;
668
669 4. send 0xf3 PS/2 command to FSP;
670
671 5. if the page address being written is not required to be
672 inverted(refer to the 'Register inversion requirement' section),
673 goto step 6
674
675 a. send 0x47 PS/2 command to FSP;
676
677 b. send the inverted page address to FSP and goto step 9;
678
679 6. if the page address being written is not required to be
680 swapped(refer to the 'Register swapping requirement' section),
681 goto step 7
682
683 a. send 0x44 PS/2 command to FSP;
684
685 b. send the swapped page address to FSP and goto step 9;
686
687 7. send 0x33 PS/2 command to FSP;
688
689 8. send the page address to FSP;
690
691 9. the page register writing sequence is completed.
692
693Gesture ID
694==========
695
696Unlike other devices which sends multiple fingers' coordinates to host,
697FSP processes multiple fingers' coordinates internally and convert them
698into a 8 bits integer, namely 'Gesture ID.' Following is a list of
699supported gesture IDs:
700
701 ======= ==================================
702 ID Description
703 ======= ==================================
704 0x86 2 finger straight up
705 0x82 2 finger straight down
706 0x80 2 finger straight right
707 0x84 2 finger straight left
708 0x8f 2 finger zoom in
709 0x8b 2 finger zoom out
710 0xc0 2 finger curve, counter clockwise
711 0xc4 2 finger curve, clockwise
712 0x2e 3 finger straight up
713 0x2a 3 finger straight down
714 0x28 3 finger straight right
715 0x2c 3 finger straight left
716 0x38 palm
717 ======= ==================================
718
719Register Listing
720================
721
722Registers are represented in 16 bits values. The higher 8 bits represent
723the page address and the lower 8 bits represent the relative offset within
724that particular page. Refer to the 'Programming Sequence for Page Register
725Reading/Writing' section for instructions on how to change current page
726address::
727
728 offset width default r/w name
729 0x8200 bit7~bit0 0x01 RO device ID
730
731 0x8201 bit7~bit0 RW version ID
732 0xc1: STL3888 Ax
733 0xd0 ~ 0xd2: STL3888 Bx
734 0xe0 ~ 0xe1: STL3888 Cx
735 0xe2 ~ 0xe3: STL3888 Dx
736
737 0x8202 bit7~bit0 0x01 RO vendor ID
738
739 0x8203 bit7~bit0 0x01 RO product ID
740
741 0x8204 bit3~bit0 0x01 RW revision ID
742
743 0x820b test mode status 1
744 bit3 1 RO 0: rotate 180 degree
745 1: no rotation
746 *only supported by H/W prior to Cx
747
748 0x820f register file page control
749 bit2 0 RW 1: rotate 180 degree
750 0: no rotation
751 *supported since Cx
752
753 bit0 0 RW 1 to enable page 1 register files
754 *only supported by H/W prior to Cx
755
756 0x8210 RW system control 1
757 bit0 1 RW Reserved, must be 1
758 bit1 0 RW Reserved, must be 0
759 bit4 0 RW Reserved, must be 0
760 bit5 1 RW register clock gating enable
761 0: read only, 1: read/write enable
762 (Note that following registers does not require clock gating being
763 enabled prior to write: 05 06 07 08 09 0c 0f 10 11 12 16 17 18 23 2e
764 40 41 42 43. In addition to that, this bit must be 1 when gesture
765 mode is enabled)
766
767 0x8220 test mode status
768 bit5~bit4 RO number of buttons
769 11 => 2, lbtn/rbtn
770 10 => 4, lbtn/rbtn/scru/scrd
771 01 => 6, lbtn/rbtn/scru/scrd/scrl/scrr
772 00 => 6, lbtn/rbtn/scru/scrd/fbtn/bbtn
773 *only supported by H/W prior to Cx
774
775 0x8231 RW on-pad command detection
776 bit7 0 RW on-pad command left button down tag
777 enable
778 0: disable, 1: enable
779 *only supported by H/W prior to Cx
780
781 0x8234 RW on-pad command control 5
782 bit4~bit0 0x05 RW XLO in 0s/4/1, so 03h = 0010.1b = 2.5
783 (Note that position unit is in 0.5 scanline)
784 *only supported by H/W prior to Cx
785
786 bit7 0 RW on-pad tap zone enable
787 0: disable, 1: enable
788 *only supported by H/W prior to Cx
789
790 0x8235 RW on-pad command control 6
791 bit4~bit0 0x1d RW XHI in 0s/4/1, so 19h = 1100.1b = 12.5
792 (Note that position unit is in 0.5 scanline)
793 *only supported by H/W prior to Cx
794
795 0x8236 RW on-pad command control 7
796 bit4~bit0 0x04 RW YLO in 0s/4/1, so 03h = 0010.1b = 2.5
797 (Note that position unit is in 0.5 scanline)
798 *only supported by H/W prior to Cx
799
800 0x8237 RW on-pad command control 8
801 bit4~bit0 0x13 RW YHI in 0s/4/1, so 11h = 1000.1b = 8.5
802 (Note that position unit is in 0.5 scanline)
803 *only supported by H/W prior to Cx
804
805 0x8240 RW system control 5
806 bit1 0 RW FSP Intellimouse mode enable
807 0: disable, 1: enable
808 *only supported by H/W prior to Cx
809
810 bit2 0 RW movement + abs. coordinate mode enable
811 0: disable, 1: enable
812 (Note that this function has the functionality of bit 1 even when
813 bit 1 is not set. However, the format is different from that of bit 1.
814 In addition, when bit 1 and bit 2 are set at the same time, bit 2 will
815 override bit 1.)
816 *only supported by H/W prior to Cx
817
818 bit3 0 RW abs. coordinate only mode enable
819 0: disable, 1: enable
820 (Note that this function has the functionality of bit 1 even when
821 bit 1 is not set. However, the format is different from that of bit 1.
822 In addition, when bit 1, bit 2 and bit 3 are set at the same time,
823 bit 3 will override bit 1 and 2.)
824 *only supported by H/W prior to Cx
825
826 bit5 0 RW auto switch enable
827 0: disable, 1: enable
828 *only supported by H/W prior to Cx
829
830 bit6 0 RW G0 abs. + notify packet format enable
831 0: disable, 1: enable
832 (Note that the absolute/relative coordinate output still depends on
833 bit 2 and 3. That is, if any of those bit is 1, host will receive
834 absolute coordinates; otherwise, host only receives packets with
835 relative coordinate.)
836 *only supported by H/W prior to Cx
837
838 bit7 0 RW EN_PS2_F2: PS/2 gesture mode 2nd
839 finger packet enable
840 0: disable, 1: enable
841 *only supported by H/W prior to Cx
842
843 0x8243 RW on-pad control
844 bit0 0 RW on-pad control enable
845 0: disable, 1: enable
846 (Note that if this bit is cleared, bit 3/5 will be ineffective)
847 *only supported by H/W prior to Cx
848
849 bit3 0 RW on-pad fix vertical scrolling enable
850 0: disable, 1: enable
851 *only supported by H/W prior to Cx
852
853 bit5 0 RW on-pad fix horizontal scrolling enable
854 0: disable, 1: enable
855 *only supported by H/W prior to Cx
856
857 0x8290 RW software control register 1
858 bit0 0 RW absolute coordination mode
859 0: disable, 1: enable
860 *supported since Cx
861
862 bit1 0 RW gesture ID output
863 0: disable, 1: enable
864 *supported since Cx
865
866 bit2 0 RW two fingers' coordinates output
867 0: disable, 1: enable
868 *supported since Cx
869
870 bit3 0 RW finger up one packet output
871 0: disable, 1: enable
872 *supported since Cx
873
874 bit4 0 RW absolute coordination continuous mode
875 0: disable, 1: enable
876 *supported since Cx
877
878 bit6~bit5 00 RW gesture group selection
879 00: basic
880 01: suite
881 10: suite pro
882 11: advanced
883 *supported since Cx
884
885 bit7 0 RW Bx packet output compatible mode
886 0: disable, 1: enable
887 *supported since Cx
888 *supported since Cx
889
890
891 0x833d RW on-pad command control 1
892 bit7 1 RW on-pad command detection enable
893 0: disable, 1: enable
894 *supported since Cx
895
896 0x833e RW on-pad command detection
897 bit7 0 RW on-pad command left button down tag
898 enable. Works only in H/W based PS/2
899 data packet mode.
900 0: disable, 1: enable
901 *supported since Cx
diff --git a/Documentation/input/walkera0701.txt b/Documentation/input/devices/walkera0701.rst
index 49e3ac60dcef..2adda99ca717 100644
--- a/Documentation/input/walkera0701.txt
+++ b/Documentation/input/devices/walkera0701.rst
@@ -1,3 +1,6 @@
1===========================
2Walkera WK-0701 transmitter
3===========================
1 4
2Walkera WK-0701 transmitter is supplied with a ready to fly Walkera 5Walkera WK-0701 transmitter is supplied with a ready to fly Walkera
3helicopters such as HM36, HM37, HM60. The walkera0701 module enables to use 6helicopters such as HM36, HM37, HM60. The walkera0701 module enables to use
@@ -10,7 +13,8 @@ or use cogito:
10cg-clone http://zub.fei.tuke.sk/GIT/walkera0701-joystick 13cg-clone http://zub.fei.tuke.sk/GIT/walkera0701-joystick
11 14
12 15
13Connecting to PC: 16Connecting to PC
17================
14 18
15At back side of transmitter S-video connector can be found. Modulation 19At back side of transmitter S-video connector can be found. Modulation
16pulses from processor to HF part can be found at pin 2 of this connector, 20pulses from processor to HF part can be found at pin 2 of this connector,
@@ -19,7 +23,8 @@ modulation pulses to PC, signal pulses must be amplified.
19 23
20Cable: (walkera TX to parport) 24Cable: (walkera TX to parport)
21 25
22Walkera WK-0701 TX S-VIDEO connector: 26Walkera WK-0701 TX S-VIDEO connector::
27
23 (back side of TX) 28 (back side of TX)
24 __ __ S-video: canon25 29 __ __ S-video: canon25
25 / |_| \ pin 2 (signal) NPN parport 30 / |_| \ pin 2 (signal) NPN parport
@@ -30,10 +35,10 @@ Walkera WK-0701 TX S-VIDEO connector:
30 ------- 3 __________________________________|________________ 25 GND 35 ------- 3 __________________________________|________________ 25 GND
31 E 36 E
32 37
33
34I use green LED and BC109 NPN transistor. 38I use green LED and BC109 NPN transistor.
35 39
36Software: 40Software
41========
37 42
38Build kernel with walkera0701 module. Module walkera0701 need exclusive 43Build kernel with walkera0701 module. Module walkera0701 need exclusive
39access to parport, modules like lp must be unloaded before loading 44access to parport, modules like lp must be unloaded before loading
@@ -44,7 +49,8 @@ be changed by TX "joystick", check output from /proc/interrupts. Value for
44 49
45 50
46 51
47Technical details: 52Technical details
53=================
48 54
49Driver use interrupt from parport ACK input bit to measure pulse length 55Driver use interrupt from parport ACK input bit to measure pulse length
50using hrtimers. 56using hrtimers.
@@ -53,17 +59,29 @@ Frame format:
53Based on walkera WK-0701 PCM Format description by Shaul Eizikovich. 59Based on walkera WK-0701 PCM Format description by Shaul Eizikovich.
54(downloaded from http://www.smartpropoplus.com/Docs/Walkera_Wk-0701_PCM.pdf) 60(downloaded from http://www.smartpropoplus.com/Docs/Walkera_Wk-0701_PCM.pdf)
55 61
56Signal pulses: 62Signal pulses
57 (ANALOG) 63-------------
58 SYNC BIN OCT 64
59 +---------+ +------+ 65::
60 | | | | 66
61--+ +------+ +--- 67 (ANALOG)
68 SYNC BIN OCT
69 +---------+ +------+
70 | | | |
71 --+ +------+ +---
72
73Frame
74-----
75
76::
62 77
63Frame:
64 SYNC , BIN1, OCT1, BIN2, OCT2 ... BIN24, OCT24, BIN25, next frame SYNC .. 78 SYNC , BIN1, OCT1, BIN2, OCT2 ... BIN24, OCT24, BIN25, next frame SYNC ..
65 79
66pulse length: 80pulse length
81------------
82
83::
84
67 Binary values: Analog octal values: 85 Binary values: Analog octal values:
68 86
69 288 uS Binary 0 318 uS 000 87 288 uS Binary 0 318 uS 000
@@ -80,7 +98,8 @@ pulse length:
80(Warning, pulses on ACK are inverted by transistor, irq is raised up on sync 98(Warning, pulses on ACK are inverted by transistor, irq is raised up on sync
81to bin change or octal value to bin change). 99to bin change or octal value to bin change).
82 100
83Binary data representations: 101Binary data representations
102---------------------------
84 103
85One binary and octal value can be grouped to nibble. 24 nibbles + one binary 104One binary and octal value can be grouped to nibble. 24 nibbles + one binary
86values can be sampled between sync pulses. 105values can be sampled between sync pulses.
@@ -100,10 +119,10 @@ binary value can be sampled. This bit and magic number is not used in
100software driver. Some details about this magic numbers can be found in 119software driver. Some details about this magic numbers can be found in
101Walkera_Wk-0701_PCM.pdf. 120Walkera_Wk-0701_PCM.pdf.
102 121
103Checksum calculation: 122Checksum calculation
123--------------------
104 124
105Summary of octal values in nibbles must be same as octal value in checksum 125Summary of octal values in nibbles must be same as octal value in checksum
106nibble (only first 3 bits are used). Binary value for checksum nibble is 126nibble (only first 3 bits are used). Binary value for checksum nibble is
107calculated by sum of binary values in checked nibbles + sum of octal values 127calculated by sum of binary values in checked nibbles + sum of octal values
108in checked nibbles divided by 8. Only bit 0 of this sum is used. 128in checked nibbles divided by 8. Only bit 0 of this sum is used.
109
diff --git a/Documentation/input/xpad.txt b/Documentation/input/devices/xpad.rst
index d1b23f295db4..5a709ab77c8d 100644
--- a/Documentation/input/xpad.txt
+++ b/Documentation/input/devices/xpad.rst
@@ -1,4 +1,6 @@
1=======================================================
1xpad - Linux USB driver for Xbox compatible controllers 2xpad - Linux USB driver for Xbox compatible controllers
3=======================================================
2 4
3This driver exposes all first-party and third-party Xbox compatible 5This driver exposes all first-party and third-party Xbox compatible
4controllers. It has a long history and has enjoyed considerable usage 6controllers. It has a long history and has enjoyed considerable usage
@@ -15,9 +17,11 @@ the Xbox One's rumble protocol has not been reverse engineered but in
15the future could be supported. 17the future could be supported.
16 18
17 19
180. Notes 20Notes
19-------- 21=====
22
20The number of buttons/axes reported varies based on 3 things: 23The number of buttons/axes reported varies based on 3 things:
24
21- if you are using a known controller 25- if you are using a known controller
22- if you are using a known dance pad 26- if you are using a known dance pad
23- if using an unknown device (one not listed below), what you set in the 27- if using an unknown device (one not listed below), what you set in the
@@ -35,8 +39,9 @@ This is not true. Both dpad_to_buttons and triggers_to_buttons only affect
35unknown controllers. 39unknown controllers.
36 40
37 41
380.1 Normal Controllers 42Normal Controllers
39---------------------- 43------------------
44
40With a normal controller, the directional pad is mapped to its own X/Y axes. 45With a normal controller, the directional pad is mapped to its own X/Y axes.
41The jstest-program from joystick-1.2.15 (jstest-version 2.1.0) will report 8 46The jstest-program from joystick-1.2.15 (jstest-version 2.1.0) will report 8
42axes and 10 buttons. 47axes and 10 buttons.
@@ -55,8 +60,9 @@ in game functionality were OK. However, I find it rather difficult to
55play first person shooters with a pad. Your mileage may vary. 60play first person shooters with a pad. Your mileage may vary.
56 61
57 62
580.2 Xbox Dance Pads 63Xbox Dance Pads
59------------------- 64---------------
65
60When using a known dance pad, jstest will report 6 axes and 14 buttons. 66When using a known dance pad, jstest will report 6 axes and 14 buttons.
61 67
62For dance style pads (like the redoctane pad) several changes 68For dance style pads (like the redoctane pad) several changes
@@ -73,24 +79,21 @@ of buttons, see section 0.3 - Unknown Controllers
73I've tested this with Stepmania, and it works quite well. 79I've tested this with Stepmania, and it works quite well.
74 80
75 81
760.3 Unknown Controllers 82Unknown Controllers
77---------------------- 83-------------------
84
78If you have an unknown xbox controller, it should work just fine with 85If you have an unknown xbox controller, it should work just fine with
79the default settings. 86the default settings.
80 87
81HOWEVER if you have an unknown dance pad not listed below, it will not 88HOWEVER if you have an unknown dance pad not listed below, it will not
82work UNLESS you set "dpad_to_buttons" to 1 in the module configuration. 89work UNLESS you set "dpad_to_buttons" to 1 in the module configuration.
83 90
84PLEASE, if you have an unknown controller, email Dom <binary1230@yahoo.com> with
85a dump from /proc/bus/usb and a description of the pad (manufacturer, country,
86whether it is a dance pad or normal controller) so that we can add your pad
87to the list of supported devices, ensuring that it will work out of the
88box in the future.
89 91
92USB adapters
93============
90 94
911. USB adapters
92--------------
93All generations of Xbox controllers speak USB over the wire. 95All generations of Xbox controllers speak USB over the wire.
96
94- Original Xbox controllers use a proprietary connector and require adapters. 97- Original Xbox controllers use a proprietary connector and require adapters.
95- Wireless Xbox 360 controllers require a 'Xbox 360 Wireless Gaming Receiver 98- Wireless Xbox 360 controllers require a 'Xbox 360 Wireless Gaming Receiver
96 for Windows' 99 for Windows'
@@ -101,8 +104,9 @@ All generations of Xbox controllers speak USB over the wire.
101 104
102 105
103 106
1041.1 Original Xbox USB adapters 107Original Xbox USB adapters
105-------------- 108--------------------------
109
106Using this driver with an Original Xbox controller requires an 110Using this driver with an Original Xbox controller requires an
107adapter cable to break out the proprietary connector's pins to USB. 111adapter cable to break out the proprietary connector's pins to USB.
108You can buy these online fairly cheap, or build your own. 112You can buy these online fairly cheap, or build your own.
@@ -115,7 +119,7 @@ the controller device) with the only difference in a nonstandard connector
115You just need to solder a USB connector onto the cable and keep the 119You just need to solder a USB connector onto the cable and keep the
116yellow wire unconnected. The other pins have the same order on both 120yellow wire unconnected. The other pins have the same order on both
117connectors so there is no magic to it. Detailed info on these matters 121connectors so there is no magic to it. Detailed info on these matters
118can be found on the net ([1], [2], [3]). 122can be found on the net ([1]_, [2]_, [3]_).
119 123
120Thanks to the trip splitter found on the cable you don't even need to cut the 124Thanks to the trip splitter found on the cable you don't even need to cut the
121original one. You can buy an extension cable and cut that instead. That way, 125original one. You can buy an extension cable and cut that instead. That way,
@@ -123,22 +127,46 @@ you can still use the controller with your X-Box, if you have one ;)
123 127
124 128
125 129
1262. Driver Installation 130Driver Installation
127---------------------- 131===================
128 132
129Once you have the adapter cable, if needed, and the controller connected 133Once you have the adapter cable, if needed, and the controller connected
130the xpad module should be auto loaded. To confirm you can cat 134the xpad module should be auto loaded. To confirm you can cat
131/proc/bus/usb/devices. There should be an entry like the one at the end [4]. 135/sys/kernel/debug/usb/devices. There should be an entry like those:
136
137.. code-block:: none
138 :caption: dump from InterAct PowerPad Pro (Germany)
139
140 T: Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0
141 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs= 1
142 P: Vendor=05fd ProdID=107a Rev= 1.00
143 C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
144 I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=(none)
145 E: Ad=81(I) Atr=03(Int.) MxPS= 32 Ivl= 10ms
146 E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl= 10ms
132 147
148.. code-block:: none
149 :caption: dump from Redoctane Xbox Dance Pad (US)
133 150
151 T: Bus=01 Lev=02 Prnt=09 Port=00 Cnt=01 Dev#= 10 Spd=12 MxCh= 0
152 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
153 P: Vendor=0c12 ProdID=8809 Rev= 0.01
154 S: Product=XBOX DDR
155 C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
156 I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=xpad
157 E: Ad=82(I) Atr=03(Int.) MxPS= 32 Ivl=4ms
158 E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl=4ms
159
160
161Supported Controllers
162=====================
134 163
1353. Supported Controllers
136------------------------
137For a full list of supported controllers and associated vendor and product 164For a full list of supported controllers and associated vendor and product
138IDs see the xpad_device[] array[6]. 165IDs see the xpad_device[] array\ [4]_.
139 166
140As of the historic version 0.0.6 (2006-10-10) the following devices 167As of the historic version 0.0.6 (2006-10-10) the following devices
141were supported: 168were supported::
169
142 original Microsoft XBOX controller (US), vendor=0x045e, product=0x0202 170 original Microsoft XBOX controller (US), vendor=0x045e, product=0x0202
143 smaller Microsoft XBOX controller (US), vendor=0x045e, product=0x0289 171 smaller Microsoft XBOX controller (US), vendor=0x045e, product=0x0289
144 original Microsoft XBOX controller (Japan), vendor=0x045e, product=0x0285 172 original Microsoft XBOX controller (Japan), vendor=0x045e, product=0x0285
@@ -152,14 +180,16 @@ the module option 'dpad_to_buttons'.
152If you have an unrecognized controller please see 0.3 - Unknown Controllers 180If you have an unrecognized controller please see 0.3 - Unknown Controllers
153 181
154 182
1554. Manual Testing 183Manual Testing
156----------------- 184==============
185
157To test this driver's functionality you may use 'jstest'. 186To test this driver's functionality you may use 'jstest'.
158 187
159For example: 188For example::
160> modprobe xpad 189
161> modprobe joydev 190 > modprobe xpad
162> jstest /dev/js0 191 > modprobe joydev
192 > jstest /dev/js0
163 193
164If you're using a normal controller, there should be a single line showing 194If you're using a normal controller, there should be a single line showing
16518 inputs (8 axes, 10 buttons), and its values should change if you move 19518 inputs (8 axes, 10 buttons), and its values should change if you move
@@ -170,57 +200,34 @@ It works? Voila, you're done ;)
170 200
171 201
172 202
1735. Thanks 203Thanks
174--------- 204======
175 205
176I have to thank ITO Takayuki for the detailed info on his site 206I have to thank ITO Takayuki for the detailed info on his site
177 http://euc.jp/periphs/xbox-controller.ja.html. 207 http://euc.jp/periphs/xbox-controller.ja.html.
178 208
179His useful info and both the usb-skeleton as well as the iforce input driver 209His useful info and both the usb-skeleton as well as the iforce input driver
180(Greg Kroah-Hartmann; Vojtech Pavlik) helped a lot in rapid prototyping 210(Greg Kroah-Hartmann; Vojtech Pavlik) helped a lot in rapid prototyping
181the basic functionality. 211the basic functionality.
182 212
183 213
184 214
1856. References 215References
186------------- 216==========
187
188[1]: http://euc.jp/periphs/xbox-controller.ja.html (ITO Takayuki)
189[2]: http://xpad.xbox-scene.com/
190[3]: http://www.markosweb.com/www/xboxhackz.com/
191[4]: /proc/bus/usb/devices - dump from InterAct PowerPad Pro (Germany):
192
193T: Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0
194D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs= 1
195P: Vendor=05fd ProdID=107a Rev= 1.00
196C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
197I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=(none)
198E: Ad=81(I) Atr=03(Int.) MxPS= 32 Ivl= 10ms
199E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl= 10ms
200
201[5]: /proc/bus/usb/devices - dump from Redoctane Xbox Dance Pad (US):
202
203T: Bus=01 Lev=02 Prnt=09 Port=00 Cnt=01 Dev#= 10 Spd=12 MxCh= 0
204D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
205P: Vendor=0c12 ProdID=8809 Rev= 0.01
206S: Product=XBOX DDR
207C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
208I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=xpad
209E: Ad=82(I) Atr=03(Int.) MxPS= 32 Ivl=4ms
210E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl=4ms
211 217
212[6]: http://lxr.free-electrons.com/ident?i=xpad_device 218.. [1] http://euc.jp/periphs/xbox-controller.ja.html (ITO Takayuki)
219.. [2] http://xpad.xbox-scene.com/
220.. [3] http://www.markosweb.com/www/xboxhackz.com/
221.. [4] http://lxr.free-electrons.com/ident?i=xpad_device
213 222
214 223
224Historic Edits
225==============
215 226
2167. Historic Edits 2272002-07-16 - Marko Friedemann <mfr@bmx-chemnitz.de>
217-----------------
218Marko Friedemann <mfr@bmx-chemnitz.de>
2192002-07-16
220 - original doc 228 - original doc
221 229
222Dominic Cerquetti <binary1230@yahoo.com> 2302005-03-19 - Dominic Cerquetti <binary1230@yahoo.com>
2232005-03-19
224 - added stuff for dance pads, new d-pad->axes mappings 231 - added stuff for dance pads, new d-pad->axes mappings
225 232
226Later changes may be viewed with 'git log Documentation/input/xpad.txt' 233Later changes may be viewed with 'git log Documentation/input/xpad.txt'
diff --git a/Documentation/input/yealink.txt b/Documentation/input/devices/yealink.rst
index 8277b76ec506..bb5a1aafeca2 100644
--- a/Documentation/input/yealink.txt
+++ b/Documentation/input/devices/yealink.rst
@@ -1,8 +1,12 @@
1===============================================
1Driver documentation for yealink usb-p1k phones 2Driver documentation for yealink usb-p1k phones
3===============================================
4
5Status
6======
2 7
30. Status
4~~~~~~~~~
5The p1k is a relatively cheap usb 1.1 phone with: 8The p1k is a relatively cheap usb 1.1 phone with:
9
6 - keyboard full support, yealink.ko / input event API 10 - keyboard full support, yealink.ko / input event API
7 - LCD full support, yealink.ko / sysfs API 11 - LCD full support, yealink.ko / sysfs API
8 - LED full support, yealink.ko / sysfs API 12 - LED full support, yealink.ko / sysfs API
@@ -14,38 +18,11 @@ The p1k is a relatively cheap usb 1.1 phone with:
14For vendor documentation see http://www.yealink.com 18For vendor documentation see http://www.yealink.com
15 19
16 20
171. Compilation (stand alone version) 21keyboard features
18~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22=================
19Currently only kernel 2.6.x.y versions are supported.
20In order to build the yealink.ko module do
21
22 make
23
24If you encounter problems please check if in the MAKE_OPTS variable in
25the Makefile is pointing to the location where your kernel sources
26are located, default /usr/src/linux.
27
28
291.1 Troubleshooting
30~~~~~~~~~~~~~~~~~~~
31Q: Module yealink compiled and installed without any problem but phone
32 is not initialized and does not react to any actions.
33A: If you see something like:
34 hiddev0: USB HID v1.00 Device [Yealink Network Technology Ltd. VOIP USB Phone
35 in dmesg, it means that the hid driver has grabbed the device first. Try to
36 load module yealink before any other usb hid driver. Please see the
37 instructions provided by your distribution on module configuration.
38
39Q: Phone is working now (displays version and accepts keypad input) but I can't
40 find the sysfs files.
41A: The sysfs files are located on the particular usb endpoint. On most
42 distributions you can do: "find /sys/ -name get_icons" for a hint.
43
44 23
452. keyboard features
46~~~~~~~~~~~~~~~~~~~~
47The current mapping in the kernel is provided by the map_p1k_to_key 24The current mapping in the kernel is provided by the map_p1k_to_key
48function: 25function::
49 26
50 Physical USB-P1K button layout input events 27 Physical USB-P1K button layout input events
51 28
@@ -60,14 +37,15 @@ function:
60 7 8 9 7, 8, 9, 37 7 8 9 7, 8, 9,
61 * 0 # *, 0, #, 38 * 0 # *, 0, #,
62 39
63 The "up" and "down" keys, are symbolised by arrows on the button. 40The "up" and "down" keys, are symbolised by arrows on the button.
64 The "pickup" and "hangup" keys are symbolised by a green and red phone 41The "pickup" and "hangup" keys are symbolised by a green and red phone
65 on the button. 42on the button.
66 43
67 44
683. LCD features 45LCD features
69~~~~~~~~~~~~~~~ 46============
70The LCD is divided and organised as a 3 line display: 47
48The LCD is divided and organised as a 3 line display::
71 49
72 |[] [][] [][] [][] in |[][] 50 |[] [][] [][] [][] in |[][]
73 |[] M [][] D [][] : [][] out |[][] 51 |[] M [][] D [][] : [][] out |[][]
@@ -79,18 +57,19 @@ The LCD is divided and organised as a 3 line display:
79 [] [] [] [] [] [] [] [] [] [] [] [] 57 [] [] [] [] [] [] [] [] [] [] [] []
80 58
81 59
82Line 1 Format (see below) : 18.e8.M8.88...188 60 Line 1 Format (see below) : 18.e8.M8.88...188
83 Icon names : M D : IN OUT STORE 61 Icon names : M D : IN OUT STORE
84Line 2 Format : ......... 62 Line 2 Format : .........
85 Icon name : NEW REP SU MO TU WE TH FR SA 63 Icon name : NEW REP SU MO TU WE TH FR SA
86Line 3 Format : 888888888888 64 Line 3 Format : 888888888888
87 65
88 66
89Format description: 67Format description:
90 From a userspace perspective the world is separated into "digits" and "icons". 68 From a userspace perspective the world is separated into "digits" and "icons".
91 A digit can have a character set, an icon can only be ON or OFF. 69 A digit can have a character set, an icon can only be ON or OFF.
92 70
93 Format specifier 71 Format specifier::
72
94 '8' : Generic 7 segment digit with individual addressable segments 73 '8' : Generic 7 segment digit with individual addressable segments
95 74
96 Reduced capability 7 segment digit, when segments are hard wired together. 75 Reduced capability 7 segment digit, when segments are hard wired together.
@@ -105,9 +84,11 @@ Format description:
105 elements. 84 elements.
106 85
107 86
1084. Driver usage 87Driver usage
109~~~~~~~~~~~~~~~ 88============
110For userland the following interfaces are available using the sysfs interface: 89
90For userland the following interfaces are available using the sysfs interface::
91
111 /sys/.../ 92 /sys/.../
112 line1 Read/Write, lcd line1 93 line1 Read/Write, lcd line1
113 line2 Read/Write, lcd line2 94 line2 Read/Write, lcd line2
@@ -118,38 +99,43 @@ For userland the following interfaces are available using the sysfs interface:
118 show_icon Write, display the element by writing the icon name. 99 show_icon Write, display the element by writing the icon name.
119 100
120 map_seg7 Read/Write, the 7 segments char set, common for all 101 map_seg7 Read/Write, the 7 segments char set, common for all
121 yealink phones. (see map_to_7segment.h) 102 yealink phones. (see map_to_7segment.h)
122 103
123 ringtone Write, upload binary representation of a ringtone, 104 ringtone Write, upload binary representation of a ringtone,
124 see yealink.c. status EXPERIMENTAL due to potential 105 see yealink.c. status EXPERIMENTAL due to potential
125 races between async. and sync usb calls. 106 races between async. and sync usb calls.
126 107
127 108
1284.1 lineX 109lineX
129~~~~~~~~~ 110~~~~~
130Reading /sys/../lineX will return the format string with its current value: 111
112Reading /sys/../lineX will return the format string with its current value.
113
114 Example::
131 115
132 Example: 116 cat ./line3
133 cat ./line3 117 888888888888
134 888888888888 118 Linux Rocks!
135 Linux Rocks!
136 119
137Writing to /sys/../lineX will set the corresponding LCD line. 120Writing to /sys/../lineX will set the corresponding LCD line.
121
138 - Excess characters are ignored. 122 - Excess characters are ignored.
139 - If less characters are written than allowed, the remaining digits are 123 - If less characters are written than allowed, the remaining digits are
140 unchanged. 124 unchanged.
141 - The tab '\t'and '\n' char does not overwrite the original content. 125 - The tab '\t'and '\n' char does not overwrite the original content.
142 - Writing a space to an icon will always hide its content. 126 - Writing a space to an icon will always hide its content.
143 127
144 Example: 128 Example::
145 date +"%m.%e.%k:%M" | sed 's/^0/ /' > ./line1 129
130 date +"%m.%e.%k:%M" | sed 's/^0/ /' > ./line1
146 131
147 Will update the LCD with the current date & time. 132 Will update the LCD with the current date & time.
148 133
149 134
1504.2 get_icons 135get_icons
151~~~~~~~~~~~~~ 136~~~~~~~~~
152Reading will return all available icon names and its current settings: 137
138Reading will return all available icon names and its current settings::
153 139
154 cat ./get_icons 140 cat ./get_icons
155 on M 141 on M
@@ -172,45 +158,68 @@ Reading will return all available icon names and its current settings:
172 RINGTONE 158 RINGTONE
173 159
174 160
1754.3 show/hide icons 161show/hide icons
176~~~~~~~~~~~~~~~~~~~ 162~~~~~~~~~~~~~~~
163
177Writing to these files will update the state of the icon. 164Writing to these files will update the state of the icon.
178Only one icon at a time can be updated. 165Only one icon at a time can be updated.
179 166
180If an icon is also on a ./lineX the corresponding value is 167If an icon is also on a ./lineX the corresponding value is
181updated with the first letter of the icon. 168updated with the first letter of the icon.
182 169
183 Example - light up the store icon: 170 Example - light up the store icon::
184 echo -n "STORE" > ./show_icon 171
172 echo -n "STORE" > ./show_icon
173
174 cat ./line1
175 18.e8.M8.88...188
176 S
177
178 Example - sound the ringtone for 10 seconds::
185 179
186 cat ./line1 180 echo -n RINGTONE > /sys/..../show_icon
187 18.e8.M8.88...188 181 sleep 10
188 S 182 echo -n RINGTONE > /sys/..../hide_icon
189 183
190 Example - sound the ringtone for 10 seconds:
191 echo -n RINGTONE > /sys/..../show_icon
192 sleep 10
193 echo -n RINGTONE > /sys/..../hide_icon
194 184
185Sound features
186==============
195 187
1965. Sound features
197~~~~~~~~~~~~~~~~~
198Sound is supported by the ALSA driver: snd_usb_audio 188Sound is supported by the ALSA driver: snd_usb_audio
199 189
200One 16-bit channel with sample and playback rates of 8000 Hz is the practical 190One 16-bit channel with sample and playback rates of 8000 Hz is the practical
201limit of the device. 191limit of the device.
202 192
203 Example - recording test: 193 Example - recording test::
204 arecord -v -d 10 -r 8000 -f S16_LE -t wav foobar.wav
205 194
206 Example - playback test: 195 arecord -v -d 10 -r 8000 -f S16_LE -t wav foobar.wav
207 aplay foobar.wav
208 196
197 Example - playback test::
198
199 aplay foobar.wav
200
201
202Troubleshooting
203===============
204
205:Q: Module yealink compiled and installed without any problem but phone
206 is not initialized and does not react to any actions.
207:A: If you see something like:
208 hiddev0: USB HID v1.00 Device [Yealink Network Technology Ltd. VOIP USB Phone
209 in dmesg, it means that the hid driver has grabbed the device first. Try to
210 load module yealink before any other usb hid driver. Please see the
211 instructions provided by your distribution on module configuration.
212
213:Q: Phone is working now (displays version and accepts keypad input) but I can't
214 find the sysfs files.
215:A: The sysfs files are located on the particular usb endpoint. On most
216 distributions you can do: "find /sys/ -name get_icons" for a hint.
217
218
219Credits & Acknowledgments
220=========================
209 221
2106. Credits & Acknowledgments
211~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212 - Olivier Vandorpe, for starting the usbb2k-api project doing much of 222 - Olivier Vandorpe, for starting the usbb2k-api project doing much of
213 the reverse engineering. 223 the reverse engineering.
214 - Martin Diehl, for pointing out how to handle USB memory allocation. 224 - Martin Diehl, for pointing out how to handle USB memory allocation.
215 - Dmitry Torokhov, for the numerous code reviews and suggestions. 225 - Dmitry Torokhov, for the numerous code reviews and suggestions.
216
diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.rst
index 575415f4cef0..a8c0873beb95 100644
--- a/Documentation/input/event-codes.txt
+++ b/Documentation/input/event-codes.rst
@@ -1,3 +1,10 @@
1.. _input-event-codes:
2
3=================
4Input event codes
5=================
6
7
1The input protocol uses a map of types and codes to express input device values 8The input protocol uses a map of types and codes to express input device values
2to userspace. This document describes the types and codes and how and when they 9to userspace. This document describes the types and codes and how and when they
3may be used. 10may be used.
@@ -17,82 +24,102 @@ reports supported by a device are also provided by sysfs in
17class/input/event*/device/capabilities/, and the properties of a device are 24class/input/event*/device/capabilities/, and the properties of a device are
18provided in class/input/event*/device/properties. 25provided in class/input/event*/device/properties.
19 26
20Event types: 27Event types
21=========== 28===========
29
22Event types are groupings of codes under a logical input construct. Each 30Event types are groupings of codes under a logical input construct. Each
23type has a set of applicable codes to be used in generating events. See the 31type has a set of applicable codes to be used in generating events. See the
24Codes section for details on valid codes for each type. 32Codes section for details on valid codes for each type.
25 33
26* EV_SYN: 34* EV_SYN:
35
27 - Used as markers to separate events. Events may be separated in time or in 36 - Used as markers to separate events. Events may be separated in time or in
28 space, such as with the multitouch protocol. 37 space, such as with the multitouch protocol.
29 38
30* EV_KEY: 39* EV_KEY:
40
31 - Used to describe state changes of keyboards, buttons, or other key-like 41 - Used to describe state changes of keyboards, buttons, or other key-like
32 devices. 42 devices.
33 43
34* EV_REL: 44* EV_REL:
45
35 - Used to describe relative axis value changes, e.g. moving the mouse 5 units 46 - Used to describe relative axis value changes, e.g. moving the mouse 5 units
36 to the left. 47 to the left.
37 48
38* EV_ABS: 49* EV_ABS:
50
39 - Used to describe absolute axis value changes, e.g. describing the 51 - Used to describe absolute axis value changes, e.g. describing the
40 coordinates of a touch on a touchscreen. 52 coordinates of a touch on a touchscreen.
41 53
42* EV_MSC: 54* EV_MSC:
55
43 - Used to describe miscellaneous input data that do not fit into other types. 56 - Used to describe miscellaneous input data that do not fit into other types.
44 57
45* EV_SW: 58* EV_SW:
59
46 - Used to describe binary state input switches. 60 - Used to describe binary state input switches.
47 61
48* EV_LED: 62* EV_LED:
63
49 - Used to turn LEDs on devices on and off. 64 - Used to turn LEDs on devices on and off.
50 65
51* EV_SND: 66* EV_SND:
67
52 - Used to output sound to devices. 68 - Used to output sound to devices.
53 69
54* EV_REP: 70* EV_REP:
71
55 - Used for autorepeating devices. 72 - Used for autorepeating devices.
56 73
57* EV_FF: 74* EV_FF:
75
58 - Used to send force feedback commands to an input device. 76 - Used to send force feedback commands to an input device.
59 77
60* EV_PWR: 78* EV_PWR:
79
61 - A special type for power button and switch input. 80 - A special type for power button and switch input.
62 81
63* EV_FF_STATUS: 82* EV_FF_STATUS:
83
64 - Used to receive force feedback device status. 84 - Used to receive force feedback device status.
65 85
66Event codes: 86Event codes
67=========== 87===========
88
68Event codes define the precise type of event. 89Event codes define the precise type of event.
69 90
70EV_SYN: 91EV_SYN
71---------- 92------
93
72EV_SYN event values are undefined. Their usage is defined only by when they are 94EV_SYN event values are undefined. Their usage is defined only by when they are
73sent in the evdev event stream. 95sent in the evdev event stream.
74 96
75* SYN_REPORT: 97* SYN_REPORT:
98
76 - Used to synchronize and separate events into packets of input data changes 99 - Used to synchronize and separate events into packets of input data changes
77 occurring at the same moment in time. For example, motion of a mouse may set 100 occurring at the same moment in time. For example, motion of a mouse may set
78 the REL_X and REL_Y values for one motion, then emit a SYN_REPORT. The next 101 the REL_X and REL_Y values for one motion, then emit a SYN_REPORT. The next
79 motion will emit more REL_X and REL_Y values and send another SYN_REPORT. 102 motion will emit more REL_X and REL_Y values and send another SYN_REPORT.
80 103
81* SYN_CONFIG: 104* SYN_CONFIG:
105
82 - TBD 106 - TBD
83 107
84* SYN_MT_REPORT: 108* SYN_MT_REPORT:
109
85 - Used to synchronize and separate touch events. See the 110 - Used to synchronize and separate touch events. See the
86 multi-touch-protocol.txt document for more information. 111 multi-touch-protocol.txt document for more information.
87 112
88* SYN_DROPPED: 113* SYN_DROPPED:
114
89 - Used to indicate buffer overrun in the evdev client's event queue. 115 - Used to indicate buffer overrun in the evdev client's event queue.
90 Client should ignore all events up to and including next SYN_REPORT 116 Client should ignore all events up to and including next SYN_REPORT
91 event and query the device (using EVIOCG* ioctls) to obtain its 117 event and query the device (using EVIOCG* ioctls) to obtain its
92 current state. 118 current state.
93 119
94EV_KEY: 120EV_KEY
95---------- 121------
122
96EV_KEY events take the form KEY_<name> or BTN_<name>. For example, KEY_A is used 123EV_KEY events take the form KEY_<name> or BTN_<name>. For example, KEY_A is used
97to represent the 'A' key on a keyboard. When a key is depressed, an event with 124to represent the 'A' key on a keyboard. When a key is depressed, an event with
98the key's code is emitted with value 1. When the key is released, an event is 125the key's code is emitted with value 1. When the key is released, an event is
@@ -103,6 +130,7 @@ BTN_<name> is used for other types of momentary switch events.
103A few EV_KEY codes have special meanings: 130A few EV_KEY codes have special meanings:
104 131
105* BTN_TOOL_<name>: 132* BTN_TOOL_<name>:
133
106 - These codes are used in conjunction with input trackpads, tablets, and 134 - These codes are used in conjunction with input trackpads, tablets, and
107 touchscreens. These devices may be used with fingers, pens, or other tools. 135 touchscreens. These devices may be used with fingers, pens, or other tools.
108 When an event occurs and a tool is used, the corresponding BTN_TOOL_<name> 136 When an event occurs and a tool is used, the corresponding BTN_TOOL_<name>
@@ -112,6 +140,7 @@ A few EV_KEY codes have special meanings:
112 code when events are generated. 140 code when events are generated.
113 141
114* BTN_TOUCH: 142* BTN_TOUCH:
143
115 BTN_TOUCH is used for touch contact. While an input tool is determined to be 144 BTN_TOUCH is used for touch contact. While an input tool is determined to be
116 within meaningful physical contact, the value of this property must be set 145 within meaningful physical contact, the value of this property must be set
117 to 1. Meaningful physical contact may mean any contact, or it may mean 146 to 1. Meaningful physical contact may mean any contact, or it may mean
@@ -132,6 +161,7 @@ future, this distinction will be deprecated and the device properties ioctl
132EVIOCGPROP, defined in linux/input.h, will be used to convey the device type. 161EVIOCGPROP, defined in linux/input.h, will be used to convey the device type.
133 162
134* BTN_TOOL_FINGER, BTN_TOOL_DOUBLETAP, BTN_TOOL_TRIPLETAP, BTN_TOOL_QUADTAP: 163* BTN_TOOL_FINGER, BTN_TOOL_DOUBLETAP, BTN_TOOL_TRIPLETAP, BTN_TOOL_QUADTAP:
164
135 - These codes denote one, two, three, and four finger interaction on a 165 - These codes denote one, two, three, and four finger interaction on a
136 trackpad or touchscreen. For example, if the user uses two fingers and moves 166 trackpad or touchscreen. For example, if the user uses two fingers and moves
137 them on the touchpad in an effort to scroll content on screen, 167 them on the touchpad in an effort to scroll content on screen,
@@ -147,8 +177,9 @@ a value of 1 in the same synchronization frame. This usage is deprecated.
147Note: In multitouch drivers, the input_mt_report_finger_count() function should 177Note: In multitouch drivers, the input_mt_report_finger_count() function should
148be used to emit these codes. Please see multi-touch-protocol.txt for details. 178be used to emit these codes. Please see multi-touch-protocol.txt for details.
149 179
150EV_REL: 180EV_REL
151---------- 181------
182
152EV_REL events describe relative changes in a property. For example, a mouse may 183EV_REL events describe relative changes in a property. For example, a mouse may
153move to the left by a certain number of units, but its absolute position in 184move to the left by a certain number of units, but its absolute position in
154space is unknown. If the absolute position is known, EV_ABS codes should be used 185space is unknown. If the absolute position is known, EV_ABS codes should be used
@@ -157,17 +188,20 @@ instead of EV_REL codes.
157A few EV_REL codes have special meanings: 188A few EV_REL codes have special meanings:
158 189
159* REL_WHEEL, REL_HWHEEL: 190* REL_WHEEL, REL_HWHEEL:
191
160 - These codes are used for vertical and horizontal scroll wheels, 192 - These codes are used for vertical and horizontal scroll wheels,
161 respectively. 193 respectively.
162 194
163EV_ABS: 195EV_ABS
164---------- 196------
197
165EV_ABS events describe absolute changes in a property. For example, a touchpad 198EV_ABS events describe absolute changes in a property. For example, a touchpad
166may emit coordinates for a touch location. 199may emit coordinates for a touch location.
167 200
168A few EV_ABS codes have special meanings: 201A few EV_ABS codes have special meanings:
169 202
170* ABS_DISTANCE: 203* ABS_DISTANCE:
204
171 - Used to describe the distance of a tool from an interaction surface. This 205 - Used to describe the distance of a tool from an interaction surface. This
172 event should only be emitted while the tool is hovering, meaning in close 206 event should only be emitted while the tool is hovering, meaning in close
173 proximity of the device and while the value of the BTN_TOUCH code is 0. If 207 proximity of the device and while the value of the BTN_TOUCH code is 0. If
@@ -179,11 +213,13 @@ A few EV_ABS codes have special meanings:
179 hardware and is otherwise independent of ABS_DISTANCE and/or BTN_TOUCH. 213 hardware and is otherwise independent of ABS_DISTANCE and/or BTN_TOUCH.
180 214
181* ABS_MT_<name>: 215* ABS_MT_<name>:
216
182 - Used to describe multitouch input events. Please see 217 - Used to describe multitouch input events. Please see
183 multi-touch-protocol.txt for details. 218 multi-touch-protocol.txt for details.
184 219
185EV_SW: 220EV_SW
186---------- 221-----
222
187EV_SW events describe stateful binary switches. For example, the SW_LID code is 223EV_SW events describe stateful binary switches. For example, the SW_LID code is
188used to denote when a laptop lid is closed. 224used to denote when a laptop lid is closed.
189 225
@@ -195,14 +231,16 @@ Upon resume, if the switch state is the same as before suspend, then the input
195subsystem will filter out the duplicate switch state reports. The driver does 231subsystem will filter out the duplicate switch state reports. The driver does
196not need to keep the state of the switch at any time. 232not need to keep the state of the switch at any time.
197 233
198EV_MSC: 234EV_MSC
199---------- 235------
236
200EV_MSC events are used for input and output events that do not fall under other 237EV_MSC events are used for input and output events that do not fall under other
201categories. 238categories.
202 239
203A few EV_MSC codes have special meaning: 240A few EV_MSC codes have special meaning:
204 241
205* MSC_TIMESTAMP: 242* MSC_TIMESTAMP:
243
206 - Used to report the number of microseconds since the last reset. This event 244 - Used to report the number of microseconds since the last reset. This event
207 should be coded as an uint32 value, which is allowed to wrap around with 245 should be coded as an uint32 value, which is allowed to wrap around with
208 no special consequence. It is assumed that the time difference between two 246 no special consequence. It is assumed that the time difference between two
@@ -211,39 +249,46 @@ A few EV_MSC codes have special meaning:
211 unknown. If the device does not provide this information, the driver must 249 unknown. If the device does not provide this information, the driver must
212 not provide it to user space. 250 not provide it to user space.
213 251
214EV_LED: 252EV_LED
215---------- 253------
254
216EV_LED events are used for input and output to set and query the state of 255EV_LED events are used for input and output to set and query the state of
217various LEDs on devices. 256various LEDs on devices.
218 257
219EV_REP: 258EV_REP
220---------- 259------
260
221EV_REP events are used for specifying autorepeating events. 261EV_REP events are used for specifying autorepeating events.
222 262
223EV_SND: 263EV_SND
224---------- 264------
265
225EV_SND events are used for sending sound commands to simple sound output 266EV_SND events are used for sending sound commands to simple sound output
226devices. 267devices.
227 268
228EV_FF: 269EV_FF
229---------- 270-----
271
230EV_FF events are used to initialize a force feedback capable device and to cause 272EV_FF events are used to initialize a force feedback capable device and to cause
231such device to feedback. 273such device to feedback.
232 274
233EV_PWR: 275EV_PWR
234---------- 276------
277
235EV_PWR events are a special type of event used specifically for power 278EV_PWR events are a special type of event used specifically for power
236management. Its usage is not well defined. To be addressed later. 279management. Its usage is not well defined. To be addressed later.
237 280
238Device properties: 281Device properties
239================= 282=================
283
240Normally, userspace sets up an input device based on the data it emits, 284Normally, userspace sets up an input device based on the data it emits,
241i.e., the event types. In the case of two devices emitting the same event 285i.e., the event types. In the case of two devices emitting the same event
242types, additional information can be provided in the form of device 286types, additional information can be provided in the form of device
243properties. 287properties.
244 288
245INPUT_PROP_DIRECT + INPUT_PROP_POINTER: 289INPUT_PROP_DIRECT + INPUT_PROP_POINTER
246-------------------------------------- 290--------------------------------------
291
247The INPUT_PROP_DIRECT property indicates that device coordinates should be 292The INPUT_PROP_DIRECT property indicates that device coordinates should be
248directly mapped to screen coordinates (not taking into account trivial 293directly mapped to screen coordinates (not taking into account trivial
249transformations, such as scaling, flipping and rotating). Non-direct input 294transformations, such as scaling, flipping and rotating). Non-direct input
@@ -260,8 +305,9 @@ If neither INPUT_PROP_DIRECT or INPUT_PROP_POINTER are set, the property is
260considered undefined and the device type should be deduced in the 305considered undefined and the device type should be deduced in the
261traditional way, using emitted event types. 306traditional way, using emitted event types.
262 307
263INPUT_PROP_BUTTONPAD: 308INPUT_PROP_BUTTONPAD
264-------------------- 309--------------------
310
265For touchpads where the button is placed beneath the surface, such that 311For touchpads where the button is placed beneath the surface, such that
266pressing down on the pad causes a button click, this property should be 312pressing down on the pad causes a button click, this property should be
267set. Common in clickpad notebooks and macbooks from 2009 and onwards. 313set. Common in clickpad notebooks and macbooks from 2009 and onwards.
@@ -270,8 +316,9 @@ Originally, the buttonpad property was coded into the bcm5974 driver
270version field under the name integrated button. For backwards 316version field under the name integrated button. For backwards
271compatibility, both methods need to be checked in userspace. 317compatibility, both methods need to be checked in userspace.
272 318
273INPUT_PROP_SEMI_MT: 319INPUT_PROP_SEMI_MT
274------------------ 320------------------
321
275Some touchpads, most common between 2008 and 2011, can detect the presence 322Some touchpads, most common between 2008 and 2011, can detect the presence
276of multiple contacts without resolving the individual positions; only the 323of multiple contacts without resolving the individual positions; only the
277number of contacts and a rectangular shape is known. For such 324number of contacts and a rectangular shape is known. For such
@@ -285,9 +332,10 @@ gestures can normally be extracted from it.
285If INPUT_PROP_SEMI_MT is not set, the device is assumed to be a true MT 332If INPUT_PROP_SEMI_MT is not set, the device is assumed to be a true MT
286device. 333device.
287 334
288INPUT_PROP_TOPBUTTONPAD: 335INPUT_PROP_TOPBUTTONPAD
289----------------------- 336-----------------------
290Some laptops, most notably the Lenovo *40 series provide a trackstick 337
338Some laptops, most notably the Lenovo 40 series provide a trackstick
291device but do not have physical buttons associated with the trackstick 339device but do not have physical buttons associated with the trackstick
292device. Instead, the top area of the touchpad is marked to show 340device. Instead, the top area of the touchpad is marked to show
293visual/haptic areas for left, middle, right buttons intended to be used 341visual/haptic areas for left, middle, right buttons intended to be used
@@ -299,7 +347,8 @@ The kernel does not provide button emulation for such devices but treats
299them as any other INPUT_PROP_BUTTONPAD device. 347them as any other INPUT_PROP_BUTTONPAD device.
300 348
301INPUT_PROP_ACCELEROMETER 349INPUT_PROP_ACCELEROMETER
302------------------------- 350------------------------
351
303Directional axes on this device (absolute and/or relative x, y, z) represent 352Directional axes on this device (absolute and/or relative x, y, z) represent
304accelerometer data. Some devices also report gyroscope data, which devices 353accelerometer data. Some devices also report gyroscope data, which devices
305can report through the rotational axes (absolute and/or relative rx, ry, rz). 354can report through the rotational axes (absolute and/or relative rx, ry, rz).
@@ -307,21 +356,24 @@ can report through the rotational axes (absolute and/or relative rx, ry, rz).
307All other axes retain their meaning. A device must not mix 356All other axes retain their meaning. A device must not mix
308regular directional axes and accelerometer axes on the same event node. 357regular directional axes and accelerometer axes on the same event node.
309 358
310Guidelines: 359Guidelines
311========== 360==========
361
312The guidelines below ensure proper single-touch and multi-finger functionality. 362The guidelines below ensure proper single-touch and multi-finger functionality.
313For multi-touch functionality, see the multi-touch-protocol.txt document for 363For multi-touch functionality, see the multi-touch-protocol.txt document for
314more information. 364more information.
315 365
316Mice: 366Mice
317---------- 367----
368
318REL_{X,Y} must be reported when the mouse moves. BTN_LEFT must be used to report 369REL_{X,Y} must be reported when the mouse moves. BTN_LEFT must be used to report
319the primary button press. BTN_{MIDDLE,RIGHT,4,5,etc.} should be used to report 370the primary button press. BTN_{MIDDLE,RIGHT,4,5,etc.} should be used to report
320further buttons of the device. REL_WHEEL and REL_HWHEEL should be used to report 371further buttons of the device. REL_WHEEL and REL_HWHEEL should be used to report
321scroll wheel events where available. 372scroll wheel events where available.
322 373
323Touchscreens: 374Touchscreens
324---------- 375------------
376
325ABS_{X,Y} must be reported with the location of the touch. BTN_TOUCH must be 377ABS_{X,Y} must be reported with the location of the touch. BTN_TOUCH must be
326used to report when a touch is active on the screen. 378used to report when a touch is active on the screen.
327BTN_{MOUSE,LEFT,MIDDLE,RIGHT} must not be reported as the result of touch 379BTN_{MOUSE,LEFT,MIDDLE,RIGHT} must not be reported as the result of touch
@@ -329,8 +381,9 @@ contact. BTN_TOOL_<name> events should be reported where possible.
329 381
330For new hardware, INPUT_PROP_DIRECT should be set. 382For new hardware, INPUT_PROP_DIRECT should be set.
331 383
332Trackpads: 384Trackpads
333---------- 385---------
386
334Legacy trackpads that only provide relative position information must report 387Legacy trackpads that only provide relative position information must report
335events like mice described above. 388events like mice described above.
336 389
@@ -341,8 +394,9 @@ be used to report the number of touches active on the trackpad.
341 394
342For new hardware, INPUT_PROP_POINTER should be set. 395For new hardware, INPUT_PROP_POINTER should be set.
343 396
344Tablets: 397Tablets
345---------- 398-------
399
346BTN_TOOL_<name> events must be reported when a stylus or other tool is active on 400BTN_TOOL_<name> events must be reported when a stylus or other tool is active on
347the tablet. ABS_{X,Y} must be reported with the location of the tool. BTN_TOUCH 401the tablet. ABS_{X,Y} must be reported with the location of the tool. BTN_TOUCH
348should be used to report when the tool is in contact with the tablet. 402should be used to report when the tool is in contact with the tablet.
diff --git a/Documentation/input/ff.txt b/Documentation/input/ff.rst
index be742eec7aab..6a265a6934e6 100644
--- a/Documentation/input/ff.txt
+++ b/Documentation/input/ff.rst
@@ -1,12 +1,16 @@
1Force feedback for Linux. 1========================
2By Johann Deneux <johann.deneux@gmail.com> on 2001/04/22. 2Force feedback for Linux
3Updated by Anssi Hannula <anssi.hannula@gmail.com> on 2006/04/09. 3========================
4You may redistribute this file. Please remember to include shape.fig and 4
5interactive.fig as well. 5:Author: Johann Deneux <johann.deneux@gmail.com> on 2001/04/22.
6---------------------------------------------------------------------------- 6:Updated: Anssi Hannula <anssi.hannula@gmail.com> on 2006/04/09.
7 7
81. Introduction 8You may redistribute this file. Please remember to include shape.svg and
9~~~~~~~~~~~~~~~ 9interactive.svg as well.
10
11Introduction
12~~~~~~~~~~~~
13
10This document describes how to use force feedback devices under Linux. The 14This document describes how to use force feedback devices under Linux. The
11goal is not to support these devices as if they were simple input-only devices 15goal is not to support these devices as if they were simple input-only devices
12(as it is already the case), but to really enable the rendering of force 16(as it is already the case), but to really enable the rendering of force
@@ -15,8 +19,9 @@ This document only describes the force feedback part of the Linux input
15interface. Please read joystick.txt and input.txt before reading further this 19interface. Please read joystick.txt and input.txt before reading further this
16document. 20document.
17 21
182. Instructions to the user 22Instructions to the user
19~~~~~~~~~~~~~~~~~~~~~~~~~~~ 23~~~~~~~~~~~~~~~~~~~~~~~~
24
20To enable force feedback, you have to: 25To enable force feedback, you have to:
21 26
221. have your kernel configured with evdev and a driver that supports your 271. have your kernel configured with evdev and a driver that supports your
@@ -33,39 +38,48 @@ something goes wrong.
33If you have a serial iforce device, you need to start inputattach. See 38If you have a serial iforce device, you need to start inputattach. See
34joystick.txt for details. 39joystick.txt for details.
35 40
362.1 Does it work ? 41Does it work ?
37~~~~~~~~~~~~~~~~~~ 42--------------
38There is an utility called fftest that will allow you to test the driver. 43
39% fftest /dev/input/eventXX 44There is an utility called fftest that will allow you to test the driver::
45
46 % fftest /dev/input/eventXX
47
48Instructions to the developer
49~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40 50
413. Instructions to the developer
42~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43All interactions are done using the event API. That is, you can use ioctl() 51All interactions are done using the event API. That is, you can use ioctl()
44and write() on /dev/input/eventXX. 52and write() on /dev/input/eventXX.
45This information is subject to change. 53This information is subject to change.
46 54
473.1 Querying device capabilities 55Querying device capabilities
48~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56----------------------------
49#include <linux/input.h> 57
50#include <sys/ioctl.h> 58::
51 59
52#define BITS_TO_LONGS(x) \ 60 #include <linux/input.h>
53 (((x) + 8 * sizeof (unsigned long) - 1) / (8 * sizeof (unsigned long))) 61 #include <sys/ioctl.h>
54unsigned long features[BITS_TO_LONGS(FF_CNT)]; 62
55int ioctl(int file_descriptor, int request, unsigned long *features); 63 #define BITS_TO_LONGS(x) \
64 (((x) + 8 * sizeof (unsigned long) - 1) / (8 * sizeof (unsigned long)))
65 unsigned long features[BITS_TO_LONGS(FF_CNT)];
66 int ioctl(int file_descriptor, int request, unsigned long *features);
56 67
57"request" must be EVIOCGBIT(EV_FF, size of features array in bytes ) 68"request" must be EVIOCGBIT(EV_FF, size of features array in bytes )
58 69
59Returns the features supported by the device. features is a bitfield with the 70Returns the features supported by the device. features is a bitfield with the
60following bits: 71following bits:
72
61- FF_CONSTANT can render constant force effects 73- FF_CONSTANT can render constant force effects
62- FF_PERIODIC can render periodic effects with the following waveforms: 74- FF_PERIODIC can render periodic effects with the following waveforms:
75
63 - FF_SQUARE square waveform 76 - FF_SQUARE square waveform
64 - FF_TRIANGLE triangle waveform 77 - FF_TRIANGLE triangle waveform
65 - FF_SINE sine waveform 78 - FF_SINE sine waveform
66 - FF_SAW_UP sawtooth up waveform 79 - FF_SAW_UP sawtooth up waveform
67 - FF_SAW_DOWN sawtooth down waveform 80 - FF_SAW_DOWN sawtooth down waveform
68 - FF_CUSTOM custom waveform 81 - FF_CUSTOM custom waveform
82
69- FF_RAMP can render ramp effects 83- FF_RAMP can render ramp effects
70- FF_SPRING can simulate the presence of a spring 84- FF_SPRING can simulate the presence of a spring
71- FF_FRICTION can simulate friction 85- FF_FRICTION can simulate friction
@@ -75,24 +89,30 @@ following bits:
75- FF_GAIN gain is adjustable 89- FF_GAIN gain is adjustable
76- FF_AUTOCENTER autocenter is adjustable 90- FF_AUTOCENTER autocenter is adjustable
77 91
78Note: In most cases you should use FF_PERIODIC instead of FF_RUMBLE. All 92.. note::
93
94 - In most cases you should use FF_PERIODIC instead of FF_RUMBLE. All
79 devices that support FF_RUMBLE support FF_PERIODIC (square, triangle, 95 devices that support FF_RUMBLE support FF_PERIODIC (square, triangle,
80 sine) and the other way around. 96 sine) and the other way around.
81 97
82Note: The exact syntax FF_CUSTOM is undefined for the time being as no driver 98 - The exact syntax FF_CUSTOM is undefined for the time being as no driver
83 supports it yet. 99 supports it yet.
84 100
101::
85 102
86int ioctl(int fd, EVIOCGEFFECTS, int *n); 103 int ioctl(int fd, EVIOCGEFFECTS, int *n);
87 104
88Returns the number of effects the device can keep in its memory. 105Returns the number of effects the device can keep in its memory.
89 106
903.2 Uploading effects to the device 107Uploading effects to the device
91~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 108-------------------------------
92#include <linux/input.h> 109
93#include <sys/ioctl.h> 110::
94 111
95int ioctl(int file_descriptor, int request, struct ff_effect *effect); 112 #include <linux/input.h>
113 #include <sys/ioctl.h>
114
115 int ioctl(int file_descriptor, int request, struct ff_effect *effect);
96 116
97"request" must be EVIOCSFF. 117"request" must be EVIOCSFF.
98 118
@@ -106,38 +126,53 @@ allocate a new effect.
106 126
107Effects are file descriptor specific. 127Effects are file descriptor specific.
108 128
109See <uapi/linux/input.h> for a description of the ff_effect struct. You should 129See <uapi/linux/input.h> for a description of the ff_effect struct. You
110also find help in a few sketches, contained in files shape.fig and 130should also find help in a few sketches, contained in files shape.svg
111interactive.fig. You need xfig to visualize these files. 131and interactive.svg:
132
133.. figure:: shape.svg
112 134
1133.3 Removing an effect from the device 135 Shape
114~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 136
115int ioctl(int fd, EVIOCRMFF, effect.id); 137.. figure:: interactive.svg
138
139 Interactive
140
141
142Removing an effect from the device
143----------------------------------
144
145::
146
147 int ioctl(int fd, EVIOCRMFF, effect.id);
116 148
117This makes room for new effects in the device's memory. Note that this also 149This makes room for new effects in the device's memory. Note that this also
118stops the effect if it was playing. 150stops the effect if it was playing.
119 151
1203.4 Controlling the playback of effects 152Controlling the playback of effects
121~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 153-----------------------------------
154
122Control of playing is done with write(). Below is an example: 155Control of playing is done with write(). Below is an example:
123 156
124#include <linux/input.h> 157::
125#include <unistd.h> 158
159 #include <linux/input.h>
160 #include <unistd.h>
126 161
127 struct input_event play; 162 struct input_event play;
128 struct input_event stop; 163 struct input_event stop;
129 struct ff_effect effect; 164 struct ff_effect effect;
130 int fd; 165 int fd;
131... 166 ...
132 fd = open("/dev/input/eventXX", O_RDWR); 167 fd = open("/dev/input/eventXX", O_RDWR);
133... 168 ...
134 /* Play three times */ 169 /* Play three times */
135 play.type = EV_FF; 170 play.type = EV_FF;
136 play.code = effect.id; 171 play.code = effect.id;
137 play.value = 3; 172 play.value = 3;
138 173
139 write(fd, (const void*) &play, sizeof(play)); 174 write(fd, (const void*) &play, sizeof(play));
140... 175 ...
141 /* Stop an effect */ 176 /* Stop an effect */
142 stop.type = EV_FF; 177 stop.type = EV_FF;
143 stop.code = effect.id; 178 stop.code = effect.id;
@@ -145,43 +180,50 @@ Control of playing is done with write(). Below is an example:
145 180
146 write(fd, (const void*) &play, sizeof(stop)); 181 write(fd, (const void*) &play, sizeof(stop));
147 182
1483.5 Setting the gain 183Setting the gain
149~~~~~~~~~~~~~~~~~~~~ 184----------------
185
150Not all devices have the same strength. Therefore, users should set a gain 186Not all devices have the same strength. Therefore, users should set a gain
151factor depending on how strong they want effects to be. This setting is 187factor depending on how strong they want effects to be. This setting is
152persistent across access to the driver. 188persistent across access to the driver.
153 189
154/* Set the gain of the device 190::
155int gain; /* between 0 and 100 */ 191
156struct input_event ie; /* structure used to communicate with the driver */ 192 /* Set the gain of the device
193 int gain; /* between 0 and 100 */
194 struct input_event ie; /* structure used to communicate with the driver */
157 195
158ie.type = EV_FF; 196 ie.type = EV_FF;
159ie.code = FF_GAIN; 197 ie.code = FF_GAIN;
160ie.value = 0xFFFFUL * gain / 100; 198 ie.value = 0xFFFFUL * gain / 100;
161 199
162if (write(fd, &ie, sizeof(ie)) == -1) 200 if (write(fd, &ie, sizeof(ie)) == -1)
163 perror("set gain"); 201 perror("set gain");
164 202
1653.6 Enabling/Disabling autocenter 203Enabling/Disabling autocenter
166~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 204-----------------------------
205
167The autocenter feature quite disturbs the rendering of effects in my opinion, 206The autocenter feature quite disturbs the rendering of effects in my opinion,
168and I think it should be an effect, which computation depends on the game 207and I think it should be an effect, which computation depends on the game
169type. But you can enable it if you want. 208type. But you can enable it if you want.
170 209
171int autocenter; /* between 0 and 100 */ 210::
172struct input_event ie; 211
212 int autocenter; /* between 0 and 100 */
213 struct input_event ie;
173 214
174ie.type = EV_FF; 215 ie.type = EV_FF;
175ie.code = FF_AUTOCENTER; 216 ie.code = FF_AUTOCENTER;
176ie.value = 0xFFFFUL * autocenter / 100; 217 ie.value = 0xFFFFUL * autocenter / 100;
177 218
178if (write(fd, &ie, sizeof(ie)) == -1) 219 if (write(fd, &ie, sizeof(ie)) == -1)
179 perror("set auto-center"); 220 perror("set auto-center");
180 221
181A value of 0 means "no auto-center". 222A value of 0 means "no auto-center".
182 223
1833.7 Dynamic update of an effect 224Dynamic update of an effect
184~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 225---------------------------
226
185Proceed as if you wanted to upload a new effect, except that instead of 227Proceed as if you wanted to upload a new effect, except that instead of
186setting the id field to -1, you set it to the wanted effect id. 228setting the id field to -1, you set it to the wanted effect id.
187Normally, the effect is not stopped and restarted. However, depending on the 229Normally, the effect is not stopped and restarted. However, depending on the
@@ -192,30 +234,32 @@ case, the driver stops the effect, up-load it, and restart it.
192Therefore it is recommended to dynamically change direction while the effect 234Therefore it is recommended to dynamically change direction while the effect
193is playing only when it is ok to restart the effect with a replay count of 1. 235is playing only when it is ok to restart the effect with a replay count of 1.
194 236
1953.8 Information about the status of effects 237Information about the status of effects
196~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 238---------------------------------------
239
197Every time the status of an effect is changed, an event is sent. The values 240Every time the status of an effect is changed, an event is sent. The values
198and meanings of the fields of the event are as follows: 241and meanings of the fields of the event are as follows::
199 242
200struct input_event { 243 struct input_event {
201/* When the status of the effect changed */ 244 /* When the status of the effect changed */
202 struct timeval time; 245 struct timeval time;
203 246
204/* Set to EV_FF_STATUS */ 247 /* Set to EV_FF_STATUS */
205 unsigned short type; 248 unsigned short type;
206 249
207/* Contains the id of the effect */ 250 /* Contains the id of the effect */
208 unsigned short code; 251 unsigned short code;
209 252
210/* Indicates the status */ 253 /* Indicates the status */
211 unsigned int value; 254 unsigned int value;
212}; 255 };
213 256
214FF_STATUS_STOPPED The effect stopped playing 257 FF_STATUS_STOPPED The effect stopped playing
215FF_STATUS_PLAYING The effect started to play 258 FF_STATUS_PLAYING The effect started to play
216 259
217NOTE: Status feedback is only supported by iforce driver. If you have 260.. note::
261
262 - Status feedback is only supported by iforce driver. If you have
218 a really good reason to use this, please contact 263 a really good reason to use this, please contact
219 linux-joystick@atrey.karlin.mff.cuni.cz or anssi.hannula@gmail.com 264 linux-joystick@atrey.karlin.mff.cuni.cz or anssi.hannula@gmail.com
220 so that support for it can be added to the rest of the drivers. 265 so that support for it can be added to the rest of the drivers.
221
diff --git a/Documentation/input/gamepad.txt b/Documentation/input/gamepad.rst
index 3f6d8a5e9cdc..4d5e7fb80a84 100644
--- a/Documentation/input/gamepad.txt
+++ b/Documentation/input/gamepad.rst
@@ -1,15 +1,19 @@
1 Linux Gamepad API 1---------------------------
2---------------------------------------------------------------------------- 2Linux Gamepad Specification
3---------------------------
3 4
41. Intro 5:Author: 2013 by David Herrmann <dh.herrmann@gmail.com>
5~~~~~~~~ 6
7
8Introduction
9~~~~~~~~~~~~
6Linux provides many different input drivers for gamepad hardware. To avoid 10Linux provides many different input drivers for gamepad hardware. To avoid
7having user-space deal with different button-mappings for each gamepad, this 11having user-space deal with different button-mappings for each gamepad, this
8document defines how gamepads are supposed to report their data. 12document defines how gamepads are supposed to report their data.
9 13
102. Geometry 14Geometry
11~~~~~~~~~~~ 15~~~~~~~~
12As "gamepad" we define devices which roughly look like this: 16As "gamepad" we define devices which roughly look like this::
13 17
14 ____________________________ __ 18 ____________________________ __
15 / [__ZL__] [__ZR__] \ | 19 / [__ZL__] [__ZR__] \ |
@@ -35,6 +39,7 @@ As "gamepad" we define devices which roughly look like this:
35 Menu Pad 39 Menu Pad
36 40
37Most gamepads have the following features: 41Most gamepads have the following features:
42
38 - Action-Pad 43 - Action-Pad
39 4 buttons in diamonds-shape (on the right side). The buttons are 44 4 buttons in diamonds-shape (on the right side). The buttons are
40 differently labeled on most devices so we define them as NORTH, 45 differently labeled on most devices so we define them as NORTH,
@@ -58,8 +63,9 @@ Most gamepads have the following features:
58 Many devices provide force-feedback features. But are mostly just 63 Many devices provide force-feedback features. But are mostly just
59 simple rumble motors. 64 simple rumble motors.
60 65
613. Detection 66Detection
62~~~~~~~~~~~~ 67~~~~~~~~~
68
63All gamepads that follow the protocol described here map BTN_GAMEPAD. This is 69All gamepads that follow the protocol described here map BTN_GAMEPAD. This is
64an alias for BTN_SOUTH/BTN_A. It can be used to identify a gamepad as such. 70an alias for BTN_SOUTH/BTN_A. It can be used to identify a gamepad as such.
65However, not all gamepads provide all features, so you need to test for all 71However, not all gamepads provide all features, so you need to test for all
@@ -85,75 +91,101 @@ devices that report a small subset of the events.
85No other devices, that do not look/feel like a gamepad, shall report these 91No other devices, that do not look/feel like a gamepad, shall report these
86events. 92events.
87 93
884. Events 94Events
89~~~~~~~~~ 95~~~~~~
96
90Gamepads report the following events: 97Gamepads report the following events:
91 98
92Action-Pad: 99- Action-Pad:
100
93 Every gamepad device has at least 2 action buttons. This means, that every 101 Every gamepad device has at least 2 action buttons. This means, that every
94 device reports BTN_SOUTH (which BTN_GAMEPAD is an alias for). Regardless 102 device reports BTN_SOUTH (which BTN_GAMEPAD is an alias for). Regardless
95 of the labels on the buttons, the codes are sent according to the 103 of the labels on the buttons, the codes are sent according to the
96 physical position of the buttons. 104 physical position of the buttons.
105
97 Please note that 2- and 3-button pads are fairly rare and old. You might 106 Please note that 2- and 3-button pads are fairly rare and old. You might
98 want to filter gamepads that do not report all four. 107 want to filter gamepads that do not report all four.
99 2-Button Pad: 108
109 - 2-Button Pad:
110
100 If only 2 action-buttons are present, they are reported as BTN_SOUTH and 111 If only 2 action-buttons are present, they are reported as BTN_SOUTH and
101 BTN_EAST. For vertical layouts, the upper button is BTN_EAST. For 112 BTN_EAST. For vertical layouts, the upper button is BTN_EAST. For
102 horizontal layouts, the button more on the right is BTN_EAST. 113 horizontal layouts, the button more on the right is BTN_EAST.
103 3-Button Pad: 114
115 - 3-Button Pad:
116
104 If only 3 action-buttons are present, they are reported as (from left 117 If only 3 action-buttons are present, they are reported as (from left
105 to right): BTN_WEST, BTN_SOUTH, BTN_EAST 118 to right): BTN_WEST, BTN_SOUTH, BTN_EAST
106 If the buttons are aligned perfectly vertically, they are reported as 119 If the buttons are aligned perfectly vertically, they are reported as
107 (from top down): BTN_WEST, BTN_SOUTH, BTN_EAST 120 (from top down): BTN_WEST, BTN_SOUTH, BTN_EAST
108 4-Button Pad: 121
122 - 4-Button Pad:
123
109 If all 4 action-buttons are present, they can be aligned in two 124 If all 4 action-buttons are present, they can be aligned in two
110 different formations. If diamond-shaped, they are reported as BTN_NORTH, 125 different formations. If diamond-shaped, they are reported as BTN_NORTH,
111 BTN_WEST, BTN_SOUTH, BTN_EAST according to their physical location. 126 BTN_WEST, BTN_SOUTH, BTN_EAST according to their physical location.
112 If rectangular-shaped, the upper-left button is BTN_NORTH, lower-left 127 If rectangular-shaped, the upper-left button is BTN_NORTH, lower-left
113 is BTN_WEST, lower-right is BTN_SOUTH and upper-right is BTN_EAST. 128 is BTN_WEST, lower-right is BTN_SOUTH and upper-right is BTN_EAST.
114 129
115D-Pad: 130- D-Pad:
131
116 Every gamepad provides a D-Pad with four directions: Up, Down, Left, Right 132 Every gamepad provides a D-Pad with four directions: Up, Down, Left, Right
117 Some of these are available as digital buttons, some as analog buttons. Some 133 Some of these are available as digital buttons, some as analog buttons. Some
118 may even report both. The kernel does not convert between these so 134 may even report both. The kernel does not convert between these so
119 applications should support both and choose what is more appropriate if 135 applications should support both and choose what is more appropriate if
120 both are reported. 136 both are reported.
121 Digital buttons are reported as: 137
138 - Digital buttons are reported as:
139
122 BTN_DPAD_* 140 BTN_DPAD_*
123 Analog buttons are reported as: 141
142 - Analog buttons are reported as:
143
124 ABS_HAT0X and ABS_HAT0Y 144 ABS_HAT0X and ABS_HAT0Y
125 (for ABS values negative is left/up, positive is right/down)
126 145
127Analog-Sticks: 146 (for ABS values negative is left/up, positive is right/down)
147
148- Analog-Sticks:
149
128 The left analog-stick is reported as ABS_X, ABS_Y. The right analog stick is 150 The left analog-stick is reported as ABS_X, ABS_Y. The right analog stick is
129 reported as ABS_RX, ABS_RY. Zero, one or two sticks may be present. 151 reported as ABS_RX, ABS_RY. Zero, one or two sticks may be present.
130 If analog-sticks provide digital buttons, they are mapped accordingly as 152 If analog-sticks provide digital buttons, they are mapped accordingly as
131 BTN_THUMBL (first/left) and BTN_THUMBR (second/right). 153 BTN_THUMBL (first/left) and BTN_THUMBR (second/right).
132 (for ABS values negative is left/up, positive is right/down)
133 154
134Triggers: 155 (for ABS values negative is left/up, positive is right/down)
156
157- Triggers:
158
135 Trigger buttons can be available as digital or analog buttons or both. User- 159 Trigger buttons can be available as digital or analog buttons or both. User-
136 space must correctly deal with any situation and choose the most appropriate 160 space must correctly deal with any situation and choose the most appropriate
137 mode. 161 mode.
162
138 Upper trigger buttons are reported as BTN_TR or ABS_HAT1X (right) and BTN_TL 163 Upper trigger buttons are reported as BTN_TR or ABS_HAT1X (right) and BTN_TL
139 or ABS_HAT1Y (left). Lower trigger buttons are reported as BTN_TR2 or 164 or ABS_HAT1Y (left). Lower trigger buttons are reported as BTN_TR2 or
140 ABS_HAT2X (right/ZR) and BTN_TL2 or ABS_HAT2Y (left/ZL). 165 ABS_HAT2X (right/ZR) and BTN_TL2 or ABS_HAT2Y (left/ZL).
166
141 If only one trigger-button combination is present (upper+lower), they are 167 If only one trigger-button combination is present (upper+lower), they are
142 reported as "right" triggers (BTN_TR/ABS_HAT1X). 168 reported as "right" triggers (BTN_TR/ABS_HAT1X).
143 (ABS trigger values start at 0, pressure is reported as positive values)
144 169
145Menu-Pad: 170 (ABS trigger values start at 0, pressure is reported as positive values)
171
172- Menu-Pad:
173
146 Menu buttons are always digital and are mapped according to their location 174 Menu buttons are always digital and are mapped according to their location
147 instead of their labels. That is: 175 instead of their labels. That is:
148 1-button Pad: Mapped as BTN_START 176
149 2-button Pad: Left button mapped as BTN_SELECT, right button mapped as 177 - 1-button Pad:
150 BTN_START 178
179 Mapped as BTN_START
180
181 - 2-button Pad:
182
183 Left button mapped as BTN_SELECT, right button mapped as BTN_START
184
151 Many pads also have a third button which is branded or has a special symbol 185 Many pads also have a third button which is branded or has a special symbol
152 and meaning. Such buttons are mapped as BTN_MODE. Examples are the Nintendo 186 and meaning. Such buttons are mapped as BTN_MODE. Examples are the Nintendo
153 "HOME" button, the XBox "X"-button or Sony "PS" button. 187 "HOME" button, the XBox "X"-button or Sony "PS" button.
154 188
155Rumble: 189- Rumble:
156 Rumble is advertised as FF_RUMBLE.
157 190
158---------------------------------------------------------------------------- 191 Rumble is advertised as FF_RUMBLE.
159 Written 2013 by David Herrmann <dh.herrmann@gmail.com>
diff --git a/Documentation/input/gameport-programming.txt b/Documentation/input/gameport-programming.rst
index 03a74fc3b496..c96911df1c54 100644
--- a/Documentation/input/gameport-programming.txt
+++ b/Documentation/input/gameport-programming.rst
@@ -1,11 +1,12 @@
1~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1Programming gameport drivers 2Programming gameport drivers
2~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 4
41. A basic classic gameport 5A basic classic gameport
5~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6~~~~~~~~~~~~~~~~~~~~~~~~
6 7
7If the gameport doesn't provide more than the inb()/outb() functionality, 8If the gameport doesn't provide more than the inb()/outb() functionality,
8the code needed to register it with the joystick drivers is simple: 9the code needed to register it with the joystick drivers is simple::
9 10
10 struct gameport gameport; 11 struct gameport gameport;
11 12
@@ -37,12 +38,12 @@ space only when something really is using it. Disable it again in the
37callback, so that it doesn't fail if some of the possible addresses are 38callback, so that it doesn't fail if some of the possible addresses are
38already occupied by other gameports. 39already occupied by other gameports.
39 40
402. Memory mapped gameport 41Memory mapped gameport
41~~~~~~~~~~~~~~~~~~~~~~~~~ 42~~~~~~~~~~~~~~~~~~~~~~
42 43
43When a gameport can be accessed through MMIO, this way is preferred, because 44When a gameport can be accessed through MMIO, this way is preferred, because
44it is faster, allowing more reads per second. Registering such a gameport 45it is faster, allowing more reads per second. Registering such a gameport
45isn't as easy as a basic IO one, but not so much complex: 46isn't as easy as a basic IO one, but not so much complex::
46 47
47 struct gameport gameport; 48 struct gameport gameport;
48 49
@@ -53,19 +54,21 @@ isn't as easy as a basic IO one, but not so much complex:
53 54
54 unsigned char my_read(struct gameport *gameport) 55 unsigned char my_read(struct gameport *gameport)
55 { 56 {
56 return my_mmio; 57 return my_mmio;
57 } 58 }
58 59
59 gameport.read = my_read; 60 gameport.read = my_read;
60 gameport.trigger = my_trigger; 61 gameport.trigger = my_trigger;
61 gameport_register_port(&gameport); 62 gameport_register_port(&gameport);
62 63
633. Cooked mode gameport 64.. _gameport_pgm_cooked_mode:
64~~~~~~~~~~~~~~~~~~~~~~~ 65
66Cooked mode gameport
67~~~~~~~~~~~~~~~~~~~~
65 68
66There are gameports that can report the axis values as numbers, that means 69There are gameports that can report the axis values as numbers, that means
67the driver doesn't have to measure them the old way - an ADC is built into 70the driver doesn't have to measure them the old way - an ADC is built into
68the gameport. To register a cooked gameport: 71the gameport. To register a cooked gameport::
69 72
70 struct gameport gameport; 73 struct gameport gameport;
71 74
@@ -95,8 +98,8 @@ See analog.c and input.c for handling of fuzz - the fuzz value determines
95the size of a gaussian filter window that is used to eliminate the noise 98the size of a gaussian filter window that is used to eliminate the noise
96in the data. 99in the data.
97 100
984. More complex gameports 101More complex gameports
99~~~~~~~~~~~~~~~~~~~~~~~~~ 102~~~~~~~~~~~~~~~~~~~~~~
100 103
101Gameports can support both raw and cooked modes. In that case combine either 104Gameports can support both raw and cooked modes. In that case combine either
102examples 1+2 or 1+3. Gameports can support internal calibration - see below, 105examples 1+2 or 1+3. Gameports can support internal calibration - see below,
@@ -104,65 +107,91 @@ and also lightning.c and analog.c on how that works. If your driver supports
104more than one gameport instance simultaneously, use the ->private member of 107more than one gameport instance simultaneously, use the ->private member of
105the gameport struct to point to your data. 108the gameport struct to point to your data.
106 109
1075. Unregistering a gameport 110Unregistering a gameport
108~~~~~~~~~~~~~~~~~~~~~~~~~~~ 111~~~~~~~~~~~~~~~~~~~~~~~~
112
113Simple::
114
115 gameport_unregister_port(&gameport);
116
117The gameport structure
118~~~~~~~~~~~~~~~~~~~~~~
109 119
110Simple: 120.. note::
111 121
112gameport_unregister_port(&gameport); 122 This section is outdated. There are several fields here that don't
123 match what's there at include/linux/gameport.h.
113 124
1146. The gameport structure 125::
115~~~~~~~~~~~~~~~~~~~~~~~~~
116 126
117struct gameport { 127 struct gameport {
118 128
119 void *private; 129 void *private;
120 130
121A private pointer for free use in the gameport driver. (Not the joystick 131A private pointer for free use in the gameport driver. (Not the joystick
122driver!) 132driver!)
123 133
134::
135
124 int number; 136 int number;
125 137
126Number assigned to the gameport when registered. Informational purpose only. 138Number assigned to the gameport when registered. Informational purpose only.
127 139
140::
141
128 int io; 142 int io;
129 143
130I/O address for use with raw mode. You have to either set this, or ->read() 144I/O address for use with raw mode. You have to either set this, or ->read()
131to some value if your gameport supports raw mode. 145to some value if your gameport supports raw mode.
132 146
147::
148
133 int speed; 149 int speed;
134 150
135Raw mode speed of the gameport reads in thousands of reads per second. 151Raw mode speed of the gameport reads in thousands of reads per second.
136 152
153::
154
137 int fuzz; 155 int fuzz;
138 156
139If the gameport supports cooked mode, this should be set to a value that 157If the gameport supports cooked mode, this should be set to a value that
140represents the amount of noise in the data. See section 3. 158represents the amount of noise in the data. See
159:ref:`gameport_pgm_cooked_mode`.
160
161::
141 162
142 void (*trigger)(struct gameport *); 163 void (*trigger)(struct gameport *);
143 164
144Trigger. This function should trigger the ns558 oneshots. If set to NULL, 165Trigger. This function should trigger the ns558 oneshots. If set to NULL,
145outb(0xff, io) will be used. 166outb(0xff, io) will be used.
146 167
168::
169
147 unsigned char (*read)(struct gameport *); 170 unsigned char (*read)(struct gameport *);
148 171
149Read the buttons and ns558 oneshot bits. If set to NULL, inb(io) will be 172Read the buttons and ns558 oneshot bits. If set to NULL, inb(io) will be
150used instead. 173used instead.
151 174
152 int (*cooked_read)(struct gameport *, int *axes, int *buttons); 175::
176
177 int (*cooked_read)(struct gameport *, int *axes, int *buttons);
153 178
154If the gameport supports cooked mode, it should point this to its cooked 179If the gameport supports cooked mode, it should point this to its cooked
155read function. It should fill axes[0..3] with four values of the joystick axes 180read function. It should fill axes[0..3] with four values of the joystick axes
156and buttons[0] with four bits representing the buttons. 181and buttons[0] with four bits representing the buttons.
157 182
158 int (*calibrate)(struct gameport *, int *axes, int *max); 183::
184
185 int (*calibrate)(struct gameport *, int *axes, int *max);
159 186
160Function for calibrating the ADC hardware. When called, axes[0..3] should be 187Function for calibrating the ADC hardware. When called, axes[0..3] should be
161pre-filled by cooked data by the caller, max[0..3] should be pre-filled with 188pre-filled by cooked data by the caller, max[0..3] should be pre-filled with
162expected maximums for each axis. The calibrate() function should set the 189expected maximums for each axis. The calibrate() function should set the
163sensitivity of the ADC hardware so that the maximums fit in its range and 190sensitivity of the ADC hardware so that the maximums fit in its range and
164recompute the axes[] values to match the new sensitivity or re-read them from 191recompute the axes[] values to match the new sensitivity or re-read them from
165the hardware so that they give valid values. 192the hardware so that they give valid values.
193
194::
166 195
167 int (*open)(struct gameport *, int mode); 196 int (*open)(struct gameport *, int mode);
168 197
@@ -172,16 +201,22 @@ Second, resource allocation can happen here. The port can also be enabled
172here. Prior to this call, other fields of the gameport struct (namely the io 201here. Prior to this call, other fields of the gameport struct (namely the io
173member) need not to be valid. 202member) need not to be valid.
174 203
204::
205
175 void (*close)(struct gameport *); 206 void (*close)(struct gameport *);
176 207
177Close() should free the resources allocated by open, possibly disabling the 208Close() should free the resources allocated by open, possibly disabling the
178gameport. 209gameport.
179 210
211::
212
180 struct gameport_dev *dev; 213 struct gameport_dev *dev;
181 struct gameport *next; 214 struct gameport *next;
182 215
183For internal use by the gameport layer. 216For internal use by the gameport layer.
184 217
185}; 218::
219
220 };
186 221
187Enjoy! 222Enjoy!
diff --git a/Documentation/input/gpio-tilt.txt b/Documentation/input/gpio-tilt.txt
deleted file mode 100644
index 2cdfd9bcb1af..000000000000
--- a/Documentation/input/gpio-tilt.txt
+++ /dev/null
@@ -1,103 +0,0 @@
1Driver for tilt-switches connected via GPIOs
2============================================
3
4Generic driver to read data from tilt switches connected via gpios.
5Orientation can be provided by one or more than one tilt switches,
6i.e. each tilt switch providing one axis, and the number of axes
7is also not limited.
8
9
10Data structures:
11----------------
12
13The array of struct gpio in the gpios field is used to list the gpios
14that represent the current tilt state.
15
16The array of struct gpio_tilt_axis describes the axes that are reported
17to the input system. The values set therein are used for the
18input_set_abs_params calls needed to init the axes.
19
20The array of struct gpio_tilt_state maps gpio states to the corresponding
21values to report. The gpio state is represented as a bitfield where the
22bit-index corresponds to the index of the gpio in the struct gpio array.
23In the same manner the values stored in the axes array correspond to
24the elements of the gpio_tilt_axis-array.
25
26
27Example:
28--------
29
30Example configuration for a single TS1003 tilt switch that rotates around
31one axis in 4 steps and emits the current tilt via two GPIOs.
32
33static int sg060_tilt_enable(struct device *dev) {
34 /* code to enable the sensors */
35};
36
37static void sg060_tilt_disable(struct device *dev) {
38 /* code to disable the sensors */
39};
40
41static struct gpio sg060_tilt_gpios[] = {
42 { SG060_TILT_GPIO_SENSOR1, GPIOF_IN, "tilt_sensor1" },
43 { SG060_TILT_GPIO_SENSOR2, GPIOF_IN, "tilt_sensor2" },
44};
45
46static struct gpio_tilt_state sg060_tilt_states[] = {
47 {
48 .gpios = (0 << 1) | (0 << 0),
49 .axes = (int[]) {
50 0,
51 },
52 }, {
53 .gpios = (0 << 1) | (1 << 0),
54 .axes = (int[]) {
55 1, /* 90 degrees */
56 },
57 }, {
58 .gpios = (1 << 1) | (1 << 0),
59 .axes = (int[]) {
60 2, /* 180 degrees */
61 },
62 }, {
63 .gpios = (1 << 1) | (0 << 0),
64 .axes = (int[]) {
65 3, /* 270 degrees */
66 },
67 },
68};
69
70static struct gpio_tilt_axis sg060_tilt_axes[] = {
71 {
72 .axis = ABS_RY,
73 .min = 0,
74 .max = 3,
75 .fuzz = 0,
76 .flat = 0,
77 },
78};
79
80static struct gpio_tilt_platform_data sg060_tilt_pdata= {
81 .gpios = sg060_tilt_gpios,
82 .nr_gpios = ARRAY_SIZE(sg060_tilt_gpios),
83
84 .axes = sg060_tilt_axes,
85 .nr_axes = ARRAY_SIZE(sg060_tilt_axes),
86
87 .states = sg060_tilt_states,
88 .nr_states = ARRAY_SIZE(sg060_tilt_states),
89
90 .debounce_interval = 100,
91
92 .poll_interval = 1000,
93 .enable = sg060_tilt_enable,
94 .disable = sg060_tilt_disable,
95};
96
97static struct platform_device sg060_device_tilt = {
98 .name = "gpio-tilt-polled",
99 .id = -1,
100 .dev = {
101 .platform_data = &sg060_tilt_pdata,
102 },
103};
diff --git a/Documentation/input/iforce-protocol.txt b/Documentation/input/iforce-protocol.txt
deleted file mode 100644
index 66287151c54a..000000000000
--- a/Documentation/input/iforce-protocol.txt
+++ /dev/null
@@ -1,258 +0,0 @@
1** Introduction
2This document describes what I managed to discover about the protocol used to
3specify force effects to I-Force 2.0 devices. None of this information comes
4from Immerse. That's why you should not trust what is written in this
5document. This document is intended to help understanding the protocol.
6This is not a reference. Comments and corrections are welcome. To contact me,
7send an email to: johann.deneux@gmail.com
8
9** WARNING **
10I shall not be held responsible for any damage or harm caused if you try to
11send data to your I-Force device based on what you read in this document.
12
13** Preliminary Notes:
14All values are hexadecimal with big-endian encoding (msb on the left). Beware,
15values inside packets are encoded using little-endian. Bytes whose roles are
16unknown are marked ??? Information that needs deeper inspection is marked (?)
17
18** General form of a packet **
19This is how packets look when the device uses the rs232 to communicate.
202B OP LEN DATA CS
21CS is the checksum. It is equal to the exclusive or of all bytes.
22
23When using USB:
24OP DATA
25The 2B, LEN and CS fields have disappeared, probably because USB handles frames and
26data corruption is handled or unsignificant.
27
28First, I describe effects that are sent by the device to the computer
29
30** Device input state
31This packet is used to indicate the state of each button and the value of each
32axis
33OP= 01 for a joystick, 03 for a wheel
34LEN= Varies from device to device
3500 X-Axis lsb
3601 X-Axis msb
3702 Y-Axis lsb, or gas pedal for a wheel
3803 Y-Axis msb, or brake pedal for a wheel
3904 Throttle
4005 Buttons
4106 Lower 4 bits: Buttons
42 Upper 4 bits: Hat
4307 Rudder
44
45** Device effects states
46OP= 02
47LEN= Varies
4800 ? Bit 1 (Value 2) is the value of the deadman switch
4901 Bit 8 is set if the effect is playing. Bits 0 to 7 are the effect id.
5002 ??
5103 Address of parameter block changed (lsb)
5204 Address of parameter block changed (msb)
5305 Address of second parameter block changed (lsb)
54... depending on the number of parameter blocks updated
55
56** Force effect **
57OP= 01
58LEN= 0e
5900 Channel (when playing several effects at the same time, each must be assigned a channel)
6001 Wave form
61 Val 00 Constant
62 Val 20 Square
63 Val 21 Triangle
64 Val 22 Sine
65 Val 23 Sawtooth up
66 Val 24 Sawtooth down
67 Val 40 Spring (Force = f(pos))
68 Val 41 Friction (Force = f(velocity)) and Inertia (Force = f(acceleration))
69
70
7102 Axes affected and trigger
72 Bits 4-7: Val 2 = effect along one axis. Byte 05 indicates direction
73 Val 4 = X axis only. Byte 05 must contain 5a
74 Val 8 = Y axis only. Byte 05 must contain b4
75 Val c = X and Y axes. Bytes 05 must contain 60
76 Bits 0-3: Val 0 = No trigger
77 Val x+1 = Button x triggers the effect
78 When the whole byte is 0, cancel the previously set trigger
79
8003-04 Duration of effect (little endian encoding, in ms)
81
8205 Direction of effect, if applicable. Else, see 02 for value to assign.
83
8406-07 Minimum time between triggering.
85
8608-09 Address of periodicity or magnitude parameters
870a-0b Address of attack and fade parameters, or ffff if none.
88*or*
8908-09 Address of interactive parameters for X-axis, or ffff if not applicable
900a-0b Address of interactive parameters for Y-axis, or ffff if not applicable
91
920c-0d Delay before execution of effect (little endian encoding, in ms)
93
94
95** Time based parameters **
96
97*** Attack and fade ***
98OP= 02
99LEN= 08
10000-01 Address where to store the parameters
10102-03 Duration of attack (little endian encoding, in ms)
10204 Level at end of attack. Signed byte.
10305-06 Duration of fade.
10407 Level at end of fade.
105
106*** Magnitude ***
107OP= 03
108LEN= 03
10900-01 Address
11002 Level. Signed byte.
111
112*** Periodicity ***
113OP= 04
114LEN= 07
11500-01 Address
11602 Magnitude. Signed byte.
11703 Offset. Signed byte.
11804 Phase. Val 00 = 0 deg, Val 40 = 90 degs.
11905-06 Period (little endian encoding, in ms)
120
121** Interactive parameters **
122OP= 05
123LEN= 0a
12400-01 Address
12502 Positive Coeff
12603 Negative Coeff
12704+05 Offset (center)
12806+07 Dead band (Val 01F4 = 5000 (decimal))
12908 Positive saturation (Val 0a = 1000 (decimal) Val 64 = 10000 (decimal))
13009 Negative saturation
131
132The encoding is a bit funny here: For coeffs, these are signed values. The
133maximum value is 64 (100 decimal), the min is 9c.
134For the offset, the minimum value is FE0C, the maximum value is 01F4.
135For the deadband, the minimum value is 0, the max is 03E8.
136
137** Controls **
138OP= 41
139LEN= 03
14000 Channel
14101 Start/Stop
142 Val 00: Stop
143 Val 01: Start and play once.
144 Val 41: Start and play n times (See byte 02 below)
14502 Number of iterations n.
146
147** Init **
148
149*** Querying features ***
150OP= ff
151Query command. Length varies according to the query type.
152The general format of this packet is:
153ff 01 QUERY [INDEX] CHECKSUM
154responses are of the same form:
155FF LEN QUERY VALUE_QUERIED CHECKSUM2
156where LEN = 1 + length(VALUE_QUERIED)
157
158**** Query ram size ****
159QUERY = 42 ('B'uffer size)
160The device should reply with the same packet plus two additional bytes
161containing the size of the memory:
162ff 03 42 03 e8 CS would mean that the device has 1000 bytes of ram available.
163
164**** Query number of effects ****
165QUERY = 4e ('N'umber of effects)
166The device should respond by sending the number of effects that can be played
167at the same time (one byte)
168ff 02 4e 14 CS would stand for 20 effects.
169
170**** Vendor's id ****
171QUERY = 4d ('M'anufacturer)
172Query the vendors'id (2 bytes)
173
174**** Product id *****
175QUERY = 50 ('P'roduct)
176Query the product id (2 bytes)
177
178**** Open device ****
179QUERY = 4f ('O'pen)
180No data returned.
181
182**** Close device *****
183QUERY = 43 ('C')lose
184No data returned.
185
186**** Query effect ****
187QUERY = 45 ('E')
188Send effect type.
189Returns nonzero if supported (2 bytes)
190
191**** Firmware Version ****
192QUERY = 56 ('V'ersion)
193Sends back 3 bytes - major, minor, subminor
194
195*** Initialisation of the device ***
196
197**** Set Control ****
198!!! Device dependent, can be different on different models !!!
199OP= 40 <idx> <val> [<val>]
200LEN= 2 or 3
20100 Idx
202 Idx 00 Set dead zone (0..2048)
203 Idx 01 Ignore Deadman sensor (0..1)
204 Idx 02 Enable comm watchdog (0..1)
205 Idx 03 Set the strength of the spring (0..100)
206 Idx 04 Enable or disable the spring (0/1)
207 Idx 05 Set axis saturation threshold (0..2048)
208
209**** Set Effect State ****
210OP= 42 <val>
211LEN= 1
21200 State
213 Bit 3 Pause force feedback
214 Bit 2 Enable force feedback
215 Bit 0 Stop all effects
216
217**** Set overall gain ****
218OP= 43 <val>
219LEN= 1
22000 Gain
221 Val 00 = 0%
222 Val 40 = 50%
223 Val 80 = 100%
224
225** Parameter memory **
226
227Each device has a certain amount of memory to store parameters of effects.
228The amount of RAM may vary, I encountered values from 200 to 1000 bytes. Below
229is the amount of memory apparently needed for every set of parameters:
230 - period : 0c
231 - magnitude : 02
232 - attack and fade : 0e
233 - interactive : 08
234
235** Appendix: How to study the protocol ? **
236
2371. Generate effects using the force editor provided with the DirectX SDK, or
238use Immersion Studio (freely available at their web site in the developer section:
239www.immersion.com)
2402. Start a soft spying RS232 or USB (depending on where you connected your
241joystick/wheel). I used ComPortSpy from fCoder (alpha version!)
2423. Play the effect, and watch what happens on the spy screen.
243
244A few words about ComPortSpy:
245At first glance, this software seems, hum, well... buggy. In fact, data appear with a
246few seconds latency. Personally, I restart it every time I play an effect.
247Remember it's free (as in free beer) and alpha!
248
249** URLS **
250Check www.immerse.com for Immersion Studio, and www.fcoder.com for ComPortSpy.
251
252** Author of this document **
253Johann Deneux <johann.deneux@gmail.com>
254Home page at http://web.archive.org/web/*/http://www.esil.univ-mrs.fr
255
256Additions by Vojtech Pavlik.
257
258I-Force is trademark of Immersion Corp.
diff --git a/Documentation/input/index.rst b/Documentation/input/index.rst
new file mode 100644
index 000000000000..7a3e71c2bd00
--- /dev/null
+++ b/Documentation/input/index.rst
@@ -0,0 +1,20 @@
1=============================
2The Linux Input Documentation
3=============================
4
5Contents:
6
7.. toctree::
8 :maxdepth: 2
9 :numbered:
10
11 input_uapi
12 input_kapi
13 devices/index
14
15.. only:: subproject and html
16
17 Indices
18 =======
19
20 * :ref:`genindex`
diff --git a/Documentation/input/input-programming.txt b/Documentation/input/input-programming.rst
index c3b940baba42..45a4c6e05e39 100644
--- a/Documentation/input/input-programming.txt
+++ b/Documentation/input/input-programming.rst
@@ -1,77 +1,75 @@
1Programming input drivers 1===============================
2~~~~~~~~~~~~~~~~~~~~~~~~~ 2Creating an input device driver
3===============================
3 4
41. Creating an input device driver 5The simplest example
5~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6~~~~~~~~~~~~~~~~~~~~
6
71.0 The simplest example
8~~~~~~~~~~~~~~~~~~~~~~~~
9 7
10Here comes a very simple example of an input device driver. The device has 8Here comes a very simple example of an input device driver. The device has
11just one button and the button is accessible at i/o port BUTTON_PORT. When 9just one button and the button is accessible at i/o port BUTTON_PORT. When
12pressed or released a BUTTON_IRQ happens. The driver could look like: 10pressed or released a BUTTON_IRQ happens. The driver could look like::
13 11
14#include <linux/input.h> 12 #include <linux/input.h>
15#include <linux/module.h> 13 #include <linux/module.h>
16#include <linux/init.h> 14 #include <linux/init.h>
17 15
18#include <asm/irq.h> 16 #include <asm/irq.h>
19#include <asm/io.h> 17 #include <asm/io.h>
20 18
21static struct input_dev *button_dev; 19 static struct input_dev *button_dev;
22 20
23static irqreturn_t button_interrupt(int irq, void *dummy) 21 static irqreturn_t button_interrupt(int irq, void *dummy)
24{ 22 {
25 input_report_key(button_dev, BTN_0, inb(BUTTON_PORT) & 1); 23 input_report_key(button_dev, BTN_0, inb(BUTTON_PORT) & 1);
26 input_sync(button_dev); 24 input_sync(button_dev);
27 return IRQ_HANDLED; 25 return IRQ_HANDLED;
28} 26 }
29 27
30static int __init button_init(void) 28 static int __init button_init(void)
31{ 29 {
32 int error; 30 int error;
33 31
34 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) { 32 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) {
35 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq); 33 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq);
36 return -EBUSY; 34 return -EBUSY;
37 } 35 }
38 36
39 button_dev = input_allocate_device(); 37 button_dev = input_allocate_device();
40 if (!button_dev) { 38 if (!button_dev) {
41 printk(KERN_ERR "button.c: Not enough memory\n"); 39 printk(KERN_ERR "button.c: Not enough memory\n");
42 error = -ENOMEM; 40 error = -ENOMEM;
43 goto err_free_irq; 41 goto err_free_irq;
44 } 42 }
45 43
46 button_dev->evbit[0] = BIT_MASK(EV_KEY); 44 button_dev->evbit[0] = BIT_MASK(EV_KEY);
47 button_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0); 45 button_dev->keybit[BIT_WORD(BTN_0)] = BIT_MASK(BTN_0);
48 46
49 error = input_register_device(button_dev); 47 error = input_register_device(button_dev);
50 if (error) { 48 if (error) {
51 printk(KERN_ERR "button.c: Failed to register device\n"); 49 printk(KERN_ERR "button.c: Failed to register device\n");
52 goto err_free_dev; 50 goto err_free_dev;
53 } 51 }
54 52
55 return 0; 53 return 0;
56 54
57 err_free_dev: 55 err_free_dev:
58 input_free_device(button_dev); 56 input_free_device(button_dev);
59 err_free_irq: 57 err_free_irq:
60 free_irq(BUTTON_IRQ, button_interrupt); 58 free_irq(BUTTON_IRQ, button_interrupt);
61 return error; 59 return error;
62} 60 }
63 61
64static void __exit button_exit(void) 62 static void __exit button_exit(void)
65{ 63 {
66 input_unregister_device(button_dev); 64 input_unregister_device(button_dev);
67 free_irq(BUTTON_IRQ, button_interrupt); 65 free_irq(BUTTON_IRQ, button_interrupt);
68} 66 }
69 67
70module_init(button_init); 68 module_init(button_init);
71module_exit(button_exit); 69 module_exit(button_exit);
72 70
731.1 What the example does 71What the example does
74~~~~~~~~~~~~~~~~~~~~~~~~~ 72~~~~~~~~~~~~~~~~~~~~~
75 73
76First it has to include the <linux/input.h> file, which interfaces to the 74First it has to include the <linux/input.h> file, which interfaces to the
77input subsystem. This provides all the definitions needed. 75input subsystem. This provides all the definitions needed.
@@ -85,7 +83,7 @@ and sets up input bitfields. This way the device driver tells the other
85parts of the input systems what it is - what events can be generated or 83parts of the input systems what it is - what events can be generated or
86accepted by this input device. Our example device can only generate EV_KEY 84accepted by this input device. Our example device can only generate EV_KEY
87type events, and from those only BTN_0 event code. Thus we only set these 85type events, and from those only BTN_0 event code. Thus we only set these
88two bits. We could have used 86two bits. We could have used::
89 87
90 set_bit(EV_KEY, button_dev.evbit); 88 set_bit(EV_KEY, button_dev.evbit);
91 set_bit(BTN_0, button_dev.keybit); 89 set_bit(BTN_0, button_dev.keybit);
@@ -93,7 +91,7 @@ two bits. We could have used
93as well, but with more than single bits the first approach tends to be 91as well, but with more than single bits the first approach tends to be
94shorter. 92shorter.
95 93
96Then the example driver registers the input device structure by calling 94Then the example driver registers the input device structure by calling::
97 95
98 input_register_device(&button_dev); 96 input_register_device(&button_dev);
99 97
@@ -102,12 +100,12 @@ calls device handler modules _connect functions to tell them a new input
102device has appeared. input_register_device() may sleep and therefore must 100device has appeared. input_register_device() may sleep and therefore must
103not be called from an interrupt or with a spinlock held. 101not be called from an interrupt or with a spinlock held.
104 102
105While in use, the only used function of the driver is 103While in use, the only used function of the driver is::
106 104
107 button_interrupt() 105 button_interrupt()
108 106
109which upon every interrupt from the button checks its state and reports it 107which upon every interrupt from the button checks its state and reports it
110via the 108via the::
111 109
112 input_report_key() 110 input_report_key()
113 111
@@ -116,7 +114,7 @@ routine isn't reporting two same value events (press, press for example) to
116the input system, because the input_report_* functions check that 114the input system, because the input_report_* functions check that
117themselves. 115themselves.
118 116
119Then there is the 117Then there is the::
120 118
121 input_sync() 119 input_sync()
122 120
@@ -125,38 +123,38 @@ This doesn't seem important in the one button case, but is quite important
125for for example mouse movement, where you don't want the X and Y values 123for for example mouse movement, where you don't want the X and Y values
126to be interpreted separately, because that'd result in a different movement. 124to be interpreted separately, because that'd result in a different movement.
127 125
1281.2 dev->open() and dev->close() 126dev->open() and dev->close()
129~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 127~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130 128
131In case the driver has to repeatedly poll the device, because it doesn't 129In case the driver has to repeatedly poll the device, because it doesn't
132have an interrupt coming from it and the polling is too expensive to be done 130have an interrupt coming from it and the polling is too expensive to be done
133all the time, or if the device uses a valuable resource (eg. interrupt), it 131all the time, or if the device uses a valuable resource (eg. interrupt), it
134can use the open and close callback to know when it can stop polling or 132can use the open and close callback to know when it can stop polling or
135release the interrupt and when it must resume polling or grab the interrupt 133release the interrupt and when it must resume polling or grab the interrupt
136again. To do that, we would add this to our example driver: 134again. To do that, we would add this to our example driver::
137 135
138static int button_open(struct input_dev *dev) 136 static int button_open(struct input_dev *dev)
139{ 137 {
140 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) { 138 if (request_irq(BUTTON_IRQ, button_interrupt, 0, "button", NULL)) {
141 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq); 139 printk(KERN_ERR "button.c: Can't allocate irq %d\n", button_irq);
142 return -EBUSY; 140 return -EBUSY;
143 } 141 }
144 142
145 return 0; 143 return 0;
146} 144 }
147 145
148static void button_close(struct input_dev *dev) 146 static void button_close(struct input_dev *dev)
149{ 147 {
150 free_irq(IRQ_AMIGA_VERTB, button_interrupt); 148 free_irq(IRQ_AMIGA_VERTB, button_interrupt);
151} 149 }
152 150
153static int __init button_init(void) 151 static int __init button_init(void)
154{ 152 {
155 ... 153 ...
156 button_dev->open = button_open; 154 button_dev->open = button_open;
157 button_dev->close = button_close; 155 button_dev->close = button_close;
158 ... 156 ...
159} 157 }
160 158
161Note that input core keeps track of number of users for the device and 159Note that input core keeps track of number of users for the device and
162makes sure that dev->open() is called only when the first user connects 160makes sure that dev->open() is called only when the first user connects
@@ -166,11 +164,11 @@ disconnects. Calls to both callbacks are serialized.
166The open() callback should return a 0 in case of success or any nonzero value 164The open() callback should return a 0 in case of success or any nonzero value
167in case of failure. The close() callback (which is void) must always succeed. 165in case of failure. The close() callback (which is void) must always succeed.
168 166
1691.3 Basic event types 167Basic event types
170~~~~~~~~~~~~~~~~~~~~~ 168~~~~~~~~~~~~~~~~~
171 169
172The most simple event type is EV_KEY, which is used for keys and buttons. 170The most simple event type is EV_KEY, which is used for keys and buttons.
173It's reported to the input system via: 171It's reported to the input system via::
174 172
175 input_report_key(struct input_dev *dev, int code, int value) 173 input_report_key(struct input_dev *dev, int code, int value)
176 174
@@ -188,7 +186,7 @@ events are namely for joysticks and digitizers - devices that do work in an
188absolute coordinate systems. 186absolute coordinate systems.
189 187
190Having the device report EV_REL buttons is as simple as with EV_KEY, simply 188Having the device report EV_REL buttons is as simple as with EV_KEY, simply
191set the corresponding bits and call the 189set the corresponding bits and call the::
192 190
193 input_report_rel(struct input_dev *dev, int code, int value) 191 input_report_rel(struct input_dev *dev, int code, int value)
194 192
@@ -197,14 +195,14 @@ function. Events are generated only for nonzero value.
197However EV_ABS requires a little special care. Before calling 195However EV_ABS requires a little special care. Before calling
198input_register_device, you have to fill additional fields in the input_dev 196input_register_device, you have to fill additional fields in the input_dev
199struct for each absolute axis your device has. If our button device had also 197struct for each absolute axis your device has. If our button device had also
200the ABS_X axis: 198the ABS_X axis::
201 199
202 button_dev.absmin[ABS_X] = 0; 200 button_dev.absmin[ABS_X] = 0;
203 button_dev.absmax[ABS_X] = 255; 201 button_dev.absmax[ABS_X] = 255;
204 button_dev.absfuzz[ABS_X] = 4; 202 button_dev.absfuzz[ABS_X] = 4;
205 button_dev.absflat[ABS_X] = 8; 203 button_dev.absflat[ABS_X] = 8;
206 204
207Or, you can just say: 205Or, you can just say::
208 206
209 input_set_abs_params(button_dev, ABS_X, 0, 255, 4, 8); 207 input_set_abs_params(button_dev, ABS_X, 0, 255, 4, 8);
210 208
@@ -218,18 +216,18 @@ If you don't need absfuzz and absflat, you can set them to zero, which mean
218that the thing is precise and always returns to exactly the center position 216that the thing is precise and always returns to exactly the center position
219(if it has any). 217(if it has any).
220 218
2211.4 BITS_TO_LONGS(), BIT_WORD(), BIT_MASK() 219BITS_TO_LONGS(), BIT_WORD(), BIT_MASK()
222~~~~~~~~~~~~~~~~~~~~~~~~~~ 220~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223 221
224These three macros from bitops.h help some bitfield computations: 222These three macros from bitops.h help some bitfield computations::
225 223
226 BITS_TO_LONGS(x) - returns the length of a bitfield array in longs for 224 BITS_TO_LONGS(x) - returns the length of a bitfield array in longs for
227 x bits 225 x bits
228 BIT_WORD(x) - returns the index in the array in longs for bit x 226 BIT_WORD(x) - returns the index in the array in longs for bit x
229 BIT_MASK(x) - returns the index in a long for bit x 227 BIT_MASK(x) - returns the index in a long for bit x
230 228
2311.5 The id* and name fields 229The id* and name fields
232~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 230~~~~~~~~~~~~~~~~~~~~~~~
233 231
234The dev->name should be set before registering the input device by the input 232The dev->name should be set before registering the input device by the input
235device driver. It's a string like 'Generic button device' containing a 233device driver. It's a string like 'Generic button device' containing a
@@ -245,8 +243,8 @@ driver.
245 243
246The id and name fields can be passed to userland via the evdev interface. 244The id and name fields can be passed to userland via the evdev interface.
247 245
2481.6 The keycode, keycodemax, keycodesize fields 246The keycode, keycodemax, keycodesize fields
249~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 247~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
250 248
251These three fields should be used by input devices that have dense keymaps. 249These three fields should be used by input devices that have dense keymaps.
252The keycode is an array used to map from scancodes to input system keycodes. 250The keycode is an array used to map from scancodes to input system keycodes.
@@ -259,14 +257,15 @@ When a device has all 3 aforementioned fields filled in, the driver may
259rely on kernel's default implementation of setting and querying keycode 257rely on kernel's default implementation of setting and querying keycode
260mappings. 258mappings.
261 259
2621.7 dev->getkeycode() and dev->setkeycode() 260dev->getkeycode() and dev->setkeycode()
263~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 261~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
262
264getkeycode() and setkeycode() callbacks allow drivers to override default 263getkeycode() and setkeycode() callbacks allow drivers to override default
265keycode/keycodesize/keycodemax mapping mechanism provided by input core 264keycode/keycodesize/keycodemax mapping mechanism provided by input core
266and implement sparse keycode maps. 265and implement sparse keycode maps.
267 266
2681.8 Key autorepeat 267Key autorepeat
269~~~~~~~~~~~~~~~~~~ 268~~~~~~~~~~~~~~
270 269
271... is simple. It is handled by the input.c module. Hardware autorepeat is 270... is simple. It is handled by the input.c module. Hardware autorepeat is
272not used, because it's not present in many devices and even where it is 271not used, because it's not present in many devices and even where it is
@@ -274,29 +273,30 @@ present, it is broken sometimes (at keyboards: Toshiba notebooks). To enable
274autorepeat for your device, just set EV_REP in dev->evbit. All will be 273autorepeat for your device, just set EV_REP in dev->evbit. All will be
275handled by the input system. 274handled by the input system.
276 275
2771.9 Other event types, handling output events 276Other event types, handling output events
278~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 277~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
279 278
280The other event types up to now are: 279The other event types up to now are:
281 280
282EV_LED - used for the keyboard LEDs. 281- EV_LED - used for the keyboard LEDs.
283EV_SND - used for keyboard beeps. 282- EV_SND - used for keyboard beeps.
284 283
285They are very similar to for example key events, but they go in the other 284They are very similar to for example key events, but they go in the other
286direction - from the system to the input device driver. If your input device 285direction - from the system to the input device driver. If your input device
287driver can handle these events, it has to set the respective bits in evbit, 286driver can handle these events, it has to set the respective bits in evbit,
288*and* also the callback routine: 287*and* also the callback routine::
289 288
290 button_dev->event = button_event; 289 button_dev->event = button_event;
291 290
292int button_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); 291 int button_event(struct input_dev *dev, unsigned int type,
293{ 292 unsigned int code, int value)
294 if (type == EV_SND && code == SND_BELL) { 293 {
295 outb(value, BUTTON_BELL); 294 if (type == EV_SND && code == SND_BELL) {
296 return 0; 295 outb(value, BUTTON_BELL);
297 } 296 return 0;
298 return -1; 297 }
299} 298 return -1;
299 }
300 300
301This callback routine can be called from an interrupt or a BH (although that 301This callback routine can be called from an interrupt or a BH (although that
302isn't a rule), and thus must not sleep, and must not take too long to finish. 302isn't a rule), and thus must not sleep, and must not take too long to finish.
diff --git a/Documentation/input/input.rst b/Documentation/input/input.rst
new file mode 100644
index 000000000000..3b3a22975106
--- /dev/null
+++ b/Documentation/input/input.rst
@@ -0,0 +1,281 @@
1.. include:: <isonum.txt>
2
3============
4Introduction
5============
6
7:Copyright: |copy| 1999-2001 Vojtech Pavlik <vojtech@ucw.cz> - Sponsored by SuSE
8
9Architecture
10============
11
12Input subsystem a collection of drivers that is designed to support
13all input devices under Linux. Most of the drivers reside in
14drivers/input, although quite a few live in drivers/hid and
15drivers/platform.
16
17The core of the input subsystem is the input module, which must be
18loaded before any other of the input modules - it serves as a way of
19communication between two groups of modules:
20
21Device drivers
22--------------
23
24These modules talk to the hardware (for example via USB), and provide
25events (keystrokes, mouse movements) to the input module.
26
27Event handlers
28--------------
29
30These modules get events from input core and pass them where needed
31via various interfaces - keystrokes to the kernel, mouse movements via
32a simulated PS/2 interface to GPM and X, and so on.
33
34Simple Usage
35============
36
37For the most usual configuration, with one USB mouse and one USB keyboard,
38you'll have to load the following modules (or have them built in to the
39kernel)::
40
41 input
42 mousedev
43 usbcore
44 uhci_hcd or ohci_hcd or ehci_hcd
45 usbhid
46 hid_generic
47
48After this, the USB keyboard will work straight away, and the USB mouse
49will be available as a character device on major 13, minor 63::
50
51 crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice
52
53This device usually created automatically by the system. The commands
54to create it by hand are::
55
56 cd /dev
57 mkdir input
58 mknod input/mice c 13 63
59
60After that you have to point GPM (the textmode mouse cut&paste tool) and
61XFree to this device to use it - GPM should be called like::
62
63 gpm -t ps2 -m /dev/input/mice
64
65And in X::
66
67 Section "Pointer"
68 Protocol "ImPS/2"
69 Device "/dev/input/mice"
70 ZAxisMapping 4 5
71 EndSection
72
73When you do all of the above, you can use your USB mouse and keyboard.
74
75Detailed Description
76====================
77
78Event handlers
79--------------
80
81Event handlers distribute the events from the devices to userspace and
82in-kernel consumers, as needed.
83
84evdev
85~~~~~
86
87``evdev`` is the generic input event interface. It passes the events
88generated in the kernel straight to the program, with timestamps. The
89event codes are the same on all architectures and are hardware
90independent.
91
92This is the preferred interface for userspace to consume user
93input, and all clients are encouraged to use it.
94
95See :ref:`event-interface` for notes on API.
96
97The devices are in /dev/input::
98
99 crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0
100 crw-r--r-- 1 root root 13, 65 Apr 1 10:50 event1
101 crw-r--r-- 1 root root 13, 66 Apr 1 10:50 event2
102 crw-r--r-- 1 root root 13, 67 Apr 1 10:50 event3
103 ...
104
105There are two ranges of minors: 64 through 95 is the static legacy
106range. If there are more than 32 input devices in a system, additional
107evdev nodes are created with minors starting with 256.
108
109keyboard
110~~~~~~~~
111
112``keyboard`` is in-kernel input handler ad is a part of VT code. It
113consumes keyboard keystrokes and handles user input for VT consoles.
114
115mousedev
116~~~~~~~~
117
118``mousedev`` is a hack to make legacy programs that use mouse input
119work. It takes events from either mice or digitizers/tablets and makes
120a PS/2-style (a la /dev/psaux) mouse device available to the
121userland.
122
123Mousedev devices in /dev/input (as shown above) are::
124
125 crw-r--r-- 1 root root 13, 32 Mar 28 22:45 mouse0
126 crw-r--r-- 1 root root 13, 33 Mar 29 00:41 mouse1
127 crw-r--r-- 1 root root 13, 34 Mar 29 00:41 mouse2
128 crw-r--r-- 1 root root 13, 35 Apr 1 10:50 mouse3
129 ...
130 ...
131 crw-r--r-- 1 root root 13, 62 Apr 1 10:50 mouse30
132 crw-r--r-- 1 root root 13, 63 Apr 1 10:50 mice
133
134Each ``mouse`` device is assigned to a single mouse or digitizer, except
135the last one - ``mice``. This single character device is shared by all
136mice and digitizers, and even if none are connected, the device is
137present. This is useful for hotplugging USB mice, so that older programs
138that do not handle hotplug can open the device even when no mice are
139present.
140
141CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are
142the size of your screen (in pixels) in XFree86. This is needed if you
143want to use your digitizer in X, because its movement is sent to X
144via a virtual PS/2 mouse and thus needs to be scaled
145accordingly. These values won't be used if you use a mouse only.
146
147Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
148ExplorerPS/2 (IntelliMouse Explorer) protocols, depending on what the
149program reading the data wishes. You can set GPM and X to any of
150these. You'll need ImPS/2 if you want to make use of a wheel on a USB
151mouse and ExplorerPS/2 if you want to use extra (up to 5) buttons.
152
153joydev
154~~~~~~
155
156``joydev`` implements v0.x and v1.x Linux joystick API. See
157:ref:`joystick-api` for details.
158
159As soon as any joystick is connected, it can be accessed in /dev/input on::
160
161 crw-r--r-- 1 root root 13, 0 Apr 1 10:50 js0
162 crw-r--r-- 1 root root 13, 1 Apr 1 10:50 js1
163 crw-r--r-- 1 root root 13, 2 Apr 1 10:50 js2
164 crw-r--r-- 1 root root 13, 3 Apr 1 10:50 js3
165 ...
166
167And so on up to js31 in legacy range, and additional nodes with minors
168above 256 if there are more joystick devices.
169
170Device drivers
171--------------
172
173Device drivers are the modules that generate events.
174
175hid-generic
176~~~~~~~~~~~
177
178``hid-generic`` is one of the largest and most complex driver of the
179whole suite. It handles all HID devices, and because there is a very
180wide variety of them, and because the USB HID specification isn't
181simple, it needs to be this big.
182
183Currently, it handles USB mice, joysticks, gamepads, steering wheels
184keyboards, trackballs and digitizers.
185
186However, USB uses HID also for monitor controls, speaker controls, UPSs,
187LCDs and many other purposes.
188
189The monitor and speaker controls should be easy to add to the hid/input
190interface, but for the UPSs and LCDs it doesn't make much sense. For this,
191the hiddev interface was designed. See Documentation/hid/hiddev.txt
192for more information about it.
193
194The usage of the usbhid module is very simple, it takes no parameters,
195detects everything automatically and when a HID device is inserted, it
196detects it appropriately.
197
198However, because the devices vary wildly, you might happen to have a
199device that doesn't work well. In that case #define DEBUG at the beginning
200of hid-core.c and send me the syslog traces.
201
202usbmouse
203~~~~~~~~
204
205For embedded systems, for mice with broken HID descriptors and just any
206other use when the big usbhid wouldn't be a good choice, there is the
207usbmouse driver. It handles USB mice only. It uses a simpler HIDBP
208protocol. This also means the mice must support this simpler protocol. Not
209all do. If you don't have any strong reason to use this module, use usbhid
210instead.
211
212usbkbd
213~~~~~~
214
215Much like usbmouse, this module talks to keyboards with a simplified
216HIDBP protocol. It's smaller, but doesn't support any extra special keys.
217Use usbhid instead if there isn't any special reason to use this.
218
219psmouse
220~~~~~~~
221
222This is driver for all flavors of pointing devices using PS/2
223protocol, including Synaptics and ALPS touchpads, Intellimouse
224Explorer devices, Logitech PS/2 mice and so on.
225
226atkbd
227~~~~~
228
229This is driver for PS/2 (AT) keyboards.
230
231iforce
232~~~~~~
233
234A driver for I-Force joysticks and wheels, both over USB and RS232.
235It includes Force Feedback support now, even though Immersion
236Corp. considers the protocol a trade secret and won't disclose a word
237about it.
238
239Verifying if it works
240=====================
241
242Typing a couple keys on the keyboard should be enough to check that
243a keyboard works and is correctly connected to the kernel keyboard
244driver.
245
246Doing a ``cat /dev/input/mouse0`` (c, 13, 32) will verify that a mouse
247is also emulated; characters should appear if you move it.
248
249You can test the joystick emulation with the ``jstest`` utility,
250available in the joystick package (see :ref:`joystick-doc`).
251
252You can test the event devices with the ``evtest`` utility.
253
254.. _event-interface:
255
256Event interface
257===============
258
259You can use blocking and nonblocking reads, and also select() on the
260/dev/input/eventX devices, and you'll always get a whole number of input
261events on a read. Their layout is::
262
263 struct input_event {
264 struct timeval time;
265 unsigned short type;
266 unsigned short code;
267 unsigned int value;
268 };
269
270``time`` is the timestamp, it returns the time at which the event happened.
271Type is for example EV_REL for relative moment, EV_KEY for a keypress or
272release. More types are defined in include/uapi/linux/input-event-codes.h.
273
274``code`` is event code, for example REL_X or KEY_BACKSPACE, again a complete
275list is in include/uapi/linux/input-event-codes.h.
276
277``value`` is the value the event carries. Either a relative change for
278EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
279release, 1 for keypress and 2 for autorepeat.
280
281See :ref:`input-event-codes` for more information about various even codes.
diff --git a/Documentation/input/input.txt b/Documentation/input/input.txt
deleted file mode 100644
index 7ebce100fe90..000000000000
--- a/Documentation/input/input.txt
+++ /dev/null
@@ -1,290 +0,0 @@
1 Linux Input drivers v1.0
2 (c) 1999-2001 Vojtech Pavlik <vojtech@ucw.cz>
3 Sponsored by SuSE
4----------------------------------------------------------------------------
5
60. Disclaimer
7~~~~~~~~~~~~~
8 This program is free software; you can redistribute it and/or modify it
9under the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 2 of the License, or (at your option)
11any later version.
12
13 This program is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16more details.
17
18 You should have received a copy of the GNU General Public License along
19with this program; if not, write to the Free Software Foundation, Inc., 59
20Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Should you need to contact me, the author, you can do so either by e-mail
23- mail your message to <vojtech@ucw.cz>, or by paper mail: Vojtech Pavlik,
24Simunkova 1594, Prague 8, 182 00 Czech Republic
25
26 For your convenience, the GNU General Public License version 2 is included
27in the package: See the file COPYING.
28
291. Introduction
30~~~~~~~~~~~~~~~
31 This is a collection of drivers that is designed to support all input
32devices under Linux. While it is currently used only on for USB input
33devices, future use (say 2.5/2.6) is expected to expand to replace
34most of the existing input system, which is why it lives in
35drivers/input/ instead of drivers/usb/.
36
37 The centre of the input drivers is the input module, which must be
38loaded before any other of the input modules - it serves as a way of
39communication between two groups of modules:
40
411.1 Device drivers
42~~~~~~~~~~~~~~~~~~
43 These modules talk to the hardware (for example via USB), and provide
44events (keystrokes, mouse movements) to the input module.
45
461.2 Event handlers
47~~~~~~~~~~~~~~~~~~
48 These modules get events from input and pass them where needed via
49various interfaces - keystrokes to the kernel, mouse movements via a
50simulated PS/2 interface to GPM and X and so on.
51
522. Simple Usage
53~~~~~~~~~~~~~~~
54 For the most usual configuration, with one USB mouse and one USB keyboard,
55you'll have to load the following modules (or have them built in to the
56kernel):
57
58 input
59 mousedev
60 keybdev
61 usbcore
62 uhci_hcd or ohci_hcd or ehci_hcd
63 usbhid
64
65 After this, the USB keyboard will work straight away, and the USB mouse
66will be available as a character device on major 13, minor 63:
67
68 crw-r--r-- 1 root root 13, 63 Mar 28 22:45 mice
69
70 This device has to be created.
71 The commands to create it by hand are:
72
73 cd /dev
74 mkdir input
75 mknod input/mice c 13 63
76
77 After that you have to point GPM (the textmode mouse cut&paste tool) and
78XFree to this device to use it - GPM should be called like:
79
80 gpm -t ps2 -m /dev/input/mice
81
82 And in X:
83
84 Section "Pointer"
85 Protocol "ImPS/2"
86 Device "/dev/input/mice"
87 ZAxisMapping 4 5
88 EndSection
89
90 When you do all of the above, you can use your USB mouse and keyboard.
91
923. Detailed Description
93~~~~~~~~~~~~~~~~~~~~~~~
943.1 Device drivers
95~~~~~~~~~~~~~~~~~~
96 Device drivers are the modules that generate events. The events are
97however not useful without being handled, so you also will need to use some
98of the modules from section 3.2.
99
1003.1.1 usbhid
101~~~~~~~~~~~~
102 usbhid is the largest and most complex driver of the whole suite. It
103handles all HID devices, and because there is a very wide variety of them,
104and because the USB HID specification isn't simple, it needs to be this big.
105
106 Currently, it handles USB mice, joysticks, gamepads, steering wheels
107keyboards, trackballs and digitizers.
108
109 However, USB uses HID also for monitor controls, speaker controls, UPSs,
110LCDs and many other purposes.
111
112 The monitor and speaker controls should be easy to add to the hid/input
113interface, but for the UPSs and LCDs it doesn't make much sense. For this,
114the hiddev interface was designed. See Documentation/hid/hiddev.txt
115for more information about it.
116
117 The usage of the usbhid module is very simple, it takes no parameters,
118detects everything automatically and when a HID device is inserted, it
119detects it appropriately.
120
121 However, because the devices vary wildly, you might happen to have a
122device that doesn't work well. In that case #define DEBUG at the beginning
123of hid-core.c and send me the syslog traces.
124
1253.1.2 usbmouse
126~~~~~~~~~~~~~~
127 For embedded systems, for mice with broken HID descriptors and just any
128other use when the big usbhid wouldn't be a good choice, there is the
129usbmouse driver. It handles USB mice only. It uses a simpler HIDBP
130protocol. This also means the mice must support this simpler protocol. Not
131all do. If you don't have any strong reason to use this module, use usbhid
132instead.
133
1343.1.3 usbkbd
135~~~~~~~~~~~~
136 Much like usbmouse, this module talks to keyboards with a simplified
137HIDBP protocol. It's smaller, but doesn't support any extra special keys.
138Use usbhid instead if there isn't any special reason to use this.
139
1403.1.4 wacom
141~~~~~~~~~~~
142 This is a driver for Wacom Graphire and Intuos tablets. Not for Wacom
143PenPartner, that one is handled by the HID driver. Although the Intuos and
144Graphire tablets claim that they are HID tablets as well, they are not and
145thus need this specific driver.
146
1473.1.5 iforce
148~~~~~~~~~~~~
149 A driver for I-Force joysticks and wheels, both over USB and RS232.
150It includes ForceFeedback support now, even though Immersion
151Corp. considers the protocol a trade secret and won't disclose a word
152about it.
153
1543.2 Event handlers
155~~~~~~~~~~~~~~~~~~
156 Event handlers distribute the events from the devices to userland and
157kernel, as needed.
158
1593.2.1 keybdev
160~~~~~~~~~~~~~
161 keybdev is currently a rather ugly hack that translates the input
162events into architecture-specific keyboard raw mode (Xlated AT Set2 on
163x86), and passes them into the handle_scancode function of the
164keyboard.c module. This works well enough on all architectures that
165keybdev can generate rawmode on, other architectures can be added to
166it.
167
168 The right way would be to pass the events to keyboard.c directly,
169best if keyboard.c would itself be an event handler. This is done in
170the input patch, available on the webpage mentioned below.
171
1723.2.2 mousedev
173~~~~~~~~~~~~~~
174 mousedev is also a hack to make programs that use mouse input
175work. It takes events from either mice or digitizers/tablets and makes
176a PS/2-style (a la /dev/psaux) mouse device available to the
177userland. Ideally, the programs could use a more reasonable interface,
178for example evdev
179
180 Mousedev devices in /dev/input (as shown above) are:
181
182 crw-r--r-- 1 root root 13, 32 Mar 28 22:45 mouse0
183 crw-r--r-- 1 root root 13, 33 Mar 29 00:41 mouse1
184 crw-r--r-- 1 root root 13, 34 Mar 29 00:41 mouse2
185 crw-r--r-- 1 root root 13, 35 Apr 1 10:50 mouse3
186 ...
187 ...
188 crw-r--r-- 1 root root 13, 62 Apr 1 10:50 mouse30
189 crw-r--r-- 1 root root 13, 63 Apr 1 10:50 mice
190
191Each 'mouse' device is assigned to a single mouse or digitizer, except
192the last one - 'mice'. This single character device is shared by all
193mice and digitizers, and even if none are connected, the device is
194present. This is useful for hotplugging USB mice, so that programs
195can open the device even when no mice are present.
196
197 CONFIG_INPUT_MOUSEDEV_SCREEN_[XY] in the kernel configuration are
198the size of your screen (in pixels) in XFree86. This is needed if you
199want to use your digitizer in X, because its movement is sent to X
200via a virtual PS/2 mouse and thus needs to be scaled
201accordingly. These values won't be used if you use a mouse only.
202
203 Mousedev will generate either PS/2, ImPS/2 (Microsoft IntelliMouse) or
204ExplorerPS/2 (IntelliMouse Explorer) protocols, depending on what the
205program reading the data wishes. You can set GPM and X to any of
206these. You'll need ImPS/2 if you want to make use of a wheel on a USB
207mouse and ExplorerPS/2 if you want to use extra (up to 5) buttons.
208
2093.2.3 joydev
210~~~~~~~~~~~~
211 Joydev implements v0.x and v1.x Linux joystick api, much like
212drivers/char/joystick/joystick.c used to in earlier versions. See
213joystick-api.txt in the Documentation subdirectory for details. As
214soon as any joystick is connected, it can be accessed in /dev/input
215on:
216
217 crw-r--r-- 1 root root 13, 0 Apr 1 10:50 js0
218 crw-r--r-- 1 root root 13, 1 Apr 1 10:50 js1
219 crw-r--r-- 1 root root 13, 2 Apr 1 10:50 js2
220 crw-r--r-- 1 root root 13, 3 Apr 1 10:50 js3
221 ...
222
223And so on up to js31.
224
2253.2.4 evdev
226~~~~~~~~~~~
227 evdev is the generic input event interface. It passes the events
228generated in the kernel straight to the program, with timestamps. The
229API is still evolving, but should be usable now. It's described in
230section 5.
231
232 This should be the way for GPM and X to get keyboard and mouse
233events. It allows for multihead in X without any specific multihead
234kernel support. The event codes are the same on all architectures and
235are hardware independent.
236
237 The devices are in /dev/input:
238
239 crw-r--r-- 1 root root 13, 64 Apr 1 10:49 event0
240 crw-r--r-- 1 root root 13, 65 Apr 1 10:50 event1
241 crw-r--r-- 1 root root 13, 66 Apr 1 10:50 event2
242 crw-r--r-- 1 root root 13, 67 Apr 1 10:50 event3
243 ...
244
245And so on up to event31.
246
2474. Verifying if it works
248~~~~~~~~~~~~~~~~~~~~~~~~
249 Typing a couple keys on the keyboard should be enough to check that
250a USB keyboard works and is correctly connected to the kernel keyboard
251driver.
252
253 Doing a "cat /dev/input/mouse0" (c, 13, 32) will verify that a mouse
254is also emulated; characters should appear if you move it.
255
256 You can test the joystick emulation with the 'jstest' utility,
257available in the joystick package (see Documentation/input/joystick.txt).
258
259 You can test the event devices with the 'evtest' utility available
260in the LinuxConsole project CVS archive (see the URL below).
261
2625. Event interface
263~~~~~~~~~~~~~~~~~~
264 Should you want to add event device support into any application (X, gpm,
265svgalib ...) I <vojtech@ucw.cz> will be happy to provide you any help I
266can. Here goes a description of the current state of things, which is going
267to be extended, but not changed incompatibly as time goes:
268
269 You can use blocking and nonblocking reads, also select() on the
270/dev/input/eventX devices, and you'll always get a whole number of input
271events on a read. Their layout is:
272
273struct input_event {
274 struct timeval time;
275 unsigned short type;
276 unsigned short code;
277 unsigned int value;
278};
279
280 'time' is the timestamp, it returns the time at which the event happened.
281Type is for example EV_REL for relative moment, EV_KEY for a keypress or
282release. More types are defined in include/uapi/linux/input-event-codes.h.
283
284 'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete
285list is in include/uapi/linux/input-event-codes.h.
286
287 'value' is the value the event carries. Either a relative change for
288EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
289release, 1 for keypress and 2 for autorepeat.
290
diff --git a/Documentation/input/input_kapi.rst b/Documentation/input/input_kapi.rst
new file mode 100644
index 000000000000..41f1b7e6b78e
--- /dev/null
+++ b/Documentation/input/input_kapi.rst
@@ -0,0 +1,17 @@
1.. include:: <isonum.txt>
2
3################################
4Linux Input Subsystem kernel API
5################################
6
7.. class:: toc-title
8
9 Table of Contents
10
11.. toctree::
12 :maxdepth: 2
13 :numbered:
14
15 input-programming
16 gameport-programming
17 notifier
diff --git a/Documentation/input/input_uapi.rst b/Documentation/input/input_uapi.rst
new file mode 100644
index 000000000000..4a0391609327
--- /dev/null
+++ b/Documentation/input/input_uapi.rst
@@ -0,0 +1,22 @@
1.. include:: <isonum.txt>
2
3###################################
4Linux Input Subsystem userspace API
5###################################
6
7.. class:: toc-title
8
9 Table of Contents
10
11.. toctree::
12 :maxdepth: 2
13 :numbered:
14
15 input
16 event-codes
17 multi-touch-protocol
18 gamepad
19 ff
20 joydev/index
21 uinput
22 userio
diff --git a/Documentation/input/interactive.fig b/Documentation/input/interactive.fig
deleted file mode 100644
index 1e7de387723a..000000000000
--- a/Documentation/input/interactive.fig
+++ /dev/null
@@ -1,42 +0,0 @@
1#FIG 3.2
2Landscape
3Center
4Inches
5Letter
6100.00
7Single
8-2
91200 2
102 1 0 2 0 7 50 0 -1 6.000 0 0 -1 0 0 6
11 1200 3600 1800 3600 2400 4800 3000 4800 4200 5700 4800 5700
122 2 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 5
13 1200 3150 4800 3150 4800 6300 1200 6300 1200 3150
142 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
15 1200 4800 4800 4800
162 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4
17 2400 4800 2400 6525 1950 7125 1950 7800
182 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4
19 3000 4800 3000 6525 3600 7125 3600 7800
202 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 1 3
21 0 0 1.00 60.00 120.00
22 3825 5400 4125 5100 5400 5100
232 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 1 3
24 0 0 1.00 60.00 120.00
25 2100 4200 2400 3900 5400 3900
262 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
27 4800 5700 5400 5700
282 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
29 1800 3600 5400 3600
302 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 1 3
31 0 0 1.00 60.00 120.00
32 2700 4800 2700 4425 5400 4425
332 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2
34 0 0 1.00 60.00 120.00
35 0 0 1.00 60.00 120.00
36 1950 7800 3600 7800
374 1 0 50 0 0 12 0.0000 4 135 810 2775 7725 Dead band\001
384 0 0 50 0 0 12 0.0000 4 180 1155 5400 5700 right saturation\001
394 0 0 50 0 0 12 0.0000 4 135 1065 5400 3600 left saturation\001
404 0 0 50 0 0 12 0.0000 4 180 2505 5400 3900 left coeff ( positive in that case )\001
414 0 0 50 0 0 12 0.0000 4 180 2640 5475 5100 right coeff ( negative in that case )\001
424 0 0 50 0 0 12 0.0000 4 105 480 5400 4425 center\001
diff --git a/Documentation/input/interactive.svg b/Documentation/input/interactive.svg
new file mode 100644
index 000000000000..a3513709a09b
--- /dev/null
+++ b/Documentation/input/interactive.svg
@@ -0,0 +1,24 @@
1<svg width="5.75in" height="3.90in" version="1.1" viewBox="1178 3138 6779.9424 4671.3427" xmlns="http://www.w3.org/2000/svg">
2 <polyline transform="translate(-18.5,-16.294)" points="1200 3600 1800 3600 2400 4800 3e3 4800 4200 5700 4800 5700" fill="none" stroke="#000" stroke-width="15"/>
3 <rect x="1181.5" y="3133.7" width="3600" height="3150" rx="0" fill="none" stroke="#000" stroke-width="7"/>
4 <polyline transform="translate(-18.5,-16.294)" points="1200 4800 4800 4800" fill="none" stroke="#000" stroke-width="7"/>
5 <polyline transform="translate(-18.5,-16.294)" points="2400 4800 2400 6525 1950 7125 1950 7800" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
6 <polyline transform="translate(-18.5,-16.294)" points="3e3 4800 3e3 6525 3600 7125 3600 7800" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
7 <polyline transform="translate(-18.5,-16.294)" points="3837 5389 4125 5100 5400 5100" fill="none" stroke="#000" stroke-width="7"/>
8 <polyline transform="translate(-18.5,-16.294)" points="3889 5292 3826 5398 3932 5334" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
9 <polyline transform="translate(-18.5,-16.294)" points="2112 4189 2400 3900 5400 3900" fill="none" stroke="#000" stroke-width="7"/>
10 <polyline transform="translate(-18.5,-16.294)" points="2164 4092 2101 4198 2207 4134" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
11 <polyline transform="translate(-18.5,-16.294)" points="4800 5700 5400 5700" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
12 <polyline transform="translate(-18.5,-16.294)" points="1800 3600 5400 3600" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
13 <polyline transform="translate(-18.5,-16.294)" points="2700 4784 2700 4425 5400 4425" fill="none" stroke="#000" stroke-width="7"/>
14 <polyline transform="translate(-18.5,-16.294)" points="2670 4678 2700 4798 2730 4678" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
15 <polyline transform="translate(-18.5,-16.294)" points="1967 7800 3583 7800" fill="none" stroke="#000" stroke-width="7"/>
16 <polyline transform="translate(-18.5,-16.294)" points="3478 7830 3598 7800 3478 7770" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
17 <polyline transform="translate(-18.5,-16.294)" points="2072 7770 1952 7800 2072 7830" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
18 <text x="2775" y="7725" font-family="sans-serif" font-size="144px" stroke="#000000" stroke-width=".025in" text-anchor="middle" xml:space="preserve">Dead band</text>
19 <text x="5400" y="5700" font-family="sans-serif" font-size="144px" stroke="#000000" stroke-width=".025in" xml:space="preserve">right saturation</text>
20 <text x="5400" y="3600" font-family="sans-serif" font-size="144px" stroke="#000000" stroke-width=".025in" xml:space="preserve">left saturation</text>
21 <text x="5400" y="3900" font-family="sans-serif" font-size="144px" stroke="#000000" stroke-width=".025in" xml:space="preserve">left coeff ( positive in that case )</text>
22 <text x="5475" y="5100" font-family="sans-serif" font-size="144px" stroke="#000000" stroke-width=".025in" xml:space="preserve">right coeff ( negative in that case )</text>
23 <text x="5400" y="4425" font-family="sans-serif" font-size="144px" stroke="#000000" stroke-width=".025in" xml:space="preserve">center</text>
24</svg>
diff --git a/Documentation/input/joydev/index.rst b/Documentation/input/joydev/index.rst
new file mode 100644
index 000000000000..8d9666c7561c
--- /dev/null
+++ b/Documentation/input/joydev/index.rst
@@ -0,0 +1,18 @@
1.. include:: <isonum.txt>
2
3======================
4Linux Joystick support
5======================
6
7:Copyright: |copy| 1996-2000 Vojtech Pavlik <vojtech@ucw.cz> - Sponsored by SuSE
8
9.. class:: toc-title
10
11 Table of Contents
12
13.. toctree::
14 :maxdepth: 3
15 :numbered:
16
17 joystick
18 joystick-api
diff --git a/Documentation/input/joystick-api.txt b/Documentation/input/joydev/joystick-api.rst
index 943b18eac918..95803e2e8cd0 100644
--- a/Documentation/input/joystick-api.txt
+++ b/Documentation/input/joydev/joystick-api.rst
@@ -1,31 +1,54 @@
1 Joystick API Documentation -*-Text-*- 1.. _joystick-api:
2 2
3 Ragnar Hojland Espinosa 3=====================
4 <ragnar@macula.net> 4Programming Interface
5=====================
5 6
6 7 Aug 1998 7:Author: Ragnar Hojland Espinosa <ragnar@macula.net> - 7 Aug 1998
7 8
81. Initialization 9Introduction
9~~~~~~~~~~~~~~~~~ 10============
11
12.. important::
13 This document describes legacy ``js`` interface. Newer clients are
14 encouraged to switch to the generic event (``evdev``) interface.
15
16The 1.0 driver uses a new, event based approach to the joystick driver.
17Instead of the user program polling for the joystick values, the joystick
18driver now reports only any changes of its state. See joystick-api.txt,
19joystick.h and jstest.c included in the joystick package for more
20information. The joystick device can be used in either blocking or
21nonblocking mode, and supports select() calls.
22
23For backward compatibility the old (v0.x) interface is still included.
24Any call to the joystick driver using the old interface will return values
25that are compatible to the old interface. This interface is still limited
26to 2 axes, and applications using it usually decode only 2 buttons, although
27the driver provides up to 32.
28
29Initialization
30==============
10 31
11Open the joystick device following the usual semantics (that is, with open). 32Open the joystick device following the usual semantics (that is, with open).
12Since the driver now reports events instead of polling for changes, 33Since the driver now reports events instead of polling for changes,
13immediately after the open it will issue a series of synthetic events 34immediately after the open it will issue a series of synthetic events
14(JS_EVENT_INIT) that you can read to check the initial state of the 35(JS_EVENT_INIT) that you can read to obtain the initial state of the
15joystick. 36joystick.
16 37
17By default, the device is opened in blocking mode. 38By default, the device is opened in blocking mode::
18 39
19 int fd = open ("/dev/input/js0", O_RDONLY); 40 int fd = open ("/dev/input/js0", O_RDONLY);
20 41
21 42
222. Event Reading 43Event Reading
23~~~~~~~~~~~~~~~~ 44=============
45
46::
24 47
25 struct js_event e; 48 struct js_event e;
26 read (fd, &e, sizeof(e)); 49 read (fd, &e, sizeof(e));
27 50
28where js_event is defined as 51where js_event is defined as::
29 52
30 struct js_event { 53 struct js_event {
31 __u32 time; /* event timestamp in milliseconds */ 54 __u32 time; /* event timestamp in milliseconds */
@@ -38,10 +61,10 @@ If the read is successful, it will return sizeof(e), unless you wanted to read
38more than one event per read as described in section 3.1. 61more than one event per read as described in section 3.1.
39 62
40 63
412.1 js_event.type 64js_event.type
42~~~~~~~~~~~~~~~~~ 65-------------
43 66
44The possible values of ``type'' are 67The possible values of ``type`` are::
45 68
46 #define JS_EVENT_BUTTON 0x01 /* button pressed/released */ 69 #define JS_EVENT_BUTTON 0x01 /* button pressed/released */
47 #define JS_EVENT_AXIS 0x02 /* joystick moved */ 70 #define JS_EVENT_AXIS 0x02 /* joystick moved */
@@ -49,47 +72,50 @@ The possible values of ``type'' are
49 72
50As mentioned above, the driver will issue synthetic JS_EVENT_INIT ORed 73As mentioned above, the driver will issue synthetic JS_EVENT_INIT ORed
51events on open. That is, if it's issuing a INIT BUTTON event, the 74events on open. That is, if it's issuing a INIT BUTTON event, the
52current type value will be 75current type value will be::
53 76
54 int type = JS_EVENT_BUTTON | JS_EVENT_INIT; /* 0x81 */ 77 int type = JS_EVENT_BUTTON | JS_EVENT_INIT; /* 0x81 */
55 78
56If you choose not to differentiate between synthetic or real events 79If you choose not to differentiate between synthetic or real events
57you can turn off the JS_EVENT_INIT bits 80you can turn off the JS_EVENT_INIT bits::
58 81
59 type &= ~JS_EVENT_INIT; /* 0x01 */ 82 type &= ~JS_EVENT_INIT; /* 0x01 */
60 83
61 84
622.2 js_event.number 85js_event.number
63~~~~~~~~~~~~~~~~~~~ 86---------------
64 87
65The values of ``number'' correspond to the axis or button that 88The values of ``number`` correspond to the axis or button that
66generated the event. Note that they carry separate numeration (that 89generated the event. Note that they carry separate numeration (that
67is, you have both an axis 0 and a button 0). Generally, 90is, you have both an axis 0 and a button 0). Generally,
68 91
69 number 92 =============== =======
93 Axis number
94 =============== =======
70 1st Axis X 0 95 1st Axis X 0
71 1st Axis Y 1 96 1st Axis Y 1
72 2nd Axis X 2 97 2nd Axis X 2
73 2nd Axis Y 3 98 2nd Axis Y 3
74 ...and so on 99 ...and so on
100 =============== =======
75 101
76Hats vary from one joystick type to another. Some can be moved in 8 102Hats vary from one joystick type to another. Some can be moved in 8
77directions, some only in 4, The driver, however, always reports a hat as two 103directions, some only in 4, The driver, however, always reports a hat as two
78independent axis, even if the hardware doesn't allow independent movement. 104independent axis, even if the hardware doesn't allow independent movement.
79 105
80 106
812.3 js_event.value 107js_event.value
82~~~~~~~~~~~~~~~~~~ 108--------------
83 109
84For an axis, ``value'' is a signed integer between -32767 and +32767 110For an axis, ``value`` is a signed integer between -32767 and +32767
85representing the position of the joystick along that axis. If you 111representing the position of the joystick along that axis. If you
86don't read a 0 when the joystick is `dead', or if it doesn't span the 112don't read a 0 when the joystick is ``dead``, or if it doesn't span the
87full range, you should recalibrate it (with, for example, jscal). 113full range, you should recalibrate it (with, for example, jscal).
88 114
89For a button, ``value'' for a press button event is 1 and for a release 115For a button, ``value`` for a press button event is 1 and for a release
90button event is 0. 116button event is 0.
91 117
92Though this 118Though this::
93 119
94 if (js_event.type == JS_EVENT_BUTTON) { 120 if (js_event.type == JS_EVENT_BUTTON) {
95 buttons_state ^= (1 << js_event.number); 121 buttons_state ^= (1 << js_event.number);
@@ -97,6 +123,8 @@ Though this
97 123
98may work well if you handle JS_EVENT_INIT events separately, 124may work well if you handle JS_EVENT_INIT events separately,
99 125
126::
127
100 if ((js_event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) { 128 if ((js_event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) {
101 if (js_event.value) 129 if (js_event.value)
102 buttons_state |= (1 << js_event.number); 130 buttons_state |= (1 << js_event.number);
@@ -109,17 +137,17 @@ have to write a separate handler for JS_EVENT_INIT events in the first
109snippet, this ends up being shorter. 137snippet, this ends up being shorter.
110 138
111 139
1122.4 js_event.time 140js_event.time
113~~~~~~~~~~~~~~~~~ 141-------------
114 142
115The time an event was generated is stored in ``js_event.time''. It's a time 143The time an event was generated is stored in ``js_event.time``. It's a time
116in milliseconds since ... well, since sometime in the past. This eases the 144in milliseconds since ... well, since sometime in the past. This eases the
117task of detecting double clicks, figuring out if movement of axis and button 145task of detecting double clicks, figuring out if movement of axis and button
118presses happened at the same time, and similar. 146presses happened at the same time, and similar.
119 147
120 148
1213. Reading 149Reading
122~~~~~~~~~~ 150=======
123 151
124If you open the device in blocking mode, a read will block (that is, 152If you open the device in blocking mode, a read will block (that is,
125wait) forever until an event is generated and effectively read. There 153wait) forever until an event is generated and effectively read. There
@@ -133,8 +161,8 @@ admittedly, a long time;)
133 b) open the device in non-blocking mode (O_NONBLOCK) 161 b) open the device in non-blocking mode (O_NONBLOCK)
134 162
135 163
1363.1 O_NONBLOCK 164O_NONBLOCK
137~~~~~~~~~~~~~~ 165----------
138 166
139If read returns -1 when reading in O_NONBLOCK mode, this isn't 167If read returns -1 when reading in O_NONBLOCK mode, this isn't
140necessarily a "real" error (check errno(3)); it can just mean there 168necessarily a "real" error (check errno(3)); it can just mean there
@@ -143,6 +171,8 @@ all events on the queue (that is, until you get a -1).
143 171
144For example, 172For example,
145 173
174::
175
146 while (1) { 176 while (1) {
147 while (read (fd, &e, sizeof(e)) > 0) { 177 while (read (fd, &e, sizeof(e)) > 0) {
148 process_event (e); 178 process_event (e);
@@ -171,14 +201,17 @@ the driver will switch to startup mode and next time you read it,
171synthetic events (JS_EVENT_INIT) will be generated to inform you of 201synthetic events (JS_EVENT_INIT) will be generated to inform you of
172the actual state of the joystick. 202the actual state of the joystick.
173 203
174[As for version 1.2.8, the queue is circular and able to hold 64 204
205.. note::
206
207 As of version 1.2.8, the queue is circular and able to hold 64
175 events. You can increment this size bumping up JS_BUFF_SIZE in 208 events. You can increment this size bumping up JS_BUFF_SIZE in
176 joystick.h and recompiling the driver.] 209 joystick.h and recompiling the driver.
177 210
178 211
179In the above code, you might as well want to read more than one event 212In the above code, you might as well want to read more than one event
180at a time using the typical read(2) functionality. For that, you would 213at a time using the typical read(2) functionality. For that, you would
181replace the read above with something like 214replace the read above with something like::
182 215
183 struct js_event mybuffer[0xff]; 216 struct js_event mybuffer[0xff];
184 int i = read (fd, mybuffer, sizeof(mybuffer)); 217 int i = read (fd, mybuffer, sizeof(mybuffer));
@@ -189,10 +222,10 @@ sizeof(js_event) Again, if the buffer was full, it's a good idea to
189process the events and keep reading it until you empty the driver queue. 222process the events and keep reading it until you empty the driver queue.
190 223
191 224
1924. IOCTLs 225IOCTLs
193~~~~~~~~~ 226======
194 227
195The joystick driver defines the following ioctl(2) operations. 228The joystick driver defines the following ioctl(2) operations::
196 229
197 /* function 3rd arg */ 230 /* function 3rd arg */
198 #define JSIOCGAXES /* get number of axes char */ 231 #define JSIOCGAXES /* get number of axes char */
@@ -202,31 +235,31 @@ The joystick driver defines the following ioctl(2) operations.
202 #define JSIOCSCORR /* set correction values &js_corr */ 235 #define JSIOCSCORR /* set correction values &js_corr */
203 #define JSIOCGCORR /* get correction values &js_corr */ 236 #define JSIOCGCORR /* get correction values &js_corr */
204 237
205For example, to read the number of axes 238For example, to read the number of axes::
206 239
207 char number_of_axes; 240 char number_of_axes;
208 ioctl (fd, JSIOCGAXES, &number_of_axes); 241 ioctl (fd, JSIOCGAXES, &number_of_axes);
209 242
210 243
2114.1 JSIOGCVERSION 244JSIOGCVERSION
212~~~~~~~~~~~~~~~~~ 245-------------
213 246
214JSIOGCVERSION is a good way to check in run-time whether the running 247JSIOGCVERSION is a good way to check in run-time whether the running
215driver is 1.0+ and supports the event interface. If it is not, the 248driver is 1.0+ and supports the event interface. If it is not, the
216IOCTL will fail. For a compile-time decision, you can test the 249IOCTL will fail. For a compile-time decision, you can test the
217JS_VERSION symbol 250JS_VERSION symbol::
218 251
219 #ifdef JS_VERSION 252 #ifdef JS_VERSION
220 #if JS_VERSION > 0xsomething 253 #if JS_VERSION > 0xsomething
221 254
222 255
2234.2 JSIOCGNAME 256JSIOCGNAME
224~~~~~~~~~~~~~~ 257----------
225 258
226JSIOCGNAME(len) allows you to get the name string of the joystick - the same 259JSIOCGNAME(len) allows you to get the name string of the joystick - the same
227as is being printed at boot time. The 'len' argument is the length of the 260as is being printed at boot time. The 'len' argument is the length of the
228buffer provided by the application asking for the name. It is used to avoid 261buffer provided by the application asking for the name. It is used to avoid
229possible overrun should the name be too long. 262possible overrun should the name be too long::
230 263
231 char name[128]; 264 char name[128];
232 if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0) 265 if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
@@ -234,8 +267,8 @@ possible overrun should the name be too long.
234 printf("Name: %s\n", name); 267 printf("Name: %s\n", name);
235 268
236 269
2374.3 JSIOC[SG]CORR 270JSIOC[SG]CORR
238~~~~~~~~~~~~~~~~~ 271-------------
239 272
240For usage on JSIOC[SG]CORR I suggest you to look into jscal.c They are 273For usage on JSIOC[SG]CORR I suggest you to look into jscal.c They are
241not needed in a normal program, only in joystick calibration software 274not needed in a normal program, only in joystick calibration software
@@ -246,7 +279,7 @@ warning in following releases of the driver.
246Both JSIOCSCORR and JSIOCGCORR expect &js_corr to be able to hold 279Both JSIOCSCORR and JSIOCGCORR expect &js_corr to be able to hold
247information for all axis. That is, struct js_corr corr[MAX_AXIS]; 280information for all axis. That is, struct js_corr corr[MAX_AXIS];
248 281
249struct js_corr is defined as 282struct js_corr is defined as::
250 283
251 struct js_corr { 284 struct js_corr {
252 __s32 coef[8]; 285 __s32 coef[8];
@@ -254,17 +287,17 @@ struct js_corr is defined as
254 __u16 type; 287 __u16 type;
255 }; 288 };
256 289
257and ``type'' 290and ``type``::
258 291
259 #define JS_CORR_NONE 0x00 /* returns raw values */ 292 #define JS_CORR_NONE 0x00 /* returns raw values */
260 #define JS_CORR_BROKEN 0x01 /* broken line */ 293 #define JS_CORR_BROKEN 0x01 /* broken line */
261 294
262 295
2635. Backward compatibility 296Backward compatibility
264~~~~~~~~~~~~~~~~~~~~~~~~~ 297======================
265 298
266The 0.x joystick driver API is quite limited and its usage is deprecated. 299The 0.x joystick driver API is quite limited and its usage is deprecated.
267The driver offers backward compatibility, though. Here's a quick summary: 300The driver offers backward compatibility, though. Here's a quick summary::
268 301
269 struct JS_DATA_TYPE js; 302 struct JS_DATA_TYPE js;
270 while (1) { 303 while (1) {
@@ -275,7 +308,7 @@ The driver offers backward compatibility, though. Here's a quick summary:
275 } 308 }
276 309
277As you can figure out from the example, the read returns immediately, 310As you can figure out from the example, the read returns immediately,
278with the actual state of the joystick. 311with the actual state of the joystick::
279 312
280 struct JS_DATA_TYPE { 313 struct JS_DATA_TYPE {
281 int buttons; /* immediate button state */ 314 int buttons; /* immediate button state */
@@ -283,12 +316,14 @@ with the actual state of the joystick.
283 int y; /* immediate y axis value */ 316 int y; /* immediate y axis value */
284 }; 317 };
285 318
286and JS_RETURN is defined as 319and JS_RETURN is defined as::
287 320
288 #define JS_RETURN sizeof(struct JS_DATA_TYPE) 321 #define JS_RETURN sizeof(struct JS_DATA_TYPE)
289 322
290To test the state of the buttons, 323To test the state of the buttons,
291 324
325::
326
292 first_button_state = js.buttons & 1; 327 first_button_state = js.buttons & 1;
293 second_button_state = js.buttons & 2; 328 second_button_state = js.buttons & 2;
294 329
@@ -302,13 +337,12 @@ called Multisystem joysticks in this driver), under /dev/djsX. This driver
302doesn't try to be compatible with that interface. 337doesn't try to be compatible with that interface.
303 338
304 339
3056. Final Notes 340Final Notes
306~~~~~~~~~~~~~~ 341===========
307 342
308____/| Comments, additions, and specially corrections are welcome. 343::
309\ o.O| Documentation valid for at least version 1.2.8 of the joystick
310 =(_)= driver and as usual, the ultimate source for documentation is
311 U to "Use The Source Luke" or, at your convenience, Vojtech ;)
312 344
313 - Ragnar 345 ____/| Comments, additions, and specially corrections are welcome.
314EOF 346 \ o.O| Documentation valid for at least version 1.2.8 of the joystick
347 =(_)= driver and as usual, the ultimate source for documentation is
348 U to "Use The Source Luke" or, at your convenience, Vojtech ;)
diff --git a/Documentation/input/joydev/joystick.rst b/Documentation/input/joydev/joystick.rst
new file mode 100644
index 000000000000..9746fd76cc58
--- /dev/null
+++ b/Documentation/input/joydev/joystick.rst
@@ -0,0 +1,585 @@
1.. include:: <isonum.txt>
2
3.. _joystick-doc:
4
5Introduction
6============
7
8The joystick driver for Linux provides support for a variety of joysticks
9and similar devices. It is based on a larger project aiming to support all
10input devices in Linux.
11
12The mailing list for the project is:
13
14 linux-input@vger.kernel.org
15
16send "subscribe linux-input" to majordomo@vger.kernel.org to subscribe to it.
17
18Usage
19=====
20
21For basic usage you just choose the right options in kernel config and
22you should be set.
23
24Utilities
25---------
26
27For testing and other purposes (for example serial devices), there is a set
28of utilities, such as ``jstest``, ``jscal``, and ``evtest``,
29usually packaged as ``joystick``, ``input-utils``, ``evtest``, and so on.
30
31``inputattach`` utility is required if your joystick is connected to a
32serial port.
33
34Device nodes
35------------
36
37For applications to be able to use the joysticks, device nodes should be
38created in /dev. Normally it is done automatically by the system, but
39it can also be done by hand::
40
41 cd /dev
42 rm js*
43 mkdir input
44 mknod input/js0 c 13 0
45 mknod input/js1 c 13 1
46 mknod input/js2 c 13 2
47 mknod input/js3 c 13 3
48 ln -s input/js0 js0
49 ln -s input/js1 js1
50 ln -s input/js2 js2
51 ln -s input/js3 js3
52
53For testing with inpututils it's also convenient to create these::
54
55 mknod input/event0 c 13 64
56 mknod input/event1 c 13 65
57 mknod input/event2 c 13 66
58 mknod input/event3 c 13 67
59
60Modules needed
61--------------
62
63For all joystick drivers to function, you'll need the userland interface
64module in kernel, either loaded or compiled in::
65
66 modprobe joydev
67
68For gameport joysticks, you'll have to load the gameport driver as well::
69
70 modprobe ns558
71
72And for serial port joysticks, you'll need the serial input line
73discipline module loaded and the inputattach utility started::
74
75 modprobe serport
76 inputattach -xxx /dev/tts/X &
77
78In addition to that, you'll need the joystick driver module itself, most
79usually you'll have an analog joystick::
80
81 modprobe analog
82
83For automatic module loading, something like this might work - tailor to
84your needs::
85
86 alias tty-ldisc-2 serport
87 alias char-major-13 input
88 above input joydev ns558 analog
89 options analog map=gamepad,none,2btn
90
91Verifying that it works
92-----------------------
93
94For testing the joystick driver functionality, there is the jstest
95program in the utilities package. You run it by typing::
96
97 jstest /dev/input/js0
98
99And it should show a line with the joystick values, which update as you
100move the stick, and press its buttons. The axes should all be zero when the
101joystick is in the center position. They should not jitter by themselves to
102other close values, and they also should be steady in any other position of
103the stick. They should have the full range from -32767 to 32767. If all this
104is met, then it's all fine, and you can play the games. :)
105
106If it's not, then there might be a problem. Try to calibrate the joystick,
107and if it still doesn't work, read the drivers section of this file, the
108troubleshooting section, and the FAQ.
109
110Calibration
111-----------
112
113For most joysticks you won't need any manual calibration, since the
114joystick should be autocalibrated by the driver automagically. However, with
115some analog joysticks, that either do not use linear resistors, or if you
116want better precision, you can use the jscal program::
117
118 jscal -c /dev/input/js0
119
120included in the joystick package to set better correction coefficients than
121what the driver would choose itself.
122
123After calibrating the joystick you can verify if you like the new
124calibration using the jstest command, and if you do, you then can save the
125correction coefficients into a file::
126
127 jscal -p /dev/input/js0 > /etc/joystick.cal
128
129And add a line to your rc script executing that file::
130
131 source /etc/joystick.cal
132
133This way, after the next reboot your joystick will remain calibrated. You
134can also add the ``jscal -p`` line to your shutdown script.
135
136HW specific driver information
137==============================
138
139In this section each of the separate hardware specific drivers is described.
140
141Analog joysticks
142----------------
143
144The analog.c uses the standard analog inputs of the gameport, and thus
145supports all standard joysticks and gamepads. It uses a very advanced
146routine for this, allowing for data precision that can't be found on any
147other system.
148
149It also supports extensions like additional hats and buttons compatible
150with CH Flightstick Pro, ThrustMaster FCS or 6 and 8 button gamepads. Saitek
151Cyborg 'digital' joysticks are also supported by this driver, because
152they're basically souped up CHF sticks.
153
154However the only types that can be autodetected are:
155
156* 2-axis, 4-button joystick
157* 3-axis, 4-button joystick
158* 4-axis, 4-button joystick
159* Saitek Cyborg 'digital' joysticks
160
161For other joystick types (more/less axes, hats, and buttons) support
162you'll need to specify the types either on the kernel command line or on the
163module command line, when inserting analog into the kernel. The
164parameters are::
165
166 analog.map=<type1>,<type2>,<type3>,....
167
168'type' is type of the joystick from the table below, defining joysticks
169present on gameports in the system, starting with gameport0, second 'type'
170entry defining joystick on gameport1 and so on.
171
172 ========= =====================================================
173 Type Meaning
174 ========= =====================================================
175 none No analog joystick on that port
176 auto Autodetect joystick
177 2btn 2-button n-axis joystick
178 y-joy Two 2-button 2-axis joysticks on an Y-cable
179 y-pad Two 2-button 2-axis gamepads on an Y-cable
180 fcs Thrustmaster FCS compatible joystick
181 chf Joystick with a CH Flightstick compatible hat
182 fullchf CH Flightstick compatible with two hats and 6 buttons
183 gamepad 4/6-button n-axis gamepad
184 gamepad8 8-button 2-axis gamepad
185 ========= =====================================================
186
187In case your joystick doesn't fit in any of the above categories, you can
188specify the type as a number by combining the bits in the table below. This
189is not recommended unless you really know what are you doing. It's not
190dangerous, but not simple either.
191
192 ==== =========================
193 Bit Meaning
194 ==== =========================
195 0 Axis X1
196 1 Axis Y1
197 2 Axis X2
198 3 Axis Y2
199 4 Button A
200 5 Button B
201 6 Button C
202 7 Button D
203 8 CHF Buttons X and Y
204 9 CHF Hat 1
205 10 CHF Hat 2
206 11 FCS Hat
207 12 Pad Button X
208 13 Pad Button Y
209 14 Pad Button U
210 15 Pad Button V
211 16 Saitek F1-F4 Buttons
212 17 Saitek Digital Mode
213 19 GamePad
214 20 Joy2 Axis X1
215 21 Joy2 Axis Y1
216 22 Joy2 Axis X2
217 23 Joy2 Axis Y2
218 24 Joy2 Button A
219 25 Joy2 Button B
220 26 Joy2 Button C
221 27 Joy2 Button D
222 31 Joy2 GamePad
223 ==== =========================
224
225Microsoft SideWinder joysticks
226------------------------------
227
228Microsoft 'Digital Overdrive' protocol is supported by the sidewinder.c
229module. All currently supported joysticks:
230
231* Microsoft SideWinder 3D Pro
232* Microsoft SideWinder Force Feedback Pro
233* Microsoft SideWinder Force Feedback Wheel
234* Microsoft SideWinder FreeStyle Pro
235* Microsoft SideWinder GamePad (up to four, chained)
236* Microsoft SideWinder Precision Pro
237* Microsoft SideWinder Precision Pro USB
238
239are autodetected, and thus no module parameters are needed.
240
241There is one caveat with the 3D Pro. There are 9 buttons reported,
242although the joystick has only 8. The 9th button is the mode switch on the
243rear side of the joystick. However, moving it, you'll reset the joystick,
244and make it unresponsive for about a one third of a second. Furthermore, the
245joystick will also re-center itself, taking the position it was in during
246this time as a new center position. Use it if you want, but think first.
247
248The SideWinder Standard is not a digital joystick, and thus is supported
249by the analog driver described above.
250
251Logitech ADI devices
252--------------------
253
254Logitech ADI protocol is supported by the adi.c module. It should support
255any Logitech device using this protocol. This includes, but is not limited
256to:
257
258* Logitech CyberMan 2
259* Logitech ThunderPad Digital
260* Logitech WingMan Extreme Digital
261* Logitech WingMan Formula
262* Logitech WingMan Interceptor
263* Logitech WingMan GamePad
264* Logitech WingMan GamePad USB
265* Logitech WingMan GamePad Extreme
266* Logitech WingMan Extreme Digital 3D
267
268ADI devices are autodetected, and the driver supports up to two (any
269combination of) devices on a single gameport, using an Y-cable or chained
270together.
271
272Logitech WingMan Joystick, Logitech WingMan Attack, Logitech WingMan
273Extreme and Logitech WingMan ThunderPad are not digital joysticks and are
274handled by the analog driver described above. Logitech WingMan Warrior and
275Logitech Magellan are supported by serial drivers described below. Logitech
276WingMan Force and Logitech WingMan Formula Force are supported by the
277I-Force driver described below. Logitech CyberMan is not supported yet.
278
279Gravis GrIP
280-----------
281
282Gravis GrIP protocol is supported by the grip.c module. It currently
283supports:
284
285* Gravis GamePad Pro
286* Gravis BlackHawk Digital
287* Gravis Xterminator
288* Gravis Xterminator DualControl
289
290All these devices are autodetected, and you can even use any combination
291of up to two of these pads either chained together or using an Y-cable on a
292single gameport.
293
294GrIP MultiPort isn't supported yet. Gravis Stinger is a serial device and is
295supported by the stinger driver. Other Gravis joysticks are supported by the
296analog driver.
297
298FPGaming A3D and MadCatz A3D
299----------------------------
300
301The Assassin 3D protocol created by FPGaming, is used both by FPGaming
302themselves and is licensed to MadCatz. A3D devices are supported by the
303a3d.c module. It currently supports:
304
305* FPGaming Assassin 3D
306* MadCatz Panther
307* MadCatz Panther XL
308
309All these devices are autodetected. Because the Assassin 3D and the Panther
310allow connecting analog joysticks to them, you'll need to load the analog
311driver as well to handle the attached joysticks.
312
313The trackball should work with USB mousedev module as a normal mouse. See
314the USB documentation for how to setup an USB mouse.
315
316ThrustMaster DirectConnect (BSP)
317--------------------------------
318
319The TM DirectConnect (BSP) protocol is supported by the tmdc.c
320module. This includes, but is not limited to:
321
322* ThrustMaster Millennium 3D Interceptor
323* ThrustMaster 3D Rage Pad
324* ThrustMaster Fusion Digital Game Pad
325
326Devices not directly supported, but hopefully working are:
327
328* ThrustMaster FragMaster
329* ThrustMaster Attack Throttle
330
331If you have one of these, contact me.
332
333TMDC devices are autodetected, and thus no parameters to the module
334are needed. Up to two TMDC devices can be connected to one gameport, using
335an Y-cable.
336
337Creative Labs Blaster
338---------------------
339
340The Blaster protocol is supported by the cobra.c module. It supports only
341the:
342
343* Creative Blaster GamePad Cobra
344
345Up to two of these can be used on a single gameport, using an Y-cable.
346
347Genius Digital joysticks
348------------------------
349
350The Genius digitally communicating joysticks are supported by the gf2k.c
351module. This includes:
352
353* Genius Flight2000 F-23 joystick
354* Genius Flight2000 F-31 joystick
355* Genius G-09D gamepad
356
357Other Genius digital joysticks are not supported yet, but support can be
358added fairly easily.
359
360InterAct Digital joysticks
361--------------------------
362
363The InterAct digitally communicating joysticks are supported by the
364interact.c module. This includes:
365
366* InterAct HammerHead/FX gamepad
367* InterAct ProPad8 gamepad
368
369Other InterAct digital joysticks are not supported yet, but support can be
370added fairly easily.
371
372PDPI Lightning 4 gamecards
373--------------------------
374
375PDPI Lightning 4 gamecards are supported by the lightning.c module.
376Once the module is loaded, the analog driver can be used to handle the
377joysticks. Digitally communicating joystick will work only on port 0, while
378using Y-cables, you can connect up to 8 analog joysticks to a single L4
379card, 16 in case you have two in your system.
380
381Trident 4DWave / Aureal Vortex
382------------------------------
383
384Soundcards with a Trident 4DWave DX/NX or Aureal Vortex/Vortex2 chipsets
385provide an "Enhanced Game Port" mode where the soundcard handles polling the
386joystick. This mode is supported by the pcigame.c module. Once loaded the
387analog driver can use the enhanced features of these gameports..
388
389Crystal SoundFusion
390-------------------
391
392Soundcards with Crystal SoundFusion chipsets provide an "Enhanced Game
393Port", much like the 4DWave or Vortex above. This, and also the normal mode
394for the port of the SoundFusion is supported by the cs461x.c module.
395
396SoundBlaster Live!
397------------------
398
399The Live! has a special PCI gameport, which, although it doesn't provide
400any "Enhanced" stuff like 4DWave and friends, is quite a bit faster than
401its ISA counterparts. It also requires special support, hence the
402emu10k1-gp.c module for it instead of the normal ns558.c one.
403
404SoundBlaster 64 and 128 - ES1370 and ES1371, ESS Solo1 and S3 SonicVibes
405------------------------------------------------------------------------
406
407These PCI soundcards have specific gameports. They are handled by the
408sound drivers themselves. Make sure you select gameport support in the
409joystick menu and sound card support in the sound menu for your appropriate
410card.
411
412Amiga
413-----
414
415Amiga joysticks, connected to an Amiga, are supported by the amijoy.c
416driver. Since they can't be autodetected, the driver has a command line:
417
418 amijoy.map=<a>,<b>
419
420a and b define the joysticks connected to the JOY0DAT and JOY1DAT ports of
421the Amiga.
422
423 ====== ===========================
424 Value Joystick type
425 ====== ===========================
426 0 None
427 1 1-button digital joystick
428 ====== ===========================
429
430No more joystick types are supported now, but that should change in the
431future if I get an Amiga in the reach of my fingers.
432
433Game console and 8-bit pads and joysticks
434-----------------------------------------
435
436These pads and joysticks are not designed for PCs and other computers
437Linux runs on, and usually require a special connector for attaching
438them through a parallel port.
439
440See :ref:`joystick-parport` for more info.
441
442SpaceTec/LabTec devices
443-----------------------
444
445SpaceTec serial devices communicate using the SpaceWare protocol. It is
446supported by the spaceorb.c and spaceball.c drivers. The devices currently
447supported by spaceorb.c are:
448
449* SpaceTec SpaceBall Avenger
450* SpaceTec SpaceOrb 360
451
452Devices currently supported by spaceball.c are:
453
454* SpaceTec SpaceBall 4000 FLX
455
456In addition to having the spaceorb/spaceball and serport modules in the
457kernel, you also need to attach a serial port to it. to do that, run the
458inputattach program::
459
460 inputattach --spaceorb /dev/tts/x &
461
462or::
463
464 inputattach --spaceball /dev/tts/x &
465
466where /dev/tts/x is the serial port which the device is connected to. After
467doing this, the device will be reported and will start working.
468
469There is one caveat with the SpaceOrb. The button #6, the on the bottom
470side of the orb, although reported as an ordinary button, causes internal
471recentering of the spaceorb, moving the zero point to the position in which
472the ball is at the moment of pressing the button. So, think first before
473you bind it to some other function.
474
475SpaceTec SpaceBall 2003 FLX and 3003 FLX are not supported yet.
476
477Logitech SWIFT devices
478----------------------
479
480The SWIFT serial protocol is supported by the warrior.c module. It
481currently supports only the:
482
483* Logitech WingMan Warrior
484
485but in the future, Logitech CyberMan (the original one, not CM2) could be
486supported as well. To use the module, you need to run inputattach after you
487insert/compile the module into your kernel::
488
489 inputattach --warrior /dev/tts/x &
490
491/dev/tts/x is the serial port your Warrior is attached to.
492
493Magellan / Space Mouse
494----------------------
495
496The Magellan (or Space Mouse), manufactured by LogiCad3d (formerly Space
497Systems), for many other companies (Logitech, HP, ...) is supported by the
498joy-magellan module. It currently supports only the:
499
500* Magellan 3D
501* Space Mouse
502
503models, the additional buttons on the 'Plus' versions are not supported yet.
504
505To use it, you need to attach the serial port to the driver using the::
506
507 inputattach --magellan /dev/tts/x &
508
509command. After that the Magellan will be detected, initialized, will beep,
510and the /dev/input/jsX device should become usable.
511
512I-Force devices
513---------------
514
515All I-Force devices are supported by the iforce module. This includes:
516
517* AVB Mag Turbo Force
518* AVB Top Shot Pegasus
519* AVB Top Shot Force Feedback Racing Wheel
520* Logitech WingMan Force
521* Logitech WingMan Force Wheel
522* Guillemot Race Leader Force Feedback
523* Guillemot Force Feedback Racing Wheel
524* Thrustmaster Motor Sport GT
525
526To use it, you need to attach the serial port to the driver using the::
527
528 inputattach --iforce /dev/tts/x &
529
530command. After that the I-Force device will be detected, and the
531/dev/input/jsX device should become usable.
532
533In case you're using the device via the USB port, the inputattach command
534isn't needed.
535
536The I-Force driver now supports force feedback via the event interface.
537
538Please note that Logitech WingMan 3D devices are _not_ supported by this
539module, rather by hid. Force feedback is not supported for those devices.
540Logitech gamepads are also hid devices.
541
542Gravis Stinger gamepad
543----------------------
544
545The Gravis Stinger serial port gamepad, designed for use with laptop
546computers, is supported by the stinger.c module. To use it, attach the
547serial port to the driver using::
548
549 inputattach --stinger /dev/tty/x &
550
551where x is the number of the serial port.
552
553Troubleshooting
554===============
555
556There is quite a high probability that you run into some problems. For
557testing whether the driver works, if in doubt, use the jstest utility in
558some of its modes. The most useful modes are "normal" - for the 1.x
559interface, and "old" for the "0.x" interface. You run it by typing::
560
561 jstest --normal /dev/input/js0
562 jstest --old /dev/input/js0
563
564Additionally you can do a test with the evtest utility::
565
566 evtest /dev/input/event0
567
568Oh, and read the FAQ! :)
569
570FAQ
571===
572
573:Q: Running 'jstest /dev/input/js0' results in "File not found" error. What's the
574 cause?
575:A: The device files don't exist. Create them (see section 2.2).
576
577:Q: Is it possible to connect my old Atari/Commodore/Amiga/console joystick
578 or pad that uses a 9-pin D-type cannon connector to the serial port of my
579 PC?
580:A: Yes, it is possible, but it'll burn your serial port or the pad. It
581 won't work, of course.
582
583:Q: My joystick doesn't work with Quake / Quake 2. What's the cause?
584:A: Quake / Quake 2 don't support joystick. Use joy2key to simulate keypresses
585 for them.
diff --git a/Documentation/input/joystick-parport.txt b/Documentation/input/joystick-parport.txt
deleted file mode 100644
index 56870c70a796..000000000000
--- a/Documentation/input/joystick-parport.txt
+++ /dev/null
@@ -1,542 +0,0 @@
1 Linux Joystick parport drivers v2.0
2 (c) 1998-2000 Vojtech Pavlik <vojtech@ucw.cz>
3 (c) 1998 Andree Borrmann <a.borrmann@tu-bs.de>
4 Sponsored by SuSE
5----------------------------------------------------------------------------
6
70. Disclaimer
8~~~~~~~~~~~~~
9 Any information in this file is provided as-is, without any guarantee that
10it will be true. So, use it at your own risk. The possible damages that can
11happen include burning your parallel port, and/or the sticks and joystick
12and maybe even more. Like when a lightning kills you it is not our problem.
13
141. Intro
15~~~~~~~~
16 The joystick parport drivers are used for joysticks and gamepads not
17originally designed for PCs and other computers Linux runs on. Because of
18that, PCs usually lack the right ports to connect these devices to. Parallel
19port, because of its ability to change single bits at will, and providing
20both output and input bits is the most suitable port on the PC for
21connecting such devices.
22
232. Devices supported
24~~~~~~~~~~~~~~~~~~~~
25 Many console and 8-bit computer gamepads and joysticks are supported. The
26following subsections discuss usage of each.
27
282.1 NES and SNES
29~~~~~~~~~~~~~~~~
30 The Nintendo Entertainment System and Super Nintendo Entertainment System
31gamepads are widely available, and easy to get. Also, they are quite easy to
32connect to a PC, and don't need much processing speed (108 us for NES and
33165 us for SNES, compared to about 1000 us for PC gamepads) to communicate
34with them.
35
36 All NES and SNES use the same synchronous serial protocol, clocked from
37the computer's side (and thus timing insensitive). To allow up to 5 NES
38and/or SNES gamepads and/or SNES mice connected to the parallel port at once,
39the output lines of the parallel port are shared, while one of 5 available
40input lines is assigned to each gamepad.
41
42 This protocol is handled by the gamecon.c driver, so that's the one
43you'll use for NES, SNES gamepads and SNES mice.
44
45 The main problem with PC parallel ports is that they don't have +5V power
46source on any of their pins. So, if you want a reliable source of power
47for your pads, use either keyboard or joystick port, and make a pass-through
48cable. You can also pull the power directly from the power supply (the red
49wire is +5V).
50
51 If you want to use the parallel port only, you can take the power is from
52some data pin. For most gamepad and parport implementations only one pin is
53needed, and I'd recommend pin 9 for that, the highest data bit. On the other
54hand, if you are not planning to use anything else than NES / SNES on the
55port, anything between and including pin 4 and pin 9 will work.
56
57(pin 9) -----> Power
58
59 Unfortunately, there are pads that need a lot more of power, and parallel
60ports that can't give much current through the data pins. If this is your
61case, you'll need to use diodes (as a prevention of destroying your parallel
62port), and combine the currents of two or more data bits together.
63
64 Diodes
65(pin 9) ----|>|-------+------> Power
66 |
67(pin 8) ----|>|-------+
68 |
69(pin 7) ----|>|-------+
70 |
71 <and so on> :
72 |
73(pin 4) ----|>|-------+
74
75 Ground is quite easy. On PC's parallel port the ground is on any of the
76pins from pin 18 to pin 25. So use any pin of these you like for the ground.
77
78(pin 18) -----> Ground
79
80 NES and SNES pads have two input bits, Clock and Latch, which drive the
81serial transfer. These are connected to pins 2 and 3 of the parallel port,
82respectively.
83
84(pin 2) -----> Clock
85(pin 3) -----> Latch
86
87 And the last thing is the NES / SNES data wire. Only that isn't shared and
88each pad needs its own data pin. The parallel port pins are:
89
90(pin 10) -----> Pad 1 data
91(pin 11) -----> Pad 2 data
92(pin 12) -----> Pad 3 data
93(pin 13) -----> Pad 4 data
94(pin 15) -----> Pad 5 data
95
96 Note that pin 14 is not used, since it is not an input pin on the parallel
97port.
98
99 This is everything you need on the PC's side of the connection, now on to
100the gamepads side. The NES and SNES have different connectors. Also, there
101are quite a lot of NES clones, and because Nintendo used proprietary
102connectors for their machines, the cloners couldn't and used standard D-Cannon
103connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo
104A, Turbo B, Select and Start, and is connected through 5 wires, then it is
105either a NES or NES clone and will work with this connection. SNES gamepads
106also use 5 wires, but have more buttons. They will work as well, of course.
107
108Pinout for NES gamepads Pinout for SNES gamepads and mice
109
110 +----> Power +-----------------------\
111 | 7 | o o o o | x x o | 1
112 5 +---------+ 7 +-----------------------/
113 | x x o \ | | | | |
114 | o o o o | | | | | +-> Ground
115 4 +------------+ 1 | | | +------------> Data
116 | | | | | | +---------------> Latch
117 | | | +-> Ground | +------------------> Clock
118 | | +----> Clock +---------------------> Power
119 | +-------> Latch
120 +----------> Data
121
122Pinout for NES clone (db9) gamepads Pinout for NES clone (db15) gamepads
123
124 +---------> Clock +-----------------> Data
125 | +-------> Latch | +---> Ground
126 | | +-----> Data | |
127 | | | ___________________
128 _____________ 8 \ o x x x x x x o / 1
129 5 \ x o o o x / 1 \ o x x o x x o /
130 \ x o x o / 15 `~~~~~~~~~~~~~' 9
131 9 `~~~~~~~' 6 | | |
132 | | | | +----> Clock
133 | +----> Power | +----------> Latch
134 +--------> Ground +----------------> Power
135
1362.2 Multisystem joysticks
137~~~~~~~~~~~~~~~~~~~~~~~~~
138 In the era of 8-bit machines, there was something like de-facto standard
139for joystick ports. They were all digital, and all used D-Cannon 9 pin
140connectors (db9). Because of that, a single joystick could be used without
141hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,
142Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these
143joysticks are called "Multisystem".
144
145 Now their pinout:
146
147 +---------> Right
148 | +-------> Left
149 | | +-----> Down
150 | | | +---> Up
151 | | | |
152 _____________
1535 \ x o o o o / 1
154 \ x o x o /
155 9 `~~~~~~~' 6
156 | |
157 | +----> Button
158 +--------> Ground
159
160 However, as time passed, extensions to this standard developed, and these
161were not compatible with each other:
162
163
164 Atari 130, 800/XL/XE MSX
165
166 +-----------> Power
167 +---------> Right | +---------> Right
168 | +-------> Left | | +-------> Left
169 | | +-----> Down | | | +-----> Down
170 | | | +---> Up | | | | +---> Up
171 | | | | | | | | |
172 _____________ _____________
1735 \ x o o o o / 1 5 \ o o o o o / 1
174 \ x o o o / \ o o o o /
175 9 `~~~~~~~' 6 9 `~~~~~~~' 6
176 | | | | | | |
177 | | +----> Button | | | +----> Button 1
178 | +------> Power | | +------> Button 2
179 +--------> Ground | +--------> Output 3
180 +----------> Ground
181
182 Amstrad CPC Commodore C64
183
184 +-----------> Analog Y
185 +---------> Right | +---------> Right
186 | +-------> Left | | +-------> Left
187 | | +-----> Down | | | +-----> Down
188 | | | +---> Up | | | | +---> Up
189 | | | | | | | | |
190 _____________ _____________
1915 \ x o o o o / 1 5 \ o o o o o / 1
192 \ x o o o / \ o o o o /
193 9 `~~~~~~~' 6 9 `~~~~~~~' 6
194 | | | | | | |
195 | | +----> Button 1 | | | +----> Button
196 | +------> Button 2 | | +------> Power
197 +--------> Ground | +--------> Ground
198 +----------> Analog X
199
200 Sinclair Spectrum +2A/+3 Amiga 1200
201
202 +-----------> Up +-----------> Button 3
203 | +---------> Fire | +---------> Right
204 | | | | +-------> Left
205 | | +-----> Ground | | | +-----> Down
206 | | | | | | | +---> Up
207 | | | | | | | |
208 _____________ _____________
2095 \ o o x o x / 1 5 \ o o o o o / 1
210 \ o o o o / \ o o o o /
211 9 `~~~~~~~' 6 9 `~~~~~~~' 6
212 | | | | | | | |
213 | | | +----> Right | | | +----> Button 1
214 | | +------> Left | | +------> Power
215 | +--------> Ground | +--------> Ground
216 +----------> Down +----------> Button 2
217
218 And there were many others.
219
2202.2.1 Multisystem joysticks using db9.c
221~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
222 For the Multisystem joysticks, and their derivatives, the db9.c driver
223was written. It allows only one joystick / gamepad per parallel port, but
224the interface is easy to build and works with almost anything.
225
226 For the basic 1-button Multisystem joystick you connect its wires to the
227parallel port like this:
228
229(pin 1) -----> Power
230(pin 18) -----> Ground
231
232(pin 2) -----> Up
233(pin 3) -----> Down
234(pin 4) -----> Left
235(pin 5) -----> Right
236(pin 6) -----> Button 1
237
238 However, if the joystick is switch based (eg. clicks when you move it),
239you might or might not, depending on your parallel port, need 10 kOhm pullup
240resistors on each of the direction and button signals, like this:
241
242(pin 2) ------------+------> Up
243 Resistor |
244(pin 1) --[10kOhm]--+
245
246 Try without, and if it doesn't work, add them. For TTL based joysticks /
247gamepads the pullups are not needed.
248
249 For joysticks with two buttons you connect the second button to pin 7 on
250the parallel port.
251
252(pin 7) -----> Button 2
253
254 And that's it.
255
256 On a side note, if you have already built a different adapter for use with
257the digital joystick driver 0.8.0.2, this is also supported by the db9.c
258driver, as device type 8. (See section 3.2)
259
2602.2.2 Multisystem joysticks using gamecon.c
261~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
262 For some people just one joystick per parallel port is not enough, and/or
263want to use them on one parallel port together with NES/SNES/PSX pads. This is
264possible using the gamecon.c. It supports up to 5 devices of the above types,
265including 1 and 2 buttons Multisystem joysticks.
266
267 However, there is nothing for free. To allow more sticks to be used at
268once, you need the sticks to be purely switch based (that is non-TTL), and
269not to need power. Just a plain simple six switches inside. If your
270joystick can do more (eg. turbofire) you'll need to disable it totally first
271if you want to use gamecon.c.
272
273 Also, the connection is a bit more complex. You'll need a bunch of diodes,
274and one pullup resistor. First, you connect the Directions and the button
275the same as for db9, however with the diodes between.
276
277 Diodes
278(pin 2) -----|<|----> Up
279(pin 3) -----|<|----> Down
280(pin 4) -----|<|----> Left
281(pin 5) -----|<|----> Right
282(pin 6) -----|<|----> Button 1
283
284 For two button sticks you also connect the other button.
285
286(pin 7) -----|<|----> Button 2
287
288 And finally, you connect the Ground wire of the joystick, like done in
289this little schematic to Power and Data on the parallel port, as described
290for the NES / SNES pads in section 2.1 of this file - that is, one data pin
291for each joystick. The power source is shared.
292
293Data ------------+-----> Ground
294 Resistor |
295Power --[10kOhm]--+
296
297 And that's all, here we go!
298
2992.2.3 Multisystem joysticks using turbografx.c
300~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301 The TurboGraFX interface, designed by
302
303 Steffen Schwenke <schwenke@burg-halle.de>
304
305 allows up to 7 Multisystem joysticks connected to the parallel port. In
306Steffen's version, there is support for up to 5 buttons per joystick. However,
307since this doesn't work reliably on all parallel ports, the turbografx.c driver
308supports only one button per joystick. For more information on how to build the
309interface, see
310
311 http://www2.burg-halle.de/~schwenke/parport.html
312
3132.3 Sony Playstation
314~~~~~~~~~~~~~~~~~~~~
315
316 The PSX controller is supported by the gamecon.c. Pinout of the PSX
317controller (compatible with DirectPadPro):
318
319 +---------+---------+---------+
3209 | o o o | o o o | o o o | 1 parallel
321 \________|_________|________/ port pins
322 | | | | | |
323 | | | | | +--------> Clock --- (4)
324 | | | | +------------> Select --- (3)
325 | | | +---------------> Power --- (5-9)
326 | | +------------------> Ground --- (18-25)
327 | +-------------------------> Command --- (2)
328 +----------------------------> Data --- (one of 10,11,12,13,15)
329
330 The driver supports these controllers:
331
332 * Standard PSX Pad
333 * NegCon PSX Pad
334 * Analog PSX Pad (red mode)
335 * Analog PSX Pad (green mode)
336 * PSX Rumble Pad
337 * PSX DDR Pad
338
3392.4 Sega
340~~~~~~~~
341 All the Sega controllers are more or less based on the standard 2-button
342Multisystem joystick. However, since they don't use switches and use TTL
343logic, the only driver usable with them is the db9.c driver.
344
3452.4.1 Sega Master System
346~~~~~~~~~~~~~~~~~~~~~~~~
347 The SMS gamepads are almost exactly the same as normal 2-button
348Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
349parallel port pins, and the following schematic:
350
351 +-----------> Power
352 | +---------> Right
353 | | +-------> Left
354 | | | +-----> Down
355 | | | | +---> Up
356 | | | | |
357 _____________
3585 \ o o o o o / 1
359 \ o o x o /
360 9 `~~~~~~~' 6
361 | | |
362 | | +----> Button 1
363 | +--------> Ground
364 +----------> Button 2
365
3662.4.2 Sega Genesis aka MegaDrive
367~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
368 The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension
369to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1). Use
370the following schematic:
371
372 +-----------> Power
373 | +---------> Right
374 | | +-------> Left
375 | | | +-----> Down
376 | | | | +---> Up
377 | | | | |
378 _____________
3795 \ o o o o o / 1
380 \ o o o o /
381 9 `~~~~~~~' 6
382 | | | |
383 | | | +----> Button 1
384 | | +------> Select
385 | +--------> Ground
386 +----------> Button 2
387
388 The Select pin goes to pin 14 on the parallel port.
389
390(pin 14) -----> Select
391
392 The rest is the same as for Multi2 joysticks using db9.c
393
3942.4.3 Sega Saturn
395~~~~~~~~~~~~~~~~~
396 Sega Saturn has eight buttons, and to transfer that, without hacks like
397Genesis 6 pads use, it needs one more select pin. Anyway, it is still
398handled by the db9.c driver. Its pinout is very different from anything
399else. Use this schematic:
400
401 +-----------> Select 1
402 | +---------> Power
403 | | +-------> Up
404 | | | +-----> Down
405 | | | | +---> Ground
406 | | | | |
407 _____________
4085 \ o o o o o / 1
409 \ o o o o /
410 9 `~~~~~~~' 6
411 | | | |
412 | | | +----> Select 2
413 | | +------> Right
414 | +--------> Left
415 +----------> Power
416
417 Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the
418parallel port.
419
420(pin 14) -----> Select 1
421(pin 16) -----> Select 2
422
423 The other pins (Up, Down, Right, Left, Power, Ground) are the same as for
424Multi joysticks using db9.c
425
4263. The drivers
427~~~~~~~~~~~~~~
428 There are three drivers for the parallel port interfaces. Each, as
429described above, allows to connect a different group of joysticks and pads.
430Here are described their command lines:
431
4323.1 gamecon.c
433~~~~~~~~~~~~~
434 Using gamecon.c you can connect up to five devices to one parallel port. It
435uses the following kernel/module command line:
436
437 gamecon.map=port,pad1,pad2,pad3,pad4,pad5
438
439 Where 'port' the number of the parport interface (eg. 0 for parport0).
440
441 And 'pad1' to 'pad5' are pad types connected to different data input pins
442(10,11,12,13,15), as described in section 2.1 of this file.
443
444 The types are:
445
446 Type | Joystick/Pad
447 --------------------
448 0 | None
449 1 | SNES pad
450 2 | NES pad
451 4 | Multisystem 1-button joystick
452 5 | Multisystem 2-button joystick
453 6 | N64 pad
454 7 | Sony PSX controller
455 8 | Sony PSX DDR controller
456 9 | SNES mouse
457
458 The exact type of the PSX controller type is autoprobed when used, so
459hot swapping should work (but is not recommended).
460
461 Should you want to use more than one of parallel ports at once, you can use
462gamecon.map2 and gamecon.map3 as additional command line parameters for two
463more parallel ports.
464
465 There are two options specific to PSX driver portion. gamecon.psx_delay sets
466the command delay when talking to the controllers. The default of 25 should
467work but you can try lowering it for better performance. If your pads don't
468respond try raising it until they work. Setting the type to 8 allows the
469driver to be used with Dance Dance Revolution or similar games. Arrow keys are
470registered as key presses instead of X and Y axes.
471
4723.2 db9.c
473~~~~~~~~~
474 Apart from making an interface, there is nothing difficult on using the
475db9.c driver. It uses the following kernel/module command line:
476
477 db9.dev=port,type
478
479 Where 'port' is the number of the parport interface (eg. 0 for parport0).
480
481 Caveat here: This driver only works on bidirectional parallel ports. If
482your parallel port is recent enough, you should have no trouble with this.
483Old parallel ports may not have this feature.
484
485 'Type' is the type of joystick or pad attached:
486
487 Type | Joystick/Pad
488 --------------------
489 0 | None
490 1 | Multisystem 1-button joystick
491 2 | Multisystem 2-button joystick
492 3 | Genesis pad (3+1 buttons)
493 5 | Genesis pad (5+1 buttons)
494 6 | Genesis pad (6+2 buttons)
495 7 | Saturn pad (8 buttons)
496 8 | Multisystem 1-button joystick (v0.8.0.2 pin-out)
497 9 | Two Multisystem 1-button joysticks (v0.8.0.2 pin-out)
498 10 | Amiga CD32 pad
499
500 Should you want to use more than one of these joysticks/pads at once, you
501can use db9.dev2 and db9.dev3 as additional command line parameters for two
502more joysticks/pads.
503
5043.3 turbografx.c
505~~~~~~~~~~~~~~~~
506 The turbografx.c driver uses a very simple kernel/module command line:
507
508 turbografx.map=port,js1,js2,js3,js4,js5,js6,js7
509
510 Where 'port' is the number of the parport interface (eg. 0 for parport0).
511
512 'jsX' is the number of buttons the Multisystem joysticks connected to the
513interface ports 1-7 have. For a standard multisystem joystick, this is 1.
514
515 Should you want to use more than one of these interfaces at once, you can
516use turbografx.map2 and turbografx.map3 as additional command line parameters
517for two more interfaces.
518
5193.4 PC parallel port pinout
520~~~~~~~~~~~~~~~~~~~~~~~~~~~
521 .----------------------------------------.
522 At the PC: \ 13 12 11 10 9 8 7 6 5 4 3 2 1 /
523 \ 25 24 23 22 21 20 19 18 17 16 15 14 /
524 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
525
526 Pin | Name | Description
527 ~~~~~~|~~~~~~~~~|~~~~~~~~~~
528 1 | /STROBE | Strobe
529 2-9 | D0-D7 | Data Bit 0-7
530 10 | /ACK | Acknowledge
531 11 | BUSY | Busy
532 12 | PE | Paper End
533 13 | SELIN | Select In
534 14 | /AUTOFD | Autofeed
535 15 | /ERROR | Error
536 16 | /INIT | Initialize
537 17 | /SEL | Select
538 18-25 | GND | Signal Ground
539
5403.5 End
541~~~~~~~
542 That's all, folks! Have fun!
diff --git a/Documentation/input/joystick.txt b/Documentation/input/joystick.txt
deleted file mode 100644
index 8d027dc86c1f..000000000000
--- a/Documentation/input/joystick.txt
+++ /dev/null
@@ -1,586 +0,0 @@
1 Linux Joystick driver v2.0.0
2 (c) 1996-2000 Vojtech Pavlik <vojtech@ucw.cz>
3 Sponsored by SuSE
4----------------------------------------------------------------------------
5
60. Disclaimer
7~~~~~~~~~~~~~
8 This program is free software; you can redistribute it and/or modify it
9under the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 2 of the License, or (at your option)
11any later version.
12
13 This program is distributed in the hope that it will be useful, but
14WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16more details.
17
18 You should have received a copy of the GNU General Public License along
19with this program; if not, write to the Free Software Foundation, Inc., 59
20Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Should you need to contact me, the author, you can do so either by e-mail
23- mail your message to <vojtech@ucw.cz>, or by paper mail: Vojtech Pavlik,
24Simunkova 1594, Prague 8, 182 00 Czech Republic
25
26 For your convenience, the GNU General Public License version 2 is included
27in the package: See the file COPYING.
28
291. Intro
30~~~~~~~~
31 The joystick driver for Linux provides support for a variety of joysticks
32and similar devices. It is based on a larger project aiming to support all
33input devices in Linux.
34
35 Should you encounter any problems while using the driver, or joysticks
36this driver can't make complete use of, I'm very interested in hearing about
37them. Bug reports and success stories are also welcome.
38
39 The input project website is at:
40
41 http://atrey.karlin.mff.cuni.cz/~vojtech/input/
42
43 There is also a mailing list for the driver at:
44
45 listproc@atrey.karlin.mff.cuni.cz
46
47send "subscribe linux-joystick Your Name" to subscribe to it.
48
492. Usage
50~~~~~~~~
51 For basic usage you just choose the right options in kernel config and
52you should be set.
53
542.1 inpututils
55~~~~~~~~~~~~~~
56For testing and other purposes (for example serial devices), a set of
57utilities is available at the abovementioned website. I suggest you download
58and install it before going on.
59
602.2 Device nodes
61~~~~~~~~~~~~~~~~
62For applications to be able to use the joysticks,
63you'll have to manually create these nodes in /dev:
64
65cd /dev
66rm js*
67mkdir input
68mknod input/js0 c 13 0
69mknod input/js1 c 13 1
70mknod input/js2 c 13 2
71mknod input/js3 c 13 3
72ln -s input/js0 js0
73ln -s input/js1 js1
74ln -s input/js2 js2
75ln -s input/js3 js3
76
77For testing with inpututils it's also convenient to create these:
78
79mknod input/event0 c 13 64
80mknod input/event1 c 13 65
81mknod input/event2 c 13 66
82mknod input/event3 c 13 67
83
842.4 Modules needed
85~~~~~~~~~~~~~~~~~~
86 For all joystick drivers to function, you'll need the userland interface
87module in kernel, either loaded or compiled in:
88
89 modprobe joydev
90
91 For gameport joysticks, you'll have to load the gameport driver as well;
92
93 modprobe ns558
94
95 And for serial port joysticks, you'll need the serial input line
96discipline module loaded and the inputattach utility started:
97
98 modprobe serport
99 inputattach -xxx /dev/tts/X &
100
101 In addition to that, you'll need the joystick driver module itself, most
102usually you'll have an analog joystick:
103
104 modprobe analog
105
106 For automatic module loading, something like this might work - tailor to
107your needs:
108
109 alias tty-ldisc-2 serport
110 alias char-major-13 input
111 above input joydev ns558 analog
112 options analog map=gamepad,none,2btn
113
1142.5 Verifying that it works
115~~~~~~~~~~~~~~~~~~~~~~~~~~~
116 For testing the joystick driver functionality, there is the jstest
117program in the utilities package. You run it by typing:
118
119 jstest /dev/input/js0
120
121 And it should show a line with the joystick values, which update as you
122move the stick, and press its buttons. The axes should all be zero when the
123joystick is in the center position. They should not jitter by themselves to
124other close values, and they also should be steady in any other position of
125the stick. They should have the full range from -32767 to 32767. If all this
126is met, then it's all fine, and you can play the games. :)
127
128 If it's not, then there might be a problem. Try to calibrate the joystick,
129and if it still doesn't work, read the drivers section of this file, the
130troubleshooting section, and the FAQ.
131
1322.6. Calibration
133~~~~~~~~~~~~~~~~
134 For most joysticks you won't need any manual calibration, since the
135joystick should be autocalibrated by the driver automagically. However, with
136some analog joysticks, that either do not use linear resistors, or if you
137want better precision, you can use the jscal program
138
139 jscal -c /dev/input/js0
140
141 included in the joystick package to set better correction coefficients than
142what the driver would choose itself.
143
144 After calibrating the joystick you can verify if you like the new
145calibration using the jstest command, and if you do, you then can save the
146correction coefficients into a file
147
148 jscal -p /dev/input/js0 > /etc/joystick.cal
149
150 And add a line to your rc script executing that file
151
152 source /etc/joystick.cal
153
154 This way, after the next reboot your joystick will remain calibrated. You
155can also add the jscal -p line to your shutdown script.
156
157
1583. HW specific driver information
159~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160In this section each of the separate hardware specific drivers is described.
161
1623.1 Analog joysticks
163~~~~~~~~~~~~~~~~~~~~
164 The analog.c uses the standard analog inputs of the gameport, and thus
165supports all standard joysticks and gamepads. It uses a very advanced
166routine for this, allowing for data precision that can't be found on any
167other system.
168
169 It also supports extensions like additional hats and buttons compatible
170with CH Flightstick Pro, ThrustMaster FCS or 6 and 8 button gamepads. Saitek
171Cyborg 'digital' joysticks are also supported by this driver, because
172they're basically souped up CHF sticks.
173
174 However the only types that can be autodetected are:
175
176* 2-axis, 4-button joystick
177* 3-axis, 4-button joystick
178* 4-axis, 4-button joystick
179* Saitek Cyborg 'digital' joysticks
180
181 For other joystick types (more/less axes, hats, and buttons) support
182you'll need to specify the types either on the kernel command line or on the
183module command line, when inserting analog into the kernel. The
184parameters are:
185
186 analog.map=<type1>,<type2>,<type3>,....
187
188 'type' is type of the joystick from the table below, defining joysticks
189present on gameports in the system, starting with gameport0, second 'type'
190entry defining joystick on gameport1 and so on.
191
192 Type | Meaning
193 -----------------------------------
194 none | No analog joystick on that port
195 auto | Autodetect joystick
196 2btn | 2-button n-axis joystick
197 y-joy | Two 2-button 2-axis joysticks on an Y-cable
198 y-pad | Two 2-button 2-axis gamepads on an Y-cable
199 fcs | Thrustmaster FCS compatible joystick
200 chf | Joystick with a CH Flightstick compatible hat
201 fullchf | CH Flightstick compatible with two hats and 6 buttons
202 gamepad | 4/6-button n-axis gamepad
203 gamepad8 | 8-button 2-axis gamepad
204
205 In case your joystick doesn't fit in any of the above categories, you can
206specify the type as a number by combining the bits in the table below. This
207is not recommended unless you really know what are you doing. It's not
208dangerous, but not simple either.
209
210 Bit | Meaning
211 --------------------------
212 0 | Axis X1
213 1 | Axis Y1
214 2 | Axis X2
215 3 | Axis Y2
216 4 | Button A
217 5 | Button B
218 6 | Button C
219 7 | Button D
220 8 | CHF Buttons X and Y
221 9 | CHF Hat 1
222 10 | CHF Hat 2
223 11 | FCS Hat
224 12 | Pad Button X
225 13 | Pad Button Y
226 14 | Pad Button U
227 15 | Pad Button V
228 16 | Saitek F1-F4 Buttons
229 17 | Saitek Digital Mode
230 19 | GamePad
231 20 | Joy2 Axis X1
232 21 | Joy2 Axis Y1
233 22 | Joy2 Axis X2
234 23 | Joy2 Axis Y2
235 24 | Joy2 Button A
236 25 | Joy2 Button B
237 26 | Joy2 Button C
238 27 | Joy2 Button D
239 31 | Joy2 GamePad
240
2413.2 Microsoft SideWinder joysticks
242~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
243 Microsoft 'Digital Overdrive' protocol is supported by the sidewinder.c
244module. All currently supported joysticks:
245
246* Microsoft SideWinder 3D Pro
247* Microsoft SideWinder Force Feedback Pro
248* Microsoft SideWinder Force Feedback Wheel
249* Microsoft SideWinder FreeStyle Pro
250* Microsoft SideWinder GamePad (up to four, chained)
251* Microsoft SideWinder Precision Pro
252* Microsoft SideWinder Precision Pro USB
253
254 are autodetected, and thus no module parameters are needed.
255
256 There is one caveat with the 3D Pro. There are 9 buttons reported,
257although the joystick has only 8. The 9th button is the mode switch on the
258rear side of the joystick. However, moving it, you'll reset the joystick,
259and make it unresponsive for about a one third of a second. Furthermore, the
260joystick will also re-center itself, taking the position it was in during
261this time as a new center position. Use it if you want, but think first.
262
263 The SideWinder Standard is not a digital joystick, and thus is supported
264by the analog driver described above.
265
2663.3 Logitech ADI devices
267~~~~~~~~~~~~~~~~~~~~~~~~
268 Logitech ADI protocol is supported by the adi.c module. It should support
269any Logitech device using this protocol. This includes, but is not limited
270to:
271
272* Logitech CyberMan 2
273* Logitech ThunderPad Digital
274* Logitech WingMan Extreme Digital
275* Logitech WingMan Formula
276* Logitech WingMan Interceptor
277* Logitech WingMan GamePad
278* Logitech WingMan GamePad USB
279* Logitech WingMan GamePad Extreme
280* Logitech WingMan Extreme Digital 3D
281
282 ADI devices are autodetected, and the driver supports up to two (any
283combination of) devices on a single gameport, using an Y-cable or chained
284together.
285
286 Logitech WingMan Joystick, Logitech WingMan Attack, Logitech WingMan
287Extreme and Logitech WingMan ThunderPad are not digital joysticks and are
288handled by the analog driver described above. Logitech WingMan Warrior and
289Logitech Magellan are supported by serial drivers described below. Logitech
290WingMan Force and Logitech WingMan Formula Force are supported by the
291I-Force driver described below. Logitech CyberMan is not supported yet.
292
2933.4 Gravis GrIP
294~~~~~~~~~~~~~~~
295 Gravis GrIP protocol is supported by the grip.c module. It currently
296supports:
297
298* Gravis GamePad Pro
299* Gravis BlackHawk Digital
300* Gravis Xterminator
301* Gravis Xterminator DualControl
302
303 All these devices are autodetected, and you can even use any combination
304of up to two of these pads either chained together or using an Y-cable on a
305single gameport.
306
307GrIP MultiPort isn't supported yet. Gravis Stinger is a serial device and is
308supported by the stinger driver. Other Gravis joysticks are supported by the
309analog driver.
310
3113.5 FPGaming A3D and MadCatz A3D
312~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313 The Assassin 3D protocol created by FPGaming, is used both by FPGaming
314themselves and is licensed to MadCatz. A3D devices are supported by the
315a3d.c module. It currently supports:
316
317* FPGaming Assassin 3D
318* MadCatz Panther
319* MadCatz Panther XL
320
321 All these devices are autodetected. Because the Assassin 3D and the Panther
322allow connecting analog joysticks to them, you'll need to load the analog
323driver as well to handle the attached joysticks.
324
325 The trackball should work with USB mousedev module as a normal mouse. See
326the USB documentation for how to setup an USB mouse.
327
3283.6 ThrustMaster DirectConnect (BSP)
329~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
330 The TM DirectConnect (BSP) protocol is supported by the tmdc.c
331module. This includes, but is not limited to:
332
333* ThrustMaster Millennium 3D Interceptor
334* ThrustMaster 3D Rage Pad
335* ThrustMaster Fusion Digital Game Pad
336
337 Devices not directly supported, but hopefully working are:
338
339* ThrustMaster FragMaster
340* ThrustMaster Attack Throttle
341
342 If you have one of these, contact me.
343
344 TMDC devices are autodetected, and thus no parameters to the module
345are needed. Up to two TMDC devices can be connected to one gameport, using
346an Y-cable.
347
3483.7 Creative Labs Blaster
349~~~~~~~~~~~~~~~~~~~~~~~~~
350 The Blaster protocol is supported by the cobra.c module. It supports only
351the:
352
353* Creative Blaster GamePad Cobra
354
355 Up to two of these can be used on a single gameport, using an Y-cable.
356
3573.8 Genius Digital joysticks
358~~~~~~~~~~~~~~~~~~~~~~~~~~~~
359 The Genius digitally communicating joysticks are supported by the gf2k.c
360module. This includes:
361
362* Genius Flight2000 F-23 joystick
363* Genius Flight2000 F-31 joystick
364* Genius G-09D gamepad
365
366 Other Genius digital joysticks are not supported yet, but support can be
367added fairly easily.
368
3693.9 InterAct Digital joysticks
370~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
371 The InterAct digitally communicating joysticks are supported by the
372interact.c module. This includes:
373
374* InterAct HammerHead/FX gamepad
375* InterAct ProPad8 gamepad
376
377 Other InterAct digital joysticks are not supported yet, but support can be
378added fairly easily.
379
3803.10 PDPI Lightning 4 gamecards
381~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382 PDPI Lightning 4 gamecards are supported by the lightning.c module.
383Once the module is loaded, the analog driver can be used to handle the
384joysticks. Digitally communicating joystick will work only on port 0, while
385using Y-cables, you can connect up to 8 analog joysticks to a single L4
386card, 16 in case you have two in your system.
387
3883.11 Trident 4DWave / Aureal Vortex
389~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
390 Soundcards with a Trident 4DWave DX/NX or Aureal Vortex/Vortex2 chipsets
391provide an "Enhanced Game Port" mode where the soundcard handles polling the
392joystick. This mode is supported by the pcigame.c module. Once loaded the
393analog driver can use the enhanced features of these gameports..
394
3953.13 Crystal SoundFusion
396~~~~~~~~~~~~~~~~~~~~~~~~
397 Soundcards with Crystal SoundFusion chipsets provide an "Enhanced Game
398Port", much like the 4DWave or Vortex above. This, and also the normal mode
399for the port of the SoundFusion is supported by the cs461x.c module.
400
4013.14 SoundBlaster Live!
402~~~~~~~~~~~~~~~~~~~~~~~~
403 The Live! has a special PCI gameport, which, although it doesn't provide
404any "Enhanced" stuff like 4DWave and friends, is quite a bit faster than
405its ISA counterparts. It also requires special support, hence the
406emu10k1-gp.c module for it instead of the normal ns558.c one.
407
4083.15 SoundBlaster 64 and 128 - ES1370 and ES1371, ESS Solo1 and S3 SonicVibes
409~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
410 These PCI soundcards have specific gameports. They are handled by the
411sound drivers themselves. Make sure you select gameport support in the
412joystick menu and sound card support in the sound menu for your appropriate
413card.
414
4153.16 Amiga
416~~~~~~~~~~
417 Amiga joysticks, connected to an Amiga, are supported by the amijoy.c
418driver. Since they can't be autodetected, the driver has a command line.
419
420 amijoy.map=<a>,<b>
421
422 a and b define the joysticks connected to the JOY0DAT and JOY1DAT ports of
423the Amiga.
424
425 Value | Joystick type
426 ---------------------
427 0 | None
428 1 | 1-button digital joystick
429
430 No more joystick types are supported now, but that should change in the
431future if I get an Amiga in the reach of my fingers.
432
4333.17 Game console and 8-bit pads and joysticks
434~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
435See joystick-parport.txt for more info.
436
4373.18 SpaceTec/LabTec devices
438~~~~~~~~~~~~~~~~~~~~~~~~~~~~
439 SpaceTec serial devices communicate using the SpaceWare protocol. It is
440supported by the spaceorb.c and spaceball.c drivers. The devices currently
441supported by spaceorb.c are:
442
443* SpaceTec SpaceBall Avenger
444* SpaceTec SpaceOrb 360
445
446Devices currently supported by spaceball.c are:
447
448* SpaceTec SpaceBall 4000 FLX
449
450 In addition to having the spaceorb/spaceball and serport modules in the
451kernel, you also need to attach a serial port to it. to do that, run the
452inputattach program:
453
454 inputattach --spaceorb /dev/tts/x &
455or
456 inputattach --spaceball /dev/tts/x &
457
458where /dev/tts/x is the serial port which the device is connected to. After
459doing this, the device will be reported and will start working.
460
461 There is one caveat with the SpaceOrb. The button #6, the on the bottom
462side of the orb, although reported as an ordinary button, causes internal
463recentering of the spaceorb, moving the zero point to the position in which
464the ball is at the moment of pressing the button. So, think first before
465you bind it to some other function.
466
467SpaceTec SpaceBall 2003 FLX and 3003 FLX are not supported yet.
468
4693.19 Logitech SWIFT devices
470~~~~~~~~~~~~~~~~~~~~~~~~~~~
471 The SWIFT serial protocol is supported by the warrior.c module. It
472currently supports only the:
473
474* Logitech WingMan Warrior
475
476but in the future, Logitech CyberMan (the original one, not CM2) could be
477supported as well. To use the module, you need to run inputattach after you
478insert/compile the module into your kernel:
479
480 inputattach --warrior /dev/tts/x &
481
482/dev/tts/x is the serial port your Warrior is attached to.
483
4843.20 Magellan / Space Mouse
485~~~~~~~~~~~~~~~~~~~~~~~~~~~
486 The Magellan (or Space Mouse), manufactured by LogiCad3d (formerly Space
487Systems), for many other companies (Logitech, HP, ...) is supported by the
488joy-magellan module. It currently supports only the:
489
490* Magellan 3D
491* Space Mouse
492
493models, the additional buttons on the 'Plus' versions are not supported yet.
494
495 To use it, you need to attach the serial port to the driver using the
496
497 inputattach --magellan /dev/tts/x &
498
499command. After that the Magellan will be detected, initialized, will beep,
500and the /dev/input/jsX device should become usable.
501
5023.21 I-Force devices
503~~~~~~~~~~~~~~~~~~~~
504 All I-Force devices are supported by the iforce module. This includes:
505
506* AVB Mag Turbo Force
507* AVB Top Shot Pegasus
508* AVB Top Shot Force Feedback Racing Wheel
509* Logitech WingMan Force
510* Logitech WingMan Force Wheel
511* Guillemot Race Leader Force Feedback
512* Guillemot Force Feedback Racing Wheel
513* Thrustmaster Motor Sport GT
514
515 To use it, you need to attach the serial port to the driver using the
516
517 inputattach --iforce /dev/tts/x &
518
519command. After that the I-Force device will be detected, and the
520/dev/input/jsX device should become usable.
521
522 In case you're using the device via the USB port, the inputattach command
523isn't needed.
524
525 The I-Force driver now supports force feedback via the event interface.
526
527 Please note that Logitech WingMan *3D devices are _not_ supported by this
528module, rather by hid. Force feedback is not supported for those devices.
529Logitech gamepads are also hid devices.
530
5313.22 Gravis Stinger gamepad
532~~~~~~~~~~~~~~~~~~~~~~~~~~~
533 The Gravis Stinger serial port gamepad, designed for use with laptop
534computers, is supported by the stinger.c module. To use it, attach the
535serial port to the driver using:
536
537 inputattach --stinger /dev/tty/x &
538
539where x is the number of the serial port.
540
5414. Troubleshooting
542~~~~~~~~~~~~~~~~~~
543 There is quite a high probability that you run into some problems. For
544testing whether the driver works, if in doubt, use the jstest utility in
545some of its modes. The most useful modes are "normal" - for the 1.x
546interface, and "old" for the "0.x" interface. You run it by typing:
547
548 jstest --normal /dev/input/js0
549 jstest --old /dev/input/js0
550
551 Additionally you can do a test with the evtest utility:
552
553 evtest /dev/input/event0
554
555 Oh, and read the FAQ! :)
556
5575. FAQ
558~~~~~~
559Q: Running 'jstest /dev/input/js0' results in "File not found" error. What's the
560 cause?
561A: The device files don't exist. Create them (see section 2.2).
562
563Q: Is it possible to connect my old Atari/Commodore/Amiga/console joystick
564 or pad that uses a 9-pin D-type cannon connector to the serial port of my
565 PC?
566A: Yes, it is possible, but it'll burn your serial port or the pad. It
567 won't work, of course.
568
569Q: My joystick doesn't work with Quake / Quake 2. What's the cause?
570A: Quake / Quake 2 don't support joystick. Use joy2key to simulate keypresses
571 for them.
572
5736. Programming Interface
574~~~~~~~~~~~~~~~~~~~~~~~~
575 The 1.0 driver uses a new, event based approach to the joystick driver.
576Instead of the user program polling for the joystick values, the joystick
577driver now reports only any changes of its state. See joystick-api.txt,
578joystick.h and jstest.c included in the joystick package for more
579information. The joystick device can be used in either blocking or
580nonblocking mode and supports select() calls.
581
582 For backward compatibility the old (v0.x) interface is still included.
583Any call to the joystick driver using the old interface will return values
584that are compatible to the old interface. This interface is still limited
585to 2 axes, and applications using it usually decode only 2 buttons, although
586the driver provides up to 32.
diff --git a/Documentation/input/multi-touch-protocol.txt b/Documentation/input/multi-touch-protocol.rst
index c51f1146f3bd..8035868c56bc 100644
--- a/Documentation/input/multi-touch-protocol.txt
+++ b/Documentation/input/multi-touch-protocol.rst
@@ -1,6 +1,10 @@
1.. include:: <isonum.txt>
2
3=========================
1Multi-touch (MT) Protocol 4Multi-touch (MT) Protocol
2------------------------- 5=========================
3 Copyright (C) 2009-2010 Henrik Rydberg <rydberg@euromail.se> 6
7:Copyright: |copy| 2009-2010 Henrik Rydberg <rydberg@euromail.se>
4 8
5 9
6Introduction 10Introduction
@@ -18,6 +22,9 @@ describes how to send the raw data for all contacts to the receiver. For
18devices capable of tracking identifiable contacts (type B), the protocol 22devices capable of tracking identifiable contacts (type B), the protocol
19describes how to send updates for individual contacts via event slots. 23describes how to send updates for individual contacts via event slots.
20 24
25.. note::
26 MT potocol type A is obsolete, all kernel drivers have been
27 converted to use type B.
21 28
22Protocol Usage 29Protocol Usage
23-------------- 30--------------
@@ -47,12 +54,12 @@ The main difference between the stateless type A protocol and the stateful
47type B slot protocol lies in the usage of identifiable contacts to reduce 54type B slot protocol lies in the usage of identifiable contacts to reduce
48the amount of data sent to userspace. The slot protocol requires the use of 55the amount of data sent to userspace. The slot protocol requires the use of
49the ABS_MT_TRACKING_ID, either provided by the hardware or computed from 56the ABS_MT_TRACKING_ID, either provided by the hardware or computed from
50the raw data [5]. 57the raw data [#f5]_.
51 58
52For type A devices, the kernel driver should generate an arbitrary 59For type A devices, the kernel driver should generate an arbitrary
53enumeration of the full set of anonymous contacts currently on the 60enumeration of the full set of anonymous contacts currently on the
54surface. The order in which the packets appear in the event stream is not 61surface. The order in which the packets appear in the event stream is not
55important. Event filtering and finger tracking is left to user space [3]. 62important. Event filtering and finger tracking is left to user space [#f3]_.
56 63
57For type B devices, the kernel driver should associate a slot with each 64For type B devices, the kernel driver should associate a slot with each
58identified contact, and use that slot to propagate changes for the contact. 65identified contact, and use that slot to propagate changes for the contact.
@@ -86,7 +93,7 @@ Protocol Example A
86------------------ 93------------------
87 94
88Here is what a minimal event sequence for a two-contact touch would look 95Here is what a minimal event sequence for a two-contact touch would look
89like for a type A device: 96like for a type A device::
90 97
91 ABS_MT_POSITION_X x[0] 98 ABS_MT_POSITION_X x[0]
92 ABS_MT_POSITION_Y y[0] 99 ABS_MT_POSITION_Y y[0]
@@ -100,14 +107,14 @@ The sequence after moving one of the contacts looks exactly the same; the
100raw data for all present contacts are sent between every synchronization 107raw data for all present contacts are sent between every synchronization
101with SYN_REPORT. 108with SYN_REPORT.
102 109
103Here is the sequence after lifting the first contact: 110Here is the sequence after lifting the first contact::
104 111
105 ABS_MT_POSITION_X x[1] 112 ABS_MT_POSITION_X x[1]
106 ABS_MT_POSITION_Y y[1] 113 ABS_MT_POSITION_Y y[1]
107 SYN_MT_REPORT 114 SYN_MT_REPORT
108 SYN_REPORT 115 SYN_REPORT
109 116
110And here is the sequence after lifting the second contact: 117And here is the sequence after lifting the second contact::
111 118
112 SYN_MT_REPORT 119 SYN_MT_REPORT
113 SYN_REPORT 120 SYN_REPORT
@@ -122,7 +129,7 @@ Protocol Example B
122------------------ 129------------------
123 130
124Here is what a minimal event sequence for a two-contact touch would look 131Here is what a minimal event sequence for a two-contact touch would look
125like for a type B device: 132like for a type B device::
126 133
127 ABS_MT_SLOT 0 134 ABS_MT_SLOT 0
128 ABS_MT_TRACKING_ID 45 135 ABS_MT_TRACKING_ID 45
@@ -134,13 +141,13 @@ like for a type B device:
134 ABS_MT_POSITION_Y y[1] 141 ABS_MT_POSITION_Y y[1]
135 SYN_REPORT 142 SYN_REPORT
136 143
137Here is the sequence after moving contact 45 in the x direction: 144Here is the sequence after moving contact 45 in the x direction::
138 145
139 ABS_MT_SLOT 0 146 ABS_MT_SLOT 0
140 ABS_MT_POSITION_X x[0] 147 ABS_MT_POSITION_X x[0]
141 SYN_REPORT 148 SYN_REPORT
142 149
143Here is the sequence after lifting the contact in slot 0: 150Here is the sequence after lifting the contact in slot 0::
144 151
145 ABS_MT_TRACKING_ID -1 152 ABS_MT_TRACKING_ID -1
146 SYN_REPORT 153 SYN_REPORT
@@ -149,7 +156,7 @@ The slot being modified is already 0, so the ABS_MT_SLOT is omitted. The
149message removes the association of slot 0 with contact 45, thereby 156message removes the association of slot 0 with contact 45, thereby
150destroying contact 45 and freeing slot 0 to be reused for another contact. 157destroying contact 45 and freeing slot 0 to be reused for another contact.
151 158
152Finally, here is the sequence after lifting the second contact: 159Finally, here is the sequence after lifting the second contact::
153 160
154 ABS_MT_SLOT 1 161 ABS_MT_SLOT 1
155 ABS_MT_TRACKING_ID -1 162 ABS_MT_TRACKING_ID -1
@@ -181,6 +188,8 @@ ABS_MT_PRESSURE may be used to provide the pressure on the contact area
181instead. Devices capable of contact hovering can use ABS_MT_DISTANCE to 188instead. Devices capable of contact hovering can use ABS_MT_DISTANCE to
182indicate the distance between the contact and the surface. 189indicate the distance between the contact and the surface.
183 190
191::
192
184 193
185 Linux MT Win8 194 Linux MT Win8
186 __________ _______________________ 195 __________ _______________________
@@ -212,7 +221,7 @@ via ABS_MT_BLOB_ID.
212 221
213The ABS_MT_TOOL_TYPE may be used to specify whether the touching tool is a 222The ABS_MT_TOOL_TYPE may be used to specify whether the touching tool is a
214finger or a pen or something else. Finally, the ABS_MT_TRACKING_ID event 223finger or a pen or something else. Finally, the ABS_MT_TRACKING_ID event
215may be used to track identified contacts over time [5]. 224may be used to track identified contacts over time [#f5]_.
216 225
217In the type B protocol, ABS_MT_TOOL_TYPE and ABS_MT_TRACKING_ID are 226In the type B protocol, ABS_MT_TOOL_TYPE and ABS_MT_TRACKING_ID are
218implicitly handled by input core; drivers should instead call 227implicitly handled by input core; drivers should instead call
@@ -223,117 +232,103 @@ Event Semantics
223--------------- 232---------------
224 233
225ABS_MT_TOUCH_MAJOR 234ABS_MT_TOUCH_MAJOR
226 235 The length of the major axis of the contact. The length should be given in
227The length of the major axis of the contact. The length should be given in 236 surface units. If the surface has an X times Y resolution, the largest
228surface units. If the surface has an X times Y resolution, the largest 237 possible value of ABS_MT_TOUCH_MAJOR is sqrt(X^2 + Y^2), the diagonal [#f4]_.
229possible value of ABS_MT_TOUCH_MAJOR is sqrt(X^2 + Y^2), the diagonal [4].
230 238
231ABS_MT_TOUCH_MINOR 239ABS_MT_TOUCH_MINOR
232 240 The length, in surface units, of the minor axis of the contact. If the
233The length, in surface units, of the minor axis of the contact. If the 241 contact is circular, this event can be omitted [#f4]_.
234contact is circular, this event can be omitted [4].
235 242
236ABS_MT_WIDTH_MAJOR 243ABS_MT_WIDTH_MAJOR
237 244 The length, in surface units, of the major axis of the approaching
238The length, in surface units, of the major axis of the approaching 245 tool. This should be understood as the size of the tool itself. The
239tool. This should be understood as the size of the tool itself. The 246 orientation of the contact and the approaching tool are assumed to be the
240orientation of the contact and the approaching tool are assumed to be the 247 same [#f4]_.
241same [4].
242 248
243ABS_MT_WIDTH_MINOR 249ABS_MT_WIDTH_MINOR
250 The length, in surface units, of the minor axis of the approaching
251 tool. Omit if circular [#f4]_.
244 252
245The length, in surface units, of the minor axis of the approaching 253 The above four values can be used to derive additional information about
246tool. Omit if circular [4]. 254 the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates
247 255 the notion of pressure. The fingers of the hand and the palm all have
248The above four values can be used to derive additional information about 256 different characteristic widths.
249the contact. The ratio ABS_MT_TOUCH_MAJOR / ABS_MT_WIDTH_MAJOR approximates
250the notion of pressure. The fingers of the hand and the palm all have
251different characteristic widths.
252 257
253ABS_MT_PRESSURE 258ABS_MT_PRESSURE
254 259 The pressure, in arbitrary units, on the contact area. May be used instead
255The pressure, in arbitrary units, on the contact area. May be used instead 260 of TOUCH and WIDTH for pressure-based devices or any device with a spatial
256of TOUCH and WIDTH for pressure-based devices or any device with a spatial 261 signal intensity distribution.
257signal intensity distribution.
258 262
259ABS_MT_DISTANCE 263ABS_MT_DISTANCE
260 264 The distance, in surface units, between the contact and the surface. Zero
261The distance, in surface units, between the contact and the surface. Zero 265 distance means the contact is touching the surface. A positive number means
262distance means the contact is touching the surface. A positive number means 266 the contact is hovering above the surface.
263the contact is hovering above the surface.
264 267
265ABS_MT_ORIENTATION 268ABS_MT_ORIENTATION
266 269 The orientation of the touching ellipse. The value should describe a signed
267The orientation of the touching ellipse. The value should describe a signed 270 quarter of a revolution clockwise around the touch center. The signed value
268quarter of a revolution clockwise around the touch center. The signed value 271 range is arbitrary, but zero should be returned for an ellipse aligned with
269range is arbitrary, but zero should be returned for an ellipse aligned with 272 the Y axis of the surface, a negative value when the ellipse is turned to
270the Y axis of the surface, a negative value when the ellipse is turned to 273 the left, and a positive value when the ellipse is turned to the
271the left, and a positive value when the ellipse is turned to the 274 right. When completely aligned with the X axis, the range max should be
272right. When completely aligned with the X axis, the range max should be 275 returned.
273returned. 276
274 277 Touch ellipsis are symmetrical by default. For devices capable of true 360
275Touch ellipsis are symmetrical by default. For devices capable of true 360 278 degree orientation, the reported orientation must exceed the range max to
276degree orientation, the reported orientation must exceed the range max to 279 indicate more than a quarter of a revolution. For an upside-down finger,
277indicate more than a quarter of a revolution. For an upside-down finger, 280 range max * 2 should be returned.
278range max * 2 should be returned. 281
279 282 Orientation can be omitted if the touch area is circular, or if the
280Orientation can be omitted if the touch area is circular, or if the 283 information is not available in the kernel driver. Partial orientation
281information is not available in the kernel driver. Partial orientation 284 support is possible if the device can distinguish between the two axis, but
282support is possible if the device can distinguish between the two axis, but 285 not (uniquely) any values in between. In such cases, the range of
283not (uniquely) any values in between. In such cases, the range of 286 ABS_MT_ORIENTATION should be [0, 1] [#f4]_.
284ABS_MT_ORIENTATION should be [0, 1] [4].
285 287
286ABS_MT_POSITION_X 288ABS_MT_POSITION_X
287 289 The surface X coordinate of the center of the touching ellipse.
288The surface X coordinate of the center of the touching ellipse.
289 290
290ABS_MT_POSITION_Y 291ABS_MT_POSITION_Y
291 292 The surface Y coordinate of the center of the touching ellipse.
292The surface Y coordinate of the center of the touching ellipse.
293 293
294ABS_MT_TOOL_X 294ABS_MT_TOOL_X
295 295 The surface X coordinate of the center of the approaching tool. Omit if
296The surface X coordinate of the center of the approaching tool. Omit if 296 the device cannot distinguish between the intended touch point and the
297the device cannot distinguish between the intended touch point and the 297 tool itself.
298tool itself.
299 298
300ABS_MT_TOOL_Y 299ABS_MT_TOOL_Y
300 The surface Y coordinate of the center of the approaching tool. Omit if the
301 device cannot distinguish between the intended touch point and the tool
302 itself.
301 303
302The surface Y coordinate of the center of the approaching tool. Omit if the 304 The four position values can be used to separate the position of the touch
303device cannot distinguish between the intended touch point and the tool 305 from the position of the tool. If both positions are present, the major
304itself. 306 tool axis points towards the touch point [#f1]_. Otherwise, the tool axes are
305 307 aligned with the touch axes.
306The four position values can be used to separate the position of the touch
307from the position of the tool. If both positions are present, the major
308tool axis points towards the touch point [1]. Otherwise, the tool axes are
309aligned with the touch axes.
310 308
311ABS_MT_TOOL_TYPE 309ABS_MT_TOOL_TYPE
312 310 The type of approaching tool. A lot of kernel drivers cannot distinguish
313The type of approaching tool. A lot of kernel drivers cannot distinguish 311 between different tool types, such as a finger or a pen. In such cases, the
314between different tool types, such as a finger or a pen. In such cases, the 312 event should be omitted. The protocol currently supports MT_TOOL_FINGER,
315event should be omitted. The protocol currently supports MT_TOOL_FINGER, 313 MT_TOOL_PEN, and MT_TOOL_PALM [#f2]_. For type B devices, this event is
316MT_TOOL_PEN, and MT_TOOL_PALM [2]. For type B devices, this event is handled 314 handled by input core; drivers should instead use
317by input core; drivers should instead use input_mt_report_slot_state(). 315 input_mt_report_slot_state(). A contact's ABS_MT_TOOL_TYPE may change over
318A contact's ABS_MT_TOOL_TYPE may change over time while still touching the 316 time while still touching the device, because the firmware may not be able
319device, because the firmware may not be able to determine which tool is being 317 to determine which tool is being used when it first appears.
320used when it first appears.
321 318
322ABS_MT_BLOB_ID 319ABS_MT_BLOB_ID
323 320 The BLOB_ID groups several packets together into one arbitrarily shaped
324The BLOB_ID groups several packets together into one arbitrarily shaped 321 contact. The sequence of points forms a polygon which defines the shape of
325contact. The sequence of points forms a polygon which defines the shape of 322 the contact. This is a low-level anonymous grouping for type A devices, and
326the contact. This is a low-level anonymous grouping for type A devices, and 323 should not be confused with the high-level trackingID [#f5]_. Most type A
327should not be confused with the high-level trackingID [5]. Most type A 324 devices do not have blob capability, so drivers can safely omit this event.
328devices do not have blob capability, so drivers can safely omit this event.
329 325
330ABS_MT_TRACKING_ID 326ABS_MT_TRACKING_ID
331 327 The TRACKING_ID identifies an initiated contact throughout its life cycle
332The TRACKING_ID identifies an initiated contact throughout its life cycle 328 [#f5]_. The value range of the TRACKING_ID should be large enough to ensure
333[5]. The value range of the TRACKING_ID should be large enough to ensure 329 unique identification of a contact maintained over an extended period of
334unique identification of a contact maintained over an extended period of 330 time. For type B devices, this event is handled by input core; drivers
335time. For type B devices, this event is handled by input core; drivers 331 should instead use input_mt_report_slot_state().
336should instead use input_mt_report_slot_state().
337 332
338 333
339Event Computation 334Event Computation
@@ -346,7 +341,7 @@ this section gives recipes for how to compute certain events.
346For devices reporting contacts as rectangular shapes, signed orientation 341For devices reporting contacts as rectangular shapes, signed orientation
347cannot be obtained. Assuming X and Y are the lengths of the sides of the 342cannot be obtained. Assuming X and Y are the lengths of the sides of the
348touching rectangle, here is a simple formula that retains the most 343touching rectangle, here is a simple formula that retains the most
349information possible: 344information possible::
350 345
351 ABS_MT_TOUCH_MAJOR := max(X, Y) 346 ABS_MT_TOUCH_MAJOR := max(X, Y)
352 ABS_MT_TOUCH_MINOR := min(X, Y) 347 ABS_MT_TOUCH_MINOR := min(X, Y)
@@ -356,7 +351,7 @@ The range of ABS_MT_ORIENTATION should be set to [0, 1], to indicate that
356the device can distinguish between a finger along the Y axis (0) and a 351the device can distinguish between a finger along the Y axis (0) and a
357finger along the X axis (1). 352finger along the X axis (1).
358 353
359For win8 devices with both T and C coordinates, the position mapping is 354For win8 devices with both T and C coordinates, the position mapping is::
360 355
361 ABS_MT_POSITION_X := T_X 356 ABS_MT_POSITION_X := T_X
362 ABS_MT_POSITION_Y := T_Y 357 ABS_MT_POSITION_Y := T_Y
@@ -365,7 +360,7 @@ For win8 devices with both T and C coordinates, the position mapping is
365 360
366Unfortunately, there is not enough information to specify both the touching 361Unfortunately, there is not enough information to specify both the touching
367ellipse and the tool ellipse, so one has to resort to approximations. One 362ellipse and the tool ellipse, so one has to resort to approximations. One
368simple scheme, which is compatible with earlier usage, is: 363simple scheme, which is compatible with earlier usage, is::
369 364
370 ABS_MT_TOUCH_MAJOR := min(X, Y) 365 ABS_MT_TOUCH_MAJOR := min(X, Y)
371 ABS_MT_TOUCH_MINOR := <not used> 366 ABS_MT_TOUCH_MINOR := <not used>
@@ -386,7 +381,7 @@ The process of finger tracking, i.e., to assign a unique trackingID to each
386initiated contact on the surface, is a Euclidian Bipartite Matching 381initiated contact on the surface, is a Euclidian Bipartite Matching
387problem. At each event synchronization, the set of actual contacts is 382problem. At each event synchronization, the set of actual contacts is
388matched to the set of contacts from the previous synchronization. A full 383matched to the set of contacts from the previous synchronization. A full
389implementation can be found in [3]. 384implementation can be found in [#f3]_.
390 385
391 386
392Gestures 387Gestures
@@ -408,11 +403,8 @@ in a finger packet must not be recognized as single-touch events.
408For type A devices, all finger data bypasses input filtering, since 403For type A devices, all finger data bypasses input filtering, since
409subsequent events of the same type refer to different fingers. 404subsequent events of the same type refer to different fingers.
410 405
411For example usage of the type A protocol, see the bcm5974 driver. For 406.. [#f1] Also, the difference (TOOL_X - POSITION_X) can be used to model tilt.
412example usage of the type B protocol, see the hid-egalax driver. 407.. [#f2] The list can of course be extended.
413 408.. [#f3] The mtdev project: http://bitmath.org/code/mtdev/.
414[1] Also, the difference (TOOL_X - POSITION_X) can be used to model tilt. 409.. [#f4] See the section on event computation.
415[2] The list can of course be extended. 410.. [#f5] See the section on finger tracking.
416[3] The mtdev project: http://bitmath.org/code/mtdev/.
417[4] See the section on event computation.
418[5] See the section on finger tracking.
diff --git a/Documentation/input/notifier.txt b/Documentation/input/notifier.rst
index 95172ca6f3d2..161350cb865e 100644
--- a/Documentation/input/notifier.txt
+++ b/Documentation/input/notifier.rst
@@ -1,4 +1,6 @@
1=================
1Keyboard notifier 2Keyboard notifier
3=================
2 4
3One can use register_keyboard_notifier to get called back on keyboard 5One can use register_keyboard_notifier to get called back on keyboard
4events (see kbd_keycode() function for details). The passed structure is 6events (see kbd_keycode() function for details). The passed structure is
@@ -23,9 +25,9 @@ For each kind of event but the last, the callback may return NOTIFY_STOP in
23order to "eat" the event: the notify loop is stopped and the keyboard event is 25order to "eat" the event: the notify loop is stopped and the keyboard event is
24dropped. 26dropped.
25 27
26In a rough C snippet, we have: 28In a rough C snippet, we have::
27 29
28kbd_keycode(keycode) { 30 kbd_keycode(keycode) {
29 ... 31 ...
30 params.value = keycode; 32 params.value = keycode;
31 if (notifier_call_chain(KBD_KEYCODE,&params) == NOTIFY_STOP) 33 if (notifier_call_chain(KBD_KEYCODE,&params) == NOTIFY_STOP)
@@ -47,6 +49,6 @@ kbd_keycode(keycode) {
47 return; 49 return;
48 apply keysym; 50 apply keysym;
49 notifier_call_chain(KBD_POST_KEYSYM,&params); 51 notifier_call_chain(KBD_POST_KEYSYM,&params);
50} 52 }
51 53
52NOTE: This notifier is usually called from interrupt context. 54.. note:: This notifier is usually called from interrupt context.
diff --git a/Documentation/input/sentelic.txt b/Documentation/input/sentelic.txt
deleted file mode 100644
index 89251e2a3eba..000000000000
--- a/Documentation/input/sentelic.txt
+++ /dev/null
@@ -1,873 +0,0 @@
1Copyright (C) 2002-2011 Sentelic Corporation.
2Last update: Dec-07-2011
3
4==============================================================================
5* Finger Sensing Pad Intellimouse Mode(scrolling wheel, 4th and 5th buttons)
6==============================================================================
7A) MSID 4: Scrolling wheel mode plus Forward page(4th button) and Backward
8 page (5th button)
9@1. Set sample rate to 200;
10@2. Set sample rate to 200;
11@3. Set sample rate to 80;
12@4. Issuing the "Get device ID" command (0xF2) and waits for the response;
13@5. FSP will respond 0x04.
14
15Packet 1
16 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
17BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
18 1 |Y|X|y|x|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 | | |B|F|W|W|W|W|
19 |---------------| |---------------| |---------------| |---------------|
20
21Byte 1: Bit7 => Y overflow
22 Bit6 => X overflow
23 Bit5 => Y sign bit
24 Bit4 => X sign bit
25 Bit3 => 1
26 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
27 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
28 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
29Byte 2: X Movement(9-bit 2's complement integers)
30Byte 3: Y Movement(9-bit 2's complement integers)
31Byte 4: Bit3~Bit0 => the scrolling wheel's movement since the last data report.
32 valid values, -8 ~ +7
33 Bit4 => 1 = 4th mouse button is pressed, Forward one page.
34 0 = 4th mouse button is not pressed.
35 Bit5 => 1 = 5th mouse button is pressed, Backward one page.
36 0 = 5th mouse button is not pressed.
37
38B) MSID 6: Horizontal and Vertical scrolling.
39@ Set bit 1 in register 0x40 to 1
40
41# FSP replaces scrolling wheel's movement as 4 bits to show horizontal and
42 vertical scrolling.
43
44Packet 1
45 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
46BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
47 1 |Y|X|y|x|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 | | |B|F|r|l|u|d|
48 |---------------| |---------------| |---------------| |---------------|
49
50Byte 1: Bit7 => Y overflow
51 Bit6 => X overflow
52 Bit5 => Y sign bit
53 Bit4 => X sign bit
54 Bit3 => 1
55 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
56 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
57 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
58Byte 2: X Movement(9-bit 2's complement integers)
59Byte 3: Y Movement(9-bit 2's complement integers)
60Byte 4: Bit0 => the Vertical scrolling movement downward.
61 Bit1 => the Vertical scrolling movement upward.
62 Bit2 => the Horizontal scrolling movement leftward.
63 Bit3 => the Horizontal scrolling movement rightward.
64 Bit4 => 1 = 4th mouse button is pressed, Forward one page.
65 0 = 4th mouse button is not pressed.
66 Bit5 => 1 = 5th mouse button is pressed, Backward one page.
67 0 = 5th mouse button is not pressed.
68
69C) MSID 7:
70# FSP uses 2 packets (8 Bytes) to represent Absolute Position.
71 so we have PACKET NUMBER to identify packets.
72 If PACKET NUMBER is 0, the packet is Packet 1.
73 If PACKET NUMBER is 1, the packet is Packet 2.
74 Please count this number in program.
75
76# MSID6 special packet will be enable at the same time when enable MSID 7.
77
78==============================================================================
79* Absolute position for STL3886-G0.
80==============================================================================
81@ Set bit 2 or 3 in register 0x40 to 1
82@ Set bit 6 in register 0x40 to 1
83
84Packet 1 (ABSOLUTE POSITION)
85 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
86BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
87 1 |0|1|V|1|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|d|u|X|X|Y|Y|
88 |---------------| |---------------| |---------------| |---------------|
89
90Byte 1: Bit7~Bit6 => 00, Normal data packet
91 => 01, Absolute coordination packet
92 => 10, Notify packet
93 Bit5 => valid bit
94 Bit4 => 1
95 Bit3 => 1
96 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
97 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
98 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
99Byte 2: X coordinate (xpos[9:2])
100Byte 3: Y coordinate (ypos[9:2])
101Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
102 Bit3~Bit2 => X coordinate (ypos[1:0])
103 Bit4 => scroll up
104 Bit5 => scroll down
105 Bit6 => scroll left
106 Bit7 => scroll right
107
108Notify Packet for G0
109 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
110BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
111 1 |1|0|0|1|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |M|M|M|M|M|M|M|M| 4 |0|0|0|0|0|0|0|0|
112 |---------------| |---------------| |---------------| |---------------|
113
114Byte 1: Bit7~Bit6 => 00, Normal data packet
115 => 01, Absolute coordination packet
116 => 10, Notify packet
117 Bit5 => 0
118 Bit4 => 1
119 Bit3 => 1
120 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
121 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
122 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
123Byte 2: Message Type => 0x5A (Enable/Disable status packet)
124 Mode Type => 0xA5 (Normal/Icon mode status)
125Byte 3: Message Type => 0x00 (Disabled)
126 => 0x01 (Enabled)
127 Mode Type => 0x00 (Normal)
128 => 0x01 (Icon)
129Byte 4: Bit7~Bit0 => Don't Care
130
131==============================================================================
132* Absolute position for STL3888-Ax.
133==============================================================================
134Packet 1 (ABSOLUTE POSITION)
135 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
136BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
137 1 |0|1|V|A|1|L|0|1| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |x|x|y|y|X|X|Y|Y|
138 |---------------| |---------------| |---------------| |---------------|
139
140Byte 1: Bit7~Bit6 => 00, Normal data packet
141 => 01, Absolute coordination packet
142 => 10, Notify packet
143 => 11, Normal data packet with on-pad click
144 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
145 When both fingers are up, the last two reports have zero valid
146 bit.
147 Bit4 => arc
148 Bit3 => 1
149 Bit2 => Left Button, 1 is pressed, 0 is released.
150 Bit1 => 0
151 Bit0 => 1
152Byte 2: X coordinate (xpos[9:2])
153Byte 3: Y coordinate (ypos[9:2])
154Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
155 Bit3~Bit2 => X coordinate (ypos[1:0])
156 Bit5~Bit4 => y1_g
157 Bit7~Bit6 => x1_g
158
159Packet 2 (ABSOLUTE POSITION)
160 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
161BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
162 1 |0|1|V|A|1|R|1|0| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |x|x|y|y|X|X|Y|Y|
163 |---------------| |---------------| |---------------| |---------------|
164
165Byte 1: Bit7~Bit6 => 00, Normal data packet
166 => 01, Absolute coordinates packet
167 => 10, Notify packet
168 => 11, Normal data packet with on-pad click
169 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
170 When both fingers are up, the last two reports have zero valid
171 bit.
172 Bit4 => arc
173 Bit3 => 1
174 Bit2 => Right Button, 1 is pressed, 0 is released.
175 Bit1 => 1
176 Bit0 => 0
177Byte 2: X coordinate (xpos[9:2])
178Byte 3: Y coordinate (ypos[9:2])
179Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
180 Bit3~Bit2 => X coordinate (ypos[1:0])
181 Bit5~Bit4 => y2_g
182 Bit7~Bit6 => x2_g
183
184Notify Packet for STL3888-Ax
185 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
186BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
187 1 |1|0|1|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|d|u|0|0|0|0|
188 |---------------| |---------------| |---------------| |---------------|
189
190Byte 1: Bit7~Bit6 => 00, Normal data packet
191 => 01, Absolute coordinates packet
192 => 10, Notify packet
193 => 11, Normal data packet with on-pad click
194 Bit5 => 1
195 Bit4 => when in absolute coordinates mode (valid when EN_PKT_GO is 1):
196 0: left button is generated by the on-pad command
197 1: left button is generated by the external button
198 Bit3 => 1
199 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
200 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
201 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
202Byte 2: Message Type => 0xB7 (Multi Finger, Multi Coordinate mode)
203Byte 3: Bit7~Bit6 => Don't care
204 Bit5~Bit4 => Number of fingers
205 Bit3~Bit1 => Reserved
206 Bit0 => 1: enter gesture mode; 0: leaving gesture mode
207Byte 4: Bit7 => scroll right button
208 Bit6 => scroll left button
209 Bit5 => scroll down button
210 Bit4 => scroll up button
211 * Note that if gesture and additional button (Bit4~Bit7)
212 happen at the same time, the button information will not
213 be sent.
214 Bit3~Bit0 => Reserved
215
216Sample sequence of Multi-finger, Multi-coordinate mode:
217
218 notify packet (valid bit == 1), abs pkt 1, abs pkt 2, abs pkt 1,
219 abs pkt 2, ..., notify packet (valid bit == 0)
220
221==============================================================================
222* Absolute position for STL3888-B0.
223==============================================================================
224Packet 1(ABSOLUTE POSITION)
225 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
226BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
227 1 |0|1|V|F|1|0|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|u|d|X|X|Y|Y|
228 |---------------| |---------------| |---------------| |---------------|
229
230Byte 1: Bit7~Bit6 => 00, Normal data packet
231 => 01, Absolute coordinates packet
232 => 10, Notify packet
233 => 11, Normal data packet with on-pad click
234 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
235 When both fingers are up, the last two reports have zero valid
236 bit.
237 Bit4 => finger up/down information. 1: finger down, 0: finger up.
238 Bit3 => 1
239 Bit2 => finger index, 0 is the first finger, 1 is the second finger.
240 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
241 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
242Byte 2: X coordinate (xpos[9:2])
243Byte 3: Y coordinate (ypos[9:2])
244Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
245 Bit3~Bit2 => X coordinate (ypos[1:0])
246 Bit4 => scroll down button
247 Bit5 => scroll up button
248 Bit6 => scroll left button
249 Bit7 => scroll right button
250
251Packet 2 (ABSOLUTE POSITION)
252 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
253BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
254 1 |0|1|V|F|1|1|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|u|d|X|X|Y|Y|
255 |---------------| |---------------| |---------------| |---------------|
256
257Byte 1: Bit7~Bit6 => 00, Normal data packet
258 => 01, Absolute coordination packet
259 => 10, Notify packet
260 => 11, Normal data packet with on-pad click
261 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up.
262 When both fingers are up, the last two reports have zero valid
263 bit.
264 Bit4 => finger up/down information. 1: finger down, 0: finger up.
265 Bit3 => 1
266 Bit2 => finger index, 0 is the first finger, 1 is the second finger.
267 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
268 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
269Byte 2: X coordinate (xpos[9:2])
270Byte 3: Y coordinate (ypos[9:2])
271Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
272 Bit3~Bit2 => X coordinate (ypos[1:0])
273 Bit4 => scroll down button
274 Bit5 => scroll up button
275 Bit6 => scroll left button
276 Bit7 => scroll right button
277
278Notify Packet for STL3888-B0
279 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
280BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
281 1 |1|0|1|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|u|d|0|0|0|0|
282 |---------------| |---------------| |---------------| |---------------|
283
284Byte 1: Bit7~Bit6 => 00, Normal data packet
285 => 01, Absolute coordination packet
286 => 10, Notify packet
287 => 11, Normal data packet with on-pad click
288 Bit5 => 1
289 Bit4 => when in absolute coordinates mode (valid when EN_PKT_GO is 1):
290 0: left button is generated by the on-pad command
291 1: left button is generated by the external button
292 Bit3 => 1
293 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
294 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
295 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
296Byte 2: Message Type => 0xB7 (Multi Finger, Multi Coordinate mode)
297Byte 3: Bit7~Bit6 => Don't care
298 Bit5~Bit4 => Number of fingers
299 Bit3~Bit1 => Reserved
300 Bit0 => 1: enter gesture mode; 0: leaving gesture mode
301Byte 4: Bit7 => scroll right button
302 Bit6 => scroll left button
303 Bit5 => scroll up button
304 Bit4 => scroll down button
305 * Note that if gesture and additional button(Bit4~Bit7)
306 happen at the same time, the button information will not
307 be sent.
308 Bit3~Bit0 => Reserved
309
310Sample sequence of Multi-finger, Multi-coordinate mode:
311
312 notify packet (valid bit == 1), abs pkt 1, abs pkt 2, abs pkt 1,
313 abs pkt 2, ..., notify packet (valid bit == 0)
314
315==============================================================================
316* Absolute position for STL3888-Cx and STL3888-Dx.
317==============================================================================
318Single Finger, Absolute Coordinate Mode (SFAC)
319 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
320BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
321 1 |0|1|0|P|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|B|F|X|X|Y|Y|
322 |---------------| |---------------| |---------------| |---------------|
323
324Byte 1: Bit7~Bit6 => 00, Normal data packet
325 => 01, Absolute coordinates packet
326 => 10, Notify packet
327 Bit5 => Coordinate mode(always 0 in SFAC mode):
328 0: single-finger absolute coordinates (SFAC) mode
329 1: multi-finger, multiple coordinates (MFMC) mode
330 Bit4 => 0: The LEFT button is generated by on-pad command (OPC)
331 1: The LEFT button is generated by external button
332 Default is 1 even if the LEFT button is not pressed.
333 Bit3 => Always 1, as specified by PS/2 protocol.
334 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
335 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
336 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
337Byte 2: X coordinate (xpos[9:2])
338Byte 3: Y coordinate (ypos[9:2])
339Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
340 Bit3~Bit2 => X coordinate (ypos[1:0])
341 Bit4 => 4th mouse button(forward one page)
342 Bit5 => 5th mouse button(backward one page)
343 Bit6 => scroll left button
344 Bit7 => scroll right button
345
346Multi Finger, Multiple Coordinates Mode (MFMC):
347 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
348BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
349 1 |0|1|1|P|1|F|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|B|F|X|X|Y|Y|
350 |---------------| |---------------| |---------------| |---------------|
351
352Byte 1: Bit7~Bit6 => 00, Normal data packet
353 => 01, Absolute coordination packet
354 => 10, Notify packet
355 Bit5 => Coordinate mode (always 1 in MFMC mode):
356 0: single-finger absolute coordinates (SFAC) mode
357 1: multi-finger, multiple coordinates (MFMC) mode
358 Bit4 => 0: The LEFT button is generated by on-pad command (OPC)
359 1: The LEFT button is generated by external button
360 Default is 1 even if the LEFT button is not pressed.
361 Bit3 => Always 1, as specified by PS/2 protocol.
362 Bit2 => Finger index, 0 is the first finger, 1 is the second finger.
363 If bit 1 and 0 are all 1 and bit 4 is 0, the middle external
364 button is pressed.
365 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
366 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
367Byte 2: X coordinate (xpos[9:2])
368Byte 3: Y coordinate (ypos[9:2])
369Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0])
370 Bit3~Bit2 => X coordinate (ypos[1:0])
371 Bit4 => 4th mouse button(forward one page)
372 Bit5 => 5th mouse button(backward one page)
373 Bit6 => scroll left button
374 Bit7 => scroll right button
375
376 When one of the two fingers is up, the device will output four consecutive
377MFMC#0 report packets with zero X and Y to represent 1st finger is up or
378four consecutive MFMC#1 report packets with zero X and Y to represent that
379the 2nd finger is up. On the other hand, if both fingers are up, the device
380will output four consecutive single-finger, absolute coordinate(SFAC) packets
381with zero X and Y.
382
383Notify Packet for STL3888-Cx/Dx
384 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
385BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
386 1 |1|0|0|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|u|d|0|0|0|0|
387 |---------------| |---------------| |---------------| |---------------|
388
389Byte 1: Bit7~Bit6 => 00, Normal data packet
390 => 01, Absolute coordinates packet
391 => 10, Notify packet
392 Bit5 => Always 0
393 Bit4 => 0: The LEFT button is generated by on-pad command(OPC)
394 1: The LEFT button is generated by external button
395 Default is 1 even if the LEFT button is not pressed.
396 Bit3 => 1
397 Bit2 => Middle Button, 1 is pressed, 0 is not pressed.
398 Bit1 => Right Button, 1 is pressed, 0 is not pressed.
399 Bit0 => Left Button, 1 is pressed, 0 is not pressed.
400Byte 2: Message type:
401 0xba => gesture information
402 0xc0 => one finger hold-rotating gesture
403Byte 3: The first parameter for the received message:
404 0xba => gesture ID (refer to the 'Gesture ID' section)
405 0xc0 => region ID
406Byte 4: The second parameter for the received message:
407 0xba => N/A
408 0xc0 => finger up/down information
409
410Sample sequence of Multi-finger, Multi-coordinates mode:
411
412 notify packet (valid bit == 1), MFMC packet 1 (byte 1, bit 2 == 0),
413 MFMC packet 2 (byte 1, bit 2 == 1), MFMC packet 1, MFMC packet 2,
414 ..., notify packet (valid bit == 0)
415
416 That is, when the device is in MFMC mode, the host will receive
417 interleaved absolute coordinate packets for each finger.
418
419==============================================================================
420* FSP Enable/Disable packet
421==============================================================================
422 Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
423BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------|
424 1 |Y|X|0|0|1|M|R|L| 2 |0|1|0|1|1|0|1|E| 3 | | | | | | | | | 4 | | | | | | | | |
425 |---------------| |---------------| |---------------| |---------------|
426
427FSP will send out enable/disable packet when FSP receive PS/2 enable/disable
428command. Host will receive the packet which Middle, Right, Left button will
429be set. The packet only use byte 0 and byte 1 as a pattern of original packet.
430Ignore the other bytes of the packet.
431
432Byte 1: Bit7 => 0, Y overflow
433 Bit6 => 0, X overflow
434 Bit5 => 0, Y sign bit
435 Bit4 => 0, X sign bit
436 Bit3 => 1
437 Bit2 => 1, Middle Button
438 Bit1 => 1, Right Button
439 Bit0 => 1, Left Button
440Byte 2: Bit7~1 => (0101101b)
441 Bit0 => 1 = Enable
442 0 = Disable
443Byte 3: Don't care
444Byte 4: Don't care (MOUSE ID 3, 4)
445Byte 5~8: Don't care (Absolute packet)
446
447==============================================================================
448* PS/2 Command Set
449==============================================================================
450
451FSP supports basic PS/2 commanding set and modes, refer to following URL for
452details about PS/2 commands:
453
454http://www.computer-engineering.org/ps2mouse/
455
456==============================================================================
457* Programming Sequence for Determining Packet Parsing Flow
458==============================================================================
4591. Identify FSP by reading device ID(0x00) and version(0x01) register
460
4612a. For FSP version < STL3888 Cx, determine number of buttons by reading
462 the 'test mode status' (0x20) register:
463
464 buttons = reg[0x20] & 0x30
465
466 if buttons == 0x30 or buttons == 0x20:
467 # two/four buttons
468 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
469 section A for packet parsing detail(ignore byte 4, bit ~ 7)
470 elif buttons == 0x10:
471 # 6 buttons
472 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
473 section B for packet parsing detail
474 elif buttons == 0x00:
475 # 6 buttons
476 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
477 section A for packet parsing detail
478
4792b. For FSP version >= STL3888 Cx:
480 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse'
481 section A for packet parsing detail (ignore byte 4, bit ~ 7)
482
483==============================================================================
484* Programming Sequence for Register Reading/Writing
485==============================================================================
486
487Register inversion requirement:
488
489 Following values needed to be inverted(the '~' operator in C) before being
490sent to FSP:
491
492 0xe8, 0xe9, 0xee, 0xf2, 0xf3 and 0xff.
493
494Register swapping requirement:
495
496 Following values needed to have their higher 4 bits and lower 4 bits being
497swapped before being sent to FSP:
498
499 10, 20, 40, 60, 80, 100 and 200.
500
501Register reading sequence:
502
503 1. send 0xf3 PS/2 command to FSP;
504
505 2. send 0x66 PS/2 command to FSP;
506
507 3. send 0x88 PS/2 command to FSP;
508
509 4. send 0xf3 PS/2 command to FSP;
510
511 5. if the register address being to read is not required to be
512 inverted(refer to the 'Register inversion requirement' section),
513 goto step 6
514
515 5a. send 0x68 PS/2 command to FSP;
516
517 5b. send the inverted register address to FSP and goto step 8;
518
519 6. if the register address being to read is not required to be
520 swapped(refer to the 'Register swapping requirement' section),
521 goto step 7
522
523 6a. send 0xcc PS/2 command to FSP;
524
525 6b. send the swapped register address to FSP and goto step 8;
526
527 7. send 0x66 PS/2 command to FSP;
528
529 7a. send the original register address to FSP and goto step 8;
530
531 8. send 0xe9(status request) PS/2 command to FSP;
532
533 9. the 4th byte of the response read from FSP should be the
534 requested register value(?? indicates don't care byte):
535
536 host: 0xe9
537 3888: 0xfa (??) (??) (val)
538
539 * Note that since the Cx release, the hardware will return 1's
540 complement of the register value at the 3rd byte of status request
541 result:
542
543 host: 0xe9
544 3888: 0xfa (??) (~val) (val)
545
546Register writing sequence:
547
548 1. send 0xf3 PS/2 command to FSP;
549
550 2. if the register address being to write is not required to be
551 inverted(refer to the 'Register inversion requirement' section),
552 goto step 3
553
554 2a. send 0x74 PS/2 command to FSP;
555
556 2b. send the inverted register address to FSP and goto step 5;
557
558 3. if the register address being to write is not required to be
559 swapped(refer to the 'Register swapping requirement' section),
560 goto step 4
561
562 3a. send 0x77 PS/2 command to FSP;
563
564 3b. send the swapped register address to FSP and goto step 5;
565
566 4. send 0x55 PS/2 command to FSP;
567
568 4a. send the register address to FSP and goto step 5;
569
570 5. send 0xf3 PS/2 command to FSP;
571
572 6. if the register value being to write is not required to be
573 inverted(refer to the 'Register inversion requirement' section),
574 goto step 7
575
576 6a. send 0x47 PS/2 command to FSP;
577
578 6b. send the inverted register value to FSP and goto step 9;
579
580 7. if the register value being to write is not required to be
581 swapped(refer to the 'Register swapping requirement' section),
582 goto step 8
583
584 7a. send 0x44 PS/2 command to FSP;
585
586 7b. send the swapped register value to FSP and goto step 9;
587
588 8. send 0x33 PS/2 command to FSP;
589
590 8a. send the register value to FSP;
591
592 9. the register writing sequence is completed.
593
594 * Note that since the Cx release, the hardware will return 1's
595 complement of the register value at the 3rd byte of status request
596 result. Host can optionally send another 0xe9 (status request) PS/2
597 command to FSP at the end of register writing to verify that the
598 register writing operation is successful (?? indicates don't care
599 byte):
600
601 host: 0xe9
602 3888: 0xfa (??) (~val) (val)
603
604==============================================================================
605* Programming Sequence for Page Register Reading/Writing
606==============================================================================
607
608 In order to overcome the limitation of maximum number of registers
609supported, the hardware separates register into different groups called
610'pages.' Each page is able to include up to 255 registers.
611
612 The default page after power up is 0x82; therefore, if one has to get
613access to register 0x8301, one has to use following sequence to switch
614to page 0x83, then start reading/writing from/to offset 0x01 by using
615the register read/write sequence described in previous section.
616
617Page register reading sequence:
618
619 1. send 0xf3 PS/2 command to FSP;
620
621 2. send 0x66 PS/2 command to FSP;
622
623 3. send 0x88 PS/2 command to FSP;
624
625 4. send 0xf3 PS/2 command to FSP;
626
627 5. send 0x83 PS/2 command to FSP;
628
629 6. send 0x88 PS/2 command to FSP;
630
631 7. send 0xe9(status request) PS/2 command to FSP;
632
633 8. the response read from FSP should be the requested page value.
634
635Page register writing sequence:
636
637 1. send 0xf3 PS/2 command to FSP;
638
639 2. send 0x38 PS/2 command to FSP;
640
641 3. send 0x88 PS/2 command to FSP;
642
643 4. send 0xf3 PS/2 command to FSP;
644
645 5. if the page address being written is not required to be
646 inverted(refer to the 'Register inversion requirement' section),
647 goto step 6
648
649 5a. send 0x47 PS/2 command to FSP;
650
651 5b. send the inverted page address to FSP and goto step 9;
652
653 6. if the page address being written is not required to be
654 swapped(refer to the 'Register swapping requirement' section),
655 goto step 7
656
657 6a. send 0x44 PS/2 command to FSP;
658
659 6b. send the swapped page address to FSP and goto step 9;
660
661 7. send 0x33 PS/2 command to FSP;
662
663 8. send the page address to FSP;
664
665 9. the page register writing sequence is completed.
666
667==============================================================================
668* Gesture ID
669==============================================================================
670
671 Unlike other devices which sends multiple fingers' coordinates to host,
672FSP processes multiple fingers' coordinates internally and convert them
673into a 8 bits integer, namely 'Gesture ID.' Following is a list of
674supported gesture IDs:
675
676 ID Description
677 0x86 2 finger straight up
678 0x82 2 finger straight down
679 0x80 2 finger straight right
680 0x84 2 finger straight left
681 0x8f 2 finger zoom in
682 0x8b 2 finger zoom out
683 0xc0 2 finger curve, counter clockwise
684 0xc4 2 finger curve, clockwise
685 0x2e 3 finger straight up
686 0x2a 3 finger straight down
687 0x28 3 finger straight right
688 0x2c 3 finger straight left
689 0x38 palm
690
691==============================================================================
692* Register Listing
693==============================================================================
694
695 Registers are represented in 16 bits values. The higher 8 bits represent
696the page address and the lower 8 bits represent the relative offset within
697that particular page. Refer to the 'Programming Sequence for Page Register
698Reading/Writing' section for instructions on how to change current page
699address.
700
701offset width default r/w name
7020x8200 bit7~bit0 0x01 RO device ID
703
7040x8201 bit7~bit0 RW version ID
705 0xc1: STL3888 Ax
706 0xd0 ~ 0xd2: STL3888 Bx
707 0xe0 ~ 0xe1: STL3888 Cx
708 0xe2 ~ 0xe3: STL3888 Dx
709
7100x8202 bit7~bit0 0x01 RO vendor ID
711
7120x8203 bit7~bit0 0x01 RO product ID
713
7140x8204 bit3~bit0 0x01 RW revision ID
715
7160x820b test mode status 1
717 bit3 1 RO 0: rotate 180 degree
718 1: no rotation
719 *only supported by H/W prior to Cx
720
7210x820f register file page control
722 bit2 0 RW 1: rotate 180 degree
723 0: no rotation
724 *supported since Cx
725
726 bit0 0 RW 1 to enable page 1 register files
727 *only supported by H/W prior to Cx
728
7290x8210 RW system control 1
730 bit0 1 RW Reserved, must be 1
731 bit1 0 RW Reserved, must be 0
732 bit4 0 RW Reserved, must be 0
733 bit5 1 RW register clock gating enable
734 0: read only, 1: read/write enable
735 (Note that following registers does not require clock gating being
736 enabled prior to write: 05 06 07 08 09 0c 0f 10 11 12 16 17 18 23 2e
737 40 41 42 43. In addition to that, this bit must be 1 when gesture
738 mode is enabled)
739
7400x8220 test mode status
741 bit5~bit4 RO number of buttons
742 11 => 2, lbtn/rbtn
743 10 => 4, lbtn/rbtn/scru/scrd
744 01 => 6, lbtn/rbtn/scru/scrd/scrl/scrr
745 00 => 6, lbtn/rbtn/scru/scrd/fbtn/bbtn
746 *only supported by H/W prior to Cx
747
7480x8231 RW on-pad command detection
749 bit7 0 RW on-pad command left button down tag
750 enable
751 0: disable, 1: enable
752 *only supported by H/W prior to Cx
753
7540x8234 RW on-pad command control 5
755 bit4~bit0 0x05 RW XLO in 0s/4/1, so 03h = 0010.1b = 2.5
756 (Note that position unit is in 0.5 scanline)
757 *only supported by H/W prior to Cx
758
759 bit7 0 RW on-pad tap zone enable
760 0: disable, 1: enable
761 *only supported by H/W prior to Cx
762
7630x8235 RW on-pad command control 6
764 bit4~bit0 0x1d RW XHI in 0s/4/1, so 19h = 1100.1b = 12.5
765 (Note that position unit is in 0.5 scanline)
766 *only supported by H/W prior to Cx
767
7680x8236 RW on-pad command control 7
769 bit4~bit0 0x04 RW YLO in 0s/4/1, so 03h = 0010.1b = 2.5
770 (Note that position unit is in 0.5 scanline)
771 *only supported by H/W prior to Cx
772
7730x8237 RW on-pad command control 8
774 bit4~bit0 0x13 RW YHI in 0s/4/1, so 11h = 1000.1b = 8.5
775 (Note that position unit is in 0.5 scanline)
776 *only supported by H/W prior to Cx
777
7780x8240 RW system control 5
779 bit1 0 RW FSP Intellimouse mode enable
780 0: disable, 1: enable
781 *only supported by H/W prior to Cx
782
783 bit2 0 RW movement + abs. coordinate mode enable
784 0: disable, 1: enable
785 (Note that this function has the functionality of bit 1 even when
786 bit 1 is not set. However, the format is different from that of bit 1.
787 In addition, when bit 1 and bit 2 are set at the same time, bit 2 will
788 override bit 1.)
789 *only supported by H/W prior to Cx
790
791 bit3 0 RW abs. coordinate only mode enable
792 0: disable, 1: enable
793 (Note that this function has the functionality of bit 1 even when
794 bit 1 is not set. However, the format is different from that of bit 1.
795 In addition, when bit 1, bit 2 and bit 3 are set at the same time,
796 bit 3 will override bit 1 and 2.)
797 *only supported by H/W prior to Cx
798
799 bit5 0 RW auto switch enable
800 0: disable, 1: enable
801 *only supported by H/W prior to Cx
802
803 bit6 0 RW G0 abs. + notify packet format enable
804 0: disable, 1: enable
805 (Note that the absolute/relative coordinate output still depends on
806 bit 2 and 3. That is, if any of those bit is 1, host will receive
807 absolute coordinates; otherwise, host only receives packets with
808 relative coordinate.)
809 *only supported by H/W prior to Cx
810
811 bit7 0 RW EN_PS2_F2: PS/2 gesture mode 2nd
812 finger packet enable
813 0: disable, 1: enable
814 *only supported by H/W prior to Cx
815
8160x8243 RW on-pad control
817 bit0 0 RW on-pad control enable
818 0: disable, 1: enable
819 (Note that if this bit is cleared, bit 3/5 will be ineffective)
820 *only supported by H/W prior to Cx
821
822 bit3 0 RW on-pad fix vertical scrolling enable
823 0: disable, 1: enable
824 *only supported by H/W prior to Cx
825
826 bit5 0 RW on-pad fix horizontal scrolling enable
827 0: disable, 1: enable
828 *only supported by H/W prior to Cx
829
8300x8290 RW software control register 1
831 bit0 0 RW absolute coordination mode
832 0: disable, 1: enable
833 *supported since Cx
834
835 bit1 0 RW gesture ID output
836 0: disable, 1: enable
837 *supported since Cx
838
839 bit2 0 RW two fingers' coordinates output
840 0: disable, 1: enable
841 *supported since Cx
842
843 bit3 0 RW finger up one packet output
844 0: disable, 1: enable
845 *supported since Cx
846
847 bit4 0 RW absolute coordination continuous mode
848 0: disable, 1: enable
849 *supported since Cx
850
851 bit6~bit5 00 RW gesture group selection
852 00: basic
853 01: suite
854 10: suite pro
855 11: advanced
856 *supported since Cx
857
858 bit7 0 RW Bx packet output compatible mode
859 0: disable, 1: enable *supported since Cx
860 *supported since Cx
861
862
8630x833d RW on-pad command control 1
864 bit7 1 RW on-pad command detection enable
865 0: disable, 1: enable
866 *supported since Cx
867
8680x833e RW on-pad command detection
869 bit7 0 RW on-pad command left button down tag
870 enable. Works only in H/W based PS/2
871 data packet mode.
872 0: disable, 1: enable
873 *supported since Cx
diff --git a/Documentation/input/shape.fig b/Documentation/input/shape.fig
deleted file mode 100644
index c22bff83d06f..000000000000
--- a/Documentation/input/shape.fig
+++ /dev/null
@@ -1,65 +0,0 @@
1#FIG 3.2
2Landscape
3Center
4Inches
5Letter
6100.00
7Single
8-2
91200 2
102 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 6
11 4200 3600 4200 3075 4950 2325 7425 2325 8250 3150 8250 3600
122 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
13 4200 3675 4200 5400
142 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
15 8250 3675 8250 5400
162 1 0 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
17 3675 3600 8700 3600
182 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
19 8775 3600 10200 3600
202 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
21 8325 3150 9075 3150
222 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
23 7500 2325 10200 2325
242 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
25 3600 3600 3000 3600
262 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
27 4125 3075 3000 3075
282 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2
29 0 0 1.00 60.00 120.00
30 0 0 1.00 60.00 120.00
31 4200 5400 8175 5400
322 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2
33 0 0 1.00 60.00 120.00
34 0 0 1.00 60.00 120.00
35 10125 2325 10125 3600
362 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2
37 0 0 1.00 60.00 120.00
38 0 0 1.00 60.00 120.00
39 3000 3150 3000 3600
402 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2
41 0 0 1.00 60.00 120.00
42 0 0 1.00 60.00 120.00
43 9075 3150 9075 3600
442 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
45 4950 2325 4950 1200
462 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 2
47 7425 2325 7425 1200
482 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4
49 4200 3075 4200 2400 3600 1800 3600 1200
502 1 1 1 0 7 50 0 -1 4.000 0 0 -1 0 0 4
51 8250 3150 8250 2475 8775 1950 8775 1200
522 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2
53 0 0 1.00 60.00 120.00
54 0 0 1.00 60.00 120.00
55 3600 1275 4950 1275
562 1 0 1 0 7 50 0 -1 4.000 0 0 -1 1 1 2
57 0 0 1.00 60.00 120.00
58 0 0 1.00 60.00 120.00
59 7425 1275 8700 1275
604 1 0 50 0 0 12 0.0000 4 135 1140 6075 5325 Effect duration\001
614 0 0 50 0 0 12 0.0000 4 180 1305 10200 3000 Effect magnitude\001
624 0 0 50 0 0 12 0.0000 4 135 780 9150 3450 Fade level\001
634 1 0 50 0 0 12 0.0000 4 180 1035 4275 1200 Attack length\001
644 1 0 50 0 0 12 0.0000 4 180 885 8175 1200 Fade length\001
654 2 0 50 0 0 12 0.0000 4 135 930 2925 3375 Attack level\001
diff --git a/Documentation/input/shape.svg b/Documentation/input/shape.svg
new file mode 100644
index 000000000000..fc0af44db3f7
--- /dev/null
+++ b/Documentation/input/shape.svg
@@ -0,0 +1,39 @@
1<svg width="7.95in" height="3.70in" version="1.1" viewBox="1956 1041 9354.492 4306.001" xmlns="http://www.w3.org/2000/svg">
2 <polyline transform="translate(-121.88 -68.4)" points="4200 3600 4200 3075 4950 2325 7425 2325 8250 3150 8250 3600" fill="none" stroke="#000" stroke-width="15"/>
3 <polyline transform="translate(-121.88 -68.4)" points="4200 3675 4200 5400" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
4 <polyline transform="translate(-121.88 -68.4)" points="8250 3675 8250 5400" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
5 <polyline transform="translate(-121.88 -68.4)" points="3675 3600 8700 3600" fill="none" stroke="#000" stroke-width="7"/>
6 <polyline transform="translate(-121.88 -68.4)" points="8775 3600 10200 3600" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
7 <polyline transform="translate(-121.88 -68.4)" points="8325 3150 9075 3150" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
8 <polyline transform="translate(-121.88 -68.4)" points="7500 2325 10200 2325" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
9 <polyline transform="translate(-121.88 -68.4)" points="3600 3600 3e3 3600" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
10 <polyline transform="translate(-121.88 -68.4)" points="4125 3075 3e3 3075" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
11 <polyline transform="translate(-121.88 -68.4)" points="4217 5400 8158 5400" fill="none" stroke="#000" stroke-width="7"/>
12 <polyline transform="translate(-121.88 -68.4)" points="8053 5430 8173 5400 8053 5370" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
13 <polyline transform="translate(-121.88 -68.4)" points="4322 5370 4202 5400 4322 5430" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
14 <polyline transform="translate(-121.88 -68.4)" points="10125 2342 10125 3583" fill="none" stroke="#000" stroke-width="7"/>
15 <polyline transform="translate(-121.88 -68.4)" points="10095 3478 10125 3598 10155 3478" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
16 <polyline transform="translate(-121.88 -68.4)" points="10155 2447 10125 2327 10095 2447" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
17 <polyline transform="translate(-121.88 -68.4)" points="3e3 3167 3e3 3583" fill="none" stroke="#000" stroke-width="7"/>
18 <polyline transform="translate(-121.88 -68.4)" points="2970 3478 3e3 3598 3030 3478" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
19 <polyline transform="translate(-121.88 -68.4)" points="3030 3272 3e3 3152 2970 3272" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
20 <polyline transform="translate(-121.88 -68.4)" points="9075 3167 9075 3583" fill="none" stroke="#000" stroke-width="7"/>
21 <polyline transform="translate(-121.88 -68.4)" points="9045 3478 9075 3598 9105 3478" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
22 <polyline transform="translate(-121.88 -68.4)" points="9105 3272 9075 3152 9045 3272" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
23 <polyline transform="translate(-121.88 -68.4)" points="4950 2325 4950 1200" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
24 <polyline transform="translate(-121.88 -68.4)" points="7425 2325 7425 1200" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
25 <polyline transform="translate(-121.88 -68.4)" points="4200 3075 4200 2400 3600 1800 3600 1200" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
26 <polyline transform="translate(-121.88 -68.4)" points="8250 3150 8250 2475 8775 1950 8775 1200" fill="none" stroke="#000" stroke-dasharray="40, 40" stroke-width="7"/>
27 <polyline transform="translate(-121.88 -68.4)" points="3617 1275 4933 1275" fill="none" stroke="#000" stroke-width="7"/>
28 <polyline transform="translate(-121.88 -68.4)" points="4828 1305 4948 1275 4828 1245" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
29 <polyline transform="translate(-121.88 -68.4)" points="3722 1245 3602 1275 3722 1305" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
30 <polyline transform="translate(-121.88 -68.4)" points="7442 1275 8683 1275" fill="none" stroke="#000" stroke-width="7"/>
31 <polyline transform="translate(-121.88 -68.4)" points="8578 1305 8698 1275 8578 1245" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
32 <polyline transform="translate(-121.88 -68.4)" points="7547 1245 7427 1275 7547 1305" fill="none" stroke="#000" stroke-miterlimit="8" stroke-width="7"/>
33 <text x="5953.125" y="5256.6001" fill="#000000" font-family="sans-serif" font-size="144px" stroke-width=".025in" text-anchor="middle" xml:space="preserve">Effect duration</text>
34 <text x="10078.125" y="2931.5999" fill="#000000" font-family="sans-serif" font-size="144px" stroke-width=".025in" xml:space="preserve">Effect magnitude</text>
35 <text x="9028.125" y="3381.5999" fill="#000000" font-family="sans-serif" font-size="144px" stroke-width=".025in" xml:space="preserve">Fade level</text>
36 <text x="4153.125" y="1131.6" fill="#000000" font-family="sans-serif" font-size="144px" stroke-width=".025in" text-anchor="middle" xml:space="preserve">Attack length</text>
37 <text x="8053.125" y="1131.6" fill="#000000" font-family="sans-serif" font-size="144px" stroke-width=".025in" text-anchor="middle" xml:space="preserve">Fade length</text>
38 <text x="2803.125" y="3306.5999" fill="#000000" font-family="sans-serif" font-size="144px" stroke-width=".025in" text-anchor="end" xml:space="preserve">Attack level</text>
39</svg>
diff --git a/Documentation/input/uinput.rst b/Documentation/input/uinput.rst
new file mode 100644
index 000000000000..b8e90b6a126c
--- /dev/null
+++ b/Documentation/input/uinput.rst
@@ -0,0 +1,245 @@
1=============
2uinput module
3=============
4
5Introduction
6============
7
8uinput is a kernel module that makes it possible to emulate input devices
9from userspace. By writing to /dev/uinput (or /dev/input/uinput) device, a
10process can create a virtual input device with specific capabilities. Once
11this virtual device is created, the process can send events through it,
12that will be delivered to userspace and in-kernel consumers.
13
14Interface
15=========
16
17::
18
19 linux/uinput.h
20
21The uinput header defines ioctls to create, set up, and destroy virtual
22devices.
23
24libevdev
25========
26
27libevdev is a wrapper library for evdev devices that provides interfaces to
28create uinput devices and send events. libevdev is less error-prone than
29accessing uinput directly, and should be considered for new software.
30
31For examples and more information about libevdev:
32https://www.freedesktop.org/software/libevdev/doc/latest/
33
34Examples
35========
36
37Keyboard events
38---------------
39
40This first example shows how to create a new virtual device, and how to
41send a key event. All default imports and error handlers were removed for
42the sake of simplicity.
43
44.. code-block:: c
45
46 #include <linux/uinput.h>
47
48 void emit(int fd, int type, int code, int val)
49 {
50 struct input_event ie;
51
52 ie.type = type;
53 ie.code = code;
54 ie.value = val;
55 /* timestamp values below are ignored */
56 ie.time.tv_sec = 0;
57 ie.time.tv_usec = 0;
58
59 write(fd, &ie, sizeof(ie));
60 }
61
62 int main(void)
63 {
64 struct uinput_setup usetup;
65
66 int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
67
68
69 /*
70 * The ioctls below will enable the device that is about to be
71 * created, to pass key events, in this case the space key.
72 */
73 ioctl(fd, UI_SET_EVBIT, EV_KEY);
74 ioctl(fd, UI_SET_KEYBIT, KEY_SPACE);
75
76 memset(&usetup, 0, sizeof(usetup));
77 usetup.id.bustype = BUS_USB;
78 usetup.id.vendor = 0x1234; /* sample vendor */
79 usetup.id.product = 0x5678; /* sample product */
80 strcpy(usetup.name, "Example device");
81
82 ioctl(fd, UI_DEV_SETUP, &usetup);
83 ioctl(fd, UI_DEV_CREATE);
84
85 /*
86 * On UI_DEV_CREATE the kernel will create the device node for this
87 * device. We are inserting a pause here so that userspace has time
88 * to detect, initialize the new device, and can start listening to
89 * the event, otherwise it will not notice the event we are about
90 * to send. This pause is only needed in our example code!
91 */
92 sleep(1);
93
94 /* Key press, report the event, send key release, and report again */
95 emit(fd, EV_KEY, KEY_SPACE, 1);
96 emit(fd, EV_SYN, SYN_REPORT, 0);
97 emit(fd, EV_KEY, KEY_SPACE, 0);
98 emit(fd, EV_SYN, SYN_REPORT, 0);
99
100 /*
101 * Give userspace some time to read the events before we destroy the
102 * device with UI_DEV_DESTOY.
103 */
104 sleep(1);
105
106 ioctl(fd, UI_DEV_DESTROY);
107 close(fd);
108
109 return 0;
110 }
111
112Mouse movements
113---------------
114
115This example shows how to create a virtual device that behaves like a physical
116mouse.
117
118.. code-block:: c
119
120 #include <linux/uinput.h>
121
122 /* emit function is identical to of the first example */
123
124 int main(void)
125 {
126 struct uinput_setup usetup;
127 int i = 50;
128
129 int fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
130
131 /* enable mouse button left and relative events */
132 ioctl(fd, UI_SET_EVBIT, EV_KEY);
133 ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);
134
135 ioctl(fd, UI_SET_EVBIT, EV_REL);
136 ioctl(fd, UI_SET_RELBIT, REL_X);
137 ioctl(fd, UI_SET_RELBIT, REL_Y);
138
139 memset(&usetup, 0, sizeof(usetup));
140 usetup.id.bustype = BUS_USB;
141 usetup.id.vendor = 0x1234; /* sample vendor */
142 usetup.id.product = 0x5678; /* sample product */
143 strcpy(usetup.name, "Example device");
144
145 ioctl(fd, UI_DEV_SETUP, &usetup);
146 ioctl(fd, UI_DEV_CREATE);
147
148 /*
149 * On UI_DEV_CREATE the kernel will create the device node for this
150 * device. We are inserting a pause here so that userspace has time
151 * to detect, initialize the new device, and can start listening to
152 * the event, otherwise it will not notice the event we are about
153 * to send. This pause is only needed in our example code!
154 */
155 sleep(1);
156
157 /* Move the mouse diagonally, 5 units per axis */
158 while (i--) {
159 emit(fd, EV_REL, REL_X, 5);
160 emit(fd, EV_REL, REL_Y, 5);
161 emit(fd, EV_SYN, SYN_REPORT, 0);
162 usleep(15000);
163 }
164
165 /*
166 * Give userspace some time to read the events before we destroy the
167 * device with UI_DEV_DESTOY.
168 */
169 sleep(1);
170
171 ioctl(fd, UI_DEV_DESTROY);
172 close(fd);
173
174 return 0;
175 }
176
177
178uinput old interface
179--------------------
180
181Before uinput version 5, there wasn't a dedicated ioctl to set up a virtual
182device. Programs supportinf older versions of uinput interface need to fill
183a uinput_user_dev structure and write it to the uinput file descriptor to
184configure the new uinput device. New code should not use the old interface
185but interact with uinput via ioctl calls, or use libevdev.
186
187.. code-block:: c
188
189 #include <linux/uinput.h>
190
191 /* emit function is identical to of the first example */
192
193 int main(void)
194 {
195 struct uinput_user_dev uud;
196 int version, rc, fd;
197
198 fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
199 rc = ioctl(fd, UI_GET_VERSION, &version);
200
201 if (rc == 0 && version >= 5) {
202 /* use UI_DEV_SETUP */
203 return 0;
204 }
205
206 /*
207 * The ioctls below will enable the device that is about to be
208 * created, to pass key events, in this case the space key.
209 */
210 ioctl(fd, UI_SET_EVBIT, EV_KEY);
211 ioctl(fd, UI_SET_KEYBIT, KEY_SPACE);
212
213 memset(&uud, 0, sizeof(uud));
214 snprintf(uud.name, UINPUT_MAX_NAME_SIZE, "uinput old interface");
215 write(fd, &uud, sizeof(uud));
216
217 ioctl(fd, UI_DEV_CREATE);
218
219 /*
220 * On UI_DEV_CREATE the kernel will create the device node for this
221 * device. We are inserting a pause here so that userspace has time
222 * to detect, initialize the new device, and can start listening to
223 * the event, otherwise it will not notice the event we are about
224 * to send. This pause is only needed in our example code!
225 */
226 sleep(1);
227
228 /* Key press, report the event, send key release, and report again */
229 emit(fd, EV_KEY, KEY_SPACE, 1);
230 emit(fd, EV_SYN, SYN_REPORT, 0);
231 emit(fd, EV_KEY, KEY_SPACE, 0);
232 emit(fd, EV_SYN, SYN_REPORT, 0);
233
234 /*
235 * Give userspace some time to read the events before we destroy the
236 * device with UI_DEV_DESTOY.
237 */
238 sleep(1);
239
240 ioctl(fd, UI_DEV_DESTROY);
241
242 close(fd);
243 return 0;
244 }
245
diff --git a/Documentation/input/userio.txt b/Documentation/input/userio.rst
index 0880c0f447a6..f780c77931fe 100644
--- a/Documentation/input/userio.txt
+++ b/Documentation/input/userio.rst
@@ -1,37 +1,47 @@
1 The userio Protocol 1.. include:: <isonum.txt>
2 (c) 2015 Stephen Chandler Paul <thatslyude@gmail.com> 2
3 Sponsored by Red Hat 3===================
4-------------------------------------------------------------------------------- 4The userio Protocol
5 5===================
61. Introduction 6
7~~~~~~~~~~~~~~~ 7
8 This module is intended to try to make the lives of input driver developers 8:Copyright: |copy| 2015 Stephen Chandler Paul <thatslyude@gmail.com>
9
10Sponsored by Red Hat
11
12
13Introduction
14=============
15
16This module is intended to try to make the lives of input driver developers
9easier by allowing them to test various serio devices (mainly the various 17easier by allowing them to test various serio devices (mainly the various
10touchpads found on laptops) without having to have the physical device in front 18touchpads found on laptops) without having to have the physical device in front
11of them. userio accomplishes this by allowing any privileged userspace program 19of them. userio accomplishes this by allowing any privileged userspace program
12to directly interact with the kernel's serio driver and control a virtual serio 20to directly interact with the kernel's serio driver and control a virtual serio
13port from there. 21port from there.
14 22
152. Usage overview 23Usage overview
16~~~~~~~~~~~~~~~~~ 24==============
17 In order to interact with the userio kernel module, one simply opens the 25
26In order to interact with the userio kernel module, one simply opens the
18/dev/userio character device in their applications. Commands are sent to the 27/dev/userio character device in their applications. Commands are sent to the
19kernel module by writing to the device, and any data received from the serio 28kernel module by writing to the device, and any data received from the serio
20driver is read as-is from the /dev/userio device. All of the structures and 29driver is read as-is from the /dev/userio device. All of the structures and
21macros you need to interact with the device are defined in <linux/userio.h> and 30macros you need to interact with the device are defined in <linux/userio.h> and
22<linux/serio.h>. 31<linux/serio.h>.
23 32
243. Command Structure 33Command Structure
25~~~~~~~~~~~~~~~~~~~~ 34=================
26 The struct used for sending commands to /dev/userio is as follows: 35
36The struct used for sending commands to /dev/userio is as follows::
27 37
28 struct userio_cmd { 38 struct userio_cmd {
29 __u8 type; 39 __u8 type;
30 __u8 data; 40 __u8 data;
31 }; 41 };
32 42
33 "type" describes the type of command that is being sent. This can be any one 43``type`` describes the type of command that is being sent. This can be any one
34of the USERIO_CMD macros defined in <linux/userio.h>. "data" is the argument 44of the USERIO_CMD macros defined in <linux/userio.h>. ``data`` is the argument
35that goes along with the command. In the event that the command doesn't have an 45that goes along with the command. In the event that the command doesn't have an
36argument, this field can be left untouched and will be ignored by the kernel. 46argument, this field can be left untouched and will be ignored by the kernel.
37Each command should be sent by writing the struct directly to the character 47Each command should be sent by writing the struct directly to the character
@@ -39,31 +49,36 @@ device. In the event that the command you send is invalid, an error will be
39returned by the character device and a more descriptive error will be printed 49returned by the character device and a more descriptive error will be printed
40to the kernel log. Only one command can be sent at a time, any additional data 50to the kernel log. Only one command can be sent at a time, any additional data
41written to the character device after the initial command will be ignored. 51written to the character device after the initial command will be ignored.
42 To close the virtual serio port, just close /dev/userio.
43 52
444. Commands 53To close the virtual serio port, just close /dev/userio.
45~~~~~~~~~~~ 54
55Commands
56========
57
58USERIO_CMD_REGISTER
59~~~~~~~~~~~~~~~~~~~
46 60
474.1 USERIO_CMD_REGISTER 61Registers the port with the serio driver and begins transmitting data back and
48~~~~~~~~~~~~~~~~~~~~~~~
49 Registers the port with the serio driver and begins transmitting data back and
50forth. Registration can only be performed once a port type is set with 62forth. Registration can only be performed once a port type is set with
51USERIO_CMD_SET_PORT_TYPE. Has no argument. 63USERIO_CMD_SET_PORT_TYPE. Has no argument.
52 64
534.2 USERIO_CMD_SET_PORT_TYPE 65USERIO_CMD_SET_PORT_TYPE
54~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66~~~~~~~~~~~~~~~~~~~~~~~~
55 Sets the type of port we're emulating, where "data" is the port type being 67
68Sets the type of port we're emulating, where ``data`` is the port type being
56set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042 69set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042
57would set the port type to be a normal PS/2 port. 70would set the port type to be a normal PS/2 port.
58 71
594.3 USERIO_CMD_SEND_INTERRUPT 72USERIO_CMD_SEND_INTERRUPT
60~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 73~~~~~~~~~~~~~~~~~~~~~~~~~
61 Sends an interrupt through the virtual serio port to the serio driver, where 74
62"data" is the interrupt data being sent. 75Sends an interrupt through the virtual serio port to the serio driver, where
76``data`` is the interrupt data being sent.
77
78Userspace tools
79===============
63 80
645. Userspace tools 81The userio userspace tools are able to record PS/2 devices using some of the
65~~~~~~~~~~~~~~~~~~
66 The userio userspace tools are able to record PS/2 devices using some of the
67debugging information from i8042, and play back the devices on /dev/userio. The 82debugging information from i8042, and play back the devices on /dev/userio. The
68latest version of these tools can be found at: 83latest version of these tools can be found at:
69 84
diff --git a/MAINTAINERS b/MAINTAINERS
index c732ba701ae7..fe73af757247 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6551,7 +6551,7 @@ INPUT MULTITOUCH (MT) PROTOCOL
6551M: Henrik Rydberg <rydberg@bitmath.org> 6551M: Henrik Rydberg <rydberg@bitmath.org>
6552L: linux-input@vger.kernel.org 6552L: linux-input@vger.kernel.org
6553S: Odd fixes 6553S: Odd fixes
6554F: Documentation/input/multi-touch-protocol.txt 6554F: Documentation/input/multi-touch-protocol.rst
6555F: drivers/input/input-mt.c 6555F: drivers/input/input-mt.c
6556K: \b(ABS|SYN)_MT_ 6556K: \b(ABS|SYN)_MT_
6557 6557
@@ -13963,7 +13963,7 @@ YEALINK PHONE DRIVER
13963M: Henk Vergonet <Henk.Vergonet@gmail.com> 13963M: Henk Vergonet <Henk.Vergonet@gmail.com>
13964L: usbb2k-api-dev@nongnu.org 13964L: usbb2k-api-dev@nongnu.org
13965S: Maintained 13965S: Maintained
13966F: Documentation/input/yealink.txt 13966F: Documentation/input/yealink.rst
13967F: drivers/input/misc/yealink.* 13967F: drivers/input/misc/yealink.*
13968 13968
13969Z8530 DRIVER FOR AX.25 13969Z8530 DRIVER FOR AX.25
diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index e216433b56ed..e2c97728b3c6 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -26,7 +26,6 @@
26#include <linux/smsc911x.h> 26#include <linux/smsc911x.h>
27#include <linux/input.h> 27#include <linux/input.h>
28#include <linux/gpio_keys.h> 28#include <linux/gpio_keys.h>
29#include <linux/input/eeti_ts.h>
30#include <linux/leds.h> 29#include <linux/leds.h>
31#include <linux/w1-gpio.h> 30#include <linux/w1-gpio.h>
32#include <linux/sched.h> 31#include <linux/sched.h>
@@ -965,15 +964,28 @@ static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
965 .addr = 0x48, 964 .addr = 0x48,
966}; 965};
967 966
968static struct eeti_ts_platform_data eeti_ts_pdata = { 967static struct gpiod_lookup_table raumfeld_controller_gpios_table = {
969 .irq_active_high = 1, 968 .dev_id = "0-000a",
970 .irq_gpio = GPIO_TOUCH_IRQ, 969 .table = {
970 GPIO_LOOKUP("gpio-pxa",
971 GPIO_TOUCH_IRQ, "attn", GPIO_ACTIVE_HIGH),
972 { },
973 },
974};
975
976static const struct resource raumfeld_controller_resources[] __initconst = {
977 {
978 .start = PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ),
979 .end = PXA_GPIO_TO_IRQ(GPIO_TOUCH_IRQ),
980 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
981 },
971}; 982};
972 983
973static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = { 984static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
974 .type = "eeti_ts", 985 .type = "eeti_ts",
975 .addr = 0x0a, 986 .addr = 0x0a,
976 .platform_data = &eeti_ts_pdata, 987 .resources = raumfeld_controller_resources,
988 .num_resources = ARRAY_SIZE(raumfeld_controller_resources),
977}; 989};
978 990
979static struct platform_device *raumfeld_common_devices[] = { 991static struct platform_device *raumfeld_common_devices[] = {
@@ -1064,6 +1076,8 @@ static void __init __maybe_unused raumfeld_controller_init(void)
1064 platform_device_register(&rotary_encoder_device); 1076 platform_device_register(&rotary_encoder_device);
1065 1077
1066 spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices)); 1078 spi_register_board_info(ARRAY_AND_SIZE(controller_spi_devices));
1079
1080 gpiod_add_lookup_table(&raumfeld_controller_gpios_table);
1067 i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1); 1081 i2c_register_board_info(0, &raumfeld_controller_i2c_board_info, 1);
1068 1082
1069 ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown"); 1083 ret = gpio_request(GPIO_SHUTDOWN_BATT, "battery shutdown");
diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c
index 6e5fac6a5262..31186ead5a40 100644
--- a/drivers/i2c/i2c-boardinfo.c
+++ b/drivers/i2c/i2c-boardinfo.c
@@ -15,6 +15,7 @@
15#include <linux/export.h> 15#include <linux/export.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/property.h>
18#include <linux/rwsem.h> 19#include <linux/rwsem.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
20 21
@@ -55,6 +56,7 @@ EXPORT_SYMBOL_GPL(__i2c_first_dynamic_bus_num);
55 * 56 *
56 * The board info passed can safely be __initdata, but be careful of embedded 57 * The board info passed can safely be __initdata, but be careful of embedded
57 * pointers (for platform_data, functions, etc) since that won't be copied. 58 * pointers (for platform_data, functions, etc) since that won't be copied.
59 * Device properties are deep-copied though.
58 */ 60 */
59int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned len) 61int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsigned len)
60{ 62{
@@ -78,6 +80,28 @@ int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsig
78 80
79 devinfo->busnum = busnum; 81 devinfo->busnum = busnum;
80 devinfo->board_info = *info; 82 devinfo->board_info = *info;
83
84 if (info->properties) {
85 devinfo->board_info.properties =
86 property_entries_dup(info->properties);
87 if (IS_ERR(devinfo->board_info.properties)) {
88 status = PTR_ERR(devinfo->board_info.properties);
89 break;
90 }
91 }
92
93 if (info->resources) {
94 devinfo->board_info.resources =
95 kmemdup(info->resources,
96 info->num_resources *
97 sizeof(*info->resources),
98 GFP_KERNEL);
99 if (!devinfo->board_info.resources) {
100 status = -ENOMEM;
101 break;
102 }
103 }
104
81 list_add_tail(&devinfo->list, &__i2c_board_list); 105 list_add_tail(&devinfo->list, &__i2c_board_list);
82 } 106 }
83 107
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7a065c4260f3..82576aaccc90 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -74,7 +74,6 @@
74static DEFINE_MUTEX(core_lock); 74static DEFINE_MUTEX(core_lock);
75static DEFINE_IDR(i2c_adapter_idr); 75static DEFINE_IDR(i2c_adapter_idr);
76 76
77static struct device_type i2c_client_type;
78static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver); 77static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
79 78
80static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE; 79static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE;
@@ -1153,11 +1152,12 @@ struct bus_type i2c_bus_type = {
1153}; 1152};
1154EXPORT_SYMBOL_GPL(i2c_bus_type); 1153EXPORT_SYMBOL_GPL(i2c_bus_type);
1155 1154
1156static struct device_type i2c_client_type = { 1155struct device_type i2c_client_type = {
1157 .groups = i2c_dev_groups, 1156 .groups = i2c_dev_groups,
1158 .uevent = i2c_device_uevent, 1157 .uevent = i2c_device_uevent,
1159 .release = i2c_client_dev_release, 1158 .release = i2c_client_dev_release,
1160}; 1159};
1160EXPORT_SYMBOL_GPL(i2c_client_type);
1161 1161
1162 1162
1163/** 1163/**
@@ -1334,6 +1334,32 @@ static void i2c_dev_set_name(struct i2c_adapter *adap,
1334 i2c_encode_flags_to_addr(client)); 1334 i2c_encode_flags_to_addr(client));
1335} 1335}
1336 1336
1337static int i2c_dev_irq_from_resources(const struct resource *resources,
1338 unsigned int num_resources)
1339{
1340 struct irq_data *irqd;
1341 int i;
1342
1343 for (i = 0; i < num_resources; i++) {
1344 const struct resource *r = &resources[i];
1345
1346 if (resource_type(r) != IORESOURCE_IRQ)
1347 continue;
1348
1349 if (r->flags & IORESOURCE_BITS) {
1350 irqd = irq_get_irq_data(r->start);
1351 if (!irqd)
1352 break;
1353
1354 irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
1355 }
1356
1357 return r->start;
1358 }
1359
1360 return 0;
1361}
1362
1337/** 1363/**
1338 * i2c_new_device - instantiate an i2c device 1364 * i2c_new_device - instantiate an i2c device
1339 * @adap: the adapter managing the device 1365 * @adap: the adapter managing the device
@@ -1369,7 +1395,11 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
1369 1395
1370 client->flags = info->flags; 1396 client->flags = info->flags;
1371 client->addr = info->addr; 1397 client->addr = info->addr;
1398
1372 client->irq = info->irq; 1399 client->irq = info->irq;
1400 if (!client->irq)
1401 client->irq = i2c_dev_irq_from_resources(info->resources,
1402 info->num_resources);
1373 1403
1374 strlcpy(client->name, info->type, sizeof(client->name)); 1404 strlcpy(client->name, info->type, sizeof(client->name));
1375 1405
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 4a2a9e370be7..cedc665364cd 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -385,8 +385,8 @@ static int gameport_queue_event(void *object, struct module *owner,
385 } 385 }
386 386
387 if (!try_module_get(owner)) { 387 if (!try_module_get(owner)) {
388 pr_warning("Can't get module reference, dropping event %d\n", 388 pr_warn("Can't get module reference, dropping event %d\n",
389 event_type); 389 event_type);
390 kfree(event); 390 kfree(event);
391 retval = -EINVAL; 391 retval = -EINVAL;
392 goto out; 392 goto out;
@@ -542,9 +542,8 @@ static void gameport_init_port(struct gameport *gameport)
542 542
543 INIT_LIST_HEAD(&gameport->node); 543 INIT_LIST_HEAD(&gameport->node);
544 spin_lock_init(&gameport->timer_lock); 544 spin_lock_init(&gameport->timer_lock);
545 init_timer(&gameport->poll_timer); 545 setup_timer(&gameport->poll_timer, gameport_run_poll_handler,
546 gameport->poll_timer.function = gameport_run_poll_handler; 546 (unsigned long)gameport);
547 gameport->poll_timer.data = (unsigned long)gameport;
548} 547}
549 548
550/* 549/*
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index da326090c2b0..f4ad83eab67f 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -609,9 +609,7 @@ static void db9_attach(struct parport *pp)
609 db9->pd = pd; 609 db9->pd = pd;
610 db9->mode = mode; 610 db9->mode = mode;
611 db9->parportno = pp->number; 611 db9->parportno = pp->number;
612 init_timer(&db9->timer); 612 setup_timer(&db9->timer, db9_timer, (long)db9);
613 db9->timer.data = (long) db9;
614 db9->timer.function = db9_timer;
615 613
616 for (i = 0; i < (min(db9_mode->n_pads, DB9_MAX_DEVICES)); i++) { 614 for (i = 0; i < (min(db9_mode->n_pads, DB9_MAX_DEVICES)); i++) {
617 615
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index eae14d512353..c43f087a496d 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -870,7 +870,8 @@ static int gc_setup_pad(struct gc *gc, int idx, int pad_type)
870 870
871 err = gc_n64_init_ff(input_dev, idx); 871 err = gc_n64_init_ff(input_dev, idx);
872 if (err) { 872 if (err) {
873 pr_warning("Failed to initiate rumble for N64 device %d\n", idx); 873 pr_warn("Failed to initiate rumble for N64 device %d\n",
874 idx);
874 goto err_free_dev; 875 goto err_free_dev;
875 } 876 }
876 877
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index 77f575dd0901..a1fdc75a438d 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -200,9 +200,7 @@ static void tgfx_attach(struct parport *pp)
200 mutex_init(&tgfx->sem); 200 mutex_init(&tgfx->sem);
201 tgfx->pd = pd; 201 tgfx->pd = pd;
202 tgfx->parportno = pp->number; 202 tgfx->parportno = pp->number;
203 init_timer(&tgfx->timer); 203 setup_timer(&tgfx->timer, tgfx_timer, (long)tgfx);
204 tgfx->timer.data = (long) tgfx;
205 tgfx->timer.function = tgfx_timer;
206 204
207 for (i = 0; i < n_devs; i++) { 205 for (i = 0; i < n_devs; i++) {
208 if (n_buttons[i] < 1) 206 if (n_buttons[i] < 1)
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 153b1ee13e03..df83fdc6c0e7 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -339,6 +339,64 @@ static struct usb_device_id xpad_table[] = {
339 339
340MODULE_DEVICE_TABLE(usb, xpad_table); 340MODULE_DEVICE_TABLE(usb, xpad_table);
341 341
342struct xboxone_init_packet {
343 u16 idVendor;
344 u16 idProduct;
345 const u8 *data;
346 u8 len;
347};
348
349#define XBOXONE_INIT_PKT(_vid, _pid, _data) \
350 { \
351 .idVendor = (_vid), \
352 .idProduct = (_pid), \
353 .data = (_data), \
354 .len = ARRAY_SIZE(_data), \
355 }
356
357
358/*
359 * This packet is required for all Xbox One pads with 2015
360 * or later firmware installed (or present from the factory).
361 */
362static const u8 xboxone_fw2015_init[] = {
363 0x05, 0x20, 0x00, 0x01, 0x00
364};
365
366/*
367 * This packet is required for the Titanfall 2 Xbox One pads
368 * (0x0e6f:0x0165) to finish initialization and for Hori pads
369 * (0x0f0d:0x0067) to make the analog sticks work.
370 */
371static const u8 xboxone_hori_init[] = {
372 0x01, 0x20, 0x00, 0x09, 0x00, 0x04, 0x20, 0x3a,
373 0x00, 0x00, 0x00, 0x80, 0x00
374};
375
376/*
377 * A rumble packet is required for some PowerA pads to start
378 * sending input reports. One of those pads is (0x24c6:0x543a).
379 */
380static const u8 xboxone_zerorumble_init[] = {
381 0x09, 0x00, 0x00, 0x09, 0x00, 0x0F, 0x00, 0x00,
382 0x00, 0x00, 0x00, 0x00, 0x00
383};
384
385/*
386 * This specifies the selection of init packets that a gamepad
387 * will be sent on init *and* the order in which they will be
388 * sent. The correct sequence number will be added when the
389 * packet is going to be sent.
390 */
391static const struct xboxone_init_packet xboxone_init_packets[] = {
392 XBOXONE_INIT_PKT(0x0e6f, 0x0165, xboxone_hori_init),
393 XBOXONE_INIT_PKT(0x0f0d, 0x0067, xboxone_hori_init),
394 XBOXONE_INIT_PKT(0x0000, 0x0000, xboxone_fw2015_init),
395 XBOXONE_INIT_PKT(0x24c6, 0x541a, xboxone_zerorumble_init),
396 XBOXONE_INIT_PKT(0x24c6, 0x542a, xboxone_zerorumble_init),
397 XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_zerorumble_init),
398};
399
342struct xpad_output_packet { 400struct xpad_output_packet {
343 u8 data[XPAD_PKT_LEN]; 401 u8 data[XPAD_PKT_LEN];
344 u8 len; 402 u8 len;
@@ -375,6 +433,7 @@ struct usb_xpad {
375 433
376 struct xpad_output_packet out_packets[XPAD_NUM_OUT_PACKETS]; 434 struct xpad_output_packet out_packets[XPAD_NUM_OUT_PACKETS];
377 int last_out_packet; 435 int last_out_packet;
436 int init_seq;
378 437
379#if defined(CONFIG_JOYSTICK_XPAD_LEDS) 438#if defined(CONFIG_JOYSTICK_XPAD_LEDS)
380 struct xpad_led *led; 439 struct xpad_led *led;
@@ -750,11 +809,47 @@ exit:
750} 809}
751 810
752/* Callers must hold xpad->odata_lock spinlock */ 811/* Callers must hold xpad->odata_lock spinlock */
812static bool xpad_prepare_next_init_packet(struct usb_xpad *xpad)
813{
814 const struct xboxone_init_packet *init_packet;
815
816 if (xpad->xtype != XTYPE_XBOXONE)
817 return false;
818
819 /* Perform initialization sequence for Xbox One pads that require it */
820 while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) {
821 init_packet = &xboxone_init_packets[xpad->init_seq++];
822
823 if (init_packet->idVendor != 0 &&
824 init_packet->idVendor != xpad->dev->id.vendor)
825 continue;
826
827 if (init_packet->idProduct != 0 &&
828 init_packet->idProduct != xpad->dev->id.product)
829 continue;
830
831 /* This packet applies to our device, so prepare to send it */
832 memcpy(xpad->odata, init_packet->data, init_packet->len);
833 xpad->irq_out->transfer_buffer_length = init_packet->len;
834
835 /* Update packet with current sequence number */
836 xpad->odata[2] = xpad->odata_serial++;
837 return true;
838 }
839
840 return false;
841}
842
843/* Callers must hold xpad->odata_lock spinlock */
753static bool xpad_prepare_next_out_packet(struct usb_xpad *xpad) 844static bool xpad_prepare_next_out_packet(struct usb_xpad *xpad)
754{ 845{
755 struct xpad_output_packet *pkt, *packet = NULL; 846 struct xpad_output_packet *pkt, *packet = NULL;
756 int i; 847 int i;
757 848
849 /* We may have init packets to send before we can send user commands */
850 if (xpad_prepare_next_init_packet(xpad))
851 return true;
852
758 for (i = 0; i < XPAD_NUM_OUT_PACKETS; i++) { 853 for (i = 0; i < XPAD_NUM_OUT_PACKETS; i++) {
759 if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) 854 if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS)
760 xpad->last_out_packet = 0; 855 xpad->last_out_packet = 0;
@@ -940,24 +1035,17 @@ static int xpad_inquiry_pad_presence(struct usb_xpad *xpad)
940 1035
941static int xpad_start_xbox_one(struct usb_xpad *xpad) 1036static int xpad_start_xbox_one(struct usb_xpad *xpad)
942{ 1037{
943 struct xpad_output_packet *packet =
944 &xpad->out_packets[XPAD_OUT_CMD_IDX];
945 unsigned long flags; 1038 unsigned long flags;
946 int retval; 1039 int retval;
947 1040
948 spin_lock_irqsave(&xpad->odata_lock, flags); 1041 spin_lock_irqsave(&xpad->odata_lock, flags);
949 1042
950 /* Xbox one controller needs to be initialized. */ 1043 /*
951 packet->data[0] = 0x05; 1044 * Begin the init sequence by attempting to send a packet.
952 packet->data[1] = 0x20; 1045 * We will cycle through the init packet sequence before
953 packet->data[2] = xpad->odata_serial++; /* packet serial */ 1046 * sending any packets from the output ring.
954 packet->data[3] = 0x01; /* rumble bit enable? */ 1047 */
955 packet->data[4] = 0x00; 1048 xpad->init_seq = 0;
956 packet->len = 5;
957 packet->pending = true;
958
959 /* Reset the sequence so we send out start packet first */
960 xpad->last_out_packet = -1;
961 retval = xpad_try_sending_next_out_packet(xpad); 1049 retval = xpad_try_sending_next_out_packet(xpad);
962 1050
963 spin_unlock_irqrestore(&xpad->odata_lock, flags); 1051 spin_unlock_irqrestore(&xpad->odata_lock, flags);
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index 6a250d65f8fe..c7a8120b13c0 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -30,6 +30,7 @@
30#include <linux/notifier.h> 30#include <linux/notifier.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/sysrq.h>
33#include <linux/input/matrix_keypad.h> 34#include <linux/input/matrix_keypad.h>
34#include <linux/mfd/cros_ec.h> 35#include <linux/mfd/cros_ec.h>
35#include <linux/mfd/cros_ec_commands.h> 36#include <linux/mfd/cros_ec_commands.h>
@@ -260,6 +261,12 @@ static int cros_ec_keyb_work(struct notifier_block *nb,
260 ckdev->ec->event_size); 261 ckdev->ec->event_size);
261 break; 262 break;
262 263
264 case EC_MKBP_EVENT_SYSRQ:
265 val = get_unaligned_le32(&ckdev->ec->event_data.data.sysrq);
266 dev_dbg(ckdev->dev, "sysrq code from EC: %#x\n", val);
267 handle_sysrq(val);
268 break;
269
263 case EC_MKBP_EVENT_BUTTON: 270 case EC_MKBP_EVENT_BUTTON:
264 case EC_MKBP_EVENT_SWITCH: 271 case EC_MKBP_EVENT_SWITCH:
265 /* 272 /*
diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c
index c94d610b9d78..0d74312d5b02 100644
--- a/drivers/input/keyboard/locomokbd.c
+++ b/drivers/input/keyboard/locomokbd.c
@@ -264,9 +264,8 @@ static int locomokbd_probe(struct locomo_dev *dev)
264 264
265 spin_lock_init(&locomokbd->lock); 265 spin_lock_init(&locomokbd->lock);
266 266
267 init_timer(&locomokbd->timer); 267 setup_timer(&locomokbd->timer, locomokbd_timer_callback,
268 locomokbd->timer.function = locomokbd_timer_callback; 268 (unsigned long)locomokbd);
269 locomokbd->timer.data = (unsigned long) locomokbd;
270 269
271 locomokbd->suspend_jiffies = jiffies; 270 locomokbd->suspend_jiffies = jiffies;
272 271
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 18839cd5f76e..1f316d66e6f7 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -42,9 +42,10 @@ struct matrix_keypad {
42}; 42};
43 43
44/* 44/*
45 * NOTE: normally the GPIO has to be put into HiZ when de-activated to cause 45 * NOTE: If drive_inactive_cols is false, then the GPIO has to be put into
46 * minmal side effect when scanning other columns, here it is configured to 46 * HiZ when de-activated to cause minmal side effect when scanning other
47 * be input, and it should work on most platforms. 47 * columns. In that case it is configured here to be input, otherwise it is
48 * driven with the inactive value.
48 */ 49 */
49static void __activate_col(const struct matrix_keypad_platform_data *pdata, 50static void __activate_col(const struct matrix_keypad_platform_data *pdata,
50 int col, bool on) 51 int col, bool on)
@@ -55,7 +56,8 @@ static void __activate_col(const struct matrix_keypad_platform_data *pdata,
55 gpio_direction_output(pdata->col_gpios[col], level_on); 56 gpio_direction_output(pdata->col_gpios[col], level_on);
56 } else { 57 } else {
57 gpio_set_value_cansleep(pdata->col_gpios[col], !level_on); 58 gpio_set_value_cansleep(pdata->col_gpios[col], !level_on);
58 gpio_direction_input(pdata->col_gpios[col]); 59 if (!pdata->drive_inactive_cols)
60 gpio_direction_input(pdata->col_gpios[col]);
59 } 61 }
60} 62}
61 63
@@ -432,6 +434,9 @@ matrix_keypad_parse_dt(struct device *dev)
432 if (of_get_property(np, "gpio-activelow", NULL)) 434 if (of_get_property(np, "gpio-activelow", NULL))
433 pdata->active_low = true; 435 pdata->active_low = true;
434 436
437 pdata->drive_inactive_cols =
438 of_property_read_bool(np, "drive-inactive-cols");
439
435 of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms); 440 of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms);
436 of_property_read_u32(np, "col-scan-delay-us", 441 of_property_read_u32(np, "col-scan-delay-us",
437 &pdata->col_scan_delay_us); 442 &pdata->col_scan_delay_us);
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
index ebc67ba41fe2..940d38b08e6b 100644
--- a/drivers/input/keyboard/omap4-keypad.c
+++ b/drivers/input/keyboard/omap4-keypad.c
@@ -358,7 +358,7 @@ static int omap4_keypad_probe(struct platform_device *pdev)
358 "omap4-keypad", keypad_data); 358 "omap4-keypad", keypad_data);
359 if (error) { 359 if (error) {
360 dev_err(&pdev->dev, "failed to register interrupt\n"); 360 dev_err(&pdev->dev, "failed to register interrupt\n");
361 goto err_free_input; 361 goto err_free_keymap;
362 } 362 }
363 363
364 device_init_wakeup(&pdev->dev, true); 364 device_init_wakeup(&pdev->dev, true);
diff --git a/drivers/input/keyboard/qt1070.c b/drivers/input/keyboard/qt1070.c
index 5a5778729e37..76bb51309a78 100644
--- a/drivers/input/keyboard/qt1070.c
+++ b/drivers/input/keyboard/qt1070.c
@@ -274,9 +274,18 @@ static const struct i2c_device_id qt1070_id[] = {
274}; 274};
275MODULE_DEVICE_TABLE(i2c, qt1070_id); 275MODULE_DEVICE_TABLE(i2c, qt1070_id);
276 276
277#ifdef CONFIG_OF
278static const struct of_device_id qt1070_of_match[] = {
279 { .compatible = "qt1070", },
280 { },
281};
282MODULE_DEVICE_TABLE(of, qt1070_of_match);
283#endif
284
277static struct i2c_driver qt1070_driver = { 285static struct i2c_driver qt1070_driver = {
278 .driver = { 286 .driver = {
279 .name = "qt1070", 287 .name = "qt1070",
288 .of_match_table = of_match_ptr(qt1070_of_match),
280 .pm = &qt1070_pm_ops, 289 .pm = &qt1070_pm_ops,
281 }, 290 },
282 .id_table = qt1070_id, 291 .id_table = qt1070_id,
diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c
index 44dd7689c571..e37e335e406f 100644
--- a/drivers/input/keyboard/tca8418_keypad.c
+++ b/drivers/input/keyboard/tca8418_keypad.c
@@ -188,8 +188,6 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data)
188 input_event(input, EV_MSC, MSC_SCAN, code); 188 input_event(input, EV_MSC, MSC_SCAN, code);
189 input_report_key(input, keymap[code], state); 189 input_report_key(input, keymap[code], state);
190 190
191 /* Read for next loop */
192 error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, &reg);
193 } while (1); 191 } while (1);
194 192
195 input_sync(input); 193 input_sync(input);
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 9f7b72249eac..3872488c3fd7 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -143,7 +143,7 @@ config INPUT_PM8941_PWRKEY
143 143
144config INPUT_PM8XXX_VIBRATOR 144config INPUT_PM8XXX_VIBRATOR
145 tristate "Qualcomm PM8XXX vibrator support" 145 tristate "Qualcomm PM8XXX vibrator support"
146 depends on MFD_PM8XXX 146 depends on MFD_PM8XXX || MFD_SPMI_PMIC
147 select INPUT_FF_MEMLESS 147 select INPUT_FF_MEMLESS
148 help 148 help
149 This option enables device driver support for the vibrator 149 This option enables device driver support for the vibrator
diff --git a/drivers/input/misc/apanel.c b/drivers/input/misc/apanel.c
index 53630afab606..aad1df04c854 100644
--- a/drivers/input/misc/apanel.c
+++ b/drivers/input/misc/apanel.c
@@ -314,7 +314,8 @@ static int __init apanel_init(void)
314 if (devno >= APANEL_DEV_MAX) 314 if (devno >= APANEL_DEV_MAX)
315 pr_notice(APANEL ": unknown device %u found\n", devno); 315 pr_notice(APANEL ": unknown device %u found\n", devno);
316 else if (device_chip[devno] != CHIP_NONE) 316 else if (device_chip[devno] != CHIP_NONE)
317 pr_warning(APANEL ": duplicate entry for devno %u\n", devno); 317 pr_warn(APANEL ": duplicate entry for devno %u\n",
318 devno);
318 319
319 else if (method != 1 && method != 2 && method != 4) { 320 else if (method != 1 && method != 2 && method != 4) {
320 pr_notice(APANEL ": unknown method %u for devno %u\n", 321 pr_notice(APANEL ": unknown method %u for devno %u\n",
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 1ac898db303a..f11807db6979 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -13,6 +13,7 @@
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 */ 14 */
15 15
16#include <linux/acpi.h>
16#include <linux/errno.h> 17#include <linux/errno.h>
17#include <linux/irq.h> 18#include <linux/irq.h>
18#include <linux/init.h> 19#include <linux/init.h>
@@ -188,21 +189,13 @@ static void axp20x_remove_sysfs_group(void *_data)
188 sysfs_remove_group(&dev->kobj, &axp20x_attribute_group); 189 sysfs_remove_group(&dev->kobj, &axp20x_attribute_group);
189} 190}
190 191
191static int axp20x_pek_probe(struct platform_device *pdev) 192static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
193 struct platform_device *pdev)
192{ 194{
193 struct axp20x_pek *axp20x_pek; 195 struct axp20x_dev *axp20x = axp20x_pek->axp20x;
194 struct axp20x_dev *axp20x;
195 struct input_dev *idev; 196 struct input_dev *idev;
196 int error; 197 int error;
197 198
198 axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
199 GFP_KERNEL);
200 if (!axp20x_pek)
201 return -ENOMEM;
202
203 axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
204 axp20x = axp20x_pek->axp20x;
205
206 axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR"); 199 axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
207 if (axp20x_pek->irq_dbr < 0) { 200 if (axp20x_pek->irq_dbr < 0) {
208 dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n", 201 dev_err(&pdev->dev, "No IRQ for PEK_DBR, error=%d\n",
@@ -239,7 +232,7 @@ static int axp20x_pek_probe(struct platform_device *pdev)
239 axp20x_pek_irq, 0, 232 axp20x_pek_irq, 0,
240 "axp20x-pek-dbr", idev); 233 "axp20x-pek-dbr", idev);
241 if (error < 0) { 234 if (error < 0) {
242 dev_err(axp20x->dev, "Failed to request dbr IRQ#%d: %d\n", 235 dev_err(&pdev->dev, "Failed to request dbr IRQ#%d: %d\n",
243 axp20x_pek->irq_dbr, error); 236 axp20x_pek->irq_dbr, error);
244 return error; 237 return error;
245 } 238 }
@@ -248,30 +241,57 @@ static int axp20x_pek_probe(struct platform_device *pdev)
248 axp20x_pek_irq, 0, 241 axp20x_pek_irq, 0,
249 "axp20x-pek-dbf", idev); 242 "axp20x-pek-dbf", idev);
250 if (error < 0) { 243 if (error < 0) {
251 dev_err(axp20x->dev, "Failed to request dbf IRQ#%d: %d\n", 244 dev_err(&pdev->dev, "Failed to request dbf IRQ#%d: %d\n",
252 axp20x_pek->irq_dbf, error); 245 axp20x_pek->irq_dbf, error);
253 return error; 246 return error;
254 } 247 }
255 248
256 error = sysfs_create_group(&pdev->dev.kobj, &axp20x_attribute_group); 249 error = input_register_device(idev);
257 if (error) { 250 if (error) {
258 dev_err(axp20x->dev, "Failed to create sysfs attributes: %d\n", 251 dev_err(&pdev->dev, "Can't register input device: %d\n",
259 error); 252 error);
260 return error; 253 return error;
261 } 254 }
262 255
263 error = devm_add_action(&pdev->dev, 256 return 0;
264 axp20x_remove_sysfs_group, &pdev->dev); 257}
258
259static int axp20x_pek_probe(struct platform_device *pdev)
260{
261 struct axp20x_pek *axp20x_pek;
262 int error;
263
264 axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
265 GFP_KERNEL);
266 if (!axp20x_pek)
267 return -ENOMEM;
268
269 axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
270
271 /*
272 * Do not register the input device if there is an "INTCFD9"
273 * gpio button ACPI device, that handles the power button too,
274 * and otherwise we end up reporting all presses twice.
275 */
276 if (!acpi_dev_found("INTCFD9") ||
277 !IS_ENABLED(CONFIG_INPUT_SOC_BUTTON_ARRAY)) {
278 error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
279 if (error)
280 return error;
281 }
282
283 error = sysfs_create_group(&pdev->dev.kobj, &axp20x_attribute_group);
265 if (error) { 284 if (error) {
266 axp20x_remove_sysfs_group(&pdev->dev); 285 dev_err(&pdev->dev, "Failed to create sysfs attributes: %d\n",
267 dev_err(&pdev->dev, "Failed to add sysfs cleanup action: %d\n",
268 error); 286 error);
269 return error; 287 return error;
270 } 288 }
271 289
272 error = input_register_device(idev); 290 error = devm_add_action(&pdev->dev,
291 axp20x_remove_sysfs_group, &pdev->dev);
273 if (error) { 292 if (error) {
274 dev_err(axp20x->dev, "Can't register input device: %d\n", 293 axp20x_remove_sysfs_group(&pdev->dev);
294 dev_err(&pdev->dev, "Failed to add sysfs cleanup action: %d\n",
275 error); 295 error);
276 return error; 296 return error;
277 } 297 }
diff --git a/drivers/input/misc/bma150.c b/drivers/input/misc/bma150.c
index 1fa85379f86c..1efcfdf9f8a8 100644
--- a/drivers/input/misc/bma150.c
+++ b/drivers/input/misc/bma150.c
@@ -70,7 +70,6 @@
70#define BMA150_CFG_5_REG 0x11 70#define BMA150_CFG_5_REG 0x11
71 71
72#define BMA150_CHIP_ID 2 72#define BMA150_CHIP_ID 2
73#define BMA180_CHIP_ID 3
74#define BMA150_CHIP_ID_REG BMA150_DATA_0_REG 73#define BMA150_CHIP_ID_REG BMA150_DATA_0_REG
75 74
76#define BMA150_ACC_X_LSB_REG BMA150_DATA_2_REG 75#define BMA150_ACC_X_LSB_REG BMA150_DATA_2_REG
@@ -538,13 +537,8 @@ static int bma150_probe(struct i2c_client *client,
538 return -EIO; 537 return -EIO;
539 } 538 }
540 539
541 /*
542 * Note if the IIO CONFIG_BMA180 driver is enabled we want to fail
543 * the probe for the bma180 as the iio driver is preferred.
544 */
545 chip_id = i2c_smbus_read_byte_data(client, BMA150_CHIP_ID_REG); 540 chip_id = i2c_smbus_read_byte_data(client, BMA150_CHIP_ID_REG);
546 if (chip_id != BMA150_CHIP_ID && 541 if (chip_id != BMA150_CHIP_ID) {
547 (IS_ENABLED(CONFIG_BMA180) || chip_id != BMA180_CHIP_ID)) {
548 dev_err(&client->dev, "BMA150 chip id error: %d\n", chip_id); 542 dev_err(&client->dev, "BMA150 chip id error: %d\n", chip_id);
549 return -EINVAL; 543 return -EINVAL;
550 } 544 }
@@ -648,9 +642,6 @@ static UNIVERSAL_DEV_PM_OPS(bma150_pm, bma150_suspend, bma150_resume, NULL);
648 642
649static const struct i2c_device_id bma150_id[] = { 643static const struct i2c_device_id bma150_id[] = {
650 { "bma150", 0 }, 644 { "bma150", 0 },
651#if !IS_ENABLED(CONFIG_BMA180)
652 { "bma180", 0 },
653#endif
654 { "smb380", 0 }, 645 { "smb380", 0 },
655 { "bma023", 0 }, 646 { "bma023", 0 },
656 { } 647 { }
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c
index 82e272ebc0ed..bab256ef32b9 100644
--- a/drivers/input/misc/dm355evm_keys.c
+++ b/drivers/input/misc/dm355evm_keys.c
@@ -32,7 +32,6 @@
32struct dm355evm_keys { 32struct dm355evm_keys {
33 struct input_dev *input; 33 struct input_dev *input;
34 struct device *dev; 34 struct device *dev;
35 int irq;
36}; 35};
37 36
38/* These initial keycodes can be remapped */ 37/* These initial keycodes can be remapped */
@@ -176,74 +175,49 @@ static int dm355evm_keys_probe(struct platform_device *pdev)
176{ 175{
177 struct dm355evm_keys *keys; 176 struct dm355evm_keys *keys;
178 struct input_dev *input; 177 struct input_dev *input;
179 int status; 178 int irq;
179 int error;
180 180
181 /* allocate instance struct and input dev */ 181 keys = devm_kzalloc(&pdev->dev, sizeof (*keys), GFP_KERNEL);
182 keys = kzalloc(sizeof *keys, GFP_KERNEL); 182 if (!keys)
183 input = input_allocate_device(); 183 return -ENOMEM;
184 if (!keys || !input) { 184
185 status = -ENOMEM; 185 input = devm_input_allocate_device(&pdev->dev);
186 goto fail1; 186 if (!input)
187 } 187 return -ENOMEM;
188 188
189 keys->dev = &pdev->dev; 189 keys->dev = &pdev->dev;
190 keys->input = input; 190 keys->input = input;
191 191
192 /* set up "threaded IRQ handler" */
193 status = platform_get_irq(pdev, 0);
194 if (status < 0)
195 goto fail1;
196 keys->irq = status;
197
198 input->name = "DM355 EVM Controls"; 192 input->name = "DM355 EVM Controls";
199 input->phys = "dm355evm/input0"; 193 input->phys = "dm355evm/input0";
200 input->dev.parent = &pdev->dev;
201 194
202 input->id.bustype = BUS_I2C; 195 input->id.bustype = BUS_I2C;
203 input->id.product = 0x0355; 196 input->id.product = 0x0355;
204 input->id.version = dm355evm_msp_read(DM355EVM_MSP_FIRMREV); 197 input->id.version = dm355evm_msp_read(DM355EVM_MSP_FIRMREV);
205 198
206 status = sparse_keymap_setup(input, dm355evm_keys, NULL); 199 error = sparse_keymap_setup(input, dm355evm_keys, NULL);
207 if (status) 200 if (error)
208 goto fail1; 201 return error;
209 202
210 /* REVISIT: flush the event queue? */ 203 /* REVISIT: flush the event queue? */
211 204
212 status = request_threaded_irq(keys->irq, NULL, dm355evm_keys_irq, 205 /* set up "threaded IRQ handler" */
213 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 206 irq = platform_get_irq(pdev, 0);
214 dev_name(&pdev->dev), keys); 207 if (irq < 0)
215 if (status < 0) 208 return irq;
216 goto fail2;
217
218 /* register */
219 status = input_register_device(input);
220 if (status < 0)
221 goto fail3;
222
223 platform_set_drvdata(pdev, keys);
224
225 return 0;
226
227fail3:
228 free_irq(keys->irq, keys);
229fail2:
230 sparse_keymap_free(input);
231fail1:
232 input_free_device(input);
233 kfree(keys);
234 dev_err(&pdev->dev, "can't register, err %d\n", status);
235
236 return status;
237}
238 209
239static int dm355evm_keys_remove(struct platform_device *pdev) 210 error = devm_request_threaded_irq(&pdev->dev, irq,
240{ 211 NULL, dm355evm_keys_irq,
241 struct dm355evm_keys *keys = platform_get_drvdata(pdev); 212 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
213 dev_name(&pdev->dev), keys);
214 if (error)
215 return error;
242 216
243 free_irq(keys->irq, keys); 217 /* register */
244 sparse_keymap_free(keys->input); 218 error = input_register_device(input);
245 input_unregister_device(keys->input); 219 if (error)
246 kfree(keys); 220 return error;
247 221
248 return 0; 222 return 0;
249} 223}
@@ -259,7 +233,6 @@ static int dm355evm_keys_remove(struct platform_device *pdev)
259 */ 233 */
260static struct platform_driver dm355evm_keys_driver = { 234static struct platform_driver dm355evm_keys_driver = {
261 .probe = dm355evm_keys_probe, 235 .probe = dm355evm_keys_probe,
262 .remove = dm355evm_keys_remove,
263 .driver = { 236 .driver = {
264 .name = "dm355evm_keys", 237 .name = "dm355evm_keys",
265 }, 238 },
diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c
index fb089d36c0d6..17eb84ab4c0b 100644
--- a/drivers/input/misc/drv260x.c
+++ b/drivers/input/misc/drv260x.c
@@ -652,7 +652,6 @@ static const struct i2c_device_id drv260x_id[] = {
652}; 652};
653MODULE_DEVICE_TABLE(i2c, drv260x_id); 653MODULE_DEVICE_TABLE(i2c, drv260x_id);
654 654
655#ifdef CONFIG_OF
656static const struct of_device_id drv260x_of_match[] = { 655static const struct of_device_id drv260x_of_match[] = {
657 { .compatible = "ti,drv2604", }, 656 { .compatible = "ti,drv2604", },
658 { .compatible = "ti,drv2604l", }, 657 { .compatible = "ti,drv2604l", },
@@ -661,13 +660,12 @@ static const struct of_device_id drv260x_of_match[] = {
661 { } 660 { }
662}; 661};
663MODULE_DEVICE_TABLE(of, drv260x_of_match); 662MODULE_DEVICE_TABLE(of, drv260x_of_match);
664#endif
665 663
666static struct i2c_driver drv260x_driver = { 664static struct i2c_driver drv260x_driver = {
667 .probe = drv260x_probe, 665 .probe = drv260x_probe,
668 .driver = { 666 .driver = {
669 .name = "drv260x-haptics", 667 .name = "drv260x-haptics",
670 .of_match_table = of_match_ptr(drv260x_of_match), 668 .of_match_table = drv260x_of_match,
671 .pm = &drv260x_pm_ops, 669 .pm = &drv260x_pm_ops,
672 }, 670 },
673 .id_table = drv260x_id, 671 .id_table = drv260x_id,
diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c
index 5113877153d7..7dd1c1fbe42a 100644
--- a/drivers/input/misc/pm8xxx-vibrator.c
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -10,19 +10,15 @@
10 * GNU General Public License for more details. 10 * GNU General Public License for more details.
11 */ 11 */
12 12
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/errno.h> 13#include <linux/errno.h>
16#include <linux/platform_device.h>
17#include <linux/input.h> 14#include <linux/input.h>
18#include <linux/slab.h> 15#include <linux/kernel.h>
16#include <linux/module.h>
17#include <linux/of.h>
18#include <linux/of_device.h>
19#include <linux/platform_device.h>
19#include <linux/regmap.h> 20#include <linux/regmap.h>
20 21#include <linux/slab.h>
21#define VIB_DRV 0x4A
22
23#define VIB_DRV_SEL_MASK 0xf8
24#define VIB_DRV_SEL_SHIFT 0x03
25#define VIB_DRV_EN_MANUAL_MASK 0xfc
26 22
27#define VIB_MAX_LEVEL_mV (3100) 23#define VIB_MAX_LEVEL_mV (3100)
28#define VIB_MIN_LEVEL_mV (1200) 24#define VIB_MIN_LEVEL_mV (1200)
@@ -30,20 +26,48 @@
30 26
31#define MAX_FF_SPEED 0xff 27#define MAX_FF_SPEED 0xff
32 28
29struct pm8xxx_regs {
30 unsigned int enable_addr;
31 unsigned int enable_mask;
32
33 unsigned int drv_addr;
34 unsigned int drv_mask;
35 unsigned int drv_shift;
36 unsigned int drv_en_manual_mask;
37};
38
39static const struct pm8xxx_regs pm8058_regs = {
40 .drv_addr = 0x4A,
41 .drv_mask = 0xf8,
42 .drv_shift = 3,
43 .drv_en_manual_mask = 0xfc,
44};
45
46static struct pm8xxx_regs pm8916_regs = {
47 .enable_addr = 0xc046,
48 .enable_mask = BIT(7),
49 .drv_addr = 0xc041,
50 .drv_mask = 0x1F,
51 .drv_shift = 0,
52 .drv_en_manual_mask = 0,
53};
54
33/** 55/**
34 * struct pm8xxx_vib - structure to hold vibrator data 56 * struct pm8xxx_vib - structure to hold vibrator data
35 * @vib_input_dev: input device supporting force feedback 57 * @vib_input_dev: input device supporting force feedback
36 * @work: work structure to set the vibration parameters 58 * @work: work structure to set the vibration parameters
37 * @regmap: regmap for register read/write 59 * @regmap: regmap for register read/write
60 * @regs: registers' info
38 * @speed: speed of vibration set from userland 61 * @speed: speed of vibration set from userland
39 * @active: state of vibrator 62 * @active: state of vibrator
40 * @level: level of vibration to set in the chip 63 * @level: level of vibration to set in the chip
41 * @reg_vib_drv: VIB_DRV register value 64 * @reg_vib_drv: regs->drv_addr register value
42 */ 65 */
43struct pm8xxx_vib { 66struct pm8xxx_vib {
44 struct input_dev *vib_input_dev; 67 struct input_dev *vib_input_dev;
45 struct work_struct work; 68 struct work_struct work;
46 struct regmap *regmap; 69 struct regmap *regmap;
70 const struct pm8xxx_regs *regs;
47 int speed; 71 int speed;
48 int level; 72 int level;
49 bool active; 73 bool active;
@@ -59,18 +83,24 @@ static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on)
59{ 83{
60 int rc; 84 int rc;
61 unsigned int val = vib->reg_vib_drv; 85 unsigned int val = vib->reg_vib_drv;
86 const struct pm8xxx_regs *regs = vib->regs;
62 87
63 if (on) 88 if (on)
64 val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK); 89 val |= (vib->level << regs->drv_shift) & regs->drv_mask;
65 else 90 else
66 val &= ~VIB_DRV_SEL_MASK; 91 val &= ~regs->drv_mask;
67 92
68 rc = regmap_write(vib->regmap, VIB_DRV, val); 93 rc = regmap_write(vib->regmap, regs->drv_addr, val);
69 if (rc < 0) 94 if (rc < 0)
70 return rc; 95 return rc;
71 96
72 vib->reg_vib_drv = val; 97 vib->reg_vib_drv = val;
73 return 0; 98
99 if (regs->enable_mask)
100 rc = regmap_update_bits(vib->regmap, regs->enable_addr,
101 on ? regs->enable_mask : 0, val);
102
103 return rc;
74} 104}
75 105
76/** 106/**
@@ -80,10 +110,11 @@ static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on)
80static void pm8xxx_work_handler(struct work_struct *work) 110static void pm8xxx_work_handler(struct work_struct *work)
81{ 111{
82 struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib, work); 112 struct pm8xxx_vib *vib = container_of(work, struct pm8xxx_vib, work);
113 const struct pm8xxx_regs *regs = vib->regs;
83 int rc; 114 int rc;
84 unsigned int val; 115 unsigned int val;
85 116
86 rc = regmap_read(vib->regmap, VIB_DRV, &val); 117 rc = regmap_read(vib->regmap, regs->drv_addr, &val);
87 if (rc < 0) 118 if (rc < 0)
88 return; 119 return;
89 120
@@ -147,6 +178,7 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
147 struct input_dev *input_dev; 178 struct input_dev *input_dev;
148 int error; 179 int error;
149 unsigned int val; 180 unsigned int val;
181 const struct pm8xxx_regs *regs;
150 182
151 vib = devm_kzalloc(&pdev->dev, sizeof(*vib), GFP_KERNEL); 183 vib = devm_kzalloc(&pdev->dev, sizeof(*vib), GFP_KERNEL);
152 if (!vib) 184 if (!vib)
@@ -163,16 +195,19 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
163 INIT_WORK(&vib->work, pm8xxx_work_handler); 195 INIT_WORK(&vib->work, pm8xxx_work_handler);
164 vib->vib_input_dev = input_dev; 196 vib->vib_input_dev = input_dev;
165 197
198 regs = of_device_get_match_data(&pdev->dev);
199
166 /* operate in manual mode */ 200 /* operate in manual mode */
167 error = regmap_read(vib->regmap, VIB_DRV, &val); 201 error = regmap_read(vib->regmap, regs->drv_addr, &val);
168 if (error < 0) 202 if (error < 0)
169 return error; 203 return error;
170 204
171 val &= ~VIB_DRV_EN_MANUAL_MASK; 205 val &= regs->drv_en_manual_mask;
172 error = regmap_write(vib->regmap, VIB_DRV, val); 206 error = regmap_write(vib->regmap, regs->drv_addr, val);
173 if (error < 0) 207 if (error < 0)
174 return error; 208 return error;
175 209
210 vib->regs = regs;
176 vib->reg_vib_drv = val; 211 vib->reg_vib_drv = val;
177 212
178 input_dev->name = "pm8xxx_vib_ffmemless"; 213 input_dev->name = "pm8xxx_vib_ffmemless";
@@ -212,8 +247,9 @@ static int __maybe_unused pm8xxx_vib_suspend(struct device *dev)
212static SIMPLE_DEV_PM_OPS(pm8xxx_vib_pm_ops, pm8xxx_vib_suspend, NULL); 247static SIMPLE_DEV_PM_OPS(pm8xxx_vib_pm_ops, pm8xxx_vib_suspend, NULL);
213 248
214static const struct of_device_id pm8xxx_vib_id_table[] = { 249static const struct of_device_id pm8xxx_vib_id_table[] = {
215 { .compatible = "qcom,pm8058-vib" }, 250 { .compatible = "qcom,pm8058-vib", .data = &pm8058_regs },
216 { .compatible = "qcom,pm8921-vib" }, 251 { .compatible = "qcom,pm8921-vib", .data = &pm8058_regs },
252 { .compatible = "qcom,pm8916-vib", .data = &pm8916_regs },
217 { } 253 { }
218}; 254};
219MODULE_DEVICE_TABLE(of, pm8xxx_vib_id_table); 255MODULE_DEVICE_TABLE(of, pm8xxx_vib_id_table);
diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
index e53801dbd560..edca0d737750 100644
--- a/drivers/input/misc/pwm-beeper.c
+++ b/drivers/input/misc/pwm-beeper.c
@@ -19,6 +19,7 @@
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/property.h>
22#include <linux/pwm.h> 23#include <linux/pwm.h>
23#include <linux/slab.h> 24#include <linux/slab.h>
24#include <linux/workqueue.h> 25#include <linux/workqueue.h>
@@ -29,6 +30,7 @@ struct pwm_beeper {
29 struct regulator *amplifier; 30 struct regulator *amplifier;
30 struct work_struct work; 31 struct work_struct work;
31 unsigned long period; 32 unsigned long period;
33 unsigned int bell_frequency;
32 bool suspended; 34 bool suspended;
33 bool amplifier_on; 35 bool amplifier_on;
34}; 36};
@@ -94,7 +96,7 @@ static int pwm_beeper_event(struct input_dev *input,
94 96
95 switch (code) { 97 switch (code) {
96 case SND_BELL: 98 case SND_BELL:
97 value = value ? 1000 : 0; 99 value = value ? beeper->bell_frequency : 0;
98 break; 100 break;
99 case SND_TONE: 101 case SND_TONE:
100 break; 102 break;
@@ -131,6 +133,7 @@ static int pwm_beeper_probe(struct platform_device *pdev)
131 struct device *dev = &pdev->dev; 133 struct device *dev = &pdev->dev;
132 struct pwm_beeper *beeper; 134 struct pwm_beeper *beeper;
133 struct pwm_state state; 135 struct pwm_state state;
136 u32 bell_frequency;
134 int error; 137 int error;
135 138
136 beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL); 139 beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL);
@@ -167,6 +170,16 @@ static int pwm_beeper_probe(struct platform_device *pdev)
167 170
168 INIT_WORK(&beeper->work, pwm_beeper_work); 171 INIT_WORK(&beeper->work, pwm_beeper_work);
169 172
173 error = device_property_read_u32(dev, "beeper-hz", &bell_frequency);
174 if (error) {
175 bell_frequency = 1000;
176 dev_dbg(dev,
177 "failed to parse 'beeper-hz' property, using default: %uHz\n",
178 bell_frequency);
179 }
180
181 beeper->bell_frequency = bell_frequency;
182
170 beeper->input = devm_input_allocate_device(dev); 183 beeper->input = devm_input_allocate_device(dev);
171 if (!beeper->input) { 184 if (!beeper->input) {
172 dev_err(dev, "Failed to allocate input device\n"); 185 dev_err(dev, "Failed to allocate input device\n");
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index ddb2f22fca7a..f210a3322559 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -20,13 +20,6 @@
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22 22
23/*
24 * Definition of buttons on the tablet. The ACPI index of each button
25 * is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC
26 * Platforms"
27 */
28#define MAX_NBUTTONS 5
29
30struct soc_button_info { 23struct soc_button_info {
31 const char *name; 24 const char *name;
32 int acpi_index; 25 int acpi_index;
@@ -55,7 +48,7 @@ static int soc_button_lookup_gpio(struct device *dev, int acpi_index)
55 struct gpio_desc *desc; 48 struct gpio_desc *desc;
56 int gpio; 49 int gpio;
57 50
58 desc = gpiod_get_index(dev, KBUILD_MODNAME, acpi_index, GPIOD_ASIS); 51 desc = gpiod_get_index(dev, NULL, acpi_index, GPIOD_ASIS);
59 if (IS_ERR(desc)) 52 if (IS_ERR(desc))
60 return PTR_ERR(desc); 53 return PTR_ERR(desc);
61 54
@@ -79,14 +72,19 @@ soc_button_device_create(struct platform_device *pdev,
79 int gpio; 72 int gpio;
80 int error; 73 int error;
81 74
75 for (info = button_info; info->name; info++)
76 if (info->autorepeat == autorepeat)
77 n_buttons++;
78
82 gpio_keys_pdata = devm_kzalloc(&pdev->dev, 79 gpio_keys_pdata = devm_kzalloc(&pdev->dev,
83 sizeof(*gpio_keys_pdata) + 80 sizeof(*gpio_keys_pdata) +
84 sizeof(*gpio_keys) * MAX_NBUTTONS, 81 sizeof(*gpio_keys) * n_buttons,
85 GFP_KERNEL); 82 GFP_KERNEL);
86 if (!gpio_keys_pdata) 83 if (!gpio_keys_pdata)
87 return ERR_PTR(-ENOMEM); 84 return ERR_PTR(-ENOMEM);
88 85
89 gpio_keys = (void *)(gpio_keys_pdata + 1); 86 gpio_keys = (void *)(gpio_keys_pdata + 1);
87 n_buttons = 0;
90 88
91 for (info = button_info; info->name; info++) { 89 for (info = button_info; info->name; info++) {
92 if (info->autorepeat != autorepeat) 90 if (info->autorepeat != autorepeat)
@@ -140,6 +138,153 @@ err_free_mem:
140 return ERR_PTR(error); 138 return ERR_PTR(error);
141} 139}
142 140
141static int soc_button_get_acpi_object_int(const union acpi_object *obj)
142{
143 if (obj->type != ACPI_TYPE_INTEGER)
144 return -1;
145
146 return obj->integer.value;
147}
148
149/* Parse a single ACPI0011 _DSD button descriptor */
150static int soc_button_parse_btn_desc(struct device *dev,
151 const union acpi_object *desc,
152 int collection_uid,
153 struct soc_button_info *info)
154{
155 int upage, usage;
156
157 if (desc->type != ACPI_TYPE_PACKAGE ||
158 desc->package.count != 5 ||
159 /* First byte should be 1 (control) */
160 soc_button_get_acpi_object_int(&desc->package.elements[0]) != 1 ||
161 /* Third byte should be collection uid */
162 soc_button_get_acpi_object_int(&desc->package.elements[2]) !=
163 collection_uid) {
164 dev_err(dev, "Invalid ACPI Button Descriptor\n");
165 return -ENODEV;
166 }
167
168 info->event_type = EV_KEY;
169 info->acpi_index =
170 soc_button_get_acpi_object_int(&desc->package.elements[1]);
171 upage = soc_button_get_acpi_object_int(&desc->package.elements[3]);
172 usage = soc_button_get_acpi_object_int(&desc->package.elements[4]);
173
174 /*
175 * The UUID: fa6bd625-9ce8-470d-a2c7-b3ca36c4282e descriptors use HID
176 * usage page and usage codes, but otherwise the device is not HID
177 * compliant: it uses one irq per button instead of generating HID
178 * input reports and some buttons should generate wakeups where as
179 * others should not, so we cannot use the HID subsystem.
180 *
181 * Luckily all devices only use a few usage page + usage combinations,
182 * so we can simply check for the known combinations here.
183 */
184 if (upage == 0x01 && usage == 0x81) {
185 info->name = "power";
186 info->event_code = KEY_POWER;
187 info->wakeup = true;
188 } else if (upage == 0x07 && usage == 0xe3) {
189 info->name = "home";
190 info->event_code = KEY_LEFTMETA;
191 info->wakeup = true;
192 } else if (upage == 0x0c && usage == 0xe9) {
193 info->name = "volume_up";
194 info->event_code = KEY_VOLUMEUP;
195 info->autorepeat = true;
196 } else if (upage == 0x0c && usage == 0xea) {
197 info->name = "volume_down";
198 info->event_code = KEY_VOLUMEDOWN;
199 info->autorepeat = true;
200 } else {
201 dev_warn(dev, "Unknown button index %d upage %02x usage %02x, ignoring\n",
202 info->acpi_index, upage, usage);
203 info->name = "unknown";
204 info->event_code = KEY_RESERVED;
205 }
206
207 return 0;
208}
209
210/* ACPI0011 _DSD btns descriptors UUID: fa6bd625-9ce8-470d-a2c7-b3ca36c4282e */
211static const u8 btns_desc_uuid[16] = {
212 0x25, 0xd6, 0x6b, 0xfa, 0xe8, 0x9c, 0x0d, 0x47,
213 0xa2, 0xc7, 0xb3, 0xca, 0x36, 0xc4, 0x28, 0x2e
214};
215
216/* Parse ACPI0011 _DSD button descriptors */
217static struct soc_button_info *soc_button_get_button_info(struct device *dev)
218{
219 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
220 const union acpi_object *desc, *el0, *uuid, *btns_desc = NULL;
221 struct soc_button_info *button_info;
222 acpi_status status;
223 int i, btn, collection_uid = -1;
224
225 status = acpi_evaluate_object_typed(ACPI_HANDLE(dev), "_DSD", NULL,
226 &buf, ACPI_TYPE_PACKAGE);
227 if (ACPI_FAILURE(status)) {
228 dev_err(dev, "ACPI _DSD object not found\n");
229 return ERR_PTR(-ENODEV);
230 }
231
232 /* Look for the Button Descriptors UUID */
233 desc = buf.pointer;
234 for (i = 0; (i + 1) < desc->package.count; i += 2) {
235 uuid = &desc->package.elements[i];
236
237 if (uuid->type != ACPI_TYPE_BUFFER ||
238 uuid->buffer.length != 16 ||
239 desc->package.elements[i + 1].type != ACPI_TYPE_PACKAGE) {
240 break;
241 }
242
243 if (memcmp(uuid->buffer.pointer, btns_desc_uuid, 16) == 0) {
244 btns_desc = &desc->package.elements[i + 1];
245 break;
246 }
247 }
248
249 if (!btns_desc) {
250 dev_err(dev, "ACPI Button Descriptors not found\n");
251 return ERR_PTR(-ENODEV);
252 }
253
254 /* The first package describes the collection */
255 el0 = &btns_desc->package.elements[0];
256 if (el0->type == ACPI_TYPE_PACKAGE &&
257 el0->package.count == 5 &&
258 /* First byte should be 0 (collection) */
259 soc_button_get_acpi_object_int(&el0->package.elements[0]) == 0 &&
260 /* Third byte should be 0 (top level collection) */
261 soc_button_get_acpi_object_int(&el0->package.elements[2]) == 0) {
262 collection_uid = soc_button_get_acpi_object_int(
263 &el0->package.elements[1]);
264 }
265 if (collection_uid == -1) {
266 dev_err(dev, "Invalid Button Collection Descriptor\n");
267 return ERR_PTR(-ENODEV);
268 }
269
270 /* There are package.count - 1 buttons + 1 terminating empty entry */
271 button_info = devm_kcalloc(dev, btns_desc->package.count,
272 sizeof(*button_info), GFP_KERNEL);
273 if (!button_info)
274 return ERR_PTR(-ENOMEM);
275
276 /* Parse the button descriptors */
277 for (i = 1, btn = 0; i < btns_desc->package.count; i++, btn++) {
278 if (soc_button_parse_btn_desc(dev,
279 &btns_desc->package.elements[i],
280 collection_uid,
281 &button_info[btn]))
282 return ERR_PTR(-ENODEV);
283 }
284
285 return button_info;
286}
287
143static int soc_button_remove(struct platform_device *pdev) 288static int soc_button_remove(struct platform_device *pdev)
144{ 289{
145 struct soc_button_data *priv = platform_get_drvdata(pdev); 290 struct soc_button_data *priv = platform_get_drvdata(pdev);
@@ -167,9 +312,15 @@ static int soc_button_probe(struct platform_device *pdev)
167 if (!id) 312 if (!id)
168 return -ENODEV; 313 return -ENODEV;
169 314
170 button_info = (struct soc_button_info *)id->driver_data; 315 if (!id->driver_data) {
316 button_info = soc_button_get_button_info(dev);
317 if (IS_ERR(button_info))
318 return PTR_ERR(button_info);
319 } else {
320 button_info = (struct soc_button_info *)id->driver_data;
321 }
171 322
172 if (gpiod_count(dev, KBUILD_MODNAME) <= 0) { 323 if (gpiod_count(dev, NULL) <= 0) {
173 dev_dbg(dev, "no GPIO attached, ignoring...\n"); 324 dev_dbg(dev, "no GPIO attached, ignoring...\n");
174 return -ENODEV; 325 return -ENODEV;
175 } 326 }
@@ -197,9 +348,17 @@ static int soc_button_probe(struct platform_device *pdev)
197 if (!priv->children[0] && !priv->children[1]) 348 if (!priv->children[0] && !priv->children[1])
198 return -ENODEV; 349 return -ENODEV;
199 350
351 if (!id->driver_data)
352 devm_kfree(dev, button_info);
353
200 return 0; 354 return 0;
201} 355}
202 356
357/*
358 * Definition of buttons on the tablet. The ACPI index of each button
359 * is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC
360 * Platforms"
361 */
203static struct soc_button_info soc_button_PNP0C40[] = { 362static struct soc_button_info soc_button_PNP0C40[] = {
204 { "power", 0, EV_KEY, KEY_POWER, false, true }, 363 { "power", 0, EV_KEY, KEY_POWER, false, true },
205 { "home", 1, EV_KEY, KEY_LEFTMETA, false, true }, 364 { "home", 1, EV_KEY, KEY_LEFTMETA, false, true },
@@ -211,6 +370,7 @@ static struct soc_button_info soc_button_PNP0C40[] = {
211 370
212static const struct acpi_device_id soc_button_acpi_match[] = { 371static const struct acpi_device_id soc_button_acpi_match[] = {
213 { "PNP0C40", (unsigned long)soc_button_PNP0C40 }, 372 { "PNP0C40", (unsigned long)soc_button_PNP0C40 },
373 { "ACPI0011", 0 },
214 { } 374 { }
215}; 375};
216 376
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c
index 54162d2cbcfc..1c13005b228f 100644
--- a/drivers/input/misc/twl4030-pwrbutton.c
+++ b/drivers/input/misc/twl4030-pwrbutton.c
@@ -64,13 +64,12 @@ static int twl4030_pwrbutton_probe(struct platform_device *pdev)
64 return -ENOMEM; 64 return -ENOMEM;
65 } 65 }
66 66
67 pwr->evbit[0] = BIT_MASK(EV_KEY); 67 input_set_capability(pwr, EV_KEY, KEY_POWER);
68 pwr->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER);
69 pwr->name = "twl4030_pwrbutton"; 68 pwr->name = "twl4030_pwrbutton";
70 pwr->phys = "twl4030_pwrbutton/input0"; 69 pwr->phys = "twl4030_pwrbutton/input0";
71 pwr->dev.parent = &pdev->dev; 70 pwr->dev.parent = &pdev->dev;
72 71
73 err = devm_request_threaded_irq(&pwr->dev, irq, NULL, powerbutton_irq, 72 err = devm_request_threaded_irq(&pdev->dev, irq, NULL, powerbutton_irq,
74 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | 73 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING |
75 IRQF_ONESHOT, 74 IRQF_ONESHOT,
76 "twl4030_pwrbutton", pwr); 75 "twl4030_pwrbutton", pwr);
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index e25f87ba19f6..43e67f546366 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -1243,12 +1243,10 @@ static int setup_input_dev(void)
1243 1243
1244 error = input_register_polled_device(wistron_idev); 1244 error = input_register_polled_device(wistron_idev);
1245 if (error) 1245 if (error)
1246 goto err_free_keymap; 1246 goto err_free_dev;
1247 1247
1248 return 0; 1248 return 0;
1249 1249
1250 err_free_keymap:
1251 sparse_keymap_free(input_dev);
1252 err_free_dev: 1250 err_free_dev:
1253 input_free_polled_device(wistron_idev); 1251 input_free_polled_device(wistron_idev);
1254 return error; 1252 return error;
@@ -1300,7 +1298,6 @@ static int wistron_remove(struct platform_device *dev)
1300{ 1298{
1301 wistron_led_remove(); 1299 wistron_led_remove();
1302 input_unregister_polled_device(wistron_idev); 1300 input_unregister_polled_device(wistron_idev);
1303 sparse_keymap_free(wistron_idev->input);
1304 input_free_polled_device(wistron_idev); 1301 input_free_polled_device(wistron_idev);
1305 bios_detach(); 1302 bios_detach();
1306 1303
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 3900875dec10..690148f9940e 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -41,6 +41,12 @@ struct xenkbd_info {
41 char phys[32]; 41 char phys[32];
42}; 42};
43 43
44enum { KPARAM_X, KPARAM_Y, KPARAM_CNT };
45static int ptr_size[KPARAM_CNT] = { XENFB_WIDTH, XENFB_HEIGHT };
46module_param_array(ptr_size, int, NULL, 0444);
47MODULE_PARM_DESC(ptr_size,
48 "Pointing device width, height in pixels (default 800,600)");
49
44static int xenkbd_remove(struct xenbus_device *); 50static int xenkbd_remove(struct xenbus_device *);
45static int xenkbd_connect_backend(struct xenbus_device *, struct xenkbd_info *); 51static int xenkbd_connect_backend(struct xenbus_device *, struct xenkbd_info *);
46static void xenkbd_disconnect_backend(struct xenkbd_info *); 52static void xenkbd_disconnect_backend(struct xenkbd_info *);
@@ -84,8 +90,8 @@ static irqreturn_t input_handler(int rq, void *dev_id)
84 input_report_key(dev, event->key.keycode, 90 input_report_key(dev, event->key.keycode,
85 event->key.pressed); 91 event->key.pressed);
86 else 92 else
87 pr_warning("unhandled keycode 0x%x\n", 93 pr_warn("unhandled keycode 0x%x\n",
88 event->key.keycode); 94 event->key.keycode);
89 break; 95 break;
90 case XENKBD_TYPE_POS: 96 case XENKBD_TYPE_POS:
91 input_report_abs(dev, ABS_X, event->pos.abs_x); 97 input_report_abs(dev, ABS_X, event->pos.abs_x);
@@ -128,12 +134,17 @@ static int xenkbd_probe(struct xenbus_device *dev,
128 if (!info->page) 134 if (!info->page)
129 goto error_nomem; 135 goto error_nomem;
130 136
137 /* Set input abs params to match backend screen res */
131 abs = xenbus_read_unsigned(dev->otherend, "feature-abs-pointer", 0); 138 abs = xenbus_read_unsigned(dev->otherend, "feature-abs-pointer", 0);
139 ptr_size[KPARAM_X] = xenbus_read_unsigned(dev->otherend, "width",
140 ptr_size[KPARAM_X]);
141 ptr_size[KPARAM_Y] = xenbus_read_unsigned(dev->otherend, "height",
142 ptr_size[KPARAM_Y]);
132 if (abs) { 143 if (abs) {
133 ret = xenbus_write(XBT_NIL, dev->nodename, 144 ret = xenbus_write(XBT_NIL, dev->nodename,
134 "request-abs-pointer", "1"); 145 "request-abs-pointer", "1");
135 if (ret) { 146 if (ret) {
136 pr_warning("xenkbd: can't request abs-pointer"); 147 pr_warn("xenkbd: can't request abs-pointer\n");
137 abs = 0; 148 abs = 0;
138 } 149 }
139 } 150 }
@@ -174,8 +185,8 @@ static int xenkbd_probe(struct xenbus_device *dev,
174 185
175 if (abs) { 186 if (abs) {
176 __set_bit(EV_ABS, ptr->evbit); 187 __set_bit(EV_ABS, ptr->evbit);
177 input_set_abs_params(ptr, ABS_X, 0, XENFB_WIDTH, 0, 0); 188 input_set_abs_params(ptr, ABS_X, 0, ptr_size[KPARAM_X], 0, 0);
178 input_set_abs_params(ptr, ABS_Y, 0, XENFB_HEIGHT, 0, 0); 189 input_set_abs_params(ptr, ABS_Y, 0, ptr_size[KPARAM_Y], 0, 0);
179 } else { 190 } else {
180 input_set_capability(ptr, EV_REL, REL_X); 191 input_set_capability(ptr, EV_REL, REL_X);
181 input_set_capability(ptr, EV_REL, REL_Y); 192 input_set_capability(ptr, EV_REL, REL_Y);
@@ -309,9 +320,6 @@ static void xenkbd_disconnect_backend(struct xenkbd_info *info)
309static void xenkbd_backend_changed(struct xenbus_device *dev, 320static void xenkbd_backend_changed(struct xenbus_device *dev,
310 enum xenbus_state backend_state) 321 enum xenbus_state backend_state)
311{ 322{
312 struct xenkbd_info *info = dev_get_drvdata(&dev->dev);
313 int ret, val;
314
315 switch (backend_state) { 323 switch (backend_state) {
316 case XenbusStateInitialising: 324 case XenbusStateInitialising:
317 case XenbusStateInitialised: 325 case XenbusStateInitialised:
@@ -321,15 +329,6 @@ static void xenkbd_backend_changed(struct xenbus_device *dev,
321 break; 329 break;
322 330
323 case XenbusStateInitWait: 331 case XenbusStateInitWait:
324InitWait:
325 if (xenbus_read_unsigned(info->xbdev->otherend,
326 "feature-abs-pointer", 0)) {
327 ret = xenbus_write(XBT_NIL, info->xbdev->nodename,
328 "request-abs-pointer", "1");
329 if (ret)
330 pr_warning("xenkbd: can't request abs-pointer");
331 }
332
333 xenbus_switch_state(dev, XenbusStateConnected); 332 xenbus_switch_state(dev, XenbusStateConnected);
334 break; 333 break;
335 334
@@ -340,17 +339,7 @@ InitWait:
340 * get Connected twice here. 339 * get Connected twice here.
341 */ 340 */
342 if (dev->state != XenbusStateConnected) 341 if (dev->state != XenbusStateConnected)
343 goto InitWait; /* no InitWait seen yet, fudge it */ 342 xenbus_switch_state(dev, XenbusStateConnected);
344
345 /* Set input abs params to match backend screen res */
346 if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
347 "width", "%d", &val) > 0)
348 input_set_abs_params(info->ptr, ABS_X, 0, val, 0, 0);
349
350 if (xenbus_scanf(XBT_NIL, info->xbdev->otherend,
351 "height", "%d", &val) > 0)
352 input_set_abs_params(info->ptr, ABS_Y, 0, val, 0, 0);
353
354 break; 343 break;
355 344
356 case XenbusStateClosed: 345 case XenbusStateClosed:
diff --git a/drivers/input/misc/yealink.h b/drivers/input/misc/yealink.h
index 1e0f52397010..934c247f8a0f 100644
--- a/drivers/input/misc/yealink.h
+++ b/drivers/input/misc/yealink.h
@@ -28,7 +28,7 @@
28struct yld_ctl_packet { 28struct yld_ctl_packet {
29 u8 cmd; /* command code, see below */ 29 u8 cmd; /* command code, see below */
30 u8 size; /* 1-11, size of used data bytes. */ 30 u8 size; /* 1-11, size of used data bytes. */
31 u16 offset; /* internal packet offset */ 31 __be16 offset; /* internal packet offset */
32 u8 data[11]; 32 u8 data[11];
33 s8 sum; /* negative sum of 15 preceding bytes */ 33 s8 sum; /* negative sum of 15 preceding bytes */
34} __attribute__ ((packed)); 34} __attribute__ ((packed));
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 096abb4ad5cd..89ebb8f39fee 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -78,6 +78,18 @@ config MOUSE_PS2_SYNAPTICS
78 78
79 If unsure, say Y. 79 If unsure, say Y.
80 80
81config MOUSE_PS2_SYNAPTICS_SMBUS
82 bool "Synaptics PS/2 SMbus companion" if EXPERT
83 default y
84 depends on MOUSE_PS2
85 depends on I2C=y || I2C=MOUSE_PS2
86 select MOUSE_PS2_SMBUS
87 help
88 Say Y here if you have a Synaptics RMI4 touchpad connected to
89 to an SMBus, but enumerated through PS/2.
90
91 If unsure, say Y.
92
81config MOUSE_PS2_CYPRESS 93config MOUSE_PS2_CYPRESS
82 bool "Cypress PS/2 mouse protocol extension" if EXPERT 94 bool "Cypress PS/2 mouse protocol extension" if EXPERT
83 default y 95 default y
@@ -171,6 +183,10 @@ config MOUSE_PS2_VMMOUSE
171 183
172 If unsure, say N. 184 If unsure, say N.
173 185
186config MOUSE_PS2_SMBUS
187 bool
188 depends on MOUSE_PS2
189
174config MOUSE_SERIAL 190config MOUSE_SERIAL
175 tristate "Serial mouse" 191 tristate "Serial mouse"
176 select SERIO 192 select SERIO
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 6168b134937b..56bf0ad877c6 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -39,6 +39,8 @@ psmouse-$(CONFIG_MOUSE_PS2_TOUCHKIT) += touchkit_ps2.o
39psmouse-$(CONFIG_MOUSE_PS2_CYPRESS) += cypress_ps2.o 39psmouse-$(CONFIG_MOUSE_PS2_CYPRESS) += cypress_ps2.o
40psmouse-$(CONFIG_MOUSE_PS2_VMMOUSE) += vmmouse.o 40psmouse-$(CONFIG_MOUSE_PS2_VMMOUSE) += vmmouse.o
41 41
42psmouse-$(CONFIG_MOUSE_PS2_SMBUS) += psmouse-smbus.o
43
42elan_i2c-objs := elan_i2c_core.o 44elan_i2c-objs := elan_i2c_core.o
43elan_i2c-$(CONFIG_MOUSE_ELAN_I2C_I2C) += elan_i2c_i2c.o 45elan_i2c-$(CONFIG_MOUSE_ELAN_I2C_I2C) += elan_i2c_i2c.o
44elan_i2c-$(CONFIG_MOUSE_ELAN_I2C_SMBUS) += elan_i2c_smbus.o 46elan_i2c-$(CONFIG_MOUSE_ELAN_I2C_SMBUS) += elan_i2c_smbus.o
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index f210e19ddba6..262d1057c1da 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -106,39 +106,36 @@ static const struct alps_nibble_commands alps_v6_nibble_commands[] = {
106#define ALPS_DUALPOINT_WITH_PRESSURE 0x400 /* device can report trackpoint pressure */ 106#define ALPS_DUALPOINT_WITH_PRESSURE 0x400 /* device can report trackpoint pressure */
107 107
108static const struct alps_model_info alps_model_data[] = { 108static const struct alps_model_info alps_model_data[] = {
109 { { 0x32, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } }, /* Toshiba Salellite Pro M10 */
110 { { 0x33, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V1, 0x88, 0xf8, 0 } }, /* UMAX-530T */
111 { { 0x53, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
112 { { 0x53, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
113 { { 0x60, 0x03, 0xc8 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } }, /* HP ze1115 */
114 { { 0x63, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
115 { { 0x63, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
116 { { 0x63, 0x02, 0x28 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } }, /* Fujitsu Siemens S6010 */
117 { { 0x63, 0x02, 0x3c }, 0x00, { ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL } }, /* Toshiba Satellite S2400-103 */
118 { { 0x63, 0x02, 0x50 }, 0x00, { ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 } }, /* NEC Versa L320 */
119 { { 0x63, 0x02, 0x64 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
120 { { 0x63, 0x03, 0xc8 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } }, /* Dell Latitude D800 */
121 { { 0x73, 0x00, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT } }, /* ThinkPad R61 8918-5QG */
122 { { 0x73, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
123 { { 0x73, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } }, /* Ahtec Laptop */
124
125 /* 109 /*
126 * XXX This entry is suspicious. First byte has zero lower nibble, 110 * XXX This entry is suspicious. First byte has zero lower nibble,
127 * which is what a normal mouse would report. Also, the value 0x0e 111 * which is what a normal mouse would report. Also, the value 0x0e
128 * isn't valid per PS/2 spec. 112 * isn't valid per PS/2 spec.
129 */ 113 */
130 { { 0x20, 0x02, 0x0e }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } }, 114 { { 0x20, 0x02, 0x0e }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },
131 115
132 { { 0x22, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } }, 116 { { 0x22, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },
133 { { 0x22, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT } }, /* Dell Latitude D600 */ 117 { { 0x22, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT } }, /* Dell Latitude D600 */
134 /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ 118 { { 0x32, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } }, /* Toshiba Salellite Pro M10 */
135 { { 0x62, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xcf, 0xcf, 119 { { 0x33, 0x02, 0x0a }, { ALPS_PROTO_V1, 0x88, 0xf8, 0 } }, /* UMAX-530T */
136 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } }, 120 { { 0x52, 0x01, 0x14 }, { ALPS_PROTO_V2, 0xff, 0xff,
137 { { 0x73, 0x00, 0x14 }, 0x00, { ALPS_PROTO_V6, 0xff, 0xff, ALPS_DUALPOINT } }, /* Dell XT2 */
138 { { 0x73, 0x02, 0x50 }, 0x00, { ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS } }, /* Dell Vostro 1400 */
139 { { 0x52, 0x01, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xff, 0xff,
140 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } }, /* Toshiba Tecra A11-11L */ 121 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } }, /* Toshiba Tecra A11-11L */
141 { { 0x73, 0x02, 0x64 }, 0x8a, { ALPS_PROTO_V4, 0x8f, 0x8f, 0 } }, 122 { { 0x53, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
123 { { 0x53, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
124 { { 0x60, 0x03, 0xc8 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } }, /* HP ze1115 */
125 { { 0x62, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xcf, 0xcf,
126 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } }, /* Dell Latitude E5500, E6400, E6500, Precision M4400 */
127 { { 0x63, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
128 { { 0x63, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
129 { { 0x63, 0x02, 0x28 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } }, /* Fujitsu Siemens S6010 */
130 { { 0x63, 0x02, 0x3c }, { ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL } }, /* Toshiba Satellite S2400-103 */
131 { { 0x63, 0x02, 0x50 }, { ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 } }, /* NEC Versa L320 */
132 { { 0x63, 0x02, 0x64 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
133 { { 0x63, 0x03, 0xc8 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } }, /* Dell Latitude D800 */
134 { { 0x73, 0x00, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT } }, /* ThinkPad R61 8918-5QG */
135 { { 0x73, 0x00, 0x14 }, { ALPS_PROTO_V6, 0xff, 0xff, ALPS_DUALPOINT } }, /* Dell XT2 */
136 { { 0x73, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
137 { { 0x73, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } }, /* Ahtec Laptop */
138 { { 0x73, 0x02, 0x50 }, { ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS } }, /* Dell Vostro 1400 */
142}; 139};
143 140
144static const struct alps_protocol_info alps_v3_protocol_data = { 141static const struct alps_protocol_info alps_v3_protocol_data = {
@@ -149,6 +146,10 @@ static const struct alps_protocol_info alps_v3_rushmore_data = {
149 ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT 146 ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
150}; 147};
151 148
149static const struct alps_protocol_info alps_v4_protocol_data = {
150 ALPS_PROTO_V4, 0x8f, 0x8f, 0
151};
152
152static const struct alps_protocol_info alps_v5_protocol_data = { 153static const struct alps_protocol_info alps_v5_protocol_data = {
153 ALPS_PROTO_V5, 0xc8, 0xd8, 0 154 ALPS_PROTO_V5, 0xc8, 0xd8, 0
154}; 155};
@@ -161,6 +162,10 @@ static const struct alps_protocol_info alps_v8_protocol_data = {
161 ALPS_PROTO_V8, 0x18, 0x18, 0 162 ALPS_PROTO_V8, 0x18, 0x18, 0
162}; 163};
163 164
165static const struct alps_protocol_info alps_v9_protocol_data = {
166 ALPS_PROTO_V9, 0xc8, 0xc8, 0
167};
168
164/* 169/*
165 * Some v2 models report the stick buttons in separate bits 170 * Some v2 models report the stick buttons in separate bits
166 */ 171 */
@@ -2806,12 +2811,8 @@ static const struct alps_protocol_info *alps_match_table(unsigned char *e7,
2806 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) { 2811 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
2807 model = &alps_model_data[i]; 2812 model = &alps_model_data[i];
2808 2813
2809 if (!memcmp(e7, model->signature, sizeof(model->signature)) && 2814 if (!memcmp(e7, model->signature, sizeof(model->signature)))
2810 (!model->command_mode_resp ||
2811 model->command_mode_resp == ec[2])) {
2812
2813 return &model->protocol_info; 2815 return &model->protocol_info;
2814 }
2815 } 2816 }
2816 2817
2817 return NULL; 2818 return NULL;
@@ -2849,7 +2850,10 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
2849 2850
2850 protocol = alps_match_table(e7, ec); 2851 protocol = alps_match_table(e7, ec);
2851 if (!protocol) { 2852 if (!protocol) {
2852 if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0x50 && 2853 if (e7[0] == 0x73 && e7[1] == 0x02 && e7[2] == 0x64 &&
2854 ec[2] == 0x8a) {
2855 protocol = &alps_v4_protocol_data;
2856 } else if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0x50 &&
2853 ec[0] == 0x73 && (ec[1] == 0x01 || ec[1] == 0x02)) { 2857 ec[0] == 0x73 && (ec[1] == 0x01 || ec[1] == 0x02)) {
2854 protocol = &alps_v5_protocol_data; 2858 protocol = &alps_v5_protocol_data;
2855 } else if (ec[0] == 0x88 && 2859 } else if (ec[0] == 0x88 &&
@@ -2863,6 +2867,12 @@ static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
2863 } else if (e7[0] == 0x73 && e7[1] == 0x03 && 2867 } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
2864 (e7[2] == 0x14 || e7[2] == 0x28)) { 2868 (e7[2] == 0x14 || e7[2] == 0x28)) {
2865 protocol = &alps_v8_protocol_data; 2869 protocol = &alps_v8_protocol_data;
2870 } else if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0xc8) {
2871 protocol = &alps_v9_protocol_data;
2872 psmouse_warn(psmouse,
2873 "Unsupported ALPS V9 touchpad: E7=%3ph, EC=%3ph\n",
2874 e7, ec);
2875 return -EINVAL;
2866 } else { 2876 } else {
2867 psmouse_dbg(psmouse, 2877 psmouse_dbg(psmouse,
2868 "Likely not an ALPS touchpad: E7=%3ph, EC=%3ph\n", e7, ec); 2878 "Likely not an ALPS touchpad: E7=%3ph, EC=%3ph\n", e7, ec);
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index 4334f2805d93..ed2d6879fa52 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -23,6 +23,7 @@
23#define ALPS_PROTO_V6 0x600 23#define ALPS_PROTO_V6 0x600
24#define ALPS_PROTO_V7 0x700 /* t3btl t4s */ 24#define ALPS_PROTO_V7 0x700 /* t3btl t4s */
25#define ALPS_PROTO_V8 0x800 /* SS4btl SS4s */ 25#define ALPS_PROTO_V8 0x800 /* SS4btl SS4s */
26#define ALPS_PROTO_V9 0x900 /* ss3btl */
26 27
27#define MAX_TOUCHES 4 28#define MAX_TOUCHES 4
28 29
@@ -172,10 +173,6 @@ struct alps_protocol_info {
172/** 173/**
173 * struct alps_model_info - touchpad ID table 174 * struct alps_model_info - touchpad ID table
174 * @signature: E7 response string to match. 175 * @signature: E7 response string to match.
175 * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response
176 * (aka command mode response) identifies the firmware minor version. This
177 * can be used to distinguish different hardware models which are not
178 * uniquely identifiable through their E7 responses.
179 * @protocol_info: information about protocol used by the device. 176 * @protocol_info: information about protocol used by the device.
180 * 177 *
181 * Many (but not all) ALPS touchpads can be identified by looking at the 178 * Many (but not all) ALPS touchpads can be identified by looking at the
@@ -184,7 +181,6 @@ struct alps_protocol_info {
184 */ 181 */
185struct alps_model_info { 182struct alps_model_info {
186 u8 signature[3]; 183 u8 signature[3];
187 u8 command_mode_resp;
188 struct alps_protocol_info protocol_info; 184 struct alps_protocol_info protocol_info;
189}; 185};
190 186
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index a598b7223cef..f73b47b8c578 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -116,17 +116,6 @@ static DEFINE_MUTEX(psmouse_mutex);
116 116
117static struct workqueue_struct *kpsmoused_wq; 117static struct workqueue_struct *kpsmoused_wq;
118 118
119struct psmouse_protocol {
120 enum psmouse_type type;
121 bool maxproto;
122 bool ignore_parity; /* Protocol should ignore parity errors from KBC */
123 bool try_passthru; /* Try protocol also on passthrough ports */
124 const char *name;
125 const char *alias;
126 int (*detect)(struct psmouse *, bool);
127 int (*init)(struct psmouse *);
128};
129
130static void psmouse_report_standard_buttons(struct input_dev *dev, u8 buttons) 119static void psmouse_report_standard_buttons(struct input_dev *dev, u8 buttons)
131{ 120{
132 input_report_key(dev, BTN_LEFT, buttons & BIT(0)); 121 input_report_key(dev, BTN_LEFT, buttons & BIT(0));
@@ -148,7 +137,7 @@ psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse)
148 137
149 /* Full packet accumulated, process it */ 138 /* Full packet accumulated, process it */
150 139
151 switch (psmouse->type) { 140 switch (psmouse->protocol->type) {
152 case PSMOUSE_IMPS: 141 case PSMOUSE_IMPS:
153 /* IntelliMouse has scroll wheel */ 142 /* IntelliMouse has scroll wheel */
154 input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]); 143 input_report_rel(dev, REL_WHEEL, -(signed char) packet[3]);
@@ -325,7 +314,8 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
325 goto out; 314 goto out;
326 315
327 if (unlikely((flags & SERIO_TIMEOUT) || 316 if (unlikely((flags & SERIO_TIMEOUT) ||
328 ((flags & SERIO_PARITY) && !psmouse->ignore_parity))) { 317 ((flags & SERIO_PARITY) &&
318 !psmouse->protocol->ignore_parity))) {
329 319
330 if (psmouse->state == PSMOUSE_ACTIVATED) 320 if (psmouse->state == PSMOUSE_ACTIVATED)
331 psmouse_warn(psmouse, 321 psmouse_warn(psmouse,
@@ -372,7 +362,7 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
372 } 362 }
373 363
374 if (psmouse->packet[1] == PSMOUSE_RET_ID || 364 if (psmouse->packet[1] == PSMOUSE_RET_ID ||
375 (psmouse->type == PSMOUSE_HGPK && 365 (psmouse->protocol->type == PSMOUSE_HGPK &&
376 psmouse->packet[1] == PSMOUSE_RET_BAT)) { 366 psmouse->packet[1] == PSMOUSE_RET_BAT)) {
377 __psmouse_set_state(psmouse, PSMOUSE_IGNORE); 367 __psmouse_set_state(psmouse, PSMOUSE_IGNORE);
378 serio_reconnect(serio); 368 serio_reconnect(serio);
@@ -783,7 +773,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
783 .name = "SynPS/2", 773 .name = "SynPS/2",
784 .alias = "synaptics", 774 .alias = "synaptics",
785 .detect = synaptics_detect, 775 .detect = synaptics_detect,
786 .init = synaptics_init, 776 .init = synaptics_init_absolute,
787 }, 777 },
788 { 778 {
789 .type = PSMOUSE_SYNAPTICS_RELATIVE, 779 .type = PSMOUSE_SYNAPTICS_RELATIVE,
@@ -793,6 +783,16 @@ static const struct psmouse_protocol psmouse_protocols[] = {
793 .init = synaptics_init_relative, 783 .init = synaptics_init_relative,
794 }, 784 },
795#endif 785#endif
786#ifdef CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS
787 {
788 .type = PSMOUSE_SYNAPTICS_SMBUS,
789 .name = "SynSMBus",
790 .alias = "synaptics-smbus",
791 .detect = synaptics_detect,
792 .init = synaptics_init_smbus,
793 .smbus_companion = true,
794 },
795#endif
796#ifdef CONFIG_MOUSE_PS2_ALPS 796#ifdef CONFIG_MOUSE_PS2_ALPS
797 { 797 {
798 .type = PSMOUSE_ALPS, 798 .type = PSMOUSE_ALPS,
@@ -959,6 +959,8 @@ static void psmouse_apply_defaults(struct psmouse *psmouse)
959 959
960 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 960 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
961 961
962 psmouse->protocol = &psmouse_protocols[0];
963
962 psmouse->set_rate = psmouse_set_rate; 964 psmouse->set_rate = psmouse_set_rate;
963 psmouse->set_resolution = psmouse_set_resolution; 965 psmouse->set_resolution = psmouse_set_resolution;
964 psmouse->set_scale = psmouse_set_scale; 966 psmouse->set_scale = psmouse_set_scale;
@@ -966,6 +968,7 @@ static void psmouse_apply_defaults(struct psmouse *psmouse)
966 psmouse->protocol_handler = psmouse_process_byte; 968 psmouse->protocol_handler = psmouse_process_byte;
967 psmouse->pktsize = 3; 969 psmouse->pktsize = 3;
968 psmouse->reconnect = NULL; 970 psmouse->reconnect = NULL;
971 psmouse->fast_reconnect = NULL;
969 psmouse->disconnect = NULL; 972 psmouse->disconnect = NULL;
970 psmouse->cleanup = NULL; 973 psmouse->cleanup = NULL;
971 psmouse->pt_activate = NULL; 974 psmouse->pt_activate = NULL;
@@ -1018,6 +1021,7 @@ static int psmouse_extensions(struct psmouse *psmouse,
1018 unsigned int max_proto, bool set_properties) 1021 unsigned int max_proto, bool set_properties)
1019{ 1022{
1020 bool synaptics_hardware = false; 1023 bool synaptics_hardware = false;
1024 int ret;
1021 1025
1022 /* 1026 /*
1023 * Always check for focaltech, this is safe as it uses pnp-id 1027 * Always check for focaltech, this is safe as it uses pnp-id
@@ -1080,9 +1084,14 @@ static int psmouse_extensions(struct psmouse *psmouse,
1080 * enabled first, since we try detecting Synaptics 1084 * enabled first, since we try detecting Synaptics
1081 * even when protocol is disabled. 1085 * even when protocol is disabled.
1082 */ 1086 */
1083 if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) && 1087 if (IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS) ||
1084 (!set_properties || synaptics_init(psmouse) == 0)) { 1088 IS_ENABLED(CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS)) {
1085 return PSMOUSE_SYNAPTICS; 1089 if (!set_properties)
1090 return PSMOUSE_SYNAPTICS;
1091
1092 ret = synaptics_init(psmouse);
1093 if (ret >= 0)
1094 return ret;
1086 } 1095 }
1087 1096
1088 /* 1097 /*
@@ -1431,9 +1440,8 @@ static void psmouse_cleanup(struct serio *serio)
1431 */ 1440 */
1432static void psmouse_disconnect(struct serio *serio) 1441static void psmouse_disconnect(struct serio *serio)
1433{ 1442{
1434 struct psmouse *psmouse, *parent = NULL; 1443 struct psmouse *psmouse = serio_get_drvdata(serio);
1435 1444 struct psmouse *parent = NULL;
1436 psmouse = serio_get_drvdata(serio);
1437 1445
1438 sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group); 1446 sysfs_remove_group(&serio->dev.kobj, &psmouse_attribute_group);
1439 1447
@@ -1461,7 +1469,10 @@ static void psmouse_disconnect(struct serio *serio)
1461 1469
1462 serio_close(serio); 1470 serio_close(serio);
1463 serio_set_drvdata(serio, NULL); 1471 serio_set_drvdata(serio, NULL);
1464 input_unregister_device(psmouse->dev); 1472
1473 if (psmouse->dev)
1474 input_unregister_device(psmouse->dev);
1475
1465 kfree(psmouse); 1476 kfree(psmouse);
1466 1477
1467 if (parent) 1478 if (parent)
@@ -1475,6 +1486,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
1475{ 1486{
1476 const struct psmouse_protocol *selected_proto; 1487 const struct psmouse_protocol *selected_proto;
1477 struct input_dev *input_dev = psmouse->dev; 1488 struct input_dev *input_dev = psmouse->dev;
1489 enum psmouse_type type;
1478 1490
1479 input_dev->dev.parent = &psmouse->ps2dev.serio->dev; 1491 input_dev->dev.parent = &psmouse->ps2dev.serio->dev;
1480 1492
@@ -1487,15 +1499,13 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
1487 if (proto->init && proto->init(psmouse) < 0) 1499 if (proto->init && proto->init(psmouse) < 0)
1488 return -1; 1500 return -1;
1489 1501
1490 psmouse->type = proto->type;
1491 selected_proto = proto; 1502 selected_proto = proto;
1492 } else { 1503 } else {
1493 psmouse->type = psmouse_extensions(psmouse, 1504 type = psmouse_extensions(psmouse, psmouse_max_proto, true);
1494 psmouse_max_proto, true); 1505 selected_proto = psmouse_protocol_by_type(type);
1495 selected_proto = psmouse_protocol_by_type(psmouse->type);
1496 } 1506 }
1497 1507
1498 psmouse->ignore_parity = selected_proto->ignore_parity; 1508 psmouse->protocol = selected_proto;
1499 1509
1500 /* 1510 /*
1501 * If mouse's packet size is 3 there is no point in polling the 1511 * If mouse's packet size is 3 there is no point in polling the
@@ -1521,7 +1531,7 @@ static int psmouse_switch_protocol(struct psmouse *psmouse,
1521 input_dev->phys = psmouse->phys; 1531 input_dev->phys = psmouse->phys;
1522 input_dev->id.bustype = BUS_I8042; 1532 input_dev->id.bustype = BUS_I8042;
1523 input_dev->id.vendor = 0x0002; 1533 input_dev->id.vendor = 0x0002;
1524 input_dev->id.product = psmouse->type; 1534 input_dev->id.product = psmouse->protocol->type;
1525 input_dev->id.version = psmouse->model; 1535 input_dev->id.version = psmouse->model;
1526 1536
1527 return 0; 1537 return 0;
@@ -1583,12 +1593,18 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1583 1593
1584 psmouse_switch_protocol(psmouse, NULL); 1594 psmouse_switch_protocol(psmouse, NULL);
1585 1595
1586 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1596 if (!psmouse->protocol->smbus_companion) {
1587 psmouse_initialize(psmouse); 1597 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1598 psmouse_initialize(psmouse);
1588 1599
1589 error = input_register_device(psmouse->dev); 1600 error = input_register_device(input_dev);
1590 if (error) 1601 if (error)
1591 goto err_protocol_disconnect; 1602 goto err_protocol_disconnect;
1603 } else {
1604 /* Smbus companion will be reporting events, not us. */
1605 input_free_device(input_dev);
1606 psmouse->dev = input_dev = NULL;
1607 }
1592 1608
1593 if (parent && parent->pt_activate) 1609 if (parent && parent->pt_activate)
1594 parent->pt_activate(parent); 1610 parent->pt_activate(parent);
@@ -1597,7 +1613,12 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1597 if (error) 1613 if (error)
1598 goto err_pt_deactivate; 1614 goto err_pt_deactivate;
1599 1615
1600 psmouse_activate(psmouse); 1616 /*
1617 * PS/2 devices having SMBus companions should stay disabled
1618 * on PS/2 side, in order to have SMBus part operable.
1619 */
1620 if (!psmouse->protocol->smbus_companion)
1621 psmouse_activate(psmouse);
1601 1622
1602 out: 1623 out:
1603 /* If this is a pass-through port the parent needs to be re-activated */ 1624 /* If this is a pass-through port the parent needs to be re-activated */
@@ -1610,8 +1631,10 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1610 err_pt_deactivate: 1631 err_pt_deactivate:
1611 if (parent && parent->pt_deactivate) 1632 if (parent && parent->pt_deactivate)
1612 parent->pt_deactivate(parent); 1633 parent->pt_deactivate(parent);
1613 input_unregister_device(psmouse->dev); 1634 if (input_dev) {
1614 input_dev = NULL; /* so we don't try to free it below */ 1635 input_unregister_device(input_dev);
1636 input_dev = NULL; /* so we don't try to free it below */
1637 }
1615 err_protocol_disconnect: 1638 err_protocol_disconnect:
1616 if (psmouse->disconnect) 1639 if (psmouse->disconnect)
1617 psmouse->disconnect(psmouse); 1640 psmouse->disconnect(psmouse);
@@ -1628,15 +1651,26 @@ static int psmouse_connect(struct serio *serio, struct serio_driver *drv)
1628 goto out; 1651 goto out;
1629} 1652}
1630 1653
1631static int psmouse_reconnect(struct serio *serio) 1654static int __psmouse_reconnect(struct serio *serio, bool fast_reconnect)
1632{ 1655{
1633 struct psmouse *psmouse = serio_get_drvdata(serio); 1656 struct psmouse *psmouse = serio_get_drvdata(serio);
1634 struct psmouse *parent = NULL; 1657 struct psmouse *parent = NULL;
1635 unsigned char type; 1658 int (*reconnect_handler)(struct psmouse *);
1659 enum psmouse_type type;
1636 int rc = -1; 1660 int rc = -1;
1637 1661
1638 mutex_lock(&psmouse_mutex); 1662 mutex_lock(&psmouse_mutex);
1639 1663
1664 if (fast_reconnect) {
1665 reconnect_handler = psmouse->fast_reconnect;
1666 if (!reconnect_handler) {
1667 rc = -ENOENT;
1668 goto out_unlock;
1669 }
1670 } else {
1671 reconnect_handler = psmouse->reconnect;
1672 }
1673
1640 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) { 1674 if (serio->parent && serio->id.type == SERIO_PS_PSTHRU) {
1641 parent = serio_get_drvdata(serio->parent); 1675 parent = serio_get_drvdata(serio->parent);
1642 psmouse_deactivate(parent); 1676 psmouse_deactivate(parent);
@@ -1644,8 +1678,8 @@ static int psmouse_reconnect(struct serio *serio)
1644 1678
1645 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 1679 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1646 1680
1647 if (psmouse->reconnect) { 1681 if (reconnect_handler) {
1648 if (psmouse->reconnect(psmouse)) 1682 if (reconnect_handler(psmouse))
1649 goto out; 1683 goto out;
1650 } else { 1684 } else {
1651 psmouse_reset(psmouse); 1685 psmouse_reset(psmouse);
@@ -1654,7 +1688,7 @@ static int psmouse_reconnect(struct serio *serio)
1654 goto out; 1688 goto out;
1655 1689
1656 type = psmouse_extensions(psmouse, psmouse_max_proto, false); 1690 type = psmouse_extensions(psmouse, psmouse_max_proto, false);
1657 if (psmouse->type != type) 1691 if (psmouse->protocol->type != type)
1658 goto out; 1692 goto out;
1659 } 1693 }
1660 1694
@@ -1662,14 +1696,21 @@ static int psmouse_reconnect(struct serio *serio)
1662 * OK, the device type (and capabilities) match the old one, 1696 * OK, the device type (and capabilities) match the old one,
1663 * we can continue using it, complete initialization 1697 * we can continue using it, complete initialization
1664 */ 1698 */
1665 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1699 if (!psmouse->protocol->smbus_companion) {
1666 1700 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1667 psmouse_initialize(psmouse); 1701 psmouse_initialize(psmouse);
1702 }
1668 1703
1669 if (parent && parent->pt_activate) 1704 if (parent && parent->pt_activate)
1670 parent->pt_activate(parent); 1705 parent->pt_activate(parent);
1671 1706
1672 psmouse_activate(psmouse); 1707 /*
1708 * PS/2 devices having SMBus companions should stay disabled
1709 * on PS/2 side, in order to have SMBus part operable.
1710 */
1711 if (!psmouse->protocol->smbus_companion)
1712 psmouse_activate(psmouse);
1713
1673 rc = 0; 1714 rc = 0;
1674 1715
1675out: 1716out:
@@ -1677,10 +1718,21 @@ out:
1677 if (parent) 1718 if (parent)
1678 psmouse_activate(parent); 1719 psmouse_activate(parent);
1679 1720
1721out_unlock:
1680 mutex_unlock(&psmouse_mutex); 1722 mutex_unlock(&psmouse_mutex);
1681 return rc; 1723 return rc;
1682} 1724}
1683 1725
1726static int psmouse_reconnect(struct serio *serio)
1727{
1728 return __psmouse_reconnect(serio, false);
1729}
1730
1731static int psmouse_fast_reconnect(struct serio *serio)
1732{
1733 return __psmouse_reconnect(serio, true);
1734}
1735
1684static struct serio_device_id psmouse_serio_ids[] = { 1736static struct serio_device_id psmouse_serio_ids[] = {
1685 { 1737 {
1686 .type = SERIO_8042, 1738 .type = SERIO_8042,
@@ -1708,6 +1760,7 @@ static struct serio_driver psmouse_drv = {
1708 .interrupt = psmouse_interrupt, 1760 .interrupt = psmouse_interrupt,
1709 .connect = psmouse_connect, 1761 .connect = psmouse_connect,
1710 .reconnect = psmouse_reconnect, 1762 .reconnect = psmouse_reconnect,
1763 .fast_reconnect = psmouse_fast_reconnect,
1711 .disconnect = psmouse_disconnect, 1764 .disconnect = psmouse_disconnect,
1712 .cleanup = psmouse_cleanup, 1765 .cleanup = psmouse_cleanup,
1713}; 1766};
@@ -1717,9 +1770,11 @@ ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *de
1717{ 1770{
1718 struct serio *serio = to_serio_port(dev); 1771 struct serio *serio = to_serio_port(dev);
1719 struct psmouse_attribute *attr = to_psmouse_attr(devattr); 1772 struct psmouse_attribute *attr = to_psmouse_attr(devattr);
1720 struct psmouse *psmouse; 1773 struct psmouse *psmouse = serio_get_drvdata(serio);
1721 1774
1722 psmouse = serio_get_drvdata(serio); 1775 if (psmouse->protocol->smbus_companion &&
1776 devattr != &psmouse_attr_protocol.dattr)
1777 return -ENOENT;
1723 1778
1724 return attr->show(psmouse, attr->data, buf); 1779 return attr->show(psmouse, attr->data, buf);
1725} 1780}
@@ -1738,6 +1793,12 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
1738 1793
1739 psmouse = serio_get_drvdata(serio); 1794 psmouse = serio_get_drvdata(serio);
1740 1795
1796 if (psmouse->protocol->smbus_companion &&
1797 devattr != &psmouse_attr_protocol.dattr) {
1798 retval = -ENOENT;
1799 goto out_unlock;
1800 }
1801
1741 if (attr->protect) { 1802 if (attr->protect) {
1742 if (psmouse->state == PSMOUSE_IGNORE) { 1803 if (psmouse->state == PSMOUSE_IGNORE) {
1743 retval = -ENODEV; 1804 retval = -ENODEV;
@@ -1749,13 +1810,14 @@ ssize_t psmouse_attr_set_helper(struct device *dev, struct device_attribute *dev
1749 psmouse_deactivate(parent); 1810 psmouse_deactivate(parent);
1750 } 1811 }
1751 1812
1752 psmouse_deactivate(psmouse); 1813 if (!psmouse->protocol->smbus_companion)
1814 psmouse_deactivate(psmouse);
1753 } 1815 }
1754 1816
1755 retval = attr->set(psmouse, attr->data, buf, count); 1817 retval = attr->set(psmouse, attr->data, buf, count);
1756 1818
1757 if (attr->protect) { 1819 if (attr->protect) {
1758 if (retval != -ENODEV) 1820 if (retval != -ENODEV && !psmouse->protocol->smbus_companion)
1759 psmouse_activate(psmouse); 1821 psmouse_activate(psmouse);
1760 1822
1761 if (parent) 1823 if (parent)
@@ -1792,7 +1854,7 @@ static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const
1792 1854
1793static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf) 1855static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf)
1794{ 1856{
1795 return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name); 1857 return sprintf(buf, "%s\n", psmouse->protocol->name);
1796} 1858}
1797 1859
1798static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1860static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, const char *buf, size_t count)
@@ -1808,7 +1870,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1808 if (!proto) 1870 if (!proto)
1809 return -EINVAL; 1871 return -EINVAL;
1810 1872
1811 if (psmouse->type == proto->type) 1873 if (psmouse->protocol == proto)
1812 return count; 1874 return count;
1813 1875
1814 new_dev = input_allocate_device(); 1876 new_dev = input_allocate_device();
@@ -1832,7 +1894,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1832 return -ENODEV; 1894 return -ENODEV;
1833 } 1895 }
1834 1896
1835 if (psmouse->type == proto->type) { 1897 if (psmouse->protocol == proto) {
1836 input_free_device(new_dev); 1898 input_free_device(new_dev);
1837 return count; /* switched by other thread */ 1899 return count; /* switched by other thread */
1838 } 1900 }
@@ -1845,7 +1907,7 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1845 } 1907 }
1846 1908
1847 old_dev = psmouse->dev; 1909 old_dev = psmouse->dev;
1848 old_proto = psmouse_protocol_by_type(psmouse->type); 1910 old_proto = psmouse->protocol;
1849 1911
1850 if (psmouse->disconnect) 1912 if (psmouse->disconnect)
1851 psmouse->disconnect(psmouse); 1913 psmouse->disconnect(psmouse);
@@ -1864,23 +1926,29 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
1864 psmouse_initialize(psmouse); 1926 psmouse_initialize(psmouse);
1865 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1927 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1866 1928
1867 error = input_register_device(psmouse->dev); 1929 if (psmouse->protocol->smbus_companion) {
1868 if (error) { 1930 input_free_device(psmouse->dev);
1869 if (psmouse->disconnect) 1931 psmouse->dev = NULL;
1870 psmouse->disconnect(psmouse); 1932 } else {
1933 error = input_register_device(psmouse->dev);
1934 if (error) {
1935 if (psmouse->disconnect)
1936 psmouse->disconnect(psmouse);
1871 1937
1872 psmouse_set_state(psmouse, PSMOUSE_IGNORE); 1938 psmouse_set_state(psmouse, PSMOUSE_IGNORE);
1873 input_free_device(new_dev); 1939 input_free_device(new_dev);
1874 psmouse->dev = old_dev; 1940 psmouse->dev = old_dev;
1875 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING); 1941 psmouse_set_state(psmouse, PSMOUSE_INITIALIZING);
1876 psmouse_switch_protocol(psmouse, old_proto); 1942 psmouse_switch_protocol(psmouse, old_proto);
1877 psmouse_initialize(psmouse); 1943 psmouse_initialize(psmouse);
1878 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1944 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
1879 1945
1880 return error; 1946 return error;
1947 }
1881 } 1948 }
1882 1949
1883 input_unregister_device(old_dev); 1950 if (old_dev)
1951 input_unregister_device(old_dev);
1884 1952
1885 if (parent && parent->pt_activate) 1953 if (parent && parent->pt_activate)
1886 parent->pt_activate(parent); 1954 parent->pt_activate(parent);
@@ -1947,16 +2015,27 @@ static int __init psmouse_init(void)
1947 synaptics_module_init(); 2015 synaptics_module_init();
1948 hgpk_module_init(); 2016 hgpk_module_init();
1949 2017
2018 err = psmouse_smbus_module_init();
2019 if (err)
2020 return err;
2021
1950 kpsmoused_wq = alloc_ordered_workqueue("kpsmoused", 0); 2022 kpsmoused_wq = alloc_ordered_workqueue("kpsmoused", 0);
1951 if (!kpsmoused_wq) { 2023 if (!kpsmoused_wq) {
1952 pr_err("failed to create kpsmoused workqueue\n"); 2024 pr_err("failed to create kpsmoused workqueue\n");
1953 return -ENOMEM; 2025 err = -ENOMEM;
2026 goto err_smbus_exit;
1954 } 2027 }
1955 2028
1956 err = serio_register_driver(&psmouse_drv); 2029 err = serio_register_driver(&psmouse_drv);
1957 if (err) 2030 if (err)
1958 destroy_workqueue(kpsmoused_wq); 2031 goto err_destroy_wq;
2032
2033 return 0;
1959 2034
2035err_destroy_wq:
2036 destroy_workqueue(kpsmoused_wq);
2037err_smbus_exit:
2038 psmouse_smbus_module_exit();
1960 return err; 2039 return err;
1961} 2040}
1962 2041
@@ -1964,6 +2043,7 @@ static void __exit psmouse_exit(void)
1964{ 2043{
1965 serio_unregister_driver(&psmouse_drv); 2044 serio_unregister_driver(&psmouse_drv);
1966 destroy_workqueue(kpsmoused_wq); 2045 destroy_workqueue(kpsmoused_wq);
2046 psmouse_smbus_module_exit();
1967} 2047}
1968 2048
1969module_init(psmouse_init); 2049module_init(psmouse_init);
diff --git a/drivers/input/mouse/psmouse-smbus.c b/drivers/input/mouse/psmouse-smbus.c
new file mode 100644
index 000000000000..c7ac24d119c1
--- /dev/null
+++ b/drivers/input/mouse/psmouse-smbus.c
@@ -0,0 +1,302 @@
1/*
2 * Copyright (c) 2017 Red Hat, Inc
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published by
6 * the Free Software Foundation.
7 */
8
9#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/libps2.h>
14#include <linux/i2c.h>
15#include <linux/serio.h>
16#include <linux/slab.h>
17#include <linux/workqueue.h>
18#include "psmouse.h"
19
20struct psmouse_smbus_dev {
21 struct i2c_board_info board;
22 struct psmouse *psmouse;
23 struct i2c_client *client;
24 struct list_head node;
25 bool dead;
26};
27
28static LIST_HEAD(psmouse_smbus_list);
29static DEFINE_MUTEX(psmouse_smbus_mutex);
30
31static void psmouse_smbus_check_adapter(struct i2c_adapter *adapter)
32{
33 struct psmouse_smbus_dev *smbdev;
34
35 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HOST_NOTIFY))
36 return;
37
38 mutex_lock(&psmouse_smbus_mutex);
39
40 list_for_each_entry(smbdev, &psmouse_smbus_list, node) {
41 if (smbdev->dead)
42 continue;
43
44 if (smbdev->client)
45 continue;
46
47 /*
48 * Here would be a good place to check if device is actually
49 * present, but it seems that SMBus will not respond unless we
50 * fully reset PS/2 connection. So cross our fingers, and try
51 * to switch over, hopefully our system will not have too many
52 * "host notify" I2C adapters.
53 */
54 psmouse_dbg(smbdev->psmouse,
55 "SMBus candidate adapter appeared, triggering rescan\n");
56 serio_rescan(smbdev->psmouse->ps2dev.serio);
57 }
58
59 mutex_unlock(&psmouse_smbus_mutex);
60}
61
62static void psmouse_smbus_detach_i2c_client(struct i2c_client *client)
63{
64 struct psmouse_smbus_dev *smbdev, *tmp;
65
66 mutex_lock(&psmouse_smbus_mutex);
67
68 list_for_each_entry_safe(smbdev, tmp, &psmouse_smbus_list, node) {
69 if (smbdev->client != client)
70 continue;
71
72 kfree(client->dev.platform_data);
73 client->dev.platform_data = NULL;
74
75 if (!smbdev->dead) {
76 psmouse_dbg(smbdev->psmouse,
77 "Marking SMBus companion %s as gone\n",
78 dev_name(&smbdev->client->dev));
79 smbdev->dead = true;
80 serio_rescan(smbdev->psmouse->ps2dev.serio);
81 } else {
82 list_del(&smbdev->node);
83 kfree(smbdev);
84 }
85 }
86
87 mutex_unlock(&psmouse_smbus_mutex);
88}
89
90static int psmouse_smbus_notifier_call(struct notifier_block *nb,
91 unsigned long action, void *data)
92{
93 struct device *dev = data;
94
95 switch (action) {
96 case BUS_NOTIFY_ADD_DEVICE:
97 if (dev->type == &i2c_adapter_type)
98 psmouse_smbus_check_adapter(to_i2c_adapter(dev));
99 break;
100
101 case BUS_NOTIFY_REMOVED_DEVICE:
102 if (dev->type == &i2c_client_type)
103 psmouse_smbus_detach_i2c_client(to_i2c_client(dev));
104 break;
105 }
106
107 return 0;
108}
109
110static struct notifier_block psmouse_smbus_notifier = {
111 .notifier_call = psmouse_smbus_notifier_call,
112};
113
114static psmouse_ret_t psmouse_smbus_process_byte(struct psmouse *psmouse)
115{
116 return PSMOUSE_FULL_PACKET;
117}
118
119static int psmouse_smbus_reconnect(struct psmouse *psmouse)
120{
121 psmouse_deactivate(psmouse);
122
123 return 0;
124}
125
126struct psmouse_smbus_removal_work {
127 struct work_struct work;
128 struct i2c_client *client;
129};
130
131static void psmouse_smbus_remove_i2c_device(struct work_struct *work)
132{
133 struct psmouse_smbus_removal_work *rwork =
134 container_of(work, struct psmouse_smbus_removal_work, work);
135
136 dev_dbg(&rwork->client->dev, "destroying SMBus companion device\n");
137 i2c_unregister_device(rwork->client);
138
139 kfree(rwork);
140}
141
142/*
143 * This schedules removal of SMBus companion device. We have to do
144 * it in a separate tread to avoid deadlocking on psmouse_mutex in
145 * case the device has a trackstick (which is also driven by psmouse).
146 *
147 * Note that this may be racing with i2c adapter removal, but we
148 * can't do anything about that: i2c automatically destroys clients
149 * attached to an adapter that is being removed. This has to be
150 * fixed in i2c core.
151 */
152static void psmouse_smbus_schedule_remove(struct i2c_client *client)
153{
154 struct psmouse_smbus_removal_work *rwork;
155
156 rwork = kzalloc(sizeof(*rwork), GFP_KERNEL);
157 if (rwork) {
158 INIT_WORK(&rwork->work, psmouse_smbus_remove_i2c_device);
159 rwork->client = client;
160
161 schedule_work(&rwork->work);
162 }
163}
164
165static void psmouse_smbus_disconnect(struct psmouse *psmouse)
166{
167 struct psmouse_smbus_dev *smbdev = psmouse->private;
168
169 mutex_lock(&psmouse_smbus_mutex);
170
171 if (smbdev->dead) {
172 list_del(&smbdev->node);
173 kfree(smbdev);
174 } else {
175 smbdev->dead = true;
176 psmouse_dbg(smbdev->psmouse,
177 "posting removal request for SMBus companion %s\n",
178 dev_name(&smbdev->client->dev));
179 psmouse_smbus_schedule_remove(smbdev->client);
180 }
181
182 mutex_unlock(&psmouse_smbus_mutex);
183
184 psmouse->private = NULL;
185}
186
187static int psmouse_smbus_create_companion(struct device *dev, void *data)
188{
189 struct psmouse_smbus_dev *smbdev = data;
190 unsigned short addr_list[] = { smbdev->board.addr, I2C_CLIENT_END };
191 struct i2c_adapter *adapter;
192
193 adapter = i2c_verify_adapter(dev);
194 if (!adapter)
195 return 0;
196
197 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_HOST_NOTIFY))
198 return 0;
199
200 smbdev->client = i2c_new_probed_device(adapter, &smbdev->board,
201 addr_list, NULL);
202 if (!smbdev->client)
203 return 0;
204
205 /* We have our(?) device, stop iterating i2c bus. */
206 return 1;
207}
208
209void psmouse_smbus_cleanup(struct psmouse *psmouse)
210{
211 struct psmouse_smbus_dev *smbdev, *tmp;
212
213 mutex_lock(&psmouse_smbus_mutex);
214
215 list_for_each_entry_safe(smbdev, tmp, &psmouse_smbus_list, node) {
216 if (psmouse == smbdev->psmouse) {
217 list_del(&smbdev->node);
218 kfree(smbdev);
219 }
220 }
221
222 mutex_unlock(&psmouse_smbus_mutex);
223}
224
225int psmouse_smbus_init(struct psmouse *psmouse,
226 const struct i2c_board_info *board,
227 const void *pdata, size_t pdata_size,
228 bool leave_breadcrumbs)
229{
230 struct psmouse_smbus_dev *smbdev;
231 int error;
232
233 smbdev = kzalloc(sizeof(*smbdev), GFP_KERNEL);
234 if (!smbdev)
235 return -ENOMEM;
236
237 smbdev->psmouse = psmouse;
238 smbdev->board = *board;
239
240 smbdev->board.platform_data = kmemdup(pdata, pdata_size, GFP_KERNEL);
241 if (!smbdev->board.platform_data) {
242 kfree(smbdev);
243 return -ENOMEM;
244 }
245
246 psmouse->private = smbdev;
247 psmouse->protocol_handler = psmouse_smbus_process_byte;
248 psmouse->reconnect = psmouse_smbus_reconnect;
249 psmouse->fast_reconnect = psmouse_smbus_reconnect;
250 psmouse->disconnect = psmouse_smbus_disconnect;
251 psmouse->resync_time = 0;
252
253 psmouse_deactivate(psmouse);
254
255 mutex_lock(&psmouse_smbus_mutex);
256 list_add_tail(&smbdev->node, &psmouse_smbus_list);
257 mutex_unlock(&psmouse_smbus_mutex);
258
259 /* Bind to already existing adapters right away */
260 error = i2c_for_each_dev(smbdev, psmouse_smbus_create_companion);
261
262 if (smbdev->client) {
263 /* We have our companion device */
264 return 0;
265 }
266
267 /*
268 * If we did not create i2c device we will not need platform
269 * data even if we are leaving breadcrumbs.
270 */
271 kfree(smbdev->board.platform_data);
272 smbdev->board.platform_data = NULL;
273
274 if (error < 0 || !leave_breadcrumbs) {
275 mutex_lock(&psmouse_smbus_mutex);
276 list_del(&smbdev->node);
277 mutex_unlock(&psmouse_smbus_mutex);
278
279 kfree(smbdev);
280 }
281
282 return error < 0 ? error : -EAGAIN;
283}
284
285int __init psmouse_smbus_module_init(void)
286{
287 int error;
288
289 error = bus_register_notifier(&i2c_bus_type, &psmouse_smbus_notifier);
290 if (error) {
291 pr_err("failed to register i2c bus notifier: %d\n", error);
292 return error;
293 }
294
295 return 0;
296}
297
298void psmouse_smbus_module_exit(void)
299{
300 bus_unregister_notifier(&i2c_bus_type, &psmouse_smbus_notifier);
301 flush_scheduled_work();
302}
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index 8c83b8e2505c..38855e425f01 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -44,21 +44,60 @@ enum psmouse_scale {
44 PSMOUSE_SCALE21 44 PSMOUSE_SCALE21
45}; 45};
46 46
47enum psmouse_type {
48 PSMOUSE_NONE,
49 PSMOUSE_PS2,
50 PSMOUSE_PS2PP,
51 PSMOUSE_THINKPS,
52 PSMOUSE_GENPS,
53 PSMOUSE_IMPS,
54 PSMOUSE_IMEX,
55 PSMOUSE_SYNAPTICS,
56 PSMOUSE_ALPS,
57 PSMOUSE_LIFEBOOK,
58 PSMOUSE_TRACKPOINT,
59 PSMOUSE_TOUCHKIT_PS2,
60 PSMOUSE_CORTRON,
61 PSMOUSE_HGPK,
62 PSMOUSE_ELANTECH,
63 PSMOUSE_FSP,
64 PSMOUSE_SYNAPTICS_RELATIVE,
65 PSMOUSE_CYPRESS,
66 PSMOUSE_FOCALTECH,
67 PSMOUSE_VMMOUSE,
68 PSMOUSE_BYD,
69 PSMOUSE_SYNAPTICS_SMBUS,
70 PSMOUSE_AUTO /* This one should always be last */
71};
72
73struct psmouse;
74
75struct psmouse_protocol {
76 enum psmouse_type type;
77 bool maxproto;
78 bool ignore_parity; /* Protocol should ignore parity errors from KBC */
79 bool try_passthru; /* Try protocol also on passthrough ports */
80 bool smbus_companion; /* "Protocol" is a stub, device is on SMBus */
81 const char *name;
82 const char *alias;
83 int (*detect)(struct psmouse *, bool);
84 int (*init)(struct psmouse *);
85};
86
47struct psmouse { 87struct psmouse {
48 void *private; 88 void *private;
49 struct input_dev *dev; 89 struct input_dev *dev;
50 struct ps2dev ps2dev; 90 struct ps2dev ps2dev;
51 struct delayed_work resync_work; 91 struct delayed_work resync_work;
52 char *vendor; 92 const char *vendor;
53 char *name; 93 const char *name;
94 const struct psmouse_protocol *protocol;
54 unsigned char packet[8]; 95 unsigned char packet[8];
55 unsigned char badbyte; 96 unsigned char badbyte;
56 unsigned char pktcnt; 97 unsigned char pktcnt;
57 unsigned char pktsize; 98 unsigned char pktsize;
58 unsigned char type;
59 unsigned char oob_data_type; 99 unsigned char oob_data_type;
60 unsigned char extra_buttons; 100 unsigned char extra_buttons;
61 bool ignore_parity;
62 bool acks_disable_command; 101 bool acks_disable_command;
63 unsigned int model; 102 unsigned int model;
64 unsigned long last; 103 unsigned long last;
@@ -80,6 +119,7 @@ struct psmouse {
80 void (*set_scale)(struct psmouse *psmouse, enum psmouse_scale scale); 119 void (*set_scale)(struct psmouse *psmouse, enum psmouse_scale scale);
81 120
82 int (*reconnect)(struct psmouse *psmouse); 121 int (*reconnect)(struct psmouse *psmouse);
122 int (*fast_reconnect)(struct psmouse *psmouse);
83 void (*disconnect)(struct psmouse *psmouse); 123 void (*disconnect)(struct psmouse *psmouse);
84 void (*cleanup)(struct psmouse *psmouse); 124 void (*cleanup)(struct psmouse *psmouse);
85 int (*poll)(struct psmouse *psmouse); 125 int (*poll)(struct psmouse *psmouse);
@@ -88,31 +128,6 @@ struct psmouse {
88 void (*pt_deactivate)(struct psmouse *psmouse); 128 void (*pt_deactivate)(struct psmouse *psmouse);
89}; 129};
90 130
91enum psmouse_type {
92 PSMOUSE_NONE,
93 PSMOUSE_PS2,
94 PSMOUSE_PS2PP,
95 PSMOUSE_THINKPS,
96 PSMOUSE_GENPS,
97 PSMOUSE_IMPS,
98 PSMOUSE_IMEX,
99 PSMOUSE_SYNAPTICS,
100 PSMOUSE_ALPS,
101 PSMOUSE_LIFEBOOK,
102 PSMOUSE_TRACKPOINT,
103 PSMOUSE_TOUCHKIT_PS2,
104 PSMOUSE_CORTRON,
105 PSMOUSE_HGPK,
106 PSMOUSE_ELANTECH,
107 PSMOUSE_FSP,
108 PSMOUSE_SYNAPTICS_RELATIVE,
109 PSMOUSE_CYPRESS,
110 PSMOUSE_FOCALTECH,
111 PSMOUSE_VMMOUSE,
112 PSMOUSE_BYD,
113 PSMOUSE_AUTO /* This one should always be last */
114};
115
116void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work, 131void psmouse_queue_work(struct psmouse *psmouse, struct delayed_work *work,
117 unsigned long delay); 132 unsigned long delay);
118int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command); 133int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
@@ -195,5 +210,34 @@ static struct psmouse_attribute psmouse_attr_##_name = { \
195 &(psmouse)->ps2dev.serio->dev, \ 210 &(psmouse)->ps2dev.serio->dev, \
196 psmouse_fmt(format), ##__VA_ARGS__) 211 psmouse_fmt(format), ##__VA_ARGS__)
197 212
213#ifdef CONFIG_MOUSE_PS2_SMBUS
214
215int psmouse_smbus_module_init(void);
216void psmouse_smbus_module_exit(void);
217
218struct i2c_board_info;
219
220int psmouse_smbus_init(struct psmouse *psmouse,
221 const struct i2c_board_info *board,
222 const void *pdata, size_t pdata_size,
223 bool leave_breadcrumbs);
224void psmouse_smbus_cleanup(struct psmouse *psmouse);
225
226#else /* !CONFIG_MOUSE_PS2_SMBUS */
227
228static inline int psmouse_smbus_module_init(void)
229{
230 return 0;
231}
232
233static inline void psmouse_smbus_module_exit(void)
234{
235}
236
237static inline void psmouse_smbus_cleanup(struct psmouse *psmouse)
238{
239}
240
241#endif /* CONFIG_MOUSE_PS2_SMBUS */
198 242
199#endif /* _PSMOUSE_H */ 243#endif /* _PSMOUSE_H */
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 597ee4b01d9f..131df9d3660f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -29,6 +29,8 @@
29#include <linux/input/mt.h> 29#include <linux/input/mt.h>
30#include <linux/serio.h> 30#include <linux/serio.h>
31#include <linux/libps2.h> 31#include <linux/libps2.h>
32#include <linux/rmi.h>
33#include <linux/i2c.h>
32#include <linux/slab.h> 34#include <linux/slab.h>
33#include "psmouse.h" 35#include "psmouse.h"
34#include "synaptics.h" 36#include "synaptics.h"
@@ -77,22 +79,27 @@
77/* 79/*
78 * Set the synaptics touchpad mode byte by special commands 80 * Set the synaptics touchpad mode byte by special commands
79 */ 81 */
80static int synaptics_mode_cmd(struct psmouse *psmouse, unsigned char mode) 82static int synaptics_mode_cmd(struct psmouse *psmouse, u8 mode)
81{ 83{
82 unsigned char param[1]; 84 u8 param[1];
85 int error;
86
87 error = psmouse_sliced_command(psmouse, mode);
88 if (error)
89 return error;
83 90
84 if (psmouse_sliced_command(psmouse, mode))
85 return -1;
86 param[0] = SYN_PS_SET_MODE2; 91 param[0] = SYN_PS_SET_MODE2;
87 if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE)) 92 error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE);
88 return -1; 93 if (error)
94 return error;
95
89 return 0; 96 return 0;
90} 97}
91 98
92int synaptics_detect(struct psmouse *psmouse, bool set_properties) 99int synaptics_detect(struct psmouse *psmouse, bool set_properties)
93{ 100{
94 struct ps2dev *ps2dev = &psmouse->ps2dev; 101 struct ps2dev *ps2dev = &psmouse->ps2dev;
95 unsigned char param[4]; 102 u8 param[4];
96 103
97 param[0] = 0; 104 param[0] = 0;
98 105
@@ -119,59 +126,8 @@ void synaptics_reset(struct psmouse *psmouse)
119 synaptics_mode_cmd(psmouse, 0); 126 synaptics_mode_cmd(psmouse, 0);
120} 127}
121 128
122#ifdef CONFIG_MOUSE_PS2_SYNAPTICS 129#if defined(CONFIG_MOUSE_PS2_SYNAPTICS) || \
123 130 defined(CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS)
124static bool cr48_profile_sensor;
125
126#define ANY_BOARD_ID 0
127struct min_max_quirk {
128 const char * const *pnp_ids;
129 struct {
130 unsigned long int min, max;
131 } board_id;
132 int x_min, x_max, y_min, y_max;
133};
134
135static const struct min_max_quirk min_max_pnpid_table[] = {
136 {
137 (const char * const []){"LEN0033", NULL},
138 {ANY_BOARD_ID, ANY_BOARD_ID},
139 1024, 5052, 2258, 4832
140 },
141 {
142 (const char * const []){"LEN0042", NULL},
143 {ANY_BOARD_ID, ANY_BOARD_ID},
144 1232, 5710, 1156, 4696
145 },
146 {
147 (const char * const []){"LEN0034", "LEN0036", "LEN0037",
148 "LEN0039", "LEN2002", "LEN2004",
149 NULL},
150 {ANY_BOARD_ID, 2961},
151 1024, 5112, 2024, 4832
152 },
153 {
154 (const char * const []){"LEN2000", NULL},
155 {ANY_BOARD_ID, ANY_BOARD_ID},
156 1024, 5113, 2021, 4832
157 },
158 {
159 (const char * const []){"LEN2001", NULL},
160 {ANY_BOARD_ID, ANY_BOARD_ID},
161 1024, 5022, 2508, 4832
162 },
163 {
164 (const char * const []){"LEN2006", NULL},
165 {2691, 2691},
166 1024, 5045, 2457, 4832
167 },
168 {
169 (const char * const []){"LEN2006", NULL},
170 {ANY_BOARD_ID, ANY_BOARD_ID},
171 1264, 5675, 1171, 4688
172 },
173 { }
174};
175 131
176/* This list has been kindly provided by Synaptics. */ 132/* This list has been kindly provided by Synaptics. */
177static const char * const topbuttonpad_pnp_ids[] = { 133static const char * const topbuttonpad_pnp_ids[] = {
@@ -211,101 +167,109 @@ static const char * const topbuttonpad_pnp_ids[] = {
211 NULL 167 NULL
212}; 168};
213 169
214/* This list has been kindly provided by Synaptics. */ 170static const char * const smbus_pnp_ids[] = {
215static const char * const forcepad_pnp_ids[] = { 171 /* all of the topbuttonpad_pnp_ids are valid, we just add some extras */
216 "SYN300D", 172 "LEN0048", /* X1 Carbon 3 */
217 "SYN3014", 173 "LEN0046", /* X250 */
174 "LEN004a", /* W541 */
175 "LEN200f", /* T450s */
218 NULL 176 NULL
219}; 177};
220 178
221/*****************************************************************************
222 * Synaptics communications functions
223 ****************************************************************************/
224
225/* 179/*
226 * Synaptics touchpads report the y coordinate from bottom to top, which is 180 * Send a command to the synpatics touchpad by special commands
227 * opposite from what userspace expects.
228 * This function is used to invert y before reporting.
229 */ 181 */
230static int synaptics_invert_y(int y) 182static int synaptics_send_cmd(struct psmouse *psmouse, u8 cmd, u8 *param)
231{ 183{
232 return YMAX_NOMINAL + YMIN_NOMINAL - y; 184 int error;
185
186 error = psmouse_sliced_command(psmouse, cmd);
187 if (error)
188 return error;
189
190 error = ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO);
191 if (error)
192 return error;
193
194 return 0;
195}
196
197static int synaptics_query_int(struct psmouse *psmouse, u8 query_cmd, u32 *val)
198{
199 int error;
200 union {
201 __be32 be_val;
202 char buf[4];
203 } resp = { 0 };
204
205 error = synaptics_send_cmd(psmouse, query_cmd, resp.buf + 1);
206 if (error)
207 return error;
208
209 *val = be32_to_cpu(resp.be_val);
210 return 0;
233} 211}
234 212
235/* 213/*
236 * Send a command to the synpatics touchpad by special commands 214 * Identify Touchpad
215 * See also the SYN_ID_* macros
237 */ 216 */
238static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c, unsigned char *param) 217static int synaptics_identify(struct psmouse *psmouse,
218 struct synaptics_device_info *info)
239{ 219{
240 if (psmouse_sliced_command(psmouse, c)) 220 int error;
241 return -1; 221
242 if (ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) 222 error = synaptics_query_int(psmouse, SYN_QUE_IDENTIFY, &info->identity);
243 return -1; 223 if (error)
244 return 0; 224 return error;
225
226 return SYN_ID_IS_SYNAPTICS(info->identity) ? 0 : -ENXIO;
245} 227}
246 228
247/* 229/*
248 * Read the model-id bytes from the touchpad 230 * Read the model-id bytes from the touchpad
249 * see also SYN_MODEL_* macros 231 * see also SYN_MODEL_* macros
250 */ 232 */
251static int synaptics_model_id(struct psmouse *psmouse) 233static int synaptics_model_id(struct psmouse *psmouse,
234 struct synaptics_device_info *info)
252{ 235{
253 struct synaptics_data *priv = psmouse->private; 236 return synaptics_query_int(psmouse, SYN_QUE_MODEL, &info->model_id);
254 unsigned char mi[3];
255
256 if (synaptics_send_cmd(psmouse, SYN_QUE_MODEL, mi))
257 return -1;
258 priv->model_id = (mi[0]<<16) | (mi[1]<<8) | mi[2];
259 return 0;
260} 237}
261 238
262static int synaptics_more_extended_queries(struct psmouse *psmouse) 239/*
240 * Read the firmware id from the touchpad
241 */
242static int synaptics_firmware_id(struct psmouse *psmouse,
243 struct synaptics_device_info *info)
263{ 244{
264 struct synaptics_data *priv = psmouse->private; 245 return synaptics_query_int(psmouse, SYN_QUE_FIRMWARE_ID,
265 unsigned char buf[3]; 246 &info->firmware_id);
266
267 if (synaptics_send_cmd(psmouse, SYN_QUE_MEXT_CAPAB_10, buf))
268 return -1;
269
270 priv->ext_cap_10 = (buf[0]<<16) | (buf[1]<<8) | buf[2];
271
272 return 0;
273} 247}
274 248
275/* 249/*
276 * Read the board id and the "More Extended Queries" from the touchpad 250 * Read the board id and the "More Extended Queries" from the touchpad
277 * The board id is encoded in the "QUERY MODES" response 251 * The board id is encoded in the "QUERY MODES" response
278 */ 252 */
279static int synaptics_query_modes(struct psmouse *psmouse) 253static int synaptics_query_modes(struct psmouse *psmouse,
254 struct synaptics_device_info *info)
280{ 255{
281 struct synaptics_data *priv = psmouse->private; 256 u8 bid[3];
282 unsigned char bid[3]; 257 int error;
283 258
284 /* firmwares prior 7.5 have no board_id encoded */ 259 /* firmwares prior 7.5 have no board_id encoded */
285 if (SYN_ID_FULL(priv->identity) < 0x705) 260 if (SYN_ID_FULL(info->identity) < 0x705)
286 return 0; 261 return 0;
287 262
288 if (synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid)) 263 error = synaptics_send_cmd(psmouse, SYN_QUE_MODES, bid);
289 return -1; 264 if (error)
290 priv->board_id = ((bid[0] & 0xfc) << 6) | bid[1]; 265 return error;
291
292 if (SYN_MEXT_CAP_BIT(bid[0]))
293 return synaptics_more_extended_queries(psmouse);
294 266
295 return 0; 267 info->board_id = ((bid[0] & 0xfc) << 6) | bid[1];
296}
297 268
298/* 269 if (SYN_MEXT_CAP_BIT(bid[0]))
299 * Read the firmware id from the touchpad 270 return synaptics_query_int(psmouse, SYN_QUE_MEXT_CAPAB_10,
300 */ 271 &info->ext_cap_10);
301static int synaptics_firmware_id(struct psmouse *psmouse)
302{
303 struct synaptics_data *priv = psmouse->private;
304 unsigned char fwid[3];
305 272
306 if (synaptics_send_cmd(psmouse, SYN_QUE_FIRMWARE_ID, fwid))
307 return -1;
308 priv->firmware_id = (fwid[0] << 16) | (fwid[1] << 8) | fwid[2];
309 return 0; 273 return 0;
310} 274}
311 275
@@ -313,139 +277,236 @@ static int synaptics_firmware_id(struct psmouse *psmouse)
313 * Read the capability-bits from the touchpad 277 * Read the capability-bits from the touchpad
314 * see also the SYN_CAP_* macros 278 * see also the SYN_CAP_* macros
315 */ 279 */
316static int synaptics_capability(struct psmouse *psmouse) 280static int synaptics_capability(struct psmouse *psmouse,
281 struct synaptics_device_info *info)
317{ 282{
318 struct synaptics_data *priv = psmouse->private; 283 int error;
319 unsigned char cap[3];
320 284
321 if (synaptics_send_cmd(psmouse, SYN_QUE_CAPABILITIES, cap)) 285 error = synaptics_query_int(psmouse, SYN_QUE_CAPABILITIES,
322 return -1; 286 &info->capabilities);
323 priv->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2]; 287 if (error)
324 priv->ext_cap = priv->ext_cap_0c = 0; 288 return error;
289
290 info->ext_cap = info->ext_cap_0c = 0;
325 291
326 /* 292 /*
327 * Older firmwares had submodel ID fixed to 0x47 293 * Older firmwares had submodel ID fixed to 0x47
328 */ 294 */
329 if (SYN_ID_FULL(priv->identity) < 0x705 && 295 if (SYN_ID_FULL(info->identity) < 0x705 &&
330 SYN_CAP_SUBMODEL_ID(priv->capabilities) != 0x47) { 296 SYN_CAP_SUBMODEL_ID(info->capabilities) != 0x47) {
331 return -1; 297 return -ENXIO;
332 } 298 }
333 299
334 /* 300 /*
335 * Unless capExtended is set the rest of the flags should be ignored 301 * Unless capExtended is set the rest of the flags should be ignored
336 */ 302 */
337 if (!SYN_CAP_EXTENDED(priv->capabilities)) 303 if (!SYN_CAP_EXTENDED(info->capabilities))
338 priv->capabilities = 0; 304 info->capabilities = 0;
339 305
340 if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 1) { 306 if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 1) {
341 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB, cap)) { 307 error = synaptics_query_int(psmouse, SYN_QUE_EXT_CAPAB,
308 &info->ext_cap);
309 if (error) {
342 psmouse_warn(psmouse, 310 psmouse_warn(psmouse,
343 "device claims to have extended capabilities, but I'm not able to read them.\n"); 311 "device claims to have extended capabilities, but I'm not able to read them.\n");
344 } else { 312 } else {
345 priv->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
346
347 /* 313 /*
348 * if nExtBtn is greater than 8 it should be considered 314 * if nExtBtn is greater than 8 it should be considered
349 * invalid and treated as 0 315 * invalid and treated as 0
350 */ 316 */
351 if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) > 8) 317 if (SYN_CAP_MULTI_BUTTON_NO(info->ext_cap) > 8)
352 priv->ext_cap &= 0xff0fff; 318 info->ext_cap &= ~SYN_CAP_MB_MASK;
353 } 319 }
354 } 320 }
355 321
356 if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 4) { 322 if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 4) {
357 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_CAPAB_0C, cap)) { 323 error = synaptics_query_int(psmouse, SYN_QUE_EXT_CAPAB_0C,
324 &info->ext_cap_0c);
325 if (error)
358 psmouse_warn(psmouse, 326 psmouse_warn(psmouse,
359 "device claims to have extended capability 0x0c, but I'm not able to read it.\n"); 327 "device claims to have extended capability 0x0c, but I'm not able to read it.\n");
360 } else {
361 priv->ext_cap_0c = (cap[0] << 16) | (cap[1] << 8) | cap[2];
362 }
363 } 328 }
364 329
365 return 0; 330 return 0;
366} 331}
367 332
368/* 333/*
369 * Identify Touchpad
370 * See also the SYN_ID_* macros
371 */
372static int synaptics_identify(struct psmouse *psmouse)
373{
374 struct synaptics_data *priv = psmouse->private;
375 unsigned char id[3];
376
377 if (synaptics_send_cmd(psmouse, SYN_QUE_IDENTIFY, id))
378 return -1;
379 priv->identity = (id[0]<<16) | (id[1]<<8) | id[2];
380 if (SYN_ID_IS_SYNAPTICS(priv->identity))
381 return 0;
382 return -1;
383}
384
385/*
386 * Read touchpad resolution and maximum reported coordinates 334 * Read touchpad resolution and maximum reported coordinates
387 * Resolution is left zero if touchpad does not support the query 335 * Resolution is left zero if touchpad does not support the query
388 */ 336 */
389 337static int synaptics_resolution(struct psmouse *psmouse,
390static int synaptics_resolution(struct psmouse *psmouse) 338 struct synaptics_device_info *info)
391{ 339{
392 struct synaptics_data *priv = psmouse->private; 340 u8 resp[3];
393 unsigned char resp[3]; 341 int error;
394 342
395 if (SYN_ID_MAJOR(priv->identity) < 4) 343 if (SYN_ID_MAJOR(info->identity) < 4)
396 return 0; 344 return 0;
397 345
398 if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, resp) == 0) { 346 error = synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, resp);
347 if (!error) {
399 if (resp[0] != 0 && (resp[1] & 0x80) && resp[2] != 0) { 348 if (resp[0] != 0 && (resp[1] & 0x80) && resp[2] != 0) {
400 priv->x_res = resp[0]; /* x resolution in units/mm */ 349 info->x_res = resp[0]; /* x resolution in units/mm */
401 priv->y_res = resp[2]; /* y resolution in units/mm */ 350 info->y_res = resp[2]; /* y resolution in units/mm */
402 } 351 }
403 } 352 }
404 353
405 if (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 && 354 if (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 5 &&
406 SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) { 355 SYN_CAP_MAX_DIMENSIONS(info->ext_cap_0c)) {
407 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp)) { 356 error = synaptics_send_cmd(psmouse,
357 SYN_QUE_EXT_MAX_COORDS, resp);
358 if (error) {
408 psmouse_warn(psmouse, 359 psmouse_warn(psmouse,
409 "device claims to have max coordinates query, but I'm not able to read it.\n"); 360 "device claims to have max coordinates query, but I'm not able to read it.\n");
410 } else { 361 } else {
411 priv->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); 362 info->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);
412 priv->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); 363 info->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);
413 psmouse_info(psmouse, 364 psmouse_info(psmouse,
414 "queried max coordinates: x [..%d], y [..%d]\n", 365 "queried max coordinates: x [..%d], y [..%d]\n",
415 priv->x_max, priv->y_max); 366 info->x_max, info->y_max);
416 } 367 }
417 } 368 }
418 369
419 if (SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c) && 370 if (SYN_CAP_MIN_DIMENSIONS(info->ext_cap_0c) &&
420 (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 || 371 (SYN_EXT_CAP_REQUESTS(info->capabilities) >= 7 ||
421 /* 372 /*
422 * Firmware v8.1 does not report proper number of extended 373 * Firmware v8.1 does not report proper number of extended
423 * capabilities, but has been proven to report correct min 374 * capabilities, but has been proven to report correct min
424 * coordinates. 375 * coordinates.
425 */ 376 */
426 SYN_ID_FULL(priv->identity) == 0x801)) { 377 SYN_ID_FULL(info->identity) == 0x801)) {
427 if (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) { 378 error = synaptics_send_cmd(psmouse,
379 SYN_QUE_EXT_MIN_COORDS, resp);
380 if (error) {
428 psmouse_warn(psmouse, 381 psmouse_warn(psmouse,
429 "device claims to have min coordinates query, but I'm not able to read it.\n"); 382 "device claims to have min coordinates query, but I'm not able to read it.\n");
430 } else { 383 } else {
431 priv->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1); 384 info->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);
432 priv->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3); 385 info->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);
433 psmouse_info(psmouse, 386 psmouse_info(psmouse,
434 "queried min coordinates: x [%d..], y [%d..]\n", 387 "queried min coordinates: x [%d..], y [%d..]\n",
435 priv->x_min, priv->y_min); 388 info->x_min, info->y_min);
436 } 389 }
437 } 390 }
438 391
439 return 0; 392 return 0;
440} 393}
441 394
395static int synaptics_query_hardware(struct psmouse *psmouse,
396 struct synaptics_device_info *info)
397{
398 int error;
399
400 error = synaptics_identify(psmouse, info);
401 if (error)
402 return error;
403
404 error = synaptics_model_id(psmouse, info);
405 if (error)
406 return error;
407
408 error = synaptics_firmware_id(psmouse, info);
409 if (error)
410 return error;
411
412 error = synaptics_query_modes(psmouse, info);
413 if (error)
414 return error;
415
416 error = synaptics_capability(psmouse, info);
417 if (error)
418 return error;
419
420 error = synaptics_resolution(psmouse, info);
421 if (error)
422 return error;
423
424 return 0;
425}
426
427#endif /* CONFIG_MOUSE_PS2_SYNAPTICS || CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */
428
429#ifdef CONFIG_MOUSE_PS2_SYNAPTICS
430
431static bool cr48_profile_sensor;
432
433#define ANY_BOARD_ID 0
434struct min_max_quirk {
435 const char * const *pnp_ids;
436 struct {
437 u32 min, max;
438 } board_id;
439 u32 x_min, x_max, y_min, y_max;
440};
441
442static const struct min_max_quirk min_max_pnpid_table[] = {
443 {
444 (const char * const []){"LEN0033", NULL},
445 {ANY_BOARD_ID, ANY_BOARD_ID},
446 1024, 5052, 2258, 4832
447 },
448 {
449 (const char * const []){"LEN0042", NULL},
450 {ANY_BOARD_ID, ANY_BOARD_ID},
451 1232, 5710, 1156, 4696
452 },
453 {
454 (const char * const []){"LEN0034", "LEN0036", "LEN0037",
455 "LEN0039", "LEN2002", "LEN2004",
456 NULL},
457 {ANY_BOARD_ID, 2961},
458 1024, 5112, 2024, 4832
459 },
460 {
461 (const char * const []){"LEN2000", NULL},
462 {ANY_BOARD_ID, ANY_BOARD_ID},
463 1024, 5113, 2021, 4832
464 },
465 {
466 (const char * const []){"LEN2001", NULL},
467 {ANY_BOARD_ID, ANY_BOARD_ID},
468 1024, 5022, 2508, 4832
469 },
470 {
471 (const char * const []){"LEN2006", NULL},
472 {2691, 2691},
473 1024, 5045, 2457, 4832
474 },
475 {
476 (const char * const []){"LEN2006", NULL},
477 {ANY_BOARD_ID, ANY_BOARD_ID},
478 1264, 5675, 1171, 4688
479 },
480 { }
481};
482
483/* This list has been kindly provided by Synaptics. */
484static const char * const forcepad_pnp_ids[] = {
485 "SYN300D",
486 "SYN3014",
487 NULL
488};
489
490/*****************************************************************************
491 * Synaptics communications functions
492 ****************************************************************************/
493
494/*
495 * Synaptics touchpads report the y coordinate from bottom to top, which is
496 * opposite from what userspace expects.
497 * This function is used to invert y before reporting.
498 */
499static int synaptics_invert_y(int y)
500{
501 return YMAX_NOMINAL + YMIN_NOMINAL - y;
502}
503
442/* 504/*
443 * Apply quirk(s) if the hardware matches 505 * Apply quirk(s) if the hardware matches
444 */ 506 */
445 507static void synaptics_apply_quirks(struct psmouse *psmouse,
446static void synaptics_apply_quirks(struct psmouse *psmouse) 508 struct synaptics_device_info *info)
447{ 509{
448 struct synaptics_data *priv = psmouse->private;
449 int i; 510 int i;
450 511
451 for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) { 512 for (i = 0; min_max_pnpid_table[i].pnp_ids; i++) {
@@ -454,62 +515,45 @@ static void synaptics_apply_quirks(struct psmouse *psmouse)
454 continue; 515 continue;
455 516
456 if (min_max_pnpid_table[i].board_id.min != ANY_BOARD_ID && 517 if (min_max_pnpid_table[i].board_id.min != ANY_BOARD_ID &&
457 priv->board_id < min_max_pnpid_table[i].board_id.min) 518 info->board_id < min_max_pnpid_table[i].board_id.min)
458 continue; 519 continue;
459 520
460 if (min_max_pnpid_table[i].board_id.max != ANY_BOARD_ID && 521 if (min_max_pnpid_table[i].board_id.max != ANY_BOARD_ID &&
461 priv->board_id > min_max_pnpid_table[i].board_id.max) 522 info->board_id > min_max_pnpid_table[i].board_id.max)
462 continue; 523 continue;
463 524
464 priv->x_min = min_max_pnpid_table[i].x_min; 525 info->x_min = min_max_pnpid_table[i].x_min;
465 priv->x_max = min_max_pnpid_table[i].x_max; 526 info->x_max = min_max_pnpid_table[i].x_max;
466 priv->y_min = min_max_pnpid_table[i].y_min; 527 info->y_min = min_max_pnpid_table[i].y_min;
467 priv->y_max = min_max_pnpid_table[i].y_max; 528 info->y_max = min_max_pnpid_table[i].y_max;
468 psmouse_info(psmouse, 529 psmouse_info(psmouse,
469 "quirked min/max coordinates: x [%d..%d], y [%d..%d]\n", 530 "quirked min/max coordinates: x [%d..%d], y [%d..%d]\n",
470 priv->x_min, priv->x_max, 531 info->x_min, info->x_max,
471 priv->y_min, priv->y_max); 532 info->y_min, info->y_max);
472 break; 533 break;
473 } 534 }
474} 535}
475 536
476static int synaptics_query_hardware(struct psmouse *psmouse)
477{
478 if (synaptics_identify(psmouse))
479 return -1;
480 if (synaptics_model_id(psmouse))
481 return -1;
482 if (synaptics_firmware_id(psmouse))
483 return -1;
484 if (synaptics_query_modes(psmouse))
485 return -1;
486 if (synaptics_capability(psmouse))
487 return -1;
488 if (synaptics_resolution(psmouse))
489 return -1;
490
491 synaptics_apply_quirks(psmouse);
492
493 return 0;
494}
495
496static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) 537static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
497{ 538{
498 static unsigned char param = 0xc8; 539 static u8 param = 0xc8;
499 struct synaptics_data *priv = psmouse->private; 540 struct synaptics_data *priv = psmouse->private;
541 int error;
500 542
501 if (!(SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) || 543 if (!(SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
502 SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c))) 544 SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c)))
503 return 0; 545 return 0;
504 546
505 if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) 547 error = psmouse_sliced_command(psmouse, SYN_QUE_MODEL);
506 return -1; 548 if (error)
549 return error;
507 550
508 if (ps2_command(&psmouse->ps2dev, &param, PSMOUSE_CMD_SETRATE)) 551 error = ps2_command(&psmouse->ps2dev, &param, PSMOUSE_CMD_SETRATE);
509 return -1; 552 if (error)
553 return error;
510 554
511 /* Advanced gesture mode also sends multi finger data */ 555 /* Advanced gesture mode also sends multi finger data */
512 priv->capabilities |= BIT(1); 556 priv->info.capabilities |= BIT(1);
513 557
514 return 0; 558 return 0;
515} 559}
@@ -517,6 +561,7 @@ static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse)
517static int synaptics_set_mode(struct psmouse *psmouse) 561static int synaptics_set_mode(struct psmouse *psmouse)
518{ 562{
519 struct synaptics_data *priv = psmouse->private; 563 struct synaptics_data *priv = psmouse->private;
564 int error;
520 565
521 priv->mode = 0; 566 priv->mode = 0;
522 if (priv->absolute_mode) 567 if (priv->absolute_mode)
@@ -525,16 +570,21 @@ static int synaptics_set_mode(struct psmouse *psmouse)
525 priv->mode |= SYN_BIT_DISABLE_GESTURE; 570 priv->mode |= SYN_BIT_DISABLE_GESTURE;
526 if (psmouse->rate >= 80) 571 if (psmouse->rate >= 80)
527 priv->mode |= SYN_BIT_HIGH_RATE; 572 priv->mode |= SYN_BIT_HIGH_RATE;
528 if (SYN_CAP_EXTENDED(priv->capabilities)) 573 if (SYN_CAP_EXTENDED(priv->info.capabilities))
529 priv->mode |= SYN_BIT_W_MODE; 574 priv->mode |= SYN_BIT_W_MODE;
530 575
531 if (synaptics_mode_cmd(psmouse, priv->mode)) 576 error = synaptics_mode_cmd(psmouse, priv->mode);
532 return -1; 577 if (error)
578 return error;
533 579
534 if (priv->absolute_mode && 580 if (priv->absolute_mode) {
535 synaptics_set_advanced_gesture_mode(psmouse)) { 581 error = synaptics_set_advanced_gesture_mode(psmouse);
536 psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); 582 if (error) {
537 return -1; 583 psmouse_err(psmouse,
584 "Advanced gesture mode init failed: %d\n",
585 error);
586 return error;
587 }
538 } 588 }
539 589
540 return 0; 590 return 0;
@@ -558,15 +608,20 @@ static void synaptics_set_rate(struct psmouse *psmouse, unsigned int rate)
558/***************************************************************************** 608/*****************************************************************************
559 * Synaptics pass-through PS/2 port support 609 * Synaptics pass-through PS/2 port support
560 ****************************************************************************/ 610 ****************************************************************************/
561static int synaptics_pt_write(struct serio *serio, unsigned char c) 611static int synaptics_pt_write(struct serio *serio, u8 c)
562{ 612{
563 struct psmouse *parent = serio_get_drvdata(serio->parent); 613 struct psmouse *parent = serio_get_drvdata(serio->parent);
564 char rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */ 614 u8 rate_param = SYN_PS_CLIENT_CMD; /* indicates that we want pass-through port */
615 int error;
616
617 error = psmouse_sliced_command(parent, c);
618 if (error)
619 return error;
620
621 error = ps2_command(&parent->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE);
622 if (error)
623 return error;
565 624
566 if (psmouse_sliced_command(parent, c))
567 return -1;
568 if (ps2_command(&parent->ps2dev, &rate_param, PSMOUSE_CMD_SETRATE))
569 return -1;
570 return 0; 625 return 0;
571} 626}
572 627
@@ -592,13 +647,12 @@ static void synaptics_pt_stop(struct serio *serio)
592 serio_continue_rx(parent->ps2dev.serio); 647 serio_continue_rx(parent->ps2dev.serio);
593} 648}
594 649
595static int synaptics_is_pt_packet(unsigned char *buf) 650static int synaptics_is_pt_packet(u8 *buf)
596{ 651{
597 return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4; 652 return (buf[0] & 0xFC) == 0x84 && (buf[3] & 0xCC) == 0xC4;
598} 653}
599 654
600static void synaptics_pass_pt_packet(struct serio *ptport, 655static void synaptics_pass_pt_packet(struct serio *ptport, u8 *packet)
601 unsigned char *packet)
602{ 656{
603 struct psmouse *child = serio_get_drvdata(ptport); 657 struct psmouse *child = serio_get_drvdata(ptport);
604 658
@@ -661,7 +715,7 @@ static void synaptics_pt_create(struct psmouse *psmouse)
661 * Functions to interpret the absolute mode packets 715 * Functions to interpret the absolute mode packets
662 ****************************************************************************/ 716 ****************************************************************************/
663 717
664static void synaptics_parse_agm(const unsigned char buf[], 718static void synaptics_parse_agm(const u8 buf[],
665 struct synaptics_data *priv, 719 struct synaptics_data *priv,
666 struct synaptics_hw_state *hw) 720 struct synaptics_hw_state *hw)
667{ 721{
@@ -688,31 +742,31 @@ static void synaptics_parse_agm(const unsigned char buf[],
688 } 742 }
689} 743}
690 744
691static void synaptics_parse_ext_buttons(const unsigned char buf[], 745static void synaptics_parse_ext_buttons(const u8 buf[],
692 struct synaptics_data *priv, 746 struct synaptics_data *priv,
693 struct synaptics_hw_state *hw) 747 struct synaptics_hw_state *hw)
694{ 748{
695 unsigned int ext_bits = 749 unsigned int ext_bits =
696 (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1; 750 (SYN_CAP_MULTI_BUTTON_NO(priv->info.ext_cap) + 1) >> 1;
697 unsigned int ext_mask = GENMASK(ext_bits - 1, 0); 751 unsigned int ext_mask = GENMASK(ext_bits - 1, 0);
698 752
699 hw->ext_buttons = buf[4] & ext_mask; 753 hw->ext_buttons = buf[4] & ext_mask;
700 hw->ext_buttons |= (buf[5] & ext_mask) << ext_bits; 754 hw->ext_buttons |= (buf[5] & ext_mask) << ext_bits;
701} 755}
702 756
703static int synaptics_parse_hw_state(const unsigned char buf[], 757static int synaptics_parse_hw_state(const u8 buf[],
704 struct synaptics_data *priv, 758 struct synaptics_data *priv,
705 struct synaptics_hw_state *hw) 759 struct synaptics_hw_state *hw)
706{ 760{
707 memset(hw, 0, sizeof(struct synaptics_hw_state)); 761 memset(hw, 0, sizeof(struct synaptics_hw_state));
708 762
709 if (SYN_MODEL_NEWABS(priv->model_id)) { 763 if (SYN_MODEL_NEWABS(priv->info.model_id)) {
710 hw->w = (((buf[0] & 0x30) >> 2) | 764 hw->w = (((buf[0] & 0x30) >> 2) |
711 ((buf[0] & 0x04) >> 1) | 765 ((buf[0] & 0x04) >> 1) |
712 ((buf[3] & 0x04) >> 2)); 766 ((buf[3] & 0x04) >> 2));
713 767
714 if ((SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) || 768 if ((SYN_CAP_ADV_GESTURE(priv->info.ext_cap_0c) ||
715 SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) && 769 SYN_CAP_IMAGE_SENSOR(priv->info.ext_cap_0c)) &&
716 hw->w == 2) { 770 hw->w == 2) {
717 synaptics_parse_agm(buf, priv, hw); 771 synaptics_parse_agm(buf, priv, hw);
718 return 1; 772 return 1;
@@ -765,7 +819,7 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
765 819
766 hw->left = priv->report_press; 820 hw->left = priv->report_press;
767 821
768 } else if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { 822 } else if (SYN_CAP_CLICKPAD(priv->info.ext_cap_0c)) {
769 /* 823 /*
770 * Clickpad's button is transmitted as middle button, 824 * Clickpad's button is transmitted as middle button,
771 * however, since it is primary button, we will report 825 * however, since it is primary button, we will report
@@ -773,18 +827,18 @@ static int synaptics_parse_hw_state(const unsigned char buf[],
773 */ 827 */
774 hw->left = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0; 828 hw->left = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
775 829
776 } else if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) { 830 } else if (SYN_CAP_MIDDLE_BUTTON(priv->info.capabilities)) {
777 hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0; 831 hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
778 if (hw->w == 2) 832 if (hw->w == 2)
779 hw->scroll = (signed char)(buf[1]); 833 hw->scroll = (s8)buf[1];
780 } 834 }
781 835
782 if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) { 836 if (SYN_CAP_FOUR_BUTTON(priv->info.capabilities)) {
783 hw->up = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0; 837 hw->up = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
784 hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0; 838 hw->down = ((buf[0] ^ buf[3]) & 0x02) ? 1 : 0;
785 } 839 }
786 840
787 if (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) > 0 && 841 if (SYN_CAP_MULTI_BUTTON_NO(priv->info.ext_cap) > 0 &&
788 ((buf[0] ^ buf[3]) & 0x02)) { 842 ((buf[0] ^ buf[3]) & 0x02)) {
789 synaptics_parse_ext_buttons(buf, priv, hw); 843 synaptics_parse_ext_buttons(buf, priv, hw);
790 } 844 }
@@ -853,24 +907,24 @@ static void synaptics_report_ext_buttons(struct psmouse *psmouse,
853{ 907{
854 struct input_dev *dev = psmouse->dev; 908 struct input_dev *dev = psmouse->dev;
855 struct synaptics_data *priv = psmouse->private; 909 struct synaptics_data *priv = psmouse->private;
856 int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1; 910 int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->info.ext_cap) + 1) >> 1;
857 int i; 911 int i;
858 912
859 if (!SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap)) 913 if (!SYN_CAP_MULTI_BUTTON_NO(priv->info.ext_cap))
860 return; 914 return;
861 915
862 /* Bug in FW 8.1 & 8.2, buttons are reported only when ExtBit is 1 */ 916 /* Bug in FW 8.1 & 8.2, buttons are reported only when ExtBit is 1 */
863 if ((SYN_ID_FULL(priv->identity) == 0x801 || 917 if ((SYN_ID_FULL(priv->info.identity) == 0x801 ||
864 SYN_ID_FULL(priv->identity) == 0x802) && 918 SYN_ID_FULL(priv->info.identity) == 0x802) &&
865 !((psmouse->packet[0] ^ psmouse->packet[3]) & 0x02)) 919 !((psmouse->packet[0] ^ psmouse->packet[3]) & 0x02))
866 return; 920 return;
867 921
868 if (!SYN_CAP_EXT_BUTTONS_STICK(priv->ext_cap_10)) { 922 if (!SYN_CAP_EXT_BUTTONS_STICK(priv->info.ext_cap_10)) {
869 for (i = 0; i < ext_bits; i++) { 923 for (i = 0; i < ext_bits; i++) {
870 input_report_key(dev, BTN_0 + 2 * i, 924 input_report_key(dev, BTN_0 + 2 * i,
871 hw->ext_buttons & (1 << i)); 925 hw->ext_buttons & BIT(i));
872 input_report_key(dev, BTN_1 + 2 * i, 926 input_report_key(dev, BTN_1 + 2 * i,
873 hw->ext_buttons & (1 << (i + ext_bits))); 927 hw->ext_buttons & BIT(i + ext_bits));
874 } 928 }
875 return; 929 return;
876 } 930 }
@@ -884,9 +938,9 @@ static void synaptics_report_ext_buttons(struct psmouse *psmouse,
884 u8 pt_buttons; 938 u8 pt_buttons;
885 939
886 /* The trackstick expects at most 3 buttons */ 940 /* The trackstick expects at most 3 buttons */
887 pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) | 941 pt_buttons = SYN_EXT_BUTTON_STICK_L(hw->ext_buttons) |
888 SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 | 942 SYN_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 |
889 SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2; 943 SYN_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2;
890 944
891 serio_interrupt(priv->pt_port, 945 serio_interrupt(priv->pt_port,
892 PSMOUSE_OOB_EXTRA_BTNS, SERIO_OOB_DATA); 946 PSMOUSE_OOB_EXTRA_BTNS, SERIO_OOB_DATA);
@@ -903,10 +957,10 @@ static void synaptics_report_buttons(struct psmouse *psmouse,
903 input_report_key(dev, BTN_LEFT, hw->left); 957 input_report_key(dev, BTN_LEFT, hw->left);
904 input_report_key(dev, BTN_RIGHT, hw->right); 958 input_report_key(dev, BTN_RIGHT, hw->right);
905 959
906 if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) 960 if (SYN_CAP_MIDDLE_BUTTON(priv->info.capabilities))
907 input_report_key(dev, BTN_MIDDLE, hw->middle); 961 input_report_key(dev, BTN_MIDDLE, hw->middle);
908 962
909 if (SYN_CAP_FOUR_BUTTON(priv->capabilities)) { 963 if (SYN_CAP_FOUR_BUTTON(priv->info.capabilities)) {
910 input_report_key(dev, BTN_FORWARD, hw->up); 964 input_report_key(dev, BTN_FORWARD, hw->up);
911 input_report_key(dev, BTN_BACK, hw->down); 965 input_report_key(dev, BTN_BACK, hw->down);
912 } 966 }
@@ -931,7 +985,7 @@ static void synaptics_report_mt_data(struct psmouse *psmouse,
931 pos[i].y = synaptics_invert_y(hw[i]->y); 985 pos[i].y = synaptics_invert_y(hw[i]->y);
932 } 986 }
933 987
934 input_mt_assign_slots(dev, slot, pos, nsemi, DMAX * priv->x_res); 988 input_mt_assign_slots(dev, slot, pos, nsemi, DMAX * priv->info.x_res);
935 989
936 for (i = 0; i < nsemi; i++) { 990 for (i = 0; i < nsemi; i++) {
937 input_mt_slot(dev, slot[i]); 991 input_mt_slot(dev, slot[i]);
@@ -985,6 +1039,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
985{ 1039{
986 struct input_dev *dev = psmouse->dev; 1040 struct input_dev *dev = psmouse->dev;
987 struct synaptics_data *priv = psmouse->private; 1041 struct synaptics_data *priv = psmouse->private;
1042 struct synaptics_device_info *info = &priv->info;
988 struct synaptics_hw_state hw; 1043 struct synaptics_hw_state hw;
989 int num_fingers; 1044 int num_fingers;
990 int finger_width; 1045 int finger_width;
@@ -992,7 +1047,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
992 if (synaptics_parse_hw_state(psmouse->packet, priv, &hw)) 1047 if (synaptics_parse_hw_state(psmouse->packet, priv, &hw))
993 return; 1048 return;
994 1049
995 if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) { 1050 if (SYN_CAP_IMAGE_SENSOR(info->ext_cap_0c)) {
996 synaptics_image_sensor_process(psmouse, &hw); 1051 synaptics_image_sensor_process(psmouse, &hw);
997 return; 1052 return;
998 } 1053 }
@@ -1020,18 +1075,18 @@ static void synaptics_process_packet(struct psmouse *psmouse)
1020 if (hw.z > 0 && hw.x > 1) { 1075 if (hw.z > 0 && hw.x > 1) {
1021 num_fingers = 1; 1076 num_fingers = 1;
1022 finger_width = 5; 1077 finger_width = 5;
1023 if (SYN_CAP_EXTENDED(priv->capabilities)) { 1078 if (SYN_CAP_EXTENDED(info->capabilities)) {
1024 switch (hw.w) { 1079 switch (hw.w) {
1025 case 0 ... 1: 1080 case 0 ... 1:
1026 if (SYN_CAP_MULTIFINGER(priv->capabilities)) 1081 if (SYN_CAP_MULTIFINGER(info->capabilities))
1027 num_fingers = hw.w + 2; 1082 num_fingers = hw.w + 2;
1028 break; 1083 break;
1029 case 2: 1084 case 2:
1030 if (SYN_MODEL_PEN(priv->model_id)) 1085 if (SYN_MODEL_PEN(info->model_id))
1031 ; /* Nothing, treat a pen as a single finger */ 1086 ; /* Nothing, treat a pen as a single finger */
1032 break; 1087 break;
1033 case 4 ... 15: 1088 case 4 ... 15:
1034 if (SYN_CAP_PALMDETECT(priv->capabilities)) 1089 if (SYN_CAP_PALMDETECT(info->capabilities))
1035 finger_width = hw.w; 1090 finger_width = hw.w;
1036 break; 1091 break;
1037 } 1092 }
@@ -1046,7 +1101,7 @@ static void synaptics_process_packet(struct psmouse *psmouse)
1046 return; 1101 return;
1047 } 1102 }
1048 1103
1049 if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) 1104 if (SYN_CAP_ADV_GESTURE(info->ext_cap_0c))
1050 synaptics_report_semi_mt_data(dev, &hw, &priv->agm, 1105 synaptics_report_semi_mt_data(dev, &hw, &priv->agm,
1051 num_fingers); 1106 num_fingers);
1052 1107
@@ -1063,11 +1118,11 @@ static void synaptics_process_packet(struct psmouse *psmouse)
1063 } 1118 }
1064 input_report_abs(dev, ABS_PRESSURE, hw.z); 1119 input_report_abs(dev, ABS_PRESSURE, hw.z);
1065 1120
1066 if (SYN_CAP_PALMDETECT(priv->capabilities)) 1121 if (SYN_CAP_PALMDETECT(info->capabilities))
1067 input_report_abs(dev, ABS_TOOL_WIDTH, finger_width); 1122 input_report_abs(dev, ABS_TOOL_WIDTH, finger_width);
1068 1123
1069 input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1); 1124 input_report_key(dev, BTN_TOOL_FINGER, num_fingers == 1);
1070 if (SYN_CAP_MULTIFINGER(priv->capabilities)) { 1125 if (SYN_CAP_MULTIFINGER(info->capabilities)) {
1071 input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2); 1126 input_report_key(dev, BTN_TOOL_DOUBLETAP, num_fingers == 2);
1072 input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3); 1127 input_report_key(dev, BTN_TOOL_TRIPLETAP, num_fingers == 3);
1073 } 1128 }
@@ -1077,18 +1132,18 @@ static void synaptics_process_packet(struct psmouse *psmouse)
1077 input_sync(dev); 1132 input_sync(dev);
1078} 1133}
1079 1134
1080static int synaptics_validate_byte(struct psmouse *psmouse, 1135static bool synaptics_validate_byte(struct psmouse *psmouse,
1081 int idx, unsigned char pkt_type) 1136 int idx, enum synaptics_pkt_type pkt_type)
1082{ 1137{
1083 static const unsigned char newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 }; 1138 static const u8 newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 };
1084 static const unsigned char newabs_rel_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 }; 1139 static const u8 newabs_rel_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 };
1085 static const unsigned char newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 }; 1140 static const u8 newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
1086 static const unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 }; 1141 static const u8 oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
1087 static const unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 }; 1142 static const u8 oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
1088 const char *packet = psmouse->packet; 1143 const u8 *packet = psmouse->packet;
1089 1144
1090 if (idx < 0 || idx > 4) 1145 if (idx < 0 || idx > 4)
1091 return 0; 1146 return false;
1092 1147
1093 switch (pkt_type) { 1148 switch (pkt_type) {
1094 1149
@@ -1104,19 +1159,21 @@ static int synaptics_validate_byte(struct psmouse *psmouse,
1104 1159
1105 default: 1160 default:
1106 psmouse_err(psmouse, "unknown packet type %d\n", pkt_type); 1161 psmouse_err(psmouse, "unknown packet type %d\n", pkt_type);
1107 return 0; 1162 return false;
1108 } 1163 }
1109} 1164}
1110 1165
1111static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse) 1166static enum synaptics_pkt_type
1167synaptics_detect_pkt_type(struct psmouse *psmouse)
1112{ 1168{
1113 int i; 1169 int i;
1114 1170
1115 for (i = 0; i < 5; i++) 1171 for (i = 0; i < 5; i++) {
1116 if (!synaptics_validate_byte(psmouse, i, SYN_NEWABS_STRICT)) { 1172 if (!synaptics_validate_byte(psmouse, i, SYN_NEWABS_STRICT)) {
1117 psmouse_info(psmouse, "using relaxed packet validation\n"); 1173 psmouse_info(psmouse, "using relaxed packet validation\n");
1118 return SYN_NEWABS_RELAXED; 1174 return SYN_NEWABS_RELAXED;
1119 } 1175 }
1176 }
1120 1177
1121 return SYN_NEWABS_STRICT; 1178 return SYN_NEWABS_STRICT;
1122} 1179}
@@ -1129,7 +1186,7 @@ static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse)
1129 if (unlikely(priv->pkt_type == SYN_NEWABS)) 1186 if (unlikely(priv->pkt_type == SYN_NEWABS))
1130 priv->pkt_type = synaptics_detect_pkt_type(psmouse); 1187 priv->pkt_type = synaptics_detect_pkt_type(psmouse);
1131 1188
1132 if (SYN_CAP_PASS_THROUGH(priv->capabilities) && 1189 if (SYN_CAP_PASS_THROUGH(priv->info.capabilities) &&
1133 synaptics_is_pt_packet(psmouse->packet)) { 1190 synaptics_is_pt_packet(psmouse->packet)) {
1134 if (priv->pt_port) 1191 if (priv->pt_port)
1135 synaptics_pass_pt_packet(priv->pt_port, 1192 synaptics_pass_pt_packet(priv->pt_port,
@@ -1148,26 +1205,27 @@ static psmouse_ret_t synaptics_process_byte(struct psmouse *psmouse)
1148 * Driver initialization/cleanup functions 1205 * Driver initialization/cleanup functions
1149 ****************************************************************************/ 1206 ****************************************************************************/
1150static void set_abs_position_params(struct input_dev *dev, 1207static void set_abs_position_params(struct input_dev *dev,
1151 struct synaptics_data *priv, int x_code, 1208 struct synaptics_device_info *info,
1152 int y_code) 1209 int x_code, int y_code)
1153{ 1210{
1154 int x_min = priv->x_min ?: XMIN_NOMINAL; 1211 int x_min = info->x_min ?: XMIN_NOMINAL;
1155 int x_max = priv->x_max ?: XMAX_NOMINAL; 1212 int x_max = info->x_max ?: XMAX_NOMINAL;
1156 int y_min = priv->y_min ?: YMIN_NOMINAL; 1213 int y_min = info->y_min ?: YMIN_NOMINAL;
1157 int y_max = priv->y_max ?: YMAX_NOMINAL; 1214 int y_max = info->y_max ?: YMAX_NOMINAL;
1158 int fuzz = SYN_CAP_REDUCED_FILTERING(priv->ext_cap_0c) ? 1215 int fuzz = SYN_CAP_REDUCED_FILTERING(info->ext_cap_0c) ?
1159 SYN_REDUCED_FILTER_FUZZ : 0; 1216 SYN_REDUCED_FILTER_FUZZ : 0;
1160 1217
1161 input_set_abs_params(dev, x_code, x_min, x_max, fuzz, 0); 1218 input_set_abs_params(dev, x_code, x_min, x_max, fuzz, 0);
1162 input_set_abs_params(dev, y_code, y_min, y_max, fuzz, 0); 1219 input_set_abs_params(dev, y_code, y_min, y_max, fuzz, 0);
1163 input_abs_set_res(dev, x_code, priv->x_res); 1220 input_abs_set_res(dev, x_code, info->x_res);
1164 input_abs_set_res(dev, y_code, priv->y_res); 1221 input_abs_set_res(dev, y_code, info->y_res);
1165} 1222}
1166 1223
1167static void set_input_params(struct psmouse *psmouse, 1224static void set_input_params(struct psmouse *psmouse,
1168 struct synaptics_data *priv) 1225 struct synaptics_data *priv)
1169{ 1226{
1170 struct input_dev *dev = psmouse->dev; 1227 struct input_dev *dev = psmouse->dev;
1228 struct synaptics_device_info *info = &priv->info;
1171 int i; 1229 int i;
1172 1230
1173 /* Things that apply to both modes */ 1231 /* Things that apply to both modes */
@@ -1176,7 +1234,7 @@ static void set_input_params(struct psmouse *psmouse,
1176 __set_bit(BTN_LEFT, dev->keybit); 1234 __set_bit(BTN_LEFT, dev->keybit);
1177 __set_bit(BTN_RIGHT, dev->keybit); 1235 __set_bit(BTN_RIGHT, dev->keybit);
1178 1236
1179 if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) 1237 if (SYN_CAP_MIDDLE_BUTTON(info->capabilities))
1180 __set_bit(BTN_MIDDLE, dev->keybit); 1238 __set_bit(BTN_MIDDLE, dev->keybit);
1181 1239
1182 if (!priv->absolute_mode) { 1240 if (!priv->absolute_mode) {
@@ -1189,15 +1247,15 @@ static void set_input_params(struct psmouse *psmouse,
1189 1247
1190 /* Absolute mode */ 1248 /* Absolute mode */
1191 __set_bit(EV_ABS, dev->evbit); 1249 __set_bit(EV_ABS, dev->evbit);
1192 set_abs_position_params(dev, priv, ABS_X, ABS_Y); 1250 set_abs_position_params(dev, &priv->info, ABS_X, ABS_Y);
1193 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); 1251 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0);
1194 1252
1195 if (cr48_profile_sensor) 1253 if (cr48_profile_sensor)
1196 input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0); 1254 input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0);
1197 1255
1198 if (SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c)) { 1256 if (SYN_CAP_IMAGE_SENSOR(info->ext_cap_0c)) {
1199 set_abs_position_params(dev, priv, ABS_MT_POSITION_X, 1257 set_abs_position_params(dev, info,
1200 ABS_MT_POSITION_Y); 1258 ABS_MT_POSITION_X, ABS_MT_POSITION_Y);
1201 /* Image sensors can report per-contact pressure */ 1259 /* Image sensors can report per-contact pressure */
1202 input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0); 1260 input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0);
1203 input_mt_init_slots(dev, 2, INPUT_MT_POINTER | INPUT_MT_TRACK); 1261 input_mt_init_slots(dev, 2, INPUT_MT_POINTER | INPUT_MT_TRACK);
@@ -1205,9 +1263,9 @@ static void set_input_params(struct psmouse *psmouse,
1205 /* Image sensors can signal 4 and 5 finger clicks */ 1263 /* Image sensors can signal 4 and 5 finger clicks */
1206 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 1264 __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
1207 __set_bit(BTN_TOOL_QUINTTAP, dev->keybit); 1265 __set_bit(BTN_TOOL_QUINTTAP, dev->keybit);
1208 } else if (SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) { 1266 } else if (SYN_CAP_ADV_GESTURE(info->ext_cap_0c)) {
1209 set_abs_position_params(dev, priv, ABS_MT_POSITION_X, 1267 set_abs_position_params(dev, info,
1210 ABS_MT_POSITION_Y); 1268 ABS_MT_POSITION_X, ABS_MT_POSITION_Y);
1211 /* 1269 /*
1212 * Profile sensor in CR-48 tracks contacts reasonably well, 1270 * Profile sensor in CR-48 tracks contacts reasonably well,
1213 * other non-image sensors with AGM use semi-mt. 1271 * other non-image sensors with AGM use semi-mt.
@@ -1218,35 +1276,35 @@ static void set_input_params(struct psmouse *psmouse,
1218 INPUT_MT_TRACK : INPUT_MT_SEMI_MT)); 1276 INPUT_MT_TRACK : INPUT_MT_SEMI_MT));
1219 } 1277 }
1220 1278
1221 if (SYN_CAP_PALMDETECT(priv->capabilities)) 1279 if (SYN_CAP_PALMDETECT(info->capabilities))
1222 input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); 1280 input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0);
1223 1281
1224 __set_bit(BTN_TOUCH, dev->keybit); 1282 __set_bit(BTN_TOUCH, dev->keybit);
1225 __set_bit(BTN_TOOL_FINGER, dev->keybit); 1283 __set_bit(BTN_TOOL_FINGER, dev->keybit);
1226 1284
1227 if (SYN_CAP_MULTIFINGER(priv->capabilities)) { 1285 if (SYN_CAP_MULTIFINGER(info->capabilities)) {
1228 __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); 1286 __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit);
1229 __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit); 1287 __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit);
1230 } 1288 }
1231 1289
1232 if (SYN_CAP_FOUR_BUTTON(priv->capabilities) || 1290 if (SYN_CAP_FOUR_BUTTON(info->capabilities) ||
1233 SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) { 1291 SYN_CAP_MIDDLE_BUTTON(info->capabilities)) {
1234 __set_bit(BTN_FORWARD, dev->keybit); 1292 __set_bit(BTN_FORWARD, dev->keybit);
1235 __set_bit(BTN_BACK, dev->keybit); 1293 __set_bit(BTN_BACK, dev->keybit);
1236 } 1294 }
1237 1295
1238 if (!SYN_CAP_EXT_BUTTONS_STICK(priv->ext_cap_10)) 1296 if (!SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10))
1239 for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap); i++) 1297 for (i = 0; i < SYN_CAP_MULTI_BUTTON_NO(info->ext_cap); i++)
1240 __set_bit(BTN_0 + i, dev->keybit); 1298 __set_bit(BTN_0 + i, dev->keybit);
1241 1299
1242 __clear_bit(EV_REL, dev->evbit); 1300 __clear_bit(EV_REL, dev->evbit);
1243 __clear_bit(REL_X, dev->relbit); 1301 __clear_bit(REL_X, dev->relbit);
1244 __clear_bit(REL_Y, dev->relbit); 1302 __clear_bit(REL_Y, dev->relbit);
1245 1303
1246 if (SYN_CAP_CLICKPAD(priv->ext_cap_0c)) { 1304 if (SYN_CAP_CLICKPAD(info->ext_cap_0c)) {
1247 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); 1305 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit);
1248 if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) && 1306 if (psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) &&
1249 !SYN_CAP_EXT_BUTTONS_STICK(priv->ext_cap_10)) 1307 !SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10))
1250 __set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit); 1308 __set_bit(INPUT_PROP_TOPBUTTONPAD, dev->propbit);
1251 /* Clickpads report only left button */ 1309 /* Clickpads report only left button */
1252 __clear_bit(BTN_RIGHT, dev->keybit); 1310 __clear_bit(BTN_RIGHT, dev->keybit);
@@ -1300,7 +1358,14 @@ static void synaptics_disconnect(struct psmouse *psmouse)
1300{ 1358{
1301 struct synaptics_data *priv = psmouse->private; 1359 struct synaptics_data *priv = psmouse->private;
1302 1360
1303 if (!priv->absolute_mode && SYN_ID_DISGEST_SUPPORTED(priv->identity)) 1361 /*
1362 * We might have left a breadcrumb when trying to
1363 * set up SMbus companion.
1364 */
1365 psmouse_smbus_cleanup(psmouse);
1366
1367 if (!priv->absolute_mode &&
1368 SYN_ID_DISGEST_SUPPORTED(priv->info.identity))
1304 device_remove_file(&psmouse->ps2dev.serio->dev, 1369 device_remove_file(&psmouse->ps2dev.serio->dev,
1305 &psmouse_attr_disable_gesture.dattr); 1370 &psmouse_attr_disable_gesture.dattr);
1306 1371
@@ -1312,8 +1377,8 @@ static void synaptics_disconnect(struct psmouse *psmouse)
1312static int synaptics_reconnect(struct psmouse *psmouse) 1377static int synaptics_reconnect(struct psmouse *psmouse)
1313{ 1378{
1314 struct synaptics_data *priv = psmouse->private; 1379 struct synaptics_data *priv = psmouse->private;
1315 struct synaptics_data old_priv = *priv; 1380 struct synaptics_device_info info;
1316 unsigned char param[2]; 1381 u8 param[2];
1317 int retry = 0; 1382 int retry = 0;
1318 int error; 1383 int error;
1319 1384
@@ -1334,32 +1399,34 @@ static int synaptics_reconnect(struct psmouse *psmouse)
1334 } while (error && ++retry < 3); 1399 } while (error && ++retry < 3);
1335 1400
1336 if (error) 1401 if (error)
1337 return -1; 1402 return error;
1338 1403
1339 if (retry > 1) 1404 if (retry > 1)
1340 psmouse_dbg(psmouse, "reconnected after %d tries\n", retry); 1405 psmouse_dbg(psmouse, "reconnected after %d tries\n", retry);
1341 1406
1342 if (synaptics_query_hardware(psmouse)) { 1407 error = synaptics_query_hardware(psmouse, &info);
1408 if (error) {
1343 psmouse_err(psmouse, "Unable to query device.\n"); 1409 psmouse_err(psmouse, "Unable to query device.\n");
1344 return -1; 1410 return error;
1345 } 1411 }
1346 1412
1347 if (synaptics_set_mode(psmouse)) { 1413 error = synaptics_set_mode(psmouse);
1414 if (error) {
1348 psmouse_err(psmouse, "Unable to initialize device.\n"); 1415 psmouse_err(psmouse, "Unable to initialize device.\n");
1349 return -1; 1416 return error;
1350 } 1417 }
1351 1418
1352 if (old_priv.identity != priv->identity || 1419 if (info.identity != priv->info.identity ||
1353 old_priv.model_id != priv->model_id || 1420 info.model_id != priv->info.model_id ||
1354 old_priv.capabilities != priv->capabilities || 1421 info.capabilities != priv->info.capabilities ||
1355 old_priv.ext_cap != priv->ext_cap) { 1422 info.ext_cap != priv->info.ext_cap) {
1356 psmouse_err(psmouse, 1423 psmouse_err(psmouse,
1357 "hardware appears to be different: id(%ld-%ld), model(%ld-%ld), caps(%lx-%lx), ext(%lx-%lx).\n", 1424 "hardware appears to be different: id(%u-%u), model(%u-%u), caps(%x-%x), ext(%x-%x).\n",
1358 old_priv.identity, priv->identity, 1425 priv->info.identity, info.identity,
1359 old_priv.model_id, priv->model_id, 1426 priv->info.model_id, info.model_id,
1360 old_priv.capabilities, priv->capabilities, 1427 priv->info.capabilities, info.capabilities,
1361 old_priv.ext_cap, priv->ext_cap); 1428 priv->info.ext_cap, info.ext_cap);
1362 return -1; 1429 return -ENXIO;
1363 } 1430 }
1364 1431
1365 return 0; 1432 return 0;
@@ -1439,36 +1506,22 @@ void __init synaptics_module_init(void)
1439 cr48_profile_sensor = dmi_check_system(cr48_dmi_table); 1506 cr48_profile_sensor = dmi_check_system(cr48_dmi_table);
1440} 1507}
1441 1508
1442static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode) 1509static int synaptics_init_ps2(struct psmouse *psmouse,
1510 struct synaptics_device_info *info,
1511 bool absolute_mode)
1443{ 1512{
1444 struct synaptics_data *priv; 1513 struct synaptics_data *priv;
1445 int err = -1; 1514 int err;
1446 1515
1447 /* 1516 synaptics_apply_quirks(psmouse, info);
1448 * The OLPC XO has issues with Synaptics' absolute mode; the constant
1449 * packet spew overloads the EC such that key presses on the keyboard
1450 * are missed. Given that, don't even attempt to use Absolute mode.
1451 * Relative mode seems to work just fine.
1452 */
1453 if (absolute_mode && broken_olpc_ec) {
1454 psmouse_info(psmouse,
1455 "OLPC XO detected, not enabling Synaptics protocol.\n");
1456 return -ENODEV;
1457 }
1458 1517
1459 psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL); 1518 psmouse->private = priv = kzalloc(sizeof(struct synaptics_data), GFP_KERNEL);
1460 if (!priv) 1519 if (!priv)
1461 return -ENOMEM; 1520 return -ENOMEM;
1462 1521
1463 psmouse_reset(psmouse); 1522 priv->info = *info;
1464
1465 if (synaptics_query_hardware(psmouse)) {
1466 psmouse_err(psmouse, "Unable to query device.\n");
1467 goto init_fail;
1468 }
1469
1470 priv->absolute_mode = absolute_mode; 1523 priv->absolute_mode = absolute_mode;
1471 if (SYN_ID_DISGEST_SUPPORTED(priv->identity)) 1524 if (SYN_ID_DISGEST_SUPPORTED(info->identity))
1472 priv->disable_gesture = true; 1525 priv->disable_gesture = true;
1473 1526
1474 /* 1527 /*
@@ -1477,20 +1530,22 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode)
1477 */ 1530 */
1478 priv->is_forcepad = psmouse_matches_pnp_id(psmouse, forcepad_pnp_ids); 1531 priv->is_forcepad = psmouse_matches_pnp_id(psmouse, forcepad_pnp_ids);
1479 1532
1480 if (synaptics_set_mode(psmouse)) { 1533 err = synaptics_set_mode(psmouse);
1534 if (err) {
1481 psmouse_err(psmouse, "Unable to initialize device.\n"); 1535 psmouse_err(psmouse, "Unable to initialize device.\n");
1482 goto init_fail; 1536 goto init_fail;
1483 } 1537 }
1484 1538
1485 priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS; 1539 priv->pkt_type = SYN_MODEL_NEWABS(info->model_id) ?
1540 SYN_NEWABS : SYN_OLDABS;
1486 1541
1487 psmouse_info(psmouse, 1542 psmouse_info(psmouse,
1488 "Touchpad model: %ld, fw: %ld.%ld, id: %#lx, caps: %#lx/%#lx/%#lx/%#lx, board id: %lu, fw id: %lu\n", 1543 "Touchpad model: %lu, fw: %lu.%lu, id: %#x, caps: %#x/%#x/%#x/%#x, board id: %u, fw id: %u\n",
1489 SYN_ID_MODEL(priv->identity), 1544 SYN_ID_MODEL(info->identity),
1490 SYN_ID_MAJOR(priv->identity), SYN_ID_MINOR(priv->identity), 1545 SYN_ID_MAJOR(info->identity), SYN_ID_MINOR(info->identity),
1491 priv->model_id, 1546 info->model_id,
1492 priv->capabilities, priv->ext_cap, priv->ext_cap_0c, 1547 info->capabilities, info->ext_cap, info->ext_cap_0c,
1493 priv->ext_cap_10, priv->board_id, priv->firmware_id); 1548 info->ext_cap_10, info->board_id, info->firmware_id);
1494 1549
1495 set_input_params(psmouse, priv); 1550 set_input_params(psmouse, priv);
1496 1551
@@ -1501,8 +1556,8 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode)
1501 * Hardware info bits seem to be good candidates as they 1556 * Hardware info bits seem to be good candidates as they
1502 * are documented to be for Synaptics corp. internal use. 1557 * are documented to be for Synaptics corp. internal use.
1503 */ 1558 */
1504 psmouse->model = ((priv->model_id & 0x00ff0000) >> 8) | 1559 psmouse->model = ((info->model_id & 0x00ff0000) >> 8) |
1505 (priv->model_id & 0x000000ff); 1560 (info->model_id & 0x000000ff);
1506 1561
1507 if (absolute_mode) { 1562 if (absolute_mode) {
1508 psmouse->protocol_handler = synaptics_process_byte; 1563 psmouse->protocol_handler = synaptics_process_byte;
@@ -1520,7 +1575,7 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode)
1520 /* Synaptics can usually stay in sync without extra help */ 1575 /* Synaptics can usually stay in sync without extra help */
1521 psmouse->resync_time = 0; 1576 psmouse->resync_time = 0;
1522 1577
1523 if (SYN_CAP_PASS_THROUGH(priv->capabilities)) 1578 if (SYN_CAP_PASS_THROUGH(info->capabilities))
1524 synaptics_pt_create(psmouse); 1579 synaptics_pt_create(psmouse);
1525 1580
1526 /* 1581 /*
@@ -1535,7 +1590,7 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode)
1535 psmouse->rate = 40; 1590 psmouse->rate = 40;
1536 } 1591 }
1537 1592
1538 if (!priv->absolute_mode && SYN_ID_DISGEST_SUPPORTED(priv->identity)) { 1593 if (!priv->absolute_mode && SYN_ID_DISGEST_SUPPORTED(info->identity)) {
1539 err = device_create_file(&psmouse->ps2dev.serio->dev, 1594 err = device_create_file(&psmouse->ps2dev.serio->dev,
1540 &psmouse_attr_disable_gesture.dattr); 1595 &psmouse_attr_disable_gesture.dattr);
1541 if (err) { 1596 if (err) {
@@ -1553,7 +1608,23 @@ static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode)
1553 return err; 1608 return err;
1554} 1609}
1555 1610
1556int synaptics_init(struct psmouse *psmouse) 1611static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode)
1612{
1613 struct synaptics_device_info info;
1614 int error;
1615
1616 psmouse_reset(psmouse);
1617
1618 error = synaptics_query_hardware(psmouse, &info);
1619 if (error) {
1620 psmouse_err(psmouse, "Unable to query device: %d\n", error);
1621 return error;
1622 }
1623
1624 return synaptics_init_ps2(psmouse, &info, absolute_mode);
1625}
1626
1627int synaptics_init_absolute(struct psmouse *psmouse)
1557{ 1628{
1558 return __synaptics_init(psmouse, true); 1629 return __synaptics_init(psmouse, true);
1559} 1630}
@@ -1563,15 +1634,204 @@ int synaptics_init_relative(struct psmouse *psmouse)
1563 return __synaptics_init(psmouse, false); 1634 return __synaptics_init(psmouse, false);
1564} 1635}
1565 1636
1637static int synaptics_setup_ps2(struct psmouse *psmouse,
1638 struct synaptics_device_info *info)
1639{
1640 bool absolute_mode = true;
1641 int error;
1642
1643 /*
1644 * The OLPC XO has issues with Synaptics' absolute mode; the constant
1645 * packet spew overloads the EC such that key presses on the keyboard
1646 * are missed. Given that, don't even attempt to use Absolute mode.
1647 * Relative mode seems to work just fine.
1648 */
1649 if (broken_olpc_ec) {
1650 psmouse_info(psmouse,
1651 "OLPC XO detected, forcing relative protocol.\n");
1652 absolute_mode = false;
1653 }
1654
1655 error = synaptics_init_ps2(psmouse, info, absolute_mode);
1656 if (error)
1657 return error;
1658
1659 return absolute_mode ? PSMOUSE_SYNAPTICS : PSMOUSE_SYNAPTICS_RELATIVE;
1660}
1661
1566#else /* CONFIG_MOUSE_PS2_SYNAPTICS */ 1662#else /* CONFIG_MOUSE_PS2_SYNAPTICS */
1567 1663
1568void __init synaptics_module_init(void) 1664void __init synaptics_module_init(void)
1569{ 1665{
1570} 1666}
1571 1667
1572int synaptics_init(struct psmouse *psmouse) 1668static int __maybe_unused
1669synaptics_setup_ps2(struct psmouse *psmouse,
1670 struct synaptics_device_info *info)
1573{ 1671{
1574 return -ENOSYS; 1672 return -ENOSYS;
1575} 1673}
1576 1674
1577#endif /* CONFIG_MOUSE_PS2_SYNAPTICS */ 1675#endif /* CONFIG_MOUSE_PS2_SYNAPTICS */
1676
1677#ifdef CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS
1678
1679/*
1680 * The newest Synaptics device can use a secondary bus (called InterTouch) which
1681 * provides a better bandwidth and allow a better control of the touchpads.
1682 * This is used to decide if we need to use this bus or not.
1683 */
1684enum {
1685 SYNAPTICS_INTERTOUCH_NOT_SET = -1,
1686 SYNAPTICS_INTERTOUCH_OFF,
1687 SYNAPTICS_INTERTOUCH_ON,
1688};
1689
1690static int synaptics_intertouch = SYNAPTICS_INTERTOUCH_NOT_SET;
1691module_param_named(synaptics_intertouch, synaptics_intertouch, int, 0644);
1692MODULE_PARM_DESC(synaptics_intertouch, "Use a secondary bus for the Synaptics device.");
1693
1694static int synaptics_create_intertouch(struct psmouse *psmouse,
1695 struct synaptics_device_info *info,
1696 bool leave_breadcrumbs)
1697{
1698 bool topbuttonpad =
1699 psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) &&
1700 !SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10);
1701 const struct rmi_device_platform_data pdata = {
1702 .sensor_pdata = {
1703 .sensor_type = rmi_sensor_touchpad,
1704 .axis_align.flip_y = true,
1705 /* to prevent cursors jumps: */
1706 .kernel_tracking = true,
1707 .topbuttonpad = topbuttonpad,
1708 },
1709 .f30_data = {
1710 .buttonpad = SYN_CAP_CLICKPAD(info->ext_cap_0c),
1711 .trackstick_buttons =
1712 !!SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10),
1713 },
1714 };
1715 const struct i2c_board_info intertouch_board = {
1716 I2C_BOARD_INFO("rmi4_smbus", 0x2c),
1717 .flags = I2C_CLIENT_HOST_NOTIFY,
1718 };
1719
1720 return psmouse_smbus_init(psmouse, &intertouch_board,
1721 &pdata, sizeof(pdata),
1722 leave_breadcrumbs);
1723}
1724
1725/**
1726 * synaptics_setup_intertouch - called once the PS/2 devices are enumerated
1727 * and decides to instantiate a SMBus InterTouch device.
1728 */
1729static int synaptics_setup_intertouch(struct psmouse *psmouse,
1730 struct synaptics_device_info *info,
1731 bool leave_breadcrumbs)
1732{
1733 int error;
1734
1735 if (synaptics_intertouch == SYNAPTICS_INTERTOUCH_OFF)
1736 return -ENXIO;
1737
1738 if (synaptics_intertouch == SYNAPTICS_INTERTOUCH_NOT_SET) {
1739 if (!psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) &&
1740 !psmouse_matches_pnp_id(psmouse, smbus_pnp_ids))
1741 return -ENXIO;
1742 }
1743
1744 psmouse_info(psmouse, "Trying to set up SMBus access\n");
1745
1746 error = synaptics_create_intertouch(psmouse, info, leave_breadcrumbs);
1747 if (error) {
1748 if (error == -EAGAIN)
1749 psmouse_info(psmouse, "SMbus companion is not ready yet\n");
1750 else
1751 psmouse_err(psmouse, "unable to create intertouch device\n");
1752
1753 return error;
1754 }
1755
1756 return 0;
1757}
1758
1759int synaptics_init_smbus(struct psmouse *psmouse)
1760{
1761 struct synaptics_device_info info;
1762 int error;
1763
1764 psmouse_reset(psmouse);
1765
1766 error = synaptics_query_hardware(psmouse, &info);
1767 if (error) {
1768 psmouse_err(psmouse, "Unable to query device: %d\n", error);
1769 return error;
1770 }
1771
1772 if (!SYN_CAP_INTERTOUCH(info.ext_cap_0c))
1773 return -ENXIO;
1774
1775 return synaptics_create_intertouch(psmouse, &info, false);
1776}
1777
1778#else /* CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */
1779
1780static int __maybe_unused
1781synaptics_setup_intertouch(struct psmouse *psmouse,
1782 struct synaptics_device_info *info,
1783 bool leave_breadcrumbs)
1784{
1785 return -ENOSYS;
1786}
1787
1788int synaptics_init_smbus(struct psmouse *psmouse)
1789{
1790 return -ENOSYS;
1791}
1792
1793#endif /* CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */
1794
1795#if defined(CONFIG_MOUSE_PS2_SYNAPTICS) || \
1796 defined(CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS)
1797
1798int synaptics_init(struct psmouse *psmouse)
1799{
1800 struct synaptics_device_info info;
1801 int error;
1802 int retval;
1803
1804 psmouse_reset(psmouse);
1805
1806 error = synaptics_query_hardware(psmouse, &info);
1807 if (error) {
1808 psmouse_err(psmouse, "Unable to query device: %d\n", error);
1809 return error;
1810 }
1811
1812 if (SYN_CAP_INTERTOUCH(info.ext_cap_0c)) {
1813 error = synaptics_setup_intertouch(psmouse, &info, true);
1814 if (!error)
1815 return PSMOUSE_SYNAPTICS_SMBUS;
1816 }
1817
1818 retval = synaptics_setup_ps2(psmouse, &info);
1819 if (retval < 0) {
1820 /*
1821 * Not using any flavor of Synaptics support, so clean up
1822 * SMbus breadcrumbs, if any.
1823 */
1824 psmouse_smbus_cleanup(psmouse);
1825 }
1826
1827 return retval;
1828}
1829
1830#else /* CONFIG_MOUSE_PS2_SYNAPTICS || CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */
1831
1832int synaptics_init(struct psmouse *psmouse)
1833{
1834 return -ENOSYS;
1835}
1836
1837#endif /* CONFIG_MOUSE_PS2_SYNAPTICS || CONFIG_MOUSE_PS2_SYNAPTICS_SMBUS */
diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
index 116ae2546ace..fc00e005c611 100644
--- a/drivers/input/mouse/synaptics.h
+++ b/drivers/input/mouse/synaptics.h
@@ -25,36 +25,37 @@
25#define SYN_QUE_MEXT_CAPAB_10 0x10 25#define SYN_QUE_MEXT_CAPAB_10 0x10
26 26
27/* synatics modes */ 27/* synatics modes */
28#define SYN_BIT_ABSOLUTE_MODE (1 << 7) 28#define SYN_BIT_ABSOLUTE_MODE BIT(7)
29#define SYN_BIT_HIGH_RATE (1 << 6) 29#define SYN_BIT_HIGH_RATE BIT(6)
30#define SYN_BIT_SLEEP_MODE (1 << 3) 30#define SYN_BIT_SLEEP_MODE BIT(3)
31#define SYN_BIT_DISABLE_GESTURE (1 << 2) 31#define SYN_BIT_DISABLE_GESTURE BIT(2)
32#define SYN_BIT_FOUR_BYTE_CLIENT (1 << 1) 32#define SYN_BIT_FOUR_BYTE_CLIENT BIT(1)
33#define SYN_BIT_W_MODE (1 << 0) 33#define SYN_BIT_W_MODE BIT(0)
34 34
35/* synaptics model ID bits */ 35/* synaptics model ID bits */
36#define SYN_MODEL_ROT180(m) ((m) & (1 << 23)) 36#define SYN_MODEL_ROT180(m) ((m) & BIT(23))
37#define SYN_MODEL_PORTRAIT(m) ((m) & (1 << 22)) 37#define SYN_MODEL_PORTRAIT(m) ((m) & BIT(22))
38#define SYN_MODEL_SENSOR(m) (((m) >> 16) & 0x3f) 38#define SYN_MODEL_SENSOR(m) (((m) & GENMASK(21, 16)) >> 16)
39#define SYN_MODEL_HARDWARE(m) (((m) >> 9) & 0x7f) 39#define SYN_MODEL_HARDWARE(m) (((m) & GENMASK(15, 9)) >> 9)
40#define SYN_MODEL_NEWABS(m) ((m) & (1 << 7)) 40#define SYN_MODEL_NEWABS(m) ((m) & BIT(7))
41#define SYN_MODEL_PEN(m) ((m) & (1 << 6)) 41#define SYN_MODEL_PEN(m) ((m) & BIT(6))
42#define SYN_MODEL_SIMPLIC(m) ((m) & (1 << 5)) 42#define SYN_MODEL_SIMPLIC(m) ((m) & BIT(5))
43#define SYN_MODEL_GEOMETRY(m) ((m) & 0x0f) 43#define SYN_MODEL_GEOMETRY(m) ((m) & GENMASK(3, 0))
44 44
45/* synaptics capability bits */ 45/* synaptics capability bits */
46#define SYN_CAP_EXTENDED(c) ((c) & (1 << 23)) 46#define SYN_CAP_EXTENDED(c) ((c) & BIT(23))
47#define SYN_CAP_MIDDLE_BUTTON(c) ((c) & (1 << 18)) 47#define SYN_CAP_MIDDLE_BUTTON(c) ((c) & BIT(18))
48#define SYN_CAP_PASS_THROUGH(c) ((c) & (1 << 7)) 48#define SYN_CAP_PASS_THROUGH(c) ((c) & BIT(7))
49#define SYN_CAP_SLEEP(c) ((c) & (1 << 4)) 49#define SYN_CAP_SLEEP(c) ((c) & BIT(4))
50#define SYN_CAP_FOUR_BUTTON(c) ((c) & (1 << 3)) 50#define SYN_CAP_FOUR_BUTTON(c) ((c) & BIT(3))
51#define SYN_CAP_MULTIFINGER(c) ((c) & (1 << 1)) 51#define SYN_CAP_MULTIFINGER(c) ((c) & BIT(1))
52#define SYN_CAP_PALMDETECT(c) ((c) & (1 << 0)) 52#define SYN_CAP_PALMDETECT(c) ((c) & BIT(0))
53#define SYN_CAP_SUBMODEL_ID(c) (((c) & 0x00ff00) >> 8) 53#define SYN_CAP_SUBMODEL_ID(c) (((c) & GENMASK(15, 8)) >> 8)
54#define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) 54#define SYN_EXT_CAP_REQUESTS(c) (((c) & GENMASK(22, 20)) >> 20)
55#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) 55#define SYN_CAP_MB_MASK GENMASK(15, 12)
56#define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) 56#define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & SYN_CAP_MB_MASK) >> 12)
57#define SYN_MEXT_CAP_BIT(m) ((m) & (1 << 1)) 57#define SYN_CAP_PRODUCT_ID(ec) (((ec) & GENMASK(23, 16)) >> 16)
58#define SYN_MEXT_CAP_BIT(m) ((m) & BIT(1))
58 59
59/* 60/*
60 * The following describes response for the 0x0c query. 61 * The following describes response for the 0x0c query.
@@ -83,13 +84,14 @@
83 * hinged at the top. 84 * hinged at the top.
84 * 2 0x20 report min query 0x0f gives min coord reported 85 * 2 0x20 report min query 0x0f gives min coord reported
85 */ 86 */
86#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100000) /* 1-button ClickPad */ 87#define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & BIT(20)) /* 1-button ClickPad */
87#define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100) /* 2-button ClickPad */ 88#define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & BIT(8)) /* 2-button ClickPad */
88#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000) 89#define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & BIT(17))
89#define SYN_CAP_MIN_DIMENSIONS(ex0c) ((ex0c) & 0x002000) 90#define SYN_CAP_MIN_DIMENSIONS(ex0c) ((ex0c) & BIT(13))
90#define SYN_CAP_ADV_GESTURE(ex0c) ((ex0c) & 0x080000) 91#define SYN_CAP_ADV_GESTURE(ex0c) ((ex0c) & BIT(19))
91#define SYN_CAP_REDUCED_FILTERING(ex0c) ((ex0c) & 0x000400) 92#define SYN_CAP_REDUCED_FILTERING(ex0c) ((ex0c) & BIT(10))
92#define SYN_CAP_IMAGE_SENSOR(ex0c) ((ex0c) & 0x000800) 93#define SYN_CAP_IMAGE_SENSOR(ex0c) ((ex0c) & BIT(11))
94#define SYN_CAP_INTERTOUCH(ex0c) ((ex0c) & BIT(14))
93 95
94/* 96/*
95 * The following descibes response for the 0x10 query. 97 * The following descibes response for the 0x10 query.
@@ -108,42 +110,44 @@
108 * 3 0xff SecurePad height the height of the SecurePad fingerprint 110 * 3 0xff SecurePad height the height of the SecurePad fingerprint
109 * reader. 111 * reader.
110 */ 112 */
111#define SYN_CAP_EXT_BUTTONS_STICK(ex10) ((ex10) & 0x010000) 113#define SYN_CAP_EXT_BUTTONS_STICK(ex10) ((ex10) & BIT(16))
112#define SYN_CAP_SECUREPAD(ex10) ((ex10) & 0x020000) 114#define SYN_CAP_SECUREPAD(ex10) ((ex10) & BIT(17))
113 115
114#define SYN_CAP_EXT_BUTTON_STICK_L(eb) (!!((eb) & 0x01)) 116#define SYN_EXT_BUTTON_STICK_L(eb) (((eb) & BIT(0)) >> 0)
115#define SYN_CAP_EXT_BUTTON_STICK_M(eb) (!!((eb) & 0x02)) 117#define SYN_EXT_BUTTON_STICK_M(eb) (((eb) & BIT(1)) >> 1)
116#define SYN_CAP_EXT_BUTTON_STICK_R(eb) (!!((eb) & 0x04)) 118#define SYN_EXT_BUTTON_STICK_R(eb) (((eb) & BIT(2)) >> 2)
117 119
118/* synaptics modes query bits */ 120/* synaptics modes query bits */
119#define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7)) 121#define SYN_MODE_ABSOLUTE(m) ((m) & BIT(7))
120#define SYN_MODE_RATE(m) ((m) & (1 << 6)) 122#define SYN_MODE_RATE(m) ((m) & BIT(6))
121#define SYN_MODE_BAUD_SLEEP(m) ((m) & (1 << 3)) 123#define SYN_MODE_BAUD_SLEEP(m) ((m) & BIT(3))
122#define SYN_MODE_DISABLE_GESTURE(m) ((m) & (1 << 2)) 124#define SYN_MODE_DISABLE_GESTURE(m) ((m) & BIT(2))
123#define SYN_MODE_PACKSIZE(m) ((m) & (1 << 1)) 125#define SYN_MODE_PACKSIZE(m) ((m) & BIT(1))
124#define SYN_MODE_WMODE(m) ((m) & (1 << 0)) 126#define SYN_MODE_WMODE(m) ((m) & BIT(0))
125 127
126/* synaptics identify query bits */ 128/* synaptics identify query bits */
127#define SYN_ID_MODEL(i) (((i) >> 4) & 0x0f) 129#define SYN_ID_MODEL(i) (((i) & GENMASK(7, 4)) >> 4)
128#define SYN_ID_MAJOR(i) ((i) & 0x0f) 130#define SYN_ID_MAJOR(i) (((i) & GENMASK(3, 0)) >> 0)
129#define SYN_ID_MINOR(i) (((i) >> 16) & 0xff) 131#define SYN_ID_MINOR(i) (((i) & GENMASK(23, 16)) >> 16)
130#define SYN_ID_FULL(i) ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i)) 132#define SYN_ID_FULL(i) ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i))
131#define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47) 133#define SYN_ID_IS_SYNAPTICS(i) (((i) & GENMASK(15, 8)) == 0x004700U)
132#define SYN_ID_DISGEST_SUPPORTED(i) (SYN_ID_MAJOR(i) >= 4) 134#define SYN_ID_DISGEST_SUPPORTED(i) (SYN_ID_MAJOR(i) >= 4)
133 135
134/* synaptics special commands */ 136/* synaptics special commands */
135#define SYN_PS_SET_MODE2 0x14 137#define SYN_PS_SET_MODE2 0x14
136#define SYN_PS_CLIENT_CMD 0x28 138#define SYN_PS_CLIENT_CMD 0x28
137 139
138/* synaptics packet types */
139#define SYN_NEWABS 0
140#define SYN_NEWABS_STRICT 1
141#define SYN_NEWABS_RELAXED 2
142#define SYN_OLDABS 3
143
144/* amount to fuzz position data when touchpad reports reduced filtering */ 140/* amount to fuzz position data when touchpad reports reduced filtering */
145#define SYN_REDUCED_FILTER_FUZZ 8 141#define SYN_REDUCED_FILTER_FUZZ 8
146 142
143/* synaptics packet types */
144enum synaptics_pkt_type {
145 SYN_NEWABS,
146 SYN_NEWABS_STRICT,
147 SYN_NEWABS_RELAXED,
148 SYN_OLDABS,
149};
150
147/* 151/*
148 * A structure to describe the state of the touchpad hardware (buttons and pad) 152 * A structure to describe the state of the touchpad hardware (buttons and pad)
149 */ 153 */
@@ -157,26 +161,30 @@ struct synaptics_hw_state {
157 unsigned int middle:1; 161 unsigned int middle:1;
158 unsigned int up:1; 162 unsigned int up:1;
159 unsigned int down:1; 163 unsigned int down:1;
160 unsigned char ext_buttons; 164 u8 ext_buttons;
161 signed char scroll; 165 s8 scroll;
166};
167
168/* Data read from the touchpad */
169struct synaptics_device_info {
170 u32 model_id; /* Model-ID */
171 u32 firmware_id; /* Firmware-ID */
172 u32 board_id; /* Board-ID */
173 u32 capabilities; /* Capabilities */
174 u32 ext_cap; /* Extended Capabilities */
175 u32 ext_cap_0c; /* Ext Caps from 0x0c query */
176 u32 ext_cap_10; /* Ext Caps from 0x10 query */
177 u32 identity; /* Identification */
178 u32 x_res, y_res; /* X/Y resolution in units/mm */
179 u32 x_max, y_max; /* Max coordinates (from FW) */
180 u32 x_min, y_min; /* Min coordinates (from FW) */
162}; 181};
163 182
164struct synaptics_data { 183struct synaptics_data {
165 /* Data read from the touchpad */ 184 struct synaptics_device_info info;
166 unsigned long int model_id; /* Model-ID */ 185
167 unsigned long int firmware_id; /* Firmware-ID */ 186 enum synaptics_pkt_type pkt_type; /* packet type - old, new, etc */
168 unsigned long int board_id; /* Board-ID */ 187 u8 mode; /* current mode byte */
169 unsigned long int capabilities; /* Capabilities */
170 unsigned long int ext_cap; /* Extended Capabilities */
171 unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */
172 unsigned long int ext_cap_10; /* Ext Caps from 0x10 query */
173 unsigned long int identity; /* Identification */
174 unsigned int x_res, y_res; /* X/Y resolution in units/mm */
175 unsigned int x_max, y_max; /* Max coordinates (from FW) */
176 unsigned int x_min, y_min; /* Min coordinates (from FW) */
177
178 unsigned char pkt_type; /* packet type - old, new, etc */
179 unsigned char mode; /* current mode byte */
180 int scroll; 188 int scroll;
181 189
182 bool absolute_mode; /* run in Absolute mode */ 190 bool absolute_mode; /* run in Absolute mode */
@@ -200,8 +208,10 @@ struct synaptics_data {
200 208
201void synaptics_module_init(void); 209void synaptics_module_init(void);
202int synaptics_detect(struct psmouse *psmouse, bool set_properties); 210int synaptics_detect(struct psmouse *psmouse, bool set_properties);
203int synaptics_init(struct psmouse *psmouse); 211int synaptics_init_absolute(struct psmouse *psmouse);
204int synaptics_init_relative(struct psmouse *psmouse); 212int synaptics_init_relative(struct psmouse *psmouse);
213int synaptics_init_smbus(struct psmouse *psmouse);
214int synaptics_init(struct psmouse *psmouse);
205void synaptics_reset(struct psmouse *psmouse); 215void synaptics_reset(struct psmouse *psmouse);
206 216
207#endif /* _SYNAPTICS_H */ 217#endif /* _SYNAPTICS_H */
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
index cb2bf203f4ca..8538318d332c 100644
--- a/drivers/input/mouse/synaptics_i2c.c
+++ b/drivers/input/mouse/synaptics_i2c.c
@@ -652,9 +652,18 @@ static const struct i2c_device_id synaptics_i2c_id_table[] = {
652}; 652};
653MODULE_DEVICE_TABLE(i2c, synaptics_i2c_id_table); 653MODULE_DEVICE_TABLE(i2c, synaptics_i2c_id_table);
654 654
655#ifdef CONFIG_OF
656static const struct of_device_id synaptics_i2c_of_match[] = {
657 { .compatible = "synaptics,synaptics_i2c", },
658 { },
659};
660MODULE_DEVICE_TABLE(of, synaptics_i2c_of_match);
661#endif
662
655static struct i2c_driver synaptics_i2c_driver = { 663static struct i2c_driver synaptics_i2c_driver = {
656 .driver = { 664 .driver = {
657 .name = DRIVER_NAME, 665 .name = DRIVER_NAME,
666 .of_match_table = of_match_ptr(synaptics_i2c_of_match),
658 .pm = &synaptics_i2c_pm, 667 .pm = &synaptics_i2c_pm,
659 }, 668 },
660 669
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index d64fc92858f2..4f2bb5947a4e 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -251,7 +251,7 @@ static int rmi_irq_init(struct rmi_device *rmi_dev)
251 251
252 ret = devm_request_threaded_irq(&rmi_dev->dev, pdata->irq, NULL, 252 ret = devm_request_threaded_irq(&rmi_dev->dev, pdata->irq, NULL,
253 rmi_irq_fn, irq_flags | IRQF_ONESHOT, 253 rmi_irq_fn, irq_flags | IRQF_ONESHOT,
254 dev_name(rmi_dev->xport->dev), 254 dev_driver_string(rmi_dev->xport->dev),
255 rmi_dev); 255 rmi_dev);
256 if (ret < 0) { 256 if (ret < 0) {
257 dev_err(&rmi_dev->dev, "Failed to register interrupt %d\n", 257 dev_err(&rmi_dev->dev, "Failed to register interrupt %d\n",
@@ -1234,16 +1234,21 @@ static int rmi_driver_probe(struct device *dev)
1234 if (retval < 0) 1234 if (retval < 0)
1235 goto err_destroy_functions; 1235 goto err_destroy_functions;
1236 1236
1237 if (data->f01_container->dev.driver) 1237 if (data->f01_container->dev.driver) {
1238 /* Driver already bound, so enable ATTN now. */ 1238 /* Driver already bound, so enable ATTN now. */
1239 return rmi_enable_sensor(rmi_dev); 1239 retval = rmi_enable_sensor(rmi_dev);
1240 if (retval)
1241 goto err_disable_irq;
1242 }
1240 1243
1241 return 0; 1244 return 0;
1242 1245
1246err_disable_irq:
1247 rmi_disable_irq(rmi_dev, false);
1243err_destroy_functions: 1248err_destroy_functions:
1244 rmi_free_function_list(rmi_dev); 1249 rmi_free_function_list(rmi_dev);
1245err: 1250err:
1246 return retval < 0 ? retval : 0; 1251 return retval;
1247} 1252}
1248 1253
1249static struct rmi_driver rmi_physical_driver = { 1254static struct rmi_driver rmi_physical_driver = {
diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c
index 07aff4356fe0..8b0db086d68a 100644
--- a/drivers/input/rmi4/rmi_f12.c
+++ b/drivers/input/rmi4/rmi_f12.c
@@ -113,20 +113,16 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)
113 } 113 }
114 114
115 if (rmi_register_desc_has_subpacket(item, 2)) { 115 if (rmi_register_desc_has_subpacket(item, 2)) {
116 sensor->axis_align.clip_x_low = buf[offset]; 116 /* Units 1/128 sensor pitch */
117 sensor->axis_align.clip_x_high = sensor->max_x 117 rmi_dbg(RMI_DEBUG_FN, &fn->dev,
118 - buf[offset + 1]; 118 "%s: Inactive Border xlo:%d xhi:%d ylo:%d yhi:%d\n",
119 sensor->axis_align.clip_y_low = buf[offset + 2]; 119 __func__,
120 sensor->axis_align.clip_y_high = sensor->max_y 120 buf[offset], buf[offset + 1],
121 - buf[offset + 3]; 121 buf[offset + 2], buf[offset + 3]);
122
122 offset += 4; 123 offset += 4;
123 } 124 }
124 125
125 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: x low: %d x high: %d y low: %d y high: %d\n",
126 __func__,
127 sensor->axis_align.clip_x_low, sensor->axis_align.clip_x_high,
128 sensor->axis_align.clip_y_low, sensor->axis_align.clip_y_high);
129
130 if (rmi_register_desc_has_subpacket(item, 3)) { 126 if (rmi_register_desc_has_subpacket(item, 3)) {
131 rx_receivers = buf[offset]; 127 rx_receivers = buf[offset];
132 tx_receivers = buf[offset + 1]; 128 tx_receivers = buf[offset + 1];
diff --git a/drivers/input/rmi4/rmi_f34.c b/drivers/input/rmi4/rmi_f34.c
index 425fe140e9df..b8ee78e0d61f 100644
--- a/drivers/input/rmi4/rmi_f34.c
+++ b/drivers/input/rmi4/rmi_f34.c
@@ -105,16 +105,27 @@ static int rmi_f34_attention(struct rmi_function *fn, unsigned long *irq_bits)
105{ 105{
106 struct f34_data *f34 = dev_get_drvdata(&fn->dev); 106 struct f34_data *f34 = dev_get_drvdata(&fn->dev);
107 int ret; 107 int ret;
108 u8 status;
108 109
109 if (f34->bl_version != 5) 110 if (f34->bl_version == 5) {
110 return 0; 111 ret = rmi_read(f34->fn->rmi_dev, f34->v5.ctrl_address,
112 &status);
113 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n",
114 __func__, status, ret);
111 115
112 ret = rmi_read(f34->fn->rmi_dev, f34->v5.ctrl_address, &f34->v5.status); 116 if (!ret && !(status & 0x7f))
113 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n", 117 complete(&f34->v5.cmd_done);
114 __func__, f34->v5.status, ret); 118 } else {
115 119 ret = rmi_read_block(f34->fn->rmi_dev,
116 if (!ret && !(f34->v5.status & 0x7f)) 120 f34->fn->fd.data_base_addr +
117 complete(&f34->v5.cmd_done); 121 f34->v7.off.flash_status,
122 &status, sizeof(status));
123 rmi_dbg(RMI_DEBUG_FN, &fn->dev, "%s: status: %#02x, ret: %d\n",
124 __func__, status, ret);
125
126 if (!ret && !(status & 0x1f))
127 complete(&f34->v7.cmd_done);
128 }
118 129
119 return 0; 130 return 0;
120} 131}
diff --git a/drivers/input/rmi4/rmi_f34.h b/drivers/input/rmi4/rmi_f34.h
index 43a91349b28d..32c4e9581c68 100644
--- a/drivers/input/rmi4/rmi_f34.h
+++ b/drivers/input/rmi4/rmi_f34.h
@@ -30,6 +30,7 @@
30#define F34_IDLE_WAIT_MS 500 30#define F34_IDLE_WAIT_MS 500
31#define F34_ENABLE_WAIT_MS 300 31#define F34_ENABLE_WAIT_MS 300
32#define F34_ERASE_WAIT_MS 5000 32#define F34_ERASE_WAIT_MS 5000
33#define F34_WRITE_WAIT_MS 3000
33 34
34#define F34_BOOTLOADER_ID_LEN 2 35#define F34_BOOTLOADER_ID_LEN 2
35 36
@@ -47,11 +48,6 @@
47#define CONFIG_ID_SIZE 32 48#define CONFIG_ID_SIZE 32
48#define PRODUCT_ID_SIZE 10 49#define PRODUCT_ID_SIZE 10
49 50
50#define ENABLE_WAIT_MS (1 * 1000)
51#define WRITE_WAIT_MS (3 * 1000)
52
53#define MIN_SLEEP_TIME_US 50
54#define MAX_SLEEP_TIME_US 100
55 51
56#define HAS_BSR BIT(5) 52#define HAS_BSR BIT(5)
57#define HAS_CONFIG_ID BIT(3) 53#define HAS_CONFIG_ID BIT(3)
@@ -292,6 +288,7 @@ struct f34v7_data {
292 288
293 const void *config_data; 289 const void *config_data;
294 const void *image; 290 const void *image;
291 struct completion cmd_done;
295}; 292};
296 293
297struct f34_data { 294struct f34_data {
diff --git a/drivers/input/rmi4/rmi_f34v7.c b/drivers/input/rmi4/rmi_f34v7.c
index 56c6c39ad31e..10c0d11b72c9 100644
--- a/drivers/input/rmi4/rmi_f34v7.c
+++ b/drivers/input/rmi4/rmi_f34v7.c
@@ -15,6 +15,7 @@
15#include <asm/unaligned.h> 15#include <asm/unaligned.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/jiffies.h>
18 19
19#include "rmi_driver.h" 20#include "rmi_driver.h"
20#include "rmi_f34.h" 21#include "rmi_f34.h"
@@ -31,7 +32,7 @@ static int rmi_f34v7_read_flash_status(struct f34_data *f34)
31 sizeof(status)); 32 sizeof(status));
32 if (ret < 0) { 33 if (ret < 0) {
33 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, 34 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
34 "%s: Failed to read flash status\n", __func__); 35 "%s: Error %d reading flash status\n", __func__, ret);
35 return ret; 36 return ret;
36 } 37 }
37 38
@@ -60,28 +61,17 @@ static int rmi_f34v7_read_flash_status(struct f34_data *f34)
60 61
61static int rmi_f34v7_wait_for_idle(struct f34_data *f34, int timeout_ms) 62static int rmi_f34v7_wait_for_idle(struct f34_data *f34, int timeout_ms)
62{ 63{
63 int count = 0; 64 unsigned long timeout;
64 int timeout_count = ((timeout_ms * 1000) / MAX_SLEEP_TIME_US) + 1;
65 65
66 do { 66 timeout = msecs_to_jiffies(timeout_ms);
67 usleep_range(MIN_SLEEP_TIME_US, MAX_SLEEP_TIME_US);
68
69 count++;
70
71 rmi_f34v7_read_flash_status(f34);
72
73 if ((f34->v7.command == v7_CMD_IDLE)
74 && (f34->v7.flash_status == 0x00)) {
75 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
76 "Idle status detected\n");
77 return 0;
78 }
79 } while (count < timeout_count);
80 67
81 dev_err(&f34->fn->dev, 68 if (!wait_for_completion_timeout(&f34->v7.cmd_done, timeout)) {
82 "%s: Timed out waiting for idle status\n", __func__); 69 dev_warn(&f34->fn->dev, "%s: Timed out waiting for idle status\n",
70 __func__);
71 return -ETIMEDOUT;
72 }
83 73
84 return -ETIMEDOUT; 74 return 0;
85} 75}
86 76
87static int rmi_f34v7_write_command_single_transaction(struct f34_data *f34, 77static int rmi_f34v7_write_command_single_transaction(struct f34_data *f34,
@@ -285,9 +275,10 @@ static int rmi_f34v7_write_partition_id(struct f34_data *f34, u8 cmd)
285 return 0; 275 return 0;
286} 276}
287 277
288static int rmi_f34v7_read_f34v7_partition_table(struct f34_data *f34) 278static int rmi_f34v7_read_partition_table(struct f34_data *f34)
289{ 279{
290 int ret; 280 int ret;
281 unsigned long timeout;
291 u8 base; 282 u8 base;
292 __le16 length; 283 __le16 length;
293 u16 block_number = 0; 284 u16 block_number = 0;
@@ -320,6 +311,8 @@ static int rmi_f34v7_read_f34v7_partition_table(struct f34_data *f34)
320 return ret; 311 return ret;
321 } 312 }
322 313
314 init_completion(&f34->v7.cmd_done);
315
323 ret = rmi_f34v7_write_command(f34, v7_CMD_READ_CONFIG); 316 ret = rmi_f34v7_write_command(f34, v7_CMD_READ_CONFIG);
324 if (ret < 0) { 317 if (ret < 0) {
325 dev_err(&f34->fn->dev, "%s: Failed to write command\n", 318 dev_err(&f34->fn->dev, "%s: Failed to write command\n",
@@ -327,11 +320,15 @@ static int rmi_f34v7_read_f34v7_partition_table(struct f34_data *f34)
327 return ret; 320 return ret;
328 } 321 }
329 322
330 ret = rmi_f34v7_wait_for_idle(f34, WRITE_WAIT_MS); 323 timeout = msecs_to_jiffies(F34_WRITE_WAIT_MS);
331 if (ret < 0) { 324 while (time_before(jiffies, timeout)) {
332 dev_err(&f34->fn->dev, "%s: Failed to wait for idle status\n", 325 usleep_range(5000, 6000);
333 __func__); 326 rmi_f34v7_read_flash_status(f34);
334 return ret; 327
328 if (f34->v7.command == v7_CMD_IDLE &&
329 f34->v7.flash_status == 0x00) {
330 break;
331 }
335 } 332 }
336 333
337 ret = rmi_read_block(f34->fn->rmi_dev, 334 ret = rmi_read_block(f34->fn->rmi_dev,
@@ -570,7 +567,7 @@ static int rmi_f34v7_read_queries(struct f34_data *f34)
570 f34->v7.read_config_buf_size = f34->v7.partition_table_bytes; 567 f34->v7.read_config_buf_size = f34->v7.partition_table_bytes;
571 ptable = f34->v7.read_config_buf; 568 ptable = f34->v7.read_config_buf;
572 569
573 ret = rmi_f34v7_read_f34v7_partition_table(f34); 570 ret = rmi_f34v7_read_partition_table(f34);
574 if (ret < 0) { 571 if (ret < 0) {
575 dev_err(&f34->fn->dev, "%s: Failed to read partition table\n", 572 dev_err(&f34->fn->dev, "%s: Failed to read partition table\n",
576 __func__); 573 __func__);
@@ -666,6 +663,8 @@ static int rmi_f34v7_erase_config(struct f34_data *f34)
666 663
667 dev_info(&f34->fn->dev, "Erasing config...\n"); 664 dev_info(&f34->fn->dev, "Erasing config...\n");
668 665
666 init_completion(&f34->v7.cmd_done);
667
669 switch (f34->v7.config_area) { 668 switch (f34->v7.config_area) {
670 case v7_UI_CONFIG_AREA: 669 case v7_UI_CONFIG_AREA:
671 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_CONFIG); 670 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_CONFIG);
@@ -684,11 +683,11 @@ static int rmi_f34v7_erase_config(struct f34_data *f34)
684 break; 683 break;
685 } 684 }
686 685
687 ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS); 686 ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS);
688 if (ret < 0) 687 if (ret < 0)
689 return ret; 688 return ret;
690 689
691 return ret; 690 return 0;
692} 691}
693 692
694static int rmi_f34v7_erase_guest_code(struct f34_data *f34) 693static int rmi_f34v7_erase_guest_code(struct f34_data *f34)
@@ -697,11 +696,13 @@ static int rmi_f34v7_erase_guest_code(struct f34_data *f34)
697 696
698 dev_info(&f34->fn->dev, "Erasing guest code...\n"); 697 dev_info(&f34->fn->dev, "Erasing guest code...\n");
699 698
699 init_completion(&f34->v7.cmd_done);
700
700 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_GUEST_CODE); 701 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_GUEST_CODE);
701 if (ret < 0) 702 if (ret < 0)
702 return ret; 703 return ret;
703 704
704 ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS); 705 ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS);
705 if (ret < 0) 706 if (ret < 0)
706 return ret; 707 return ret;
707 708
@@ -714,11 +715,13 @@ static int rmi_f34v7_erase_all(struct f34_data *f34)
714 715
715 dev_info(&f34->fn->dev, "Erasing firmware...\n"); 716 dev_info(&f34->fn->dev, "Erasing firmware...\n");
716 717
718 init_completion(&f34->v7.cmd_done);
719
717 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_FIRMWARE); 720 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_UI_FIRMWARE);
718 if (ret < 0) 721 if (ret < 0)
719 return ret; 722 return ret;
720 723
721 ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS); 724 ret = rmi_f34v7_wait_for_idle(f34, F34_ERASE_WAIT_MS);
722 if (ret < 0) 725 if (ret < 0)
723 return ret; 726 return ret;
724 727
@@ -743,8 +746,8 @@ static int rmi_f34v7_erase_all(struct f34_data *f34)
743 return 0; 746 return 0;
744} 747}
745 748
746static int rmi_f34v7_read_f34v7_blocks(struct f34_data *f34, u16 block_cnt, 749static int rmi_f34v7_read_blocks(struct f34_data *f34,
747 u8 command) 750 u16 block_cnt, u8 command)
748{ 751{
749 int ret; 752 int ret;
750 u8 base; 753 u8 base;
@@ -787,17 +790,15 @@ static int rmi_f34v7_read_f34v7_blocks(struct f34_data *f34, u16 block_cnt,
787 return ret; 790 return ret;
788 } 791 }
789 792
793 init_completion(&f34->v7.cmd_done);
794
790 ret = rmi_f34v7_write_command(f34, command); 795 ret = rmi_f34v7_write_command(f34, command);
791 if (ret < 0) 796 if (ret < 0)
792 return ret; 797 return ret;
793 798
794 ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS); 799 ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS);
795 if (ret < 0) { 800 if (ret < 0)
796 dev_err(&f34->fn->dev,
797 "%s: Wait for idle failed (%d blks remaining)\n",
798 __func__, remaining);
799 return ret; 801 return ret;
800 }
801 802
802 ret = rmi_read_block(f34->fn->rmi_dev, 803 ret = rmi_read_block(f34->fn->rmi_dev,
803 base + f34->v7.off.payload, 804 base + f34->v7.off.payload,
@@ -853,6 +854,8 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
853 transfer = min(remaining, max_transfer); 854 transfer = min(remaining, max_transfer);
854 put_unaligned_le16(transfer, &length); 855 put_unaligned_le16(transfer, &length);
855 856
857 init_completion(&f34->v7.cmd_done);
858
856 ret = rmi_write_block(f34->fn->rmi_dev, 859 ret = rmi_write_block(f34->fn->rmi_dev,
857 base + f34->v7.off.transfer_length, 860 base + f34->v7.off.transfer_length,
858 &length, sizeof(length)); 861 &length, sizeof(length));
@@ -877,13 +880,9 @@ static int rmi_f34v7_write_f34v7_blocks(struct f34_data *f34,
877 return ret; 880 return ret;
878 } 881 }
879 882
880 ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS); 883 ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS);
881 if (ret < 0) { 884 if (ret < 0)
882 dev_err(&f34->fn->dev,
883 "%s: Failed wait for idle (%d blks remaining)\n",
884 __func__, remaining);
885 return ret; 885 return ret;
886 }
887 886
888 block_ptr += (transfer * f34->v7.block_size); 887 block_ptr += (transfer * f34->v7.block_size);
889 remaining -= transfer; 888 remaining -= transfer;
@@ -945,6 +944,8 @@ static int rmi_f34v7_write_flash_config(struct f34_data *f34)
945 return -EINVAL; 944 return -EINVAL;
946 } 945 }
947 946
947 init_completion(&f34->v7.cmd_done);
948
948 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_FLASH_CONFIG); 949 ret = rmi_f34v7_write_command(f34, v7_CMD_ERASE_FLASH_CONFIG);
949 if (ret < 0) 950 if (ret < 0)
950 return ret; 951 return ret;
@@ -952,7 +953,7 @@ static int rmi_f34v7_write_flash_config(struct f34_data *f34)
952 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev, 953 rmi_dbg(RMI_DEBUG_FN, &f34->fn->dev,
953 "%s: Erase flash config command written\n", __func__); 954 "%s: Erase flash config command written\n", __func__);
954 955
955 ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS); 956 ret = rmi_f34v7_wait_for_idle(f34, F34_WRITE_WAIT_MS);
956 if (ret < 0) 957 if (ret < 0)
957 return ret; 958 return ret;
958 959
@@ -981,7 +982,7 @@ static int rmi_f34v7_write_partition_table(struct f34_data *f34)
981 982
982 f34->v7.read_config_buf_size = f34->v7.config_size; 983 f34->v7.read_config_buf_size = f34->v7.config_size;
983 984
984 ret = rmi_f34v7_read_f34v7_blocks(f34, block_count, v7_CMD_READ_CONFIG); 985 ret = rmi_f34v7_read_blocks(f34, block_count, v7_CMD_READ_CONFIG);
985 if (ret < 0) 986 if (ret < 0)
986 return ret; 987 return ret;
987 988
@@ -1287,6 +1288,8 @@ static int rmi_f34v7_enter_flash_prog(struct f34_data *f34)
1287{ 1288{
1288 int ret; 1289 int ret;
1289 1290
1291 f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask);
1292
1290 ret = rmi_f34v7_read_flash_status(f34); 1293 ret = rmi_f34v7_read_flash_status(f34);
1291 if (ret < 0) 1294 if (ret < 0)
1292 return ret; 1295 return ret;
@@ -1294,19 +1297,16 @@ static int rmi_f34v7_enter_flash_prog(struct f34_data *f34)
1294 if (f34->v7.in_bl_mode) 1297 if (f34->v7.in_bl_mode)
1295 return 0; 1298 return 0;
1296 1299
1300 init_completion(&f34->v7.cmd_done);
1301
1297 ret = rmi_f34v7_write_command(f34, v7_CMD_ENABLE_FLASH_PROG); 1302 ret = rmi_f34v7_write_command(f34, v7_CMD_ENABLE_FLASH_PROG);
1298 if (ret < 0) 1303 if (ret < 0)
1299 return ret; 1304 return ret;
1300 1305
1301 ret = rmi_f34v7_wait_for_idle(f34, ENABLE_WAIT_MS); 1306 ret = rmi_f34v7_wait_for_idle(f34, F34_ENABLE_WAIT_MS);
1302 if (ret < 0) 1307 if (ret < 0)
1303 return ret; 1308 return ret;
1304 1309
1305 if (!f34->v7.in_bl_mode) {
1306 dev_err(&f34->fn->dev, "%s: BL mode not entered\n", __func__);
1307 return -EINVAL;
1308 }
1309
1310 return 0; 1310 return 0;
1311} 1311}
1312 1312
@@ -1314,6 +1314,8 @@ int rmi_f34v7_start_reflash(struct f34_data *f34, const struct firmware *fw)
1314{ 1314{
1315 int ret = 0; 1315 int ret = 0;
1316 1316
1317 f34->fn->rmi_dev->driver->set_irq_bits(f34->fn->rmi_dev, f34->fn->irq_mask);
1318
1317 f34->v7.config_area = v7_UI_CONFIG_AREA; 1319 f34->v7.config_area = v7_UI_CONFIG_AREA;
1318 f34->v7.image = fw->data; 1320 f34->v7.image = fw->data;
1319 1321
@@ -1376,8 +1378,13 @@ int rmi_f34v7_probe(struct f34_data *f34)
1376 1378
1377 memset(&f34->v7.blkcount, 0x00, sizeof(f34->v7.blkcount)); 1379 memset(&f34->v7.blkcount, 0x00, sizeof(f34->v7.blkcount));
1378 memset(&f34->v7.phyaddr, 0x00, sizeof(f34->v7.phyaddr)); 1380 memset(&f34->v7.phyaddr, 0x00, sizeof(f34->v7.phyaddr));
1379 rmi_f34v7_read_queries(f34);
1380 1381
1381 f34->v7.force_update = false; 1382 init_completion(&f34->v7.cmd_done);
1383
1384 ret = rmi_f34v7_read_queries(f34);
1385 if (ret < 0)
1386 return ret;
1387
1388 f34->v7.force_update = true;
1382 return 0; 1389 return 0;
1383} 1390}
diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
index 082306d7c207..e28663ef9e5a 100644
--- a/drivers/input/rmi4/rmi_i2c.c
+++ b/drivers/input/rmi4/rmi_i2c.c
@@ -204,7 +204,7 @@ static int rmi_i2c_probe(struct i2c_client *client,
204 struct rmi_device_platform_data *client_pdata = 204 struct rmi_device_platform_data *client_pdata =
205 dev_get_platdata(&client->dev); 205 dev_get_platdata(&client->dev);
206 struct rmi_i2c_xport *rmi_i2c; 206 struct rmi_i2c_xport *rmi_i2c;
207 int retval; 207 int error;
208 208
209 rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport), 209 rmi_i2c = devm_kzalloc(&client->dev, sizeof(struct rmi_i2c_xport),
210 GFP_KERNEL); 210 GFP_KERNEL);
@@ -220,30 +220,31 @@ static int rmi_i2c_probe(struct i2c_client *client,
220 220
221 rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n", 221 rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n",
222 dev_name(&client->dev)); 222 dev_name(&client->dev));
223
223 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { 224 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
224 dev_err(&client->dev, 225 dev_err(&client->dev,
225 "adapter does not support required functionality.\n"); 226 "adapter does not support required functionality\n");
226 return -ENODEV; 227 return -ENODEV;
227 } 228 }
228 229
229 rmi_i2c->supplies[0].supply = "vdd"; 230 rmi_i2c->supplies[0].supply = "vdd";
230 rmi_i2c->supplies[1].supply = "vio"; 231 rmi_i2c->supplies[1].supply = "vio";
231 retval = devm_regulator_bulk_get(&client->dev, 232 error = devm_regulator_bulk_get(&client->dev,
232 ARRAY_SIZE(rmi_i2c->supplies), 233 ARRAY_SIZE(rmi_i2c->supplies),
233 rmi_i2c->supplies); 234 rmi_i2c->supplies);
234 if (retval < 0) 235 if (error < 0)
235 return retval; 236 return error;
236 237
237 retval = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), 238 error = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies),
238 rmi_i2c->supplies); 239 rmi_i2c->supplies);
239 if (retval < 0) 240 if (error < 0)
240 return retval; 241 return error;
241 242
242 retval = devm_add_action_or_reset(&client->dev, 243 error = devm_add_action_or_reset(&client->dev,
243 rmi_i2c_regulator_bulk_disable, 244 rmi_i2c_regulator_bulk_disable,
244 rmi_i2c); 245 rmi_i2c);
245 if (retval) 246 if (error)
246 return retval; 247 return error;
247 248
248 of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms", 249 of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms",
249 &rmi_i2c->startup_delay); 250 &rmi_i2c->startup_delay);
@@ -263,26 +264,26 @@ static int rmi_i2c_probe(struct i2c_client *client,
263 * Setting the page to zero will (a) make sure the PSR is in a 264 * Setting the page to zero will (a) make sure the PSR is in a
264 * known state, and (b) make sure we can talk to the device. 265 * known state, and (b) make sure we can talk to the device.
265 */ 266 */
266 retval = rmi_set_page(rmi_i2c, 0); 267 error = rmi_set_page(rmi_i2c, 0);
267 if (retval) { 268 if (error) {
268 dev_err(&client->dev, "Failed to set page select to 0.\n"); 269 dev_err(&client->dev, "Failed to set page select to 0\n");
269 return retval; 270 return error;
270 } 271 }
271 272
272 retval = rmi_register_transport_device(&rmi_i2c->xport); 273 dev_info(&client->dev, "registering I2C-connected sensor\n");
273 if (retval) { 274
274 dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n", 275 error = rmi_register_transport_device(&rmi_i2c->xport);
275 client->addr); 276 if (error) {
276 return retval; 277 dev_err(&client->dev, "failed to register sensor: %d\n", error);
278 return error;
277 } 279 }
278 retval = devm_add_action_or_reset(&client->dev, 280
281 error = devm_add_action_or_reset(&client->dev,
279 rmi_i2c_unregister_transport, 282 rmi_i2c_unregister_transport,
280 rmi_i2c); 283 rmi_i2c);
281 if (retval) 284 if (error)
282 return retval; 285 return error;
283 286
284 dev_info(&client->dev, "registered rmi i2c driver at %#04x.\n",
285 client->addr);
286 return 0; 287 return 0;
287} 288}
288 289
diff --git a/drivers/input/rmi4/rmi_smbus.c b/drivers/input/rmi4/rmi_smbus.c
index 76752555d809..225025a0940c 100644
--- a/drivers/input/rmi4/rmi_smbus.c
+++ b/drivers/input/rmi4/rmi_smbus.c
@@ -53,6 +53,7 @@ static int rmi_smb_get_version(struct rmi_smb_xport *rmi_smb)
53 dev_err(&client->dev, "failed to get SMBus version number!\n"); 53 dev_err(&client->dev, "failed to get SMBus version number!\n");
54 return retval; 54 return retval;
55 } 55 }
56
56 return retval + 1; 57 return retval + 1;
57} 58}
58 59
@@ -83,63 +84,56 @@ static int rmi_smb_get_command_code(struct rmi_transport_dev *xport,
83{ 84{
84 struct rmi_smb_xport *rmi_smb = 85 struct rmi_smb_xport *rmi_smb =
85 container_of(xport, struct rmi_smb_xport, xport); 86 container_of(xport, struct rmi_smb_xport, xport);
87 struct mapping_table_entry new_map;
86 int i; 88 int i;
87 int retval; 89 int retval = 0;
88 struct mapping_table_entry mapping_data[1];
89 90
90 mutex_lock(&rmi_smb->mappingtable_mutex); 91 mutex_lock(&rmi_smb->mappingtable_mutex);
92
91 for (i = 0; i < RMI_SMB2_MAP_SIZE; i++) { 93 for (i = 0; i < RMI_SMB2_MAP_SIZE; i++) {
92 if (rmi_smb->mapping_table[i].rmiaddr == rmiaddr) { 94 struct mapping_table_entry *entry = &rmi_smb->mapping_table[i];
95
96 if (le16_to_cpu(entry->rmiaddr) == rmiaddr) {
93 if (isread) { 97 if (isread) {
94 if (rmi_smb->mapping_table[i].readcount 98 if (entry->readcount == bytecount)
95 == bytecount) {
96 *commandcode = i;
97 retval = 0;
98 goto exit; 99 goto exit;
99 }
100 } else { 100 } else {
101 if (rmi_smb->mapping_table[i].flags & 101 if (entry->flags & RMI_SMB2_MAP_FLAGS_WE) {
102 RMI_SMB2_MAP_FLAGS_WE) {
103 *commandcode = i;
104 retval = 0;
105 goto exit; 102 goto exit;
106 } 103 }
107 } 104 }
108 } 105 }
109 } 106 }
107
110 i = rmi_smb->table_index; 108 i = rmi_smb->table_index;
111 rmi_smb->table_index = (i + 1) % RMI_SMB2_MAP_SIZE; 109 rmi_smb->table_index = (i + 1) % RMI_SMB2_MAP_SIZE;
112 110
113 /* constructs mapping table data entry. 4 bytes each entry */ 111 /* constructs mapping table data entry. 4 bytes each entry */
114 memset(mapping_data, 0, sizeof(mapping_data)); 112 memset(&new_map, 0, sizeof(new_map));
115 113 new_map.rmiaddr = cpu_to_le16(rmiaddr);
116 mapping_data[0].rmiaddr = cpu_to_le16(rmiaddr); 114 new_map.readcount = bytecount;
117 mapping_data[0].readcount = bytecount; 115 new_map.flags = !isread ? RMI_SMB2_MAP_FLAGS_WE : 0;
118 mapping_data[0].flags = !isread ? RMI_SMB2_MAP_FLAGS_WE : 0;
119
120 retval = smb_block_write(xport, i + 0x80, mapping_data,
121 sizeof(mapping_data));
122 116
117 retval = smb_block_write(xport, i + 0x80, &new_map, sizeof(new_map));
123 if (retval < 0) { 118 if (retval < 0) {
124 /* 119 /*
125 * if not written to device mapping table 120 * if not written to device mapping table
126 * clear the driver mapping table records 121 * clear the driver mapping table records
127 */ 122 */
128 rmi_smb->mapping_table[i].rmiaddr = 0x0000; 123 memset(&new_map, 0, sizeof(new_map));
129 rmi_smb->mapping_table[i].readcount = 0;
130 rmi_smb->mapping_table[i].flags = 0;
131 goto exit;
132 } 124 }
125
133 /* save to the driver level mapping table */ 126 /* save to the driver level mapping table */
134 rmi_smb->mapping_table[i].rmiaddr = rmiaddr; 127 rmi_smb->mapping_table[i] = new_map;
135 rmi_smb->mapping_table[i].readcount = bytecount;
136 rmi_smb->mapping_table[i].flags = !isread ? RMI_SMB2_MAP_FLAGS_WE : 0;
137 *commandcode = i;
138 128
139exit: 129exit:
140 mutex_unlock(&rmi_smb->mappingtable_mutex); 130 mutex_unlock(&rmi_smb->mappingtable_mutex);
141 131
142 return retval; 132 if (retval < 0)
133 return retval;
134
135 *commandcode = i;
136 return 0;
143} 137}
144 138
145static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr, 139static int rmi_smb_write_block(struct rmi_transport_dev *xport, u16 rmiaddr,
@@ -282,19 +276,24 @@ static int rmi_smb_probe(struct i2c_client *client,
282{ 276{
283 struct rmi_device_platform_data *pdata = dev_get_platdata(&client->dev); 277 struct rmi_device_platform_data *pdata = dev_get_platdata(&client->dev);
284 struct rmi_smb_xport *rmi_smb; 278 struct rmi_smb_xport *rmi_smb;
285 int retval;
286 int smbus_version; 279 int smbus_version;
280 int error;
281
282 if (!pdata) {
283 dev_err(&client->dev, "no platform data, aborting\n");
284 return -ENOMEM;
285 }
287 286
288 if (!i2c_check_functionality(client->adapter, 287 if (!i2c_check_functionality(client->adapter,
289 I2C_FUNC_SMBUS_READ_BLOCK_DATA | 288 I2C_FUNC_SMBUS_READ_BLOCK_DATA |
290 I2C_FUNC_SMBUS_HOST_NOTIFY)) { 289 I2C_FUNC_SMBUS_HOST_NOTIFY)) {
291 dev_err(&client->dev, 290 dev_err(&client->dev,
292 "adapter does not support required functionality.\n"); 291 "adapter does not support required functionality\n");
293 return -ENODEV; 292 return -ENODEV;
294 } 293 }
295 294
296 if (client->irq <= 0) { 295 if (client->irq <= 0) {
297 dev_err(&client->dev, "no IRQ provided, giving up.\n"); 296 dev_err(&client->dev, "no IRQ provided, giving up\n");
298 return client->irq ? client->irq : -ENODEV; 297 return client->irq ? client->irq : -ENODEV;
299 } 298 }
300 299
@@ -303,12 +302,7 @@ static int rmi_smb_probe(struct i2c_client *client,
303 if (!rmi_smb) 302 if (!rmi_smb)
304 return -ENOMEM; 303 return -ENOMEM;
305 304
306 if (!pdata) { 305 rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s\n",
307 dev_err(&client->dev, "no platform data, aborting\n");
308 return -ENOMEM;
309 }
310
311 rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Probing %s.\n",
312 dev_name(&client->dev)); 306 dev_name(&client->dev));
313 307
314 rmi_smb->client = client; 308 rmi_smb->client = client;
@@ -321,34 +315,30 @@ static int rmi_smb_probe(struct i2c_client *client,
321 rmi_smb->xport.proto_name = "smb2"; 315 rmi_smb->xport.proto_name = "smb2";
322 rmi_smb->xport.ops = &rmi_smb_ops; 316 rmi_smb->xport.ops = &rmi_smb_ops;
323 317
324 retval = rmi_smb_get_version(rmi_smb); 318 smbus_version = rmi_smb_get_version(rmi_smb);
325 if (retval < 0) 319 if (smbus_version < 0)
326 return retval; 320 return smbus_version;
327 321
328 smbus_version = retval;
329 rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Smbus version is %d", 322 rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Smbus version is %d",
330 smbus_version); 323 smbus_version);
331 324
332 if (smbus_version != 2) { 325 if (smbus_version != 2) {
333 dev_err(&client->dev, "Unrecognized SMB version %d.\n", 326 dev_err(&client->dev, "Unrecognized SMB version %d\n",
334 smbus_version); 327 smbus_version);
335 return -ENODEV; 328 return -ENODEV;
336 } 329 }
337 330
338 i2c_set_clientdata(client, rmi_smb); 331 i2c_set_clientdata(client, rmi_smb);
339 332
340 retval = rmi_register_transport_device(&rmi_smb->xport); 333 dev_info(&client->dev, "registering SMbus-connected sensor\n");
341 if (retval) { 334
342 dev_err(&client->dev, "Failed to register transport driver at 0x%.2X.\n", 335 error = rmi_register_transport_device(&rmi_smb->xport);
343 client->addr); 336 if (error) {
344 i2c_set_clientdata(client, NULL); 337 dev_err(&client->dev, "failed to register sensor: %d\n", error);
345 return retval; 338 return error;
346 } 339 }
347 340
348 dev_info(&client->dev, "registered rmi smb driver at %#04x.\n",
349 client->addr);
350 return 0; 341 return 0;
351
352} 342}
353 343
354static int rmi_smb_remove(struct i2c_client *client) 344static int rmi_smb_remove(struct i2c_client *client)
diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c
index 69548d7d1f10..d97a85907ed6 100644
--- a/drivers/input/rmi4/rmi_spi.c
+++ b/drivers/input/rmi4/rmi_spi.c
@@ -370,7 +370,7 @@ static int rmi_spi_probe(struct spi_device *spi)
370 struct rmi_spi_xport *rmi_spi; 370 struct rmi_spi_xport *rmi_spi;
371 struct rmi_device_platform_data *pdata; 371 struct rmi_device_platform_data *pdata;
372 struct rmi_device_platform_data *spi_pdata = spi->dev.platform_data; 372 struct rmi_device_platform_data *spi_pdata = spi->dev.platform_data;
373 int retval; 373 int error;
374 374
375 if (spi->master->flags & SPI_MASTER_HALF_DUPLEX) 375 if (spi->master->flags & SPI_MASTER_HALF_DUPLEX)
376 return -EINVAL; 376 return -EINVAL;
@@ -383,9 +383,9 @@ static int rmi_spi_probe(struct spi_device *spi)
383 pdata = &rmi_spi->xport.pdata; 383 pdata = &rmi_spi->xport.pdata;
384 384
385 if (spi->dev.of_node) { 385 if (spi->dev.of_node) {
386 retval = rmi_spi_of_probe(spi, pdata); 386 error = rmi_spi_of_probe(spi, pdata);
387 if (retval) 387 if (error)
388 return retval; 388 return error;
389 } else if (spi_pdata) { 389 } else if (spi_pdata) {
390 *pdata = *spi_pdata; 390 *pdata = *spi_pdata;
391 } 391 }
@@ -396,10 +396,10 @@ static int rmi_spi_probe(struct spi_device *spi)
396 if (pdata->spi_data.mode) 396 if (pdata->spi_data.mode)
397 spi->mode = pdata->spi_data.mode; 397 spi->mode = pdata->spi_data.mode;
398 398
399 retval = spi_setup(spi); 399 error = spi_setup(spi);
400 if (retval < 0) { 400 if (error < 0) {
401 dev_err(&spi->dev, "spi_setup failed!\n"); 401 dev_err(&spi->dev, "spi_setup failed!\n");
402 return retval; 402 return error;
403 } 403 }
404 404
405 pdata->irq = spi->irq; 405 pdata->irq = spi->irq;
@@ -413,32 +413,34 @@ static int rmi_spi_probe(struct spi_device *spi)
413 413
414 spi_set_drvdata(spi, rmi_spi); 414 spi_set_drvdata(spi, rmi_spi);
415 415
416 retval = rmi_spi_manage_pools(rmi_spi, RMI_SPI_DEFAULT_XFER_BUF_SIZE); 416 error = rmi_spi_manage_pools(rmi_spi, RMI_SPI_DEFAULT_XFER_BUF_SIZE);
417 if (retval) 417 if (error)
418 return retval; 418 return error;
419 419
420 /* 420 /*
421 * Setting the page to zero will (a) make sure the PSR is in a 421 * Setting the page to zero will (a) make sure the PSR is in a
422 * known state, and (b) make sure we can talk to the device. 422 * known state, and (b) make sure we can talk to the device.
423 */ 423 */
424 retval = rmi_set_page(rmi_spi, 0); 424 error = rmi_set_page(rmi_spi, 0);
425 if (retval) { 425 if (error) {
426 dev_err(&spi->dev, "Failed to set page select to 0.\n"); 426 dev_err(&spi->dev, "Failed to set page select to 0.\n");
427 return retval; 427 return error;
428 } 428 }
429 429
430 retval = rmi_register_transport_device(&rmi_spi->xport); 430 dev_info(&spi->dev, "registering SPI-connected sensor\n");
431 if (retval) { 431
432 dev_err(&spi->dev, "failed to register transport.\n"); 432 error = rmi_register_transport_device(&rmi_spi->xport);
433 return retval; 433 if (error) {
434 dev_err(&spi->dev, "failed to register sensor: %d\n", error);
435 return error;
434 } 436 }
435 retval = devm_add_action_or_reset(&spi->dev, 437
438 error = devm_add_action_or_reset(&spi->dev,
436 rmi_spi_unregister_transport, 439 rmi_spi_unregister_transport,
437 rmi_spi); 440 rmi_spi);
438 if (retval) 441 if (error)
439 return retval; 442 return error;
440 443
441 dev_info(&spi->dev, "registered RMI SPI driver\n");
442 return 0; 444 return 0;
443} 445}
444 446
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 1ca7f551e2da..30d6230d48f7 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -285,8 +285,8 @@ static int serio_queue_event(void *object, struct module *owner,
285 } 285 }
286 286
287 if (!try_module_get(owner)) { 287 if (!try_module_get(owner)) {
288 pr_warning("Can't get module reference, dropping event %d\n", 288 pr_warn("Can't get module reference, dropping event %d\n",
289 event_type); 289 event_type);
290 kfree(event); 290 kfree(event);
291 retval = -EINVAL; 291 retval = -EINVAL;
292 goto out; 292 goto out;
@@ -823,8 +823,8 @@ static void serio_attach_driver(struct serio_driver *drv)
823 823
824 error = driver_attach(&drv->driver); 824 error = driver_attach(&drv->driver);
825 if (error) 825 if (error)
826 pr_warning("driver_attach() failed for %s with error %d\n", 826 pr_warn("driver_attach() failed for %s with error %d\n",
827 drv->driver.name, error); 827 drv->driver.name, error);
828} 828}
829 829
830int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name) 830int __serio_register_driver(struct serio_driver *drv, struct module *owner, const char *mod_name)
@@ -953,12 +953,24 @@ static int serio_suspend(struct device *dev)
953static int serio_resume(struct device *dev) 953static int serio_resume(struct device *dev)
954{ 954{
955 struct serio *serio = to_serio_port(dev); 955 struct serio *serio = to_serio_port(dev);
956 int error = -ENOENT;
956 957
957 /* 958 mutex_lock(&serio->drv_mutex);
958 * Driver reconnect can take a while, so better let kseriod 959 if (serio->drv && serio->drv->fast_reconnect) {
959 * deal with it. 960 error = serio->drv->fast_reconnect(serio);
960 */ 961 if (error && error != -ENOENT)
961 serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT); 962 dev_warn(dev, "fast reconnect failed with error %d\n",
963 error);
964 }
965 mutex_unlock(&serio->drv_mutex);
966
967 if (error) {
968 /*
969 * Driver reconnect can take a while, so better let
970 * kseriod deal with it.
971 */
972 serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
973 }
962 974
963 return 0; 975 return 0;
964} 976}
diff --git a/drivers/input/sparse-keymap.c b/drivers/input/sparse-keymap.c
index e7409c45bdd0..12a3ad83296d 100644
--- a/drivers/input/sparse-keymap.c
+++ b/drivers/input/sparse-keymap.c
@@ -160,12 +160,12 @@ static int sparse_keymap_setkeycode(struct input_dev *dev,
160 * @keymap: Keymap in form of array of &key_entry structures ending 160 * @keymap: Keymap in form of array of &key_entry structures ending
161 * with %KE_END type entry 161 * with %KE_END type entry
162 * @setup: Function that can be used to adjust keymap entries 162 * @setup: Function that can be used to adjust keymap entries
163 * depending on device's deeds, may be %NULL 163 * depending on device's needs, may be %NULL
164 * 164 *
165 * The function calculates size and allocates copy of the original 165 * The function calculates size and allocates copy of the original
166 * keymap after which sets up input device event bits appropriately. 166 * keymap after which sets up input device event bits appropriately.
167 * Before destroying input device allocated keymap should be freed 167 * The allocated copy of the keymap is automatically freed when it
168 * with a call to sparse_keymap_free(). 168 * is no longer needed.
169 */ 169 */
170int sparse_keymap_setup(struct input_dev *dev, 170int sparse_keymap_setup(struct input_dev *dev,
171 const struct key_entry *keymap, 171 const struct key_entry *keymap,
@@ -180,19 +180,18 @@ int sparse_keymap_setup(struct input_dev *dev,
180 for (e = keymap; e->type != KE_END; e++) 180 for (e = keymap; e->type != KE_END; e++)
181 map_size++; 181 map_size++;
182 182
183 map = kcalloc(map_size, sizeof(struct key_entry), GFP_KERNEL); 183 map = devm_kmemdup(&dev->dev, keymap, map_size * sizeof(*map),
184 GFP_KERNEL);
184 if (!map) 185 if (!map)
185 return -ENOMEM; 186 return -ENOMEM;
186 187
187 memcpy(map, keymap, map_size * sizeof(struct key_entry));
188
189 for (i = 0; i < map_size; i++) { 188 for (i = 0; i < map_size; i++) {
190 entry = &map[i]; 189 entry = &map[i];
191 190
192 if (setup) { 191 if (setup) {
193 error = setup(dev, entry); 192 error = setup(dev, entry);
194 if (error) 193 if (error)
195 goto err_out; 194 return error;
196 } 195 }
197 196
198 switch (entry->type) { 197 switch (entry->type) {
@@ -221,10 +220,6 @@ int sparse_keymap_setup(struct input_dev *dev,
221 dev->setkeycode = sparse_keymap_setkeycode; 220 dev->setkeycode = sparse_keymap_setkeycode;
222 221
223 return 0; 222 return 0;
224
225 err_out:
226 kfree(map);
227 return error;
228} 223}
229EXPORT_SYMBOL(sparse_keymap_setup); 224EXPORT_SYMBOL(sparse_keymap_setup);
230 225
@@ -232,29 +227,13 @@ EXPORT_SYMBOL(sparse_keymap_setup);
232 * sparse_keymap_free - free memory allocated for sparse keymap 227 * sparse_keymap_free - free memory allocated for sparse keymap
233 * @dev: Input device using sparse keymap 228 * @dev: Input device using sparse keymap
234 * 229 *
235 * This function is used to free memory allocated by sparse keymap 230 * This function used to free memory allocated by sparse keymap
236 * in an input device that was set up by sparse_keymap_setup(). 231 * in an input device that was set up by sparse_keymap_setup().
237 * NOTE: It is safe to cal this function while input device is 232 * Since sparse_keymap_setup() now uses a managed allocation for the
238 * still registered (however the drivers should care not to try to 233 * keymap copy, use of this function is deprecated.
239 * use freed keymap and thus have to shut off interrupts/polling
240 * before freeing the keymap).
241 */ 234 */
242void sparse_keymap_free(struct input_dev *dev) 235void sparse_keymap_free(struct input_dev *dev)
243{ 236{
244 unsigned long flags;
245
246 /*
247 * Take event lock to prevent racing with input_get_keycode()
248 * and input_set_keycode() if we are called while input device
249 * is still registered.
250 */
251 spin_lock_irqsave(&dev->event_lock, flags);
252
253 kfree(dev->keycode);
254 dev->keycode = NULL;
255 dev->keycodemax = 0;
256
257 spin_unlock_irqrestore(&dev->event_lock, flags);
258} 237}
259EXPORT_SYMBOL(sparse_keymap_free); 238EXPORT_SYMBOL(sparse_keymap_free);
260 239
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 52458cfdf017..cf26ca49ae6d 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -73,6 +73,7 @@ config TOUCHSCREEN_AD7879
73config TOUCHSCREEN_AD7879_I2C 73config TOUCHSCREEN_AD7879_I2C
74 tristate "support I2C bus connection" 74 tristate "support I2C bus connection"
75 depends on TOUCHSCREEN_AD7879 && I2C 75 depends on TOUCHSCREEN_AD7879 && I2C
76 select REGMAP_I2C
76 help 77 help
77 Say Y here if you have AD7879-1/AD7889-1 hooked to an I2C bus. 78 Say Y here if you have AD7879-1/AD7889-1 hooked to an I2C bus.
78 79
@@ -82,6 +83,7 @@ config TOUCHSCREEN_AD7879_I2C
82config TOUCHSCREEN_AD7879_SPI 83config TOUCHSCREEN_AD7879_SPI
83 tristate "support SPI bus connection" 84 tristate "support SPI bus connection"
84 depends on TOUCHSCREEN_AD7879 && SPI_MASTER 85 depends on TOUCHSCREEN_AD7879 && SPI_MASTER
86 select REGMAP_SPI
85 help 87 help
86 Say Y here if you have AD7879-1/AD7889-1 hooked to a SPI bus. 88 Say Y here if you have AD7879-1/AD7889-1 hooked to a SPI bus.
87 89
@@ -91,11 +93,11 @@ config TOUCHSCREEN_AD7879_SPI
91 module will be called ad7879-spi. 93 module will be called ad7879-spi.
92 94
93config TOUCHSCREEN_AR1021_I2C 95config TOUCHSCREEN_AR1021_I2C
94 tristate "Microchip AR1021 i2c touchscreen" 96 tristate "Microchip AR1020/1021 i2c touchscreen"
95 depends on I2C && OF 97 depends on I2C && OF
96 help 98 help
97 Say Y here if you have the Microchip AR1021 touchscreen controller 99 Say Y here if you have the Microchip AR1020 or AR1021 touchscreen
98 chip in your system. 100 controller chip in your system.
99 101
100 If unsure, say N. 102 If unsure, say N.
101 103
@@ -1033,6 +1035,16 @@ config TOUCHSCREEN_TSC2007
1033 To compile this driver as a module, choose M here: the 1035 To compile this driver as a module, choose M here: the
1034 module will be called tsc2007. 1036 module will be called tsc2007.
1035 1037
1038config TOUCHSCREEN_TSC2007_IIO
1039 bool "IIO interface for external ADC input and temperature"
1040 depends on TOUCHSCREEN_TSC2007
1041 depends on IIO=y || IIO=TOUCHSCREEN_TSC2007
1042 help
1043 Saying Y here adds an iio interface to the tsc2007 which
1044 provides values for the AUX input (used for e.g. battery
1045 or ambient light monitoring), temperature and raw input
1046 values.
1047
1036config TOUCHSCREEN_W90X900 1048config TOUCHSCREEN_W90X900
1037 tristate "W90P910 touchscreen driver" 1049 tristate "W90P910 touchscreen driver"
1038 depends on ARCH_W90X900 1050 depends on ARCH_W90X900
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 96761ce2ee6d..18e476948e44 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -80,6 +80,8 @@ obj-$(CONFIG_TOUCHSCREEN_TSC_SERIO) += tsc40.o
80obj-$(CONFIG_TOUCHSCREEN_TSC200X_CORE) += tsc200x-core.o 80obj-$(CONFIG_TOUCHSCREEN_TSC200X_CORE) += tsc200x-core.o
81obj-$(CONFIG_TOUCHSCREEN_TSC2004) += tsc2004.o 81obj-$(CONFIG_TOUCHSCREEN_TSC2004) += tsc2004.o
82obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o 82obj-$(CONFIG_TOUCHSCREEN_TSC2005) += tsc2005.o
83tsc2007-y := tsc2007_core.o
84tsc2007-$(CONFIG_TOUCHSCREEN_TSC2007_IIO) += tsc2007_iio.o
83obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o 85obj-$(CONFIG_TOUCHSCREEN_TSC2007) += tsc2007.o
84obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o 86obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o
85obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o 87obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o
diff --git a/drivers/input/touchscreen/ad7879-i2c.c b/drivers/input/touchscreen/ad7879-i2c.c
index 58f72e0246ab..49b902b10c5f 100644
--- a/drivers/input/touchscreen/ad7879-i2c.c
+++ b/drivers/input/touchscreen/ad7879-i2c.c
@@ -12,53 +12,22 @@
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/of.h> 13#include <linux/of.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/regmap.h>
15 16
16#include "ad7879.h" 17#include "ad7879.h"
17 18
18#define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */ 19#define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */
19 20
20/* All registers are word-sized. 21static const struct regmap_config ad7879_i2c_regmap_config = {
21 * AD7879 uses a high-byte first convention. 22 .reg_bits = 8,
22 */ 23 .val_bits = 16,
23static int ad7879_i2c_read(struct device *dev, u8 reg) 24 .max_register = 15,
24{
25 struct i2c_client *client = to_i2c_client(dev);
26
27 return i2c_smbus_read_word_swapped(client, reg);
28}
29
30static int ad7879_i2c_multi_read(struct device *dev,
31 u8 first_reg, u8 count, u16 *buf)
32{
33 struct i2c_client *client = to_i2c_client(dev);
34 u8 idx;
35
36 i2c_smbus_read_i2c_block_data(client, first_reg, count * 2, (u8 *)buf);
37
38 for (idx = 0; idx < count; ++idx)
39 buf[idx] = swab16(buf[idx]);
40
41 return 0;
42}
43
44static int ad7879_i2c_write(struct device *dev, u8 reg, u16 val)
45{
46 struct i2c_client *client = to_i2c_client(dev);
47
48 return i2c_smbus_write_word_swapped(client, reg, val);
49}
50
51static const struct ad7879_bus_ops ad7879_i2c_bus_ops = {
52 .bustype = BUS_I2C,
53 .read = ad7879_i2c_read,
54 .multi_read = ad7879_i2c_multi_read,
55 .write = ad7879_i2c_write,
56}; 25};
57 26
58static int ad7879_i2c_probe(struct i2c_client *client, 27static int ad7879_i2c_probe(struct i2c_client *client,
59 const struct i2c_device_id *id) 28 const struct i2c_device_id *id)
60{ 29{
61 struct ad7879 *ts; 30 struct regmap *regmap;
62 31
63 if (!i2c_check_functionality(client->adapter, 32 if (!i2c_check_functionality(client->adapter,
64 I2C_FUNC_SMBUS_WORD_DATA)) { 33 I2C_FUNC_SMBUS_WORD_DATA)) {
@@ -66,23 +35,12 @@ static int ad7879_i2c_probe(struct i2c_client *client,
66 return -EIO; 35 return -EIO;
67 } 36 }
68 37
69 ts = ad7879_probe(&client->dev, AD7879_DEVID, client->irq, 38 regmap = devm_regmap_init_i2c(client, &ad7879_i2c_regmap_config);
70 &ad7879_i2c_bus_ops); 39 if (IS_ERR(regmap))
71 if (IS_ERR(ts)) 40 return PTR_ERR(regmap);
72 return PTR_ERR(ts);
73
74 i2c_set_clientdata(client, ts);
75
76 return 0;
77}
78
79static int ad7879_i2c_remove(struct i2c_client *client)
80{
81 struct ad7879 *ts = i2c_get_clientdata(client);
82
83 ad7879_remove(ts);
84 41
85 return 0; 42 return ad7879_probe(&client->dev, regmap, client->irq,
43 BUS_I2C, AD7879_DEVID);
86} 44}
87 45
88static const struct i2c_device_id ad7879_id[] = { 46static const struct i2c_device_id ad7879_id[] = {
@@ -107,12 +65,11 @@ static struct i2c_driver ad7879_i2c_driver = {
107 .of_match_table = of_match_ptr(ad7879_i2c_dt_ids), 65 .of_match_table = of_match_ptr(ad7879_i2c_dt_ids),
108 }, 66 },
109 .probe = ad7879_i2c_probe, 67 .probe = ad7879_i2c_probe,
110 .remove = ad7879_i2c_remove,
111 .id_table = ad7879_id, 68 .id_table = ad7879_id,
112}; 69};
113 70
114module_i2c_driver(ad7879_i2c_driver); 71module_i2c_driver(ad7879_i2c_driver);
115 72
116MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 73MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
117MODULE_DESCRIPTION("AD7879(-1) touchscreen I2C bus driver"); 74MODULE_DESCRIPTION("AD7879(-1) touchscreen I2C bus driver");
118MODULE_LICENSE("GPL"); 75MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/ad7879-spi.c b/drivers/input/touchscreen/ad7879-spi.c
index d42b6b9af191..3457a5626d75 100644
--- a/drivers/input/touchscreen/ad7879-spi.c
+++ b/drivers/input/touchscreen/ad7879-spi.c
@@ -11,110 +11,28 @@
11#include <linux/spi/spi.h> 11#include <linux/spi/spi.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/of.h> 13#include <linux/of.h>
14#include <linux/regmap.h>
14 15
15#include "ad7879.h" 16#include "ad7879.h"
16 17
17#define AD7879_DEVID 0x7A /* AD7879/AD7889 */ 18#define AD7879_DEVID 0x7A /* AD7879/AD7889 */
18 19
19#define MAX_SPI_FREQ_HZ 5000000 20#define MAX_SPI_FREQ_HZ 5000000
20#define AD7879_CMD_MAGIC 0xE000
21#define AD7879_CMD_READ (1 << 10)
22#define AD7879_CMD(reg) (AD7879_CMD_MAGIC | ((reg) & 0xF))
23#define AD7879_WRITECMD(reg) (AD7879_CMD(reg))
24#define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ)
25 21
26/* 22#define AD7879_CMD_MAGIC 0xE0
27 * ad7879_read/write are only used for initial setup and for sysfs controls. 23#define AD7879_CMD_READ BIT(2)
28 * The main traffic is done in ad7879_collect().
29 */
30
31static int ad7879_spi_xfer(struct spi_device *spi,
32 u16 cmd, u8 count, u16 *tx_buf, u16 *rx_buf)
33{
34 struct spi_message msg;
35 struct spi_transfer *xfers;
36 void *spi_data;
37 u16 *command;
38 u16 *_rx_buf = _rx_buf; /* shut gcc up */
39 u8 idx;
40 int ret;
41
42 xfers = spi_data = kzalloc(sizeof(*xfers) * (count + 2), GFP_KERNEL);
43 if (!spi_data)
44 return -ENOMEM;
45
46 spi_message_init(&msg);
47
48 command = spi_data;
49 command[0] = cmd;
50 if (count == 1) {
51 /* ad7879_spi_{read,write} gave us buf on stack */
52 command[1] = *tx_buf;
53 tx_buf = &command[1];
54 _rx_buf = rx_buf;
55 rx_buf = &command[2];
56 }
57
58 ++xfers;
59 xfers[0].tx_buf = command;
60 xfers[0].len = 2;
61 spi_message_add_tail(&xfers[0], &msg);
62 ++xfers;
63
64 for (idx = 0; idx < count; ++idx) {
65 if (rx_buf)
66 xfers[idx].rx_buf = &rx_buf[idx];
67 if (tx_buf)
68 xfers[idx].tx_buf = &tx_buf[idx];
69 xfers[idx].len = 2;
70 spi_message_add_tail(&xfers[idx], &msg);
71 }
72
73 ret = spi_sync(spi, &msg);
74
75 if (count == 1)
76 _rx_buf[0] = command[2];
77
78 kfree(spi_data);
79
80 return ret;
81}
82
83static int ad7879_spi_multi_read(struct device *dev,
84 u8 first_reg, u8 count, u16 *buf)
85{
86 struct spi_device *spi = to_spi_device(dev);
87 24
88 return ad7879_spi_xfer(spi, AD7879_READCMD(first_reg), count, NULL, buf); 25static const struct regmap_config ad7879_spi_regmap_config = {
89} 26 .reg_bits = 16,
90 27 .val_bits = 16,
91static int ad7879_spi_read(struct device *dev, u8 reg) 28 .max_register = 15,
92{ 29 .read_flag_mask = AD7879_CMD_MAGIC | AD7879_CMD_READ,
93 struct spi_device *spi = to_spi_device(dev); 30 .write_flag_mask = AD7879_CMD_MAGIC,
94 u16 ret, dummy;
95
96 return ad7879_spi_xfer(spi, AD7879_READCMD(reg), 1, &dummy, &ret) ? : ret;
97}
98
99static int ad7879_spi_write(struct device *dev, u8 reg, u16 val)
100{
101 struct spi_device *spi = to_spi_device(dev);
102 u16 dummy;
103
104 return ad7879_spi_xfer(spi, AD7879_WRITECMD(reg), 1, &val, &dummy);
105}
106
107static const struct ad7879_bus_ops ad7879_spi_bus_ops = {
108 .bustype = BUS_SPI,
109 .read = ad7879_spi_read,
110 .multi_read = ad7879_spi_multi_read,
111 .write = ad7879_spi_write,
112}; 31};
113 32
114static int ad7879_spi_probe(struct spi_device *spi) 33static int ad7879_spi_probe(struct spi_device *spi)
115{ 34{
116 struct ad7879 *ts; 35 struct regmap *regmap;
117 int err;
118 36
119 /* don't exceed max specified SPI CLK frequency */ 37 /* don't exceed max specified SPI CLK frequency */
120 if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) { 38 if (spi->max_speed_hz > MAX_SPI_FREQ_HZ) {
@@ -122,29 +40,11 @@ static int ad7879_spi_probe(struct spi_device *spi)
122 return -EINVAL; 40 return -EINVAL;
123 } 41 }
124 42
125 spi->bits_per_word = 16; 43 regmap = devm_regmap_init_spi(spi, &ad7879_spi_regmap_config);
126 err = spi_setup(spi); 44 if (IS_ERR(regmap))
127 if (err) { 45 return PTR_ERR(regmap);
128 dev_dbg(&spi->dev, "spi master doesn't support 16 bits/word\n");
129 return err;
130 }
131
132 ts = ad7879_probe(&spi->dev, AD7879_DEVID, spi->irq, &ad7879_spi_bus_ops);
133 if (IS_ERR(ts))
134 return PTR_ERR(ts);
135
136 spi_set_drvdata(spi, ts);
137
138 return 0;
139}
140
141static int ad7879_spi_remove(struct spi_device *spi)
142{
143 struct ad7879 *ts = spi_get_drvdata(spi);
144
145 ad7879_remove(ts);
146 46
147 return 0; 47 return ad7879_probe(&spi->dev, regmap, spi->irq, BUS_SPI, AD7879_DEVID);
148} 48}
149 49
150#ifdef CONFIG_OF 50#ifdef CONFIG_OF
@@ -162,12 +62,11 @@ static struct spi_driver ad7879_spi_driver = {
162 .of_match_table = of_match_ptr(ad7879_spi_dt_ids), 62 .of_match_table = of_match_ptr(ad7879_spi_dt_ids),
163 }, 63 },
164 .probe = ad7879_spi_probe, 64 .probe = ad7879_spi_probe,
165 .remove = ad7879_spi_remove,
166}; 65};
167 66
168module_spi_driver(ad7879_spi_driver); 67module_spi_driver(ad7879_spi_driver);
169 68
170MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 69MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
171MODULE_DESCRIPTION("AD7879(-1) touchscreen SPI bus driver"); 70MODULE_DESCRIPTION("AD7879(-1) touchscreen SPI bus driver");
172MODULE_LICENSE("GPL"); 71MODULE_LICENSE("GPL");
173MODULE_ALIAS("spi:ad7879"); 72MODULE_ALIAS("spi:ad7879");
diff --git a/drivers/input/touchscreen/ad7879.c b/drivers/input/touchscreen/ad7879.c
index e16a44667da7..196028c45210 100644
--- a/drivers/input/touchscreen/ad7879.c
+++ b/drivers/input/touchscreen/ad7879.c
@@ -26,9 +26,9 @@
26#include <linux/input.h> 26#include <linux/input.h>
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/irq.h> 28#include <linux/irq.h>
29#include <linux/property.h>
30#include <linux/regmap.h>
29#include <linux/slab.h> 31#include <linux/slab.h>
30#include <linux/spi/spi.h>
31#include <linux/i2c.h>
32#include <linux/gpio.h> 32#include <linux/gpio.h>
33 33
34#include <linux/input/touchscreen.h> 34#include <linux/input/touchscreen.h>
@@ -106,8 +106,7 @@ enum {
106#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50) 106#define TS_PEN_UP_TIMEOUT msecs_to_jiffies(50)
107 107
108struct ad7879 { 108struct ad7879 {
109 const struct ad7879_bus_ops *bops; 109 struct regmap *regmap;
110
111 struct device *dev; 110 struct device *dev;
112 struct input_dev *input; 111 struct input_dev *input;
113 struct timer_list timer; 112 struct timer_list timer;
@@ -137,17 +136,32 @@ struct ad7879 {
137 136
138static int ad7879_read(struct ad7879 *ts, u8 reg) 137static int ad7879_read(struct ad7879 *ts, u8 reg)
139{ 138{
140 return ts->bops->read(ts->dev, reg); 139 unsigned int val;
141} 140 int error;
142 141
143static int ad7879_multi_read(struct ad7879 *ts, u8 first_reg, u8 count, u16 *buf) 142 error = regmap_read(ts->regmap, reg, &val);
144{ 143 if (error) {
145 return ts->bops->multi_read(ts->dev, first_reg, count, buf); 144 dev_err(ts->dev, "failed to read register %#02x: %d\n",
145 reg, error);
146 return error;
147 }
148
149 return val;
146} 150}
147 151
148static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val) 152static int ad7879_write(struct ad7879 *ts, u8 reg, u16 val)
149{ 153{
150 return ts->bops->write(ts->dev, reg, val); 154 int error;
155
156 error = regmap_write(ts->regmap, reg, val);
157 if (error) {
158 dev_err(ts->dev,
159 "failed to write %#04x to register %#02x: %d\n",
160 val, reg, error);
161 return error;
162 }
163
164 return 0;
151} 165}
152 166
153static int ad7879_report(struct ad7879 *ts) 167static int ad7879_report(struct ad7879 *ts)
@@ -234,7 +248,8 @@ static irqreturn_t ad7879_irq(int irq, void *handle)
234{ 248{
235 struct ad7879 *ts = handle; 249 struct ad7879 *ts = handle;
236 250
237 ad7879_multi_read(ts, AD7879_REG_XPLUS, AD7879_NR_SENSE, ts->conversion_data); 251 regmap_bulk_read(ts->regmap, AD7879_REG_XPLUS,
252 ts->conversion_data, AD7879_NR_SENSE);
238 253
239 if (!ad7879_report(ts)) 254 if (!ad7879_report(ts))
240 mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT); 255 mod_timer(&ts->timer, jiffies + TS_PEN_UP_TIMEOUT);
@@ -440,23 +455,34 @@ static void ad7879_gpio_set_value(struct gpio_chip *chip,
440static int ad7879_gpio_add(struct ad7879 *ts, 455static int ad7879_gpio_add(struct ad7879 *ts,
441 const struct ad7879_platform_data *pdata) 456 const struct ad7879_platform_data *pdata)
442{ 457{
458 bool gpio_export;
459 int gpio_base;
443 int ret = 0; 460 int ret = 0;
444 461
462 if (pdata) {
463 gpio_export = pdata->gpio_export;
464 gpio_base = pdata->gpio_base;
465 } else {
466 gpio_export = device_property_read_bool(ts->dev,
467 "gpio-controller");
468 gpio_base = -1;
469 }
470
445 mutex_init(&ts->mutex); 471 mutex_init(&ts->mutex);
446 472
447 if (pdata->gpio_export) { 473 if (gpio_export) {
448 ts->gc.direction_input = ad7879_gpio_direction_input; 474 ts->gc.direction_input = ad7879_gpio_direction_input;
449 ts->gc.direction_output = ad7879_gpio_direction_output; 475 ts->gc.direction_output = ad7879_gpio_direction_output;
450 ts->gc.get = ad7879_gpio_get_value; 476 ts->gc.get = ad7879_gpio_get_value;
451 ts->gc.set = ad7879_gpio_set_value; 477 ts->gc.set = ad7879_gpio_set_value;
452 ts->gc.can_sleep = 1; 478 ts->gc.can_sleep = 1;
453 ts->gc.base = pdata->gpio_base; 479 ts->gc.base = gpio_base;
454 ts->gc.ngpio = 1; 480 ts->gc.ngpio = 1;
455 ts->gc.label = "AD7879-GPIO"; 481 ts->gc.label = "AD7879-GPIO";
456 ts->gc.owner = THIS_MODULE; 482 ts->gc.owner = THIS_MODULE;
457 ts->gc.parent = ts->dev; 483 ts->gc.parent = ts->dev;
458 484
459 ret = gpiochip_add_data(&ts->gc, ts); 485 ret = devm_gpiochip_add_data(ts->dev, &ts->gc, ts);
460 if (ret) 486 if (ret)
461 dev_err(ts->dev, "failed to register gpio %d\n", 487 dev_err(ts->dev, "failed to register gpio %d\n",
462 ts->gc.base); 488 ts->gc.base);
@@ -464,25 +490,12 @@ static int ad7879_gpio_add(struct ad7879 *ts,
464 490
465 return ret; 491 return ret;
466} 492}
467
468static void ad7879_gpio_remove(struct ad7879 *ts)
469{
470 const struct ad7879_platform_data *pdata = dev_get_platdata(ts->dev);
471
472 if (pdata && pdata->gpio_export)
473 gpiochip_remove(&ts->gc);
474
475}
476#else 493#else
477static inline int ad7879_gpio_add(struct ad7879 *ts, 494static int ad7879_gpio_add(struct ad7879 *ts,
478 const struct ad7879_platform_data *pdata) 495 const struct ad7879_platform_data *pdata)
479{ 496{
480 return 0; 497 return 0;
481} 498}
482
483static inline void ad7879_gpio_remove(struct ad7879 *ts)
484{
485}
486#endif 499#endif
487 500
488static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts) 501static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
@@ -511,8 +524,15 @@ static int ad7879_parse_dt(struct device *dev, struct ad7879 *ts)
511 return 0; 524 return 0;
512} 525}
513 526
514struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq, 527static void ad7879_cleanup_sysfs(void *_ts)
515 const struct ad7879_bus_ops *bops) 528{
529 struct ad7879 *ts = _ts;
530
531 sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group);
532}
533
534int ad7879_probe(struct device *dev, struct regmap *regmap,
535 int irq, u16 bustype, u8 devid)
516{ 536{
517 struct ad7879_platform_data *pdata = dev_get_platdata(dev); 537 struct ad7879_platform_data *pdata = dev_get_platdata(dev);
518 struct ad7879 *ts; 538 struct ad7879 *ts;
@@ -520,14 +540,14 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
520 int err; 540 int err;
521 u16 revid; 541 u16 revid;
522 542
523 if (!irq) { 543 if (irq <= 0) {
524 dev_err(dev, "No IRQ specified\n"); 544 dev_err(dev, "No IRQ specified\n");
525 return ERR_PTR(-EINVAL); 545 return -EINVAL;
526 } 546 }
527 547
528 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL); 548 ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
529 if (!ts) 549 if (!ts)
530 return ERR_PTR(-ENOMEM); 550 return -ENOMEM;
531 551
532 if (pdata) { 552 if (pdata) {
533 /* Platform data use swapped axis (backward compatibility) */ 553 /* Platform data use swapped axis (backward compatibility) */
@@ -540,23 +560,22 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
540 ts->averaging = pdata->averaging; 560 ts->averaging = pdata->averaging;
541 ts->pen_down_acc_interval = pdata->pen_down_acc_interval; 561 ts->pen_down_acc_interval = pdata->pen_down_acc_interval;
542 ts->median = pdata->median; 562 ts->median = pdata->median;
543 } else if (dev->of_node) {
544 ad7879_parse_dt(dev, ts);
545 } else { 563 } else {
546 dev_err(dev, "No platform data\n"); 564 err = ad7879_parse_dt(dev, ts);
547 return ERR_PTR(-EINVAL); 565 if (err)
566 return err;
548 } 567 }
549 568
550 input_dev = devm_input_allocate_device(dev); 569 input_dev = devm_input_allocate_device(dev);
551 if (!input_dev) { 570 if (!input_dev) {
552 dev_err(dev, "Failed to allocate input device\n"); 571 dev_err(dev, "Failed to allocate input device\n");
553 return ERR_PTR(-ENOMEM); 572 return -ENOMEM;
554 } 573 }
555 574
556 ts->bops = bops;
557 ts->dev = dev; 575 ts->dev = dev;
558 ts->input = input_dev; 576 ts->input = input_dev;
559 ts->irq = irq; 577 ts->irq = irq;
578 ts->regmap = regmap;
560 579
561 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts); 580 setup_timer(&ts->timer, ad7879_timer, (unsigned long) ts);
562 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev)); 581 snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
@@ -564,20 +583,14 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
564 input_dev->name = "AD7879 Touchscreen"; 583 input_dev->name = "AD7879 Touchscreen";
565 input_dev->phys = ts->phys; 584 input_dev->phys = ts->phys;
566 input_dev->dev.parent = dev; 585 input_dev->dev.parent = dev;
567 input_dev->id.bustype = bops->bustype; 586 input_dev->id.bustype = bustype;
568 587
569 input_dev->open = ad7879_open; 588 input_dev->open = ad7879_open;
570 input_dev->close = ad7879_close; 589 input_dev->close = ad7879_close;
571 590
572 input_set_drvdata(input_dev, ts); 591 input_set_drvdata(input_dev, ts);
573 592
574 __set_bit(EV_ABS, input_dev->evbit); 593 input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
575 __set_bit(ABS_X, input_dev->absbit);
576 __set_bit(ABS_Y, input_dev->absbit);
577 __set_bit(ABS_PRESSURE, input_dev->absbit);
578
579 __set_bit(EV_KEY, input_dev->evbit);
580 __set_bit(BTN_TOUCH, input_dev->keybit);
581 594
582 if (pdata) { 595 if (pdata) {
583 input_set_abs_params(input_dev, ABS_X, 596 input_set_abs_params(input_dev, ABS_X,
@@ -595,17 +608,18 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
595 } else { 608 } else {
596 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0); 609 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
597 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0); 610 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
611 input_set_capability(input_dev, EV_ABS, ABS_PRESSURE);
598 touchscreen_parse_properties(input_dev, false, NULL); 612 touchscreen_parse_properties(input_dev, false, NULL);
599 if (!input_abs_get_max(input_dev, ABS_PRESSURE)) { 613 if (!input_abs_get_max(input_dev, ABS_PRESSURE)) {
600 dev_err(dev, "Touchscreen pressure is not specified\n"); 614 dev_err(dev, "Touchscreen pressure is not specified\n");
601 return ERR_PTR(-EINVAL); 615 return -EINVAL;
602 } 616 }
603 } 617 }
604 618
605 err = ad7879_write(ts, AD7879_REG_CTRL2, AD7879_RESET); 619 err = ad7879_write(ts, AD7879_REG_CTRL2, AD7879_RESET);
606 if (err < 0) { 620 if (err < 0) {
607 dev_err(dev, "Failed to write %s\n", input_dev->name); 621 dev_err(dev, "Failed to write %s\n", input_dev->name);
608 return ERR_PTR(err); 622 return err;
609 } 623 }
610 624
611 revid = ad7879_read(ts, AD7879_REG_REVID); 625 revid = ad7879_read(ts, AD7879_REG_REVID);
@@ -614,7 +628,7 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
614 if (input_dev->id.product != devid) { 628 if (input_dev->id.product != devid) {
615 dev_err(dev, "Failed to probe %s (%x vs %x)\n", 629 dev_err(dev, "Failed to probe %s (%x vs %x)\n",
616 input_dev->name, devid, revid); 630 input_dev->name, devid, revid);
617 return ERR_PTR(-ENODEV); 631 return -ENODEV;
618 } 632 }
619 633
620 ts->cmd_crtl3 = AD7879_YPLUS_BIT | 634 ts->cmd_crtl3 = AD7879_YPLUS_BIT |
@@ -639,43 +653,33 @@ struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned int irq,
639 dev_name(dev), ts); 653 dev_name(dev), ts);
640 if (err) { 654 if (err) {
641 dev_err(dev, "Failed to request IRQ: %d\n", err); 655 dev_err(dev, "Failed to request IRQ: %d\n", err);
642 return ERR_PTR(err); 656 return err;
643 } 657 }
644 658
645 __ad7879_disable(ts); 659 __ad7879_disable(ts);
646 660
647 err = sysfs_create_group(&dev->kobj, &ad7879_attr_group); 661 err = sysfs_create_group(&dev->kobj, &ad7879_attr_group);
648 if (err) 662 if (err)
649 goto err_out; 663 return err;
650 664
651 if (pdata) { 665 err = devm_add_action_or_reset(dev, ad7879_cleanup_sysfs, ts);
652 err = ad7879_gpio_add(ts, pdata); 666 if (err)
653 if (err) 667 return err;
654 goto err_remove_attr; 668
655 } 669 err = ad7879_gpio_add(ts, pdata);
670 if (err)
671 return err;
656 672
657 err = input_register_device(input_dev); 673 err = input_register_device(input_dev);
658 if (err) 674 if (err)
659 goto err_remove_gpio; 675 return err;
660 676
661 return ts; 677 dev_set_drvdata(dev, ts);
662 678
663err_remove_gpio: 679 return 0;
664 ad7879_gpio_remove(ts);
665err_remove_attr:
666 sysfs_remove_group(&dev->kobj, &ad7879_attr_group);
667err_out:
668 return ERR_PTR(err);
669} 680}
670EXPORT_SYMBOL(ad7879_probe); 681EXPORT_SYMBOL(ad7879_probe);
671 682
672void ad7879_remove(struct ad7879 *ts) 683MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
673{
674 ad7879_gpio_remove(ts);
675 sysfs_remove_group(&ts->dev->kobj, &ad7879_attr_group);
676}
677EXPORT_SYMBOL(ad7879_remove);
678
679MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
680MODULE_DESCRIPTION("AD7879(-1) touchscreen Driver"); 684MODULE_DESCRIPTION("AD7879(-1) touchscreen Driver");
681MODULE_LICENSE("GPL"); 685MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/ad7879.h b/drivers/input/touchscreen/ad7879.h
index 6fd13c48d373..7e43066a4b68 100644
--- a/drivers/input/touchscreen/ad7879.h
+++ b/drivers/input/touchscreen/ad7879.h
@@ -11,20 +11,12 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14struct ad7879;
15struct device; 14struct device;
16 15struct regmap;
17struct ad7879_bus_ops {
18 u16 bustype;
19 int (*read)(struct device *dev, u8 reg);
20 int (*multi_read)(struct device *dev, u8 first_reg, u8 count, u16 *buf);
21 int (*write)(struct device *dev, u8 reg, u16 val);
22};
23 16
24extern const struct dev_pm_ops ad7879_pm_ops; 17extern const struct dev_pm_ops ad7879_pm_ops;
25 18
26struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq, 19int ad7879_probe(struct device *dev, struct regmap *regmap,
27 const struct ad7879_bus_ops *bops); 20 int irq, u16 bustype, u8 devid);
28void ad7879_remove(struct ad7879 *);
29 21
30#endif 22#endif
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index f5793e3d945f..735a0be1ad95 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -871,7 +871,7 @@ static irqreturn_t ads7846_irq(int irq, void *handle)
871 msecs_to_jiffies(TS_POLL_PERIOD)); 871 msecs_to_jiffies(TS_POLL_PERIOD));
872 } 872 }
873 873
874 if (ts->pendown) { 874 if (ts->pendown && !ts->stopped) {
875 struct input_dev *input = ts->input; 875 struct input_dev *input = ts->input;
876 876
877 input_report_key(input, BTN_TOUCH, 0); 877 input_report_key(input, BTN_TOUCH, 0);
diff --git a/drivers/input/touchscreen/ar1021_i2c.c b/drivers/input/touchscreen/ar1021_i2c.c
index 6562b17117f7..f9dcbd63e598 100644
--- a/drivers/input/touchscreen/ar1021_i2c.c
+++ b/drivers/input/touchscreen/ar1021_i2c.c
@@ -1,11 +1,12 @@
1/* 1/*
2 * Microchip AR1021 driver for I2C 2 * Microchip AR1020 and AR1021 driver for I2C
3 * 3 *
4 * Author: Christian Gmeiner <christian.gmeiner@gmail.com> 4 * Author: Christian Gmeiner <christian.gmeiner@gmail.com>
5 * 5 *
6 * License: GPLv2 as published by the FSF. 6 * License: GPLv2 as published by the FSF.
7 */ 7 */
8 8
9#include <linux/bitops.h>
9#include <linux/module.h> 10#include <linux/module.h>
10#include <linux/input.h> 11#include <linux/input.h>
11#include <linux/of.h> 12#include <linux/of.h>
@@ -18,6 +19,10 @@
18#define AR1021_MAX_X 4095 19#define AR1021_MAX_X 4095
19#define AR1021_MAX_Y 4095 20#define AR1021_MAX_Y 4095
20 21
22#define AR1021_CMD 0x55
23
24#define AR1021_CMD_ENABLE_TOUCH 0x12
25
21struct ar1021_i2c { 26struct ar1021_i2c {
22 struct i2c_client *client; 27 struct i2c_client *client;
23 struct input_dev *input; 28 struct input_dev *input;
@@ -33,12 +38,12 @@ static irqreturn_t ar1021_i2c_irq(int irq, void *dev_id)
33 int retval; 38 int retval;
34 39
35 retval = i2c_master_recv(ar1021->client, 40 retval = i2c_master_recv(ar1021->client,
36 ar1021->data, sizeof(ar1021->data)); 41 ar1021->data, sizeof(ar1021->data));
37 if (retval != sizeof(ar1021->data)) 42 if (retval != sizeof(ar1021->data))
38 goto out; 43 goto out;
39 44
40 /* sync bit set ? */ 45 /* sync bit set ? */
41 if ((data[0] & 0x80) == 0) 46 if (!(data[0] & BIT(7)))
42 goto out; 47 goto out;
43 48
44 button = data[0] & BIT(0); 49 button = data[0] & BIT(0);
@@ -56,8 +61,19 @@ out:
56 61
57static int ar1021_i2c_open(struct input_dev *dev) 62static int ar1021_i2c_open(struct input_dev *dev)
58{ 63{
64 static const u8 cmd_enable_touch[] = {
65 AR1021_CMD,
66 0x01, /* number of bytes after this */
67 AR1021_CMD_ENABLE_TOUCH
68 };
59 struct ar1021_i2c *ar1021 = input_get_drvdata(dev); 69 struct ar1021_i2c *ar1021 = input_get_drvdata(dev);
60 struct i2c_client *client = ar1021->client; 70 struct i2c_client *client = ar1021->client;
71 int error;
72
73 error = i2c_master_send(ar1021->client, cmd_enable_touch,
74 sizeof(cmd_enable_touch));
75 if (error < 0)
76 return error;
61 77
62 enable_irq(client->irq); 78 enable_irq(client->irq);
63 79
@@ -73,7 +89,7 @@ static void ar1021_i2c_close(struct input_dev *dev)
73} 89}
74 90
75static int ar1021_i2c_probe(struct i2c_client *client, 91static int ar1021_i2c_probe(struct i2c_client *client,
76 const struct i2c_device_id *id) 92 const struct i2c_device_id *id)
77{ 93{
78 struct ar1021_i2c *ar1021; 94 struct ar1021_i2c *ar1021;
79 struct input_dev *input; 95 struct input_dev *input;
@@ -109,7 +125,7 @@ static int ar1021_i2c_probe(struct i2c_client *client,
109 125
110 error = devm_request_threaded_irq(&client->dev, client->irq, 126 error = devm_request_threaded_irq(&client->dev, client->irq,
111 NULL, ar1021_i2c_irq, 127 NULL, ar1021_i2c_irq,
112 IRQF_TRIGGER_RISING | IRQF_ONESHOT, 128 IRQF_ONESHOT,
113 "ar1021_i2c", ar1021); 129 "ar1021_i2c", ar1021);
114 if (error) { 130 if (error) {
115 dev_err(&client->dev, 131 dev_err(&client->dev,
@@ -151,7 +167,7 @@ static int __maybe_unused ar1021_i2c_resume(struct device *dev)
151static SIMPLE_DEV_PM_OPS(ar1021_i2c_pm, ar1021_i2c_suspend, ar1021_i2c_resume); 167static SIMPLE_DEV_PM_OPS(ar1021_i2c_pm, ar1021_i2c_suspend, ar1021_i2c_resume);
152 168
153static const struct i2c_device_id ar1021_i2c_id[] = { 169static const struct i2c_device_id ar1021_i2c_id[] = {
154 { "MICROCHIP_AR1021_I2C", 0 }, 170 { "ar1021", 0 },
155 { }, 171 { },
156}; 172};
157MODULE_DEVICE_TABLE(i2c, ar1021_i2c_id); 173MODULE_DEVICE_TABLE(i2c, ar1021_i2c_id);
@@ -175,5 +191,5 @@ static struct i2c_driver ar1021_i2c_driver = {
175module_i2c_driver(ar1021_i2c_driver); 191module_i2c_driver(ar1021_i2c_driver);
176 192
177MODULE_AUTHOR("Christian Gmeiner <christian.gmeiner@gmail.com>"); 193MODULE_AUTHOR("Christian Gmeiner <christian.gmeiner@gmail.com>");
178MODULE_DESCRIPTION("Microchip AR1021 I2C Driver"); 194MODULE_DESCRIPTION("Microchip AR1020 and AR1021 I2C Driver");
179MODULE_LICENSE("GPL"); 195MODULE_LICENSE("GPL");
diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
index 16023867b9da..2facad75eb6d 100644
--- a/drivers/input/touchscreen/eeti_ts.c
+++ b/drivers/input/touchscreen/eeti_ts.c
@@ -31,9 +31,9 @@
31#include <linux/interrupt.h> 31#include <linux/interrupt.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/timer.h> 33#include <linux/timer.h>
34#include <linux/gpio.h> 34#include <linux/gpio/consumer.h>
35#include <linux/input/eeti_ts.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
36#include <asm/unaligned.h>
37 37
38static bool flip_x; 38static bool flip_x;
39module_param(flip_x, bool, 0644); 39module_param(flip_x, bool, 0644);
@@ -43,54 +43,31 @@ static bool flip_y;
43module_param(flip_y, bool, 0644); 43module_param(flip_y, bool, 0644);
44MODULE_PARM_DESC(flip_y, "flip y coordinate"); 44MODULE_PARM_DESC(flip_y, "flip y coordinate");
45 45
46struct eeti_ts_priv { 46struct eeti_ts {
47 struct i2c_client *client; 47 struct i2c_client *client;
48 struct input_dev *input; 48 struct input_dev *input;
49 struct work_struct work; 49 struct gpio_desc *attn_gpio;
50 struct mutex mutex; 50 bool running;
51 int irq_gpio, irq, irq_active_high;
52}; 51};
53 52
54#define EETI_TS_BITDEPTH (11) 53#define EETI_TS_BITDEPTH (11)
55#define EETI_MAXVAL ((1 << (EETI_TS_BITDEPTH + 1)) - 1) 54#define EETI_MAXVAL ((1 << (EETI_TS_BITDEPTH + 1)) - 1)
56 55
57#define REPORT_BIT_PRESSED (1 << 0) 56#define REPORT_BIT_PRESSED BIT(0)
58#define REPORT_BIT_AD0 (1 << 1) 57#define REPORT_BIT_AD0 BIT(1)
59#define REPORT_BIT_AD1 (1 << 2) 58#define REPORT_BIT_AD1 BIT(2)
60#define REPORT_BIT_HAS_PRESSURE (1 << 6) 59#define REPORT_BIT_HAS_PRESSURE BIT(6)
61#define REPORT_RES_BITS(v) (((v) >> 1) + EETI_TS_BITDEPTH) 60#define REPORT_RES_BITS(v) (((v) >> 1) + EETI_TS_BITDEPTH)
62 61
63static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv) 62static void eeti_ts_report_event(struct eeti_ts *eeti, u8 *buf)
64{ 63{
65 return gpio_get_value(priv->irq_gpio) == priv->irq_active_high; 64 unsigned int res;
66} 65 u16 x, y;
67
68static void eeti_ts_read(struct work_struct *work)
69{
70 char buf[6];
71 unsigned int x, y, res, pressed, to = 100;
72 struct eeti_ts_priv *priv =
73 container_of(work, struct eeti_ts_priv, work);
74 66
75 mutex_lock(&priv->mutex);
76
77 while (eeti_ts_irq_active(priv) && --to)
78 i2c_master_recv(priv->client, buf, sizeof(buf));
79
80 if (!to) {
81 dev_err(&priv->client->dev,
82 "unable to clear IRQ - line stuck?\n");
83 goto out;
84 }
85
86 /* drop non-report packets */
87 if (!(buf[0] & 0x80))
88 goto out;
89
90 pressed = buf[0] & REPORT_BIT_PRESSED;
91 res = REPORT_RES_BITS(buf[0] & (REPORT_BIT_AD0 | REPORT_BIT_AD1)); 67 res = REPORT_RES_BITS(buf[0] & (REPORT_BIT_AD0 | REPORT_BIT_AD1));
92 x = buf[2] | (buf[1] << 8); 68
93 y = buf[4] | (buf[3] << 8); 69 x = get_unaligned_be16(&buf[1]);
70 y = get_unaligned_be16(&buf[3]);
94 71
95 /* fix the range to 11 bits */ 72 /* fix the range to 11 bits */
96 x >>= res - EETI_TS_BITDEPTH; 73 x >>= res - EETI_TS_BITDEPTH;
@@ -103,65 +80,78 @@ static void eeti_ts_read(struct work_struct *work)
103 y = EETI_MAXVAL - y; 80 y = EETI_MAXVAL - y;
104 81
105 if (buf[0] & REPORT_BIT_HAS_PRESSURE) 82 if (buf[0] & REPORT_BIT_HAS_PRESSURE)
106 input_report_abs(priv->input, ABS_PRESSURE, buf[5]); 83 input_report_abs(eeti->input, ABS_PRESSURE, buf[5]);
107 84
108 input_report_abs(priv->input, ABS_X, x); 85 input_report_abs(eeti->input, ABS_X, x);
109 input_report_abs(priv->input, ABS_Y, y); 86 input_report_abs(eeti->input, ABS_Y, y);
110 input_report_key(priv->input, BTN_TOUCH, !!pressed); 87 input_report_key(eeti->input, BTN_TOUCH, buf[0] & REPORT_BIT_PRESSED);
111 input_sync(priv->input); 88 input_sync(eeti->input);
112
113out:
114 mutex_unlock(&priv->mutex);
115} 89}
116 90
117static irqreturn_t eeti_ts_isr(int irq, void *dev_id) 91static irqreturn_t eeti_ts_isr(int irq, void *dev_id)
118{ 92{
119 struct eeti_ts_priv *priv = dev_id; 93 struct eeti_ts *eeti = dev_id;
94 int len;
95 int error;
96 char buf[6];
120 97
121 /* postpone I2C transactions as we are atomic */ 98 do {
122 schedule_work(&priv->work); 99 len = i2c_master_recv(eeti->client, buf, sizeof(buf));
100 if (len != sizeof(buf)) {
101 error = len < 0 ? len : -EIO;
102 dev_err(&eeti->client->dev,
103 "failed to read touchscreen data: %d\n",
104 error);
105 break;
106 }
107
108 if (buf[0] & 0x80) {
109 /* Motion packet */
110 eeti_ts_report_event(eeti, buf);
111 }
112 } while (eeti->running &&
113 eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio));
123 114
124 return IRQ_HANDLED; 115 return IRQ_HANDLED;
125} 116}
126 117
127static void eeti_ts_start(struct eeti_ts_priv *priv) 118static void eeti_ts_start(struct eeti_ts *eeti)
128{ 119{
129 enable_irq(priv->irq); 120 eeti->running = true;
130 121 wmb();
131 /* Read the events once to arm the IRQ */ 122 enable_irq(eeti->client->irq);
132 eeti_ts_read(&priv->work);
133} 123}
134 124
135static void eeti_ts_stop(struct eeti_ts_priv *priv) 125static void eeti_ts_stop(struct eeti_ts *eeti)
136{ 126{
137 disable_irq(priv->irq); 127 eeti->running = false;
138 cancel_work_sync(&priv->work); 128 wmb();
129 disable_irq(eeti->client->irq);
139} 130}
140 131
141static int eeti_ts_open(struct input_dev *dev) 132static int eeti_ts_open(struct input_dev *dev)
142{ 133{
143 struct eeti_ts_priv *priv = input_get_drvdata(dev); 134 struct eeti_ts *eeti = input_get_drvdata(dev);
144 135
145 eeti_ts_start(priv); 136 eeti_ts_start(eeti);
146 137
147 return 0; 138 return 0;
148} 139}
149 140
150static void eeti_ts_close(struct input_dev *dev) 141static void eeti_ts_close(struct input_dev *dev)
151{ 142{
152 struct eeti_ts_priv *priv = input_get_drvdata(dev); 143 struct eeti_ts *eeti = input_get_drvdata(dev);
153 144
154 eeti_ts_stop(priv); 145 eeti_ts_stop(eeti);
155} 146}
156 147
157static int eeti_ts_probe(struct i2c_client *client, 148static int eeti_ts_probe(struct i2c_client *client,
158 const struct i2c_device_id *idp) 149 const struct i2c_device_id *idp)
159{ 150{
160 struct eeti_ts_platform_data *pdata = dev_get_platdata(&client->dev); 151 struct device *dev = &client->dev;
161 struct eeti_ts_priv *priv; 152 struct eeti_ts *eeti;
162 struct input_dev *input; 153 struct input_dev *input;
163 unsigned int irq_flags; 154 int error;
164 int err = -ENOMEM;
165 155
166 /* 156 /*
167 * In contrast to what's described in the datasheet, there seems 157 * In contrast to what's described in the datasheet, there seems
@@ -170,21 +160,19 @@ static int eeti_ts_probe(struct i2c_client *client,
170 * for interrupts to occur. 160 * for interrupts to occur.
171 */ 161 */
172 162
173 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 163 eeti = devm_kzalloc(dev, sizeof(*eeti), GFP_KERNEL);
174 if (!priv) { 164 if (!eeti) {
175 dev_err(&client->dev, "failed to allocate driver data\n"); 165 dev_err(dev, "failed to allocate driver data\n");
176 return -ENOMEM; 166 return -ENOMEM;
177 } 167 }
178 168
179 mutex_init(&priv->mutex); 169 input = devm_input_allocate_device(dev);
180 input = input_allocate_device();
181 if (!input) { 170 if (!input) {
182 dev_err(&client->dev, "Failed to allocate input device.\n"); 171 dev_err(dev, "Failed to allocate input device.\n");
183 goto err1; 172 return -ENOMEM;
184 } 173 }
185 174
186 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 175 input_set_capability(input, EV_KEY, BTN_TOUCH);
187 input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
188 176
189 input_set_abs_params(input, ABS_X, 0, EETI_MAXVAL, 0, 0); 177 input_set_abs_params(input, ABS_X, 0, EETI_MAXVAL, 0, 0);
190 input_set_abs_params(input, ABS_Y, 0, EETI_MAXVAL, 0, 0); 178 input_set_abs_params(input, ABS_Y, 0, EETI_MAXVAL, 0, 0);
@@ -192,71 +180,38 @@ static int eeti_ts_probe(struct i2c_client *client,
192 180
193 input->name = client->name; 181 input->name = client->name;
194 input->id.bustype = BUS_I2C; 182 input->id.bustype = BUS_I2C;
195 input->dev.parent = &client->dev;
196 input->open = eeti_ts_open; 183 input->open = eeti_ts_open;
197 input->close = eeti_ts_close; 184 input->close = eeti_ts_close;
198 185
199 priv->client = client; 186 eeti->client = client;
200 priv->input = input; 187 eeti->input = input;
201 priv->irq_gpio = pdata->irq_gpio;
202 priv->irq = gpio_to_irq(pdata->irq_gpio);
203
204 err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name);
205 if (err < 0)
206 goto err1;
207
208 priv->irq_active_high = pdata->irq_active_high;
209
210 irq_flags = priv->irq_active_high ?
211 IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING;
212 188
213 INIT_WORK(&priv->work, eeti_ts_read); 189 eeti->attn_gpio = devm_gpiod_get_optional(dev, "attn", GPIOD_IN);
214 i2c_set_clientdata(client, priv); 190 if (IS_ERR(eeti->attn_gpio))
215 input_set_drvdata(input, priv); 191 return PTR_ERR(eeti->attn_gpio);
216 192
217 err = input_register_device(input); 193 i2c_set_clientdata(client, eeti);
218 if (err) 194 input_set_drvdata(input, eeti);
219 goto err2;
220 195
221 err = request_irq(priv->irq, eeti_ts_isr, irq_flags, 196 error = devm_request_threaded_irq(dev, client->irq,
222 client->name, priv); 197 NULL, eeti_ts_isr,
223 if (err) { 198 IRQF_ONESHOT,
224 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 199 client->name, eeti);
225 goto err3; 200 if (error) {
201 dev_err(dev, "Unable to request touchscreen IRQ: %d\n",
202 error);
203 return error;
226 } 204 }
227 205
228 /* 206 /*
229 * Disable the device for now. It will be enabled once the 207 * Disable the device for now. It will be enabled once the
230 * input device is opened. 208 * input device is opened.
231 */ 209 */
232 eeti_ts_stop(priv); 210 eeti_ts_stop(eeti);
233
234 return 0;
235
236err3:
237 input_unregister_device(input);
238 input = NULL; /* so we dont try to free it below */
239err2:
240 gpio_free(pdata->irq_gpio);
241err1:
242 input_free_device(input);
243 kfree(priv);
244 return err;
245}
246
247static int eeti_ts_remove(struct i2c_client *client)
248{
249 struct eeti_ts_priv *priv = i2c_get_clientdata(client);
250
251 free_irq(priv->irq, priv);
252 /*
253 * eeti_ts_stop() leaves IRQ disabled. We need to re-enable it
254 * so that device still works if we reload the driver.
255 */
256 enable_irq(priv->irq);
257 211
258 input_unregister_device(priv->input); 212 error = input_register_device(input);
259 kfree(priv); 213 if (error)
214 return error;
260 215
261 return 0; 216 return 0;
262} 217}
@@ -264,18 +219,18 @@ static int eeti_ts_remove(struct i2c_client *client)
264static int __maybe_unused eeti_ts_suspend(struct device *dev) 219static int __maybe_unused eeti_ts_suspend(struct device *dev)
265{ 220{
266 struct i2c_client *client = to_i2c_client(dev); 221 struct i2c_client *client = to_i2c_client(dev);
267 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 222 struct eeti_ts *eeti = i2c_get_clientdata(client);
268 struct input_dev *input_dev = priv->input; 223 struct input_dev *input_dev = eeti->input;
269 224
270 mutex_lock(&input_dev->mutex); 225 mutex_lock(&input_dev->mutex);
271 226
272 if (input_dev->users) 227 if (input_dev->users)
273 eeti_ts_stop(priv); 228 eeti_ts_stop(eeti);
274 229
275 mutex_unlock(&input_dev->mutex); 230 mutex_unlock(&input_dev->mutex);
276 231
277 if (device_may_wakeup(&client->dev)) 232 if (device_may_wakeup(&client->dev))
278 enable_irq_wake(priv->irq); 233 enable_irq_wake(client->irq);
279 234
280 return 0; 235 return 0;
281} 236}
@@ -283,16 +238,16 @@ static int __maybe_unused eeti_ts_suspend(struct device *dev)
283static int __maybe_unused eeti_ts_resume(struct device *dev) 238static int __maybe_unused eeti_ts_resume(struct device *dev)
284{ 239{
285 struct i2c_client *client = to_i2c_client(dev); 240 struct i2c_client *client = to_i2c_client(dev);
286 struct eeti_ts_priv *priv = i2c_get_clientdata(client); 241 struct eeti_ts *eeti = i2c_get_clientdata(client);
287 struct input_dev *input_dev = priv->input; 242 struct input_dev *input_dev = eeti->input;
288 243
289 if (device_may_wakeup(&client->dev)) 244 if (device_may_wakeup(&client->dev))
290 disable_irq_wake(priv->irq); 245 disable_irq_wake(client->irq);
291 246
292 mutex_lock(&input_dev->mutex); 247 mutex_lock(&input_dev->mutex);
293 248
294 if (input_dev->users) 249 if (input_dev->users)
295 eeti_ts_start(priv); 250 eeti_ts_start(eeti);
296 251
297 mutex_unlock(&input_dev->mutex); 252 mutex_unlock(&input_dev->mutex);
298 253
@@ -313,7 +268,6 @@ static struct i2c_driver eeti_ts_driver = {
313 .pm = &eeti_ts_pm, 268 .pm = &eeti_ts_pm,
314 }, 269 },
315 .probe = eeti_ts_probe, 270 .probe = eeti_ts_probe,
316 .remove = eeti_ts_remove,
317 .id_table = eeti_ts_id, 271 .id_table = eeti_ts_id,
318}; 272};
319 273
diff --git a/drivers/input/touchscreen/imx6ul_tsc.c b/drivers/input/touchscreen/imx6ul_tsc.c
index 7098e0a47019..ee82a975bfd2 100644
--- a/drivers/input/touchscreen/imx6ul_tsc.c
+++ b/drivers/input/touchscreen/imx6ul_tsc.c
@@ -337,11 +337,20 @@ static int imx6ul_tsc_open(struct input_dev *input_dev)
337 dev_err(tsc->dev, 337 dev_err(tsc->dev,
338 "Could not prepare or enable the tsc clock: %d\n", 338 "Could not prepare or enable the tsc clock: %d\n",
339 err); 339 err);
340 clk_disable_unprepare(tsc->adc_clk); 340 goto disable_adc_clk;
341 return err;
342 } 341 }
343 342
344 return imx6ul_tsc_init(tsc); 343 err = imx6ul_tsc_init(tsc);
344 if (err)
345 goto disable_tsc_clk;
346
347 return 0;
348
349disable_tsc_clk:
350 clk_disable_unprepare(tsc->tsc_clk);
351disable_adc_clk:
352 clk_disable_unprepare(tsc->adc_clk);
353 return err;
345} 354}
346 355
347static void imx6ul_tsc_close(struct input_dev *input_dev) 356static void imx6ul_tsc_close(struct input_dev *input_dev)
diff --git a/drivers/input/touchscreen/lpc32xx_ts.c b/drivers/input/touchscreen/lpc32xx_ts.c
index e0baa7de4102..4eb31ec10b18 100644
--- a/drivers/input/touchscreen/lpc32xx_ts.c
+++ b/drivers/input/touchscreen/lpc32xx_ts.c
@@ -142,11 +142,14 @@ static void lpc32xx_stop_tsc(struct lpc32xx_tsc *tsc)
142 clk_disable_unprepare(tsc->clk); 142 clk_disable_unprepare(tsc->clk);
143} 143}
144 144
145static void lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc) 145static int lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
146{ 146{
147 u32 tmp; 147 u32 tmp;
148 int err;
148 149
149 clk_prepare_enable(tsc->clk); 150 err = clk_prepare_enable(tsc->clk);
151 if (err)
152 return err;
150 153
151 tmp = tsc_readl(tsc, LPC32XX_TSC_CON) & ~LPC32XX_TSC_ADCCON_POWER_UP; 154 tmp = tsc_readl(tsc, LPC32XX_TSC_CON) & ~LPC32XX_TSC_ADCCON_POWER_UP;
152 155
@@ -184,15 +187,15 @@ static void lpc32xx_setup_tsc(struct lpc32xx_tsc *tsc)
184 187
185 /* Enable automatic ts event capture */ 188 /* Enable automatic ts event capture */
186 tsc_writel(tsc, LPC32XX_TSC_CON, tmp | LPC32XX_TSC_ADCCON_AUTO_EN); 189 tsc_writel(tsc, LPC32XX_TSC_CON, tmp | LPC32XX_TSC_ADCCON_AUTO_EN);
190
191 return 0;
187} 192}
188 193
189static int lpc32xx_ts_open(struct input_dev *dev) 194static int lpc32xx_ts_open(struct input_dev *dev)
190{ 195{
191 struct lpc32xx_tsc *tsc = input_get_drvdata(dev); 196 struct lpc32xx_tsc *tsc = input_get_drvdata(dev);
192 197
193 lpc32xx_setup_tsc(tsc); 198 return lpc32xx_setup_tsc(tsc);
194
195 return 0;
196} 199}
197 200
198static void lpc32xx_ts_close(struct input_dev *dev) 201static void lpc32xx_ts_close(struct input_dev *dev)
diff --git a/drivers/input/touchscreen/max11801_ts.c b/drivers/input/touchscreen/max11801_ts.c
index a595ae5284e3..72ca3efb5781 100644
--- a/drivers/input/touchscreen/max11801_ts.c
+++ b/drivers/input/touchscreen/max11801_ts.c
@@ -224,9 +224,16 @@ static const struct i2c_device_id max11801_ts_id[] = {
224}; 224};
225MODULE_DEVICE_TABLE(i2c, max11801_ts_id); 225MODULE_DEVICE_TABLE(i2c, max11801_ts_id);
226 226
227static const struct of_device_id max11801_ts_dt_ids[] = {
228 { .compatible = "maxim,max11801" },
229 { /* sentinel */ }
230};
231MODULE_DEVICE_TABLE(of, max11801_ts_dt_ids);
232
227static struct i2c_driver max11801_ts_driver = { 233static struct i2c_driver max11801_ts_driver = {
228 .driver = { 234 .driver = {
229 .name = "max11801_ts", 235 .name = "max11801_ts",
236 .of_match_table = max11801_ts_dt_ids,
230 }, 237 },
231 .id_table = max11801_ts_id, 238 .id_table = max11801_ts_id,
232 .probe = max11801_ts_probe, 239 .probe = max11801_ts_probe,
diff --git a/drivers/input/touchscreen/melfas_mip4.c b/drivers/input/touchscreen/melfas_mip4.c
index 703d7f983d0a..05108c2fea93 100644
--- a/drivers/input/touchscreen/melfas_mip4.c
+++ b/drivers/input/touchscreen/melfas_mip4.c
@@ -253,10 +253,21 @@ static int mip4_get_fw_version(struct mip4_ts *ts)
253 */ 253 */
254static int mip4_query_device(struct mip4_ts *ts) 254static int mip4_query_device(struct mip4_ts *ts)
255{ 255{
256 union i2c_smbus_data dummy;
256 int error; 257 int error;
257 u8 cmd[2]; 258 u8 cmd[2];
258 u8 buf[14]; 259 u8 buf[14];
259 260
261 /*
262 * Make sure there is something at this address as we do not
263 * consider subsequent failures as fatal.
264 */
265 if (i2c_smbus_xfer(ts->client->adapter, ts->client->addr,
266 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) < 0) {
267 dev_err(&ts->client->dev, "nothing at this address\n");
268 return -ENXIO;
269 }
270
260 /* Product name */ 271 /* Product name */
261 cmd[0] = MIP4_R0_INFO; 272 cmd[0] = MIP4_R0_INFO;
262 cmd[1] = MIP4_R1_INFO_PRODUCT_NAME; 273 cmd[1] = MIP4_R1_INFO_PRODUCT_NAME;
diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
index 404830a4a366..813dd68a5c82 100644
--- a/drivers/input/touchscreen/silead.c
+++ b/drivers/input/touchscreen/silead.c
@@ -580,12 +580,25 @@ static const struct acpi_device_id silead_ts_acpi_match[] = {
580MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match); 580MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match);
581#endif 581#endif
582 582
583#ifdef CONFIG_OF
584static const struct of_device_id silead_ts_of_match[] = {
585 { .compatible = "silead,gsl1680" },
586 { .compatible = "silead,gsl1688" },
587 { .compatible = "silead,gsl3670" },
588 { .compatible = "silead,gsl3675" },
589 { .compatible = "silead,gsl3692" },
590 { },
591};
592MODULE_DEVICE_TABLE(of, silead_ts_of_match);
593#endif
594
583static struct i2c_driver silead_ts_driver = { 595static struct i2c_driver silead_ts_driver = {
584 .probe = silead_ts_probe, 596 .probe = silead_ts_probe,
585 .id_table = silead_ts_id, 597 .id_table = silead_ts_id,
586 .driver = { 598 .driver = {
587 .name = SILEAD_TS_NAME, 599 .name = SILEAD_TS_NAME,
588 .acpi_match_table = ACPI_PTR(silead_ts_acpi_match), 600 .acpi_match_table = ACPI_PTR(silead_ts_acpi_match),
601 .of_match_table = of_match_ptr(silead_ts_of_match),
589 .pm = &silead_ts_pm, 602 .pm = &silead_ts_pm,
590 }, 603 },
591}; 604};
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index 4c0eecae065c..128e5bd74720 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -369,7 +369,7 @@ static void sur40_poll(struct input_polled_dev *polldev)
369 * packet ID will usually increase in the middle of a series 369 * packet ID will usually increase in the middle of a series
370 * instead of at the end. 370 * instead of at the end.
371 */ 371 */
372 if (packet_id != header->packet_id) 372 if (packet_id != le32_to_cpu(header->packet_id))
373 dev_dbg(sur40->dev, "packet ID mismatch\n"); 373 dev_dbg(sur40->dev, "packet ID mismatch\n");
374 374
375 packet_blobs = result / sizeof(struct sur40_blob); 375 packet_blobs = result / sizeof(struct sur40_blob);
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
index a340bfccdfb6..75170a7439b1 100644
--- a/drivers/input/touchscreen/tps6507x-ts.c
+++ b/drivers/input/touchscreen/tps6507x-ts.c
@@ -226,7 +226,7 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
226 */ 226 */
227 init_data = tps_board->tps6507x_ts_init_data; 227 init_data = tps_board->tps6507x_ts_init_data;
228 228
229 tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL); 229 tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL);
230 if (!tsc) { 230 if (!tsc) {
231 dev_err(tps6507x_dev->dev, "failed to allocate driver data\n"); 231 dev_err(tps6507x_dev->dev, "failed to allocate driver data\n");
232 return -ENOMEM; 232 return -ENOMEM;
@@ -240,11 +240,10 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
240 snprintf(tsc->phys, sizeof(tsc->phys), 240 snprintf(tsc->phys, sizeof(tsc->phys),
241 "%s/input0", dev_name(tsc->dev)); 241 "%s/input0", dev_name(tsc->dev));
242 242
243 poll_dev = input_allocate_polled_device(); 243 poll_dev = devm_input_allocate_polled_device(&pdev->dev);
244 if (!poll_dev) { 244 if (!poll_dev) {
245 dev_err(tsc->dev, "Failed to allocate polled input device.\n"); 245 dev_err(tsc->dev, "Failed to allocate polled input device.\n");
246 error = -ENOMEM; 246 return -ENOMEM;
247 goto err_free_mem;
248 } 247 }
249 248
250 tsc->poll_dev = poll_dev; 249 tsc->poll_dev = poll_dev;
@@ -274,32 +273,11 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
274 273
275 error = tps6507x_adc_standby(tsc); 274 error = tps6507x_adc_standby(tsc);
276 if (error) 275 if (error)
277 goto err_free_polled_dev; 276 return error;
278 277
279 error = input_register_polled_device(poll_dev); 278 error = input_register_polled_device(poll_dev);
280 if (error) 279 if (error)
281 goto err_free_polled_dev; 280 return error;
282
283 platform_set_drvdata(pdev, tsc);
284
285 return 0;
286
287err_free_polled_dev:
288 input_free_polled_device(poll_dev);
289err_free_mem:
290 kfree(tsc);
291 return error;
292}
293
294static int tps6507x_ts_remove(struct platform_device *pdev)
295{
296 struct tps6507x_ts *tsc = platform_get_drvdata(pdev);
297 struct input_polled_dev *poll_dev = tsc->poll_dev;
298
299 input_unregister_polled_device(poll_dev);
300 input_free_polled_device(poll_dev);
301
302 kfree(tsc);
303 281
304 return 0; 282 return 0;
305} 283}
@@ -309,7 +287,6 @@ static struct platform_driver tps6507x_ts_driver = {
309 .name = "tps6507x-ts", 287 .name = "tps6507x-ts",
310 }, 288 },
311 .probe = tps6507x_ts_probe, 289 .probe = tps6507x_ts_probe,
312 .remove = tps6507x_ts_remove,
313}; 290};
314module_platform_driver(tps6507x_ts_driver); 291module_platform_driver(tps6507x_ts_driver);
315 292
diff --git a/drivers/input/touchscreen/tsc2007.h b/drivers/input/touchscreen/tsc2007.h
new file mode 100644
index 000000000000..30fdf5b04a6b
--- /dev/null
+++ b/drivers/input/touchscreen/tsc2007.h
@@ -0,0 +1,101 @@
1
2/*
3 * Copyright (c) 2008 MtekVision Co., Ltd.
4 * Kwangwoo Lee <kwlee@mtekvision.com>
5 *
6 * Using code from:
7 * - ads7846.c
8 * Copyright (c) 2005 David Brownell
9 * Copyright (c) 2006 Nokia Corporation
10 * - corgi_ts.c
11 * Copyright (C) 2004-2005 Richard Purdie
12 * - omap_ts.[hc], ads7846.h, ts_osk.c
13 * Copyright (C) 2002 MontaVista Software
14 * Copyright (C) 2004 Texas Instruments
15 * Copyright (C) 2005 Dirk Behme
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License version 2 as
19 * published by the Free Software Foundation.
20 */
21
22#ifndef _TSC2007_H
23#define _TSC2007_H
24
25#define TSC2007_MEASURE_TEMP0 (0x0 << 4)
26#define TSC2007_MEASURE_AUX (0x2 << 4)
27#define TSC2007_MEASURE_TEMP1 (0x4 << 4)
28#define TSC2007_ACTIVATE_XN (0x8 << 4)
29#define TSC2007_ACTIVATE_YN (0x9 << 4)
30#define TSC2007_ACTIVATE_YP_XN (0xa << 4)
31#define TSC2007_SETUP (0xb << 4)
32#define TSC2007_MEASURE_X (0xc << 4)
33#define TSC2007_MEASURE_Y (0xd << 4)
34#define TSC2007_MEASURE_Z1 (0xe << 4)
35#define TSC2007_MEASURE_Z2 (0xf << 4)
36
37#define TSC2007_POWER_OFF_IRQ_EN (0x0 << 2)
38#define TSC2007_ADC_ON_IRQ_DIS0 (0x1 << 2)
39#define TSC2007_ADC_OFF_IRQ_EN (0x2 << 2)
40#define TSC2007_ADC_ON_IRQ_DIS1 (0x3 << 2)
41
42#define TSC2007_12BIT (0x0 << 1)
43#define TSC2007_8BIT (0x1 << 1)
44
45#define MAX_12BIT ((1 << 12) - 1)
46
47#define ADC_ON_12BIT (TSC2007_12BIT | TSC2007_ADC_ON_IRQ_DIS0)
48
49#define READ_Y (ADC_ON_12BIT | TSC2007_MEASURE_Y)
50#define READ_Z1 (ADC_ON_12BIT | TSC2007_MEASURE_Z1)
51#define READ_Z2 (ADC_ON_12BIT | TSC2007_MEASURE_Z2)
52#define READ_X (ADC_ON_12BIT | TSC2007_MEASURE_X)
53#define PWRDOWN (TSC2007_12BIT | TSC2007_POWER_OFF_IRQ_EN)
54
55struct ts_event {
56 u16 x;
57 u16 y;
58 u16 z1, z2;
59};
60
61struct tsc2007 {
62 struct input_dev *input;
63 char phys[32];
64
65 struct i2c_client *client;
66
67 u16 model;
68 u16 x_plate_ohms;
69 u16 max_rt;
70 unsigned long poll_period; /* in jiffies */
71 int fuzzx;
72 int fuzzy;
73 int fuzzz;
74
75 unsigned int gpio;
76 int irq;
77
78 wait_queue_head_t wait;
79 bool stopped;
80
81 int (*get_pendown_state)(struct device *);
82 void (*clear_penirq)(void);
83
84 struct mutex mlock;
85};
86
87int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd);
88u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc);
89bool tsc2007_is_pen_down(struct tsc2007 *ts);
90
91#if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2007_IIO)
92/* defined in tsc2007_iio.c */
93int tsc2007_iio_configure(struct tsc2007 *ts);
94#else
95static inline int tsc2007_iio_configure(struct tsc2007 *ts)
96{
97 return 0;
98}
99#endif /* CONFIG_TOUCHSCREEN_TSC2007_IIO */
100
101#endif /* _TSC2007_H */
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007_core.c
index 5d0cd51c6f41..fc7384936011 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007_core.c
@@ -27,70 +27,10 @@
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/i2c/tsc2007.h> 28#include <linux/i2c/tsc2007.h>
29#include <linux/of_device.h> 29#include <linux/of_device.h>
30#include <linux/of.h>
31#include <linux/of_gpio.h> 30#include <linux/of_gpio.h>
31#include "tsc2007.h"
32 32
33#define TSC2007_MEASURE_TEMP0 (0x0 << 4) 33int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
34#define TSC2007_MEASURE_AUX (0x2 << 4)
35#define TSC2007_MEASURE_TEMP1 (0x4 << 4)
36#define TSC2007_ACTIVATE_XN (0x8 << 4)
37#define TSC2007_ACTIVATE_YN (0x9 << 4)
38#define TSC2007_ACTIVATE_YP_XN (0xa << 4)
39#define TSC2007_SETUP (0xb << 4)
40#define TSC2007_MEASURE_X (0xc << 4)
41#define TSC2007_MEASURE_Y (0xd << 4)
42#define TSC2007_MEASURE_Z1 (0xe << 4)
43#define TSC2007_MEASURE_Z2 (0xf << 4)
44
45#define TSC2007_POWER_OFF_IRQ_EN (0x0 << 2)
46#define TSC2007_ADC_ON_IRQ_DIS0 (0x1 << 2)
47#define TSC2007_ADC_OFF_IRQ_EN (0x2 << 2)
48#define TSC2007_ADC_ON_IRQ_DIS1 (0x3 << 2)
49
50#define TSC2007_12BIT (0x0 << 1)
51#define TSC2007_8BIT (0x1 << 1)
52
53#define MAX_12BIT ((1 << 12) - 1)
54
55#define ADC_ON_12BIT (TSC2007_12BIT | TSC2007_ADC_ON_IRQ_DIS0)
56
57#define READ_Y (ADC_ON_12BIT | TSC2007_MEASURE_Y)
58#define READ_Z1 (ADC_ON_12BIT | TSC2007_MEASURE_Z1)
59#define READ_Z2 (ADC_ON_12BIT | TSC2007_MEASURE_Z2)
60#define READ_X (ADC_ON_12BIT | TSC2007_MEASURE_X)
61#define PWRDOWN (TSC2007_12BIT | TSC2007_POWER_OFF_IRQ_EN)
62
63struct ts_event {
64 u16 x;
65 u16 y;
66 u16 z1, z2;
67};
68
69struct tsc2007 {
70 struct input_dev *input;
71 char phys[32];
72
73 struct i2c_client *client;
74
75 u16 model;
76 u16 x_plate_ohms;
77 u16 max_rt;
78 unsigned long poll_period; /* in jiffies */
79 int fuzzx;
80 int fuzzy;
81 int fuzzz;
82
83 unsigned gpio;
84 int irq;
85
86 wait_queue_head_t wait;
87 bool stopped;
88
89 int (*get_pendown_state)(struct device *);
90 void (*clear_penirq)(void);
91};
92
93static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
94{ 34{
95 s32 data; 35 s32 data;
96 u16 val; 36 u16 val;
@@ -128,7 +68,7 @@ static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
128 tsc2007_xfer(tsc, PWRDOWN); 68 tsc2007_xfer(tsc, PWRDOWN);
129} 69}
130 70
131static u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc) 71u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc)
132{ 72{
133 u32 rt = 0; 73 u32 rt = 0;
134 74
@@ -137,7 +77,7 @@ static u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
137 tc->x = 0; 77 tc->x = 0;
138 78
139 if (likely(tc->x && tc->z1)) { 79 if (likely(tc->x && tc->z1)) {
140 /* compute touch pressure resistance using equation #1 */ 80 /* compute touch resistance using equation #1 */
141 rt = tc->z2 - tc->z1; 81 rt = tc->z2 - tc->z1;
142 rt *= tc->x; 82 rt *= tc->x;
143 rt *= tsc->x_plate_ohms; 83 rt *= tsc->x_plate_ohms;
@@ -148,7 +88,7 @@ static u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
148 return rt; 88 return rt;
149} 89}
150 90
151static bool tsc2007_is_pen_down(struct tsc2007 *ts) 91bool tsc2007_is_pen_down(struct tsc2007 *ts)
152{ 92{
153 /* 93 /*
154 * NOTE: We can't rely on the pressure to determine the pen down 94 * NOTE: We can't rely on the pressure to determine the pen down
@@ -180,9 +120,12 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
180 while (!ts->stopped && tsc2007_is_pen_down(ts)) { 120 while (!ts->stopped && tsc2007_is_pen_down(ts)) {
181 121
182 /* pen is down, continue with the measurement */ 122 /* pen is down, continue with the measurement */
123
124 mutex_lock(&ts->mlock);
183 tsc2007_read_values(ts, &tc); 125 tsc2007_read_values(ts, &tc);
126 mutex_unlock(&ts->mlock);
184 127
185 rt = tsc2007_calculate_pressure(ts, &tc); 128 rt = tsc2007_calculate_resistance(ts, &tc);
186 129
187 if (!rt && !ts->get_pendown_state) { 130 if (!rt && !ts->get_pendown_state) {
188 /* 131 /*
@@ -195,9 +138,11 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
195 138
196 if (rt <= ts->max_rt) { 139 if (rt <= ts->max_rt) {
197 dev_dbg(&ts->client->dev, 140 dev_dbg(&ts->client->dev,
198 "DOWN point(%4d,%4d), pressure (%4u)\n", 141 "DOWN point(%4d,%4d), resistance (%4u)\n",
199 tc.x, tc.y, rt); 142 tc.x, tc.y, rt);
200 143
144 rt = ts->max_rt - rt;
145
201 input_report_key(input, BTN_TOUCH, 1); 146 input_report_key(input, BTN_TOUCH, 1);
202 input_report_abs(input, ABS_X, tc.x); 147 input_report_abs(input, ABS_X, tc.x);
203 input_report_abs(input, ABS_Y, tc.y); 148 input_report_abs(input, ABS_Y, tc.y);
@@ -375,7 +320,8 @@ static void tsc2007_call_exit_platform_hw(void *data)
375static int tsc2007_probe(struct i2c_client *client, 320static int tsc2007_probe(struct i2c_client *client,
376 const struct i2c_device_id *id) 321 const struct i2c_device_id *id)
377{ 322{
378 const struct tsc2007_platform_data *pdata = dev_get_platdata(&client->dev); 323 const struct tsc2007_platform_data *pdata =
324 dev_get_platdata(&client->dev);
379 struct tsc2007 *ts; 325 struct tsc2007 *ts;
380 struct input_dev *input_dev; 326 struct input_dev *input_dev;
381 int err; 327 int err;
@@ -404,7 +350,9 @@ static int tsc2007_probe(struct i2c_client *client,
404 ts->client = client; 350 ts->client = client;
405 ts->irq = client->irq; 351 ts->irq = client->irq;
406 ts->input = input_dev; 352 ts->input = input_dev;
353
407 init_waitqueue_head(&ts->wait); 354 init_waitqueue_head(&ts->wait);
355 mutex_init(&ts->mlock);
408 356
409 snprintf(ts->phys, sizeof(ts->phys), 357 snprintf(ts->phys, sizeof(ts->phys),
410 "%s/input0", dev_name(&client->dev)); 358 "%s/input0", dev_name(&client->dev));
@@ -418,8 +366,7 @@ static int tsc2007_probe(struct i2c_client *client,
418 366
419 input_set_drvdata(input_dev, ts); 367 input_set_drvdata(input_dev, ts);
420 368
421 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 369 input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
422 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
423 370
424 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0); 371 input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzx, 0);
425 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0); 372 input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
@@ -455,6 +402,14 @@ static int tsc2007_probe(struct i2c_client *client,
455 402
456 tsc2007_stop(ts); 403 tsc2007_stop(ts);
457 404
405 /* power down the chip (TSC2007_SETUP does not ACK on I2C) */
406 err = tsc2007_xfer(ts, PWRDOWN);
407 if (err < 0) {
408 dev_err(&client->dev,
409 "Failed to setup chip: %d\n", err);
410 return err; /* chip does not respond */
411 }
412
458 err = input_register_device(input_dev); 413 err = input_register_device(input_dev);
459 if (err) { 414 if (err) {
460 dev_err(&client->dev, 415 dev_err(&client->dev,
@@ -462,6 +417,13 @@ static int tsc2007_probe(struct i2c_client *client,
462 return err; 417 return err;
463 } 418 }
464 419
420 err = tsc2007_iio_configure(ts);
421 if (err) {
422 dev_err(&client->dev,
423 "Failed to register with IIO: %d\n", err);
424 return err;
425 }
426
465 return 0; 427 return 0;
466} 428}
467 429
diff --git a/drivers/input/touchscreen/tsc2007_iio.c b/drivers/input/touchscreen/tsc2007_iio.c
new file mode 100644
index 000000000000..27b25a9fce83
--- /dev/null
+++ b/drivers/input/touchscreen/tsc2007_iio.c
@@ -0,0 +1,140 @@
1/*
2 * Copyright (c) 2016 Golden Delicious Comp. GmbH&Co. KG
3 * Nikolaus Schaller <hns@goldelico.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
10#include <linux/i2c.h>
11#include <linux/iio/iio.h>
12#include "tsc2007.h"
13
14struct tsc2007_iio {
15 struct tsc2007 *ts;
16};
17
18#define TSC2007_CHAN_IIO(_chan, _name, _type, _chan_info) \
19{ \
20 .datasheet_name = _name, \
21 .type = _type, \
22 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
23 BIT(_chan_info), \
24 .indexed = 1, \
25 .channel = _chan, \
26}
27
28static const struct iio_chan_spec tsc2007_iio_channel[] = {
29 TSC2007_CHAN_IIO(0, "x", IIO_VOLTAGE, IIO_CHAN_INFO_RAW),
30 TSC2007_CHAN_IIO(1, "y", IIO_VOLTAGE, IIO_CHAN_INFO_RAW),
31 TSC2007_CHAN_IIO(2, "z1", IIO_VOLTAGE, IIO_CHAN_INFO_RAW),
32 TSC2007_CHAN_IIO(3, "z2", IIO_VOLTAGE, IIO_CHAN_INFO_RAW),
33 TSC2007_CHAN_IIO(4, "adc", IIO_VOLTAGE, IIO_CHAN_INFO_RAW),
34 TSC2007_CHAN_IIO(5, "rt", IIO_VOLTAGE, IIO_CHAN_INFO_RAW), /* Ohms? */
35 TSC2007_CHAN_IIO(6, "pen", IIO_PRESSURE, IIO_CHAN_INFO_RAW),
36 TSC2007_CHAN_IIO(7, "temp0", IIO_TEMP, IIO_CHAN_INFO_RAW),
37 TSC2007_CHAN_IIO(8, "temp1", IIO_TEMP, IIO_CHAN_INFO_RAW),
38};
39
40static int tsc2007_read_raw(struct iio_dev *indio_dev,
41 struct iio_chan_spec const *chan,
42 int *val, int *val2, long mask)
43{
44 struct tsc2007_iio *iio = iio_priv(indio_dev);
45 struct tsc2007 *tsc = iio->ts;
46 int adc_chan = chan->channel;
47 int ret = 0;
48
49 if (adc_chan >= ARRAY_SIZE(tsc2007_iio_channel))
50 return -EINVAL;
51
52 if (mask != IIO_CHAN_INFO_RAW)
53 return -EINVAL;
54
55 mutex_lock(&tsc->mlock);
56
57 switch (chan->channel) {
58 case 0:
59 *val = tsc2007_xfer(tsc, READ_X);
60 break;
61 case 1:
62 *val = tsc2007_xfer(tsc, READ_Y);
63 break;
64 case 2:
65 *val = tsc2007_xfer(tsc, READ_Z1);
66 break;
67 case 3:
68 *val = tsc2007_xfer(tsc, READ_Z2);
69 break;
70 case 4:
71 *val = tsc2007_xfer(tsc, (ADC_ON_12BIT | TSC2007_MEASURE_AUX));
72 break;
73 case 5: {
74 struct ts_event tc;
75
76 tc.x = tsc2007_xfer(tsc, READ_X);
77 tc.z1 = tsc2007_xfer(tsc, READ_Z1);
78 tc.z2 = tsc2007_xfer(tsc, READ_Z2);
79 *val = tsc2007_calculate_resistance(tsc, &tc);
80 break;
81 }
82 case 6:
83 *val = tsc2007_is_pen_down(tsc);
84 break;
85 case 7:
86 *val = tsc2007_xfer(tsc,
87 (ADC_ON_12BIT | TSC2007_MEASURE_TEMP0));
88 break;
89 case 8:
90 *val = tsc2007_xfer(tsc,
91 (ADC_ON_12BIT | TSC2007_MEASURE_TEMP1));
92 break;
93 }
94
95 /* Prepare for next touch reading - power down ADC, enable PENIRQ */
96 tsc2007_xfer(tsc, PWRDOWN);
97
98 mutex_unlock(&tsc->mlock);
99
100 ret = IIO_VAL_INT;
101
102 return ret;
103}
104
105static const struct iio_info tsc2007_iio_info = {
106 .read_raw = tsc2007_read_raw,
107 .driver_module = THIS_MODULE,
108};
109
110int tsc2007_iio_configure(struct tsc2007 *ts)
111{
112 struct iio_dev *indio_dev;
113 struct tsc2007_iio *iio;
114 int error;
115
116 indio_dev = devm_iio_device_alloc(&ts->client->dev, sizeof(*iio));
117 if (!indio_dev) {
118 dev_err(&ts->client->dev, "iio_device_alloc failed\n");
119 return -ENOMEM;
120 }
121
122 iio = iio_priv(indio_dev);
123 iio->ts = ts;
124
125 indio_dev->name = "tsc2007";
126 indio_dev->dev.parent = &ts->client->dev;
127 indio_dev->info = &tsc2007_iio_info;
128 indio_dev->modes = INDIO_DIRECT_MODE;
129 indio_dev->channels = tsc2007_iio_channel;
130 indio_dev->num_channels = ARRAY_SIZE(tsc2007_iio_channel);
131
132 error = devm_iio_device_register(&ts->client->dev, indio_dev);
133 if (error) {
134 dev_err(&ts->client->dev,
135 "iio_device_register() failed: %d\n", error);
136 return error;
137 }
138
139 return 0;
140}
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 3a57e3dc9bec..72d0ece70ed3 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -38,6 +38,7 @@
38 38
39extern struct bus_type i2c_bus_type; 39extern struct bus_type i2c_bus_type;
40extern struct device_type i2c_adapter_type; 40extern struct device_type i2c_adapter_type;
41extern struct device_type i2c_client_type;
41 42
42/* --- General options ------------------------------------------------ */ 43/* --- General options ------------------------------------------------ */
43 44
@@ -306,6 +307,8 @@ static inline int i2c_slave_event(struct i2c_client *client,
306 * @of_node: pointer to OpenFirmware device node 307 * @of_node: pointer to OpenFirmware device node
307 * @fwnode: device node supplied by the platform firmware 308 * @fwnode: device node supplied by the platform firmware
308 * @properties: additional device properties for the device 309 * @properties: additional device properties for the device
310 * @resources: resources associated with the device
311 * @num_resources: number of resources in the @resources array
309 * @irq: stored in i2c_client.irq 312 * @irq: stored in i2c_client.irq
310 * 313 *
311 * I2C doesn't actually support hardware probing, although controllers and 314 * I2C doesn't actually support hardware probing, although controllers and
@@ -328,6 +331,8 @@ struct i2c_board_info {
328 struct device_node *of_node; 331 struct device_node *of_node;
329 struct fwnode_handle *fwnode; 332 struct fwnode_handle *fwnode;
330 const struct property_entry *properties; 333 const struct property_entry *properties;
334 const struct resource *resources;
335 unsigned int num_resources;
331 int irq; 336 int irq;
332}; 337};
333 338
diff --git a/include/linux/input/eeti_ts.h b/include/linux/input/eeti_ts.h
deleted file mode 100644
index 16625d799b6f..000000000000
--- a/include/linux/input/eeti_ts.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef LINUX_INPUT_EETI_TS_H
2#define LINUX_INPUT_EETI_TS_H
3
4struct eeti_ts_platform_data {
5 int irq_gpio;
6 unsigned int irq_active_high;
7};
8
9#endif /* LINUX_INPUT_EETI_TS_H */
10
diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
index 37b04a0fdea4..6174733a57eb 100644
--- a/include/linux/input/matrix_keypad.h
+++ b/include/linux/input/matrix_keypad.h
@@ -49,6 +49,8 @@ struct matrix_keymap_data {
49 * @wakeup: controls whether the device should be set up as wakeup 49 * @wakeup: controls whether the device should be set up as wakeup
50 * source 50 * source
51 * @no_autorepeat: disable key autorepeat 51 * @no_autorepeat: disable key autorepeat
52 * @drive_inactive_cols: drive inactive columns during scan, rather than
53 * making them inputs.
52 * 54 *
53 * This structure represents platform-specific data that use used by 55 * This structure represents platform-specific data that use used by
54 * matrix_keypad driver to perform proper initialization. 56 * matrix_keypad driver to perform proper initialization.
@@ -73,6 +75,7 @@ struct matrix_keypad_platform_data {
73 bool active_low; 75 bool active_low;
74 bool wakeup; 76 bool wakeup;
75 bool no_autorepeat; 77 bool no_autorepeat;
78 bool drive_inactive_cols;
76}; 79};
77 80
78int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, 81int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index f1ef6388c233..c93e7e0300ef 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -2041,6 +2041,9 @@ enum ec_mkbp_event {
2041 /* The state of the switches have changed. */ 2041 /* The state of the switches have changed. */
2042 EC_MKBP_EVENT_SWITCH = 4, 2042 EC_MKBP_EVENT_SWITCH = 4,
2043 2043
2044 /* EC sent a sysrq command */
2045 EC_MKBP_EVENT_SYSRQ = 6,
2046
2044 /* Number of MKBP events */ 2047 /* Number of MKBP events */
2045 EC_MKBP_EVENT_COUNT, 2048 EC_MKBP_EVENT_COUNT,
2046}; 2049};
@@ -2053,6 +2056,7 @@ union ec_response_get_next_data {
2053 2056
2054 uint32_t buttons; 2057 uint32_t buttons;
2055 uint32_t switches; 2058 uint32_t switches;
2059 uint32_t sysrq;
2056} __packed; 2060} __packed;
2057 2061
2058struct ec_response_get_next_event { 2062struct ec_response_get_next_event {
diff --git a/include/linux/serio.h b/include/linux/serio.h
index c733cff44e18..138a5efe863a 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -77,6 +77,7 @@ struct serio_driver {
77 irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int); 77 irqreturn_t (*interrupt)(struct serio *, unsigned char, unsigned int);
78 int (*connect)(struct serio *, struct serio_driver *drv); 78 int (*connect)(struct serio *, struct serio_driver *drv);
79 int (*reconnect)(struct serio *); 79 int (*reconnect)(struct serio *);
80 int (*fast_reconnect)(struct serio *);
80 void (*disconnect)(struct serio *); 81 void (*disconnect)(struct serio *);
81 void (*cleanup)(struct serio *); 82 void (*cleanup)(struct serio *);
82 83