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 <hujing3@lenovo.com>
Reviewed-on: https://gerrit.mot.com/2409485
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Yeqing Wang <wangyq13@motorola.com>
Reviewed-by: Wei Deng <dengwei1@motorola.com>
Reviewed-by: Wang Wang <wangwang1@lenovo.com>
Submit-Approved: Jira Key
This commit is contained in:
hujing3 2022-10-20 16:03:39 +08:00 • committed by Jing Hu
commit 44bd655a67
6 changed files with 75 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -195,6 +195,8 @@
#define FTS_CHIP_NAME "ft8726"
#endif
#define FTS_PRIMARY_NAME "primary"
/******************* Enables *********************/
/*********** 1 to enable, 0 to disable ***********/

View file

@ -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;

View file

@ -73,6 +73,9 @@
#ifdef FOCALTECH_CONFIG_PANEL_NOTIFICATIONS
#include <linux/panel_notifier.h>
#endif
#ifdef FTS_LAST_TIME_EN
#include <linux/ktime.h>
#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

View file

@ -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;