diff options
author | davidycchen <davidycchen@google.com> | 2022-03-10 14:07:08 +0800 |
---|---|---|
committer | davidycchen <davidycchen@google.com> | 2022-03-15 18:36:58 +0800 |
commit | 23bd0de511e582fcc179ca7d60be80262a979d7f (patch) | |
tree | 30f7aaba51997209b541fa9cdf1bc9b4839bd4b1 | |
parent | ba43ce7e908a9f7f8c234d8cf4a0aa4d4a4f87fa (diff) | |
download | synaptics_touch-23bd0de511e582fcc179ca7d60be80262a979d7f.tar.gz |
synaptics: support to confiure heatmap compression threshold
Read the heatmap compression threshold from the device tree and add
an attribute for debugging.
Bug: 223101478
Test: Be able to configure the compression threshold by attribute.
Signed-off-by: davidycchen <davidycchen@google.com>
Change-Id: Ia3d7f4efd3894d304e43f76224dd1d89f83a658a
-rw-r--r-- | syna_tcm2.c | 17 | ||||
-rw-r--r-- | syna_tcm2_platform.h | 1 | ||||
-rw-r--r-- | syna_tcm2_platform_spi.c | 17 | ||||
-rw-r--r-- | syna_tcm2_sysfs.c | 89 | ||||
-rw-r--r-- | tcm/synaptics_touchcom_core_dev.h | 1 |
5 files changed, 119 insertions, 6 deletions
diff --git a/syna_tcm2.c b/syna_tcm2.c index 2ca7ce5..9c0fd62 100644 --- a/syna_tcm2.c +++ b/syna_tcm2.c @@ -288,14 +288,19 @@ static void syna_dev_restore_feature_setting(struct syna_tcm *tcm) syna_dev_set_heatmap_mode(tcm, true); syna_tcm_set_dynamic_config(tcm->tcm_dev, - DC_ENABLE_PALM_REJECTION, - (tcm->enable_fw_palm & 0x01), - RESP_IN_POLLING); + DC_ENABLE_PALM_REJECTION, + (tcm->enable_fw_palm & 0x01), + RESP_IN_POLLING); syna_tcm_set_dynamic_config(tcm->tcm_dev, - DC_ENABLE_GRIP_SUPPRESSION, - (tcm->enable_fw_grip & 0x01), - RESP_IN_POLLING); + DC_ENABLE_GRIP_SUPPRESSION, + (tcm->enable_fw_grip & 0x01), + RESP_IN_POLLING); + + syna_tcm_set_dynamic_config(tcm->tcm_dev, + DC_COMPRESSION_THRESHOLD, + tcm->hw_if->compression_threhsold, + RESP_IN_POLLING); } /* Update a state machine used to toggle control of the touch IC's motion * filter. diff --git a/syna_tcm2_platform.h b/syna_tcm2_platform.h index 16c607d..e38e5a2 100644 --- a/syna_tcm2_platform.h +++ b/syna_tcm2_platform.h @@ -147,6 +147,7 @@ struct syna_hw_interface { struct syna_hw_pwr_data bdata_pwr; const char *fw_name; int pixels_per_mm; + u16 compression_threhsold; #if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) u32 offload_id; #endif diff --git a/syna_tcm2_platform_spi.c b/syna_tcm2_platform_spi.c index 683d6e4..a247fcc 100644 --- a/syna_tcm2_platform_spi.c +++ b/syna_tcm2_platform_spi.c @@ -677,6 +677,23 @@ static int syna_spi_parse_dt(struct syna_hw_interface *hw_if, hw_if->pixels_per_mm = 1; } + prop = of_find_property(np, "synaptics,compression-threshold", NULL); + if (prop && prop->length) { + retval = of_property_read_u32(np, "synaptics,compression-threshold", + &value); + if (retval < 0) { + LOGE("Fail to read synaptics,compression-threshold\n"); + return retval; + } + + hw_if->compression_threhsold = value; + } else { + /* + * Set default as 15. + */ + hw_if->compression_threhsold = 15; + } + #if IS_ENABLED(CONFIG_TOUCHSCREEN_OFFLOAD) hw_if->offload_id = 0; retval = of_property_read_u8_array(np, "synaptics,touch_offload_id", diff --git a/syna_tcm2_sysfs.c b/syna_tcm2_sysfs.c index 1f6aa9e..938c9fc 100644 --- a/syna_tcm2_sysfs.c +++ b/syna_tcm2_sysfs.c @@ -1245,6 +1245,94 @@ static struct kobj_attribute kobj_attr_mf_mode = syna_sysfs_mf_mode_store); /** + * syna_sysfs_compression_threshold_show() + * + * Attribute get the heatmap compression threshold. + * + * @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_compression_threshold_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, "%u\n", tcm->hw_if->compression_threhsold); + + syna_pal_mutex_unlock(&g_extif_mutex); + return retval; +} + +/** + * syna_sysfs_compression_threshold_store() + * + * Attribute set the heatmap compression threshold. + * + * @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_compression_threshold_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + int retval = count; + u8 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 (kstrtou8(buf, 10, &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->hw_if->compression_threhsold = input; + + syna_tcm_set_dynamic_config(tcm->tcm_dev, + DC_COMPRESSION_THRESHOLD, + input, + RESP_IN_ATTN); + + LOGI("Set the heatmap compression threshold as %u.\n", + tcm->hw_if->compression_threhsold); + + 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_compression_threshold = + __ATTR(compression_threshold, 0664, syna_sysfs_compression_threshold_show, + syna_sysfs_compression_threshold_store); + +/** * declaration of sysfs attributes */ static struct attribute *attrs[] = { @@ -1258,6 +1346,7 @@ static struct attribute *attrs[] = { &kobj_attr_fw_grip.attr, &kobj_attr_fw_palm.attr, &kobj_attr_mf_mode.attr, + &kobj_attr_compression_threshold.attr, NULL, }; diff --git a/tcm/synaptics_touchcom_core_dev.h b/tcm/synaptics_touchcom_core_dev.h index 9acfdde..9e136ba 100644 --- a/tcm/synaptics_touchcom_core_dev.h +++ b/tcm/synaptics_touchcom_core_dev.h @@ -222,6 +222,7 @@ enum dynamic_tcm_config_id { DC_DISABLE_PROXIMITY = 0x10, DC_HIGH_SENSITIVIRY_MODE = 0xCB, DC_FORCE_DOZE_MODE = 0xF0, + DC_COMPRESSION_THRESHOLD = 0xF1, DC_TOUCH_SCAN_MODE = 0xF2, DC_ENABLE_PALM_REJECTION = 0xF3, DC_CONTINUOUSLY_REPORT = 0xF5, |