input: touchscreen: Goodix gt915 driver cleanup

Cleanup the gt915 goodix driver from checkpatch failures.
Also have cleared the checkpatch errors on 4.4

This patch is propagated from 3.18 kernel
'commit 9ccc3ab159ba ("input: touchscreen: Goodix gt915
driver cleanup")'

Change-Id: Id841423f229b6abc674cc1e3c6441d55062b6ab4
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
Signed-off-by: Bingzhe Cai <bingzhec@codeaurora.org>
Signed-off-by: Sudhakar Manapati <smanap@codeaurora.org>
[abinayap@codeaurora.org: fix checkpatch errors for 4.4 kernel
Use of the '__DATE__' macro makes the build non-deterministic
Also including it in the output does not provide any value.
So remove its usage.]
Signed-off-by: Abinaya P <abinayap@codeaurora.org>
This commit is contained in:
Shantanu Jain 2013-07-18 17:34:31 +05:30 committed by Abinaya P
parent b1bafc4fd8
commit d80c9df9bc
3 changed files with 2101 additions and 2307 deletions

View file

@ -1,6 +1,7 @@
/* drivers/input/touchscreen/goodix_tool.c /* drivers/input/touchscreen/goodix_tool.c
* *
* 2010 - 2012 Goodix Technology. * 2010 - 2012 Goodix Technology.
* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -28,48 +29,38 @@ static char procname[20] = {0};
#define UPDATE_FUNCTIONS #define UPDATE_FUNCTIONS
#ifdef UPDATE_FUNCTIONS
extern s32 gup_enter_update_mode(struct i2c_client *client);
extern void gup_leave_update_mode(void);
extern s32 gup_update_proc(void *dir);
#endif
extern void gtp_irq_disable(struct goodix_ts_data *);
extern void gtp_irq_enable(struct goodix_ts_data *);
#pragma pack(1) #pragma pack(1)
typedef struct{ struct {
u8 wr; //write read flag£¬0:R 1:W 2:PID 3: u8 wr; /* write read flag£¬0:R 1:W 2:PID 3: */
u8 flag; //0:no need flag/int 1: need flag 2:need int u8 flag; /* 0:no need flag/int 1: need flag 2:need int */
u8 flag_addr[2]; //flag address u8 flag_addr[2];/* flag address */
u8 flag_val; //flag val u8 flag_val; /* flag val */
u8 flag_relation; //flag_val:flag 0:not equal 1:equal 2:> 3:< u8 flag_relation; /* flag_val:flag 0:not equal 1:equal 2:> 3:< */
u16 circle; //polling cycle u16 circle; /* polling cycle */
u8 times; //plling times u8 times; /* plling times */
u8 retry; //I2C retry times u8 retry; /* I2C retry times */
u16 delay; //delay befor read or after write u16 delay; /* delay before read or after write */
u16 data_len; //data length u16 data_len; /* data length */
u8 addr_len; //address length u8 addr_len; /* address length */
u8 addr[2]; //address u8 addr[2]; /* address */
u8 res[3]; //reserved u8 res[3]; /* reserved */
u8* data; //data pointer u8 *data; /* data pointer */
} st_cmd_head; } st_cmd_head;
#pragma pack() #pragma pack()
st_cmd_head cmd_head; st_cmd_head cmd_head;
static struct i2c_client *gt_client = NULL; static struct i2c_client *gt_client;
static struct proc_dir_entry *goodix_proc_entry; static struct proc_dir_entry *goodix_proc_entry;
static s32 goodix_tool_write(struct file *filp, const char __user *buff, unsigned long len, void *data); static s32 goodix_tool_write(struct file *filp, const char __user *buff,
static s32 goodix_tool_read( char *page, char **start, off_t off, int count, int *eof, void *data ); unsigned long len, void *data);
static s32 goodix_tool_read(char *page, char **start, off_t off, int count,
int *eof, void *data);
static s32 (*tool_i2c_read)(u8 *, u16); static s32 (*tool_i2c_read)(u8 *, u16);
static s32 (*tool_i2c_write)(u8 *, u16); static s32 (*tool_i2c_write)(u8 *, u16);
#if GTP_ESD_PROTECT s32 DATA_LENGTH;
extern void gtp_esd_switch(struct i2c_client *, s32);
#endif
s32 DATA_LENGTH = 0;
s8 IC_TYPE[16] = {0}; s8 IC_TYPE[16] = {0};
static void tool_set_proc_name(char *procname) static void tool_set_proc_name(char *procname)
@ -78,29 +69,22 @@ static void tool_set_proc_name(char * procname)
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
char date[20] = {0}; char date[20] = {0};
char month[4] = {0}; char month[4] = {0};
int i = 0, n_month = 1, n_day = 0, n_year = 0; int i = 0, n_month = 1, n_day = 0, n_year = 0, ret;
sprintf(date, "%s", __DATE__); ret = sscanf(date, "%s %d %d", month, &n_day, &n_year);
if (!ret)
//GTP_DEBUG("compile date: %s", date); return;
for (i = 0; i < 12; ++i) {
sscanf(date, "%s %d %d", month, &n_day, &n_year); if (!memcmp(months[i], month, 3)) {
for (i = 0; i < 12; ++i)
{
if (!memcmp(months[i], month, 3))
{
n_month = i+1; n_month = i+1;
break; break;
} }
} }
sprintf(procname, "gmnode%04d%02d%02d", n_year, n_month, n_day); snprintf(procname, 20, "gmnode%04d%02d%02d", n_year, n_month, n_day);
/* GTP_DEBUG("procname = %s", procname); */
//GTP_DEBUG("procname = %s", procname);
} }
static s32 tool_i2c_read_no_extra(u8 *buf, u16 len) static s32 tool_i2c_read_no_extra(u8 *buf, u16 len)
{ {
s32 ret = -1; s32 ret = -1;
@ -117,14 +101,12 @@ static s32 tool_i2c_read_no_extra(u8* buf, u16 len)
msgs[1].len = len; msgs[1].len = len;
msgs[1].buf = &buf[GTP_ADDR_LENGTH]; msgs[1].buf = &buf[GTP_ADDR_LENGTH];
for (i = 0; i < cmd_head.retry; i++) for (i = 0; i < cmd_head.retry; i++) {
{
ret = i2c_transfer(gt_client->adapter, msgs, 2); ret = i2c_transfer(gt_client->adapter, msgs, 2);
if (ret > 0) if (ret > 0)
{
break; break;
} }
}
return ret; return ret;
} }
@ -139,14 +121,12 @@ static s32 tool_i2c_write_no_extra(u8* buf, u16 len)
msg.len = len; msg.len = len;
msg.buf = buf; msg.buf = buf;
for (i = 0; i < cmd_head.retry; i++) for (i = 0; i < cmd_head.retry; i++) {
{
ret = i2c_transfer(gt_client->adapter, &msg, 1); ret = i2c_transfer(gt_client->adapter, &msg, 1);
if (ret > 0) if (ret > 0)
{
break; break;
} }
}
return ret; return ret;
} }
@ -178,21 +158,14 @@ static s32 tool_i2c_write_with_extra(u8* buf, u16 len)
static void register_i2c_func(void) static void register_i2c_func(void)
{ {
// if (!strncmp(IC_TYPE, "GT818", 5) || !strncmp(IC_TYPE, "GT816", 5) if (strcmp(IC_TYPE, "GT8110") && strcmp(IC_TYPE, "GT8105")
// || !strncmp(IC_TYPE, "GT811", 5) || !strncmp(IC_TYPE, "GT818F", 6) && strcmp(IC_TYPE, "GT801") && strcmp(IC_TYPE, "GT800")
// || !strncmp(IC_TYPE, "GT827", 5) || !strncmp(IC_TYPE,"GT828", 5) && strcmp(IC_TYPE, "GT801PLUS") && strcmp(IC_TYPE, "GT811")
// || !strncmp(IC_TYPE, "GT813", 5)) && strcmp(IC_TYPE, "GTxxx")) {
if (strncmp(IC_TYPE, "GT8110", 6) && strncmp(IC_TYPE, "GT8105", 6)
&& strncmp(IC_TYPE, "GT801", 5) && strncmp(IC_TYPE, "GT800", 5)
&& strncmp(IC_TYPE, "GT801PLUS", 9) && strncmp(IC_TYPE, "GT811", 5)
&& strncmp(IC_TYPE, "GTxxx", 5))
{
tool_i2c_read = tool_i2c_read_with_extra; tool_i2c_read = tool_i2c_read_with_extra;
tool_i2c_write = tool_i2c_write_with_extra; tool_i2c_write = tool_i2c_write_with_extra;
GTP_DEBUG("I2C function: with pre and end cmd!"); GTP_DEBUG("I2C function: with pre and end cmd!");
} } else {
else
{
tool_i2c_read = tool_i2c_read_no_extra; tool_i2c_read = tool_i2c_read_no_extra;
tool_i2c_write = tool_i2c_write_no_extra; tool_i2c_write = tool_i2c_write_no_extra;
GTP_INFO("I2C function: without pre and end cmd!"); GTP_INFO("I2C function: without pre and end cmd!");
@ -206,7 +179,6 @@ static void unregister_i2c_func(void)
GTP_INFO("I2C function: unregister i2c transfer function!"); GTP_INFO("I2C function: unregister i2c transfer function!");
} }
s32 init_wr_node(struct i2c_client *client) s32 init_wr_node(struct i2c_client *client)
{ {
s32 i; s32 i;
@ -216,22 +188,16 @@ s32 init_wr_node(struct i2c_client *client)
cmd_head.data = NULL; cmd_head.data = NULL;
i = 5; i = 5;
while ((!cmd_head.data) && i) while ((!cmd_head.data) && i) {
{
cmd_head.data = kzalloc(i * DATA_LENGTH_UINT, GFP_KERNEL); cmd_head.data = kzalloc(i * DATA_LENGTH_UINT, GFP_KERNEL);
if (NULL != cmd_head.data) if (cmd_head.data != NULL)
{
break; break;
}
i--; i--;
} }
if (i) if (i) {
{
DATA_LENGTH = i * DATA_LENGTH_UINT + GTP_ADDR_LENGTH; DATA_LENGTH = i * DATA_LENGTH_UINT + GTP_ADDR_LENGTH;
GTP_INFO("Applied memory size:%d.", DATA_LENGTH); GTP_INFO("Applied memory size:%d.", DATA_LENGTH);
} } else {
else
{
GTP_ERROR("Apply for memory failed."); GTP_ERROR("Apply for memory failed.");
return FAIL; return FAIL;
} }
@ -243,17 +209,13 @@ s32 init_wr_node(struct i2c_client *client)
tool_set_proc_name(procname); tool_set_proc_name(procname);
goodix_proc_entry = create_proc_entry(procname, 0666, NULL); goodix_proc_entry = create_proc_entry(procname, 0666, NULL);
if (goodix_proc_entry == NULL) if (goodix_proc_entry == NULL) {
{
GTP_ERROR("Couldn't create proc entry!"); GTP_ERROR("Couldn't create proc entry!");
return FAIL; return FAIL;
} }
else
{
GTP_INFO("Create proc entry success!"); GTP_INFO("Create proc entry success!");
goodix_proc_entry->write_proc = goodix_tool_write; goodix_proc_entry->write_proc = goodix_tool_write;
goodix_proc_entry->read_proc = goodix_tool_read; dix_proc_entry->read_proc = goodix_tool_read;
}
return SUCCESS; return SUCCESS;
} }
@ -270,15 +232,16 @@ static u8 relation(u8 src, u8 dst, u8 rlt)
{ {
u8 ret = 0; u8 ret = 0;
switch (rlt) switch (rlt) {
{
case 0: case 0:
ret = (src != dst) ? true : false; ret = (src != dst) ? true : false;
break; break;
case 1: case 1:
ret = (src == dst) ? true : false; ret = (src == dst) ? true : false;
GTP_DEBUG("equal:src:0x%02x dst:0x%02x ret:%d.", src, dst, (s32)ret); GTP_DEBUG("equal:src:0x%02x dst:0x%02x ret:%d.",
src, dst, (s32)ret);
break; break;
case 2: case 2:
@ -306,32 +269,35 @@ static u8 relation(u8 src, u8 dst, u8 rlt)
} }
/******************************************************* /*******************************************************
Function: * Function:
Comfirm function. * Comfirm function.
Input: * Input:
None. * None.
Output: * Output:
Return write length. * Return write length.
********************************************************/ *******************************************************
*/
static u8 comfirm(void) static u8 comfirm(void)
{ {
s32 i = 0; s32 i = 0;
u8 buf[32]; u8 buf[32];
// memcpy(&buf[GTP_ADDR_LENGTH - cmd_head.addr_len], &cmd_head.flag_addr, cmd_head.addr_len); /* memcpy(&buf[GTP_ADDR_LENGTH - cmd_head.addr_len],
// memcpy(buf, &cmd_head.flag_addr, cmd_head.addr_len);//Modified by Scott, 2012-02-17 * &cmd_head.flag_addr, cmd_head.addr_len);
* memcpy(buf, &cmd_head.flag_addr, cmd_head.addr_len);
* //Modified by Scott, 2012-02-17
*/
memcpy(buf, cmd_head.flag_addr, cmd_head.addr_len); memcpy(buf, cmd_head.flag_addr, cmd_head.addr_len);
for (i = 0; i < cmd_head.times; i++) for (i = 0; i < cmd_head.times; i++) {
{ if (tool_i2c_read(buf, 1) <= 0) {
if (tool_i2c_read(buf, 1) <= 0)
{
GTP_ERROR("Read flag data failed!"); GTP_ERROR("Read flag data failed!");
return FAIL; return FAIL;
} }
if (true == relation(buf[GTP_ADDR_LENGTH], cmd_head.flag_val, cmd_head.flag_relation)) if (true == relation(buf[GTP_ADDR_LENGTH], cmd_head.flag_val,
{ cmd_head.flag_relation)) {
GTP_DEBUG("value at flag addr:0x%02x.", buf[GTP_ADDR_LENGTH]); GTP_DEBUG("value at flag addr:0x%02x.",
buf[GTP_ADDR_LENGTH]);
GTP_DEBUG("flag value:0x%02x.", cmd_head.flag_val); GTP_DEBUG("flag value:0x%02x.", cmd_head.flag_val);
break; break;
} }
@ -339,8 +305,7 @@ static u8 comfirm(void)
msleep(cmd_head.circle); msleep(cmd_head.circle);
} }
if (i >= cmd_head.times) if (i >= cmd_head.times) {
{
GTP_ERROR("Didn't get the flag to continue!"); GTP_ERROR("Didn't get the flag to continue!");
return FAIL; return FAIL;
} }
@ -348,29 +313,31 @@ static u8 comfirm(void)
return SUCCESS; return SUCCESS;
} }
/******************************************************* /********************************************************
Function: * Function:
Goodix tool write function. * Goodix tool write function.
Input: * Input:
standard proc write function param. * standard proc write function param.
Output: * Output:
Return write length. * Return write length.
********************************************************/ *******************************************************
static s32 goodix_tool_write(struct file *filp, const char __user *buff, unsigned long len, void *data) */
static s32 goodix_tool_write(struct file *filp, const char __user *buff,
unsigned long len, void *data)
{ {
s32 ret = 0; s32 ret = 0;
GTP_DEBUG_FUNC(); GTP_DEBUG_FUNC();
GTP_DEBUG_ARRAY((u8 *)buff, len); GTP_DEBUG_ARRAY((u8 *)buff, len);
ret = copy_from_user(&cmd_head, buff, CMD_HEAD_LENGTH); ret = copy_from_user(&cmd_head, buff, CMD_HEAD_LENGTH);
if (ret) if (ret)
{
GTP_ERROR("copy_from_user failed."); GTP_ERROR("copy_from_user failed.");
}
GTP_DEBUG("wr :0x%02x.", cmd_head.wr); GTP_DEBUG("wr :0x%02x.", cmd_head.wr);
GTP_DEBUG("flag:0x%02x.", cmd_head.flag); GTP_DEBUG("flag:0x%02x.", cmd_head.flag);
GTP_DEBUG("flag addr:0x%02x%02x.", cmd_head.flag_addr[0], cmd_head.flag_addr[1]); GTP_DEBUG("flag addr:0x%02x%02x.", cmd_head.flag_addr[0],
cmd_head.flag_addr[1]);
GTP_DEBUG("flag val:0x%02x.", cmd_head.flag_val); GTP_DEBUG("flag val:0x%02x.", cmd_head.flag_val);
GTP_DEBUG("flag rel:0x%02x.", cmd_head.flag_relation); GTP_DEBUG("flag rel:0x%02x.", cmd_head.flag_relation);
GTP_DEBUG("circle :%d.", (s32)cmd_head.circle); GTP_DEBUG("circle :%d.", (s32)cmd_head.circle);
@ -383,229 +350,198 @@ static s32 goodix_tool_write(struct file *filp, const char __user *buff, unsigne
GTP_DEBUG("len:%d.", (s32)len); GTP_DEBUG("len:%d.", (s32)len);
GTP_DEBUG("buf[20]:0x%02x.", buff[CMD_HEAD_LENGTH]); GTP_DEBUG("buf[20]:0x%02x.", buff[CMD_HEAD_LENGTH]);
if (1 == cmd_head.wr) if (cmd_head.wr == 1) {
{ /* copy_from_user(&cmd_head.data[cmd_head.addr_len],
// copy_from_user(&cmd_head.data[cmd_head.addr_len], &buff[CMD_HEAD_LENGTH], cmd_head.data_len); * &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH], &buff[CMD_HEAD_LENGTH], cmd_head.data_len); */
ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH],
&buff[CMD_HEAD_LENGTH], cmd_head.data_len);
if (ret) if (ret)
{
GTP_ERROR("copy_from_user failed."); GTP_ERROR("copy_from_user failed.");
}
memcpy(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len], cmd_head.addr, cmd_head.addr_len);
GTP_DEBUG_ARRAY(cmd_head.data, cmd_head.data_len + cmd_head.addr_len); memcpy(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],
GTP_DEBUG_ARRAY((u8*)&buff[CMD_HEAD_LENGTH], cmd_head.data_len); cmd_head.addr, cmd_head.addr_len);
if (1 == cmd_head.flag) GTP_DEBUG_ARRAY(cmd_head.data,
{ cmd_head.data_len + cmd_head.addr_len);
if (FAIL == comfirm()) GTP_DEBUG_ARRAY((u8 *)&buff[CMD_HEAD_LENGTH],
{ cmd_head.data_len);
if (cmd_head.flag == 1) {
if (comfirm() == FAIL) {
GTP_ERROR("[WRITE]Comfirm fail!"); GTP_ERROR("[WRITE]Comfirm fail!");
return FAIL; return FAIL;
} }
} else if (cmd_head.flag == 2) {
/* Need interrupt! */
} }
else if (2 == cmd_head.flag) if (tool_i2c_write(
{ &cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],
//Need interrupt! cmd_head.data_len + cmd_head.addr_len) <= 0) {
}
if (tool_i2c_write(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],
cmd_head.data_len + cmd_head.addr_len) <= 0)
{
GTP_ERROR("[WRITE]Write data failed!"); GTP_ERROR("[WRITE]Write data failed!");
return FAIL; return FAIL;
} }
GTP_DEBUG_ARRAY(&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],cmd_head.data_len + cmd_head.addr_len); GTP_DEBUG_ARRAY(
&cmd_head.data[GTP_ADDR_LENGTH - cmd_head.addr_len],
cmd_head.data_len + cmd_head.addr_len);
if (cmd_head.delay) if (cmd_head.delay)
{
msleep(cmd_head.delay); msleep(cmd_head.delay);
}
return cmd_head.data_len + CMD_HEAD_LENGTH; return cmd_head.data_len + CMD_HEAD_LENGTH;
} } else if (cmd_head.wr == 3) { /* Write ic type */
else if (3 == cmd_head.wr) //Write ic type
{ ret = copy_from_user(&cmd_head.data[0], &buff[CMD_HEAD_LENGTH],
ret = copy_from_user(&cmd_head.data[0], &buff[CMD_HEAD_LENGTH], cmd_head.data_len); cmd_head.data_len);
if (ret) if (ret)
{
GTP_ERROR("copy_from_user failed."); GTP_ERROR("copy_from_user failed.");
}
memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len); memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len);
register_i2c_func(); register_i2c_func();
return cmd_head.data_len + CMD_HEAD_LENGTH; return cmd_head.data_len + CMD_HEAD_LENGTH;
} } else if (cmd_head.wr == 3) {
else if (5 == cmd_head.wr)
{ /* memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len); */
//memcpy(IC_TYPE, cmd_head.data, cmd_head.data_len);
return cmd_head.data_len + CMD_HEAD_LENGTH; return cmd_head.data_len + CMD_HEAD_LENGTH;
} } else if (cmd_head.wr == 7) { /* disable irq! */
else if (7 == cmd_head.wr)//disable irq!
{
gtp_irq_disable(i2c_get_clientdata(gt_client)); gtp_irq_disable(i2c_get_clientdata(gt_client));
#if GTP_ESD_PROTECT #if GTP_ESD_PROTECT
gtp_esd_switch(gt_client, SWITCH_OFF); gtp_esd_switch(gt_client, SWITCH_OFF);
#endif #endif
return CMD_HEAD_LENGTH; return CMD_HEAD_LENGTH;
} } else if (cmd_head.wr == 9) { /* enable irq! */
else if (9 == cmd_head.wr) //enable irq!
{
gtp_irq_enable(i2c_get_clientdata(gt_client)); gtp_irq_enable(i2c_get_clientdata(gt_client));
#if GTP_ESD_PROTECT #if GTP_ESD_PROTECT
gtp_esd_switch(gt_client, SWITCH_ON); gtp_esd_switch(gt_client, SWITCH_ON);
#endif #endif
return CMD_HEAD_LENGTH; return CMD_HEAD_LENGTH;
} } else if (cmd_head.wr == 17) {
else if(17 == cmd_head.wr)
{
struct goodix_ts_data *ts = i2c_get_clientdata(gt_client); struct goodix_ts_data *ts = i2c_get_clientdata(gt_client);
ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH], &buff[CMD_HEAD_LENGTH], cmd_head.data_len);
ret = copy_from_user(&cmd_head.data[GTP_ADDR_LENGTH],
&buff[CMD_HEAD_LENGTH], cmd_head.data_len);
if (ret) if (ret)
{
GTP_DEBUG("copy_from_user failed."); GTP_DEBUG("copy_from_user failed.");
} if (cmd_head.data[GTP_ADDR_LENGTH]) {
if(cmd_head.data[GTP_ADDR_LENGTH])
{
GTP_DEBUG("gtp enter rawdiff."); GTP_DEBUG("gtp enter rawdiff.");
ts->gtp_rawdiff_mode = true; ts->gtp_rawdiff_mode = true;
} } else {
else
{
ts->gtp_rawdiff_mode = false; ts->gtp_rawdiff_mode = false;
GTP_DEBUG("gtp leave rawdiff."); GTP_DEBUG("gtp leave rawdiff.");
} }
return CMD_HEAD_LENGTH; return CMD_HEAD_LENGTH;
} }
#ifdef UPDATE_FUNCTIONS #ifdef UPDATE_FUNCTIONS
else if (11 == cmd_head.wr)//Enter update mode! else if (cmd_head.wr == 11) { /* Enter update mode! */
{ if (gup_enter_update_mode(gt_client) == FAIL)
if (FAIL == gup_enter_update_mode(gt_client))
{
return FAIL; return FAIL;
} } else if (cmd_head.wr == 13) { /* Leave update mode! */
}
else if (13 == cmd_head.wr)//Leave update mode!
{
gup_leave_update_mode(); gup_leave_update_mode();
} } else if (cmd_head.wr == 15) { /* Update firmware! */
else if (15 == cmd_head.wr) //Update firmware!
{
show_len = 0; show_len = 0;
total_len = 0; total_len = 0;
memset(cmd_head.data, 0, cmd_head.data_len + 1); memset(cmd_head.data, 0, cmd_head.data_len + 1);
memcpy(cmd_head.data, &buff[CMD_HEAD_LENGTH], cmd_head.data_len); memcpy(cmd_head.data, &buff[CMD_HEAD_LENGTH],
cmd_head.data_len);
if (FAIL == gup_update_proc((void*)cmd_head.data)) if (gup_update_proc((void *)cmd_head.data) == FAIL)
{
return FAIL; return FAIL;
} }
}
#endif #endif
return CMD_HEAD_LENGTH; return CMD_HEAD_LENGTH;
} }
/******************************************************* /*******************************************************
Function: * Function:
Goodix tool read function. * Goodix tool read function.
Input: * Input:
standard proc read function param. * standard proc read function param.
Output: * Output:
Return read length. * Return read length.
********************************************************/ *******************************************************
static s32 goodix_tool_read( char *page, char **start, off_t off, int count, int *eof, void *data ) */
static s32 goodix_tool_read(char *page, char **start, off_t off, int count,
int *eof, void *data)
{ {
GTP_DEBUG_FUNC(); GTP_DEBUG_FUNC();
if (cmd_head.wr % 2) if (cmd_head.wr % 2) {
{
return FAIL; return FAIL;
} } else if (!cmd_head.wr) {
else if (!cmd_head.wr)
{
u16 len = 0; u16 len = 0;
s16 data_len = 0; s16 data_len = 0;
u16 loc = 0; u16 loc = 0;
if (1 == cmd_head.flag) if (cmd_head.flag == 1) {
{ if (comfirm() == FAIL) {
if (FAIL == comfirm())
{
GTP_ERROR("[READ]Comfirm fail!"); GTP_ERROR("[READ]Comfirm fail!");
return FAIL; return FAIL;
} }
} } else if (cmd_head.flag == 2) {
else if (2 == cmd_head.flag) /* Need interrupt! */
{
//Need interrupt!
} }
memcpy(cmd_head.data, cmd_head.addr, cmd_head.addr_len); memcpy(cmd_head.data, cmd_head.addr, cmd_head.addr_len);
GTP_DEBUG("[CMD HEAD DATA] ADDR:0x%02x%02x.", cmd_head.data[0], cmd_head.data[1]); GTP_DEBUG("[CMD HEAD DATA] ADDR:0x%02x%02x.", cmd_head.data[0],
GTP_DEBUG("[CMD HEAD ADDR] ADDR:0x%02x%02x.", cmd_head.addr[0], cmd_head.addr[1]); cmd_head.data[1]);
GTP_DEBUG("[CMD HEAD ADDR] ADDR:0x%02x%02x.", cmd_head.addr[0],
cmd_head.addr[1]);
if (cmd_head.delay) if (cmd_head.delay)
{
msleep(cmd_head.delay); msleep(cmd_head.delay);
}
data_len = cmd_head.data_len; data_len = cmd_head.data_len;
while(data_len > 0) while (data_len > 0) {
{
if (data_len > DATA_LENGTH) if (data_len > DATA_LENGTH)
{
len = DATA_LENGTH; len = DATA_LENGTH;
}
else else
{
len = data_len; len = data_len;
}
data_len -= DATA_LENGTH; data_len -= DATA_LENGTH;
if (tool_i2c_read(cmd_head.data, len) <= 0) if (tool_i2c_read(cmd_head.data, len) <= 0) {
{
GTP_ERROR("[READ]Read data failed!"); GTP_ERROR("[READ]Read data failed!");
return FAIL; return FAIL;
} }
memcpy(&page[loc], &cmd_head.data[GTP_ADDR_LENGTH], len); memcpy(&page[loc], &cmd_head.data[GTP_ADDR_LENGTH],
len);
loc += len; loc += len;
GTP_DEBUG_ARRAY(&cmd_head.data[GTP_ADDR_LENGTH], len); GTP_DEBUG_ARRAY(&cmd_head.data[GTP_ADDR_LENGTH], len);
GTP_DEBUG_ARRAY(page, len); GTP_DEBUG_ARRAY(page, len);
} }
} } else if (cmd_head.wr == 2) {
else if (2 == cmd_head.wr) /* memcpy(page, "gt8", cmd_head.data_len);
{ * memcpy(page, "GT818", 5);
// memcpy(page, "gt8", cmd_head.data_len); * page[5] = 0;
// memcpy(page, "GT818", 5); */
// page[5] = 0;
GTP_DEBUG("Return ic type:%s len:%d.", page, (s32)cmd_head.data_len); GTP_DEBUG("Return ic type:%s len:%d.", page,
(s32)cmd_head.data_len);
return cmd_head.data_len; return cmd_head.data_len;
//return sizeof(IC_TYPE_NAME); /* return sizeof(IC_TYPE_NAME); */
} } else if (cmd_head.wr == 4) {
else if (4 == cmd_head.wr)
{
page[0] = show_len >> 8; page[0] = show_len >> 8;
page[1] = show_len & 0xff; page[1] = show_len & 0xff;
page[2] = total_len >> 8; page[2] = total_len >> 8;
page[3] = total_len & 0xff; page[3] = total_len & 0xff;
return cmd_head.data_len; return cmd_head.data_len;
} } else if (cmd_head.wr == 6) {
else if (6 == cmd_head.wr) /* Read error code! */
{ } else if (cmd_head.wr == 8) { /*Read driver version */
//Read error code! /* memcpy(page, GTP_DRIVER_VERSION,
} * strlen(GTP_DRIVER_VERSION));
else if (8 == cmd_head.wr) //Read driver version */
{
// memcpy(page, GTP_DRIVER_VERSION, strlen(GTP_DRIVER_VERSION));
s32 tmp_len; s32 tmp_len;
tmp_len = strlen(GTP_DRIVER_VERSION); tmp_len = strlen(GTP_DRIVER_VERSION);
memcpy(page, GTP_DRIVER_VERSION, tmp_len); memcpy(page, GTP_DRIVER_VERSION, tmp_len);
page[tmp_len] = 0; page[tmp_len] = 0;

View file

@ -1,6 +1,6 @@
// make sense only when GTP_HEADER_FW_UPDATE & GTP_AUTO_UPDATE are enabled /*
// define your own firmware array here * make sense only when GTP_HEADER_FW_UPDATE & GTP_AUTO_UPDATE are enabled
const unsigned char header_fw_array[] = * define your own firmware array here
{ */
const unsigned char header_fw_array[] = {
}; };

File diff suppressed because it is too large Load diff