input/touchscreen: Synaptics Touchscreen Driver
Subsystems (2)
cover input/touchscreen: Synaptics Touchscreen Driver
This patch adds an initial driver supporting Synaptics ClearPad touchscreens that use the RMI4 protocol, as defined here:
http://www.synaptics.com/sites/default/files/511-000136-01_revA.pdf
This patch addresses most of the feedback relating to our previous submissions. Of particular interest are I2C changes based on feedback from Jean Delvare.
Any feedback not acted on (such as creation of an 'rmi' bus on the kernel bus architecture) are captured as TODOs in the code, and will be implemented in a future submission. Also, we've done a lot of reformatting in order to make checkpatch happy (down to just a few line length warnings and a couple of macro formatting issues).
This patch builds for the Omap Zoom2 platform in our development environment, but I cannot guarantee that it will build for you. We're working on making sure it builds generically, and feedback relating to that will be greatly appreciated (special thanks to Joerie de Gram for his previous feedback on this).
This version of the driver does not support all features of the RMI4 protocol yet. We felt it more important to start with a solid implementation of the basic functionality, and then build on that base to support additional features (such as gestures, proximity detection, capacitive buttons, and so on).
Additionally, as this is our team's first venture into the wonderful world of kernel submissions, we figured it was important to start out initially with a fairly simple codebase, just in case we're doing something horribly wrong.
The significant files in this version of the driver are:
rmi_core.c
Implements the basic core of the RMI4 protocol including self-discovery of RMI4 functions. This also implements RMI4 function 0x01, which provides generic device control.
rmi_function_11.c
Implements basic RMI4 function 0x11 (2D sensor) features, including multitouch up to 10 fingers.
rmi_app_touchpad.c
The major driver functions (mod_init, mod_exit,
and so on).
An additional file is included, but will eventually be changed/dropped
rmi_i2c_gta01.c
Provides platform setup for development. This will be replaced in the future by a generic approach to specifying platform parameters.
More detailed descriptions can be found in each file's comments.
We chose to use multiple source files because it makes it easy to add support for additional RMI4 functions with minimal impact to existing functions. Additionally, this supports future changes to the configuration to allow you to compile in only those RMI4 functions that you need for your particular device.
There are two existing drivers for similar Synaptics devices in the current kernel tree (excluding the PS/2 touchpad driver). These are:
./linux-2.6/drivers/input/mouse/synaptics_i2c.c
A driver for the Exeda 15mm touchpad, written by Mike Rapoport <[email protected]> and Igor Grinberg <[email protected]>
./linux-2.6/drivers/staging/dream/synaptics_i2c_rmi.c
A driver for the HTC Dream ClearPad, written by Arve Hjønnevåg <[email protected]>
We have not extended these drivers for a couple of reasons. First, the two drivers are specific to particular Synaptics products, and it is our desire to produce a general solution that takes advantage of the 'self describing' features of products that use the RMI protocol.
Second, and more importantly, is that the existing drivers are written for an older version of the RMI protocol (aka RMI3) that is being retired in favor of a more recent and substantially changed version (aka RMI4). Most currently shipping Synaptics ClearPads speak the RMI4 protocol, and it will be Synaptics protocol of choice going forward. In almost all respects, RMI4 is not backward compatible with RMI3, making it impractical to support both versions in the same driver.
Comments and other feedback on this driver are welcomed.
Bill Manson
Allie Xiong
Christopher Heiny
---
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Christopher Heiny
This patch adds an initial driver supporting Synaptics ClearPad touchscreens that use the RMI4 protocol, as defined here:
Did the actual patch go astray? I cannot find it on the mailing lists.
Henrik
Quoted 5 lines · Henrik Rydberg
Quoted 2 lines · Christopher Heiny
This patch adds an initial driver supporting Synaptics ClearPad touchscreens that use the RMI4 protocol, as defined here:
Did the actual patch go astray? I cannot find it on the mailing lists.
I received it, at least. It was pretty large, maybe got filtered out on some lists because of this.
Signature · 1 line
Jean Delvare
Quoted 9 lines · Jean Delvare
Quoted 4 lines · Henrik Rydberg
Quoted 2 lines · Christopher Heiny
This patch adds an initial driver supporting Synaptics ClearPad touchscreens that use the RMI4 protocol, as defined here:
Did the actual patch go astray? I cannot find it on the mailing lists.
I received it, at least. It was pretty large, maybe got filtered out on some lists because of this.
Yes, probably. Got it via mail, thank you Christopher.
Henrik
RFC PATCH 1/1 input/touchscreen: Synaptics Touchscreen Driver
In reply to Christopher HeinyInitial driver for Synaptics touchscreens using RMI4 protocol.
---
drivers/input/touchscreen/Kconfig | 13 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/rmi.h | 206 ++++++++ drivers/input/touchscreen/rmi_app_touchpad.c | 400 +++++++++++++++ drivers/input/touchscreen/rmi_core.c | 708 ++++++++++++++++++++++++++ drivers/input/touchscreen/rmi_core.h | 58 +++ drivers/input/touchscreen/rmi_function_11.c | 438 ++++++++++++++++ drivers/input/touchscreen/rmi_function_11.h | 43 ++ drivers/input/touchscreen/rmi_functions.h | 111 ++++ drivers/input/touchscreen/rmi_i2c.h | 51 ++ drivers/input/touchscreen/rmi_i2c_gta01.c | 117 +++++ drivers/input/touchscreen/rmi_phys_i2c.c | 578 +++++++++++++++++++++ 12 files changed, 2724 insertions(+), 0 deletions(-)
drivers/input/touchscreen/Kconfig +13 -0
@@ -307,6 +307,19 @@ config TOUCHSCREEN_MIGOR To compile this driver as a module, choose M here: the module will be called migor_ts. +config TOUCHSCREEN_SYNAPTICS_RMI4_I2C + tristate "Synaptics RMI4 I2C touchscreens" + depends on I2C + help + Say Y here if you have a Synaptics RMI4 I2C touchscreen connected to + your system. This enables support for Synaptics RMI4 over I2C based + touchscreens. + + If unsure, say N. + + To compile this driver as a set of modules, choose M here: the + modules will be called rmi, rmi_app_touchpad, rmi_phys_i2c. + config TOUCHSCREEN_TOUCHRIGHT tristate "Touchright serial touchscreen" select SERIO
drivers/input/touchscreen/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o +obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) += rmi_core.o rmi_app_touchpad.o rmi_function_11.o rmi_phys_i2c.o rmi_i2c_gta01.o obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o
drivers/input/touchscreen/rmi.h new file +206 -0
206 lines not on this page · raw message
drivers/input/touchscreen/rmi_app_touchpad.c new file +400 -0
400 lines not on this page · raw message
drivers/input/touchscreen/rmi_core.c new file +708 -0
708 lines not on this page · raw message
drivers/input/touchscreen/rmi_core.h new file +58 -0
58 lines not on this page · raw message
drivers/input/touchscreen/rmi_function_11.c new file +438 -0
438 lines not on this page · raw message
drivers/input/touchscreen/rmi_function_11.h new file +43 -0
43 lines not on this page · raw message
drivers/input/touchscreen/rmi_functions.h new file +111 -0
111 lines not on this page · raw message
drivers/input/touchscreen/rmi_i2c.h new file +51 -0
51 lines not on this page · raw message
drivers/input/touchscreen/rmi_i2c_gta01.c new file +117 -0
117 lines not on this page · raw message
drivers/input/touchscreen/rmi_phys_i2c.c new file +578 -0
578 lines not on this page · raw message
Hi Christopher,
Quoted 5 lines · Christopher Heiny
Initial driver for Synaptics touchscreens using RMI4 protocol.
Signed-off-by William Manson <[email protected]>Signed-off-by Allie Xiong <[email protected]>Signed-off-by Christopher Heiny <[email protected]>
You can add:
for the i2c parts. I still have a few comments you might be interested in, maybe for a future incremental patch:
drivers/input/touchscreen/rmi_i2c_gta01.c line 70
Quoted 10 lines
(...)
drivers/input/touchscreen/rmi_i2c_gta01.c new file +5
-0@@ -0,0 +1,117 @@ +static void +rmi_i2c_release (struct device *dev) +{ +struct platform_device *pd =container_of (dev, + struct platform_device, dev);
You could use to_platform_device(dev) instead, it's more readable.
drivers/input/touchscreen/rmi_phys_i2c.c line 34
Quoted 5 lines
(...)
drivers/input/touchscreen/rmi_phys_i2c.c new file +1
-0+/* TODO: for multiple device support will need a per-device mutex */
This comment would be better placed below, where page_mutex is declared.
drivers/input/touchscreen/rmi_phys_i2c.c line 37
Quoted 3 lines
drivers/input/touchscreen/rmi_phys_i2c.c new file +3
-0+#define DRIVER_NAME "rmi4-i2c" + +/* TODO: for multiple device support will need a per-device device name */
This comment is confusing... you would need different names if you were supporting different device _types_ in the same driver. But you definitely do _not_ need different names to support several devices of the same type in a given system.
Quoted 1 line
+#define
DEVICE_NAME"rmi4-i2c"
The use of dashes in i2c device names is strongly discouraged. Including "i2c" in these names is discouraged as well, as it is redundant. "rmi4_ts" would be a better name IMHO.
Quoted 6 lines
(...)
drivers/input/touchscreen/rmi_phys_i2c.c new file +5
-0+static int +rmi_i2c_probe (struct i2c_client *client,const struct i2c_device_id *dev_id) +{ +struct instance_data *id; +int retval =0 ;
drivers/input/touchscreen/rmi_phys_i2c.c line 357
Quoted 10 lines
drivers/input/touchscreen/rmi_phys_i2c.c new file +10
-0+int i; +bool found = false; + +struct rmi_i2c_data *rmii2cdata; +struct rmi_i2c_platformdata *platformdata; + +pr_debug ("Probing i2c RMI device\n" ); + +/* Allocate and initialize the instance data for this client */ + id =kzalloc (sizeof (*id) *2 ,GFP_KERNEL );
I still don't get the * 2.
drivers/input/touchscreen/rmi_phys_i2c.c line 382
Quoted 4 lines
(...)
drivers/input/touchscreen/rmi_phys_i2c.c new file +3
-0+/* cast to our struct rmi_i2c_data so we know +the fields (see rmi_ic2.h) */ + rmii2cdata = ((struct rmi_i2c_data *)(client->dev.platform_data));
Explicit cast still not needed, you can just write:
rmii2cdata = client->dev.platform_data;
Signature · 1 line
Jean Delvare
Quoted 6 lines · Christopher Heiny
Initial driver for Synaptics touchscreens using RMI4 protocol.
Signed-off-by William Manson <[email protected]>Signed-off-by Allie Xiong <[email protected]>Signed-off-by Christopher Heiny <[email protected]>---
Thank you for this driver. Some scattered comments on the MT parts below.
Henrik
[...]
Quoted 31 lines
drivers/input/touchscreen/rmi_function_11.c new file +31
-0+int FN_11_report (struct rmi_application *app, +struct rmi_function_info *rfi,struct input_dev *input) +{ +unsigned char values[2 ] = {0 ,0 }; +unsigned char data[12 ] = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }; +/* number of touch points - fingers down in this case */ +int fingerDownCount; +int X ,Y ,Z ,W , Wy, Wx; +int finger; +int fn11FingersSupported; +int fn11FingerRegisters; +unsigned short fn11DataBaseAddr; +unsigned char fn11DataRegBlockSize; +static bool wasdown; + + fingerDownCount =0 ; + +/* get 2D sensor finger data */ + +/* First get the finger status field - the size of the finger status +field is determined by the number of finger supporte - 2 bits per +finger, so the number of registers to read is: +registerCount = ceil(numberOfFingers/4). +Read the required number of registers and check each 2 bit field to +determine if a finger is down: +00 = finger not present, +01 = finger present and data accurate, +10 = finger present but data may not be accurate, +11 = reserved for product use. +*/ + fn11FingersSupported = rfi->numDataPoints;
drivers/input/touchscreen/rmi_function_11.c line 96
Quoted 10 lines
drivers/input/touchscreen/rmi_function_11.c new file +10
-0+ fn11FingerRegisters = (fn11FingersSupported +3 )/4 ; + + fn11DataBaseAddr = rfi->funcDescriptor.dataBaseAddr; + +if (rmi_read_multiple (app, fn11DataBaseAddr, values, + fn11FingerRegisters)) { +printk (KERN_ERR "%s: RMI4 function $11 report: " +"Could not read finger status registers 0x%x\n" , + __func__, fn11DataBaseAddr); +return 0 ;
The in-kernel rmi interface seems to expect the number of touches to be returned here, but it does not seem to be used anywhere. Would it not be more useful to return zero on success, and error codes on failure?
Quoted 26 lines
drivers/input/touchscreen/rmi_function_11.c new file +26
-0+ } + +/* For each finger present, read the proper number of registers +to get absolute data. */ + fn11DataRegBlockSize = rfi->dataRegBlockSize; + +for (finger =0 ; finger < fn11FingersSupported; finger++) { +int reg; +int fingerShift; +int fingerStatus; + +/* determine which data byte the finger status is in */ + reg = finger/4 ; +/* bit shift to get finger's status */ + fingerShift = (finger %4 ) *2 ; + fingerStatus = (values[reg] >> fingerShift) &3 ; + +/* if finger status indicates a finger is present then +read the finger data and report it */ +if (fingerStatus ==1 || fingerStatus ==2 ) { +/* number of active touch points not same as +number of supported fingers */ + fingerDownCount++; + +/* Read the finger data */ + if (rmi_read_multiple(app, fn11DataBaseAddr +
drivers/input/touchscreen/rmi_function_11.c line 132
Quoted 10 lines
drivers/input/touchscreen/rmi_function_11.c new file +10
-0+ ((finger * fn11DataRegBlockSize) + + fn11FingerRegisters), + data, fn11DataRegBlockSize)) { +printk (KERN_ERR "%s: RMI4 function $11 report: " +"Could not read finger data registers " +"0x%x\n" , __func__, + fn11DataBaseAddr + + ((finger * fn11DataRegBlockSize) + + fn11FingerRegisters)); +return 0 ;
Bailing out without finishing off the input packet...
Quoted 37 lines
drivers/input/touchscreen/rmi_function_11.c new file +37
-0+ }else { +X = (data[0 ] &0x1f ) <<4 ; +X |= data[2 ] &0xf ; +Y = (data[1 ] &0x1f ) <<4 ; +Y |= (data[2 ] >>4 ) &0xf ; +W = data[3 ]; + +/* upper 4 bits of W are Wy, +lower 4 of W are Wx */ + Wy = (W >>4 ) &0x0f ; + Wx =W &0x0f ; + +Z = data[4 ]; + +/* if this is the first finger report normal +ABS_X, ABS_Y, PRESSURE, TOOL_WIDTH events for +non-MT apps. Apps that support Multi-touch +will ignore these events and use the MT events. +Apps that don't support Multi-touch will still +function. +*/ +if (fingerDownCount ==1 ) { +input_report_abs (input,ABS_X ,X ); +input_report_abs (input,ABS_Y ,Y ); +input_report_abs (input,ABS_PRESSURE , +Z ); +input_report_abs (input,ABS_TOOL_WIDTH , +max (Wx, Wy)); +input_report_key (input,BTN_TOUCH ,1 ); + wasdown = true; + } + +/* Report Multi-Touch events for each finger */ +/* major axis of touch area ellipse */ +input_report_abs (input,ABS_MT_TOUCH_MAJOR , +max (Wx, Wy)); +/* minor axis of touch area ellipse */
drivers/input/touchscreen/rmi_function_11.c line 179
Quoted 10 lines
drivers/input/touchscreen/rmi_function_11.c new file +10
-0+input_report_abs (input,ABS_MT_TOUCH_MINOR , +min (Wx, Wy)); +/* Currently only 2 supported - 1 or 0 */ +input_report_abs (input,ABS_MT_ORIENTATION , + (Wx > Wy ?1 :0 )); +input_report_abs (input,ABS_MT_POSITION_X ,X ); +input_report_abs (input,ABS_MT_POSITION_Y ,Y ); +/* Tracking ID reported but not used yet */ +input_report_abs (input,ABS_MT_TRACKING_ID , + finger+1 );
The tracking id used here is not entirely proper, since the id seems to be reused too often.
Does the position in the finger array (0..fn11FingersSupported) really track an identified contact, as suggested by the code? If so, a proper tracking id could be formed by keeping an id per position, and assigning a new id when the fingerStatus changes for that position.
Quoted 8 lines
drivers/input/touchscreen/rmi_function_11.c new file +8
-0+/* MT sync between fingers */ +input_mt_sync (input); + } + } + } + +if (fingerDownCount) { +/* touch will be non-zero if we had any reported events */
drivers/input/touchscreen/rmi_function_11.c line 197
Quoted 10 lines
drivers/input/touchscreen/rmi_function_11.c new file +10
-0+input_sync (input);/* sync after groups of events */ + }else { +/* if we had a finger down before and now we don't have +any we need to send a button up and a sync. */ +if (wasdown) { + wasdown = false; +input_report_key (input,BTN_TOUCH ,0 ); +input_sync (input);/* sync after groups of events */ + } + }
input_sync() should always be called at the end, regardless. If nothing changed, the input core will filter it out.
Quoted 4 lines
drivers/input/touchscreen/rmi_function_11.c new file +4
-0+ +/* return the number of touch points: fingers down or buttons pressed */ +return fingerDownCount; +}