From 44bd655a678ce33e2447336c612d04e80f2dfb3d Mon Sep 17 00:00:00 2001 From: hujing3 Date: Thu, 20 Oct 2022 16:03:39 +0800 Subject: [PATCH] focaltech_0flash_v2_mmi: add touch point timestamp focaltech_0flash_v2_mmi: add touch point timestamp to support backtap improvement Change-Id: Idc205fdb69de0db0b47e0002f2b6776de823f139 Signed-off-by: hujing3 Reviewed-on: https://gerrit.mot.com/2409485 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Yeqing Wang Reviewed-by: Wei Deng Reviewed-by: Wang Wang Submit-Approved: Jira Key --- .../focaltech_0flash_v2_mmi/Android.mk | 4 +++ .../focaltech_0flash_v2_mmi/Kbuild | 5 ++++ .../focaltech_config.h | 2 ++ .../focaltech_0flash_v2_mmi/focaltech_core.c | 27 +++++++++++++++++ .../focaltech_0flash_v2_mmi/focaltech_core.h | 7 +++++ .../focaltech_ex_fun.c | 30 +++++++++++++++++++ 6 files changed, 75 insertions(+) diff --git a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Android.mk b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Android.mk index e10443c7c046..981183028167 100644 --- a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Android.mk +++ b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Android.mk @@ -31,6 +31,10 @@ ifneq ($(FOCALTECH_PINCTRL_ENABLE),) KERNEL_CFLAGS += CONFIG_INPUT_FOCALTECH_PINCTRL_EN=y endif +ifeq ($(TOUCHSCREEN_LAST_TIME),true) + KERNEL_CFLAGS += CONFIG_FOCALTECH_LAST_TIME=y +endif + include $(CLEAR_VARS) LOCAL_MODULE := focaltech_0flash_v2_mmi.ko LOCAL_MODULE_TAGS := optional diff --git a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Kbuild b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Kbuild index e7937ae3dafa..93714d15bba8 100644 --- a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Kbuild +++ b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/Kbuild @@ -42,4 +42,9 @@ endif ifneq ($(filter m y,$(CONFIG_INPUT_FOCALTECH_PINCTRL_EN)),) EXTRA_CFLAGS += -DFOCALTECH_PINCTRL_EN endif + +ifneq ($(filter m y,$(CONFIG_FOCALTECH_LAST_TIME)),) + EXTRA_CFLAGS += -DFTS_LAST_TIME_EN +endif + KBUILD_EXTRA_SYMBOLS += $(CURDIR)/../../kernel/msm-$(MODULE_KERNEL_VERSION)/Module.symvers diff --git a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_config.h b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_config.h index 4d61613c758f..452bee2f877d 100644 --- a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_config.h +++ b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_config.h @@ -195,6 +195,8 @@ #define FTS_CHIP_NAME "ft8726" #endif +#define FTS_PRIMARY_NAME "primary" + /******************* Enables *********************/ /*********** 1 to enable, 0 to disable ***********/ diff --git a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.c b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.c index 39bcc71cf083..d09765ad9bed 100644 --- a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.c +++ b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.c @@ -80,6 +80,10 @@ enum touch_state { *****************************************************************************/ struct fts_ts_data *fts_data; +#ifdef FTS_LAST_TIME_EN +static bool time_flag = 1; +#endif + /***************************************************************************** * Static function prototypes *****************************************************************************/ @@ -502,6 +506,9 @@ static int fts_input_report_b(struct fts_ts_data *ts_data, struct ts_event *even u32 max_touch_num = ts_data->pdata->max_touch_number; bool touch_event_coordinate = false; struct input_dev *input_dev = ts_data->input_dev; +#ifdef FTS_LAST_TIME_EN + bool b_touch_down = 0; +#endif for (i = 0; i < ts_data->touch_event_num; i++) { if (fts_input_report_key(ts_data, &events[i]) == 0) { @@ -522,6 +529,12 @@ static int fts_input_report_b(struct fts_ts_data *ts_data, struct ts_event *even touch_down_point_cur |= (1 << events[i].id); touch_point_pre |= (1 << events[i].id); +#ifdef FTS_LAST_TIME_EN + if (FTS_TOUCH_DOWN == events[i].flag) { + b_touch_down = 1; + } +#endif + if ((ts_data->log_level >= 2) || ((1 == ts_data->log_level) && (FTS_TOUCH_DOWN == events[i].flag))) { FTS_DEBUG("[B]P%d(%d, %d)[p:%d,tm:%d] DOWN!", @@ -552,8 +565,22 @@ static int fts_input_report_b(struct fts_ts_data *ts_data, struct ts_event *even if (ts_data->touch_points && (ts_data->log_level >= 1)) FTS_DEBUG("[B]Points All Up!"); input_report_key(input_dev, BTN_TOUCH, 0); +#ifdef FTS_LAST_TIME_EN + //enable time_flag when touch All Up for next touch session + time_flag = 1; +#endif } +#ifdef FTS_LAST_TIME_EN + //check b_touch_down && time_flag to get boot time only once in one touch session, + //to avoid impact touch performance for multi touch & moving cases + if (b_touch_down && time_flag) { + ts_data->last_event_time = ktime_get_boottime(); + time_flag = 0; + //FTS_DEBUG("time_flag, save last_event_time when touch Down"); + } +#endif + ts_data->touch_points = touch_down_point_cur; input_sync(input_dev); return 0; diff --git a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.h b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.h index 7acaed121cf2..487411730570 100644 --- a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.h +++ b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_core.h @@ -73,6 +73,9 @@ #ifdef FOCALTECH_CONFIG_PANEL_NOTIFICATIONS #include #endif +#ifdef FTS_LAST_TIME_EN +#include +#endif /***************************************************************************** * Private constant and macro definitions using #define @@ -283,6 +286,10 @@ struct fts_ts_data { uint8_t usb_connected; struct notifier_block charger_notif; #endif + +#ifdef FTS_LAST_TIME_EN + ktime_t last_event_time; +#endif }; #ifdef FTS_SET_TOUCH_STATE diff --git a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c index 84138f7c9dfe..3f241bd0403d 100644 --- a/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c +++ b/drivers/input/touchscreen/focaltech_0flash_v2_mmi/focaltech_ex_fun.c @@ -1698,11 +1698,34 @@ static ssize_t ic_ver_show(struct device *dev, return fts_ic_ver_show(dev, attr, buf); } +#ifdef FTS_LAST_TIME_EN +static ssize_t timestamp_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fts_ts_data *ts_data = dev_get_drvdata(dev); + struct input_dev *input_dev = ts_data->input_dev; + + ktime_t last_ktime; + struct timespec64 last_ts; + + mutex_lock(&input_dev->mutex); + last_ktime = ts_data->last_event_time; + ts_data->last_event_time = 0; + mutex_unlock(&input_dev->mutex); + + last_ts = ktime_to_timespec64(last_ktime); + return scnprintf(buf, PAGE_SIZE, "%lld.%ld\n", last_ts.tv_sec, last_ts.tv_nsec); +} +#endif + static struct device_attribute touchscreen_attributes[] = { __ATTR_RO(path), __ATTR_RO(vendor), __ATTR_RO(ic_ver), __ATTR_RO(panel_supplier), +#ifdef FTS_LAST_TIME_EN + __ATTR_RO(timestamp), +#endif __ATTR_NULL }; @@ -1733,9 +1756,16 @@ static int fts_sysfs_class(void *_data, bool create) return error; } +#ifdef FTS_LAST_TIME_EN + ts_class_dev = device_create(touchscreen_class, NULL, + MKDEV(INPUT_MAJOR, minor), + data, FTS_PRIMARY_NAME); +#else ts_class_dev = device_create(touchscreen_class, NULL, MKDEV(INPUT_MAJOR, minor), data, FTS_CHIP_NAME); +#endif + if (IS_ERR(ts_class_dev)) { error = PTR_ERR(ts_class_dev); ts_class_dev = NULL;