summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2021-12-09 11:13:48 +0800
committerdavidycchen <davidycchen@google.com>2021-12-09 17:58:21 +0800
commit96d884a4c6120e4a8e837f02f27079f0d993521d (patch)
tree77bc874474f7946eed0d091f6cd2cfeec07eb80a
parent79333382bf76d47d302c5925f8ab1c1bf2d0efa7 (diff)
downloadsynaptics_touch-96d884a4c6120e4a8e837f02f27079f0d993521d.tar.gz
synaptics: correct the raw data type
Delta: Signed-16bit. Raw: Unsigned-16bit. Baselise: Unsigned-16bit. Bug: 209731727. Test: echo 12 > /sys/class/spi_master/spi0/spi0.0/synaptics_tcm.0/ sysfs/get_raw_data cat /sys/class/spi_master/spi0/spi0.0/synaptics_tcm.0/sysfs/ get_raw_data Signed-off-by: davidycchen <davidycchen@google.com> Change-Id: Iaeafe623dad496c82ac65f3bd00bac65097d15e9
-rw-r--r--syna_tcm2_sysfs.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/syna_tcm2_sysfs.c b/syna_tcm2_sysfs.c
index 73ecc80..b9206af 100644
--- a/syna_tcm2_sysfs.c
+++ b/syna_tcm2_sysfs.c
@@ -735,25 +735,34 @@ static struct kobj_attribute kobj_attr_force_active =
static ssize_t syna_sysfs_get_raw_data_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
- int retval;
+ int retval = 0;
unsigned int count = 0;
struct device *p_dev;
struct kobject *p_kobj;
struct syna_tcm *tcm;
struct tcm_dev *tcm_dev;
- int i, j;
+ int i, j, mutual_length;
+ bool is_signed;
p_kobj = g_sysfs_dir->parent;
p_dev = container_of(p_kobj, struct device, kobj);
tcm = dev_get_drvdata(p_dev);
tcm_dev = tcm->tcm_dev;
+ mutual_length = tcm_dev->cols * tcm_dev->rows;
+ is_signed = (tcm->raw_data_report_code == REPORT_DELTA);
syna_pal_mutex_lock(&g_extif_mutex);
if (wait_for_completion_timeout(&tcm->raw_data_completion,
msecs_to_jiffies(500)) == 0) {
complete_all(&tcm->raw_data_completion);
- retval = scnprintf(buf + count, PAGE_SIZE - count, "Timeout\n");
+ count += scnprintf(buf + count, PAGE_SIZE - count, "Timeout\n");
+ goto exit;
+ }
+
+ if (!tcm->raw_data_buffer) {
+ count += scnprintf(buf + count, PAGE_SIZE - count,
+ "Raw data buffer is NULL.\n");
goto exit;
}
@@ -761,8 +770,10 @@ static ssize_t syna_sysfs_get_raw_data_show(struct kobject *kobj,
count += scnprintf(buf + count, PAGE_SIZE - count, "Mutual\n");
for (i = 0; i < tcm_dev->rows; i++) {
for (j = 0; j < tcm_dev->cols; j++) {
- count += scnprintf(buf + count, PAGE_SIZE - count, "%d ",
- tcm->raw_data_buffer[i * tcm_dev->cols + j]);
+ count += scnprintf(buf + count, PAGE_SIZE - count,
+ (is_signed) ? "%d " : "%u ",
+ (is_signed) ? tcm->raw_data_buffer[i * tcm_dev->cols + j] :
+ (u16) (tcm->raw_data_buffer[i * tcm_dev->cols + j]));
}
count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
}
@@ -770,22 +781,25 @@ static ssize_t syna_sysfs_get_raw_data_show(struct kobject *kobj,
/* Self raw. */
count += scnprintf(buf + count, PAGE_SIZE - count, "Self\n");
for (i = 0; i < tcm_dev->cols; i++) {
- count += scnprintf(buf + count, PAGE_SIZE - count, "%d ",
- tcm->raw_data_buffer[tcm_dev->cols * tcm_dev->rows + i]);
+ count += scnprintf(buf + count, PAGE_SIZE - count,
+ (is_signed) ? "%d " : "%u ",
+ (is_signed) ? tcm->raw_data_buffer[mutual_length + i] :
+ (u16) (tcm->raw_data_buffer[mutual_length + i]));
}
count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
for (j = 0; j < tcm_dev->rows; j++) {
- count += scnprintf(buf + count, PAGE_SIZE - count, "%d ",
- tcm->raw_data_buffer[tcm_dev->cols * tcm_dev->rows + i + j]);
+ count += scnprintf(buf + count, PAGE_SIZE - count,
+ (is_signed) ? "%d " : "%u ",
+ (is_signed) ? tcm->raw_data_buffer[mutual_length + i + j] :
+ (u16) (tcm->raw_data_buffer[mutual_length + i + j]));
}
count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
- retval = count;
-
LOGI("Got raw data, report code %#x\n", tcm->raw_data_report_code);
exit:
+ retval = count;
syna_tcm_set_dynamic_config(tcm->tcm_dev, DC_DISABLE_DOZE, 0, RESP_IN_ATTN);
syna_tcm_enable_report(tcm_dev, tcm->raw_data_report_code, false);
syna_pal_mutex_unlock(&g_extif_mutex);