From 0c784ef158918e73bb0bf6db2a5974fd318edaec Mon Sep 17 00:00:00 2001 From: wangyq13 Date: Sun, 2 May 2021 17:26:35 +0800 Subject: [PATCH] input: focaltech_0flash_mmi: add panel notifications focaltech_0flash_mmi: Add panel notifications. bq-sm2020 use panel notification and touch_set_state for single tap. Change-Id: I0eb7b0a307e2601b24376ac90dc5a35d002cb1e8 Signed-off-by: wangyq13 Reviewed-on: https://gerrit.mot.com/1938270 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: litong Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- .../focaltech_0flash_mmi/Android.mk | 4 ++ .../touchscreen/focaltech_0flash_mmi/Kbuild | 4 ++ .../focaltech_0flash_mmi/focaltech_core.c | 60 +++++++++++++++++++ .../focaltech_0flash_mmi/focaltech_core.h | 3 + 4 files changed, 71 insertions(+) diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/Android.mk b/drivers/input/touchscreen/focaltech_0flash_mmi/Android.mk index b6ee6ac93b00..cfd680fd15c6 100644 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/Android.mk +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/Android.mk @@ -23,6 +23,10 @@ ifneq ($(findstring touchscreen_mmi.ko,$(BOARD_VENDOR_KERNEL_MODULES)),) KERNEL_CFLAGS += CONFIG_INPUT_TOUCHSCREEN_MMI=y endif +ifneq ($(BOARD_USES_PANEL_NOTIFICATIONS),) + KERNEL_CFLAGS += CONFIG_INPUT_FOCALTECH_PANEL_NOTIFICATIONS=y +endif + include $(CLEAR_VARS) LOCAL_MODULE := focaltech_0flash_mmi.ko LOCAL_MODULE_TAGS := optional diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/Kbuild b/drivers/input/touchscreen/focaltech_0flash_mmi/Kbuild index 36fe8ae9f1b2..47f4ee17aed6 100644 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/Kbuild +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/Kbuild @@ -58,3 +58,7 @@ ifneq ($(filter m y,$(CONFIG_INPUT_FOCALTECH_0FLASH_MMI_PEN_NOTIFIER)),) KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../../../misc/pen/Module.symvers EXTRA_CFLAGS += -DFOCALTECH_PEN_NOTIFIER endif + +ifneq ($(filter m y,$(CONFIG_INPUT_FOCALTECH_PANEL_NOTIFICATIONS)),) +EXTRA_CFLAGS += -DFOCALTECH_CONFIG_PANEL_NOTIFICATIONS +endif diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c index 0df08d636c3b..1c31934e90b0 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.c @@ -62,6 +62,18 @@ extern int fts_mmi_dev_register(struct fts_ts_data *ts_data); extern void fts_mmi_dev_unregister(struct fts_ts_data *ts_data); #endif +#ifdef FOCALTECH_CONFIG_PANEL_NOTIFICATIONS +#define register_panel_notifier panel_register_notifier +#define unregister_panel_notifier panel_unregister_notifier +enum touch_state { + TOUCH_DEEP_SLEEP_STATE = 0, + TOUCH_LOW_POWER_STATE, +}; +#else +#define register_panel_notifier(...) rc +#define unregister_panel_notifier(...) rc +#endif + /***************************************************************************** * Private constant and macro definitions using #define *****************************************************************************/ @@ -1837,6 +1849,7 @@ int drm_notifier_callback(struct notifier_block *self, unsigned long event, void return 0; } #else +#ifndef FOCALTECH_CONFIG_PANEL_NOTIFICATIONS int drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data) { @@ -1890,6 +1903,46 @@ int drm_notifier_callback(struct notifier_block *self, return 0; } +#else +int drm_notifier_callback(struct notifier_block *self, + unsigned long event, void *data) +{ + struct msm_drm_notifier *evdata = data; + struct fts_ts_data *ts_data = + container_of(self, struct fts_ts_data, fb_notif); + + if (!evdata || (evdata->id != 0)) { + return 0; + } + + FTS_INFO("DRM event:%lu", event); + switch (event) { + case PANEL_EVENT_DISPLAY_ON: + queue_work(fts_data->ts_workqueue, &fts_data->resume_work); + break; + case PANEL_EVENT_PRE_DISPLAY_OFF: + cancel_work_sync(&fts_data->resume_work); + fts_ts_suspend(ts_data->dev); +#ifdef FOCALTECH_SENSOR_EN + if (fts_data->should_enable_gesture) { + FTS_INFO("double tap gesture suspend\n"); + touch_set_state(TOUCH_LOW_POWER_STATE, TOUCH_PANEL_IDX_PRIMARY); + fts_gesture_suspend(ts_data); + } else { +#endif + touch_set_state(TOUCH_DEEP_SLEEP_STATE, TOUCH_PANEL_IDX_PRIMARY); + fts_ts_suspend(ts_data->dev); +#ifdef FOCALTECH_SENSOR_EN + } +#endif + break; + default: + break; + } + + return 0; +} +#endif #endif #elif defined(CONFIG_FB) static int fb_notifier_callback(struct notifier_block *self, @@ -2166,10 +2219,17 @@ static int fts_ts_probe_entry(struct fts_ts_data *ts_data) FTS_ERROR("[DRM]drm_panel_notifier_register fail: active_panel NULL!\n"); } #else +#ifndef FOCALTECH_CONFIG_PANEL_NOTIFICATIONS ret = msm_drm_register_client(&ts_data->fb_notif); if (ret) { FTS_ERROR("[DRM]Unable to register fb_notifier: %d\n", ret); } +#else + ret = register_panel_notifier(&ts_data->fb_notif); + if(ret) { + FTS_ERROR("register panel_notifier failed. ret=%d\n", ret); + } +#endif #endif #elif defined(CONFIG_FB) if (ts_data->ts_workqueue) { diff --git a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h index 7ec433f2f787..b8ec0a556307 100755 --- a/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h +++ b/drivers/input/touchscreen/focaltech_0flash_mmi/focaltech_core.h @@ -73,6 +73,9 @@ #include #define SENSOR_TYPE_MOTO_TOUCH_PALM (SENSOR_TYPE_DEVICE_PRIVATE_BASE + 31) #endif +#ifdef FOCALTECH_CONFIG_PANEL_NOTIFICATIONS +#include +#endif /***************************************************************************** * Private constant and macro definitions using #define