diff options
author | davidycchen <davidycchen@google.com> | 2022-05-17 17:56:49 +0800 |
---|---|---|
committer | davidycchen <davidycchen@google.com> | 2022-05-17 17:56:49 +0800 |
commit | a39225b6e91b09ecc30a127ef68a81bfa4b96714 (patch) | |
tree | 30aac953d6cfeb334194f9aac183cae6fc14cdc8 | |
parent | 6f4670c7013b792875b8ce24fc66162c0a4f8009 (diff) | |
download | synaptics_touch-a39225b6e91b09ecc30a127ef68a81bfa4b96714.tar.gz |
synaptics: update driver version to 1.2.8
Support tags moisture test.
Bug: 232768414
Test: cat sys/class/spi_master/spi0/spi0.0/synaptics_tcm.0/sysfs/\
testing/pt_moisture
Signed-off-by: davidycchen <davidycchen@google.com>
Change-Id: If5dc4f7ff02db93d72edb62f97867734bfe73750
-rw-r--r-- | syna_tcm2.c | 2 | ||||
-rw-r--r-- | syna_tcm2.h | 2 | ||||
-rw-r--r-- | syna_tcm2_testing.c | 161 | ||||
-rw-r--r-- | syna_tcm2_testing_limits.h | 44 |
4 files changed, 208 insertions, 1 deletions
diff --git a/syna_tcm2.c b/syna_tcm2.c index 80e4da2..e1273eb 100644 --- a/syna_tcm2.c +++ b/syna_tcm2.c @@ -2026,7 +2026,9 @@ static int syna_dev_resume(struct device *dev) struct syna_tcm *tcm = dev_get_drvdata(dev); struct syna_hw_interface *hw_if = tcm->hw_if; bool irq_enabled = true; +#ifdef RESET_ON_RESUME unsigned char status; +#endif /* exit directly if device isn't in suspend state */ if (tcm->pwr_state == PWR_ON) diff --git a/syna_tcm2.h b/syna_tcm2.h index b453be6..d006e0f 100644 --- a/syna_tcm2.h +++ b/syna_tcm2.h @@ -70,7 +70,7 @@ #define SYNAPTICS_TCM_DRIVER_ID (1 << 0) #define SYNAPTICS_TCM_DRIVER_VERSION 1 -#define SYNAPTICS_TCM_DRIVER_SUBVER "2.7" +#define SYNAPTICS_TCM_DRIVER_SUBVER "2.8" /** * @section: Driver Configurations diff --git a/syna_tcm2_testing.c b/syna_tcm2_testing.c index be8fd36..e8c9ac2 100644 --- a/syna_tcm2_testing.c +++ b/syna_tcm2_testing.c @@ -1136,6 +1136,166 @@ exit: static struct kobj_attribute kobj_attr_pt16 = __ATTR(pt16, 0444, syna_testing_pt16_show, NULL); + +/** + * syna_testing_pt_tag_moisture() + * + * Sample code to perform Tags Moisture (RID30) testing + * + * @param + * [ in] tcm: the driver handle + * + * @return + * on success, 0; otherwise, negative value on error. + */ +static int syna_testing_pt_tag_moisture(struct syna_tcm *tcm, struct tcm_buffer *test_data) +{ + int retval; + bool result = false; + unsigned char code; + int attempt = 0; + short *data_ptr = NULL; + short limit; + int i, j, rows, cols; + + rows = tcm->tcm_dev->rows; + cols = tcm->tcm_dev->cols; + + LOGI("Start testing\n"); + + /* do test in polling; disable irq */ + if (tcm->hw_if->ops_enable_irq) + tcm->hw_if->ops_enable_irq(tcm->hw_if, false); + + syna_tcm_set_dynamic_config(tcm->tcm_dev, DC_DISABLE_DOZE, 1, RESP_IN_POLLING); + + retval = syna_tcm_enable_report(tcm->tcm_dev, 30, true); + if (retval < 0) { + LOGE("Fail to enable RID30\n"); + result = false; + goto exit; + } + + for (attempt = 0; attempt < 3; attempt++) { + retval = syna_tcm_get_event_data(tcm->tcm_dev, &code, + test_data); + if ((retval >= 0) && (code == 30)) + break; + } + + if ((retval < 0) || (code != 30)) { + LOGE("Fail to get a frame of RID30 to test\n"); + result = false; + goto exit; + } + + if (test_data->data_length % (rows * cols) != 0) { + LOGE("Invalid frame size of RID30, %d\n", test_data->data_length); + result = false; + goto exit; + } + + retval = syna_tcm_enable_report(tcm->tcm_dev, 30, false); + if (retval < 0) { + LOGE("Fail to disable RID30\n"); + result = false; + goto exit; + } + + /* compare to the limits */ + result = true; + data_ptr = (short *)&test_data->buf[0]; + for (i = 0; i < rows; i++) { + for (j = 0; j < cols; j++) { + if (*data_ptr < 0) + continue; + + limit = pt_moisture_limits[i * LIMIT_BOUNDARY + j]; + if (*data_ptr > limit) { + LOGE("Fail on (%2d,%2d)=%5d, limits_hi:%4d\n", + i, j, *data_ptr, limit); + result = false; + } + data_ptr++; + } + } + +exit: + syna_tcm_set_dynamic_config(tcm->tcm_dev, DC_DISABLE_DOZE, 0, RESP_IN_POLLING); + + LOGI("Result = %s\n", (result)?"pass":"fail"); + + /* recover the irq */ + if (tcm->hw_if->ops_enable_irq) + tcm->hw_if->ops_enable_irq(tcm->hw_if, true); + + return ((result) ? 0 : -1); +} + +/** + * syna_testing_pt_moisture_show() + * + * Attribute to show the result of Tags Moisture (RID30) to the console. + * + * @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_testing_pt_moisture_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + int retval, i, j; + short *data_ptr = NULL; + unsigned int count = 0; + struct syna_tcm *tcm = g_tcm_ptr; + struct tcm_buffer test_data; + + if (!tcm->is_connected) { + count = scnprintf(buf, PAGE_SIZE, + "Device is NOT connected\n"); + goto exit; + } + + syna_set_bus_ref(tcm, SYNA_BUS_REF_SYSFS, true); + + syna_tcm_buf_init(&test_data); + + retval = syna_testing_pt_tag_moisture(tcm, &test_data); + + count += scnprintf(buf, PAGE_SIZE, + "TEST Tags Moisture: %s\n", + (retval < 0) ? "fail" : "pass"); + + count += scnprintf(buf + count, PAGE_SIZE - count, "%d %d\n", + tcm->tcm_dev->cols, tcm->tcm_dev->rows); + + if (retval == 0) { + data_ptr = (short *)&(test_data.buf[0]); + for (i = 0; i < tcm->tcm_dev->rows; i++) { + for (j = 0; j < tcm->tcm_dev->cols; j++) { + count += scnprintf(buf + count, PAGE_SIZE - count, "%d ", + data_ptr[i * tcm->tcm_dev->cols + j]); + } + count += scnprintf(buf + count, PAGE_SIZE - count, "\n"); + } + } + + syna_tcm_buf_release(&test_data); + + syna_set_bus_ref(tcm, SYNA_BUS_REF_SYSFS, false); + +exit: + return count; +} + +static struct kobj_attribute kobj_attr_pt_tag_moisture = + __ATTR(pt_moisture, 0444, syna_testing_pt_moisture_show, NULL); + /* * declaration of sysfs attributes */ @@ -1148,6 +1308,7 @@ static struct attribute *attrs[] = { &kobj_attr_pt11.attr, &kobj_attr_pt12.attr, &kobj_attr_pt16.attr, + &kobj_attr_pt_tag_moisture.attr, NULL, }; diff --git a/syna_tcm2_testing_limits.h b/syna_tcm2_testing_limits.h index 7fce00f..e3191ca 100644 --- a/syna_tcm2_testing_limits.h +++ b/syna_tcm2_testing_limits.h @@ -513,4 +513,48 @@ static const short pt16_lo_limits[LIMIT_BOUNDARY * LIMIT_BOUNDARY] = { /* 39 */ 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, }; +static const short pt_moisture_limits[LIMIT_BOUNDARY * LIMIT_BOUNDARY] = { +/* 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 */ +/* 00 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 01 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 02 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 03 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 04 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 05 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 06 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 07 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 08 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 09 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 10 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 11 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 12 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 13 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 14 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 15 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 16 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 17 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 18 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 19 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 20 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 21 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 22 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 23 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 24 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 25 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 26 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 27 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 28 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 29 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 30 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 31 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 32 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 33 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 34 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 35 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 36 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 37 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 38 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +/* 39 */ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, +}; + #endif /* end of _SYNAPTICS_TCM2_TESTING_LIMITS_H_ */ |