Lines Matching +full:0 +full:- +full:9 +full:a +full:- +full:z
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright 2011-2012 Julian Squires <julian@cipht.net>
13 * - elo, gunze drivers by Vojtech Pavlik <vojtech@ucw.cz>;
14 * - wacom_w8001 driver by Jaya Kumar <jayakumar.lkml@gmail.com>;
15 * - the USB wacom input driver, credited to many people
17 * - new and old versions of linuxwacom / xf86-input-wacom credited to
20 * - and xf86wacom.c (a presumably ancient version of the linuxwacom code),
24 * - support pad buttons; (requires access to a model with pad buttons)
25 * - support (protocol 4-style) tilt (requires access to a > 1.4 rom model)
29 * Wacom serial protocol 4 documentation taken from linuxwacom-0.9.9 code,
30 * protocol 4 uses 7 or 9 byte of data in the following format:
35 * bit 5 Cursor = 0 / Stylus = 1
37 * bit 3 1 if a button on the pointing device has been pressed
40 * bit 0 X14
43 * bit 7 Always 0
44 * bits 6-0 = X13 - X7
47 * bit 7 Always 0
48 * bits 6-0 = X6 - X0
51 * bit 7 Always 0
58 * bit 0 Y14
61 * bit 7 Always 0
62 * bits 6-0 = Y13 - Y7
65 * bit 7 Always 0
66 * bits 6-0 = Y6 - Y0
69 * bit 7 Always 0
70 * bit 6 Sign of pressure data; or wheel-rel for cursor tool
76 * bit 0 P2
78 * byte 8 and 9 are optional and present only
82 * bit 7 Always 0
89 * bit 0 Xt1
91 * Byte 9
92 * bit 7 Always 0
99 * bit 0 Yt1
137 /* Note that this is a protocol 4 packet without tilt information. */
142 #define F_COVERS_SCREEN 0x01
143 #define F_HAS_STYLUS2 0x02
144 #define F_HAS_SCROLLWHEEL 0x04
147 #define STYLUS_DEVICE_ID 0x02
148 #define CURSOR_DEVICE_ID 0x06
149 #define ERASER_DEVICE_ID 0x0A
157 { 0, 0 },
180 MODEL_CINTIQ = 0x504C, /* PL */
181 MODEL_CINTIQ2 = 0x4454, /* DT */
182 MODEL_DIGITIZER_II = 0x5544, /* UD */
183 MODEL_GRAPHIRE = 0x4554, /* ET */
184 MODEL_PENPARTNER = 0x4354, /* CT */
185 MODEL_ARTPAD_II = 0x4B54, /* KT */
190 int major_v, minor_v, r = 0; in wacom_handle_model_response()
193 p = strrchr(wacom->data, 'V'); in wacom_handle_model_response()
197 major_v = minor_v = 0; in wacom_handle_model_response()
199 switch (wacom->data[2] << 8 | wacom->data[3]) { in wacom_handle_model_response()
202 if ((wacom->data[2] << 8 | wacom->data[3]) == MODEL_CINTIQ) { in wacom_handle_model_response()
203 wacom->dev->name = "Wacom Cintiq"; in wacom_handle_model_response()
204 wacom->dev->id.version = MODEL_CINTIQ; in wacom_handle_model_response()
206 wacom->dev->name = "Wacom Cintiq II"; in wacom_handle_model_response()
207 wacom->dev->id.version = MODEL_CINTIQ2; in wacom_handle_model_response()
209 wacom->res_x = 508; in wacom_handle_model_response()
210 wacom->res_y = 508; in wacom_handle_model_response()
212 switch (wacom->data[5] << 8 | wacom->data[6]) { in wacom_handle_model_response()
213 case 0x3731: /* PL-710 */ in wacom_handle_model_response()
214 wacom->res_x = 2540; in wacom_handle_model_response()
215 wacom->res_y = 2540; in wacom_handle_model_response()
217 case 0x3535: /* PL-550 */ in wacom_handle_model_response()
218 case 0x3830: /* PL-800 */ in wacom_handle_model_response()
219 wacom->extra_z_bits = 2; in wacom_handle_model_response()
222 wacom->flags = F_COVERS_SCREEN; in wacom_handle_model_response()
226 wacom->dev->name = "Wacom Penpartner"; in wacom_handle_model_response()
227 wacom->dev->id.version = MODEL_PENPARTNER; in wacom_handle_model_response()
228 wacom->res_x = 1000; in wacom_handle_model_response()
229 wacom->res_y = 1000; in wacom_handle_model_response()
233 wacom->dev->name = "Wacom Graphire"; in wacom_handle_model_response()
234 wacom->dev->id.version = MODEL_GRAPHIRE; in wacom_handle_model_response()
235 wacom->res_x = 1016; in wacom_handle_model_response()
236 wacom->res_y = 1016; in wacom_handle_model_response()
237 wacom->max_x = 5103; in wacom_handle_model_response()
238 wacom->max_y = 3711; in wacom_handle_model_response()
239 wacom->extra_z_bits = 2; in wacom_handle_model_response()
240 wacom->eraser_mask = 0x08; in wacom_handle_model_response()
241 wacom->flags = F_HAS_STYLUS2 | F_HAS_SCROLLWHEEL; in wacom_handle_model_response()
246 wacom->dev->name = "Wacom Digitizer II"; in wacom_handle_model_response()
247 wacom->dev->id.version = MODEL_DIGITIZER_II; in wacom_handle_model_response()
249 wacom->extra_z_bits = 0; /* UNTESTED */ in wacom_handle_model_response()
253 dev_err(&wacom->dev->dev, "Unsupported Wacom model %s\n", in wacom_handle_model_response()
254 wacom->data); in wacom_handle_model_response()
255 wacom->result = -ENODEV; in wacom_handle_model_response()
259 dev_info(&wacom->dev->dev, "%s tablet, version %u.%u\n", in wacom_handle_model_response()
260 wacom->dev->name, major_v, minor_v); in wacom_handle_model_response()
267 dev_dbg(&wacom->dev->dev, "Configuration string: %s\n", wacom->data); in wacom_handle_configuration_response()
268 r = sscanf(wacom->data, "~R%x,%u,%u,%u,%u", &skip, &skip, &skip, in wacom_handle_configuration_response()
269 &wacom->res_x, &wacom->res_y); in wacom_handle_configuration_response()
271 dev_warn(&wacom->dev->dev, "could not get resolution\n"); in wacom_handle_configuration_response()
278 dev_dbg(&wacom->dev->dev, "Coordinates string: %s\n", wacom->data); in wacom_handle_coordinates_response()
279 r = sscanf(wacom->data, "~C%u,%u", &wacom->max_x, &wacom->max_y); in wacom_handle_coordinates_response()
281 dev_warn(&wacom->dev->dev, "could not get max coordinates\n"); in wacom_handle_coordinates_response()
286 if (wacom->data[0] != '~' || wacom->data[1] != wacom->expect) { in wacom_handle_response()
287 dev_err(&wacom->dev->dev, in wacom_handle_response()
288 "Wacom got an unexpected response: %s\n", wacom->data); in wacom_handle_response()
289 wacom->result = -EIO; in wacom_handle_response()
291 wacom->result = 0; in wacom_handle_response()
293 switch (wacom->data[1]) { in wacom_handle_response()
306 complete(&wacom->cmd_done); in wacom_handle_response()
313 int x, y, z; in wacom_handle_packet() local
315 in_proximity_p = wacom->data[0] & 0x40; in wacom_handle_packet()
316 stylus_p = wacom->data[0] & 0x20; in wacom_handle_packet()
317 button = (wacom->data[3] & 0x78) >> 3; in wacom_handle_packet()
318 x = (wacom->data[0] & 3) << 14 | wacom->data[1]<<7 | wacom->data[2]; in wacom_handle_packet()
319 y = (wacom->data[3] & 3) << 14 | wacom->data[4]<<7 | wacom->data[5]; in wacom_handle_packet()
322 z = wacom->data[6] & 0x7f; in wacom_handle_packet()
323 if (wacom->extra_z_bits >= 1) in wacom_handle_packet()
324 z = z << 1 | (wacom->data[3] & 0x4) >> 2; in wacom_handle_packet()
325 if (wacom->extra_z_bits > 1) in wacom_handle_packet()
326 z = z << 1 | (wacom->data[0] & 0x4) >> 2; in wacom_handle_packet()
327 z = z ^ (0x40 << wacom->extra_z_bits); in wacom_handle_packet()
329 z = -1; in wacom_handle_packet()
333 tool = (button & wacom->eraser_mask) ? ERASER : STYLUS; in wacom_handle_packet()
337 if (tool != wacom->tool && wacom->tool != 0) { in wacom_handle_packet()
338 input_report_key(wacom->dev, tools[wacom->tool].input_id, 0); in wacom_handle_packet()
339 input_sync(wacom->dev); in wacom_handle_packet()
341 wacom->tool = tool; in wacom_handle_packet()
343 input_report_key(wacom->dev, tools[tool].input_id, in_proximity_p); in wacom_handle_packet()
344 input_report_abs(wacom->dev, ABS_MISC, in wacom_handle_packet()
345 in_proximity_p ? tools[tool].device_id : 0); in wacom_handle_packet()
346 input_report_abs(wacom->dev, ABS_X, x); in wacom_handle_packet()
347 input_report_abs(wacom->dev, ABS_Y, y); in wacom_handle_packet()
348 input_report_abs(wacom->dev, ABS_PRESSURE, z); in wacom_handle_packet()
350 input_report_key(wacom->dev, BTN_TOUCH, button & 1); in wacom_handle_packet()
351 input_report_key(wacom->dev, BTN_STYLUS, button & 2); in wacom_handle_packet()
352 input_report_key(wacom->dev, BTN_STYLUS2, button & 4); in wacom_handle_packet()
354 input_report_key(wacom->dev, BTN_LEFT, button & 1); in wacom_handle_packet()
355 input_report_key(wacom->dev, BTN_RIGHT, button & 2); in wacom_handle_packet()
356 input_report_key(wacom->dev, BTN_MIDDLE, button & 4); in wacom_handle_packet()
357 /* handle relative wheel for non-stylus device */ in wacom_handle_packet()
358 z = (wacom->data[6] & 0x30) >> 4; in wacom_handle_packet()
359 if (wacom->data[6] & 0x40) in wacom_handle_packet()
360 z = -z; in wacom_handle_packet()
361 input_report_rel(wacom->dev, REL_WHEEL, z); in wacom_handle_packet()
363 input_sync(wacom->dev); in wacom_handle_packet()
368 memset(wacom->data, 0, DATA_SIZE); in wacom_clear_data_buf()
369 wacom->idx = 0; in wacom_clear_data_buf()
377 if (data & 0x80) in wacom_interrupt()
378 wacom->idx = 0; in wacom_interrupt()
381 * We're either expecting a carriage return-terminated ASCII in wacom_interrupt()
382 * response string, or a seven-byte packet with the MSB set on in wacom_interrupt()
386 * example) don't send a carriage return at the end of a in wacom_interrupt()
389 if (data == '\r' && !(wacom->data[0] & 0x80)) { in wacom_interrupt()
395 /* Leave place for 0 termination */ in wacom_interrupt()
396 if (wacom->idx > (DATA_SIZE - 2)) { in wacom_interrupt()
397 dev_dbg(&wacom->dev->dev, in wacom_interrupt()
398 "throwing away %d bytes of garbage\n", wacom->idx); in wacom_interrupt()
401 wacom->data[wacom->idx++] = data; in wacom_interrupt()
403 if (wacom->idx == PACKET_LENGTH && (wacom->data[0] & 0x80)) { in wacom_interrupt()
417 input_unregister_device(wacom->dev); in wacom_disconnect()
423 int err = 0; in wacom_send()
435 switch (wacom->dev->id.version) { in wacom_send_setup_string()
470 wacom->expect = cmd[1]; in wacom_send_and_wait()
471 init_completion(&wacom->cmd_done); in wacom_send_and_wait()
477 u = wait_for_completion_timeout(&wacom->cmd_done, HZ); in wacom_send_and_wait()
478 if (u == 0) { in wacom_send_and_wait()
483 wacom->expect = 0; in wacom_send_and_wait()
484 return wacom->result; in wacom_send_and_wait()
499 if (!(wacom->res_x && wacom->res_y)) { in wacom_setup()
507 if (!(wacom->max_x && wacom->max_y)) { in wacom_setup()
522 int err = -ENOMEM; in wacom_connect()
529 wacom->dev = input_dev; in wacom_connect()
530 wacom->extra_z_bits = 1; in wacom_connect()
531 wacom->eraser_mask = 0x04; in wacom_connect()
532 wacom->tool = wacom->idx = 0; in wacom_connect()
533 snprintf(wacom->phys, sizeof(wacom->phys), "%s/input0", serio->phys); in wacom_connect()
534 input_dev->phys = wacom->phys; in wacom_connect()
535 input_dev->id.bustype = BUS_RS232; in wacom_connect()
536 input_dev->id.vendor = SERIO_WACOM_IV; in wacom_connect()
537 input_dev->id.product = serio->id.extra; in wacom_connect()
538 input_dev->dev.parent = &serio->dev; in wacom_connect()
540 input_dev->evbit[0] = in wacom_connect()
542 set_bit(ABS_MISC, input_dev->absbit); in wacom_connect()
543 set_bit(BTN_TOOL_PEN, input_dev->keybit); in wacom_connect()
544 set_bit(BTN_TOOL_RUBBER, input_dev->keybit); in wacom_connect()
545 set_bit(BTN_TOOL_MOUSE, input_dev->keybit); in wacom_connect()
546 set_bit(BTN_TOUCH, input_dev->keybit); in wacom_connect()
547 set_bit(BTN_STYLUS, input_dev->keybit); in wacom_connect()
548 set_bit(BTN_LEFT, input_dev->keybit); in wacom_connect()
549 set_bit(BTN_RIGHT, input_dev->keybit); in wacom_connect()
550 set_bit(BTN_MIDDLE, input_dev->keybit); in wacom_connect()
562 set_bit(INPUT_PROP_DIRECT, input_dev->propbit); in wacom_connect()
563 if (!(wacom->flags & F_COVERS_SCREEN)) in wacom_connect()
564 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); in wacom_connect()
566 if (wacom->flags & F_HAS_STYLUS2) in wacom_connect()
567 __set_bit(BTN_STYLUS2, input_dev->keybit); in wacom_connect()
569 if (wacom->flags & F_HAS_SCROLLWHEEL) in wacom_connect()
570 __set_bit(REL_WHEEL, input_dev->relbit); in wacom_connect()
572 input_abs_set_res(wacom->dev, ABS_X, wacom->res_x); in wacom_connect()
573 input_abs_set_res(wacom->dev, ABS_Y, wacom->res_y); in wacom_connect()
574 input_set_abs_params(wacom->dev, ABS_X, 0, wacom->max_x, 0, 0); in wacom_connect()
575 input_set_abs_params(wacom->dev, ABS_Y, 0, wacom->max_y, 0, 0); in wacom_connect()
576 input_set_abs_params(wacom->dev, ABS_PRESSURE, -1, in wacom_connect()
577 (1 << (7 + wacom->extra_z_bits)) - 1, 0, 0); in wacom_connect()
579 err = input_register_device(wacom->dev); in wacom_connect()
583 return 0; in wacom_connect()
601 { 0 }