diff options
author | davidycchen <davidycchen@google.com> | 2022-06-23 11:32:39 +0800 |
---|---|---|
committer | davidycchen <davidycchen@google.com> | 2022-06-24 12:16:18 +0800 |
commit | 44ad886dfc65303a74c87bd5b7e26149b46fc258 (patch) | |
tree | 58e54de7359313a864b53b897cc3b0b4ff18828c | |
parent | 1ae90fa9c4db5a427e821d4d19123969387a9f2c (diff) | |
download | synaptics_touch-44ad886dfc65303a74c87bd5b7e26149b46fc258.tar.gz |
synaptics: avoid reserved offload buffer without queued
Before this patch, the touch_offload_reserve_frame() and the
touch_offload_queue_frame() are call in different interrupts.
Let both function be called in the same interrupt.
Bug: 236763752
Test: enable/disable the twoshay while sliding without getting issue.
Signed-off-by: davidycchen <davidycchen@google.com>
Change-Id: I56ba750dfdbb50bb6a2b9b73cefd3e5f8e56638a
-rw-r--r-- | syna_tcm2.c | 75 | ||||
-rw-r--r-- | syna_tcm2.h | 2 |
2 files changed, 38 insertions, 39 deletions
diff --git a/syna_tcm2.c b/syna_tcm2.c index f610c6e..bf23c2c 100644 --- a/syna_tcm2.c +++ b/syna_tcm2.c @@ -610,6 +610,7 @@ static int syna_dev_parse_custom_gesture_cb(const unsigned char code, return bits; } #endif + /** * syna_tcm_free_input_events() * @@ -857,6 +858,8 @@ static void syna_dev_report_input_events(struct syna_tcm *tcm) syna_update_motion_filter(tcm, touch_count); #if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) + } else { + tcm->offload_reserved_coords = true; } #endif @@ -1075,14 +1078,8 @@ static void syna_offload_set_running(struct syna_tcm *tcm, bool running) * Use the configurations set by touch service if it's running. * Enable the firmware grip and palm if the touch service isn't running. */ - if (running) { - next_enable_fw_grip = tcm->offload.config.filter_grip; - next_enable_fw_palm = tcm->offload.config.filter_palm; - } else { - /* Enable the firmware grip and palm when touch */ - next_enable_fw_grip = 1; - next_enable_fw_palm = 1; - } + next_enable_fw_grip = running ? !tcm->offload.config.filter_grip : 1; + next_enable_fw_palm = running ? !tcm->offload.config.filter_palm : 1; if (next_enable_fw_grip != tcm->enable_fw_grip && tcm->enable_fw_grip < 2) { tcm->enable_fw_grip = next_enable_fw_grip; @@ -1345,6 +1342,32 @@ static void syna_populate_frame(struct syna_tcm *tcm, bool has_heatmap) } ATRACE_END(); } + +static void reserve_then_queue_frame(struct syna_tcm *tcm, bool has_heatmap) { + int retval; + + /* Skip if no reserved coordinates. */ + if (!tcm->offload_reserved_coords && tcm->offload.offload_running) + return; + + retval = touch_offload_reserve_frame(&tcm->offload, &tcm->reserved_frame); + if (retval != 0) { + LOGD("Could not reserve a frame: error=%d.\n", retval); + + /* Stop offload when there are no buffers available. */ + syna_offload_set_running(tcm, false); + } else { + syna_offload_set_running(tcm, true); + + syna_populate_frame(tcm, has_heatmap); + + retval = touch_offload_queue_frame(&tcm->offload, tcm->reserved_frame); + if (retval != 0) + LOGE("Failed to queue reserved frame: error=%d.\n", retval); + + tcm->offload_reserved_coords = false; + } +} #endif /* CONFIG_TOUCHSCREEN_OFFLOAD */ #if IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) @@ -1468,13 +1491,13 @@ static irqreturn_t syna_dev_interrupt_thread(int irq, void *data) /* report input event only when receiving a touch report */ if (code == REPORT_TOUCH) { #if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) - if (tcm->reserved_frame_success) { - LOGW("Last reserved frame was not queued.\n"); - syna_populate_frame(tcm, false); - touch_offload_queue_frame(&tcm->offload, tcm->reserved_frame); - tcm->reserved_frame_success = false; + /* Reserve and queue the frame if last reserved coordinates is pending. */ + if ((tcm->offload_reserved_coords) && (tcm->offload.offload_running)) { + LOGW("Last reserved coordinates was not queued.\n"); + reserve_then_queue_frame(tcm, false); } #endif + /* parse touch report once received */ retval = syna_tcm_parse_touch_report(tcm->tcm_dev, tcm->event_data.buf, @@ -1486,19 +1509,6 @@ static irqreturn_t syna_dev_interrupt_thread(int irq, void *data) } tcm->coords_timestamp = tcm->isr_timestamp; -#if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) - retval = touch_offload_reserve_frame(&tcm->offload, &tcm->reserved_frame); - if (retval != 0) { - LOGD("Could not reserve a frame: error=%d.\n", retval); - - /* Stop offload when there are no buffers available. */ - syna_offload_set_running(tcm, false); - } else { - tcm->reserved_frame_success = true; - syna_offload_set_running(tcm, true); - } -#endif - /* forward the touch event to system */ ATRACE_BEGIN("report_input_events"); syna_dev_report_input_events(tcm); @@ -1534,18 +1544,7 @@ static irqreturn_t syna_dev_interrupt_thread(int irq, void *data) LOGD("Heat map data received, size:%d\n", tcm->event_data.data_length); #if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) - if (tcm->offload.offload_running) { - syna_populate_frame(tcm, true); - - retval = touch_offload_queue_frame(&tcm->offload, - tcm->reserved_frame); - if (retval != 0) { - LOGE("Failed to queue reserved frame: error=%d.\n", - retval); - } else { - tcm->reserved_frame_success = false; - } - } + reserve_then_queue_frame(tcm, true); #endif #if IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) ATRACE_BEGIN("heatmap_read"); diff --git a/syna_tcm2.h b/syna_tcm2.h index e9536e5..a9c11cc 100644 --- a/syna_tcm2.h +++ b/syna_tcm2.h @@ -469,7 +469,7 @@ struct syna_tcm { struct touch_offload_context offload; u16 *heatmap_buff; struct touch_offload_frame *reserved_frame; - bool reserved_frame_success; + bool offload_reserved_coords; #endif #if IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) |