Lines Matching refs:w8001

82 struct w8001 {  struct
132 static void scale_touch_coordinates(struct w8001 *w8001, in scale_touch_coordinates() argument
135 if (w8001->max_pen_x && w8001->max_touch_x) in scale_touch_coordinates()
136 *x = *x * w8001->max_pen_x / w8001->max_touch_x; in scale_touch_coordinates()
138 if (w8001->max_pen_y && w8001->max_touch_y) in scale_touch_coordinates()
139 *y = *y * w8001->max_pen_y / w8001->max_touch_y; in scale_touch_coordinates()
142 static void parse_multi_touch(struct w8001 *w8001) in parse_multi_touch() argument
144 struct input_dev *dev = w8001->dev; in parse_multi_touch()
145 unsigned char *data = w8001->data; in parse_multi_touch()
161 scale_touch_coordinates(w8001, &x, &y); in parse_multi_touch()
173 if (w8001->type != BTN_TOOL_PEN && in parse_multi_touch()
174 w8001->type != BTN_TOOL_RUBBER) { in parse_multi_touch()
175 w8001->type = count == 1 ? BTN_TOOL_FINGER : KEY_RESERVED; in parse_multi_touch()
208 static void report_pen_events(struct w8001 *w8001, struct w8001_coord *coord) in report_pen_events() argument
210 struct input_dev *dev = w8001->dev; in report_pen_events()
222 switch (w8001->type) { in report_pen_events()
231 w8001->type = BTN_TOOL_PEN; in report_pen_events()
242 w8001->type = coord->f2 ? BTN_TOOL_RUBBER : BTN_TOOL_PEN; in report_pen_events()
255 input_report_key(dev, w8001->type, coord->rdy); in report_pen_events()
259 w8001->type = KEY_RESERVED; in report_pen_events()
262 static void report_single_touch(struct w8001 *w8001, struct w8001_coord *coord) in report_single_touch() argument
264 struct input_dev *dev = w8001->dev; in report_single_touch()
269 scale_touch_coordinates(w8001, &x, &y); in report_single_touch()
278 w8001->type = coord->tsw ? BTN_TOOL_FINGER : KEY_RESERVED; in report_single_touch()
284 struct w8001 *w8001 = serio_get_drvdata(serio); in w8001_interrupt() local
288 w8001->data[w8001->idx] = data; in w8001_interrupt()
289 switch (w8001->idx++) { in w8001_interrupt()
293 w8001->idx = 0; in w8001_interrupt()
299 tmp = w8001->data[0] & W8001_TOUCH_BYTE; in w8001_interrupt()
303 if (w8001->pktlen == w8001->idx) { in w8001_interrupt()
304 w8001->idx = 0; in w8001_interrupt()
305 if (w8001->type != BTN_TOOL_PEN && in w8001_interrupt()
306 w8001->type != BTN_TOOL_RUBBER) { in w8001_interrupt()
307 parse_single_touch(w8001->data, &coord); in w8001_interrupt()
308 report_single_touch(w8001, &coord); in w8001_interrupt()
315 tmp = w8001->data[0] & W8001_TAB_MASK; in w8001_interrupt()
319 tmp = w8001->data[0] & W8001_TOUCH_BYTE; in w8001_interrupt()
323 w8001->idx = 0; in w8001_interrupt()
324 parse_pen_data(w8001->data, &coord); in w8001_interrupt()
325 report_pen_events(w8001, &coord); in w8001_interrupt()
330 tmp = w8001->data[0] & W8001_TOUCH_MASK; in w8001_interrupt()
334 w8001->idx = 0; in w8001_interrupt()
335 memcpy(w8001->response, w8001->data, W8001_MAX_LENGTH); in w8001_interrupt()
336 w8001->response_type = W8001_QUERY_PACKET; in w8001_interrupt()
337 complete(&w8001->cmd_done); in w8001_interrupt()
342 w8001->idx = 0; in w8001_interrupt()
343 parse_multi_touch(w8001); in w8001_interrupt()
350 static int w8001_command(struct w8001 *w8001, unsigned char command, in w8001_command() argument
355 w8001->response_type = 0; in w8001_command()
356 init_completion(&w8001->cmd_done); in w8001_command()
358 rc = serio_write(w8001->serio, command); in w8001_command()
361 wait_for_completion_timeout(&w8001->cmd_done, HZ); in w8001_command()
362 if (w8001->response_type != W8001_QUERY_PACKET) in w8001_command()
371 struct w8001 *w8001 = input_get_drvdata(dev); in w8001_open() local
373 return w8001_command(w8001, W8001_CMD_START, false); in w8001_open()
378 struct w8001 *w8001 = input_get_drvdata(dev); in w8001_close() local
380 w8001_command(w8001, W8001_CMD_STOP, false); in w8001_close()
383 static int w8001_setup(struct w8001 *w8001) in w8001_setup() argument
385 struct input_dev *dev = w8001->dev; in w8001_setup()
390 error = w8001_command(w8001, W8001_CMD_STOP, false); in w8001_setup()
397 strlcat(w8001->name, "Wacom Serial", sizeof(w8001->name)); in w8001_setup()
402 error = w8001_command(w8001, W8001_CMD_QUERY, true); in w8001_setup()
410 parse_pen_data(w8001->response, &coord); in w8001_setup()
411 w8001->max_pen_x = coord.x; in w8001_setup()
412 w8001->max_pen_y = coord.y; in w8001_setup()
423 w8001->id = 0x90; in w8001_setup()
424 strlcat(w8001->name, " Penabled", sizeof(w8001->name)); in w8001_setup()
428 error = w8001_command(w8001, W8001_CMD_TOUCHQUERY, true); in w8001_setup()
434 if (!error && w8001->response[1]) { in w8001_setup()
438 parse_touchquery(w8001->response, &touch); in w8001_setup()
439 w8001->max_touch_x = touch.x; in w8001_setup()
440 w8001->max_touch_y = touch.y; in w8001_setup()
442 if (w8001->max_pen_x && w8001->max_pen_y) { in w8001_setup()
444 touch.x = w8001->max_pen_x; in w8001_setup()
445 touch.y = w8001->max_pen_y; in w8001_setup()
457 w8001->pktlen = W8001_PKTLEN_TOUCH93; in w8001_setup()
458 w8001->id = 0x93; in w8001_setup()
459 strlcat(w8001->name, " 1FG", sizeof(w8001->name)); in w8001_setup()
465 w8001->pktlen = W8001_PKTLEN_TOUCH9A; in w8001_setup()
466 strlcat(w8001->name, " 1FG", sizeof(w8001->name)); in w8001_setup()
467 w8001->id = 0x9a; in w8001_setup()
471 w8001->pktlen = W8001_PKTLEN_TOUCH2FG; in w8001_setup()
481 strlcat(w8001->name, " 2FG", sizeof(w8001->name)); in w8001_setup()
482 if (w8001->max_pen_x && w8001->max_pen_y) in w8001_setup()
483 w8001->id = 0xE3; in w8001_setup()
485 w8001->id = 0xE2; in w8001_setup()
490 strlcat(w8001->name, " Touchscreen", sizeof(w8001->name)); in w8001_setup()
501 struct w8001 *w8001 = serio_get_drvdata(serio); in w8001_disconnect() local
505 input_unregister_device(w8001->dev); in w8001_disconnect()
506 kfree(w8001); in w8001_disconnect()
519 struct w8001 *w8001; in w8001_connect() local
523 w8001 = kzalloc(sizeof(struct w8001), GFP_KERNEL); in w8001_connect()
525 if (!w8001 || !input_dev) { in w8001_connect()
530 w8001->serio = serio; in w8001_connect()
531 w8001->dev = input_dev; in w8001_connect()
532 init_completion(&w8001->cmd_done); in w8001_connect()
533 snprintf(w8001->phys, sizeof(w8001->phys), "%s/input0", serio->phys); in w8001_connect()
535 serio_set_drvdata(serio, w8001); in w8001_connect()
540 err = w8001_setup(w8001); in w8001_connect()
544 input_dev->name = w8001->name; in w8001_connect()
545 input_dev->phys = w8001->phys; in w8001_connect()
546 input_dev->id.product = w8001->id; in w8001_connect()
555 input_set_drvdata(input_dev, w8001); in w8001_connect()
557 err = input_register_device(w8001->dev); in w8001_connect()
569 kfree(w8001); in w8001_connect()