mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-07 20:33:58 -04:00
goodix_blr_mmi: wakeup gesture gt9966
This change formilizes gesture mode setup for GT9916 and GT9966
Goodix touch ICs. There are 2 major differnces between these two:
1) gesture mode command length
2) gesture enable mask
Command length is 6 bytes for GT9916 and 8 bytes for GT9966.
Gesture enable mask:
9916 -> 0 is enabled and 1 disabled
9966 -> 1 is enabled and 0 disabled
double tap single tap
| |
|V--------------|------V--------|
| | | | | | | | | | | | | | | | |
|---------------|---------------|
Byte 5 Byte 6
Change-Id: I76f9735addc45ed2b94a50569a3929b1b73084d0
Signed-off-by: Konstantin Makariev <hcv867@motorola.com>
Reviewed-on: https://gerrit.mot.com/2549731
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: <zhuwg1@motorola.com>
Reviewed-by: Wei Deng <dengwei1@motorola.com>
Reviewed-by: Qing Chang <qing@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
parent
f68d0640c1
commit
e2435909dc
5 changed files with 106 additions and 72 deletions
|
|
@ -253,17 +253,22 @@ int brl_resume(struct goodix_ts_core *cd)
|
|||
}
|
||||
|
||||
#define GOODIX_GESTURE_CMD 0xA6
|
||||
int brl_gesture(struct goodix_ts_core *cd, int gesture_type)
|
||||
int brl_gesture(struct goodix_ts_core *cd, unsigned int gesture_type)
|
||||
{
|
||||
struct goodix_ts_cmd cmd;
|
||||
|
||||
cmd.cmd = GOODIX_GESTURE_CMD;
|
||||
#ifdef CONFIG_GTP_FOD
|
||||
cmd.len = 6;
|
||||
#else
|
||||
cmd.len = 5;
|
||||
#endif
|
||||
cmd.data[0] = gesture_type;
|
||||
cmd.data[0] = gesture_type & 0xFF;
|
||||
if (cd->bus->ic_type == IC_TYPE_BERLIN_D) {
|
||||
cmd.len = 6;
|
||||
cmd.data[1] = (gesture_type >> 8) & 0xFF;
|
||||
} else if (cd->bus->ic_type == IC_TYPE_BERLIN_B) {
|
||||
cmd.len = 8;
|
||||
cmd.data[2] = (gesture_type >> 16) & 0xFF;
|
||||
cmd.data[3] = (gesture_type >> 24) & 0xFF;
|
||||
} else
|
||||
cmd.len = 5;
|
||||
|
||||
if (cd->hw_ops->send_cmd(cd, &cmd))
|
||||
ts_err("failed send gesture cmd");
|
||||
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ struct goodix_ts_hw_ops {
|
|||
int (*dev_confirm)(struct goodix_ts_core *cd);
|
||||
int (*resume)(struct goodix_ts_core *cd);
|
||||
int (*suspend)(struct goodix_ts_core *cd);
|
||||
int (*gesture)(struct goodix_ts_core *cd, int gesture_type);
|
||||
int (*gesture)(struct goodix_ts_core *cd, unsigned int gesture_type);
|
||||
int (*reset)(struct goodix_ts_core *cd, int delay_ms);
|
||||
int (*irq_enable)(struct goodix_ts_core *cd, bool enable);
|
||||
int (*read)(struct goodix_ts_core *cd, unsigned int addr,
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ static int gsx_gesture_ist(struct goodix_ts_core *cd,
|
|||
#ifdef GOODIX_PALM_SENSOR_EN
|
||||
int palm_flag = 0;
|
||||
#endif
|
||||
unsigned int gesture_cmd = 0;
|
||||
|
||||
if (atomic_read(&cd->suspended) == 0)
|
||||
return EVT_CONTINUE;
|
||||
|
|
@ -310,12 +311,12 @@ static int gsx_gesture_ist(struct goodix_ts_core *cd,
|
|||
}
|
||||
|
||||
re_send_ges_cmd:
|
||||
#if defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
|
||||
if (goodix_ts_send_cmd(cd, ENTER_GESTURE_MODE_CMD, 6, (cd->gesture_cmd) >> 8,
|
||||
cd->gesture_cmd & 0xFF) < 0)
|
||||
#else
|
||||
if (hw_ops->gesture(cd, 0))
|
||||
#if defined(PRODUCT_MIAMI)
|
||||
gesture_cmd = 0x80;
|
||||
#elif defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
|
||||
gesture_cmd = cd->gesture_cmd;
|
||||
#endif
|
||||
if (hw_ops->gesture(cd, gesture_cmd))
|
||||
ts_info("warning: failed re_send gesture cmd");
|
||||
gesture_ist_exit:
|
||||
if (!cd->tools_ctrl_sync)
|
||||
|
|
|
|||
|
|
@ -367,6 +367,7 @@ static int gsx_gesture_ist(struct goodix_ts_core *cd,
|
|||
struct goodix_ts_event gs_event = {0};
|
||||
__maybe_unused int fodx, fody, overlay_area;
|
||||
int ret;
|
||||
unsigned int gesture_cmd = 0;
|
||||
#if defined(CONFIG_INPUT_TOUCHSCREEN_MMI)
|
||||
struct gesture_event_data mmi_event;
|
||||
static unsigned long start = 0;
|
||||
|
|
@ -536,13 +537,11 @@ static int gsx_gesture_ist(struct goodix_ts_core *cd,
|
|||
|
||||
re_send_ges_cmd:
|
||||
#if defined(PRODUCT_MIAMI)
|
||||
if (hw_ops->gesture(cd, 0x80))
|
||||
gesture_cmd = 0x80;
|
||||
#elif defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
|
||||
if (goodix_ts_send_cmd(cd, ENTER_GESTURE_MODE_CMD, 6, (cd->gesture_cmd) >> 8,
|
||||
cd->gesture_cmd & 0xFF) < 0)
|
||||
#else
|
||||
if (hw_ops->gesture(cd, 0))
|
||||
gesture_cmd = cd->gesture_cmd;
|
||||
#endif
|
||||
if (hw_ops->gesture(cd, gesture_cmd))
|
||||
ts_info("warning: failed re_send gesture cmd");
|
||||
gesture_ist_exit:
|
||||
if (!cd->tools_ctrl_sync)
|
||||
|
|
|
|||
|
|
@ -959,17 +959,90 @@ static int goodix_ts_mmi_charger_mode(struct device *dev, int mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
|
||||
static unsigned int set_bit_in_pos(unsigned int val, int bit_pos)
|
||||
{
|
||||
return val |= (1 << bit_pos);
|
||||
}
|
||||
|
||||
static unsigned int clear_bit_in_pos(unsigned int val, int bit_pos)
|
||||
{
|
||||
return val &= ~(1 << bit_pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int goodix_berlin_gesture_setup(struct goodix_ts_core *core_data)
|
||||
{
|
||||
const struct goodix_ts_hw_ops *hw_ops = core_data->hw_ops;
|
||||
unsigned int gesture_cmd = 0;
|
||||
#if defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
|
||||
int ret = 0;
|
||||
unsigned char gesture_type = 0;
|
||||
unsigned int (*mod_func)(unsigned int, int) = set_bit_in_pos;
|
||||
|
||||
/* Goodix provided definitive description of gesture mode setting
|
||||
for 9916 and 9966 touch ICs. It's safer to fail for any others
|
||||
until it's confirmed!!!
|
||||
*/
|
||||
if (core_data->bus->ic_type != IC_TYPE_BERLIN_B &&
|
||||
core_data->bus->ic_type != IC_TYPE_BERLIN_D) {
|
||||
ts_err("GT%s gestures not set\n", core_data->fw_version.patch_pid);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (core_data->imports && core_data->imports->get_gesture_type) {
|
||||
ret = core_data->imports->get_gesture_type(core_data->bus->dev, &gesture_type);
|
||||
ts_info("Provisioned gestures 0x%02x; rc = %d\n", gesture_type, ret);
|
||||
}
|
||||
if (core_data->bus->ic_type == IC_TYPE_BERLIN_D) {
|
||||
gesture_cmd = 0xFFFF;
|
||||
mod_func = clear_bit_in_pos;
|
||||
}
|
||||
if (gesture_type & TS_MMI_GESTURE_ZERO) {
|
||||
gesture_cmd = mod_func(gesture_cmd, 5);
|
||||
ts_info("enable zero gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
}
|
||||
if (gesture_type & TS_MMI_GESTURE_SINGLE) {
|
||||
gesture_cmd = mod_func(gesture_cmd, 12);
|
||||
ts_info("enable single gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
}
|
||||
if (gesture_type & TS_MMI_GESTURE_DOUBLE) {
|
||||
gesture_cmd = mod_func(gesture_cmd, 7);
|
||||
ts_info("enable double gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
}
|
||||
#ifdef GOODIX_PALM_SENSOR_EN
|
||||
if (gesture_type & TS_MMI_GESTURE_PALM) {
|
||||
/* override previous setting */
|
||||
gesture_cmd = 0xFFFF;
|
||||
ts_info("enable palm gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
}
|
||||
#endif
|
||||
core_data->gesture_cmd = gesture_cmd;
|
||||
if (core_data->bus->ic_type == IC_TYPE_BERLIN_D) {
|
||||
/* TODO Is this really necessary??? */
|
||||
ret = goodix_ts_send_cmd(core_data, ENTER_GESTURE_MODE_CMD, 6, 0xFF, 0xFF);
|
||||
if (ret < 0) {
|
||||
ts_err("Failed to send enter gesture mode\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
#if defined(PRODUCT_MIAMI)
|
||||
/* TODO Check if Miami 9916??? */
|
||||
gesture_cmd = 0x80;
|
||||
#endif
|
||||
#endif
|
||||
hw_ops->gesture(core_data, gesture_cmd);
|
||||
ts_info("Send enable gesture mode 0x%x\n", gesture_cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int goodix_ts_mmi_panel_state(struct device *dev,
|
||||
enum ts_mmi_pm_mode from, enum ts_mmi_pm_mode to)
|
||||
{
|
||||
struct platform_device *pdev;
|
||||
struct goodix_ts_core *core_data;
|
||||
const struct goodix_ts_hw_ops *hw_ops;
|
||||
#if defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
|
||||
int ret = 0;
|
||||
unsigned short gesture_cmd = 0xFFFF;
|
||||
unsigned char gesture_type = 0;
|
||||
#endif
|
||||
|
||||
GET_GOODIX_DATA(dev);
|
||||
hw_ops = core_data->hw_ops;
|
||||
|
|
@ -977,57 +1050,13 @@ static int goodix_ts_mmi_panel_state(struct device *dev,
|
|||
switch (to) {
|
||||
case TS_MMI_PM_GESTURE:
|
||||
hw_ops->irq_enable(core_data, false);
|
||||
if (hw_ops->gesture)
|
||||
#if defined(CONFIG_BOARD_USES_DOUBLE_TAP_CTRL)
|
||||
if (core_data->imports && core_data->imports->get_gesture_type) {
|
||||
ret = core_data->imports->get_gesture_type(core_data->bus->dev, &gesture_type);
|
||||
if (hw_ops->gesture) {
|
||||
goodix_berlin_gesture_setup(core_data);
|
||||
msleep(16);
|
||||
hw_ops->irq_enable(core_data, true);
|
||||
enable_irq_wake(core_data->irq);
|
||||
core_data->gesture_enabled = true;
|
||||
}
|
||||
#ifdef GOODIX_PALM_SENSOR_EN
|
||||
if (gesture_type & TS_MMI_GESTURE_PALM) {
|
||||
//override previous setting
|
||||
gesture_cmd = 0xFFFF;
|
||||
ts_info("enable palm gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
goto palm_detection;
|
||||
}
|
||||
#endif
|
||||
if (gesture_type & TS_MMI_GESTURE_ZERO) {
|
||||
gesture_cmd &= ~(1 << 5);
|
||||
ts_info("enable zero gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
}
|
||||
if (gesture_type & TS_MMI_GESTURE_SINGLE) {
|
||||
gesture_cmd &= ~(1 << 4);
|
||||
ts_info("enable single gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
}
|
||||
if (gesture_type & TS_MMI_GESTURE_DOUBLE) {
|
||||
gesture_cmd &= ~(1 << 15);
|
||||
ts_info("enable double gesture mode cmd 0x%04x\n", gesture_cmd);
|
||||
}
|
||||
|
||||
#ifdef GOODIX_PALM_SENSOR_EN
|
||||
palm_detection:
|
||||
#endif
|
||||
ret = goodix_ts_send_cmd(core_data, ENTER_GESTURE_MODE_CMD, 6, 0xFF, 0xFF);
|
||||
if (ret < 0) {
|
||||
ts_err("Failed to send enter gesture mode\n");
|
||||
}
|
||||
ret = goodix_ts_send_cmd(core_data, ENTER_GESTURE_MODE_CMD, 6, gesture_cmd >> 8,
|
||||
gesture_cmd & 0xFF);
|
||||
if (ret < 0) {
|
||||
ts_err("Failed to send enable gesture mode\n");
|
||||
}
|
||||
core_data->gesture_cmd = gesture_cmd;
|
||||
ts_info("Send enable gesture mode 0x%04x, 0x%02x\n", gesture_cmd, gesture_type);
|
||||
#else
|
||||
#if defined(PRODUCT_MIAMI)
|
||||
hw_ops->gesture(core_data, 0x80);
|
||||
#else
|
||||
hw_ops->gesture(core_data, 0);
|
||||
#endif
|
||||
#endif
|
||||
msleep(16);
|
||||
hw_ops->irq_enable(core_data, true);
|
||||
enable_irq_wake(core_data->irq);
|
||||
core_data->gesture_enabled = true;
|
||||
break;
|
||||
case TS_MMI_PM_DEEPSLEEP:
|
||||
/* enter sleep mode or power off */
|
||||
|
|
|
|||
Loading…
Reference in a new issue