summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2020-04-10 11:09:49 +0800
committerdavidycchen <davidycchen@google.com>2020-05-27 15:42:01 +0800
commitc5d37bc9006325d1724cb2cd1ef79d5f5f06fbed (patch)
treef4e223a8cca7c0f9300b805c609608211cfc65ec
parent7f68fd6169c6fc975d17900fdcc538945851e069 (diff)
downloadfts_touch-c5d37bc9006325d1724cb2cd1ef79d5f5f06fbed.tar.gz
touch:fts: support prox_palm and touch gesture during phone call
During the phone call, report special proximity palm event for sensor HAL proximity fusion. Bug: 154675013 Change-Id: Ib7a1ecea7e2c7d350c3bfcd31de8d589642a86ed Signed-off-by: davidycchen <davidycchen@google.com>
-rw-r--r--fts.c162
-rw-r--r--fts.h9
-rw-r--r--fts_lib/ftsCore.c7
-rw-r--r--fts_lib/ftsSoftware.h5
4 files changed, 182 insertions, 1 deletions
diff --git a/fts.c b/fts.c
index 1761d3e..fe377c7 100644
--- a/fts.c
+++ b/fts.c
@@ -137,6 +137,20 @@ static int fts_mode_handler(struct fts_ts_info *info, int force);
static void fts_pinctrl_setup(struct fts_ts_info *info, bool active);
static int fts_chip_initialization(struct fts_ts_info *info, int init_type);
+#ifdef SUPPORT_PROX_PALM
+static ssize_t audio_status_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+static ssize_t audio_status_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf);
+static ssize_t prox_palm_status_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count);
+static ssize_t prox_palm_status_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf);
+#endif
/**
* Release all the touches in the linux input subsystem
@@ -2767,6 +2781,16 @@ static DEVICE_ATTR(default_mf, 0664,
fts_default_mf_show,
fts_default_mf_store);
+#ifdef SUPPORT_PROX_PALM
+static DEVICE_ATTR(audio_status, 0644,
+ audio_status_show,
+ audio_status_store);
+
+static DEVICE_ATTR(prox_palm_status, 0644,
+ prox_palm_status_show,
+ prox_palm_status_store);
+#endif
+
/* /sys/devices/soc.0/f9928000.i2c/i2c-6/6-0049 */
static struct attribute *fts_attr_group[] = {
&dev_attr_infoblock_getdata.attr,
@@ -2808,9 +2832,100 @@ static struct attribute *fts_attr_group[] = {
&dev_attr_autotune.attr,
&dev_attr_touchsim.attr,
&dev_attr_default_mf.attr,
+#ifdef SUPPORT_PROX_PALM
+ &dev_attr_prox_palm_status.attr,
+ &dev_attr_audio_status.attr,
+#endif
NULL,
};
+#ifdef SUPPORT_PROX_PALM
+/* sysfs file node to store audio status
+ * "echo cmd > audio_status" to change
+ */
+static ssize_t audio_status_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct fts_ts_info *info = dev_get_drvdata(dev);
+ int result;
+ int val;
+
+ result = kstrtoint(buf, 10, &val);
+ if (result < 0) {
+ pr_err("%s: Invalid input.\n", __func__);
+ return -EINVAL;
+ }
+
+ if (val == 0) {
+ fts_set_bus_ref(info, FTS_BUS_REF_PHONE_CALL, false);
+ } else {
+ fts_set_bus_ref(info, FTS_BUS_REF_PHONE_CALL, true);
+ sysfs_notify(&dev->kobj, NULL, dev_attr_prox_palm_status.attr.name);
+ }
+ info->audio_status = val;
+ pr_info("%s: audio status %d", __func__, val);
+ return count;
+}
+
+static ssize_t audio_status_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct fts_ts_info *info = dev_get_drvdata(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ info->audio_status);
+}
+
+static ssize_t prox_palm_status_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct fts_ts_info *info = dev_get_drvdata(dev);
+ int result;
+ int val;
+
+ result = kstrtoint(buf, 10, &val);
+ if (result < 0) {
+ pr_err("%s: Invalid input.\n", __func__);
+ return -EINVAL;
+ }
+
+ info->prox_palm_status = val;
+ sysfs_notify(&dev->kobj, NULL, dev_attr_prox_palm_status.attr.name);
+ pr_info("%s Notify prox_palms status %d", __func__,
+ info->prox_palm_status);
+ return count;
+}
+
+static ssize_t prox_palm_status_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct fts_ts_info *info = dev_get_drvdata(dev);
+
+ return scnprintf(buf, PAGE_SIZE, "%d\n",
+ info->prox_palm_status);
+}
+
+/**
+ * When the feature is enabled, touch IC will keep in active sensing mode
+ * but only report status event and gesture event and stop reporting
+ * pointer location event
+ */
+int enable_prox_palm_only_mode(bool enable)
+{
+ u8 cmd[3] = {0xC0, 0x0D, (u8) enable};
+ int ret = 0;
+
+ ret = fts_write(cmd, 3);
+ if (ret < 0)
+ pr_err("%s: %s failed, ret = %d", __func__,
+ enable ? "enable" : "disable", ret);
+ return ret;
+}
+#endif
/** @}*/
/** @}*/
@@ -3463,6 +3578,34 @@ static bool fts_status_event_handler(struct fts_ts_info *info, unsigned
event[5], event[6], event[7]);
break;
+#ifdef SUPPORT_PROX_PALM
+ case EVT_TYPE_STATUS_PROX_PALM:
+ switch (event[2]) {
+ case 0x00:
+ pr_info("%s: Proximity palm release event"
+ " = %02X %02X %02X %02X %02X %02X\n",
+ __func__, event[2], event[3], event[4],
+ event[5], event[6], event[7]);
+ info->prox_palm_status = 0;
+ sysfs_notify(&info->dev->kobj, NULL, dev_attr_prox_palm_status.attr.name);
+ break;
+
+ case 0x01:
+ pr_info("%s: Proximity palm entry event"
+ " = %02X %02X %02X %02X %02X %02X\n",
+ __func__, event[2], event[3], event[4],
+ event[5], event[6], event[7]);
+ info->prox_palm_status = 1;
+ sysfs_notify(&info->dev->kobj, NULL, dev_attr_prox_palm_status.attr.name);
+ break;
+
+ default:
+ pr_info("%s: Unknown proximity palm status = %02X %02X %02X %02X %02X %02X\n",
+ __func__, event[2], event[3], event[4],
+ event[5], event[6], event[7]);
+ }
+ break;
+#endif
default:
pr_info("%s: Received unknown status event = %02X %02X %02X %02X %02X %02X %02X %02X\n",
__func__, event[0], event[1], event[2], event[3],
@@ -5057,13 +5200,27 @@ static int fts_screen_state_chg_callback(struct notifier_block *nb,
case DRM_PANEL_BLANK_LP:
if (val == DRM_PANEL_EARLY_EVENT_BLANK) {
pr_debug("%s: BLANK\n", __func__);
+#ifdef SUPPORT_PROX_PALM
+ if (info->audio_status)
+ enable_prox_palm_only_mode(true);
+#endif
fts_set_bus_ref(info, FTS_BUS_REF_SCREEN_ON, false);
+#ifdef SUPPORT_PROX_PALM
+ release_all_touches(info);
+#endif
}
break;
case DRM_PANEL_BLANK_UNBLANK:
if (val == DRM_PANEL_EVENT_BLANK) {
pr_debug("%s: UNBLANK\n", __func__);
+#ifdef SUPPORT_PROX_PALM
+ if (info->audio_status)
+ enable_prox_palm_only_mode(false);
+#endif
fts_set_bus_ref(info, FTS_BUS_REF_SCREEN_ON, true);
+#ifdef SUPPORT_PROX_PALM
+ release_all_touches(info);
+#endif
}
break;
}
@@ -6008,6 +6165,11 @@ static int fts_pm_suspend(struct device *dev)
pr_warn("%s: bus_refmask 0x%X\n", __func__, info->bus_refmask);
if (info->resume_bit == 1 || info->sensor_sleep == false) {
+#ifdef SUPPORT_PROX_PALM
+ /* Don't block CPU suspend during phone call*/
+ if (info->bus_refmask == FTS_BUS_REF_PHONE_CALL)
+ return 0;
+#endif
pr_warn("%s: can't suspend because touch bus is in use!\n",
__func__);
return -EBUSY;
diff --git a/fts.h b/fts.h
index d5eeff0..410a304 100644
--- a/fts.h
+++ b/fts.h
@@ -308,7 +308,10 @@ enum {
FTS_BUS_REF_IRQ = 0x02,
FTS_BUS_REF_FW_UPDATE = 0x04,
FTS_BUS_REF_SYSFS = 0x08,
- FTS_BUS_REF_FORCE_ACTIVE = 0x10
+ FTS_BUS_REF_FORCE_ACTIVE = 0x10,
+#ifdef SUPPORT_PROX_PALM
+ FTS_BUS_REF_PHONE_CALL = 0x20,
+#endif
};
/* Motion filter finite state machine (FSM) states
@@ -472,6 +475,10 @@ struct fts_ts_info {
#ifdef TOUCHSCREEN_HEATMAP
int heatmap_mode; /* heatmap mode*/
#endif
+#ifdef SUPPORT_PROX_PALM
+ int audio_status;
+ int prox_palm_status;
+#endif
/* Stop changing motion filter and keep fw design */
bool use_default_mf;
/* Motion filter finite state machine (FSM) state */
diff --git a/fts_lib/ftsCore.c b/fts_lib/ftsCore.c
index fea0941..b073806 100644
--- a/fts_lib/ftsCore.c
+++ b/fts_lib/ftsCore.c
@@ -98,6 +98,10 @@ int fts_system_reset(void)
int res = -1;
int i;
u8 data[1] = { SYSTEM_RESET_VALUE };
+#ifdef SUPPORT_PROX_PALM
+ struct fts_ts_info *info = NULL;
+ info = dev_get_drvdata(&getClient()->dev);
+#endif
event_to_search = (int)EVT_ID_CONTROLLER_READY;
@@ -127,6 +131,9 @@ int fts_system_reset(void)
pr_err("fts_system_reset: ERROR %08X\n", res);
}
}
+#ifdef SUPPORT_PROX_PALM
+ info->prox_palm_status = 0;
+#endif
if (res < OK) {
pr_err("fts_system_reset...failed after 3 attempts: ERROR %08X\n",
(res | ERROR_SYSTEM_RESET_FAIL));
diff --git a/fts_lib/ftsSoftware.h b/fts_lib/ftsSoftware.h
index 0ab1204..8962411 100644
--- a/fts_lib/ftsSoftware.h
+++ b/fts_lib/ftsSoftware.h
@@ -25,6 +25,8 @@
#include <linux/types.h>
#include "ftsHardware.h"
+#define SUPPORT_PROX_PALM
+
/* signed type */
typedef signed char i8; /* /< basic type that represent one signed byte (or 8
* bits) */
@@ -406,6 +408,9 @@ typedef enum {
* Validation Status */
#define EVT_TYPE_STATUS_GOLDEN_RAW_ERR 0x16 /* /< Golden Raw
* Data Abnormal */
+#ifdef SUPPORT_PROX_PALM
+#define EVT_TYPE_STATUS_PROX_PALM 0x18 /* /< Proximity: Palm**/
+#endif
/** @} */