diff --git a/drivers/input/touchscreen/nova_0flash_mmi/Android.mk b/drivers/input/touchscreen/nova_0flash_mmi/Android.mk index e0c4cafc1140..0322a8d0ae9a 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 +ifeq ($(TOUCHSCREEN_LAST_TIME),true) + KERNEL_CFLAGS += CONFIG_NOVA_TOUCH_LAST_TIME=y +endif + ifneq ($(MOTO_PANEL_CHECK_TOUCH_STATE),) KERNEL_CFLAGS += CONFIG_INPUT_NOVA_0FLASH_MMI_NOTIFY_TOUCH_STATE=y endif diff --git a/drivers/input/touchscreen/nova_0flash_mmi/Kbuild b/drivers/input/touchscreen/nova_0flash_mmi/Kbuild index 72ba0933f9ee..2d615d652a06 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/Kbuild +++ b/drivers/input/touchscreen/nova_0flash_mmi/Kbuild @@ -13,6 +13,11 @@ endif ifneq ($(filter m y,$(CONFIG_INPUT_NOVA_0FLASH_MMI_NOTIFY_TOUCH_STATE)),) EXTRA_CFLAGS += -DNVT_SET_TOUCH_STATE endif + +ifneq ($(filter m y,$(CONFIG_NOVA_TOUCH_LAST_TIME)),) + EXTRA_CFLAGS += -DNVT_TOUCH_LAST_TIME +endif + ifneq ($(filter m y,$(CONFIG_INPUT_NOVA_PANEL_NOTIFICATIONS)),) EXTRA_CFLAGS += -DNVT_CONFIG_PANEL_NOTIFICATIONS endif diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c index 97ab3e8e0f00..a88099a30d3e 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.c @@ -292,6 +292,10 @@ const struct mtk_chip_config spi_ctrdata = { }; #endif +#ifdef NVT_TOUCH_LAST_TIME +static bool time_flag = 1; +#endif + /******************************************************* Description: Novatek touchscreen irq enable/disable function. @@ -1890,6 +1894,24 @@ static irqreturn_t nvt_ts_work_func(int irq, void *data) } input_report_key(ts->input_dev, BTN_TOUCH, (finger_cnt > 0)); + +#ifdef NVT_TOUCH_LAST_TIME + if (finger_cnt > 0) { + //touch down/moving + if(time_flag) { + //check time_flag to get boot time only once in one touch session, + //to avoid impact touch performance for multi touch & moving cases + ts->last_event_time = ktime_get_boottime(); + time_flag = 0; + NVT_DBG("set last_event_time\n"); + } + } else { + //touch UP, enable time flag for next touch + time_flag = 1; + NVT_DBG("finger_cnt 0, reset time_flag\n"); + } +#endif + #else /* MT_PROTOCOL_B */ if (finger_cnt == 0) { input_report_key(ts->input_dev, BTN_TOUCH, 0); @@ -2444,10 +2466,28 @@ static int nvt_extend_attribute_group(struct device *dev, struct attribute_group return 0; } +#ifdef NVT_TOUCH_LAST_TIME +static ssize_t timestamp_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + ktime_t last_ktime; + struct timespec64 last_ts; + + last_ktime = ts->last_event_time; + ts->last_event_time = 0; + + 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), +#ifdef NVT_TOUCH_LAST_TIME + __ATTR_RO(timestamp), +#endif #ifdef PALM_GESTURE __ATTR(palm_settings, S_IRUGO | S_IWUSR | S_IWGRP, nvt_palm_settings_show, nvt_palm_settings_store), #endif @@ -2480,7 +2520,7 @@ int32_t nvt_fw_class_init(bool create) static int minor; if (create) { -#if defined (PALM_GESTURE) || defined (EDGE_SUPPRESSION) +#if defined (PALM_GESTURE) || defined (EDGE_SUPPRESSION) || defined(NVT_TOUCH_LAST_TIME) ret = alloc_chrdev_region(&devno, 0, 1, NVT_PRIMARY_NAME); #else ret = alloc_chrdev_region(&devno, 0, 1, NVT_SPI_NAME); @@ -2500,7 +2540,7 @@ int32_t nvt_fw_class_init(bool create) ts_class_dev = device_create(touchscreen_class, NULL, devno, -#if defined (PALM_GESTURE) || defined (EDGE_SUPPRESSION) +#if defined (PALM_GESTURE) || defined (EDGE_SUPPRESSION) || defined(NVT_TOUCH_LAST_TIME) ts, NVT_PRIMARY_NAME); #else ts, NVT_SPI_NAME); @@ -2520,7 +2560,7 @@ int32_t nvt_fw_class_init(bool create) if (error) goto device_destroy; else -#if defined (PALM_GESTURE) || defined (EDGE_SUPPRESSION) +#if defined (PALM_GESTURE) || defined (EDGE_SUPPRESSION) || defined(NVT_TOUCH_LAST_TIME) NVT_LOG("create /sys/class/touchscreen/%s Succeeded!\n", NVT_PRIMARY_NAME); #else NVT_LOG("create /sys/class/touchscreen/%s Succeeded!\n", NVT_SPI_NAME); diff --git a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h index 1d69a24bf375..219ae616b541 100644 --- a/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h +++ b/drivers/input/touchscreen/nova_0flash_mmi/nt36xxx.h @@ -25,6 +25,9 @@ #include #include #include +#ifdef NVT_TOUCH_LAST_TIME +#include +#endif #ifdef NVT_SENSOR_EN #include @@ -223,6 +226,9 @@ struct nvt_ts_data { bool gesture_enabled; bool wakeable; #endif +#ifdef NVT_TOUCH_LAST_TIME + ktime_t last_event_time; +#endif #ifdef NOVATECH_PEN_NOTIFIER bool fw_ready_flag; int nvt_pen_detect_flag;