diff options
-rw-r--r-- | drivers/input/touchscreen/wacom_w8001.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c index 49bce13838be..8ed53aded2d3 100644 --- a/drivers/input/touchscreen/wacom_w8001.c +++ b/drivers/input/touchscreen/wacom_w8001.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/serio.h> | 19 | #include <linux/serio.h> |
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/ctype.h> | 21 | #include <linux/ctype.h> |
22 | #include <linux/delay.h> | ||
22 | 23 | ||
23 | #define DRIVER_DESC "Wacom W8001 serial touchscreen driver" | 24 | #define DRIVER_DESC "Wacom W8001 serial touchscreen driver" |
24 | 25 | ||
@@ -37,6 +38,7 @@ MODULE_LICENSE("GPL"); | |||
37 | 38 | ||
38 | #define W8001_QUERY_PACKET 0x20 | 39 | #define W8001_QUERY_PACKET 0x20 |
39 | 40 | ||
41 | #define W8001_CMD_STOP '0' | ||
40 | #define W8001_CMD_START '1' | 42 | #define W8001_CMD_START '1' |
41 | #define W8001_CMD_QUERY '*' | 43 | #define W8001_CMD_QUERY '*' |
42 | #define W8001_CMD_TOUCHQUERY '%' | 44 | #define W8001_CMD_TOUCHQUERY '%' |
@@ -279,24 +281,46 @@ static int w8001_setup(struct w8001 *w8001) | |||
279 | struct w8001_coord coord; | 281 | struct w8001_coord coord; |
280 | int error; | 282 | int error; |
281 | 283 | ||
282 | error = w8001_command(w8001, W8001_CMD_QUERY, true); | 284 | error = w8001_command(w8001, W8001_CMD_STOP, false); |
283 | if (error) | 285 | if (error) |
284 | return error; | 286 | return error; |
285 | 287 | ||
286 | parse_data(w8001->response, &coord); | 288 | msleep(250); /* wait 250ms before querying the device */ |
287 | 289 | ||
288 | input_set_abs_params(dev, ABS_X, 0, coord.x, 0, 0); | 290 | /* penabled? */ |
289 | input_set_abs_params(dev, ABS_Y, 0, coord.y, 0, 0); | 291 | error = w8001_command(w8001, W8001_CMD_QUERY, true); |
290 | input_set_abs_params(dev, ABS_PRESSURE, 0, coord.pen_pressure, 0, 0); | 292 | if (!error) { |
291 | input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0); | 293 | __set_bit(BTN_TOOL_PEN, dev->keybit); |
292 | input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0); | 294 | __set_bit(BTN_TOOL_RUBBER, dev->keybit); |
295 | __set_bit(BTN_STYLUS, dev->keybit); | ||
296 | __set_bit(BTN_STYLUS2, dev->keybit); | ||
297 | parse_data(w8001->response, &coord); | ||
298 | |||
299 | input_set_abs_params(dev, ABS_X, 0, coord.x, 0, 0); | ||
300 | input_set_abs_params(dev, ABS_Y, 0, coord.y, 0, 0); | ||
301 | input_set_abs_params(dev, ABS_PRESSURE, 0, coord.pen_pressure, 0, 0); | ||
302 | if (coord.tilt_x && coord.tilt_y) { | ||
303 | input_set_abs_params(dev, ABS_TILT_X, 0, coord.tilt_x, 0, 0); | ||
304 | input_set_abs_params(dev, ABS_TILT_Y, 0, coord.tilt_y, 0, 0); | ||
305 | } | ||
306 | } | ||
293 | 307 | ||
308 | /* Touch enabled? */ | ||
294 | error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true); | 309 | error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true); |
295 | if (!error) { | 310 | |
311 | /* | ||
312 | * Some non-touch devices may reply to the touch query. But their | ||
313 | * second byte is empty, which indicates touch is not supported. | ||
314 | */ | ||
315 | if (!error && w8001->response[1]) { | ||
296 | struct w8001_touch_query touch; | 316 | struct w8001_touch_query touch; |
297 | 317 | ||
298 | parse_touchquery(w8001->response, &touch); | 318 | parse_touchquery(w8001->response, &touch); |
299 | 319 | ||
320 | input_set_abs_params(dev, ABS_X, 0, touch.x, 0, 0); | ||
321 | input_set_abs_params(dev, ABS_Y, 0, touch.y, 0, 0); | ||
322 | __set_bit(BTN_TOOL_FINGER, dev->keybit); | ||
323 | |||
300 | switch (touch.sensor_id) { | 324 | switch (touch.sensor_id) { |
301 | case 0: | 325 | case 0: |
302 | case 2: | 326 | case 2: |
@@ -375,10 +399,6 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv) | |||
375 | 399 | ||
376 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 400 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
377 | __set_bit(BTN_TOUCH, input_dev->keybit); | 401 | __set_bit(BTN_TOUCH, input_dev->keybit); |
378 | __set_bit(BTN_TOOL_PEN, input_dev->keybit); | ||
379 | __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); | ||
380 | __set_bit(BTN_STYLUS, input_dev->keybit); | ||
381 | __set_bit(BTN_STYLUS2, input_dev->keybit); | ||
382 | 402 | ||
383 | serio_set_drvdata(serio, w8001); | 403 | serio_set_drvdata(serio, w8001); |
384 | err = serio_open(serio, drv); | 404 | err = serio_open(serio, drv); |