summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2021-06-15 10:44:40 +0800
committerDavid Chen <davidycchen@google.com>2021-06-16 05:27:12 +0000
commit71bca30c738bd50d62ba548501668681b4bf5098 (patch)
tree84f555652035c5d86f75f507c1ec9bc448719079
parent967599618a0068a7865f6338a3416066e83d4cfa (diff)
downloadfts_touch-71bca30c738bd50d62ba548501668681b4bf5098.tar.gz
touch: fts: add mutex to protect offload report
When the release_all_touches and offload_report run at the same time, it may cause the input report conflict before input sync. bug: 190460965 Test: flash boot.img and vendor_boot.img. Signed-off-by: davidycchen <davidycchen@google.com> Change-Id: I35e5d296a762629e64d0851f5336b7de604f8e86
-rw-r--r--fts.c26
-rw-r--r--fts.h2
2 files changed, 23 insertions, 5 deletions
diff --git a/fts.c b/fts.c
index e2cf7be..5fbc576 100644
--- a/fts.c
+++ b/fts.c
@@ -163,6 +163,8 @@ void release_all_touches(struct fts_ts_info *info)
unsigned int type = MT_TOOL_FINGER;
int i;
+ mutex_lock(&info->input_report_mutex);
+
for (i = 0; i < TOUCH_ID_MAX; i++) {
#ifdef STYLUS_MODE
if (test_bit(i, &info->stylus_id))
@@ -183,6 +185,9 @@ void release_all_touches(struct fts_ts_info *info)
}
input_report_key(info->input_dev, BTN_TOUCH, 0);
input_sync(info->input_dev);
+
+ mutex_unlock(&info->input_report_mutex);
+
info->touch_id = 0;
info->palm_touch_mask = 0;
info->grip_touch_mask = 0;
@@ -191,7 +196,6 @@ void release_all_touches(struct fts_ts_info *info)
#endif
}
-
/**
* @defgroup file_nodes Driver File Nodes
* Driver publish a series of file nodes used to provide several utilities
@@ -3003,6 +3007,8 @@ static bool fts_enter_pointer_event_handler(struct fts_ts_info *info, unsigned
if (!info->resume_bit)
goto no_report;
+ mutex_lock(&info->input_report_mutex);
+
touchType = event[1] & 0x0F;
touchId = (event[1] & 0xF0) >> 4;
@@ -3087,6 +3093,7 @@ static bool fts_enter_pointer_event_handler(struct fts_ts_info *info, unsigned
break;
default:
+ mutex_unlock(&info->input_report_mutex);
pr_err("%s : Invalid touch type = %d ! No Report...\n",
__func__, touchType);
goto no_report;
@@ -3131,7 +3138,8 @@ static bool fts_enter_pointer_event_handler(struct fts_ts_info *info, unsigned
#endif
/* pr_info("%s : Event 0x%02x - ID[%d], (x, y) = (%3d, %3d)
* Size = %d\n",
- * __func__, *event, touchId, x, y, touchType); */
+ * __func__, *event, touchId, x, y, touchType); */
+ mutex_unlock(&info->input_report_mutex);
return true;
no_report:
@@ -3149,6 +3157,8 @@ static bool fts_leave_pointer_event_handler(struct fts_ts_info *info, unsigned
unsigned int tool = MT_TOOL_FINGER;
u8 touchType;
+ mutex_lock(&info->input_report_mutex);
+
touchType = event[1] & 0x0F;
touchId = (event[1] & 0xF0) >> 4;
@@ -3181,6 +3191,7 @@ static bool fts_leave_pointer_event_handler(struct fts_ts_info *info, unsigned
break;
default:
+ mutex_unlock(&info->input_report_mutex);
pr_err("%s : Invalid touch type = %d ! No Report...\n",
__func__, touchType);
return false;
@@ -3200,6 +3211,8 @@ static bool fts_leave_pointer_event_handler(struct fts_ts_info *info, unsigned
}
#endif
+ mutex_unlock(&info->input_report_mutex);
+
return true;
}
@@ -4381,11 +4394,12 @@ static irqreturn_t fts_interrupt_handler(int irq, void *handle)
#if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD)
if (!info->offload.offload_running) {
#endif
-
+ mutex_lock(&info->input_report_mutex);
if (info->touch_id == 0)
input_report_key(info->input_dev, BTN_TOUCH, 0);
input_sync(info->input_dev);
+ mutex_unlock(&info->input_report_mutex);
#if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD)
}
@@ -4437,6 +4451,8 @@ static void fts_offload_report(void *handle,
bool touch_down = 0;
int i;
+ mutex_lock(&info->input_report_mutex);
+
input_set_timestamp(info->input_dev, report->timestamp);
for (i = 0; i < MAX_COORDS; i++) {
@@ -4473,6 +4489,8 @@ static void fts_offload_report(void *handle,
input_report_key(info->input_dev, BTN_TOUCH, touch_down);
input_sync(info->input_dev);
+
+ mutex_unlock(&info->input_report_mutex);
}
#endif /* CONFIG_TOUCHSCREEN_OFFLOAD */
@@ -6319,7 +6337,7 @@ static int fts_probe(struct spi_device *client)
mutex_init(&info->diag_cmd_lock);
- mutex_init(&(info->input_report_mutex));
+ mutex_init(&info->input_report_mutex);
mutex_init(&info->bus_mutex);
/* Assume screen is on throughout probe */
diff --git a/fts.h b/fts.h
index c2f0575..cdbe253 100644
--- a/fts.h
+++ b/fts.h
@@ -473,7 +473,7 @@ struct fts_ts_info {
struct wakeup_source *wakesrc; /* Wake Lock struct */
/* input lock */
- struct mutex input_report_mutex; /* Mutex for pressure report */
+ struct mutex input_report_mutex; /* Mutex for input report */
/* switches for features */
int gesture_enabled; /* Gesture during suspend */