Support goodix touch under water detection

TP:
Support goodix touch under water detection.

Change-Id: I8552676ca8b270595c8a99a94efe939ddb8e4802
Signed-off-by: Wenge Zhu <zhuwg1@motorola.com>
Reviewed-on: https://gerrit.mot.com/2451133
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jun Weng <wengjun1@motorola.com>
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Wenge Zhu authored and zhuwg1 committed 2022-12-06 20:02:23 -06:00
1 parent 31a13f0565
commit 59ccefeb4b
5 files changed
+89 -3

No files matched your search

@@ -15,6 +15,7 @@
* *
*/ */
#include "goodix_ts_core.h" #include "goodix_ts_core.h"
#include "goodix_ts_mmi.h"
/* berlin_A SPI mode setting */ /* berlin_A SPI mode setting */
#define GOODIX_SPI_MODE_REG 0xC900 #define GOODIX_SPI_MODE_REG 0xC900
@@ -1101,11 +1102,22 @@ static int goodix_touch_handler(struct goodix_ts_core *cd,
int fp_flags = 0; int fp_flags = 0;
static int pre_flags = 0; static int pre_flags = 0;
#endif #endif
int underwater_flag = 0;
/* clean event buffer */ /* clean event buffer */
memset(ts_event, 0, sizeof(*ts_event)); memset(ts_event, 0, sizeof(*ts_event));
/* copy pre-data to buffer */ /* copy pre-data to buffer */
memcpy(buffer, pre_buf, pre_buf_len); memcpy(buffer, pre_buf, pre_buf_len);
if (cd->set_mode.liquid_detection) {
underwater_flag = buffer[2] & GOODIX_GESTURE_UNDER_WATER;
if (cd->liquid_status != underwater_flag) {
cd->liquid_status = underwater_flag;
/* call class method */
cd->imports->report_liquid_detection_status(cd->bus->dev, cd->liquid_status? 1:0);
ts_info("under water flag changed to 0x%x\n", cd->liquid_status);
}
}
touch_num = buffer[2] & 0x0F; touch_num = buffer[2] & 0x0F;
if (touch_num > GOODIX_MAX_TOUCH) { if (touch_num > GOODIX_MAX_TOUCH) {
@@ -1244,6 +1256,7 @@ static int brl_event_handler(struct goodix_ts_core *cd,
ts_debug("unsupported request code 0x%x", pre_buf[2]); ts_debug("unsupported request code 0x%x", pre_buf[2]);
} else if (event_status & GOODIX_GESTURE_EVENT) { } else if (event_status & GOODIX_GESTURE_EVENT) {
ts_event->event_type = EVENT_GESTURE; ts_event->event_type = EVENT_GESTURE;
ts_event->gesture_report_info = pre_buf[2];
ts_event->gesture_type = pre_buf[4]; ts_event->gesture_type = pre_buf[4];
#ifdef CONFIG_GTP_FOD #ifdef CONFIG_GTP_FOD
memcpy(ts_event->gesture_data, &pre_buf[8], memcpy(ts_event->gesture_data, &pre_buf[8],
@@ -63,6 +63,7 @@
#define GOODIX_GESTURE_SINGLE_TAP 0x4C #define GOODIX_GESTURE_SINGLE_TAP 0x4C
#define GOODIX_GESTURE_FOD_DOWN 0x46 #define GOODIX_GESTURE_FOD_DOWN 0x46
#define GOODIX_GESTURE_FOD_UP 0x55 #define GOODIX_GESTURE_FOD_UP 0x55
#define GOODIX_GESTURE_UNDER_WATER 0x20
enum GOODIX_GESTURE_TYP { enum GOODIX_GESTURE_TYP {
GESTURE_SINGLE_TAP = (1 << 0), GESTURE_SINGLE_TAP = (1 << 0),
@@ -407,6 +408,7 @@ struct goodix_ts_event {
enum ts_event_type event_type; enum ts_event_type event_type;
u8 request_code; /* represent the request type */ u8 request_code; /* represent the request type */
u8 gesture_type; u8 gesture_type;
u8 gesture_report_info;
struct goodix_touch_data touch_data; struct goodix_touch_data touch_data;
struct goodix_pen_data pen_data; struct goodix_pen_data pen_data;
#ifdef CONFIG_GTP_FOD #ifdef CONFIG_GTP_FOD
@@ -488,6 +490,7 @@ struct goodix_mode_info {
int sample; int sample;
int report_rate_mode; int report_rate_mode;
int edge_mode[2]; int edge_mode[2];
int liquid_detection;
}; };
struct goodix_ts_core { struct goodix_ts_core {
@@ -516,6 +519,7 @@ struct goodix_ts_core {
int power_on; int power_on;
int irq; int irq;
size_t irq_trig_cnt; size_t irq_trig_cnt;
int liquid_status;
atomic_t irq_enabled; atomic_t irq_enabled;
atomic_t suspended; atomic_t suspended;
@@ -554,6 +558,7 @@ struct goodix_ts_core {
#ifdef CONFIG_GTP_LAST_TIME #ifdef CONFIG_GTP_LAST_TIME
ktime_t last_event_time; ktime_t last_event_time;
#endif #endif
unsigned short gesture_cmd;
atomic_t pm_resume; atomic_t pm_resume;
wait_queue_head_t pm_wq; wait_queue_head_t pm_wq;
}; };
@@ -372,6 +372,7 @@ static int gsx_gesture_ist(struct goodix_ts_core *cd,
static unsigned long start = 0; static unsigned long start = 0;
int fod_down_interval = 0; int fod_down_interval = 0;
int fod_down = cd->zerotap_data[0]; int fod_down = cd->zerotap_data[0];
int underwater_flag = 0;
#endif #endif
if (atomic_read(&cd->suspended) == 0 || cd->gesture_type == 0) if (atomic_read(&cd->suspended) == 0 || cd->gesture_type == 0)
return EVT_CONTINUE; return EVT_CONTINUE;
@@ -397,8 +398,19 @@ static int gsx_gesture_ist(struct goodix_ts_core *cd,
gs_event.event_type); gs_event.event_type);
goto re_send_ges_cmd; goto re_send_ges_cmd;
} }
ts_info("got gesture type 0x%x", gs_event.gesture_type); ts_debug("got gesture type 0x%x", gs_event.gesture_type);
#if defined(CONFIG_INPUT_TOUCHSCREEN_MMI) #if defined(CONFIG_INPUT_TOUCHSCREEN_MMI)
if (cd->set_mode.liquid_detection) {
underwater_flag = gs_event.gesture_report_info & GOODIX_GESTURE_UNDER_WATER;
if ( cd->liquid_status != underwater_flag) {
cd->liquid_status = underwater_flag;
/* call class method */
cd->imports->report_liquid_detection_status(cd->bus->dev, cd->liquid_status? 1:0);
ts_info("under water flag changed to: 0x%x\n", cd->liquid_status);
goto gesture_ist_exit;
}
}
mmi_event.evcode =0; mmi_event.evcode =0;
if ( cd->imports && cd->imports->report_gesture) { if ( cd->imports && cd->imports->report_gesture) {
if(cd->gesture_type & GESTURE_SINGLE_TAP && gs_event.gesture_type == GOODIX_GESTURE_SINGLE_TAP) { if(cd->gesture_type & GESTURE_SINGLE_TAP && gs_event.gesture_type == GOODIX_GESTURE_SINGLE_TAP) {
@@ -525,6 +537,9 @@ static int gsx_gesture_ist(struct goodix_ts_core *cd,
re_send_ges_cmd: re_send_ges_cmd:
#if defined(PRODUCT_MIAMI) #if defined(PRODUCT_MIAMI)
if (hw_ops->gesture(cd, 0x80)) if (hw_ops->gesture(cd, 0x80))
#elif defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
if (goodix_ts_send_cmd(cd, ENTER_GESTURE_MODE_CMD, 6, (cd->gesture_cmd) >> 8,
cd->gesture_cmd & 0xFF) < 0)
#else #else
if (hw_ops->gesture(cd, 0)) if (hw_ops->gesture(cd, 0))
#endif #endif
@@ -12,7 +12,6 @@
*/ */
#include "goodix_ts_mmi.h" #include "goodix_ts_mmi.h"
#include "goodix_ts_core.h"
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/input/mt.h> #include <linux/input/mt.h>
#include "goodix_ts_config.h" #include "goodix_ts_config.h"
@@ -132,7 +131,7 @@ static int goodix_ts_mmi_extend_attribute_group(struct device *dev, struct attri
return 0; return 0;
} }
static int goodix_ts_send_cmd(struct goodix_ts_core *core_data, int goodix_ts_send_cmd(struct goodix_ts_core *core_data,
u8 cmd, u8 len, u8 subCmd, u8 subCmd2) u8 cmd, u8 len, u8 subCmd, u8 subCmd2)
{ {
int ret = 0; int ret = 0;
@@ -957,6 +956,7 @@ static int goodix_ts_mmi_panel_state(struct device *dev,
if (ret < 0) { if (ret < 0) {
ts_err("Failed to send enable gesture mode\n"); ts_err("Failed to send enable gesture mode\n");
} }
core_data->gesture_cmd = gesture_cmd;
ts_info("Send enable gesture mode 0x%04x, 0x%02x\n", gesture_cmd, gesture_type); ts_info("Send enable gesture mode 0x%04x, 0x%02x\n", gesture_cmd, gesture_type);
#else #else
#if defined(PRODUCT_MIAMI) #if defined(PRODUCT_MIAMI)
@@ -1091,6 +1091,15 @@ static int goodix_ts_mmi_post_resume(struct device *dev) {
core_data->get_mode.edge_mode[1], core_data->get_mode.edge_mode[0]); core_data->get_mode.edge_mode[1], core_data->get_mode.edge_mode[0]);
} }
} }
if (core_data->get_mode.liquid_detection) {
ret = goodix_ts_send_cmd(core_data, LIQUID_DETECTION_SWITCH_CMD, 5,
core_data->get_mode.liquid_detection, 0x00);
if (!ret) {
core_data->set_mode.liquid_detection = core_data->get_mode.liquid_detection;
msleep(20);
ts_info("Success to %d liquid detection mode\n", core_data->get_mode.liquid_detection);
}
}
mutex_unlock(&core_data->mode_lock); mutex_unlock(&core_data->mode_lock);
#ifdef CONFIG_GTP_FOD #ifdef CONFIG_GTP_FOD
if(core_data->zerotap_data[0]) { if(core_data->zerotap_data[0]) {
@@ -1155,6 +1164,45 @@ static int goodix_ts_mmi_update_fps_mode(struct device *dev, int mode) {
} }
#endif #endif
static int goodix_ts_mmi_update_liquid_detect_mode(struct device *dev, int mode) {
int ret = 0;
struct platform_device *pdev;
struct goodix_ts_core *core_data;
GET_GOODIX_DATA(dev);
mutex_lock(&core_data->mode_lock);
core_data->get_mode.liquid_detection= mode;
if (core_data->set_mode.liquid_detection == mode) {
ts_debug("The value = %d is same, so not to write", mode);
goto exit;
}
if (core_data->power_on == 0) {
ts_debug("The touch is in sleep state, restore the value when resume\n");
goto exit;
}
//clear liquid status before enable detection
if (mode)
core_data->liquid_status = 0;
ret = goodix_ts_send_cmd(core_data, LIQUID_DETECTION_SWITCH_CMD, 5,
core_data->get_mode.liquid_detection, 0x00);
if (ret < 0) {
ts_err("failed to set liquid detection, mode = %d", mode);
goto exit;
}
core_data->set_mode.liquid_detection = mode;
msleep(20);
ts_info("Success to set %d\n", mode);
exit:
mutex_unlock(&core_data->mode_lock);
return ret;
}
#define Y_MIN_ID 2 #define Y_MIN_ID 2
#define Y_MAX_ID 3 #define Y_MAX_ID 3
#define SCREEN_X_MAX 1080 #define SCREEN_X_MAX 1080
@@ -1231,6 +1279,7 @@ static struct ts_mmi_methods goodix_ts_mmi_methods = {
.charger_mode = goodix_ts_mmi_charger_mode, .charger_mode = goodix_ts_mmi_charger_mode,
.refresh_rate = goodix_ts_mmi_refresh_rate, .refresh_rate = goodix_ts_mmi_refresh_rate,
.active_region = goodix_ts_mmi_active_region, .active_region = goodix_ts_mmi_active_region,
.update_liquid_detect_mode = goodix_ts_mmi_update_liquid_detect_mode,
/* Firmware */ /* Firmware */
.firmware_update = goodix_ts_firmware_update, .firmware_update = goodix_ts_firmware_update,
/* vendor specific attribute group */ /* vendor specific attribute group */
@@ -16,6 +16,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/touchscreen_mmi.h> #include <linux/touchscreen_mmi.h>
#include <linux/mmi_wake_lock.h> #include <linux/mmi_wake_lock.h>
#include "goodix_ts_core.h"
#ifdef CONFIG_INPUT_TOUCHSCREEN_MMI #ifdef CONFIG_INPUT_TOUCHSCREEN_MMI
int goodix_ts_mmi_dev_register(struct platform_device *ts_device); int goodix_ts_mmi_dev_register(struct platform_device *ts_device);
@@ -28,6 +29,8 @@ static int inline goodix_ts_mmi_dev_unregister(struct platform_device *ts_device
return -ENOSYS; return -ENOSYS;
} }
#endif #endif
int goodix_ts_send_cmd(struct goodix_ts_core *core_data,
u8 cmd, u8 len, u8 subCmd, u8 subCmd2);
#define LEATHER_MODE_SWITCH_CMD 0x26 #define LEATHER_MODE_SWITCH_CMD 0x26
#define ENTER_LEATHER_MODE 0x01 #define ENTER_LEATHER_MODE 0x01
@@ -54,4 +57,5 @@ static int inline goodix_ts_mmi_dev_unregister(struct platform_device *ts_device
#define EXIT_HIGH_REPORT_RATE_CMD 0xC100 #define EXIT_HIGH_REPORT_RATE_CMD 0xC100
#define SAMPLE_SWITCH_CMD 0xC2 #define SAMPLE_SWITCH_CMD 0xC2
#define ENTER_GESTURE_MODE_CMD 0xA6 #define ENTER_GESTURE_MODE_CMD 0xA6
#define LIQUID_DETECTION_SWITCH_CMD 0x33
#endif #endif