Skip to content

Commit 84e0506

Browse files
xNombreonettboots
authored andcommitted
input: goodix: Optimize irq handler
* Extract common variable * Add likely to if branch * Call gesture handlers only if system is suspended, this saves expensive mutex calls Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com> Signed-off-by: onettboots <blackcocopet@gmail.com>
1 parent a3d2f88 commit 84e0506

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

drivers/input/touchscreen/goodix_driver_gt9886/goodix_ts_core.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ static inline int goodix_ts_input_report(struct input_dev *dev,
996996
struct goodix_ts_device *ts_dev = core_data->ts_dev;
997997
unsigned int touch_num = touch_data->touch_num;
998998
int i, id;
999+
bool event_fod;
9991000

10001001
if (core_data->fod_status) {
10011002
if ((core_data->event_status & 0x20) == 0x20) {
@@ -1006,6 +1007,7 @@ static inline int goodix_ts_input_report(struct input_dev *dev,
10061007

10071008
mutex_lock(&ts_dev->report_mutex);
10081009
id = coords->id;
1010+
event_fod = (core_data->event_status & 0x88) == 0x88;
10091011
for (i = 0; i < ts_bdata->panel_max_id * 2; i++) {
10101012
if (touch_num && i == id) { /* this is a valid touch down event */
10111013
input_mt_slot(dev, id);
@@ -1022,7 +1024,7 @@ static inline int goodix_ts_input_report(struct input_dev *dev,
10221024
input_report_abs(dev, ABS_MT_TOUCH_MINOR, coords->area);
10231025
*/
10241026

1025-
if ((core_data->event_status & 0x88) != 0x88 || !core_data->fod_status)
1027+
if (!event_fod || !core_data->fod_status)
10261028
coords->overlapping_area = 0;
10271029
input_report_abs(dev, ABS_MT_WIDTH_MINOR, coords->overlapping_area);
10281030
input_report_abs(dev, ABS_MT_WIDTH_MAJOR, coords->overlapping_area);
@@ -1049,12 +1051,12 @@ static inline int goodix_ts_input_report(struct input_dev *dev,
10491051

10501052
/*report finger*/
10511053
/*ts_info("get_event_now :0x%02x, pre_event : %d", get_event_now, pre_event);*/
1052-
if ((core_data->event_status & 0x88) == 0x88 && core_data->fod_status) {
1054+
if (event_fod && core_data->fod_status) {
10531055
input_report_key(core_data->input_dev, BTN_INFO, 1);
10541056
/*input_report_key(core_data->input_dev, KEY_INFO, 1);*/
10551057
core_data->fod_pressed = true;
10561058
ts_info("BTN_INFO press");
1057-
} else if (core_data->fod_pressed && (core_data->event_status & 0x88) != 0x88) {
1059+
} else if (core_data->fod_pressed && !event_fod) {
10581060
if (unlikely(!core_data->fod_test)) {
10591061
input_report_key(core_data->input_dev, BTN_INFO, 0);
10601062
/*input_report_key(core_data->input_dev, KEY_INFO, 0);*/
@@ -1153,24 +1155,26 @@ static inline irqreturn_t goodix_ts_threadirq_func(int irq, void *data)
11531155
goto handled;
11541156
}
11551157

1156-
mutex_lock(&goodix_modules.mutex);
1157-
list_for_each_entry(ext_module, &goodix_modules.head, list) {
1158-
if (!ext_module->funcs->irq_event)
1159-
continue;
1160-
r = ext_module->funcs->irq_event(core_data, ext_module);
1161-
/*ts_err("enter %s r=%d\n", __func__, r);*/
1162-
if (r == EVT_CANCEL_IRQEVT) {
1163-
ts_err("enter %s EVT_CANCEL_IRQEVT\n", __func__);
1164-
mutex_unlock(&goodix_modules.mutex);
1165-
goto handled;
1158+
if (atomic_read(&core_data->suspended)) {
1159+
mutex_lock(&goodix_modules.mutex);
1160+
list_for_each_entry(ext_module, &goodix_modules.head, list) {
1161+
if (!ext_module->funcs->irq_event)
1162+
continue;
1163+
r = ext_module->funcs->irq_event(core_data, ext_module);
1164+
ts_err("enter %s r=%d\n", __func__, r);
1165+
if (r == EVT_CANCEL_IRQEVT) {
1166+
/*ts_err("enter %s EVT_CANCEL_IRQEVT \n", __func__);*/
1167+
mutex_unlock(&goodix_modules.mutex);
1168+
goto handled;
1169+
}
11661170
}
1171+
mutex_unlock(&goodix_modules.mutex);
11671172
}
1168-
mutex_unlock(&goodix_modules.mutex);
11691173

11701174
/* read touch data from touch device */
11711175
r = ts_dev->hw_ops->event_handler(ts_dev, ts_event);
11721176
if (likely(r >= 0)) {
1173-
if (ts_event->event_type == EVENT_TOUCH) {
1177+
if (likely(ts_event->event_type == EVENT_TOUCH)) {
11741178
/* report touch */
11751179
goodix_ts_input_report(core_data->input_dev,
11761180
&ts_event->event_data.touch_data);

drivers/input/touchscreen/goodix_driver_gt9886/goodix_ts_gesture.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ static int gsx_gesture_ist(struct goodix_ts_core *core_data,
422422
/*ts_debug("gsx_gesture_ist, core_data-suspend=%d",
423423
atomic_read(&core_data->suspended));*/
424424
/*ts_err("enter %s core_data->suspended=%d\n", __func__, atomic_read(&core_data->suspended));*/
425-
if (atomic_read(&core_data->suspended) == 0)
426-
return EVT_CONTINUE;
427425

428426
mutex_lock(&ts_dev->report_mutex);
429427
/* get ic gesture state*/

0 commit comments

Comments
 (0)