summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2022-08-08 14:25:28 +0800
committerdavidycchen <davidycchen@google.com>2022-08-08 15:21:42 +0800
commitde5cdbcffde875f1b7ea9cc3ad391375fa8803c3 (patch)
treeac139d0fdd5bf0cc41b0c9f114b6d05af7fefe9d
parentcb9c357e5415fcdbf4ced711f769823d90ddcaac (diff)
downloadsynaptics_touch-de5cdbcffde875f1b7ea9cc3ad391375fa8803c3.tar.gz
synaptics: set the firmware grip/palm mode with a workqueue
When there is a command triggered from a workqueue is still pending, a new command is sent from the interrupt handler causes the touch IC returns a pending error code. Move the setting commands in the interrupt handler to workqueue to avoid the above issue. Bug: 239181810 Test: Keep toggling the settings and scrolling the screen. watch -n2 "adb shell stop twoshay; sleep 1; adb shell start twoshay" Signed-off-by: davidycchen <davidycchen@google.com> Change-Id: Idb5a39147da56c2f3942280f6567ae696e3f1449
-rw-r--r--syna_tcm2.c75
-rw-r--r--syna_tcm2.h7
2 files changed, 58 insertions, 24 deletions
diff --git a/syna_tcm2.c b/syna_tcm2.c
index 0f3eeac..727715d 100644
--- a/syna_tcm2.c
+++ b/syna_tcm2.c
@@ -365,6 +365,46 @@ static void syna_set_report_rate_work(struct work_struct *work)
(tcm->touch_report_rate_config == CONFIG_HIGH_REPORT_RATE) ? 240 : 120);
}
+static void syna_set_grip_mode_work(struct work_struct *work)
+{
+ struct syna_tcm *tcm = container_of(work, struct syna_tcm, set_grip_mode_work);
+
+ if (tcm->pwr_state != PWR_ON) {
+ LOGI("Touch is already off.");
+ return;
+ }
+
+ if (tcm->enable_fw_grip != tcm->next_enable_fw_grip) {
+ tcm->enable_fw_grip = tcm->next_enable_fw_grip;
+ LOGI("%s firmware grip suppression.\n",
+ (tcm->enable_fw_grip == 1) ? "Enable" : "Disable");
+ syna_tcm_set_dynamic_config(tcm->tcm_dev,
+ DC_ENABLE_GRIP_SUPPRESSION,
+ tcm->enable_fw_grip,
+ RESP_IN_ATTN);
+ }
+}
+
+static void syna_set_palm_mode_work(struct work_struct *work)
+{
+ struct syna_tcm *tcm = container_of(work, struct syna_tcm, set_palm_mode_work);
+
+ if (tcm->pwr_state != PWR_ON) {
+ LOGI("Touch is already off.");
+ return;
+ }
+
+ if (tcm->enable_fw_palm != tcm->next_enable_fw_palm) {
+ tcm->enable_fw_palm = tcm->next_enable_fw_palm;
+ LOGI("%s firmware palm rejection.\n",
+ (tcm->enable_fw_palm == 1) ? "Enable" : "Disable");
+ syna_tcm_set_dynamic_config(tcm->tcm_dev,
+ DC_ENABLE_PALM_REJECTION,
+ tcm->enable_fw_palm,
+ RESP_IN_ATTN);
+ }
+}
+
#if defined(ENABLE_HELPER)
/**
* syna_dev_reset_detected_cb()
@@ -1070,38 +1110,21 @@ exit:
#if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD)
static void syna_offload_set_running(struct syna_tcm *tcm, bool running)
{
- int next_enable_fw_grip = 0;
- int next_enable_fw_palm = 0;
- if (tcm->offload.offload_running != running) {
+ if (tcm->offload.offload_running != running)
tcm->offload.offload_running = 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.
*/
- next_enable_fw_grip = running ? !tcm->offload.config.filter_grip : 1;
- next_enable_fw_palm = running ? !tcm->offload.config.filter_palm : 1;
+ tcm->next_enable_fw_grip = running ? !tcm->offload.config.filter_grip : 1;
+ tcm->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;
- syna_tcm_set_dynamic_config(tcm->tcm_dev,
- DC_ENABLE_GRIP_SUPPRESSION,
- tcm->enable_fw_grip,
- RESP_IN_POLLING);
- LOGI("%s firmware grip suppression.\n",
- (tcm->enable_fw_grip == 1) ? "Enable" : "Disable");
- }
+ if (tcm->next_enable_fw_grip != tcm->enable_fw_grip && tcm->enable_fw_grip < 2)
+ queue_work(tcm->event_wq, &tcm->set_grip_mode_work);
- if (next_enable_fw_palm != tcm->enable_fw_palm && tcm->enable_fw_palm < 2) {
- tcm->enable_fw_palm = next_enable_fw_palm;
- syna_tcm_set_dynamic_config(tcm->tcm_dev,
- DC_ENABLE_PALM_REJECTION,
- tcm->enable_fw_palm,
- RESP_IN_POLLING);
- LOGI("%s firmware palm rejection.\n",
- (tcm->enable_fw_palm == 1) ? "Enable" : "Disable");
- }
+ if (tcm->next_enable_fw_palm != tcm->enable_fw_palm && tcm->enable_fw_palm < 2)
+ queue_work(tcm->event_wq, &tcm->set_palm_mode_work);
}
static void syna_offload_report(void *handle,
@@ -2960,6 +2983,8 @@ static int syna_dev_probe(struct platform_device *pdev)
tcm->mf_mode = MF_DYNAMIC;
INIT_WORK(&tcm->motion_filter_work, syna_motion_filter_work);
+ INIT_WORK(&tcm->set_grip_mode_work, syna_set_grip_mode_work);
+ INIT_WORK(&tcm->set_palm_mode_work, syna_set_palm_mode_work);
tcm->touch_report_rate_config = CONFIG_HIGH_REPORT_RATE;
INIT_DELAYED_WORK(&tcm->set_report_rate_work, syna_set_report_rate_work);
@@ -3086,6 +3111,8 @@ static int syna_dev_remove(struct platform_device *pdev)
cancel_work_sync(&tcm->suspend_work);
cancel_work_sync(&tcm->resume_work);
cancel_work_sync(&tcm->motion_filter_work);
+ cancel_work_sync(&tcm->set_grip_mode_work);
+ cancel_work_sync(&tcm->set_palm_mode_work);
cancel_delayed_work_sync(&tcm->set_report_rate_work);
#if IS_ENABLED(CONFIG_TOUCHSCREEN_TBN)
diff --git a/syna_tcm2.h b/syna_tcm2.h
index a9c11cc..0aaee81 100644
--- a/syna_tcm2.h
+++ b/syna_tcm2.h
@@ -494,6 +494,11 @@ struct syna_tcm {
/* Work for motion filter commands. */
struct work_struct motion_filter_work;
+ /* Work for setting firmware grip mode. */
+ struct work_struct set_grip_mode_work;
+ /* Work for setting firmware palm mode. */
+ struct work_struct set_palm_mode_work;
+
/* IOCTL-related variables */
pid_t proc_pid;
struct task_struct *proc_task;
@@ -522,6 +527,8 @@ struct syna_tcm {
bool high_sensitivity_mode;
u8 enable_fw_grip;
u8 enable_fw_palm;
+ u8 next_enable_fw_grip;
+ u8 next_enable_fw_palm;
#if defined(USE_DRM_BRIDGE)
struct drm_bridge panel_bridge;