diff options
-rw-r--r-- | goodix_brl_hw.c | 20 | ||||
-rw-r--r-- | goodix_ts_core.c | 13 | ||||
-rw-r--r-- | goodix_ts_core.h | 7 | ||||
-rw-r--r-- | goodix_ts_proc.c | 40 |
4 files changed, 53 insertions, 27 deletions
diff --git a/goodix_brl_hw.c b/goodix_brl_hw.c index f9c3e1e..a64046e 100644 --- a/goodix_brl_hw.c +++ b/goodix_brl_hw.c @@ -389,6 +389,7 @@ static int brl_send_cmd(struct goodix_ts_core *cd, struct goodix_ts_cmd *cmd) struct goodix_ic_info_misc *misc = &cd->ic_info.misc; struct goodix_ts_hw_ops *hw_ops = cd->hw_ops; + mutex_lock(&cd->cmd_lock); cmd->state = 0; cmd->ack = 0; goodix_append_checksum( @@ -400,7 +401,7 @@ static int brl_send_cmd(struct goodix_ts_core *cd, struct goodix_ts_cmd *cmd) ret = hw_ops->write(cd, misc->cmd_addr, cmd->buf, sizeof(*cmd)); if (ret < 0) { ts_err("failed write command"); - return ret; + goto exit; } for (i = 0; i < GOODIX_CMD_RETRY; i++) { /* check command result */ @@ -408,12 +409,13 @@ static int brl_send_cmd(struct goodix_ts_core *cd, struct goodix_ts_cmd *cmd) sizeof(cmd_ack)); if (ret < 0) { ts_err("failed read command ack, %d", ret); - return ret; + goto exit; } ts_debug("cmd ack data %*ph", (int)sizeof(cmd_ack), cmd_ack.buf); if (cmd_ack.ack == CMD_ACK_OK) { - return 0; + ret = 0; + goto exit; } if (cmd_ack.ack == CMD_ACK_BUSY || cmd_ack.ack == 0x00) { @@ -426,8 +428,11 @@ static int brl_send_cmd(struct goodix_ts_core *cd, struct goodix_ts_cmd *cmd) break; } } + ret = -EINVAL; ts_err("failed get valid cmd ack"); - return -EINVAL; +exit: + mutex_unlock(&cd->cmd_lock); + return ret; } #pragma pack(1) @@ -1111,9 +1116,6 @@ static int goodix_touch_handler(struct goodix_ts_core *cd, static u8 pre_finger_num; static u8 pre_pen_num; - /* clean event buffer */ - memset(ts_event, 0, sizeof(*ts_event)); - if (event_data->touches > GOODIX_MAX_TOUCH) { ts_debug("invalid touch num %d", event_data->touches); return -EINVAL; @@ -1218,13 +1220,15 @@ static int brl_event_handler( return -EINVAL; } + /* clean event buffer */ + memset(ts_event, 0, sizeof(*ts_event)); + 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, (struct goodix_ts_touch_event_data *)event_data); diff --git a/goodix_ts_core.c b/goodix_ts_core.c index 4c2ec96..d167fb8 100644 --- a/goodix_ts_core.c +++ b/goodix_ts_core.c @@ -1401,13 +1401,14 @@ void goodix_ts_report_status(struct goodix_ts_event *ts_event) 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]", + ts_info("grip_change[%d] noise_lv_change[%d] palm_change[%d] soft_reset[%d] base_update[%d] hop_change[%d] water_change[%d]", + st->grip_change, 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] grip_type[%d]", st->water_sta, st->before_factorA, st->after_factorA, st->base_update_type, st->soft_reset_type, st->palm_sta, - st->noise_lv); + st->noise_lv, st->grip_type); } /** @@ -2608,6 +2609,7 @@ static int goodix_ts_probe(struct platform_device *pdev) core_module_prob_sate = CORE_MODULE_PROB_FAILED; return -EINVAL; } + mutex_init(&core_data->cmd_lock); goodix_core_module_init(); /* touch core layer is a platform driver */ core_data->pdev = pdev; @@ -2681,6 +2683,7 @@ err_init_tools: err_setup_gpio: goodix_set_pinctrl_state(core_data, PINCTRL_MODE_SUSPEND); err_out: + mutex_destroy(&core_data->cmd_lock); core_data->init_stage = CORE_INIT_FAIL; core_module_prob_sate = CORE_MODULE_PROB_FAILED; ts_err("goodix_ts_core failed, ret:%d", ret); diff --git a/goodix_ts_core.h b/goodix_ts_core.h index 63ecad7..e005cf8 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.11" +#define GOODIX_DRIVER_VERSION "v1.0.12" #define GOODIX_MAX_TOUCH 10 #define GOODIX_PEN_MAX_PRESSURE 4096 #define GOODIX_MAX_PEN_KEY 2 @@ -359,6 +359,7 @@ struct goodix_status_data { u8 soft_reset : 1; u8 palm_change : 1; u8 noise_lv_change : 1; + u8 grip_change : 1; u8 water_sta; u8 before_factorA; u8 after_factorA; @@ -366,7 +367,8 @@ struct goodix_status_data { u8 soft_reset_type; u8 palm_sta; u8 noise_lv; - u8 res[11]; + u8 grip_type; + u8 res[10]; u8 checksum; }; #pragma pack() @@ -628,6 +630,7 @@ struct goodix_ts_core { struct goodix_ts_hw_ops *hw_ops; struct input_dev *input_dev; struct input_dev *pen_dev; + struct mutex cmd_lock; /* TODO counld we remove this from core data? */ struct goodix_ts_event ts_event; diff --git a/goodix_ts_proc.c b/goodix_ts_proc.c index 344cd61..5020414 100644 --- a/goodix_ts_proc.c +++ b/goodix_ts_proc.c @@ -852,18 +852,23 @@ typedef struct __attribute__((packed)) { #define FLASH_CMD_STATE_OKAY 0x07 static int goodix_flash_cmd(uint8_t cmd, uint8_t status, int retry_count) { - struct goodix_ts_cmd temp_cmd; + u8 cmd_buf[] = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }; int ret; int i; u8 r_sta; - temp_cmd.len = 4; - temp_cmd.cmd = cmd; - ret = cd->hw_ops->send_cmd(cd, &temp_cmd); + cmd_buf[3] = cmd; + goodix_append_checksum(&cmd_buf[2], 2, CHECKSUM_MODE_U8_LE); + ret = cd->hw_ops->write( + cd, cd->ic_info.misc.cmd_addr, cmd_buf, sizeof(cmd_buf)); if (ret < 0) return ret; + if (retry_count == 0) + return 0; + for (i = 0; i < retry_count; i++) { + usleep_range(2000, 2100); ret = cd->hw_ops->read( cd, cd->ic_info.misc.cmd_addr, &r_sta, 1); if (ret == 0 && r_sta == status) @@ -880,7 +885,6 @@ static int goodix_flash_read(u32 addr, u8 *buf, int len) int ret; u8 *tmp_buf; u32 buffer_addr = cd->ic_info.misc.fw_buffer_addr; - struct goodix_ts_cmd temp_cmd; uint32_t checksum = 0; flash_head_info_t head_info; u8 *p = (u8 *)&head_info.address; @@ -922,8 +926,8 @@ static int goodix_flash_read(u32 addr, u8 *buf, int len) goto read_end; } - checksum = 0; - for (i = 0; i < len + sizeof(flash_head_info_t) - 4; i += 2) + checksum = len % 2 ? tmp_buf[len + sizeof(flash_head_info_t) - 1] : 0; + for (i = 0; i < len + sizeof(flash_head_info_t) - 6; i += 2) checksum += tmp_buf[4 + i] | (tmp_buf[5 + i] << 8); if (checksum != le32_to_cpup((__le32 *)tmp_buf)) { @@ -935,9 +939,7 @@ static int goodix_flash_read(u32 addr, u8 *buf, int len) memcpy(buf, tmp_buf + sizeof(flash_head_info_t), len); ret = 0; read_end: - temp_cmd.len = 4; - temp_cmd.cmd = 0x0C; - cd->hw_ops->send_cmd(cd, &temp_cmd); + goodix_flash_cmd(0x0C, 0, 0); return ret; } @@ -978,8 +980,6 @@ static const struct seq_operations seq_ops = { static int driver_test_open(struct inode *inode, struct file *file) { - memset(wbuf, 0, sizeof(wbuf)); - return seq_open(file, &seq_ops); } @@ -1324,6 +1324,12 @@ static void goodix_save_test_result(bool is_brief) ts_test->result[GTP_CAP_TEST] ? "PASS" : "FAIL"); } + if (ts_test->item[GTP_DELTA_TEST]) { + index += sprintf(&rbuf[index], "Delta test:\n"); + index += sprintf(&rbuf[index], "%s\n", + ts_test->result[GTP_DELTA_TEST] ? "PASS" + : "FAIL"); + } if (ts_test->item[GTP_SHORT_TEST]) { index += sprintf(&rbuf[index], "Short test:\n"); index += sprintf(&rbuf[index], "%s\n", @@ -2283,6 +2289,8 @@ static void goodix_get_fw_status(void) noise_lv_addr = offset + 65; cd->hw_ops->read(cd, 0x1021A, &val, 1); + index += sprintf( + &rbuf[index], "set_highsense_mode[%d] ", (val >> 6) & 0x01); index += sprintf(&rbuf[index], "set_noise_mode[%d] ", (val >> 4) & 0x03); index += @@ -2615,6 +2623,7 @@ static ssize_t driver_test_write( return count; } + memset(wbuf, 0, sizeof(wbuf)); if (copy_from_user(p, buf, count) != 0) { ts_err("copy from user failed"); return count; @@ -2874,6 +2883,7 @@ static ssize_t driver_test_write( } ts_test->item[GTP_CAP_TEST] = true; ts_test->item[GTP_NOISE_TEST] = true; + ts_test->item[GTP_DELTA_TEST] = true; ts_test->item[GTP_SELFCAP_TEST] = true; ts_test->item[GTP_SHORT_TEST] = true; goodix_auto_test(true); @@ -2977,7 +2987,10 @@ static ssize_t driver_test_write( if (!strncmp(p, CMD_GET_PACKAGE_ID, strlen(CMD_GET_PACKAGE_ID))) { rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL); + mutex_lock(&cd->cmd_lock); + usleep_range(6000, 6100); ret = goodix_flash_read(0x1F301, &id, 1); + mutex_unlock(&cd->cmd_lock); if (ret < 0) index = sprintf(rbuf, "%s: NG\n", CMD_GET_PACKAGE_ID); else @@ -2988,7 +3001,10 @@ static ssize_t driver_test_write( if (!strncmp(p, CMD_GET_MCU_ID, strlen(CMD_GET_MCU_ID))) { rbuf = kzalloc(SHORT_SIZE, GFP_KERNEL); + mutex_lock(&cd->cmd_lock); + usleep_range(6000, 6100); ret = goodix_flash_read(0x1F314, &id, 1); + mutex_unlock(&cd->cmd_lock); if (ret < 0) index = sprintf(rbuf, "%s: NG\n", CMD_GET_MCU_ID); else |