Input: elo - fix checksum calculation
Fix 10-byte protocol checksum calculation and do not discard packet early unless it is missing lead in byte. Signed-off-by: Shaun Jackman <sjackman@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
6b50d8b862
commit
1ce316efb5
1 changed files with 29 additions and 26 deletions
|
@ -36,6 +36,10 @@ MODULE_LICENSE("GPL");
|
|||
|
||||
#define ELO_MAX_LENGTH 10
|
||||
|
||||
#define ELO10_LEAD_BYTE 'U'
|
||||
|
||||
#define ELO10_TOUCH_PACKET 'T'
|
||||
|
||||
/*
|
||||
* Per-touchscreen data.
|
||||
*/
|
||||
|
@ -54,37 +58,36 @@ static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_r
|
|||
{
|
||||
struct input_dev *dev = elo->dev;
|
||||
|
||||
elo->csum += elo->data[elo->idx] = data;
|
||||
|
||||
elo->data[elo->idx] = data;
|
||||
switch (elo->idx++) {
|
||||
|
||||
case 0:
|
||||
if (data != 'U') {
|
||||
elo->csum = 0xaa;
|
||||
if (data != ELO10_LEAD_BYTE) {
|
||||
pr_debug("elo: unsynchronized data: 0x%02x\n", data);
|
||||
elo->idx = 0;
|
||||
elo->csum = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (data != 'T') {
|
||||
elo->idx = 0;
|
||||
elo->csum = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 9:
|
||||
if (elo->csum) {
|
||||
elo->idx = 0;
|
||||
if (data != elo->csum) {
|
||||
pr_debug("elo: bad checksum: 0x%02x, expected 0x%02x\n",
|
||||
data, elo->csum);
|
||||
break;
|
||||
}
|
||||
if (elo->data[1] != ELO10_TOUCH_PACKET) {
|
||||
pr_debug(elo: "unexpected packet: 0x%02x\n", elo->data[1]);
|
||||
break;
|
||||
}
|
||||
input_regs(dev, regs);
|
||||
input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]);
|
||||
input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]);
|
||||
input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]);
|
||||
input_report_key(dev, BTN_TOUCH, elo->data[8] || elo->data[7]);
|
||||
input_sync(dev);
|
||||
}
|
||||
elo->idx = 0;
|
||||
elo->csum = 0;
|
||||
break;
|
||||
}
|
||||
elo->csum += data;
|
||||
}
|
||||
|
||||
static void elo_process_data_6(struct elo *elo, unsigned char data, struct pt_regs *regs)
|
||||
|
|
Loading…
Add table
Reference in a new issue