summaryrefslogtreecommitdiff
path: root/goodix_ts_proc.c
diff options
context:
space:
mode:
authorSuper Liu <supercjliu@google.com>2023-04-06 05:19:59 +0000
committerSuper Liu <supercjliu@google.com>2023-04-06 08:02:14 +0000
commit8da5744724d93c45251f91a2f09c5420de8da65c (patch)
tree9d21ed3b371727a1e000b8b5fb1e0644c67a4c11 /goodix_ts_proc.c
parenta17332d87e6dd4f008e9575cb2f5a15fffa24fe9 (diff)
downloadgoodix_touch-8da5744724d93c45251f91a2f09c5420de8da65c.tar.gz
Revert^2 "touch/goodix: Import driver v1.2.5"
a17332d87e6dd4f008e9575cb2f5a15fffa24fe9 Change-Id: I6bd8676543a4370522f1df88c676f2075659e12e
Diffstat (limited to 'goodix_ts_proc.c')
-rw-r--r--goodix_ts_proc.c333
1 files changed, 180 insertions, 153 deletions
diff --git a/goodix_ts_proc.c b/goodix_ts_proc.c
index a8ed02f..d2f0082 100644
--- a/goodix_ts_proc.c
+++ b/goodix_ts_proc.c
@@ -52,7 +52,7 @@
#define CMD_SET_FREQ_INDEX "set_freq_index"
#define CMD_DISABLE_FILTER "disable_filter"
-char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST,
+const static char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST,
CMD_SELF_OPEN_TEST, CMD_NOISE_TEST, CMD_AUTO_NOISE_TEST, CMD_SHORT_TEST,
CMD_GET_PACKAGE_ID, CMD_GET_MCU_ID, CMD_GET_VERSION, CMD_GET_RAWDATA,
CMD_GET_DIFFDATA, CMD_GET_BASEDATA, CMD_GET_SELF_RAWDATA,
@@ -90,7 +90,6 @@ char *cmd_list[] = { CMD_FW_UPDATE, CMD_AUTO_TEST, CMD_OPEN_TEST,
#define LARGE_SIZE 5 * 1024
#define MAX_FRAME_CNT 50
#define HUGE_SIZE MAX_FRAME_CNT * 20 * 1024
-static struct goodix_ts_core *cd;
static char wbuf[SHORT_SIZE];
static char *rbuf;
static uint32_t index;
@@ -411,7 +410,7 @@ struct goodix_ts_test {
};
static struct goodix_ts_test *ts_test;
-static int cal_cha_to_cha_res(int v1, int v2)
+static int cal_cha_to_cha_res(struct goodix_ts_core *cd, int v1, int v2)
{
if (cd->bus->ic_type == IC_TYPE_BERLIN_A)
return (v1 - v2) * 63 / v2;
@@ -423,7 +422,7 @@ static int cal_cha_to_cha_res(int v1, int v2)
return (v1 / v2 - 1) * 55 + 45;
}
-static int cal_cha_to_avdd_res(int v1, int v2)
+static int cal_cha_to_avdd_res(struct goodix_ts_core *cd, int v1, int v2)
{
if (cd->bus->ic_type == IC_TYPE_BERLIN_A)
return 64 * (2 * v2 - 25) * 40 / v1 - 40;
@@ -435,7 +434,7 @@ static int cal_cha_to_avdd_res(int v1, int v2)
return 64 * (2 * v2 - 25) * 76 / v1 - 15;
}
-static int cal_cha_to_gnd_res(int v)
+static int cal_cha_to_gnd_res(struct goodix_ts_core *cd, int v)
{
if (cd->bus->ic_type == IC_TYPE_BERLIN_A)
return 64148 / v - 40;
@@ -558,7 +557,7 @@ static void goodix_save_short_res(u16 chn1, u16 chn2, int r)
}
}
-static int gdix_check_tx_tx_shortcircut(u8 short_ch_num)
+static int gdix_check_tx_tx_shortcircut(struct goodix_ts_core *cd, u8 short_ch_num)
{
int ret = 0, err = 0;
u32 r_threshold = 0, short_r = 0;
@@ -615,11 +614,9 @@ static int gdix_check_tx_tx_shortcircut(u8 short_ch_num)
if (adc_signal < ts_test->short_threshold)
continue;
- short_r = (u32)cal_cha_to_cha_res(
- self_capdata, adc_signal);
+ short_r = (u32)cal_cha_to_cha_res(cd, self_capdata, adc_signal);
if (short_r < r_threshold) {
- master_pin_num = map_die2pin(
- short_die_num + max_sen_num);
+ master_pin_num = map_die2pin(short_die_num + max_sen_num);
slave_pin_num = map_die2pin(j + max_sen_num);
if (master_pin_num == 0xFF ||
slave_pin_num == 0xFF) {
@@ -649,7 +646,7 @@ static int gdix_check_tx_tx_shortcircut(u8 short_ch_num)
return err;
}
-static int gdix_check_rx_rx_shortcircut(u8 short_ch_num)
+static int gdix_check_rx_rx_shortcircut(struct goodix_ts_core *cd, u8 short_ch_num)
{
int ret = 0, err = 0;
u32 r_threshold = 0, short_r = 0;
@@ -703,8 +700,7 @@ static int gdix_check_rx_rx_shortcircut(u8 short_ch_num)
if (adc_signal < ts_test->short_threshold)
continue;
- short_r = (u32)cal_cha_to_cha_res(
- self_capdata, adc_signal);
+ short_r = (u32)cal_cha_to_cha_res(cd, self_capdata, adc_signal);
if (short_r < r_threshold) {
master_pin_num = map_die2pin(short_die_num);
slave_pin_num = map_die2pin(j);
@@ -736,7 +732,7 @@ static int gdix_check_rx_rx_shortcircut(u8 short_ch_num)
return err;
}
-static int gdix_check_tx_rx_shortcircut(u8 short_ch_num)
+static int gdix_check_tx_rx_shortcircut(struct goodix_ts_core *cd, u8 short_ch_num)
{
int ret = 0, err = 0;
u32 r_threshold = 0, short_r = 0;
@@ -791,8 +787,7 @@ static int gdix_check_tx_rx_shortcircut(u8 short_ch_num)
if (adc_signal < ts_test->short_threshold)
continue;
- short_r = (u32)cal_cha_to_cha_res(
- self_capdata, adc_signal);
+ short_r = (u32)cal_cha_to_cha_res(cd, self_capdata, adc_signal);
if (short_r < r_threshold) {
master_pin_num = map_die2pin(short_die_num);
slave_pin_num = map_die2pin(j + max_sen_num);
@@ -824,7 +819,7 @@ static int gdix_check_tx_rx_shortcircut(u8 short_ch_num)
return err;
}
-static int gdix_check_resistance_to_gnd(u16 adc_signal, u32 pos)
+static int gdix_check_resistance_to_gnd(struct goodix_ts_core *cd, u16 adc_signal, u32 pos)
{
long r = 0;
u16 r_th = 0, avdd_value = 0;
@@ -842,10 +837,10 @@ static int gdix_check_resistance_to_gnd(u16 adc_signal, u32 pos)
if (short_type == 0) {
/* short to GND */
- r = cal_cha_to_gnd_res(adc_signal);
+ r = cal_cha_to_gnd_res(cd, adc_signal);
} else {
/* short to VDD */
- r = cal_cha_to_avdd_res(adc_signal, avdd_value);
+ r = cal_cha_to_avdd_res(cd, adc_signal, avdd_value);
}
if (pos < max_drv_num)
@@ -874,7 +869,7 @@ static int gdix_check_resistance_to_gnd(u16 adc_signal, u32 pos)
return 0;
}
-static int gdix_check_gndvdd_shortcircut(void)
+static int gdix_check_gndvdd_shortcircut(struct goodix_ts_core *cd)
{
int ret = 0, err = 0;
int size = 0, i = 0;
@@ -907,7 +902,7 @@ static int gdix_check_gndvdd_shortcircut(void)
for (i = 0; i < max_drv_num + max_sen_num; i++) {
adc_signal = le16_to_cpup((__le16 *)&data_buf[i * 2]);
- ret = gdix_check_resistance_to_gnd(adc_signal, i);
+ ret = gdix_check_resistance_to_gnd(cd, adc_signal, i);
if (ret != 0) {
ts_err("Resistance to-gnd/vdd short");
err = ret;
@@ -922,7 +917,7 @@ err_out:
#define NOTT_CHECKSUM_LEN 54
#define BRLD_CHECKSUM_LEN 62
#define BRLB_CHECKSUM_LEN 129
-static int goodix_shortcircut_analysis(void)
+static int goodix_shortcircut_analysis(struct goodix_ts_core *cd)
{
int ret;
int err = 0;
@@ -963,13 +958,13 @@ static int goodix_shortcircut_analysis(void)
test_result.drv_gnd_avdd_num, test_result.sen_gnd_avdd_num);
if (test_result.drv_drv_num)
- err |= gdix_check_tx_tx_shortcircut(test_result.drv_drv_num);
+ err |= gdix_check_tx_tx_shortcircut(cd, test_result.drv_drv_num);
if (test_result.sen_sen_num)
- err |= gdix_check_rx_rx_shortcircut(test_result.sen_sen_num);
+ err |= gdix_check_rx_rx_shortcircut(cd, test_result.sen_sen_num);
if (test_result.drv_sen_num)
- err |= gdix_check_tx_rx_shortcircut(test_result.drv_sen_num);
+ err |= gdix_check_tx_rx_shortcircut(cd, test_result.drv_sen_num);
if (test_result.drv_gnd_avdd_num || test_result.sen_gnd_avdd_num)
- err |= gdix_check_gndvdd_shortcircut();
+ err |= gdix_check_gndvdd_shortcircut(cd);
ts_info(">>>>> short check return 0x%x", err);
@@ -979,7 +974,7 @@ static int goodix_shortcircut_analysis(void)
#define INSPECT_FW_SWITCH_CMD 0x85
#define SHORT_TEST_RUN_FLAG 0xAA
#define SHORT_TEST_RUN_REG 0x10400
-static int goodix_short_test_prepare(void)
+static int goodix_short_test_prepare(struct goodix_ts_core *cd)
{
struct goodix_ts_cmd tmp_cmd;
int ret;
@@ -1018,7 +1013,7 @@ resend_cmd:
#define MAX_TEST_TIME_MS 15000
#define DEFAULT_TEST_TIME_MS 7000
#define SHORT_TEST_FINISH_FLAG 0x88
-static int goodix_shortcircut_test(void)
+static int goodix_shortcircut_test(struct goodix_ts_core *cd)
{
int ret = 0;
int res;
@@ -1027,7 +1022,7 @@ static int goodix_shortcircut_test(void)
u8 status;
ts_info("---------------------- short_test begin ----------------------");
- ret = goodix_short_test_prepare();
+ ret = goodix_short_test_prepare(cd);
if (ret < 0) {
ts_err("Failed enter short test mode");
return ret;
@@ -1071,7 +1066,7 @@ static int goodix_shortcircut_test(void)
/* start analysis short result */
ts_info("short_test finished, start analysis");
- res = goodix_shortcircut_analysis();
+ res = goodix_shortcircut_analysis(cd);
if (res == 0) {
ts_test->result[GTP_SHORT_TEST] = TEST_OK;
ret = 0;
@@ -1093,7 +1088,8 @@ typedef struct __attribute__((packed)) {
#define FLASH_CMD_STATE_CHECKERR 0x05
#define FLASH_CMD_STATE_DENY 0x06
#define FLASH_CMD_STATE_OKAY 0x07
-static int goodix_flash_cmd(uint8_t cmd, uint8_t status, int retry_count)
+static int goodix_flash_cmd(struct goodix_ts_core *cd,
+ uint8_t cmd, uint8_t status, int retry_count)
{
u8 cmd_buf[] = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x00 };
int ret;
@@ -1122,7 +1118,7 @@ static int goodix_flash_cmd(uint8_t cmd, uint8_t status, int retry_count)
return -EINVAL;
}
-static int goodix_flash_read(u32 addr, u8 *buf, int len)
+static int goodix_flash_read(struct goodix_ts_core *cd, u32 addr, u8 *buf, int len)
{
int i;
int ret;
@@ -1142,7 +1138,7 @@ static int goodix_flash_read(u32 addr, u8 *buf, int len)
checksum += p[i] | (p[i + 1] << 8);
head_info.checksum = checksum;
- ret = goodix_flash_cmd(FLASH_CMD_R_START, FLASH_CMD_STATE_READY, 15);
+ ret = goodix_flash_cmd(cd, FLASH_CMD_R_START, FLASH_CMD_STATE_READY, 15);
if (ret < 0) {
ts_err("failed enter flash read state");
goto read_end;
@@ -1155,7 +1151,7 @@ static int goodix_flash_read(u32 addr, u8 *buf, int len)
goto read_end;
}
- ret = goodix_flash_cmd(FLASH_CMD_RW_FINISH, FLASH_CMD_STATE_OKAY, 50);
+ ret = goodix_flash_cmd(cd, FLASH_CMD_RW_FINISH, FLASH_CMD_STATE_OKAY, 50);
if (ret) {
ts_err("faild read flash ready state");
goto read_end;
@@ -1182,7 +1178,7 @@ static int goodix_flash_read(u32 addr, u8 *buf, int len)
memcpy(buf, tmp_buf + sizeof(flash_head_info_t), len);
ret = 0;
read_end:
- goodix_flash_cmd(0x0C, 0, 0);
+ goodix_flash_cmd(cd, 0x0C, 0, 0);
return ret;
}
@@ -1223,15 +1219,27 @@ static const struct seq_operations seq_ops = {
static int driver_test_open(struct inode *inode, struct file *file)
{
- return seq_open(file, &seq_ops);
+ struct seq_file *seq_file;
+ int ret;
+
+ ret = seq_open(file, &seq_ops);
+ if (ret)
+ return ret;
+ seq_file = (struct seq_file *)file->private_data;
+ if (seq_file)
+ seq_file->private = PDE_DATA(inode);
+
+ mutex_lock(&goodix_devices.mutex);
+ return 0;
}
static int driver_test_release(struct inode *inode, struct file *file)
{
+ mutex_unlock(&goodix_devices.mutex);
return seq_release(inode, file);
}
-static void goodix_save_header(void)
+static void goodix_save_header(struct goodix_ts_core *cd)
{
int i;
bool total_result = true;
@@ -1465,7 +1473,7 @@ static void goodix_data_cal(s16 *data, size_t data_size, s16 *stat_result)
stat_result[2] = min;
}
-static void goodix_save_data(void)
+static void goodix_save_data(struct goodix_ts_core *cd)
{
int tx = cd->ic_info.parm.drv_num;
int rx = cd->ic_info.parm.sen_num;
@@ -1553,12 +1561,12 @@ static void goodix_save_data(void)
index += sprintf(&rbuf[index], "</DataRecord>\n");
}
-static void goodix_save_tail(void)
+static void goodix_save_tail(struct goodix_ts_core *cd)
{
index += sprintf(&rbuf[index], "</TESTLOG>\n");
}
-static void goodix_save_test_result(bool is_brief)
+static void goodix_save_test_result(struct goodix_ts_core *cd, bool is_brief)
{
if (is_brief) {
if (ts_test->item[GTP_CAP_TEST]) {
@@ -1592,9 +1600,9 @@ static void goodix_save_test_result(bool is_brief)
: "FAIL");
}
} else {
- goodix_save_header();
- goodix_save_data();
- goodix_save_tail();
+ goodix_save_header(cd);
+ goodix_save_data(cd);
+ goodix_save_tail(cd);
}
}
@@ -1724,7 +1732,7 @@ static int parse_csvfile(
return parse_valid_data(buf, size, ptr, data, rows);
}
-static int goodix_obtain_testlimits(void)
+static int goodix_obtain_testlimits(struct goodix_ts_core *cd)
{
const struct firmware *firmware = NULL;
struct device *dev = &cd->pdev->dev;
@@ -1847,7 +1855,7 @@ exit_free:
return ret;
}
-static int goodix_delta_test(void)
+static int goodix_delta_test(struct goodix_ts_core *cd)
{
int i, j;
int max_val;
@@ -1899,7 +1907,7 @@ static int goodix_delta_test(void)
return ret;
}
-static int goodix_open_test(void)
+static int goodix_open_test(struct goodix_ts_core *cd)
{
u8 *tmp_buf;
struct goodix_ts_cmd temp_cmd;
@@ -1999,7 +2007,7 @@ static int goodix_open_test(void)
ts_test->result[GTP_CAP_TEST] = TEST_NG;
}
- if (goodix_delta_test() == 0)
+ if (goodix_delta_test(cd) == 0)
ts_test->result[GTP_DELTA_TEST] = TEST_OK;
exit:
@@ -2007,7 +2015,7 @@ exit:
return ret;
}
-static int goodix_self_open_test(void)
+static int goodix_self_open_test(struct goodix_ts_core *cd)
{
u8 *tmp_buf;
struct goodix_ts_cmd temp_cmd;
@@ -2085,7 +2093,7 @@ exit:
return ret;
}
-static int goodix_noise_test(void)
+static int goodix_noise_test(struct goodix_ts_core *cd)
{
u8 *tmp_buf;
struct goodix_ts_cmd temp_cmd;
@@ -2168,19 +2176,19 @@ exit:
return ret;
}
-static int goodix_auto_test(bool is_brief)
+static int goodix_auto_test(struct goodix_ts_core *cd, bool is_brief)
{
struct goodix_ts_cmd temp_cmd;
int ret;
- ret = goodix_obtain_testlimits();
+ ret = goodix_obtain_testlimits(cd);
if (ret < 0) {
ts_err("obtain open test limits failed");
return ret;
}
cd->hw_ops->irq_enable(cd, false);
- goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
+ goodix_ts_esd_off(cd);
temp_cmd.len = 5;
temp_cmd.cmd = 0x64;
@@ -2190,7 +2198,7 @@ static int goodix_auto_test(bool is_brief)
ret = cd->hw_ops->send_cmd(cd, &temp_cmd);
if (ret < 0)
ts_err("enter test mode failed");
- goodix_open_test();
+ goodix_open_test(cd);
cd->hw_ops->reset(cd, 100);
}
@@ -2198,27 +2206,27 @@ static int goodix_auto_test(bool is_brief)
ret = cd->hw_ops->send_cmd(cd, &temp_cmd);
if (ret < 0)
ts_err("enter test mode failed");
- goodix_noise_test();
+ goodix_noise_test(cd);
cd->hw_ops->reset(cd, 100);
}
if (ts_test->item[GTP_SELFCAP_TEST]) {
- goodix_self_open_test();
+ goodix_self_open_test(cd);
cd->hw_ops->reset(cd, 100);
}
if (ts_test->item[GTP_SHORT_TEST]) {
- goodix_shortcircut_test();
+ goodix_shortcircut_test(cd);
cd->hw_ops->reset(cd, 100);
}
cd->hw_ops->irq_enable(cd, true);
- goodix_ts_blocking_notify(NOTIFY_ESD_ON, NULL);
- goodix_save_test_result(is_brief);
+ goodix_ts_esd_on(cd);
+ goodix_save_test_result(cd, is_brief);
return 0;
}
-static void goodix_auto_noise_test(u16 cnt, int threshold)
+static void goodix_auto_noise_test(struct goodix_ts_core *cd, u16 cnt, int threshold)
{
struct goodix_ts_cmd temp_cmd;
struct goodix_ts_cmd rb_cmd;
@@ -2245,7 +2253,7 @@ static void goodix_auto_noise_test(u16 cnt, int threshold)
8;
cd->hw_ops->irq_enable(cd, false);
- goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
+ goodix_ts_esd_off(cd);
restart:
temp_cmd.len = 0x07;
@@ -2325,10 +2333,10 @@ exit:
}
kfree(tmp_buf);
cd->hw_ops->irq_enable(cd, true);
- goodix_ts_blocking_notify(NOTIFY_ESD_ON, NULL);
+ goodix_ts_esd_on(cd);
}
-static int get_cap_data(uint8_t *type)
+static int get_cap_data(struct goodix_ts_core *cd, uint8_t *type)
{
struct goodix_ts_cmd temp_cmd;
int tx = cd->ic_info.parm.drv_num;
@@ -2362,7 +2370,7 @@ static int get_cap_data(uint8_t *type)
/* disable irq & close esd */
cd->hw_ops->irq_enable(cd, false);
- goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
+ goodix_ts_esd_off(cd);
if (strstr(type, CMD_GET_BASEDATA) ||
strstr(type, CMD_GET_SELF_BASEDATA)) {
@@ -2453,11 +2461,11 @@ exit:
cd->hw_ops->send_cmd(cd, &temp_cmd);
/* enable irq & esd */
cd->hw_ops->irq_enable(cd, true);
- goodix_ts_blocking_notify(NOTIFY_ESD_ON, NULL);
+ goodix_ts_esd_on(cd);
return ret;
}
-static void goodix_set_sense_mode(u8 val)
+static void goodix_set_sense_mode(struct goodix_ts_core *cd, u8 val)
{
struct goodix_ts_cmd temp_cmd;
@@ -2468,26 +2476,26 @@ static void goodix_set_sense_mode(u8 val)
/* normal mode */
index = sprintf(rbuf, "switch to coordinate mode\n");
cd->hw_ops->send_cmd(cd, &temp_cmd);
- goodix_ts_blocking_notify(NOTIFY_ESD_ON, NULL);
+ goodix_ts_esd_on(cd);
cd->hw_ops->irq_enable(cd, true);
atomic_set(&cd->suspended, 0);
} else if (val == 2) {
/* gesture mode */
index = sprintf(rbuf, "switch to gesture mode\n");
- goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
+ goodix_ts_esd_off(cd);
cd->hw_ops->gesture(cd, 0);
cd->hw_ops->irq_enable(cd, true);
atomic_set(&cd->suspended, 1);
} else {
/* sleep mode */
index = sprintf(rbuf, "switch to sleep mode\n");
- goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
+ goodix_ts_esd_off(cd);
cd->hw_ops->irq_enable(cd, false);
cd->hw_ops->suspend(cd);
}
}
-static void goodix_set_scan_mode(u8 val)
+static void goodix_set_scan_mode(struct goodix_ts_core *cd, u8 val)
{
struct goodix_ts_cmd temp_cmd;
@@ -2511,7 +2519,7 @@ static void goodix_set_scan_mode(u8 val)
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
-static void goodix_get_scan_mode(void)
+static void goodix_get_scan_mode(struct goodix_ts_core *cd)
{
u8 status;
@@ -2533,7 +2541,7 @@ static void goodix_get_scan_mode(void)
}
}
-static void goodix_set_continue_mode(u8 val)
+static void goodix_set_continue_mode(struct goodix_ts_core *cd, u8 val)
{
struct goodix_ts_cmd temp_cmd;
@@ -2551,7 +2559,7 @@ static void goodix_set_continue_mode(u8 val)
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
-static void goodix_read_config(void)
+static void goodix_read_config(struct goodix_ts_core *cd)
{
int ret;
u8 *cfg_buf;
@@ -2579,7 +2587,7 @@ exit:
kfree(cfg_buf);
}
-static void goodix_get_fw_status(void)
+static void goodix_get_fw_status(struct goodix_ts_core *cd)
{
u32 status_addr;
u32 noise_lv_addr;
@@ -2626,7 +2634,7 @@ static void goodix_get_fw_status(void)
index += sprintf(&rbuf[index], "noise-lv[%d]\n", val);
}
-static void goodix_set_highsense_mode(u8 val)
+static void goodix_set_highsense_mode(struct goodix_ts_core *cd, u8 val)
{
struct goodix_ts_cmd temp_cmd;
static bool flag = false;
@@ -2650,7 +2658,7 @@ static void goodix_set_highsense_mode(u8 val)
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
-static void goodix_set_grip_data(u8 val)
+static void goodix_set_grip_data(struct goodix_ts_core *cd, u8 val)
{
struct goodix_ts_cmd temp_cmd;
@@ -2679,7 +2687,7 @@ static void goodix_set_grip_data(u8 val)
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
-static void goodix_set_custom_mode(u8 type, u8 val)
+static void goodix_set_custom_mode(struct goodix_ts_core *cd, u8 type, u8 val)
{
struct goodix_ts_cmd temp_cmd;
@@ -2731,7 +2739,7 @@ static int obtain_param(char **buf)
return val;
}
-static int goodix_parse_gesture_param(u8 type, char **buf)
+static int goodix_parse_gesture_param(struct goodix_ts_core *cd, u8 type, char **buf)
{
if (type == GESTURE_STTW) {
gesture_param_st.length = sizeof(gesture_param_st);
@@ -2823,7 +2831,7 @@ static int goodix_parse_gesture_param(u8 type, char **buf)
return 0;
}
-static void goodix_set_gesture_param(u8 type)
+static void goodix_set_gesture_param(struct goodix_ts_core *cd, u8 type)
{
struct goodix_ts_cmd temp_cmd;
u32 cmd_reg = cd->ic_info.misc.cmd_addr;
@@ -2887,18 +2895,29 @@ exit:
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
-static void goodix_set_heatmap(int val)
+static void goodix_set_heatmap(struct goodix_ts_core *cd, int val)
{
struct goodix_ts_cmd temp_cmd;
cd->hw_ops->irq_enable(cd, false);
if (val == 0) {
index = sprintf(rbuf, "disable heatmap\n");
+/*
+ * [GOOG]
+ * Use goodix_update_heatmap() to do the heatmap process.
+ kfree(cd->heatmap_buffer);
+ cd->heatmap_buffer = NULL;
+ */
temp_cmd.len = 5;
temp_cmd.cmd = 0xC9;
temp_cmd.data[0] = 0;
} else {
index = sprintf(rbuf, "enable heatmap\n");
+/*
+ * [GOOG]
+ * Use goodix_update_heatmap() to do the heatmap process.
+ cd->heatmap_buffer = kzalloc(GOODIX_MAX_FRAMEDATA_LEN, GFP_KERNEL);
+ */
temp_cmd.len = 5;
temp_cmd.cmd = 0xC9;
temp_cmd.data[0] = 1;
@@ -2907,7 +2926,7 @@ static void goodix_set_heatmap(int val)
cd->hw_ops->irq_enable(cd, true);
}
-static void goodix_get_self_compensation(void)
+static void goodix_get_self_compensation(struct goodix_ts_core *cd)
{
u8 *cfg;
u8 *cfg_buf;
@@ -2962,7 +2981,7 @@ exit:
kfree(cfg_buf);
}
-static void goodix_set_report_rate(int rate)
+static void goodix_set_report_rate(struct goodix_ts_core *cd, int rate)
{
struct goodix_ts_cmd temp_cmd;
@@ -2975,12 +2994,12 @@ static void goodix_set_report_rate(int rate)
}
#define DUMP_AREA1_ADDR 0x10194
-#define DUMP_AREA1_LEN 132
+#define DUMP_AREA1_LEN 132
#define DUMP_AREA2_ADDR 0x10400
-#define DUMP_AREA2_LEN 596
+#define DUMP_AREA2_LEN 596
#define DUMP_AREA3_ADDR 0x10308
-#define DUMP_AREA3_LEN 64
-static void goodix_get_dump_log(void)
+#define DUMP_AREA3_LEN 64
+static void goodix_get_dump_log(struct goodix_ts_core *cd)
{
u8 buf[600];
int i;
@@ -3010,7 +3029,7 @@ static void goodix_get_dump_log(void)
}
}
-static void goodix_get_stylus_data(void)
+static void goodix_get_stylus_data(struct goodix_ts_core *cd)
{
struct goodix_stylus_data stylus_data;
u8 temp_buf[40] = { 0 };
@@ -3035,7 +3054,7 @@ static void goodix_get_stylus_data(void)
/* disable irq & close esd */
cd->hw_ops->irq_enable(cd, false);
- goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
+ goodix_ts_esd_off(cd);
/* clean touch event flag */
ret = cd->hw_ops->write(cd, flag_addr, temp_buf, 1);
@@ -3126,10 +3145,10 @@ static void goodix_get_stylus_data(void)
exit:
/* enable irq & esd */
cd->hw_ops->irq_enable(cd, true);
- goodix_ts_blocking_notify(NOTIFY_ESD_ON, NULL);
+ goodix_ts_esd_on(cd);
}
-static void goodix_force_update(void)
+static void goodix_force_update(struct goodix_ts_core *cd)
{
int i;
int ret;
@@ -3143,7 +3162,7 @@ static void goodix_force_update(void)
if (ret < 0)
ts_err("not found valid config");
- ret = goodix_do_fw_update(cd->ic_configs[CONFIG_TYPE_NORMAL],
+ ret = goodix_do_fw_update(cd,
UPDATE_MODE_BLOCK | UPDATE_MODE_FORCE |
UPDATE_MODE_SRC_REQUEST);
if (ret < 0)
@@ -3152,7 +3171,7 @@ static void goodix_force_update(void)
index = sprintf(rbuf, "%s: OK\n", CMD_FW_UPDATE);
}
-static void goodix_set_freq_index(int freq)
+static void goodix_set_freq_index(struct goodix_ts_core *cd, int freq)
{
struct goodix_ts_cmd temp_cmd;
@@ -3164,7 +3183,7 @@ static void goodix_set_freq_index(int freq)
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
-static void goodix_disable_coor_filter(int val)
+static void goodix_disable_coor_filter(struct goodix_ts_core *cd, int val)
{
struct goodix_ts_cmd temp_cmd;
@@ -3175,9 +3194,11 @@ static void goodix_disable_coor_filter(int val)
cd->hw_ops->send_cmd(cd, &temp_cmd);
}
-static ssize_t driver_test_write(
- struct file *file, const char __user *buf, size_t count, loff_t *pos)
+static ssize_t driver_test_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
{
+ struct seq_file *seq_file = (struct seq_file *)file->private_data;
+ struct goodix_ts_core *cd = (struct goodix_ts_core *)seq_file->private;
struct goodix_fw_version fw_ver;
struct goodix_ic_info ic_info;
char *p = wbuf;
@@ -3197,6 +3218,7 @@ static ssize_t driver_test_write(
ts_err("copy from user failed");
return count;
}
+ p[strlen(p) - 1] = 0;
vfree(rbuf);
rbuf = NULL;
@@ -3207,7 +3229,7 @@ static ssize_t driver_test_write(
if (!strncmp(p, CMD_FW_UPDATE, strlen(CMD_FW_UPDATE))) {
rbuf = vzalloc(SHORT_SIZE);
- goodix_force_update();
+ goodix_force_update(cd);
goto exit;
}
@@ -3232,7 +3254,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- ret = get_cap_data(CMD_GET_RAWDATA);
+ ret = get_cap_data(cd, CMD_GET_RAWDATA);
if (ret < 0) {
index = sprintf(rbuf, "%s: NG\n", CMD_GET_RAWDATA);
}
@@ -3245,7 +3267,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- ret = get_cap_data(CMD_GET_BASEDATA);
+ ret = get_cap_data(cd, CMD_GET_BASEDATA);
if (ret < 0) {
index = sprintf(rbuf, "%s: NG\n", CMD_GET_BASEDATA);
}
@@ -3258,7 +3280,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- ret = get_cap_data(CMD_GET_DIFFDATA);
+ ret = get_cap_data(cd, CMD_GET_DIFFDATA);
if (ret < 0) {
index = sprintf(rbuf, "%s: NG\n", CMD_GET_DIFFDATA);
}
@@ -3271,7 +3293,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- ret = get_cap_data(CMD_GET_SELF_RAWDATA);
+ ret = get_cap_data(cd, CMD_GET_SELF_RAWDATA);
if (ret < 0) {
index = sprintf(rbuf, "%s: NG\n", CMD_GET_SELF_RAWDATA);
}
@@ -3284,7 +3306,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- ret = get_cap_data(CMD_GET_SELF_DIFFDATA);
+ ret = get_cap_data(cd, CMD_GET_SELF_DIFFDATA);
if (ret < 0) {
index = sprintf(
rbuf, "%s: NG\n", CMD_GET_SELF_DIFFDATA);
@@ -3298,7 +3320,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- ret = get_cap_data(CMD_GET_SELF_BASEDATA);
+ ret = get_cap_data(cd, CMD_GET_SELF_BASEDATA);
if (ret < 0) {
index = sprintf(
rbuf, "%s: NG\n", CMD_GET_SELF_BASEDATA);
@@ -3446,11 +3468,11 @@ static ssize_t driver_test_write(
goto exit;
}
if (cmd_val == 0) {
- goodix_ts_blocking_notify(NOTIFY_ESD_OFF, NULL);
+ goodix_ts_esd_off(cd);
index = sprintf(
rbuf, "%s: disable OK\n", CMD_SET_ESD_ENABLE);
} else {
- goodix_ts_blocking_notify(NOTIFY_ESD_ON, NULL);
+ goodix_ts_esd_on(cd);
index = sprintf(
rbuf, "%s: enable OK\n", CMD_SET_ESD_ENABLE);
}
@@ -3504,7 +3526,7 @@ static ssize_t driver_test_write(
ts_test->item[GTP_DELTA_TEST] = true;
ts_test->item[GTP_SELFCAP_TEST] = true;
ts_test->item[GTP_SHORT_TEST] = true;
- goodix_auto_test(true);
+ goodix_auto_test(cd, true);
goto exit;
}
@@ -3525,7 +3547,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- ret = get_cap_data(CMD_GET_TX_FREQ);
+ ret = get_cap_data(cd, CMD_GET_TX_FREQ);
if (ret < 0) {
index = sprintf(rbuf, "%s: NG\n", CMD_GET_TX_FREQ);
}
@@ -3561,7 +3583,7 @@ static ssize_t driver_test_write(
CMD_SET_SENSE_MODE);
goto exit;
}
- goodix_set_sense_mode(cmd_val);
+ goodix_set_sense_mode(cd, cmd_val);
goto exit;
}
@@ -3587,7 +3609,7 @@ static ssize_t driver_test_write(
goto exit;
}
ts_test->item[GTP_NOISE_TEST] = true;
- goodix_auto_test(false);
+ goodix_auto_test(cd, false);
goto exit;
}
@@ -3615,7 +3637,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- goodix_auto_noise_test(cmd_val, cmd_val2);
+ goodix_auto_noise_test(cd, cmd_val, cmd_val2);
goto exit;
}
@@ -3627,7 +3649,7 @@ static ssize_t driver_test_write(
}
mutex_lock(&cd->cmd_lock);
usleep_range(6000, 6100);
- ret = goodix_flash_read(0x1F301, &id, 1);
+ ret = goodix_flash_read(cd, 0x1F301, &id, 1);
mutex_unlock(&cd->cmd_lock);
if (ret < 0)
index = sprintf(rbuf, "%s: NG\n", CMD_GET_PACKAGE_ID);
@@ -3645,7 +3667,7 @@ static ssize_t driver_test_write(
}
mutex_lock(&cd->cmd_lock);
usleep_range(6000, 6100);
- ret = goodix_flash_read(0x1F314, &id, 1);
+ ret = goodix_flash_read(cd, 0x1F314, &id, 1);
mutex_unlock(&cd->cmd_lock);
if (ret < 0)
index = sprintf(rbuf, "%s: NG\n", CMD_GET_MCU_ID);
@@ -3676,7 +3698,7 @@ static ssize_t driver_test_write(
CMD_SET_SCAN_MODE);
goto exit;
}
- goodix_set_scan_mode(cmd_val);
+ goodix_set_scan_mode(cd, cmd_val);
goto exit;
}
@@ -3686,7 +3708,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- goodix_get_scan_mode();
+ goodix_get_scan_mode(cd);
goto exit;
}
@@ -3712,7 +3734,7 @@ static ssize_t driver_test_write(
CMD_SET_CONTINUE_MODE);
goto exit;
}
- goodix_set_continue_mode(cmd_val);
+ goodix_set_continue_mode(cd, cmd_val);
goto exit;
}
@@ -3749,7 +3771,7 @@ static ssize_t driver_test_write(
}
ts_test->item[GTP_CAP_TEST] = true;
ts_test->freq = cmd_val2;
- goodix_auto_test(false);
+ goodix_auto_test(cd, false);
goto exit;
}
@@ -3765,7 +3787,7 @@ static ssize_t driver_test_write(
goto exit;
}
ts_test->item[GTP_SELFCAP_TEST] = true;
- goodix_auto_test(false);
+ goodix_auto_test(cd, false);
goto exit;
}
@@ -3781,7 +3803,7 @@ static ssize_t driver_test_write(
goto exit;
}
ts_test->item[GTP_SHORT_TEST] = true;
- goodix_auto_test(false);
+ goodix_auto_test(cd, false);
goto exit;
}
@@ -3791,7 +3813,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- goodix_read_config();
+ goodix_read_config(cd);
goto exit;
}
@@ -3801,7 +3823,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- goodix_get_fw_status();
+ goodix_get_fw_status(cd);
goto exit;
}
@@ -3828,7 +3850,7 @@ static ssize_t driver_test_write(
CMD_SET_HIGHSENSE_MODE);
goto exit;
}
- goodix_set_highsense_mode(cmd_val);
+ goodix_set_highsense_mode(cd, cmd_val);
goto exit;
}
@@ -3849,7 +3871,7 @@ static ssize_t driver_test_write(
CMD_SET_GRIP_DATA);
goto exit;
}
- goodix_set_grip_data(cmd_val);
+ goodix_set_grip_data(cd, cmd_val);
goto exit;
}
@@ -3870,7 +3892,7 @@ static ssize_t driver_test_write(
CMD_SET_GRIP_MODE);
goto exit;
}
- goodix_set_custom_mode(GRIP_FUNC, cmd_val);
+ goodix_set_custom_mode(cd, GRIP_FUNC, cmd_val);
goto exit;
}
@@ -3891,7 +3913,7 @@ static ssize_t driver_test_write(
CMD_SET_PALM_MODE);
goto exit;
}
- goodix_set_custom_mode(PALM_FUNC, cmd_val);
+ goodix_set_custom_mode(cd, PALM_FUNC, cmd_val);
goto exit;
}
@@ -3912,7 +3934,7 @@ static ssize_t driver_test_write(
CMD_SET_NOISE_MODE);
goto exit;
}
- goodix_set_custom_mode(NOISE_FUNC, cmd_val);
+ goodix_set_custom_mode(cd, NOISE_FUNC, cmd_val);
goto exit;
}
@@ -3933,7 +3955,7 @@ static ssize_t driver_test_write(
CMD_SET_WATER_MODE);
goto exit;
}
- goodix_set_custom_mode(WATER_FUNC, cmd_val);
+ goodix_set_custom_mode(cd, WATER_FUNC, cmd_val);
goto exit;
}
@@ -3949,8 +3971,8 @@ static ssize_t driver_test_write(
CMD_SET_ST_PARAM);
goto exit;
}
- goodix_parse_gesture_param(GESTURE_STTW, &p);
- goodix_set_gesture_param(GESTURE_STTW);
+ goodix_parse_gesture_param(cd, GESTURE_STTW, &p);
+ goodix_set_gesture_param(cd, GESTURE_STTW);
goto exit;
}
@@ -3966,8 +3988,8 @@ static ssize_t driver_test_write(
CMD_SET_LP_PARAM);
goto exit;
}
- goodix_parse_gesture_param(GESTURE_LPTW, &p);
- goodix_set_gesture_param(GESTURE_LPTW);
+ goodix_parse_gesture_param(cd, GESTURE_LPTW, &p);
+ goodix_set_gesture_param(cd, GESTURE_LPTW);
goto exit;
}
@@ -3988,7 +4010,7 @@ static ssize_t driver_test_write(
CMD_SET_HEATMAP);
goto exit;
}
- goodix_set_heatmap(cmd_val);
+ goodix_set_heatmap(cd, cmd_val);
goto exit;
}
@@ -3998,7 +4020,7 @@ static ssize_t driver_test_write(
ts_err("failed to alloc rbuf");
goto exit;
}
- goodix_get_self_compensation();
+ goodix_get_self_compensation(cd);
goto exit;
}
@@ -4019,25 +4041,27 @@ static ssize_t driver_test_write(
CMD_SET_REPORT_RATE);
goto exit;
}
- goodix_set_report_rate(cmd_val);
+ goodix_set_report_rate(cd, cmd_val);
goto exit;
}
if (!strncmp(p, CMD_GET_DUMP_LOG, strlen(CMD_GET_DUMP_LOG))) {
rbuf = vzalloc(LARGE_SIZE);
- goodix_get_dump_log();
- goto exit;
- }
- if (!strncmp(p, CMD_GET_STYLUS_DATA, strlen(CMD_GET_STYLUS_DATA))) {
- rbuf = vzalloc(LARGE_SIZE);
- goodix_get_stylus_data();
+ if (!rbuf) {
+ ts_err("failed to alloc rbuf");
+ goto exit;
+ }
+ goodix_get_dump_log(cd);
goto exit;
}
-
if (!strncmp(p, CMD_GET_STYLUS_DATA, strlen(CMD_GET_STYLUS_DATA))) {
rbuf = vzalloc(LARGE_SIZE);
- goodix_get_stylus_data();
+ if (!rbuf) {
+ ts_err("failed to alloc rbuf");
+ goto exit;
+ }
+ goodix_get_stylus_data(cd);
goto exit;
}
@@ -4054,7 +4078,7 @@ static ssize_t driver_test_write(
CMD_SET_FREQ_INDEX);
goto exit;
}
- goodix_set_freq_index(cmd_val);
+ goodix_set_freq_index(cd, cmd_val);
goto exit;
}
@@ -4071,7 +4095,7 @@ static ssize_t driver_test_write(
CMD_DISABLE_FILTER);
goto exit;
}
- goodix_disable_coor_filter(cmd_val);
+ goodix_disable_coor_filter(cd, cmd_val);
goto exit;
}
@@ -4138,7 +4162,8 @@ static const struct file_operations cmd_list_ops = {
};
#endif
-int driver_test_selftest(char* buf)
+/* [GOOG] */
+int driver_test_selftest(struct goodix_ts_core *cd, char *buf)
{
int ret = 0;
@@ -4167,7 +4192,7 @@ int driver_test_selftest(char* buf)
ts_test->item[GTP_DELTA_TEST] = true;
ts_test->item[GTP_SELFCAP_TEST] = true;
ts_test->item[GTP_SHORT_TEST] = true;
- goodix_auto_test(true);
+ goodix_auto_test(cd, true);
strlcpy(buf, rbuf, PAGE_SIZE);
@@ -4179,22 +4204,24 @@ int driver_test_proc_init(struct goodix_ts_core *core_data)
{
struct proc_dir_entry *proc_entry;
- proc_entry = proc_create(
- "goodix_ts/driver_test", 0660, NULL, &driver_test_ops);
+ proc_entry = proc_create_data(
+ "driver_test", 0660, core_data->proc_dir_entry, &driver_test_ops, core_data);
if (!proc_entry) {
- ts_err("failed to create proc entry");
- return -ENOMEM;
+ ts_err("failed to create proc driver_test");
+ return -ENODEV;
}
proc_entry =
- proc_create("goodix_ts/cmd_list", 0440, NULL, &cmd_list_ops);
-
- cd = core_data;
+ proc_create("cmd_list", 0440, core_data->proc_dir_entry, &cmd_list_ops);
+ if (!proc_entry) {
+ ts_err("failed to create proc cmd_list");
+ return -ENODEV;
+ }
return 0;
}
-void driver_test_proc_remove(void)
+void driver_test_proc_remove(struct goodix_ts_core *core_data)
{
- remove_proc_entry("goodix_ts/cmd_list", NULL);
- remove_proc_entry("goodix_ts/driver_test", NULL);
+ remove_proc_entry("cmd_list", core_data->proc_dir_entry);
+ remove_proc_entry("driver_test", core_data->proc_dir_entry);
}