diff --git a/drivers/input/touchscreen/chipone_tddi/cts_config.h b/drivers/input/touchscreen/chipone_tddi/cts_config.h index d9581056203c..659a076e7681 100644 --- a/drivers/input/touchscreen/chipone_tddi/cts_config.h +++ b/drivers/input/touchscreen/chipone_tddi/cts_config.h @@ -19,7 +19,7 @@ //#define CFG_CTS_CASCADE_SUPPORTED /* Support RK dsi extcon notifier for suspend and resume */ -#define CONFIG_PM_DSI_EXTCON_NOTIFIER +//#define CONFIG_PM_DSI_EXTCON_NOTIFIER /* Support both finger and stylus protocol, 11 */ // #define CFG_CTS_FINGER_STYLUS_SUPPORTED diff --git a/drivers/input/touchscreen/chipone_tddi/cts_core.h b/drivers/input/touchscreen/chipone_tddi/cts_core.h index 955491378292..149f8f4bdba5 100644 --- a/drivers/input/touchscreen/chipone_tddi/cts_core.h +++ b/drivers/input/touchscreen/chipone_tddi/cts_core.h @@ -4,6 +4,9 @@ #define CTS_CORE_H #include "cts_config.h" +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif enum cts_dev_hw_reg { CTS_DEV_HW_REG_HARDWARE_ID = 0x70000u, @@ -529,6 +532,10 @@ struct chipone_ts_data { struct extcon_dev *edev; struct notifier_block extcon_nb; #endif + +#ifdef CONFIG_HAS_EARLYSUSPEND + struct early_suspend early_suspend; +#endif }; /*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..2ee9947c02dc 100644 --- a/drivers/input/touchscreen/chipone_tddi/cts_driver.c +++ b/drivers/input/touchscreen/chipone_tddi/cts_driver.c @@ -372,6 +372,26 @@ static int ts_extcon_notifier(struct notifier_block *self, } #endif +#ifdef CONFIG_HAS_EARLYSUSPEND +/* earlysuspend module the suspend/resume procedure */ +static void cts_ts_early_suspend(struct early_suspend *h) +{ + struct chipone_ts_data *cts_data = container_of(h, struct chipone_ts_data, early_suspend); + + pr_info("%s %d\n", __func__, __LINE__); + flush_work(&cts_data->ts_resume_work); + cts_suspend(cts_data); +} + +static void cts_ts_late_resume(struct early_suspend *h) +{ + struct chipone_ts_data *cts_data = container_of(h, struct chipone_ts_data, early_suspend); + + pr_info("%s %d\n", __func__, __LINE__); + queue_work(cts_data->workqueue, &cts_data->ts_resume_work); +} +#endif + #ifdef CONFIG_CTS_I2C_HOST static int cts_driver_probe(struct i2c_client *client, const struct i2c_device_id *id) @@ -615,6 +635,13 @@ static int cts_driver_probe(struct spi_device *client) #endif /* CONFIG_MTK_PLATFORM */ #endif +#ifdef CONFIG_HAS_EARLYSUSPEND + cts_data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; + cts_data->early_suspend.suspend = cts_ts_early_suspend; + cts_data->early_suspend.resume = cts_ts_late_resume; + register_early_suspend(&cts_data->early_suspend); +#endif + #ifdef CONFIG_PM_DSI_EXTCON_NOTIFIER cts_data->edev = extcon_get_edev_by_phandle(&client->dev, 0); if (IS_ERR(cts_data->edev)) { @@ -756,6 +783,10 @@ static void cts_driver_remove(struct spi_device *client) #endif #endif +#ifdef CONFIG_HAS_EARLYSUSPEND + unregister_early_suspend(&cts_data->early_suspend); +#endif + cts_tool_deinit(cts_data); cts_sysfs_remove_device(&client->dev);