From 08d0ce41877a0680c2013c3d81592c486a41cf02 Mon Sep 17 00:00:00 2001 From: dengwei1 Date: Fri, 17 Sep 2021 17:11:50 +0800 Subject: [PATCH] xpeng: input touch add wait when single tap input touch add wait when single tap Change-Id: I11e11de6d4d96e28606a50b13f88b769159d4ced Signed-off-by: dengwei1 Reviewed-on: https://gerrit.mot.com/2069935 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- .../touchscreen/nova_0flash_mmi/nt36xxx.c | 53 +++++++++++++++++++ .../touchscreen/nova_0flash_mmi/nt36xxx.h | 3 ++ 2 files changed, 56 insertions(+) diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c index 01c179e4aa4e..4371806114c7 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c @@ -1350,6 +1350,13 @@ static int32_t nvt_parse_dt(struct device *dev) ts->charger_detection_enable = 0; } + if (of_property_read_bool(np, "novatek,gesture-wait-pm")) { + NVT_LOG("novatek,gesture-wait-pm set"); + ts->gesture_wait_pm = true; + } else { + ts->gesture_wait_pm = false; + } + if (of_property_read_bool(np, "novatek,report_gesture_key")) { NVT_LOG("novatek,report_gesture_key set"); ts->report_gesture_key = 1; @@ -1611,6 +1618,15 @@ static irqreturn_t nvt_ts_work_func(int irq, void *data) #if WAKEUP_GESTURE if (ts->bTouchIsAwake == 0) { pm_wakeup_event(&ts->input_dev->dev, 5000); + + if ((ts->gesture_wait_pm) && (ts->gesture_enabled)) { + /* Waiting for pm resume completed */ + ret = wait_event_interruptible_timeout(ts->pm_wq, atomic_read(&ts->pm_resume), msecs_to_jiffies(700)); + if (!ret) { + NVT_ERR("system(spi) can't finished resuming procedure."); + return IRQ_HANDLED; + } + } } #endif @@ -2481,6 +2497,10 @@ static int32_t nvt_ts_probe(struct spi_device *client) } } + if (ts->gesture_wait_pm) + init_waitqueue_head(&ts->pm_wq); + atomic_set(&ts->pm_resume, 1); + #if WAKEUP_GESTURE device_init_wakeup(&ts->input_dev->dev, 1); #endif @@ -3479,6 +3499,36 @@ static struct of_device_id nvt_match_table[] = { }; #endif +static int nvt_pm_suspend(struct device *dev) +{ + struct nvt_ts_data *ts = dev_get_drvdata(dev); + + NVT_LOG("CALL BACK TP PM SUSPEND"); + + atomic_set(&ts->pm_resume, 0); + + return 0; +} + +static int nvt_pm_resume(struct device *dev) +{ + struct nvt_ts_data *ts = dev_get_drvdata(dev); + + NVT_LOG("CALL BACK TP PM RESUME"); + + atomic_set(&ts->pm_resume, 1); + + if ((ts->gesture_wait_pm) && (ts->gesture_enabled)) + wake_up_interruptible(&ts->pm_wq); + + return 0; +} + +static const struct dev_pm_ops nvt_dev_pm_ops = { + .suspend = nvt_pm_suspend, + .resume = nvt_pm_resume, +}; + static struct spi_driver nvt_spi_driver = { .probe = nvt_ts_probe, .remove = nvt_ts_remove, @@ -3489,6 +3539,9 @@ static struct spi_driver nvt_spi_driver = { .owner = THIS_MODULE, #ifdef CONFIG_OF .of_match_table = nvt_match_table, +#endif +#ifdef CONFIG_PM + .pm = &nvt_dev_pm_ops, #endif }, }; diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h index 3633e7a54a85..6bd48f527752 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h @@ -206,6 +206,9 @@ struct nvt_ts_data { uint8_t *xbuf; struct mutex xbuf_lock; bool irq_enabled; + atomic_t pm_resume; + wait_queue_head_t pm_wq; + bool gesture_wait_pm; const char *panel_supplier; #ifdef CONFIG_MTK_SPI struct mt_chip_conf spi_ctrl;