tundra: input touch add touch time sysfs

Driver will log the last touch down event timestamp and expose it via
sysfs. This feature utilized by sensors to mitigate false detection of
back tap gestures.

Change-Id: I2907acdf1a560a6ca923b9fc20243fef642d7b90
Signed-off-by: dengwei1 <dengwei1@motorola.com>
Reviewed-on: https://gerrit.mot.com/2241177
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Wang Wang <wangwang1@lenovo.com>
Submit-Approved: Jira Key
This commit is contained in:
dengwei1 2022-04-13 15:57:49 +08:00 • committed by Wei Deng
commit 10199d3dbd
5 changed files with 67 additions and 1 deletions

View file

@ -33,6 +33,10 @@ ifeq ($(TOUCHSCREEN_FOD),true)
KBUILD_OPTIONS += CONFIG_GTP_FOD=y
endif
ifeq ($(TOUCHSCREEN_LAST_TIME),true)
KBUILD_OPTIONS += CONFIG_GTP_LAST_TIME=y
endif
include $(CLEAR_VARS)
LOCAL_MODULE := goodix_brl_mmi.ko
LOCAL_MODULE_TAGS := optional

View file

@ -50,6 +50,10 @@ ifneq ($(filter m y,$(CONFIG_TARGET_BUILD_FACROTY)),)
EXTRA_CFLAGS += -DGTP_SAVE_IN_CSV
endif
ifneq ($(filter m y,$(CONFIG_GTP_LAST_TIME)),)
EXTRA_CFLAGS += -DCONFIG_GTP_LAST_TIME
endif
ifneq ($(filter m y,$(CONFIG_INPUT_TOUCHSCREEN_MMI)),)
EXTRA_CFLAGS += -DCONFIG_INPUT_TOUCHSCREEN_MMI
goodix_brl_mmi-objs += goodix_ts_mmi.o

View file

@ -1182,8 +1182,13 @@ static void goodix_ts_report_finger(struct input_dev *dev,
{
unsigned int touch_num = touch_data->touch_num;
int i;
#ifdef CONFIG_GTP_FOD
#ifdef CONFIG_GTP_LAST_TIME
static uint8_t touchdown[GOODIX_MAX_TOUCH];
#endif
#if defined (CONFIG_GTP_FOD) || defined (CONFIG_GTP_LAST_TIME)
struct goodix_ts_core *core_data = goodix_modules.core_data;
#endif
#ifdef CONFIG_GTP_FOD
struct goodix_ts_event *ts_event = &goodix_modules.core_data ->ts_event;
#endif
mutex_lock(&dev->mutex);
@ -1193,6 +1198,13 @@ static void goodix_ts_report_finger(struct input_dev *dev,
ts_debug("report: id %d, x %d, y %d, w %d", i,
touch_data->coords[i].x, touch_data->coords[i].y,
touch_data->coords[i].w);
#ifdef CONFIG_GTP_LAST_TIME
if (touchdown[i] == 0) {
core_data->last_event_time = ktime_get();
ts_debug("TOUCH: [%d] logged timestamp\n", i);
touchdown[i] = 1;
}
#endif
input_mt_slot(dev, i);
input_mt_report_slot_state(dev, MT_TOOL_FINGER, true);
input_report_abs(dev, ABS_MT_POSITION_X,
@ -1202,6 +1214,12 @@ static void goodix_ts_report_finger(struct input_dev *dev,
input_report_abs(dev, ABS_MT_TOUCH_MAJOR,
touch_data->coords[i].w);
} else {
#ifdef CONFIG_GTP_LAST_TIME
if (touchdown[i] == 1) {
ts_debug("TOUCH: [%d] release\n", i);
touchdown[i] = 0;
}
#endif
input_mt_slot(dev, i);
input_mt_report_slot_state(dev, MT_TOOL_FINGER, false);
}

View file

@ -27,6 +27,9 @@
#ifdef CONFIG_GTP_ENABLE_PM_QOS
#include <linux/pm_qos.h>
#endif
#ifdef CONFIG_GTP_LAST_TIME
#include <linux/ktime.h>
#endif
#define GOODIX_CORE_DRIVER_NAME "goodix_ts"
#define GOODIX_PEN_DRIVER_NAME "goodix_ts,pen"
@ -539,6 +542,9 @@ struct goodix_ts_core {
unsigned char gesture_type;
int zerotap_data[1];
int fod_enable;
#endif
#ifdef CONFIG_GTP_LAST_TIME
ktime_t last_event_time;
#endif
atomic_t pm_resume;
wait_queue_head_t pm_wq;

View file

@ -43,6 +43,10 @@ static ssize_t goodix_ts_stylus_mode_show(struct device *dev,
struct device_attribute *attr, char *buf);
static ssize_t goodix_ts_sensitivity_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size);
#ifdef CONFIG_GTP_LAST_TIME
static ssize_t goodix_ts_timestamp_show(struct device *dev,
struct device_attribute *attr, char *buf);
#endif
static DEVICE_ATTR(edge, (S_IRUGO | S_IWUSR | S_IWGRP),
goodix_ts_edge_show, goodix_ts_edge_store);
@ -52,6 +56,9 @@ static DEVICE_ATTR(stylus_mode, (S_IRUGO | S_IWUSR | S_IWGRP),
goodix_ts_stylus_mode_show, goodix_ts_stylus_mode_store);
static DEVICE_ATTR(sensitivity, (S_IRUGO | S_IWUSR | S_IWGRP),
NULL, goodix_ts_sensitivity_store);
#ifdef CONFIG_GTP_LAST_TIME
static DEVICE_ATTR(timestamp, S_IRUGO, goodix_ts_timestamp_show, NULL);
#endif
/* hal settings */
#define ROTATE_0 0
@ -98,6 +105,10 @@ static int goodix_ts_mmi_extend_attribute_group(struct device *dev, struct attri
if (core_data->board_data.sensitivity_ctrl)
ADD_ATTR(sensitivity);
#ifdef CONFIG_GTP_LAST_TIME
ADD_ATTR(timestamp);
#endif
if (idx) {
ext_attributes[idx] = NULL;
*group = &ext_attr_group;
@ -577,6 +588,29 @@ static ssize_t goodix_ts_edge_show(struct device *dev,
core_data->set_mode.edge_mode[1], core_data->set_mode.edge_mode[0]);
}
#ifdef CONFIG_GTP_LAST_TIME
static ssize_t goodix_ts_timestamp_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct platform_device *pdev;
struct goodix_ts_core *core_data;
ktime_t last_ktime;
struct timespec64 last_ts;
dev = MMI_DEV_TO_TS_DEV(dev);
GET_GOODIX_DATA(dev);
mutex_lock(&core_data->mode_lock);
last_ktime = core_data->last_event_time;
core_data->last_event_time = 0;
mutex_unlock(&core_data->mode_lock);
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 int goodix_ts_mmi_methods_get_vendor(struct device *dev, void *cdata) {
return scnprintf(TO_CHARP(cdata), TS_MMI_MAX_VENDOR_LEN, "%s", "goodix");
}