diff options
author | Wendly Li <wendlyli@google.com> | 2023-08-29 07:00:00 +0000 |
---|---|---|
committer | Ravi Jain <raviajain@google.com> | 2023-10-04 06:24:03 +0000 |
commit | 1d7f6b575ca3d5c8817bea5a8905ae237e995d1a (patch) | |
tree | cc27e05ebd838959eb6d7bbf0ae2ed4e61322a02 | |
parent | 8d722b099c12ded60fc6f0356116e9dcf3895b9f (diff) | |
download | goodix_touch-1d7f6b575ca3d5c8817bea5a8905ae237e995d1a.tar.gz |
touch/goodix: Import v1.3.0 driver
- Support GT7986
Bug: 299042455
Test: check touch works properly
Change-Id: Ifce3449068c020d3d16c56ad312b7e192b84317b
Signed-off-by: xulinkun <xulinkun@goodix.com>
Signed-off-by: Wendly Li <wendlyli@google.com>
(cherry picked from commit 767c7166ceee6c940bdfc14be46ac9778f310b7d)
-rw-r--r-- | goodix_brl_hw.c | 28 | ||||
-rw-r--r-- | goodix_brl_spi.c | 3 | ||||
-rw-r--r-- | goodix_ts_core.c | 5 | ||||
-rw-r--r-- | goodix_ts_core.h | 9 | ||||
-rw-r--r-- | goodix_ts_proc.c | 64 | ||||
-rw-r--r-- | goodix_ts_utils.c | 3 |
6 files changed, 102 insertions, 10 deletions
diff --git a/goodix_brl_hw.c b/goodix_brl_hw.c index f112bd0..211d90e 100644 --- a/goodix_brl_hw.c +++ b/goodix_brl_hw.c @@ -1072,12 +1072,14 @@ static void goodix_parse_pen( static int goodix_update_heatmap(struct goodix_ts_core *cd, u8 *event_data) { + struct goodix_ts_hw_ops *hw_ops = cd->hw_ops; struct goodix_ic_info_misc *misc = &cd->ic_info.misc; int tx = cd->ic_info.parm.drv_num; int rx = cd->ic_info.parm.sen_num; int mutual_struct_len = misc->mutual_struct_len; struct goodix_mutual_data *mutual_data; struct goodix_self_sensing_data *self_sensing_data; + int ret = 0; /* * Memory map of event data @@ -1099,10 +1101,32 @@ static int goodix_update_heatmap(struct goodix_ts_core *cd, u8 *event_data) mutual_data = (struct goodix_mutual_data *)mutual_head; self_sensing_data = (struct goodix_self_sensing_data *)(mutual_head + mutual_struct_len); + + /* + * If touch IC can't support frame data mode, the driver need to send + * additional commands to read mutual-sensing and self-sensing data. + */ + if (cd->bus->sub_ic_type == IC_TYPE_SUB_GT7986) { + ret = hw_ops->read(cd, misc->mutual_diffdata_addr, + (u8 *)mutual_data, tx * rx * 2); + if (ret) { + ts_debug("failed to read mutual data"); + goto exit; + } + + ret = hw_ops->read(cd, misc->self_diffdata_addr, + (u8 *)self_sensing_data, (tx + rx) * 2); + if (ret) { + ts_debug("failed to read self data"); + goto exit; + } + } + goodix_rotate_abcd2cbad(tx, rx, mutual_data->data, cd->mutual_data); memcpy(cd->self_sensing_data, self_sensing_data->data, (tx + rx) * 2); - return 0; +exit: + return ret; } static int goodix_touch_handler(struct goodix_ts_core *cd, @@ -1216,7 +1240,7 @@ static int brl_event_handler(struct goodix_ts_core *cd, // read done hw_ops->after_event_handler(cd); - if (cd->heatmap_buffer) { + if (cd->heatmap_buffer && cd->bus->sub_ic_type != IC_TYPE_SUB_GT7986) { offset = 248 + misc->frame_data_head_len + misc->fw_attr_len + misc->fw_log_len + 8; memcpy(cd->heatmap_diff, &pre_buf[offset], tx * rx * 2); diff --git a/goodix_brl_spi.c b/goodix_brl_spi.c index 1d0b295..6761f87 100644 --- a/goodix_brl_spi.c +++ b/goodix_brl_spi.c @@ -422,6 +422,9 @@ static const struct of_device_id spi_matches[] = { .compatible = "goodix,brl-b", }, { + .compatible = "goodix,brl-b,gt7986", + }, + { .compatible = "goodix,brl-d", }, { diff --git a/goodix_ts_core.c b/goodix_ts_core.c index f73af5d..38d5567 100644 --- a/goodix_ts_core.c +++ b/goodix_ts_core.c @@ -2776,6 +2776,11 @@ int goodix_ts_stage2_init(struct goodix_ts_core *cd) * The total read size for SPI is `touch_frame_size` + 8 bytes(SPI prefix header). * Therefore, `touch_frame_package` will need to allocate 8 extra bytes for SPI I/O. */ + if (cd->bus->sub_ic_type == IC_TYPE_SUB_GT7986) { + touch_frame_size = misc->touch_data_head_len + + misc->point_struct_len * GOODIX_MAX_TOUCH + 2; + } + cd->touch_frame_size = touch_frame_size; cd->touch_frame_package = devm_kzalloc(&cd->pdev->dev, touch_frame_size + 8, GFP_KERNEL); diff --git a/goodix_ts_core.h b/goodix_ts_core.h index 293ecb4..fc9fe1b 100644 --- a/goodix_ts_core.h +++ b/goodix_ts_core.h @@ -57,7 +57,7 @@ #define GOODIX_CORE_DRIVER_NAME "goodix_ts" #define GOODIX_PEN_DRIVER_NAME "goodix_ts,pen" -#define GOODIX_DRIVER_VERSION "v1.2.11" +#define GOODIX_DRIVER_VERSION "v1.3.0" #define GOODIX_MAX_TOUCH 10 #define GOODIX_PEN_MAX_PRESSURE 4096 #define GOODIX_MAX_PEN_KEY 2 @@ -65,7 +65,7 @@ #define GOODIX_CFG_MAX_SIZE 4096 #define GOODIX_FW_MAX_SIEZE (300 * 1024) #define GOODIX_MAX_STR_LABEL_LEN 36 -#define GOODIX_MAX_FRAMEDATA_LEN 3600 +#define GOODIX_MAX_FRAMEDATA_LEN 4800 #define GOODIX_GESTURE_DATA_LEN 16 #define GOODIX_REQUEST_DATA_LEN 16 #define GOODIX_NORMAL_RESET_DELAY_MS_DEFAULT 100 /* [GOOG]*/ @@ -79,8 +79,8 @@ /* * [GOOG] * Don't hardcode for tx/rx num. -#define GOODIX_MAX_DRV_NUM 32 -#define GOODIX_MAX_SEN_NUM 39 +#define GOODIX_MAX_DRV_NUM 52 +#define GOODIX_MAX_SEN_NUM 75 */ #define GOODIX_GESTURE_UNKNOWN 0x00 #define GOODIX_GESTURE_DOUBLE_TAP 0xCC @@ -135,6 +135,7 @@ enum IC_TYPE_ID { */ enum BERLIN_B_SUB_ID { IC_TYPE_SUB_B2 = (IC_TYPE_BERLIN_B << 8) | 0x2, + IC_TYPE_SUB_GT7986 = (IC_TYPE_BERLIN_B << 8) | 0x03, }; enum GOODIX_IC_CONFIG_TYPE { diff --git a/goodix_ts_proc.c b/goodix_ts_proc.c index 59d458b..03589b5 100644 --- a/goodix_ts_proc.c +++ b/goodix_ts_proc.c @@ -95,7 +95,7 @@ const static char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST, #define GRIP_FUNC 3 #define SHORT_SIZE 150 -#define LARGE_SIZE (10 * 1024) +#define LARGE_SIZE (15 * 1024) #define HUGE_SIZE (100 * 1024) static char wbuf[SHORT_SIZE]; static char *rbuf; @@ -1935,6 +1935,13 @@ static int goodix_open_test(struct goodix_ts_core *cd) temp_cmd.cmd = 0x90; temp_cmd.data[0] = 0x84; temp_cmd.len = 5; + if (cd->bus->sub_ic_type == IC_TYPE_SUB_GT7986) { + raw_addr = cd->ic_info.misc.mutual_rawdata_addr; + sync_addr = cd->ic_info.misc.touch_data_addr; + temp_cmd.cmd = 0x01; + temp_cmd.len = 4; + } + ret = cd->hw_ops->send_cmd(cd, &temp_cmd); if (ret < 0) { ts_err("send rawdata cmd failed"); @@ -2041,6 +2048,13 @@ static int goodix_self_open_test(struct goodix_ts_core *cd) temp_cmd.cmd = 0x90; temp_cmd.data[0] = 0x84; temp_cmd.len = 5; + if (cd->bus->sub_ic_type == IC_TYPE_SUB_GT7986) { + raw_addr = cd->ic_info.misc.self_rawdata_addr; + sync_addr = cd->ic_info.misc.touch_data_addr; + temp_cmd.cmd = 0x01; + temp_cmd.len = 4; + } + ret = cd->hw_ops->send_cmd(cd, &temp_cmd); if (ret < 0) { ts_err("send rawdata cmd failed"); @@ -2119,7 +2133,14 @@ static int goodix_noise_test(struct goodix_ts_core *cd) temp_cmd.cmd = 0x90; temp_cmd.data[0] = 0x82; temp_cmd.len = 5; + if (cd->bus->sub_ic_type == IC_TYPE_SUB_GT7986) { + raw_addr = cd->ic_info.misc.mutual_diffdata_addr; + sync_addr = cd->ic_info.misc.touch_data_addr; + temp_cmd.cmd = 0x01; + temp_cmd.len = 4; + } ret = cd->hw_ops->send_cmd(cd, &temp_cmd); + if (ret < 0) { ts_err("send rawdata cmd failed"); goto exit; @@ -2606,6 +2627,25 @@ static int get_cap_data(struct goodix_ts_core *cd, uint8_t *type) temp_cmd.cmd = 0x90; temp_cmd.len = 5; + if (cd->bus->sub_ic_type == IC_TYPE_SUB_GT7986) { + if (strstr(type, CMD_GET_BASEDATA)) + mutual_addr = cd->ic_info.misc.mutual_refdata_addr; + else if (strstr(type, CMD_GET_RAWDATA)) + mutual_addr = cd->ic_info.misc.mutual_rawdata_addr; + else if (strstr(type, CMD_GET_DIFFDATA)) + mutual_addr = cd->ic_info.misc.mutual_diffdata_addr; + else if (strstr(type, CMD_GET_SELF_BASEDATA)) + self_addr = cd->ic_info.misc.self_refdata_addr; + else if (strstr(type, CMD_GET_SELF_RAWDATA)) + self_addr = cd->ic_info.misc.self_rawdata_addr; + else if (strstr(type, CMD_GET_SELF_DIFFDATA)) + self_addr = cd->ic_info.misc.self_diffdata_addr; + + flag_addr = cd->ic_info.misc.touch_data_addr; + temp_cmd.cmd = 0x01; + temp_cmd.len = 4; + } + ret = cd->hw_ops->send_cmd(cd, &temp_cmd); if (ret < 0) { ts_err("report rawdata failed, exit!"); @@ -2679,6 +2719,10 @@ exit: temp_cmd.cmd = 0x90; temp_cmd.data[0] = 0; temp_cmd.len = 5; + if (cd->bus->sub_ic_type == IC_TYPE_SUB_GT7986) { + temp_cmd.cmd = 0; + temp_cmd.len = 4; + } cd->hw_ops->send_cmd(cd, &temp_cmd); /* clean touch event flag */ val = 0; @@ -3118,7 +3162,9 @@ static void goodix_set_heatmap(struct goodix_ts_core *cd, int val) temp_cmd.cmd = 0xC9; temp_cmd.data[0] = 1; } - cd->hw_ops->send_cmd(cd, &temp_cmd); + // no need to do anything for GT7986 + if (cd->bus->sub_ic_type != IC_TYPE_SUB_GT7986) + cd->hw_ops->send_cmd(cd, &temp_cmd); cd->hw_ops->irq_enable(cd, true); } @@ -3858,6 +3904,9 @@ static ssize_t driver_test_write(struct file *file, const char __user *buf, } if (!strncmp(p, CMD_NOISE_TEST, strlen(CMD_NOISE_TEST))) { + int tx = cd->ic_info.parm.drv_num; + int rx = cd->ic_info.parm.sen_num; + token = strsep(&p, ","); if (!token || !p) { ts_err("%s: invalid cmd param", CMD_NOISE_TEST); @@ -3868,7 +3917,14 @@ static ssize_t driver_test_write(struct file *file, const char __user *buf, goto exit; } noise_data_cnt = cmd_val; - rbuf = malloc_proc_buffer(noise_data_cnt * 13000); + /* + * [GOOG] + * Change the size based on the channel number(tx * rx) for + * output (raw + data) and markup text with format "%5d,". + */ + //rbuf = malloc_proc_buffer(noise_data_cnt * 30000); + rbuf = malloc_proc_buffer(noise_data_cnt * tx * rx * 6 * 3); + /*~[GOOG]*/ if (!rbuf) { ts_err("failed to alloc rbuf"); goto exit; @@ -4041,7 +4097,7 @@ static ssize_t driver_test_write(struct file *file, const char __user *buf, * Change the size based on the channel number(tx * rx) for * output (raw + data) and markup text with format "%5d,". */ - //rbuf = malloc_proc_buffer(raw_data_cnt * 13000); + //rbuf = malloc_proc_buffer(raw_data_cnt * 30000); rbuf = malloc_proc_buffer(raw_data_cnt * tx * rx * 6 * 3); /*~[GOOG]*/ if (!rbuf) { diff --git a/goodix_ts_utils.c b/goodix_ts_utils.c index c3fc33e..ac75212 100644 --- a/goodix_ts_utils.c +++ b/goodix_ts_utils.c @@ -198,6 +198,9 @@ int goodix_get_ic_type( if (strstr(ic_name, "ga687x")) { bus_inf->sub_ic_type = IC_TYPE_SUB_B2; ts_info("sub ic type is brl-b2"); + } else if (strstr(ic_name, "gt7986")) { + bus_inf->sub_ic_type = IC_TYPE_SUB_GT7986; + ts_info("sub ic type is GT7986"); } return 0; } |