summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidycchen <davidycchen@google.com>2021-07-22 12:02:46 +0800
committerDavid Chen <davidycchen@google.com>2021-08-04 02:18:11 +0000
commit5636c050526d32eb4ddaa19e6b430cab63ab625d (patch)
tree4e04d82b427c32d501a1af1b75af064850a7ead6
parent5510c15a236af3d800f9074a4b10ec0cd8df938c (diff)
downloadfts_touch-5636c050526d32eb4ddaa19e6b430cab63ab625d.tar.gz
touch: fst2: change log format
bug: 193085179 Signed-off-by: davidycchen <davidycchen@google.com> Change-Id: I0fd74b9ebaa5df17f9d4f4720a1e603cfac9c517
-rw-r--r--fst2/fts.h2
-rw-r--r--fst2/fts_lib/fts_io.c7
-rw-r--r--fst2/fts_lib/fts_io.h5
-rw-r--r--fst2/fts_lib/fts_test.c79
4 files changed, 77 insertions, 16 deletions
diff --git a/fst2/fts.h b/fst2/fts.h
index 129d5a7..f230dc3 100644
--- a/fst2/fts.h
+++ b/fst2/fts.h
@@ -53,7 +53,7 @@
-#define DEBUG
+//#define DEBUG
/* Touch Types */
#define TOUCH_TYPE_FINGER_HOVER 0x00
diff --git a/fst2/fts_lib/fts_io.c b/fst2/fts_lib/fts_io.c
index 0e815b9..f7c4fb1 100644
--- a/fst2/fts_lib/fts_io.c
+++ b/fst2/fts_lib/fts_io.c
@@ -660,12 +660,15 @@ void log_info(int force, const char *msg, ...)
|| 1
#endif
) {
+ char log_buffer[120];
va_list args;
- printk("%s", "[ FTS ] ");
+ //printk("%s", "[ FTS ] ");
va_start(args, msg);
- vprintk(msg, args);
+ vscnprintf(log_buffer, sizeof(log_buffer), msg, args);
+ //vprintk(msg, args);
va_end(args);
+ pr_info("%s", log_buffer);
}
}
diff --git a/fst2/fts_lib/fts_io.h b/fst2/fts_lib/fts_io.h
index 9b29e3e..dd254c3 100644
--- a/fst2/fts_lib/fts_io.h
+++ b/fst2/fts_lib/fts_io.h
@@ -19,6 +19,11 @@
#ifndef _LINUX_FTS_IO_H_
#define _LINUX_FTS_IO_H_
+#ifdef pr_fmt
+#undef pr_fmt
+#define pr_fmt(fmt) "[ FTS ] " fmt
+#endif
+
/*#define I2C_INTERFACE*/
#ifdef I2C_INTERFACE
#define I2C_SAD 0x49 /* /< slave address of the IC */
diff --git a/fst2/fts_lib/fts_test.c b/fst2/fts_lib/fts_test.c
index 607a042..08ca8e2 100644
--- a/fst2/fts_lib/fts_test.c
+++ b/fst2/fts_lib/fts_test.c
@@ -230,16 +230,33 @@ int check_limits_map_total(short *data, int row, int column,
void print_frame_i8(char *label, i8 **matrix, int row, int column)
{
int i, j;
+ int buff_len, index;
+ char *buff;
+
+ pr_info("%s\n", label);
+
+ if (matrix == NULL)
+ return;
+
+ buff_len = (4 + 1) * column + 1; /* -128 str len: 4 */
+ buff = kzalloc(buff_len, GFP_KERNEL);
+ if (buff == NULL) {
+ pr_err("%s: fail to allocate buffer\n", __func__);
+ return;
+ }
- log_info(1, "%s\n", label);
for (i = 0; i < row; i++) {
- printk("[ FTS ] ");
+ if (!matrix[i])
+ break;
+ index = 0;
for (j = 0; j < column; j++)
- printk("%d ", matrix[i][j]);
- printk("\n");
+ index += scnprintf(buff + index, buff_len - index,
+ "%d ", matrix[i][j]);
+ pr_info("%s\n", buff);
kfree(matrix[i]);
}
kfree(matrix);
+ kfree(buff);
}
/**
@@ -253,19 +270,38 @@ void print_frame_i8(char *label, i8 **matrix, int row, int column)
void print_frame_short(char *label, short **matrix, int row, int column)
{
int i, j;
+ int buff_len, index;
+ char *buff;
+
+ pr_info("%s\n", label);
+
+ if (matrix == NULL)
+ return;
+
+ buff_len = (6 + 1) * column + 1; /* -32768 str len: 6 */
+ buff = kzalloc(buff_len, GFP_KERNEL);
+ if (buff == NULL) {
+ pr_err("%s: fail to allocate buffer\n", __func__);
+ return;
+ }
- log_info(1, "%s\n", label);
for (i = 0; i < row; i++) {
- printk("[ FTS ] ");
+ if (!matrix[i])
+ break;
+ index = 0;
for (j = 0; j < column; j++)
- printk("%d ", matrix[i][j]);
- printk("\n");
+ index += scnprintf(buff + index, buff_len - index,
+ "%d ", matrix[i][j]);
+ pr_info("%s\n", buff);
+ kfree(matrix[i]);
}
+ kfree(matrix);
+ kfree(buff);
}
/**
* Print in the kernel log a label followed by a matrix of u16 row x columns
- *and free its memory
+ * and free its memory
* @param label pointer to the string to print before the actual matrix
* @param matrix reference to the matrix of u16 which contain the actual data
* @param row number of rows on which the matrix should be print
@@ -274,16 +310,33 @@ void print_frame_short(char *label, short **matrix, int row, int column)
void print_frame_u16(char *label, u16 **matrix, int row, int column)
{
int i, j;
+ int buff_len, index;
+ char *buff;
+
+ pr_info("%s\n", label);
+
+ if (matrix == NULL)
+ return;
+
+ buff_len = (5 + 1) * column + 1; /* 65535 str len: 5 */
+ buff = kzalloc(buff_len, GFP_KERNEL);
+ if (buff == NULL) {
+ pr_err("%s: fail to allocate buffer\n", __func__);
+ return;
+ }
- log_info(1, "%s\n", label);
for (i = 0; i < row; i++) {
- printk("[ FTS ] ");
+ if (!matrix[i])
+ break;
+ index = 0;
for (j = 0; j < column; j++)
- printk("%d ", matrix[i][j]);
- printk("\n");
+ index += scnprintf(buff + index, buff_len - index,
+ "%d ", matrix[i][j]);
+ pr_info("%s\n", buff);
kfree(matrix[i]);
}
kfree(matrix);
+ kfree(buff);
}
/**