summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2015-10-29 15:06:26 -0700
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2015-11-02 18:28:14 +0100
commit6a68f2d6486dac9cbc13c74c2f997ee3a9c7f81b (patch)
treec6e6005d55d8c3757ca4d56cdbbf8c1e2fa155d8 /drivers
parentf09c7a335edb94a1439eee92cce8e9d399af50e1 (diff)
input: touchscreen: fusion: implement multitouch with slot handling
According to multi-touch-protocol.txt the kernel knows two type of devices: - Type A: devices which provide anonymous contacts - Type B: devices which are capable of tracking individual contacts The Fusion touch screen is a Type B device: The Touch ID field allows to differentiate between 2 different fingers. This updates the driver to properly allocate a slot for each identified contact and use the helper functions available from the input core system. (cherry picked from commit 698d0a9bb80d94adef58122717c61f55dd61e22d)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/touchscreen/fusion_F0710A.c110
1 files changed, 22 insertions, 88 deletions
diff --git a/drivers/input/touchscreen/fusion_F0710A.c b/drivers/input/touchscreen/fusion_F0710A.c
index e9a513426f9e..2fda7a687b8b 100644
--- a/drivers/input/touchscreen/fusion_F0710A.c
+++ b/drivers/input/touchscreen/fusion_F0710A.c
@@ -17,19 +17,19 @@
#include <asm/irq.h>
#include <linux/gpio.h>
#include <linux/input/fusion_F0710A.h>
+#include <linux/input/mt.h>
#include <linux/irq.h>
+#include <linux/slab.h>
#include "fusion_F0710A.h"
#define DRV_NAME "fusion_F0710A"
-
+#define MAX_TOUCHES 2
static struct fusion_F0710A_data fusion_F0710A;
static unsigned short normal_i2c[] = { fusion_F0710A_I2C_SLAVE_ADDR, I2C_CLIENT_END };
-//I2C_CLIENT_INSMOD;
-
static int fusion_F0710A_write_u8(u8 addr, u8 data)
{
return i2c_smbus_write_byte_data(fusion_F0710A.client, addr, data);
@@ -42,13 +42,6 @@ static int fusion_F0710A_read_u8(u8 addr)
static int fusion_F0710A_read_block(u8 addr, u8 len, u8 *data)
{
-#if 0
- /* When i2c_smbus_read_i2c_block_data() takes a block length parameter, we can do
- * this. lm-sensors lists hints this has been fixed, but I can't tell whether it
- * was or will be merged upstream. */
-
- return i2c_smbus_read_i2c_block_data(&fusion_F0710A.client, addr, data);
-#else
u8 msgbuf0[1] = { addr };
u16 slave = fusion_F0710A.client->addr;
u16 flags = fusion_F0710A.client->flags;
@@ -57,10 +50,8 @@ static int fusion_F0710A_read_block(u8 addr, u8 len, u8 *data)
};
return i2c_transfer(fusion_F0710A.client->adapter, msg, ARRAY_SIZE(msg));
-#endif
}
-
static int fusion_F0710A_register_input(void)
{
int ret;
@@ -74,15 +65,13 @@ static int fusion_F0710A_register_input(void)
set_bit(EV_KEY, dev->evbit);
set_bit(EV_ABS, dev->evbit);
+ set_bit(EV_SYN, dev->evbit);
+ set_bit(BTN_TOUCH, dev->keybit);
+ input_mt_init_slots(dev, MAX_TOUCHES);
input_set_abs_params(dev, ABS_MT_POSITION_X, 0, fusion_F0710A.info.xres-1, 0, 0);
input_set_abs_params(dev, ABS_MT_POSITION_Y, 0, fusion_F0710A.info.yres-1, 0, 0);
-#ifdef CONFIG_ANDROID
- input_set_abs_params(dev, ABS_MT_TRACKING_ID, 0, 15, 0, 0);
-#else
- input_set_abs_params(dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0);
- input_set_abs_params(dev, ABS_MT_WIDTH_MAJOR, 0, 15, 0, 0);
-#endif
+ input_set_abs_params(dev, ABS_MT_PRESSURE, 0, 255, 0, 0);
input_set_abs_params(dev, ABS_X, 0, fusion_F0710A.info.xres-1, 0, 0);
input_set_abs_params(dev, ABS_Y, 0, fusion_F0710A.info.yres-1, 0, 0);
@@ -172,8 +161,6 @@ while(0)
static void fusion_F0710A_wq(struct work_struct *work)
{
struct input_dev *dev = fusion_F0710A.input;
- int save_points = 0;
- int x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0;
if (fusion_F0710A_read_sensor() < 0)
goto restore_irq;
@@ -189,80 +176,27 @@ static void fusion_F0710A_wq(struct work_struct *work)
val_cut_max(fusion_F0710A.x2, fusion_F0710A.info.xres-1, fusion_F0710A.info.xy_reverse);
val_cut_max(fusion_F0710A.y2, fusion_F0710A.info.yres-1, fusion_F0710A.info.xy_reverse);
- if(fusion_F0710A.tip1 == 1)
- {
- if(fusion_F0710A.tid1 == 1)
- {
- /* first point */
- x1 = fusion_F0710A.x1;
- y1 = fusion_F0710A.y1;
- z1 = fusion_F0710A.z1;
- save_points |= fusion_F0710A_SAVE_PT1;
- }
- else if(fusion_F0710A.tid1 == 2)
- {
- /* second point ABS_DISTANCE second point pressure, BTN_2 second point touch */
- x2 = fusion_F0710A.x1;
- y2 = fusion_F0710A.y1;
- z2 = fusion_F0710A.z1;
- save_points |= fusion_F0710A_SAVE_PT2;
+ if (fusion_F0710A.tid1) {
+ input_mt_slot(dev, fusion_F0710A.tid1 - 1);
+ input_mt_report_slot_state(dev, MT_TOOL_FINGER, fusion_F0710A.tip1);
+ if (fusion_F0710A.tip1) {
+ input_report_abs(dev, ABS_MT_POSITION_X, fusion_F0710A.x1);
+ input_report_abs(dev, ABS_MT_POSITION_Y, fusion_F0710A.y1);
+ input_report_abs(dev, ABS_MT_PRESSURE, fusion_F0710A.z1);
}
}
- if(fusion_F0710A.tip2 == 1)
- {
- if(fusion_F0710A.tid2 == 2)
- {
- /* second point ABS_DISTANCE second point pressure, BTN_2 second point touch */
- x2 = fusion_F0710A.x2;
- y2 = fusion_F0710A.y2;
- z2 = fusion_F0710A.z2;
- save_points |= fusion_F0710A_SAVE_PT2;
+ if (fusion_F0710A.tid2) {
+ input_mt_slot(dev, fusion_F0710A.tid2 - 1);
+ input_mt_report_slot_state(dev, MT_TOOL_FINGER, fusion_F0710A.tip2);
+ if (fusion_F0710A.tip2) {
+ input_report_abs(dev, ABS_MT_POSITION_X, fusion_F0710A.x2);
+ input_report_abs(dev, ABS_MT_POSITION_Y, fusion_F0710A.y2);
+ input_report_abs(dev, ABS_MT_PRESSURE, fusion_F0710A.z2);
}
- else if(fusion_F0710A.tid2 == 1)/* maybe this will never happen */
- {
- /* first point */
- x1 = fusion_F0710A.x2;
- y1 = fusion_F0710A.y2;
- z1 = fusion_F0710A.z2;
- save_points |= fusion_F0710A_SAVE_PT1;
- }
- }
-
-#ifdef CONFIG_ANDROID
- if(z1)
- {
- input_report_abs(dev, ABS_MT_TRACKING_ID, 1);
- input_report_abs(dev, ABS_MT_POSITION_X, x1);
- input_report_abs(dev, ABS_MT_POSITION_Y, y1);
- }
- input_mt_sync(dev);
-
- if(z2)
- {
- input_report_abs(dev, ABS_MT_TRACKING_ID, 2);
- input_report_abs(dev, ABS_MT_POSITION_X, x2);
- input_report_abs(dev, ABS_MT_POSITION_Y, y2);
}
- input_mt_sync(dev);
-#else /* CONFIG_ANDROID */
- input_report_abs(dev, ABS_MT_TOUCH_MAJOR, z1);
- input_report_abs(dev, ABS_MT_WIDTH_MAJOR, 1);
- input_report_abs(dev, ABS_MT_POSITION_X, x1);
- input_report_abs(dev, ABS_MT_POSITION_Y, y1);
- input_mt_sync(dev);
- input_report_abs(dev, ABS_MT_TOUCH_MAJOR, z2);
- input_report_abs(dev, ABS_MT_WIDTH_MAJOR, 2);
- input_report_abs(dev, ABS_MT_POSITION_X, x2);
- input_report_abs(dev, ABS_MT_POSITION_Y, y2);
- input_mt_sync(dev);
-#endif /* CONFIG_ANDROID */
-
- input_report_abs(dev, ABS_X, x1);
- input_report_abs(dev, ABS_Y, y1);
- input_report_abs(dev, ABS_PRESSURE, z1);
- input_report_key(dev, BTN_TOUCH, fusion_F0710A.tip1);
+ input_mt_report_pointer_emulation(dev, false);
input_sync(dev);
restore_irq: