From 86b93f98c024a9c79fb001bee2bfda662770e88f Mon Sep 17 00:00:00 2001 From: Mason Wang Date: Thu, 26 May 2022 12:15:44 +0800 Subject: touch/focaltech: support uncompressed and compressed heatmap. Change the processes of reading heatmap to support both enabled uncompressed or compressed heatmap of touch firmware. Bug: 228953908 Test: Touch operation, twoshay and V4l work well Change-Id: Ief8851a6495c505aecf173cd271024f29954f2b9 --- ft3658/focaltech_core.c | 67 ++++++++++++++++++++++++++++++++++++++++++++---- ft3658/focaltech_core.h | 8 +++++- ft3658/focaltech_flash.c | 4 +++ 3 files changed, 73 insertions(+), 6 deletions(-) (limited to 'ft3658') diff --git a/ft3658/focaltech_core.c b/ft3658/focaltech_core.c index 8dd8ae4..7f157f3 100644 --- a/ft3658/focaltech_core.c +++ b/ft3658/focaltech_core.c @@ -798,12 +798,18 @@ static int fts_read_touchdata(struct fts_ts_data *data) int i; if (data->work_mode == FTS_REG_WORKMODE_WORK_VALUE) { - cmd[0] = FTS_REG_CUSTOMER_STATUS; - fts_read(cmd,1, regB2_data, FTS_CUSTOMER_STATUS_LEN); + /* If fw_heatmap_mode is enableed compressed heatmap, to read register + * 0xB2 before fts_get_heatamp() to get the length of compressed + * heatmap first. + */ + if (data->fw_heatmap_mode == FW_HEATMAP_MODE_COMPRESSED) { + cmd[0] = FTS_REG_CUSTOMER_STATUS; + fts_read(cmd, 1, regB2_data, FTS_CUSTOMER_STATUS_LEN); #if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) || \ IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) - data->compress_heatmap_wlen = (regB2_data[2] << 8) + regB2_data[3]; + data->compress_heatmap_wlen = (regB2_data[2] << 8) + regB2_data[3]; #endif + } } #endif @@ -832,6 +838,14 @@ static int fts_read_touchdata(struct fts_ts_data *data) #if IS_ENABLED(GOOGLE_REPORT_MODE) if (data->work_mode == FTS_REG_WORKMODE_WORK_VALUE) { + /* If fw_heatmap_mode is disabled heatmap or enableed uncompressed + * heatmap, to read register 0xB2 after fts_get_heatamp(). + */ + if (data->fw_heatmap_mode != FW_HEATMAP_MODE_COMPRESSED) { + cmd[0] = FTS_REG_CUSTOMER_STATUS; + fts_read(cmd, 1, regB2_data, FTS_CUSTOMER_STATUS_LEN); + } + check_regB2_status[0] = regB2_data[0] ^ data->current_host_status[0] ; if (check_regB2_status[0]) { // current_status is different with previous_status for(i = STATUS_HOPPING; i < STATUS_CNT_END; i++) { @@ -2740,6 +2754,7 @@ static int fts_ts_probe_entry(struct fts_ts_data *ts_data) int pdata_size = sizeof(struct fts_ts_platform_data); FTS_FUNC_ENTER(); + ts_data->driver_probed = false; FTS_INFO("%s", FTS_DRIVER_VERSION); ts_data->pdata = kzalloc(pdata_size, GFP_KERNEL); if (!ts_data->pdata) { @@ -2849,7 +2864,10 @@ static int fts_ts_probe_entry(struct fts_ts_data *ts_data) memset(ts_data->current_host_status, 0, FTS_CUSTOMER_STATUS_LEN); #endif #if IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) - ts_data->fw_heatmap_mode = FW_HEATMAP_MODE_COMPRESSED; + ts_data->fw_default_heatmap_mode = FW_HEATMAP_MODE_UNCOMPRESSED; + /* Update ts_data->fw_default_heatmap_mode from firmware setting */ + fts_get_default_heatmap_mode(ts_data); + ts_data->fw_heatmap_mode = ts_data->fw_default_heatmap_mode; ts_data->compress_heatmap_wlen = 0; #endif ts_data->enable_fw_grip = FW_GRIP_ENABLE; @@ -3078,6 +3096,7 @@ static int fts_ts_probe_entry(struct fts_ts_data *ts_data) (ts_data->current_host_status[0] & (1 << STATUS_LPTW)) ? "enter" : "exit"); #endif + ts_data->driver_probed = true; FTS_FUNC_EXIT(); return 0; @@ -3272,6 +3291,44 @@ static void fts_update_host_feature_setting(struct fts_ts_data *ts_data, ts_data->current_host_status[1] &= ~(1 << fw_mode_setting); } +int fts_get_default_heatmap_mode(struct fts_ts_data *ts_data) +{ + int ret = 0; + u8 value_heatmap = 0; + u8 value_compressed = 0; + u8 reg_heatmap = FTS_REG_HEATMAP_9E; + u8 reg_compressed = FTS_REG_HEATMAP_ED; + + if (!ts_data->driver_probed || ts_data->fw_loading) { + ret = fts_read_reg(reg_compressed, &value_compressed); + if (ret) { + FTS_ERROR("Read reg(%2X) error!", reg_compressed); + goto exit; + } + + ret = fts_read_reg(reg_heatmap, &value_heatmap); + if (ret) { + FTS_ERROR("Read reg(%2X) error!", reg_heatmap); + goto exit; + } + + if (value_heatmap == 0) + ts_data->fw_default_heatmap_mode = FW_HEATMAP_MODE_DISABLE; + else if (value_compressed) + ts_data->fw_default_heatmap_mode = FW_HEATMAP_MODE_COMPRESSED; + else + ts_data->fw_default_heatmap_mode = FW_HEATMAP_MODE_UNCOMPRESSED; + +exit: + if (ret == 0) { + FTS_DEBUG("Default fw_heatamp is %s and %s.\n", + value_compressed? "compressed" : "uncompressed", + value_heatmap ? "enabled" : "disabled"); + } + } + return ret; +} + int fts_set_heatmap_mode(struct fts_ts_data *ts_data, u8 heatmap_mode) { int ret = 0; @@ -3404,7 +3461,7 @@ int fts_set_glove_mode(struct fts_ts_data *ts_data, bool en) void fts_update_feature_setting(struct fts_ts_data *ts_data) { #if IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) - fts_set_heatmap_mode(ts_data, FW_HEATMAP_MODE_COMPRESSED); + fts_set_heatmap_mode(ts_data, ts_data->fw_default_heatmap_mode); #endif fts_set_grip_mode(ts_data, ts_data->enable_fw_grip); diff --git a/ft3658/focaltech_core.h b/ft3658/focaltech_core.h index 356482f..530d7f1 100644 --- a/ft3658/focaltech_core.h +++ b/ft3658/focaltech_core.h @@ -243,6 +243,7 @@ struct fts_ts_data { bool charger_mode; bool gesture_mode; /* gesture enable or disable, default: disable */ bool prc_mode; + bool driver_probed; struct pen_event pevent; /* multi-touch */ struct ts_event *events; @@ -279,6 +280,7 @@ struct fts_ts_data { #if IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) u8 fw_heatmap_mode; + u8 fw_default_heatmap_mode; int compress_heatmap_wlen; #endif u8 enable_fw_grip; @@ -393,8 +395,12 @@ int fts_gesture_readdata(struct fts_ts_data *ts_data, u8 *data); int fts_gesture_suspend(struct fts_ts_data *ts_data); int fts_gesture_resume(struct fts_ts_data *ts_data); -/* Heatmap */ +/* Heatmap and Offload*/ +#if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) || \ + IS_ENABLED(CONFIG_TOUCHSCREEN_HEATMAP) +int fts_get_default_heatmap_mode(struct fts_ts_data *ts_data); int fts_set_heatmap_mode(struct fts_ts_data *ts_data, u8 heatmap_mode); +#endif int fts_set_grip_mode(struct fts_ts_data *ts_datam, u8 grip_mode); int fts_set_palm_mode(struct fts_ts_data *ts_data, u8 palm_mode); int fts_set_continuous_mode(struct fts_ts_data *ts_data, bool en); diff --git a/ft3658/focaltech_flash.c b/ft3658/focaltech_flash.c index 6686b5a..c03c1b3 100644 --- a/ft3658/focaltech_flash.c +++ b/ft3658/focaltech_flash.c @@ -1195,6 +1195,8 @@ err_bin: fts_esdcheck_switch(ENABLE); #endif + fts_get_default_heatmap_mode(upg->ts_data); + upg->ts_data->fw_heatmap_mode = upg->ts_data->fw_default_heatmap_mode; /* Update firmware feature settings after flashing firmware. */ fts_update_feature_setting(upg->ts_data); @@ -1995,6 +1997,8 @@ static void fts_fwupg_work(struct work_struct *work) fts_esdcheck_switch(ENABLE); #endif + fts_get_default_heatmap_mode(upg->ts_data); + upg->ts_data->fw_heatmap_mode = upg->ts_data->fw_default_heatmap_mode; /* Update firmware feature settings after flashing firmware. */ fts_update_feature_setting(upg->ts_data); -- cgit v1.2.3