From 5f1062123376868d86c6c4c4b5cfc0c22f2c55d7 Mon Sep 17 00:00:00 2001 From: longc Date: Fri, 28 Jul 2023 10:25:16 +0800 Subject: [PATCH] :tp:Support Qcom panel notify for 2nd fogona touch WHY:need panel notify HOW:add tp notify Change-Id: I9eec4e548653293dc5dc1facdaa3ea9040078709 Reviewed-on: https://gerrit.mot.com/2692918 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Yan Zhang Reviewed-by: Reviewed-by: Xiangpo Zhao Submit-Approved: Jira Key --- .../touchscreen/nova_0flash_mmi/Android.mk | 6 +- .../input/touchscreen/nova_0flash_mmi/Kbuild | 2 +- .../touchscreen/nova_0flash_mmi/nt36xxx.c | 98 ++++++++++++++++++- .../touchscreen/nova_0flash_mmi/nt36xxx.h | 10 +- 4 files changed, 111 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/nova_0flash_mmi/Android.mk b/drivers/input/touchscreen/nova_0flash_mmi/Android.mk index 9c1db7d9426e..b6e6306832fa 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/Android.mk +++ b/drivers/input/touchscreen/nova_0flash_mmi/Android.mk @@ -9,6 +9,7 @@ endif ifneq ($(BOARD_USES_DOUBLE_TAP),) KERNEL_CFLAGS += CONFIG_INPUT_NOVA_0FLASH_MMI_ENABLE_DOUBLE_TAP=y + KBUILD_OPTIONS += CONFIG_INPUT_NOVA_0FLASH_MMI_ENABLE_DOUBLE_TAP=y endif ifeq ($(TOUCHSCREEN_LAST_TIME),true) @@ -28,7 +29,8 @@ ifneq ($(BOARD_USES_PANEL_NOTIFICATIONS),) endif ifeq ($(CONFIG_INPUT_ENABLE_DRM_PANEL),true) - KERNEL_CFLAGS += CONFIG_INPUT_NOVA_DRM_PANEL=y + KERNEL_CFLAGS += CONFIG_INPUT_NOVA_DRM_PANEL=y + KBUILD_OPTIONS += CONFIG_INPUT_NOVA_DRM_PANEL=y endif ifeq ($(CONFIG_INPUT_NOVA_USES_CHIP_VER_1),true) @@ -96,7 +98,7 @@ LOCAL_MODULE_TAGS := optional LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT) LOCAL_ADDITIONAL_DEPENDENCIES += $(KERNEL_MODULES_OUT)/mmi_info.ko ifneq ($(findstring touchscreen_mmi.ko,$(BOARD_VENDOR_KERNEL_MODULES)),) - KBUILD_OPTIONS += CONFIG_INPUT_TOUCHSCREEN_MMI=y + KBUILD_OPTIONS += CONFIG_INPUT_TOUCHSCREEN_MMI_NVT=y LOCAL_ADDITIONAL_DEPENDENCIES += $(KERNEL_MODULES_OUT)/touchscreen_mmi.ko endif ifneq ($(MOTO_PANEL_CHECK_TOUCH_STATE_V2),) diff --git a/drivers/input/touchscreen/nova_0flash_mmi/Kbuild b/drivers/input/touchscreen/nova_0flash_mmi/Kbuild index 22c75ceb9d72..b47c067739a8 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/Kbuild +++ b/drivers/input/touchscreen/nova_0flash_mmi/Kbuild @@ -74,7 +74,7 @@ endif ifneq ($(filter m y,$(CONFIG_DRM_PANEL_EVENT_NOTIFICATIONS)),) EXTRA_CFLAGS += -DCONFIG_DRM_PANEL_EVENT_NOTIFICATIONS endif -ifneq ($(filter m y,$(CONFIG_INPUT_TOUCHSCREEN_MMI)),) +ifneq ($(filter m y,$(CONFIG_INPUT_TOUCHSCREEN_MMI_NVT)),) KBUILD_EXTRA_SYMBOLS += $(CURDIR)/$(KBUILD_EXTMOD)/../touchscreen_mmi/$(GKI_OBJ_MODULE_DIR)/Module.symvers EXTRA_CFLAGS += -DCONFIG_INPUT_TOUCHSCREEN_MMI nova_0flash_mmi-objs += nt36xxx_mmi_class.o diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c index eaa94a0f9d20..723d59cde8df 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c @@ -214,7 +214,12 @@ int nvt_mcu_pen_detect_set(uint8_t pen_detect); #ifndef CONFIG_INPUT_TOUCHSCREEN_MMI #if (((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))) || defined(NVT_CONFIG_DRM_PANEL)) #if defined(CONFIG_DRM) +#ifdef NVT_DRM_PANEL_EVENT_NOTIFICATIONS +static void nvt_drm_notifier_callback(enum panel_event_notifier_tag tag, + struct panel_event_notification *notification, void *client_data); +#else static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data); +#endif #ifdef LCM_FAST_LIGHTUP static struct work_struct ts_resume_work; static void nova_resume_work_func(struct work_struct *work); @@ -3148,6 +3153,18 @@ static int32_t nvt_ts_probe(struct spi_device *client) #ifndef CONFIG_INPUT_TOUCHSCREEN_MMI #if (((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))) || defined(NVT_CONFIG_DRM_PANEL)) #if defined(CONFIG_DRM) +#ifdef NVT_DRM_PANEL_EVENT_NOTIFICATIONS + if (active_panel){ + ts->notifier_cookie = panel_event_notifier_register(PANEL_EVENT_NOTIFICATION_PRIMARY, + PANEL_EVENT_NOTIFIER_CLIENT_PRIMARY_TOUCH, active_panel, + &nvt_drm_notifier_callback, ts); + } + if (!ts->notifier_cookie) { + NVT_ERR("Failed to register for panel events\n"); + goto err_register_drm_notif_failed; + } + NVT_LOG("registered for panel notifications panel\n"); +#else ts->drm_notif.notifier_call = nvt_drm_notifier_callback; if (active_panel && drm_panel_notifier_register(active_panel, @@ -3156,6 +3173,7 @@ static int32_t nvt_ts_probe(struct spi_device *client) goto err_register_drm_notif_failed; } #endif +#endif #else //vension code < 5.4.0 #if defined(CONFIG_FB) #ifdef _MSM_DRM_NOTIFY_H_ @@ -3217,14 +3235,19 @@ err_create_touchscreen_class_failed: #if defined(CONFIG_INPUT_TOUCHSCREEN_MMI) nvt_mmi_init(ts, false); #endif +err_register_drm_notif_failed: #ifndef CONFIG_INPUT_TOUCHSCREEN_MMI #if (((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))) || defined(NVT_CONFIG_DRM_PANEL)) #if defined(CONFIG_DRM) if (active_panel) { +#ifdef NVT_DRM_PANEL_EVENT_NOTIFICATIONS + if (ts->notifier_cookie) + panel_event_notifier_unregister(ts->notifier_cookie); +#else if (drm_panel_notifier_unregister(active_panel, &ts->drm_notif)) NVT_ERR("Error occurred while unregistering drm_notifier.\n"); +#endif } -err_register_drm_notif_failed: #endif #else //vension code < 5.4.0 #if defined(CONFIG_FB) @@ -3360,8 +3383,13 @@ static int32_t nvt_ts_remove(struct spi_device *client) #if (((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))) || defined(NVT_CONFIG_DRM_PANEL)) #if defined(CONFIG_DRM) if (active_panel) { +#ifdef NVT_DRM_PANEL_EVENT_NOTIFICATIONS + if (ts->notifier_cookie) + panel_event_notifier_unregister(ts->notifier_cookie); +#else drm_panel_notifier_unregister(active_panel, &ts->drm_notif); NVT_ERR("Error occurred while unregistering drm_notifier.\n"); +#endif } #endif #else //vension code < 5.4.0 @@ -3467,8 +3495,13 @@ static void nvt_ts_shutdown(struct spi_device *client) #if (((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0))) || defined(NVT_CONFIG_DRM_PANEL)) #if defined(CONFIG_DRM) if (active_panel) { +#ifdef NVT_DRM_PANEL_EVENT_NOTIFICATIONS + if (ts->notifier_cookie) + panel_event_notifier_unregister(ts->notifier_cookie); +#else drm_panel_notifier_unregister(active_panel, &ts->drm_notif); NVT_ERR("Error occurred while unregistering drm_notifier.\n"); +#endif } #endif #else //vension code < 5.4.0 @@ -3763,7 +3796,68 @@ static void nova_resume_work_func(struct work_struct *work) nvt_ts_resume(&ts->client->dev); } #endif //end LCM_FAST_LIGHTUP +#ifdef NVT_DRM_PANEL_EVENT_NOTIFICATIONS +static void nvt_drm_notifier_callback(enum panel_event_notifier_tag tag, + struct panel_event_notification *notification, void *client_data) +{ + if (!notification) { + pr_err("Invalid notification\n"); + return; + } + NVT_LOG("Notification type:%d, early_trigger:%d", + notification->notif_type, + notification->notif_data.early_trigger); + switch (notification->notif_type) { + case DRM_PANEL_EVENT_UNBLANK: + if (!notification->notif_data.early_trigger) { +#ifdef LCM_FAST_LIGHTUP + if (nvt_fwu_wq) { + queue_work(nvt_fwu_wq, &ts_resume_work); + NVT_LOG("LCM_FAST_LIGHTUP, queue_work\n"); + } else { + NVT_LOG("nvt_fwu_wq null"); + nvt_ts_resume(&ts->client->dev); + } +#else + nvt_ts_resume(&ts->client->dev); +#endif //LCM_FAST_LIGHTUP + } + + break; + + case DRM_PANEL_EVENT_BLANK: + if (notification->notif_data.early_trigger) { + NVT_LOG("event=DRM_PANEL_EVENT_BLANK"); + nvt_ts_suspend(&ts->client->dev); +#if defined(NVT_SENSOR_EN) && (defined(NVT_SET_TOUCH_STATE) || defined(NVT_CONFIG_PANEL_NOTIFICATIONS)) + if (ts->should_enable_gesture) { + NVT_LOG("double tap gesture suspend\n"); + touch_set_state(TOUCH_LOW_POWER_STATE, TOUCH_PANEL_IDX_PRIMARY); + } else { + touch_set_state(TOUCH_DEEP_SLEEP_STATE, TOUCH_PANEL_IDX_PRIMARY); + } +#endif + } + break; + + case DRM_PANEL_EVENT_BLANK_LP: + NVT_LOG("received lp event\n"); + break; + + case DRM_PANEL_EVENT_FPS_CHANGE: + NVT_LOG("Received fps change old fps:%d new fps:%d\n", + notification->notif_data.old_fps, + notification->notif_data.new_fps); + break; + + default: + NVT_LOG("notification serviced :%d\n", + notification->notif_type); + break; + } +} +#else static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data) { struct msm_drm_notifier *evdata = data; @@ -3816,6 +3910,8 @@ static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long return 0; } #endif +#endif + #else //vension code < 5.4.0 #ifdef NVT_CONFIG_PANEL_NOTIFICATIONS static int nvt_panel_notifier_callback(struct notifier_block *self, unsigned long event, void *data) diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h index 63378cd88bd1..e74aa13d58b3 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h @@ -39,7 +39,12 @@ #ifdef NOVATECH_PEN_NOTIFIER #include #endif - +#ifdef NVT_CONFIG_DRM_PANEL +#if IS_ENABLED(CONFIG_QCOM_PANEL_EVENT_NOTIFIER) +#define NVT_DRM_PANEL_EVENT_NOTIFICATIONS +#include +#endif +#endif #ifdef CONFIG_HAS_EARLYSUSPEND #include #endif @@ -256,6 +261,9 @@ struct nvt_ts_data { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)) #if defined(CONFIG_DRM) struct notifier_block drm_notif; +#ifdef NVT_DRM_PANEL_EVENT_NOTIFICATIONS + void* notifier_cookie; +#endif #endif #else //vension code < 5.4.0 #if defined(CONFIG_FB)