From fc4dc05e15a1a02bc6d6ddcc9f3d19e91426fcbf Mon Sep 17 00:00:00 2001 From: Zhibin Huang Date: Wed, 17 Apr 2024 16:59:47 +0800 Subject: [PATCH] input: touchscreen: chipone_tddi: use panel notifier to fix resume/suspend timing Type: Fix Redmine ID: #474634 #468692 Associated modifications: N/A Test: N/A Signed-off-by: Zhibin Huang Change-Id: I85387aa2a35ccc78dd16500a8abbb2ee2758d1ea --- .../input/touchscreen/chipone_tddi/Kconfig | 13 +++-- .../touchscreen/chipone_tddi/cts_config.h | 7 +-- .../input/touchscreen/chipone_tddi/cts_core.h | 8 +-- .../touchscreen/chipone_tddi/cts_driver.c | 55 ++++++------------- 4 files changed, 31 insertions(+), 52 deletions(-) diff --git a/drivers/input/touchscreen/chipone_tddi/Kconfig b/drivers/input/touchscreen/chipone_tddi/Kconfig index d5d30af6cd16..03999193e381 100644 --- a/drivers/input/touchscreen/chipone_tddi/Kconfig +++ b/drivers/input/touchscreen/chipone_tddi/Kconfig @@ -4,9 +4,10 @@ # config TOUCHSCREEN_CHIPONE_9551R - tristate "chipone Touchscreen" - depends on I2C - default n - help - Say Y here if you have chipone touch panel. - If unsure, say N. + tristate "chipone Touchscreen" + depends on I2C + select ROCKCHIP_PANEL_NOTIFIER + default n + help + Say Y here if you have chipone touch panel. + If unsure, say N. diff --git a/drivers/input/touchscreen/chipone_tddi/cts_config.h b/drivers/input/touchscreen/chipone_tddi/cts_config.h index d9581056203c..8ab04d208458 100644 --- a/drivers/input/touchscreen/chipone_tddi/cts_config.h +++ b/drivers/input/touchscreen/chipone_tddi/cts_config.h @@ -18,18 +18,15 @@ /* Support cascade application */ //#define CFG_CTS_CASCADE_SUPPORTED -/* Support RK dsi extcon notifier for suspend and resume */ -#define CONFIG_PM_DSI_EXTCON_NOTIFIER - /* Support both finger and stylus protocol, 11 */ // #define CFG_CTS_FINGER_STYLUS_SUPPORTED /* #define CFG_CTS_STYLUS_BTN_SUPPORTED */ -#define CONFIG_CTS_I2C_HOST +#define CONFIG_CTS_I2C_HOST /* For Goole Security */ -#define CFG_CTS_FOR_GKI +#define CFG_CTS_FOR_GKI /** Whether reset pin is used */ #define CFG_CTS_HAS_RESET_PIN diff --git a/drivers/input/touchscreen/chipone_tddi/cts_core.h b/drivers/input/touchscreen/chipone_tddi/cts_core.h index 955491378292..6647e5b4831a 100644 --- a/drivers/input/touchscreen/chipone_tddi/cts_core.h +++ b/drivers/input/touchscreen/chipone_tddi/cts_core.h @@ -3,6 +3,8 @@ #ifndef CTS_CORE_H #define CTS_CORE_H +#include + #include "cts_config.h" enum cts_dev_hw_reg { @@ -525,10 +527,8 @@ struct chipone_ts_data { bool force_reflash; // struct kobject *suspend_kobj; -#ifdef CONFIG_PM_DSI_EXTCON_NOTIFIER - struct extcon_dev *edev; - struct notifier_block extcon_nb; -#endif + + struct notifier_block panel_nb; }; /*static inline u32 get_unaligned_le24(const void *p) diff --git a/drivers/input/touchscreen/chipone_tddi/cts_driver.c b/drivers/input/touchscreen/chipone_tddi/cts_driver.c index 3ebd444b2eb0..f83db394a355 100644 --- a/drivers/input/touchscreen/chipone_tddi/cts_driver.c +++ b/drivers/input/touchscreen/chipone_tddi/cts_driver.c @@ -5,7 +5,6 @@ #else #define LOG_TAG "SPIDrv" #endif -#include #include "cts_config.h" #include "cts_platform.h" #include "cts_core.h" @@ -348,29 +347,22 @@ static int cts_get_panel(void) } #endif -#ifdef CONFIG_PM_DSI_EXTCON_NOTIFIER -static int ts_extcon_notifier(struct notifier_block *self, - unsigned long event, void *data) +static int rockchip_panel_notifier_call(struct notifier_block *self, + unsigned long val, void *v) { + enum rockchip_panel_event event = (enum rockchip_panel_event)val; struct chipone_ts_data *cts_data = - container_of(self, struct chipone_ts_data, extcon_nb); - if (extcon_get_state(cts_data->edev, EXTCON_JACK_VIDEO_OUT)){ - pr_info("%s %d\n", __func__, __LINE__); - //cts_plat_set_reset(cts_data->pdata, 1); - //mdelay(1); - //cts_plat_set_reset(cts_data->pdata, 0); - //mdelay(5);/* 1ms */ - //cts_plat_set_reset(cts_data->pdata, 1); - cts_resume(cts_data); - } else { - cts_suspend(cts_data); - pr_info("%s %d\n", __func__, __LINE__); - //cts_plat_set_reset(cts_data->pdata, 0); - } + container_of(self, struct chipone_ts_data, panel_nb); - return 0; + if (event == PANEL_ENABLED) { + cts_info("notify to resume"); + cts_resume(cts_data); + } else if (event == PANEL_PRE_DISABLE) { + cts_info("notify to suspend"); + cts_suspend(cts_data); + } + return NOTIFY_OK; } -#endif #ifdef CONFIG_CTS_I2C_HOST static int cts_driver_probe(struct i2c_client *client, @@ -615,25 +607,14 @@ static int cts_driver_probe(struct spi_device *client) #endif /* CONFIG_MTK_PLATFORM */ #endif -#ifdef CONFIG_PM_DSI_EXTCON_NOTIFIER - cts_data->edev = extcon_get_edev_by_phandle(&client->dev, 0); - if (IS_ERR(cts_data->edev)) { - if (PTR_ERR(cts_data->edev) != -EPROBE_DEFER) - dev_err(&client->dev, "Invalid or missing extcon\n"); - pr_info("register notifier...but extcon_get_edev error\n"); - return 0; - } + cts_data->panel_nb.notifier_call = rockchip_panel_notifier_call; - cts_data->extcon_nb.notifier_call = ts_extcon_notifier; - ret = extcon_register_notifier(cts_data->edev, EXTCON_JACK_VIDEO_OUT, - &cts_data->extcon_nb); - pr_info("register notifier...\n"); - if (ret < 0) { - pr_info("fail to register notifier...\n"); - dev_err(&client->dev, "failed to register notifier for TP\n"); - return ret; + ret = devm_rockchip_panel_notifier_register_client(&client->dev, + &cts_data->panel_nb); + if (ret) { + cts_err("failed to register notifier client for TP: %d\n", ret); + goto err_deinit_oem; } -#endif return 0;