diff options
author | Wendly Li <wendlyli@google.com> | 2022-05-30 12:22:28 +0000 |
---|---|---|
committer | Wendly Li <wendlyli@google.com> | 2022-06-24 06:00:02 +0000 |
commit | 616086ad731981c95fd01f915538f7a5da60804c (patch) | |
tree | 68bc6d13aa02b3b942301d4e64d8a4268ae2d2ac | |
parent | beb4b57d63552662a471943e001286d5f82bee68 (diff) | |
download | goodix_touch-616086ad731981c95fd01f915538f7a5da60804c.tar.gz |
goodix: Support screen protector mode
Bug: 214118813
Bug: 214118988
Test: Be able to set/get screen protector mode
Change-Id: Id9464c4d565f9d104ef8e1a83cb3f80aa17b6828
Signed-off-by: Wendly Li <wendlyli@google.com>
-rw-r--r-- | goodix_brl_hw.c | 58 | ||||
-rw-r--r-- | goodix_ts_core.c | 32 | ||||
-rw-r--r-- | goodix_ts_core.h | 5 |
3 files changed, 86 insertions, 9 deletions
diff --git a/goodix_brl_hw.c b/goodix_brl_hw.c index 79b921a..ce5451c 100644 --- a/goodix_brl_hw.c +++ b/goodix_brl_hw.c @@ -1553,22 +1553,23 @@ int brl_set_heatmap_enabled(struct goodix_ts_core *cd, bool enabled) #define CUSTOM_MODE_GRIP 3 #define CUSTOM_MODE_MASK_PALM 0x02 #define CUSTOM_MODE_MASK_GRIP 0x04 +#define CUSTOM_MODE_MASK_SCREEN_PROTECTOR 0x40 int brl_set_palm_enabled(struct goodix_ts_core *cd, bool enabled) { - struct goodix_ts_cmd cmd = {0}; + struct goodix_ts_cmd cmd = { 0 }; cmd.cmd = GOODIX_CMD_SET_CUSTOM_MODE; cmd.len = 6; cmd.data[0] = CUSTOM_MODE_PALM; cmd.data[1] = enabled ? 0 : 1; if (cd->hw_ops->send_cmd(cd, &cmd)) - ts_err("failed to set palm: %s", - enabled ? "enabled" : "disabled"); + ts_err("failed to %s palm mode", + enabled ? "enable" : "disable"); return 0; } -int brl_get_palm_enabled(struct goodix_ts_core *cd, bool* enabled) +int brl_get_palm_enabled(struct goodix_ts_core *cd, bool *enabled) { int ret = 0; u8 val; @@ -1577,6 +1578,7 @@ int brl_get_palm_enabled(struct goodix_ts_core *cd, bool* enabled) if (ret != 0) { ts_err("failed to get palm enabled, ret: %d", ret); *enabled = false; + return ret; } *enabled = (val & CUSTOM_MODE_MASK_PALM) == 0; return ret; @@ -1584,33 +1586,67 @@ int brl_get_palm_enabled(struct goodix_ts_core *cd, bool* enabled) int brl_set_grip_enabled(struct goodix_ts_core *cd, bool enabled) { - struct goodix_ts_cmd cmd = {0}; + struct goodix_ts_cmd cmd = { 0 }; cmd.cmd = GOODIX_CMD_SET_CUSTOM_MODE; cmd.len = 6; cmd.data[0] = CUSTOM_MODE_GRIP; cmd.data[1] = enabled ? 1 : 0; if (cd->hw_ops->send_cmd(cd, &cmd)) - ts_err("failed to set palm: %s", - enabled ? "enabled" : "disabled"); + ts_err("failed to %s grip mode", + enabled ? "enable" : "disable"); return 0; } -int brl_get_grip_enabled(struct goodix_ts_core *cd, bool* enabled) +int brl_get_grip_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 palm enabled, ret: %d", ret); + ts_err("failed to get grip enabled, ret: %d", ret); *enabled = false; + return ret; } *enabled = (val & CUSTOM_MODE_MASK_GRIP) != 0; return ret; } +#define GOODIX_CMD_SET_SCREEN_PROTECTOR_ENABLED 0x72 +int brl_set_screen_protector_mode_enabled( + struct goodix_ts_core *cd, bool enabled) +{ + struct goodix_ts_cmd cmd = { 0 }; + + cmd.cmd = GOODIX_CMD_SET_SCREEN_PROTECTOR_ENABLED; + cmd.len = 5; + cmd.data[0] = enabled ? 1 : 0; + if (cd->hw_ops->send_cmd(cd, &cmd)) + ts_err("failed to %s screen protector mode", + enabled ? "enable" : "disable"); + + return 0; +} + +int brl_get_screen_protector_mode_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 screen protector mode enabled, ret: %d", + ret); + *enabled = false; + return ret; + } + *enabled = (val & CUSTOM_MODE_MASK_SCREEN_PROTECTOR) != 0; + return ret; +} + static struct goodix_ts_hw_ops brl_hw_ops = { .power_on = brl_power_on, .resume = brl_resume, @@ -1638,6 +1674,10 @@ static struct goodix_ts_hw_ops brl_hw_ops = { .get_palm_enabled = brl_get_palm_enabled, .set_grip_enabled = brl_set_grip_enabled, .get_grip_enabled = brl_get_grip_enabled, + .set_screen_protector_mode_enabled = + brl_set_screen_protector_mode_enabled, + .get_screen_protector_mode_enabled = + brl_get_screen_protector_mode_enabled, }; struct goodix_ts_hw_ops *goodix_get_hw_ops(void) diff --git a/goodix_ts_core.c b/goodix_ts_core.c index 18648f6..365752b 100644 --- a/goodix_ts_core.c +++ b/goodix_ts_core.c @@ -927,6 +927,36 @@ static int get_palm_mode(void *private_data, struct gti_palm_cmd *cmd) return 0; } +static int goodix_set_screen_protector_mode_enabled( + struct goodix_ts_core *cd, bool enabled) +{ + int ret = 0; + ret = cd->hw_ops->set_screen_protector_mode_enabled(cd, enabled); + if (ret == 0) + cd->screen_protector_mode_enabled = enabled; + return ret; +} + +static int set_screen_protector_mode( + void *private_data, struct gti_screen_protector_mode_cmd *cmd) +{ + struct goodix_ts_core *cd = private_data; + return goodix_set_screen_protector_mode_enabled( + cd, cmd->setting == GTI_SCREEN_PROTECTOR_MODE_ENABLE); +} + +static int get_screen_protector_mode( + void *private_data, struct gti_screen_protector_mode_cmd *cmd) +{ + struct goodix_ts_core *cd = private_data; + bool enabled = false; + + cd->hw_ops->get_screen_protector_mode_enabled(cd, &enabled); + cmd->setting = enabled ? GTI_SCREEN_PROTECTOR_MODE_ENABLE : + GTI_SCREEN_PROTECTOR_MODE_DISABLE; + return 0; +} + #endif /* prosfs create */ @@ -2394,6 +2424,8 @@ int goodix_ts_stage2_init(struct goodix_ts_core *cd) options->get_grip_mode = get_grip_mode; options->set_palm_mode = set_palm_mode; 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; cd->gti = goog_touch_interface_probe( cd, cd->bus->dev, cd->input_dev, gti_default_handler, options); diff --git a/goodix_ts_core.h b/goodix_ts_core.h index fb0df20..2992a53 100644 --- a/goodix_ts_core.h +++ b/goodix_ts_core.h @@ -594,6 +594,10 @@ struct goodix_ts_hw_ops { int (*get_palm_enabled)(struct goodix_ts_core *cd, bool* enabled); int (*set_grip_enabled)(struct goodix_ts_core *cd, bool enabled); int (*get_grip_enabled)(struct goodix_ts_core *cd, bool* enabled); + int (*set_screen_protector_mode_enabled)( + struct goodix_ts_core *cd, bool enabled); + int (*get_screen_protector_mode_enabled)( + struct goodix_ts_core *cd, bool* enabled); }; /* @@ -654,6 +658,7 @@ struct goodix_ts_core { atomic_t irq_enabled; atomic_t suspended; + bool screen_protector_mode_enabled; /* when this flag is true, driver should not clean the sync flag */ bool tools_ctrl_sync; |