diff options
author | Wendly Li <wendlyli@google.com> | 2022-06-13 07:31:48 +0000 |
---|---|---|
committer | Wendly Li <wendlyli@google.com> | 2022-06-14 18:29:09 +0000 |
commit | 967c1a070556b92b166401a10b07d2ac965e8dcd (patch) | |
tree | 28856aac2e3d5ae523dfe3702409bf116c58b9bc | |
parent | e29c9d98224bd37a84929a3d2bb98c808efdca0e (diff) | |
download | goodix_touch-967c1a070556b92b166401a10b07d2ac965e8dcd.tar.gz |
goodix: Import v1.0.11 driver
Bug: 214118830
Bug: 214118809
Test: Check fw palm and grip works fine and can be switched
Change-Id: I9cfb53fc671a073c802663ee89227ab09d3b783e
Signed-off-by: Wendly Li <wendlyli@google.com>
-rw-r--r-- | goodix_brl_hw.c | 11 | ||||
-rw-r--r-- | goodix_ts_core.c | 32 | ||||
-rw-r--r-- | goodix_ts_core.h | 55 | ||||
-rw-r--r-- | goodix_ts_gesture.c | 3 | ||||
-rw-r--r-- | goodix_ts_proc.c | 36 |
5 files changed, 121 insertions, 16 deletions
diff --git a/goodix_brl_hw.c b/goodix_brl_hw.c index ac908b1..f9c3e1e 100644 --- a/goodix_brl_hw.c +++ b/goodix_brl_hw.c @@ -1000,6 +1000,7 @@ static int brl_esd_check(struct goodix_ts_core *cd) #define GOODIX_TOUCH_EVENT 0x80 #define GOODIX_REQUEST_EVENT 0x40 #define GOODIX_GESTURE_EVENT 0x20 +#define GOODIX_STATUS_EVENT 0x02 #define GOODIX_FP_EVENT 0x08 #define POINT_TYPE_STYLUS_HOVER 0x01 #define POINT_TYPE_STYLUS 0x03 @@ -1178,6 +1179,9 @@ static int goodix_touch_handler(struct goodix_ts_core *cd, } } + if (event_data->status_changed) + ts_event->event_type |= EVENT_STATUS; + /* process custom info */ if (event_data->custom_coor_info_flag) ts_debug("TODO add custom info process function"); @@ -1215,6 +1219,11 @@ static int brl_event_handler( } ts_event->event_type = EVENT_INVALID; + /* read status event */ + if (event_data->status_changed) + hw_ops->read(cd, 0x1021C, (u8 *)&ts_event->status_data, + sizeof(ts_event->status_data)); + if (event_data->type & (GOODIX_TOUCH_EVENT >> 4)) return goodix_touch_handler(cd, ts_event, @@ -1237,6 +1246,8 @@ static int brl_event_handler( struct goodix_ts_gesture_event_data *gesture = (struct goodix_ts_gesture_event_data *)event_data; ts_event->event_type = EVENT_GESTURE; + if (event_data->status_changed) + ts_event->event_type |= EVENT_STATUS; ts_event->gesture_type = gesture->gesture_type; memcpy(ts_event->gesture_data, gesture->data, GOODIX_GESTURE_DATA_LEN); diff --git a/goodix_ts_core.c b/goodix_ts_core.c index 08871ff..4c2ec96 100644 --- a/goodix_ts_core.c +++ b/goodix_ts_core.c @@ -1386,6 +1386,30 @@ static irqreturn_t goodix_ts_isr(int irq, void *data) return IRQ_WAKE_THREAD; } +void goodix_ts_report_status(struct goodix_ts_event *ts_event) +{ + struct goodix_status_data *st = &ts_event->status_data; + int i; + u8 checksum = 0; + int len = sizeof(ts_event->status_data); + u8 *data = (u8 *)st; + + for (i = 0; i < len - 1; i++) + checksum += data[i]; + if (checksum != st->checksum) { + ts_err("status data checksum error"); + return; + } + + ts_info("noise_lv_change[%d] palm_change[%d] soft_reset[%d] base_update[%d] hop_change[%d] water_change[%d]", + st->noise_lv_change, st->palm_change, st->soft_reset, + st->base_update, st->hop_change, st->water_change); + ts_info("water_status[%d] before_factorA[%d] after_factorA[%d] base_update_type[0x%x] soft_reset_type[0x%x] palm_status[%d] noise_lv[%d]", + st->water_sta, st->before_factorA, st->after_factorA, + st->base_update_type, st->soft_reset_type, st->palm_sta, + st->noise_lv); +} + /** * goodix_ts_threadirq_func - Bottom half of interrupt * This functions is excuted in thread context, @@ -1433,7 +1457,7 @@ static irqreturn_t goodix_ts_threadirq_func(int irq, void *data) /* read touch data from touch device */ ret = hw_ops->event_handler(core_data, ts_event); if (likely(!ret)) { - if (ts_event->event_type == EVENT_TOUCH) { + if (ts_event->event_type & EVENT_TOUCH) { /* report touch */ core_data->coords_timestamp = core_data->isr_timestamp; #if IS_ENABLED(CONFIG_GOOG_TOUCH_INTERFACE) @@ -1445,12 +1469,14 @@ static irqreturn_t goodix_ts_threadirq_func(int irq, void *data) #endif } if (core_data->board_data.pen_enable && - ts_event->event_type == EVENT_PEN) { + ts_event->event_type & EVENT_PEN) { goodix_ts_report_pen( core_data->pen_dev, &ts_event->pen_data); } - if (ts_event->event_type == EVENT_REQUEST) + if (ts_event->event_type & EVENT_REQUEST) goodix_ts_request_handle(core_data, ts_event); + if (ts_event->event_type & EVENT_STATUS) + goodix_ts_report_status(ts_event); /* read done */ hw_ops->after_event_handler(core_data); diff --git a/goodix_ts_core.h b/goodix_ts_core.h index b441f00..63ecad7 100644 --- a/goodix_ts_core.h +++ b/goodix_ts_core.h @@ -53,7 +53,7 @@ #define GOODIX_CORE_DRIVER_NAME "goodix_ts" #define GOODIX_PEN_DRIVER_NAME "goodix_ts,pen" -#define GOODIX_DRIVER_VERSION "v1.0.10" +#define GOODIX_DRIVER_VERSION "v1.0.11" #define GOODIX_MAX_TOUCH 10 #define GOODIX_PEN_MAX_PRESSURE 4096 #define GOODIX_MAX_PEN_KEY 2 @@ -351,6 +351,24 @@ struct goodix_ts_cmd { u8 buf[MAX_CMD_BUF_LEN]; }; }; + +struct goodix_status_data { + u8 water_change : 1; + u8 hop_change : 1; + u8 base_update : 1; + u8 soft_reset : 1; + u8 palm_change : 1; + u8 noise_lv_change : 1; + u8 water_sta; + u8 before_factorA; + u8 after_factorA; + u8 base_update_type; + u8 soft_reset_type; + u8 palm_sta; + u8 noise_lv; + u8 res[11]; + u8 checksum; +}; #pragma pack() /* interrupt event type */ @@ -360,6 +378,7 @@ enum ts_event_type { EVENT_PEN = (1 << 1), /* pen event */ EVENT_REQUEST = (1 << 2), EVENT_GESTURE = (1 << 3), + EVENT_STATUS = (1 << 4), }; enum ts_request_type { @@ -430,27 +449,37 @@ struct goodix_ts_event { u8 gesture_data[GOODIX_GESTURE_DATA_LEN]; struct goodix_touch_data touch_data; struct goodix_pen_data pen_data; + struct goodix_status_data status_data; }; struct goodix_ts_event_data { - u8 fp_flag : 4; + u8 reserved1 : 1; + u8 status_changed : 1; + u8 reserved2 : 1; + u8 fp_flag : 1; u8 type : 4; u8 int_count; }; struct goodix_ts_request_event_data { - u8 fp_flag : 4; + u8 reserved1 : 1; + u8 status_changed : 1; + u8 reserved2 : 1; + u8 fp_flag : 1; u8 type : 4; u8 int_count; u8 request_type; - u8 reserved1; - u8 reserved2; u8 reserved3; + u8 reserved4; + u8 reserved5; u16 checksum; }; struct goodix_ts_touch_event_data { - u8 fp_flag : 4; + u8 reserved1 : 1; + u8 status_changed : 1; + u8 reserved2 : 1; + u8 fp_flag : 1; u8 type : 4; u8 int_count; u8 touches : 4; @@ -459,24 +488,27 @@ struct goodix_ts_touch_event_data { u8 edge_flag : 1; u8 reset_int : 1; u8 custom_coor_info_flag : 1; - u8 reserved1 : 7; - u16 reserved2; + u8 reserved3 : 7; + u16 reserved4; u16 checksum; u8 data[0]; }; struct goodix_ts_gesture_event_data { - u8 fp_flag : 4; + u8 reserved1 : 1; + u8 status_changed : 1; + u8 reserved2 : 1; + u8 fp_flag : 1; u8 type : 4; u8 int_count; - u8 reserved1 : 4; + u8 reserved3 : 4; u8 large_touch : 1; u8 hover_approach_flag : 1; u8 edge_flag : 1; u8 reset_int : 1; u8 touches; u8 gesture_type; - u8 reserved3; + u8 reserved4; u16 checksum; u8 data[0]; }; @@ -806,5 +838,6 @@ void goodix_tools_exit(void); int driver_test_proc_init(struct goodix_ts_core *core_data); void driver_test_proc_remove(void); int goodix_do_inspect(struct goodix_ts_core *cd, struct ts_rawdata_info *info); +void goodix_ts_report_status(struct goodix_ts_event *ts_event); #endif diff --git a/goodix_ts_gesture.c b/goodix_ts_gesture.c index 4de2a97..8d2cea3 100644 --- a/goodix_ts_gesture.c +++ b/goodix_ts_gesture.c @@ -249,6 +249,9 @@ static int gsx_gesture_ist( goto re_send_ges_cmd; } + if (gs_event.event_type & EVENT_STATUS) + goodix_ts_report_status(&gs_event); + switch (gs_event.gesture_type) { case GOODIX_GESTURE_SINGLE_TAP: if (cd->gesture_type & GESTURE_SINGLE_TAP) { diff --git a/goodix_ts_proc.c b/goodix_ts_proc.c index 51bf0bf..344cd61 100644 --- a/goodix_ts_proc.c +++ b/goodix_ts_proc.c @@ -40,6 +40,7 @@ #define CMD_GET_FW_STATUS "get_fw_status" #define CMD_SET_HIGHSENSE_MODE "set_highsense_mode" #define CMD_SET_GRIP_DATA "set_grip_data" +#define CMD_SET_GRIP_MODE "set_grip_mode" #define CMD_SET_PALM_MODE "set_palm_mode" #define CMD_SET_NOISE_MODE "set_noise_mode" #define CMD_SET_WATER_MODE "set_water_mode" @@ -56,8 +57,8 @@ char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST, CMD_GET_SCAN_MODE, CMD_SET_CONTINUE_MODE, CMD_GET_CHANNEL_NUM, CMD_GET_TX_FREQ, CMD_RESET, CMD_SET_SENSE_MODE, CMD_GET_CONFIG, CMD_GET_FW_STATUS, CMD_SET_HIGHSENSE_MODE, CMD_SET_GRIP_DATA, - CMD_SET_PALM_MODE, CMD_SET_NOISE_MODE, CMD_SET_WATER_MODE, - CMD_SET_HEATMAP, NULL }; + CMD_SET_GRIP_MODE, CMD_SET_PALM_MODE, CMD_SET_NOISE_MODE, + CMD_SET_WATER_MODE, CMD_SET_HEATMAP, NULL }; /* test limits keyword */ #define CSV_TP_SPECIAL_RAW_MIN "special_raw_min" @@ -73,6 +74,7 @@ char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST, #define PALM_FUNC 0 #define NOISE_FUNC 1 #define WATER_FUNC 2 +#define GRIP_FUNC 3 #define SHORT_SIZE 150 #define LARGE_SIZE 4096 @@ -2280,6 +2282,16 @@ static void goodix_get_fw_status(void) status_addr = offset + 38; noise_lv_addr = offset + 65; + cd->hw_ops->read(cd, 0x1021A, &val, 1); + index += + sprintf(&rbuf[index], "set_noise_mode[%d] ", (val >> 4) & 0x03); + index += + sprintf(&rbuf[index], "set_water_mode[%d] ", (val >> 3) & 0x01); + index += sprintf(&rbuf[index], "set_grip_mode[%d] ", (val >> 2) & 0x01); + index += sprintf(&rbuf[index], "set_palm_mode[%d] ", (val >> 1) & 0x01); + index += sprintf( + &rbuf[index], "set_heatmap_mode[%d]\n", (val >> 0) & 0x01); + cd->hw_ops->read(cd, status_addr, &val, 1); ts_info("addr:0x%04x fw_status:0x%02X", status_addr, val); index += sprintf( @@ -2373,6 +2385,9 @@ static void goodix_set_custom_mode(u8 type, u8 val) } else if (type == WATER_FUNC) { index = sprintf(&rbuf[index], "set water %s\n", val ? "disabled" : "restore"); + } else if (type == GRIP_FUNC) { + index = sprintf(&rbuf[index], "set grip %s\n", + val ? "disabled" : "restore"); } else { ts_err("invalid type, %d", type); return; @@ -3144,6 +3159,23 @@ static ssize_t driver_test_write( goto exit; } + if (!strncmp(p, CMD_SET_GRIP_MODE, strlen(CMD_SET_GRIP_MODE))) { + rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL); + token = strsep(&p, ","); + if (!token || !p) { + index = sprintf(rbuf, "%s: invalid cmd param\n", + CMD_SET_GRIP_MODE); + goto exit; + } + if (kstrtos32(p, 10, &cmd_val)) { + index = sprintf(rbuf, "%s: invalid cmd param\n", + CMD_SET_GRIP_MODE); + goto exit; + } + goodix_set_custom_mode(GRIP_FUNC, cmd_val); + goto exit; + } + if (!strncmp(p, CMD_SET_PALM_MODE, strlen(CMD_SET_PALM_MODE))) { rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL); token = strsep(&p, ","); |