Skip to content

Commit

Permalink
Input: atmel_mxt_ts - config CRC may start at T71
Browse files Browse the repository at this point in the history
On devices with the T71 object, the config CRC will start there, rather
than at T7.

Signed-off-by: Nick Dyer <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
ndyer authored and dtor committed Jul 27, 2018
1 parent 01cc75f commit 15082bd
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions drivers/input/touchscreen/atmel_mxt_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#define MXT_SPT_DIGITIZER_T43 43
#define MXT_SPT_MESSAGECOUNT_T44 44
#define MXT_SPT_CTECONFIG_T46 46
#define MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71 71
#define MXT_TOUCH_MULTITOUCHSCREEN_T100 100

/* MXT_GEN_MESSAGE_T5 object */
Expand Down Expand Up @@ -317,6 +318,7 @@ struct mxt_data {
u8 T6_reportid;
u16 T6_address;
u16 T7_address;
u16 T71_address;
u8 T9_reportid_min;
u8 T9_reportid_max;
u8 T19_reportid;
Expand Down Expand Up @@ -382,6 +384,7 @@ static bool mxt_object_readable(unsigned int type)
case MXT_SPT_USERDATA_T38:
case MXT_SPT_DIGITIZER_T43:
case MXT_SPT_CTECONFIG_T46:
case MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71:
return true;
default:
return false;
Expand Down Expand Up @@ -1443,6 +1446,7 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg)
u32 info_crc, config_crc, calculated_crc;
u8 *config_mem;
size_t config_mem_size;
u16 crc_start = 0;

mxt_update_crc(data, MXT_COMMAND_REPORTALL, 1);

Expand Down Expand Up @@ -1529,20 +1533,22 @@ static int mxt_update_cfg(struct mxt_data *data, const struct firmware *cfg)
goto release_mem;

/* Calculate crc of the received configs (not the raw config file) */
if (data->T7_address < cfg_start_ofs) {
dev_err(dev, "Bad T7 address, T7addr = %x, config offset %x\n",
data->T7_address, cfg_start_ofs);
ret = 0;
goto release_mem;
}
if (data->T71_address)
crc_start = data->T71_address;
else if (data->T7_address)
crc_start = data->T7_address;
else
dev_warn(dev, "Could not find CRC start\n");

calculated_crc = mxt_calculate_crc(config_mem,
data->T7_address - cfg_start_ofs,
config_mem_size);
if (crc_start > cfg_start_ofs) {
calculated_crc = mxt_calculate_crc(config_mem,
crc_start - cfg_start_ofs,
config_mem_size);

if (config_crc > 0 && config_crc != calculated_crc)
dev_warn(dev, "Config CRC error, calculated=%06X, file=%06X\n",
calculated_crc, config_crc);
if (config_crc > 0 && config_crc != calculated_crc)
dev_warn(dev, "Config CRC in file inconsistent, calculated=%06X, file=%06X\n",
calculated_crc, config_crc);
}

ret = mxt_upload_cfg_mem(data, cfg_start_ofs,
config_mem, config_mem_size);
Expand Down Expand Up @@ -1589,6 +1595,7 @@ static void mxt_free_object_table(struct mxt_data *data)
data->T5_msg_size = 0;
data->T6_reportid = 0;
data->T7_address = 0;
data->T71_address = 0;
data->T9_reportid_min = 0;
data->T9_reportid_max = 0;
data->T19_reportid = 0;
Expand Down Expand Up @@ -1654,6 +1661,9 @@ static int mxt_parse_object_table(struct mxt_data *data,
case MXT_GEN_POWER_T7:
data->T7_address = object->start_address;
break;
case MXT_SPT_DYNAMICCONFIGURATIONCONTAINER_T71:
data->T71_address = object->start_address;
break;
case MXT_TOUCH_MULTI_T9:
data->multitouch = MXT_TOUCH_MULTI_T9;
/* Only handle messages from first T9 instance */
Expand Down

0 comments on commit 15082bd

Please sign in to comment.