From 2f9acaba4bc8caa93634d9437b7be8c56caadacf Mon Sep 17 00:00:00 2001 From: wengjun1 Date: Fri, 10 Jan 2020 13:40:23 +0800 Subject: [PATCH] DLKM: Nairobi NT36672c touch bringup - Add BOARD_USES_PANEL_NOTIFICATIONS for enable panel notifications feature to fit for new display notifier callchain. Change-Id: I16c7fef774d0b76d4a4d23ad39673f85bfff582b Signed-off-by: wengjun1 Reviewed-on: https://gerrit.mot.com/1481808 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Hujun Liao Submit-Approved: Jira Key --- .../touchscreen/nova_0flash_mmi/Android.mk | 4 ++ .../input/touchscreen/nova_0flash_mmi/Kbuild | 3 + .../touchscreen/nova_0flash_mmi/nt36xxx.c | 55 +++++++++++++++++++ .../touchscreen/nova_0flash_mmi/nt36xxx.h | 7 +++ 4 files changed, 69 insertions(+) diff --git a/drivers/input/touchscreen/nova_0flash_mmi/Android.mk b/drivers/input/touchscreen/nova_0flash_mmi/Android.mk index 142b78de1475..4d7536a1a96e 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/Android.mk +++ b/drivers/input/touchscreen/nova_0flash_mmi/Android.mk @@ -11,6 +11,10 @@ ifneq ($(BOARD_USES_DOUBLE_TAP),) KERNEL_CFLAGS += CONFIG_INPUT_NOVA_0FLASH_MMI_ENABLE_DOUBLE_TAP=y endif +ifneq ($(BOARD_USES_PANEL_NOTIFICATIONS),) + KERNEL_CFLAGS += CONFIG_INPUT_NOVA_PANEL_NOTIFICATIONS=y +endif + include $(CLEAR_VARS) LOCAL_MODULE := nova_0flash_mmi.ko LOCAL_MODULE_TAGS := optional diff --git a/drivers/input/touchscreen/nova_0flash_mmi/Kbuild b/drivers/input/touchscreen/nova_0flash_mmi/Kbuild index b8e992b80b6c..c80094bee12a 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/Kbuild +++ b/drivers/input/touchscreen/nova_0flash_mmi/Kbuild @@ -9,6 +9,9 @@ endif ifneq ($(filter m y,$(CONFIG_INPUT_NOVA_0FLASH_MMI_ENABLE_DOUBLE_TAP)),) EXTRA_CFLAGS += -DNVT_SENSOR_EN endif +ifneq ($(filter m y,$(CONFIG_INPUT_NOVA_PANEL_NOTIFICATIONS)),) +EXTRA_CFLAGS += -DNVT_CONFIG_PANEL_NOTIFICATIONS +endif nova_0flash_mmi-objs += nt36xxx.o nova_0flash_mmi-objs += nt36xxx_ext_proc.o diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c index 4f0d81f1a60c..8a0e9f1324eb 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c @@ -41,6 +41,13 @@ #include #endif /* #if NVT_TOUCH_ESD_PROTECT */ +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS +#define register_panel_notifier panel_register_notifier +#define unregister_panel_notifier panel_unregister_notifier +#else +#define register_panel_notifier(...) rc +#define unregister_panel_notifier(...) rc +#endif #ifdef NVT_SENSOR_EN #ifdef CONFIG_HAS_WAKELOCK @@ -107,6 +114,10 @@ static void nvt_ts_early_suspend(struct early_suspend *h); static void nvt_ts_late_resume(struct early_suspend *h); #endif +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS +static int nvt_panel_notifier_callback(struct notifier_block *self, unsigned long event, void *data); +#endif + uint32_t ENG_RST_ADDR = 0x7FFF80; uint32_t SWRST_N8_ADDR = 0; //read from dtsi uint32_t SPI_RD_FAST_ADDR = 0; //read from dtsi @@ -2090,6 +2101,16 @@ static int32_t nvt_ts_probe(struct spi_device *client) goto err_register_fb_notif_failed; } #endif + +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS + ts->panel_notif.notifier_call = nvt_panel_notifier_callback; + ret = register_panel_notifier(&ts->panel_notif); + if(ret) { + NVT_ERR("register panel_notifier failed. ret=%d\n", ret); + goto err_register_fb_notif_failed; + } +#endif + #elif defined(CONFIG_HAS_EARLYSUSPEND) ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = nvt_ts_early_suspend; @@ -2218,6 +2239,11 @@ static int32_t nvt_ts_remove(struct spi_device *client) unregister_early_suspend(&ts->early_suspend); #endif +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS + if (unregister_panel_notifier(&ts->panel_notif)) + NVT_ERR("Error occurred while unregistering panel_notifier.\n"); +#endif + #if NVT_TOUCH_MP nvt_mp_proc_deinit(); #endif @@ -2296,6 +2322,11 @@ static void nvt_ts_shutdown(struct spi_device *client) unregister_early_suspend(&ts->early_suspend); #endif +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS + if (unregister_panel_notifier(&ts->panel_notif)) + NVT_ERR("Error occurred while unregistering panel_notifier.\n"); +#endif + #if NVT_TOUCH_MP nvt_mp_proc_deinit(); #endif @@ -2507,6 +2538,30 @@ static int32_t nvt_ts_resume(struct device *dev) return 0; } +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS +static int nvt_panel_notifier_callback(struct notifier_block *self, unsigned long event, void *data) +{ + struct nvt_ts_data *ts = + container_of(self, struct nvt_ts_data, panel_notif); + + switch (event) { + case PANEL_EVENT_PRE_DISPLAY_OFF: + NVT_LOG("event=%lu\n", event); + nvt_ts_suspend(&ts->client->dev); + break; + + case PANEL_EVENT_PRE_DISPLAY_ON: + NVT_LOG("event=%lu\n", event); + nvt_ts_resume(&ts->client->dev); + break; + default: /* use DEV_TS here to avoid unused variable */ + NVT_LOG("%s: function not implemented event %lu\n", __func__, event); + break; + } + + return 0; +} +#endif #if defined(CONFIG_FB) #ifdef _MSM_DRM_NOTIFY_H_ diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h index 231134387f87..43270b19a358 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h @@ -27,6 +27,10 @@ #include #endif +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS +#include +#endif + #ifdef CONFIG_HAS_EARLYSUSPEND #include #endif @@ -150,6 +154,9 @@ struct nvt_ts_data { #endif #elif defined(CONFIG_HAS_EARLYSUSPEND) struct early_suspend early_suspend; +#endif +#ifdef NVT_CONFIG_PANEL_NOTIFICATIONS + struct notifier_block panel_notif; #endif uint8_t fw_ver; uint8_t x_num;