diff options
author | Super Liu <supercjliu@google.com> | 2021-07-21 01:21:09 +0000 |
---|---|---|
committer | Super Liu <supercjliu@google.com> | 2021-07-21 06:51:55 +0000 |
commit | a3b66e2de3cb80831d237a651cc203ceadcb159c (patch) | |
tree | bd8985f680267eb7c3e1d4bd0e2a328719cf73d3 | |
parent | 95e828f7fc9b69aa671662178b661408d45d3b70 (diff) | |
download | sec_touch-a3b66e2de3cb80831d237a651cc203ceadcb159c.tar.gz |
touch/sec: add bugreport bus reference.
The new bus reference will separate SEC_TS_BUS_REF_BUGREPORT
from SEC_TS_BUS_REF_FORCE_ACTIVE. This will help to resolve
unusual termination during bugreport capture.
Bug: 194157915
Test: bugreport works normally for touch.
Signed-off-by: Super Liu <supercjliu@google.com>
Change-Id: I8331f3b4f03871a2d27fbb3130db3e7a25684982
-rw-r--r-- | sec_ts.c | 16 | ||||
-rw-r--r-- | sec_ts.h | 5 | ||||
-rw-r--r-- | sec_ts_fn.c | 21 |
3 files changed, 36 insertions, 6 deletions
@@ -5179,9 +5179,10 @@ static int sec_ts_pm_suspend(struct device *dev) { struct sec_ts_data *ts = dev_get_drvdata(dev); - if (ts->bus_refmask) + if (ts->bus_refmask) { input_info(true, &ts->client->dev, "%s: bus_refmask 0x%X\n", __func__, ts->bus_refmask); + } /* Flush work in case a suspend is in progress */ flush_workqueue(ts->event_wq); @@ -5190,6 +5191,19 @@ static int sec_ts_pm_suspend(struct device *dev) input_err(true, &ts->client->dev, "%s: can't suspend because touch bus is in use!\n", __func__); + if (ts->bus_refmask == SEC_TS_BUS_REF_BUGREPORT) { + s64 delta_ms = ktime_ms_delta(ktime_get(), + ts->bugreport_ktime_start); + + if (delta_ms > 30 * MSEC_PER_SEC) { + sec_ts_set_bus_ref(ts, SEC_TS_BUS_REF_BUGREPORT, false); + pm_relax(&ts->client->dev); + ts->bugreport_ktime_start = 0; + input_err(true, &ts->client->dev, + "%s: force release SEC_TS_BUS_REF_BUGREPORT(delta: %lld)!\n", + __func__, delta_ms); + } + } return -EBUSY; } @@ -586,7 +586,8 @@ enum { SEC_TS_BUS_REF_INPUT_DEV = 0x10, SEC_TS_BUS_REF_READ_INFO = 0x20, SEC_TS_BUS_REF_SYSFS = 0x40, - SEC_TS_BUS_REF_FORCE_ACTIVE = 0x80 + SEC_TS_BUS_REF_FORCE_ACTIVE = 0x80, + SEC_TS_BUS_REF_BUGREPORT = 0x100 }; enum { @@ -1093,6 +1094,8 @@ struct sec_ts_data { ktime_t usb_changed_ktime; ktime_t wlc_changed_ktime; + ktime_t bugreport_ktime_start; + int (*sec_ts_write)(struct sec_ts_data *ts, u8 reg, u8 *data, int len); diff --git a/sec_ts_fn.c b/sec_ts_fn.c index 75e94f3..ff20c34 100644 --- a/sec_ts_fn.c +++ b/sec_ts_fn.c @@ -8002,12 +8002,13 @@ static void force_touch_active(void *device_data) struct sec_cmd_data *sec = (struct sec_cmd_data *)device_data; struct sec_ts_data *ts = container_of(sec, struct sec_ts_data, sec); int active, ret; + u16 bus_ref = SEC_TS_BUS_REF_FORCE_ACTIVE; sec_ts_set_bus_ref(ts, SEC_TS_BUS_REF_SYSFS, true); sec_cmd_set_default_result(sec); - if (sec->cmd_param[0] < 0 || sec->cmd_param[0] > 1) { + if (sec->cmd_param[0] < 0 || sec->cmd_param[0] > 2) { sec_cmd_set_cmd_result(sec, "NG", 2); sec_cmd_set_cmd_exit(sec); sec->cmd_state = SEC_CMD_STATUS_FAIL; @@ -8016,15 +8017,27 @@ static void force_touch_active(void *device_data) return; } - active = sec->cmd_param[0]; + /* Specific case for bugreport. */ + if (sec->cmd_param[0] == 2) { + bus_ref = SEC_TS_BUS_REF_BUGREPORT; + active = (sec->cmd_param[1]) ? true : false; + if (active) + ts->bugreport_ktime_start = ktime_get(); + else + ts->bugreport_ktime_start = 0; + } else { + active = sec->cmd_param[0]; + } input_info(true, &ts->client->dev, - "%s: %s\n", __func__, active ? "enable" : "disable"); + "%s: %s %#x\n", __func__, active ? "enable" : "disable", + bus_ref); + if (active) pm_stay_awake(&ts->client->dev); else pm_relax(&ts->client->dev); - ret = sec_ts_set_bus_ref(ts, SEC_TS_BUS_REF_FORCE_ACTIVE, active); + ret = sec_ts_set_bus_ref(ts, bus_ref, active); if (ret == 0) { sec_cmd_set_cmd_result(sec, "OK", 2); sec->cmd_state = SEC_CMD_STATUS_OK; |