diff options
author | Wendly Li <wendlyli@google.com> | 2023-02-24 09:50:19 +0000 |
---|---|---|
committer | Wendly Li <wendlyli@google.com> | 2023-03-09 09:13:56 +0000 |
commit | 43c3130d20f6553cd581c5489046f435de09d7c4 (patch) | |
tree | 7d7bc5784c481d503bda19b66e07c0012e675c22 | |
parent | f1f49bd734cb33ed7aea62d6c71fd0e6274bbda4 (diff) | |
download | goodix_touch-43c3130d20f6553cd581c5489046f435de09d7c4.tar.gz |
touch/goodix: Support coordinate filter
Bug: 269560367
Test: Check coordinate filter works properly
Change-Id: I2fbf972d1d67f3c28b090a9db1569e52e407c384
Signed-off-by: Wendly Li <wendlyli@google.com>
-rw-r--r-- | goodix_brl_hw.c | 38 | ||||
-rw-r--r-- | goodix_ts_core.c | 21 | ||||
-rw-r--r-- | goodix_ts_core.h | 4 |
3 files changed, 63 insertions, 0 deletions
diff --git a/goodix_brl_hw.c b/goodix_brl_hw.c index 435658a..d6e2fbf 100644 --- a/goodix_brl_hw.c +++ b/goodix_brl_hw.c @@ -1616,6 +1616,7 @@ int brl_set_heatmap_enabled(struct goodix_ts_core *cd, bool enabled) #define CUSTOM_MODE_MASK_PALM 0x02 #define CUSTOM_MODE_MASK_GRIP 0x04 #define CUSTOM_MODE_MASK_SCREEN_PROTECTOR 0x40 +#define CUSTOM_MODE_MASK_COORD_FILTER 0x80 int brl_set_palm_enabled(struct goodix_ts_core *cd, bool enabled) { struct goodix_ts_cmd cmd = { 0 }; @@ -1839,6 +1840,41 @@ exit: return ret; } +#define GOODIX_CMD_SET_COORD_FILTER 0xCA +static int brl_set_coord_filter_enabled( + struct goodix_ts_core *cd, bool enabled) +{ + struct goodix_ts_cmd cmd = { 0 }; + int ret = 0; + + cmd.cmd = GOODIX_CMD_SET_COORD_FILTER; + cmd.len = 5; + cmd.data[0] = enabled ? 0 : 1; + + ret = cd->hw_ops->send_cmd(cd, &cmd); + if (ret != 0) + ts_err("failed to %s coordinate filter", + enabled ? "enable" : "disable"); + + return ret; +} + +static int brl_get_coord_filter_enabled( + struct goodix_ts_core *cd, bool *enabled) +{ + int ret = 0; + u8 val; + + ret = cd->hw_ops->read(cd, GOODIX_FEATURE_STATUS_ADDR, &val, 1); + if (ret != 0) { + ts_err("failed to get coordinate filter enabled, ret: %d", ret); + *enabled = false; + return ret; + } + *enabled = (val & CUSTOM_MODE_MASK_COORD_FILTER) == 0; + return ret; +} + static struct goodix_ts_hw_ops brl_hw_ops = { .power_on = brl_power_on, .resume = brl_resume, @@ -1874,6 +1910,8 @@ static struct goodix_ts_hw_ops brl_hw_ops = { brl_get_screen_protector_mode_enabled, .get_mutual_data = brl_get_mutual_data, .get_self_sensing_data = brl_get_self_sensing_data, + .set_coord_filter_enabled = brl_set_coord_filter_enabled, + .get_coord_filter_enabled = brl_get_coord_filter_enabled, }; struct goodix_ts_hw_ops *goodix_get_hw_ops(void) diff --git a/goodix_ts_core.c b/goodix_ts_core.c index 036200d..5afdf01 100644 --- a/goodix_ts_core.c +++ b/goodix_ts_core.c @@ -1109,6 +1109,25 @@ static int get_screen_protector_mode( return 0; } +static int set_coord_filter_enabled(void *private_data, + struct gti_coord_filter_cmd *cmd) +{ + struct goodix_ts_core *cd = private_data; + return cd->hw_ops->set_coord_filter_enabled(cd, + cmd->setting == GTI_COORD_FILTER_ENABLE); +} + +static int get_coord_filter_enabled(void *private_data, + struct gti_coord_filter_cmd *cmd) +{ + struct goodix_ts_core *cd = private_data; + bool enabled = false; + + cd->hw_ops->get_coord_filter_enabled(cd, &enabled); + cmd->setting = enabled ? GTI_COORD_FILTER_ENABLE : GTI_COORD_FILTER_DISABLE; + return 0; +} + static int set_heatmap_enabled( void *private_data, struct gti_heatmap_cmd *cmd) { @@ -2899,6 +2918,8 @@ int goodix_ts_stage2_init(struct goodix_ts_core *cd) options->get_palm_mode = get_palm_mode; options->set_screen_protector_mode = set_screen_protector_mode; options->get_screen_protector_mode = get_screen_protector_mode; + options->set_coord_filter_enabled = set_coord_filter_enabled; + options->get_coord_filter_enabled = get_coord_filter_enabled; options->set_heatmap_enabled = set_heatmap_enabled; options->get_fw_version = gti_get_fw_version; options->set_irq_mode = gti_set_irq_mode; diff --git a/goodix_ts_core.h b/goodix_ts_core.h index 74382a2..ceba3e5 100644 --- a/goodix_ts_core.h +++ b/goodix_ts_core.h @@ -686,6 +686,10 @@ struct goodix_ts_hw_ops { struct goodix_ts_core *cd, enum frame_data_type type); int (*get_self_sensing_data)( struct goodix_ts_core *cd, enum frame_data_type type); + int (*set_coord_filter_enabled)( + struct goodix_ts_core *cd, bool enabled); + int (*get_coord_filter_enabled)( + struct goodix_ts_core *cd, bool* enabled); }; /* |