Skip to content

Commit 1e0e7a6

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
Pull input fixes from Dmitry Torokhov: "Two driver fixes: - a fix for zinitix touchscreen to properly report contacts - a fix for aiptek tablet driver to be more resilient to devices with incorrect descriptors" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: aiptek - properly check endpoint type Input: zinitix - do not report shadow fingers
2 parents 14702b3 + 5600f69 commit 1e0e7a6

2 files changed

Lines changed: 39 additions & 15 deletions

File tree

drivers/input/tablet/aiptek.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,15 +1787,13 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
17871787
input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);
17881788
input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0);
17891789

1790-
/* Verify that a device really has an endpoint */
1791-
if (intf->cur_altsetting->desc.bNumEndpoints < 1) {
1790+
err = usb_find_common_endpoints(intf->cur_altsetting,
1791+
NULL, NULL, &endpoint, NULL);
1792+
if (err) {
17921793
dev_err(&intf->dev,
1793-
"interface has %d endpoints, but must have minimum 1\n",
1794-
intf->cur_altsetting->desc.bNumEndpoints);
1795-
err = -EINVAL;
1794+
"interface has no int in endpoints, but must have minimum 1\n");
17961795
goto fail3;
17971796
}
1798-
endpoint = &intf->cur_altsetting->endpoint[0].desc;
17991797

18001798
/* Go set up our URB, which is called when the tablet receives
18011799
* input.

drivers/input/touchscreen/zinitix.c

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ struct point_coord {
135135

136136
struct touch_event {
137137
__le16 status;
138-
u8 finger_cnt;
138+
u8 finger_mask;
139139
u8 time_stamp;
140140
struct point_coord point_coord[MAX_SUPPORTED_FINGER_NUM];
141141
};
@@ -322,18 +322,40 @@ static int zinitix_send_power_on_sequence(struct bt541_ts_data *bt541)
322322
static void zinitix_report_finger(struct bt541_ts_data *bt541, int slot,
323323
const struct point_coord *p)
324324
{
325+
u16 x, y;
326+
327+
if (unlikely(!(p->sub_status &
328+
(SUB_BIT_UP | SUB_BIT_DOWN | SUB_BIT_MOVE)))) {
329+
dev_dbg(&bt541->client->dev, "unknown finger event %#02x\n",
330+
p->sub_status);
331+
return;
332+
}
333+
334+
x = le16_to_cpu(p->x);
335+
y = le16_to_cpu(p->y);
336+
325337
input_mt_slot(bt541->input_dev, slot);
326-
input_mt_report_slot_state(bt541->input_dev, MT_TOOL_FINGER, true);
327-
touchscreen_report_pos(bt541->input_dev, &bt541->prop,
328-
le16_to_cpu(p->x), le16_to_cpu(p->y), true);
329-
input_report_abs(bt541->input_dev, ABS_MT_TOUCH_MAJOR, p->width);
338+
if (input_mt_report_slot_state(bt541->input_dev, MT_TOOL_FINGER,
339+
!(p->sub_status & SUB_BIT_UP))) {
340+
touchscreen_report_pos(bt541->input_dev,
341+
&bt541->prop, x, y, true);
342+
input_report_abs(bt541->input_dev,
343+
ABS_MT_TOUCH_MAJOR, p->width);
344+
dev_dbg(&bt541->client->dev, "finger %d %s (%u, %u)\n",
345+
slot, p->sub_status & SUB_BIT_DOWN ? "down" : "move",
346+
x, y);
347+
} else {
348+
dev_dbg(&bt541->client->dev, "finger %d up (%u, %u)\n",
349+
slot, x, y);
350+
}
330351
}
331352

332353
static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
333354
{
334355
struct bt541_ts_data *bt541 = bt541_handler;
335356
struct i2c_client *client = bt541->client;
336357
struct touch_event touch_event;
358+
unsigned long finger_mask;
337359
int error;
338360
int i;
339361

@@ -346,10 +368,14 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)
346368
goto out;
347369
}
348370

349-
for (i = 0; i < MAX_SUPPORTED_FINGER_NUM; i++)
350-
if (touch_event.point_coord[i].sub_status & SUB_BIT_EXIST)
351-
zinitix_report_finger(bt541, i,
352-
&touch_event.point_coord[i]);
371+
finger_mask = touch_event.finger_mask;
372+
for_each_set_bit(i, &finger_mask, MAX_SUPPORTED_FINGER_NUM) {
373+
const struct point_coord *p = &touch_event.point_coord[i];
374+
375+
/* Only process contacts that are actually reported */
376+
if (p->sub_status & SUB_BIT_EXIST)
377+
zinitix_report_finger(bt541, i, p);
378+
}
353379

354380
input_mt_sync_frame(bt541->input_dev);
355381
input_sync(bt541->input_dev);

0 commit comments

Comments
 (0)