From 80c513e09b3d5f49f8df94ffd98be30bb5e1a53c Mon Sep 17 00:00:00 2001 From: haojl2 Date: Wed, 20 May 2020 12:31:51 +0800 Subject: [PATCH] synaptics_tcm_v2: Add touchscreen class handle touch event Let touchscreen class do some gesture work before vendor driver code repot event. To accomplish some gesture algorithm, touchscreen class need report touch events and skip vendor's events report. Change-Id: I42fe9df4c0190449b0052a9f18623db1d2514285 Signed-off-by: haojl2 Reviewed-on: https://gerrit.mot.com/1567169 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- .../synaptics_tcm_mmi_v2/synaptics_touch.c | 52 ++++++++++++------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/input/touchscreen/synaptics_tcm_mmi_v2/synaptics_touch.c b/drivers/input/touchscreen/synaptics_tcm_mmi_v2/synaptics_touch.c index 55e4f641b509..d33b03e2b2a3 100644 --- a/drivers/input/touchscreen/synaptics_tcm_mmi_v2/synaptics_touch.c +++ b/drivers/input/touchscreen/synaptics_tcm_mmi_v2/synaptics_touch.c @@ -759,17 +759,22 @@ static void touch_report(void) switch (status) { case LIFT: #ifdef TYPE_B_PROTOCOL - input_mt_slot(touch_hcd->input_dev, idx); - input_mt_report_slot_state(touch_hcd->input_dev, - MT_TOOL_FINGER, 0); - if (tcm_hcd->imports && tcm_hcd->imports->report_touch_event) { struct touch_event_data touch_event; memset(&touch_event, 0, sizeof(touch_event)); touch_event.type = TS_COORDINATE_ACTION_RELEASE; touch_event.id = idx; - tcm_hcd->imports->report_touch_event(&touch_event); + tcm_hcd->imports->report_touch_event(&touch_event, touch_hcd->input_dev); + if (touch_event.skip_report) { + /* input event is reported by touchscreen class. + * vendor touch event may need update based on touch_event + */ + break; + } } + input_mt_slot(touch_hcd->input_dev, idx); + input_mt_report_slot_state(touch_hcd->input_dev, + MT_TOOL_FINGER, 0); #endif break; case FINGER: @@ -792,6 +797,29 @@ static void touch_report(void) x = touch_hcd->input_params.max_x - x; if (bdata->y_flip) y = touch_hcd->input_params.max_y - y; + + if (tcm_hcd->imports && tcm_hcd->imports->report_touch_event) { + struct touch_event_data touch_event; + memset(&touch_event, 0, sizeof(touch_event)); + touch_event.type = (object_data[idx].status != touch_hcd->prev_status[idx])? + TS_COORDINATE_ACTION_PRESS : TS_COORDINATE_ACTION_MOVE; + touch_event.id = idx; + touch_event.x = x; + touch_event.y = y; + touch_event.major = major; + touch_event.minor = minor; + tcm_hcd->imports->report_touch_event(&touch_event, touch_hcd->input_dev); + if (touch_event.skip_report) { + /* input event is reported by touchscreen class. + * vendor touch event may need update based on touch_event + */ + if ((touch_event.type == TS_COORDINATE_ACTION_PRESS) || + (touch_event.type == TS_COORDINATE_ACTION_MOVE)) + touch_count++; + break; + } + } + #ifdef TYPE_B_PROTOCOL input_mt_slot(touch_hcd->input_dev, idx); input_mt_report_slot_state(touch_hcd->input_dev, @@ -816,20 +844,6 @@ static void touch_report(void) "Finger %d: x = %d, y = %d, x_width = %d, y_width = %d\n", idx, x, y, object_data[idx].x_width, object_data[idx].y_width); touch_count++; - - if (object_data[idx].status != touch_hcd->prev_status[idx]) { - if (tcm_hcd->imports && tcm_hcd->imports->report_touch_event) { - struct touch_event_data touch_event; - memset(&touch_event, 0, sizeof(touch_event)); - touch_event.type = TS_COORDINATE_ACTION_PRESS; - touch_event.id = idx; - touch_event.x = x; - touch_event.y = y; - touch_event.major = major; - touch_event.minor = minor; - tcm_hcd->imports->report_touch_event(&touch_event); - } - } break; default: break;