Input: elants_i2c - support palm detection
Subsystems (2)
PATCH v2 1/1 Input: elants_i2c - support palm detection
From: Johnny Chuang <[email protected]>
Elan define finger/palm detection on the least significant bit of byte 33. The default value is 1 for all firmwares, which report as MT_TOOL_FINGER. If firmware support palm detection, the bit will change to 0 and report as MT_TOOL_PALM when firmware detecting palm.
---
Changes in v2:
- Modify MT_TOOL_MAX to MT_TOOL_PALM
drivers/input/touchscreen/elants_i2c.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/input/touchscreen/elants_i2c.c +10 -1
@@ -73,6 +73,7 @@#define FW_POS_STATE 1#define FW_POS_TOTAL 2#define FW_POS_XY 3 +#define FW_POS_TOOL_TYPE 33#define FW_POS_CHECKSUM 34#define FW_POS_WIDTH 35#define FW_POS_PRESSURE 45
@@ -842,6 +843,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) {struct input_dev *input = ts->input;unsigned int n_fingers; +unsigned int tool_type;u16 finger_state;int i;
@@ -852,6 +854,12 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf)dev_dbg (&ts->client->dev,"n_fingers: %u, state: %04x\n" , n_fingers, finger_state); +/* Note: all fingers have the same tool type */ +if (buf[FW_POS_TOOL_TYPE ] &0x01 ) + tool_type =MT_TOOL_FINGER ; +else + tool_type =MT_TOOL_PALM ; +for (i =0 ; i <MAX_CONTACT_NUM && n_fingers; i++) {if (finger_state &1 ) {unsigned int x, y, p, w;
@@ -867,7 +875,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) i, x, y, p, w);input_mt_slot (input, i); -input_mt_report_slot_state (input,MT_TOOL_FINGER , true); +input_mt_report_slot_state (input, tool_type, true);input_event (input,EV_ABS ,ABS_MT_POSITION_X , x);input_event (input,EV_ABS ,ABS_MT_POSITION_Y , y);input_event (input,EV_ABS ,ABS_MT_PRESSURE , p);
@@ -1307,6 +1315,7 @@ static int elants_i2c_probe(struct i2c_client *client,input_set_abs_params (ts->input,ABS_MT_POSITION_Y ,0 , ts->y_max,0 ,0 );input_set_abs_params (ts->input,ABS_MT_TOUCH_MAJOR ,0 ,255 ,0 ,0 );input_set_abs_params (ts->input,ABS_MT_PRESSURE ,0 ,255 ,0 ,0 ); +input_set_abs_params (ts->input,ABS_MT_TOOL_TYPE ,0 ,MT_TOOL_PALM ,0 ,0 );input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res);input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res);input_abs_set_res (ts->input,ABS_MT_TOUCH_MAJOR ,1 );
Signature · 1 line
2.7.4
Quoted 8 lines · Johnny Chuang
From: Johnny Chuang <[email protected]>
Elan define finger/palm detection on the least significant bit of byte 33. The default value is 1 for all firmwares, which report as
MT_TOOL_FINGER. If firmware support palm detection, the bit will change to 0 and report asMT_TOOL_PALMwhen firmware detecting palm.Signed-off-by Johnny Chuang <[email protected]>
Cheers,
Peter
Quoted 60 lines
---
Changes in v2:
- ModifyMT_TOOL_MAXtoMT_TOOL_PALMdrivers/input/touchscreen/elants_i2c.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/input/touchscreen/elants_i2c.c +10
-1@@ -73,6 +73,7 @@#define FW_POS_STATE 1#define FW_POS_TOTAL 2#define FW_POS_XY 3 +#define FW_POS_TOOL_TYPE 33#define FW_POS_CHECKSUM 34#define FW_POS_WIDTH 35#define FW_POS_PRESSURE 45@@ -842,6 +843,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) {struct input_dev *input = ts->input;unsigned int n_fingers; +unsigned int tool_type;u16 finger_state;int i;@@ -852,6 +854,12 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf)dev_dbg (&ts->client->dev,"n_fingers: %u, state: %04x\n" , n_fingers, finger_state); +/* Note: all fingers have the same tool type */ +if (buf[FW_POS_TOOL_TYPE ] &0x01 ) + tool_type =MT_TOOL_FINGER ; +else + tool_type =MT_TOOL_PALM ; +for (i =0 ; i <MAX_CONTACT_NUM && n_fingers; i++) {if (finger_state &1 ) {unsigned int x, y, p, w;@@ -867,7 +875,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) i, x, y, p, w);input_mt_slot (input, i); -input_mt_report_slot_state (input,MT_TOOL_FINGER , true); +input_mt_report_slot_state (input, tool_type, true);input_event (input,EV_ABS ,ABS_MT_POSITION_X , x);input_event (input,EV_ABS ,ABS_MT_POSITION_Y , y);input_event (input,EV_ABS ,ABS_MT_PRESSURE , p);@@ -1307,6 +1315,7 @@ static int elants_i2c_probe(struct i2c_client *client,input_set_abs_params (ts->input,ABS_MT_POSITION_Y ,0 , ts->y_max,0 ,0 );input_set_abs_params (ts->input,ABS_MT_TOUCH_MAJOR ,0 ,255 ,0 ,0 );input_set_abs_params (ts->input,ABS_MT_PRESSURE ,0 ,255 ,0 ,0 ); +input_set_abs_params (ts->input,ABS_MT_TOOL_TYPE ,0 ,MT_TOOL_PALM ,0 ,0 );input_abs_set_res (ts->input,ABS_MT_POSITION_X , ts->x_res);input_abs_set_res (ts->input,ABS_MT_POSITION_Y , ts->y_res);input_abs_set_res (ts->input,ABS_MT_TOUCH_MAJOR ,1 );Signature · 1 line
2.7.4
Dmitry Torokhov
maintainerQuoted 46 lines · Peter Hutterer
Quoted 8 lines · Johnny Chuang
From: Johnny Chuang <[email protected]>
Elan define finger/palm detection on the least significant bit of byte 33. The default value is 1 for all firmwares, which report as
MT_TOOL_FINGER. If firmware support palm detection, the bit will change to 0 and report asMT_TOOL_PALMwhen firmware detecting palm.Signed-off-by Johnny Chuang <[email protected]>Reviewed-by Peter Hutterer <[email protected]>Cheers,
PeterQuoted 31 lines
---
Changes in v2:
- ModifyMT_TOOL_MAXtoMT_TOOL_PALMdrivers/input/touchscreen/elants_i2c.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/input/touchscreen/elants_i2c.c +2
-0@@ -73,6 +73,7 @@#define FW_POS_STATE 1#define FW_POS_TOTAL 2#define FW_POS_XY 3 +#define FW_POS_TOOL_TYPE 33#define FW_POS_CHECKSUM 34#define FW_POS_WIDTH 35#define FW_POS_PRESSURE 45@@ -842,6 +843,7 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) {struct input_dev *input = ts->input;unsigned int n_fingers; +unsigned int tool_type;u16 finger_state;int i;@@ -852,6 +854,12 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf)dev_dbg (&ts->client->dev,"n_fingers: %u, state: %04x\n" , n_fingers, finger_state);
Quoted 5 lines
drivers/input/touchscreen/elants_i2c.c static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) · line 861
Quoted 5 lines
drivers/input/touchscreen/elants_i2c.c +5
-0+/* Note: all fingers have the same tool type */ +if (buf[FW_POS_TOOL_TYPE ] &0x01 ) + tool_type =MT_TOOL_FINGER ; +else + tool_type =MT_TOOL_PALM ;
I changed this to
tool_type = buf[FW_POS_TOOL_TYPE] & BIT(0) ? MT_TOOL_FINGER : MT_TOOL_PALM;
to be a bit more compact, and applied.
Thanks.
Signature · 1 line
Dmitry