summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2021-12-28 17:39:55 +0800
committerYen-Chao Chen <davidycchen@google.com>2021-12-29 02:48:38 +0000
commit37524e36ef3cecb5ae5ef03007e24e7da2b73377 (patch)
treef52f168e063648dd331da5cfabf184221fc39e1a
parentf2bfef998a7497e947a4381f96abe9e789d781d1 (diff)
downloadsynaptics_touch-37524e36ef3cecb5ae5ef03007e24e7da2b73377.tar.gz
synaptics: support touch high sensitivity mode
Add an attribute to set the touch high sensitivity mode. Bug: 199104397 Test: Read/Write the attribute. Signed-off-by: davidycchen <davidycchen@google.com> Change-Id: Ib173355258a96d53737676b3aca51e939ef201ea
-rw-r--r--syna_tcm2.h1
-rw-r--r--syna_tcm2_sysfs.c92
-rw-r--r--tcm/synaptics_touchcom_core_dev.h1
3 files changed, 94 insertions, 0 deletions
diff --git a/syna_tcm2.h b/syna_tcm2.h
index a03cb65..523378a 100644
--- a/syna_tcm2.h
+++ b/syna_tcm2.h
@@ -426,6 +426,7 @@ struct syna_tcm {
u8 raw_data_report_code;
s16 *raw_data_buffer;
struct completion raw_data_completion;
+ bool high_sensitivity_mode;
#if defined(USE_DRM_BRIDGE)
struct drm_bridge panel_bridge;
diff --git a/syna_tcm2_sysfs.c b/syna_tcm2_sysfs.c
index 1028d55..a4512c9 100644
--- a/syna_tcm2_sysfs.c
+++ b/syna_tcm2_sysfs.c
@@ -884,6 +884,97 @@ static struct kobj_attribute kobj_attr_get_raw_data =
__ATTR(get_raw_data, 0664, syna_sysfs_get_raw_data_show, syna_sysfs_get_raw_data_store);
/**
+ * syna_sysfs_high_sensitivity_show()
+ *
+ * Attribute to show current sensitivity mode.
+ *
+ * @param
+ * [ in] kobj: an instance of kobj
+ * [ in] attr: an instance of kobj attribute structure
+ * [out] buf: string buffer shown on console
+ *
+ * @return
+ * on success, number of characters being output;
+ * otherwise, negative value on error.
+ */
+static ssize_t syna_sysfs_high_sensitivity_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ int retval = 0;
+ struct device *p_dev;
+ struct kobject *p_kobj;
+ struct syna_tcm *tcm;
+
+ p_kobj = g_sysfs_dir->parent;
+ p_dev = container_of(p_kobj, struct device, kobj);
+ tcm = dev_get_drvdata(p_dev);
+
+ syna_pal_mutex_lock(&g_extif_mutex);
+
+ retval = scnprintf(buf, PAGE_SIZE, "%d\n", tcm->high_sensitivity_mode);
+
+ syna_pal_mutex_unlock(&g_extif_mutex);
+ return retval;
+}
+
+/**
+ * syna_sysfs_high_sensitivity_store()
+ *
+ * Attribute to set high sensitivity mode.
+ *
+ * @param
+ * [ in] kobj: an instance of kobj
+ * [ in] attr: an instance of kobj attribute structure
+ * [ in] buf: string buffer input
+ * [ in] count: size of buffer input
+ *
+ * @return
+ * on success, return count; otherwise, return error code
+ */
+static ssize_t syna_sysfs_high_sensitivity_store(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf, size_t count)
+{
+ int retval = count;
+ bool input;
+ struct device *p_dev;
+ struct kobject *p_kobj;
+ struct syna_tcm *tcm;
+
+ p_kobj = g_sysfs_dir->parent;
+ p_dev = container_of(p_kobj, struct device, kobj);
+ tcm = dev_get_drvdata(p_dev);
+
+ if (kstrtobool(buf, &input)) {
+ LOGE("Invalid input %s", buf);
+ return -EINVAL;
+ }
+
+ syna_set_bus_ref(tcm, SYNA_BUS_REF_SYSFS, true);
+ syna_pal_mutex_lock(&g_extif_mutex);
+
+ tcm->high_sensitivity_mode = input;
+
+ retval = syna_tcm_set_dynamic_config(tcm->tcm_dev,
+ DC_HIGH_SENSITIVIRY_MODE,
+ input,
+ RESP_IN_ATTN);
+
+ LOGI("%s high sensitivity mode.\n",
+ tcm->high_sensitivity_mode ? "Enable" : "Disable");
+
+ retval = count;
+
+ syna_pal_mutex_unlock(&g_extif_mutex);
+ syna_set_bus_ref(tcm, SYNA_BUS_REF_SYSFS, false);
+ return retval;
+}
+
+static struct kobj_attribute kobj_attr_high_sensitivity =
+ __ATTR(high_sensitivity, 0664, syna_sysfs_high_sensitivity_show,
+ syna_sysfs_high_sensitivity_store);
+
+
+/**
* declaration of sysfs attributes
*/
static struct attribute *attrs[] = {
@@ -893,6 +984,7 @@ static struct attribute *attrs[] = {
&kobj_attr_scan_mode.attr,
&kobj_attr_force_active.attr,
&kobj_attr_get_raw_data.attr,
+ &kobj_attr_high_sensitivity.attr,
NULL,
};
diff --git a/tcm/synaptics_touchcom_core_dev.h b/tcm/synaptics_touchcom_core_dev.h
index 1728830..204357f 100644
--- a/tcm/synaptics_touchcom_core_dev.h
+++ b/tcm/synaptics_touchcom_core_dev.h
@@ -207,6 +207,7 @@ enum dynamic_tcm_config_id {
DC_ENABLE_FACE_DETECTION = 0x0e,
DC_INHIBIT_ACTIVE_GESTURE = 0x0f,
DC_DISABLE_PROXIMITY = 0x10,
+ DC_HIGH_SENSITIVIRY_MODE = 0xCB,
DC_FORCE_DOZE_MODE = 0xF0,
};