summaryrefslogtreecommitdiff
path: root/syna_tcm2_testing.c
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2021-09-08 15:24:07 +0800
committerdavidycchen <davidycchen@google.com>2021-09-08 15:24:07 +0800
commit2072353c014775e8d66f7df05eeafda536b4501d (patch)
tree4fff217f52d440843f9a8cae94ebbd9fff046c9d /syna_tcm2_testing.c
parent7363f13daa302159b13a77d3c7769f46535a2f38 (diff)
downloadsynaptics_touch-2072353c014775e8d66f7df05eeafda536b4501d.tar.gz
synaptics: support 2 more test commands
Reference test code provided by synaptics. Support the sensor speed test and ADC range test. Bug: 199009920 Signed-off-by: davidycchen <davidycchen@google.com> Change-Id: I18e1b0c0f2fe5d05422c2ab2abfac14f8a14d927
Diffstat (limited to 'syna_tcm2_testing.c')
-rw-r--r--syna_tcm2_testing.c170
1 files changed, 170 insertions, 0 deletions
diff --git a/syna_tcm2_testing.c b/syna_tcm2_testing.c
index c41a92e..6b45f65 100644
--- a/syna_tcm2_testing.c
+++ b/syna_tcm2_testing.c
@@ -587,6 +587,174 @@ exit:
static struct kobj_attribute kobj_attr_pt0a =
__ATTR(pt0a, 0444, syna_testing_pt0a_show, NULL);
+/**
+ * syna_testing_pt10()
+ *
+ * Sample code to perform PT10 testing
+ *
+ * @param
+ * [ in] tcm: the driver handle
+ *
+ * @return
+ * on success, 0; otherwise, negative value on error.
+ */
+static int syna_testing_pt10(struct syna_tcm *tcm)
+{
+ int retval;
+ bool result = false;
+ struct tcm_buffer test_data;
+
+ syna_tcm_buf_init(&test_data);
+
+ LOGI("Start testing\n");
+
+ retval = syna_tcm_run_production_test(tcm->tcm_dev,
+ TEST_PID16_SENSOR_SPEED,
+ &test_data);
+ if (retval < 0) {
+ LOGE("Fail to run test %d\n", TEST_PID16_SENSOR_SPEED);
+ result = false;
+ goto exit;
+ }
+
+ result = syna_testing_compare_frame(test_data.buf,
+ test_data.data_length,
+ tcm->tcm_dev->rows,
+ tcm->tcm_dev->cols,
+ (const short *)&pt10_hi_limits[0],
+ (const short *)&pt10_lo_limits[0]);
+
+exit:
+ LOGI("Result = %s\n", (result)?"pass":"fail");
+
+ syna_tcm_buf_release(&test_data);
+
+ return ((result) ? 0 : -1);
+}
+
+/**
+ * syna_testing_pt10_show()
+ *
+ * Attribute to show the result of PT10 test 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_pt10_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ int retval;
+ unsigned int count = 0;
+ struct syna_tcm *tcm = g_tcm_ptr;
+
+ if (!tcm->is_connected) {
+ count = snprintf(buf, PAGE_SIZE,
+ "Device is NOT connected\n");
+ goto exit;
+ }
+
+ retval = syna_testing_pt10(tcm);
+
+ count = snprintf(buf, PAGE_SIZE,
+ "TEST PT$10: %s\n", (retval < 0) ? "fail" : "pass");
+
+exit:
+ return count;
+}
+
+static struct kobj_attribute kobj_attr_pt10 =
+ __ATTR(pt10, 0444, syna_testing_pt10_show, NULL);
+
+/**
+ * syna_testing_pt11()
+ *
+ * Sample code to perform PT11 testing
+ *
+ * @param
+ * [ in] tcm: the driver handle
+ *
+ * @return
+ * on success, 0; otherwise, negative value on error.
+ */
+static int syna_testing_pt11(struct syna_tcm *tcm)
+{
+ int retval;
+ bool result = false;
+ struct tcm_buffer test_data;
+
+ syna_tcm_buf_init(&test_data);
+
+ LOGI("Start testing\n");
+
+ retval = syna_tcm_run_production_test(tcm->tcm_dev,
+ TEST_PID17_ADC_RANGE,
+ &test_data);
+ if (retval < 0) {
+ LOGE("Fail to run test %d\n", TEST_PID17_ADC_RANGE);
+ result = false;
+ goto exit;
+ }
+
+ result = syna_testing_compare_frame(test_data.buf,
+ test_data.data_length,
+ tcm->tcm_dev->rows,
+ tcm->tcm_dev->cols,
+ (const short *)&pt11_hi_limits[0],
+ (const short *)&pt11_lo_limits[0]);
+
+exit:
+ LOGI("Result = %s\n", (result)?"pass":"fail");
+
+ syna_tcm_buf_release(&test_data);
+
+ return ((result) ? 0 : -1);
+}
+
+/**
+ * syna_testing_pt11_show()
+ *
+ * Attribute to show the result of PT11 test 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_pt11_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ int retval;
+ unsigned int count = 0;
+ struct syna_tcm *tcm = g_tcm_ptr;
+
+ if (!tcm->is_connected) {
+ count = snprintf(buf, PAGE_SIZE,
+ "Device is NOT connected\n");
+ goto exit;
+ }
+
+ retval = syna_testing_pt11(tcm);
+
+ count = snprintf(buf, PAGE_SIZE,
+ "TEST PT$11: %s\n", (retval < 0) ? "fail" : "pass");
+
+exit:
+ return count;
+}
+
+static struct kobj_attribute kobj_attr_pt11 =
+ __ATTR(pt11, 0444, syna_testing_pt11_show, NULL);
+
/*
* declaration of sysfs attributes
*/
@@ -595,6 +763,8 @@ static struct attribute *attrs[] = {
&kobj_attr_pt01.attr,
&kobj_attr_pt05.attr,
&kobj_attr_pt0a.attr,
+ &kobj_attr_pt10.attr,
+ &kobj_attr_pt11.attr,
NULL,
};