wacom_serial4.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /*
  2. * Wacom protocol 4 serial tablet driver
  3. *
  4. * Copyright 2014 Hans de Goede <hdegoede@redhat.com>
  5. * Copyright 2011-2012 Julian Squires <julian@cipht.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version of 2 of the License, or (at your
  10. * option) any later version. See the file COPYING in the main directory of
  11. * this archive for more details.
  12. *
  13. * Many thanks to Bill Seremetis, without whom PenPartner support
  14. * would not have been possible. Thanks to Patrick Mahoney.
  15. *
  16. * This driver was developed with reference to much code written by others,
  17. * particularly:
  18. * - elo, gunze drivers by Vojtech Pavlik <vojtech@ucw.cz>;
  19. * - wacom_w8001 driver by Jaya Kumar <jayakumar.lkml@gmail.com>;
  20. * - the USB wacom input driver, credited to many people
  21. * (see drivers/input/tablet/wacom.h);
  22. * - new and old versions of linuxwacom / xf86-input-wacom credited to
  23. * Frederic Lepied, France. <Lepied@XFree86.org> and
  24. * Ping Cheng, Wacom. <pingc@wacom.com>;
  25. * - and xf86wacom.c (a presumably ancient version of the linuxwacom code),
  26. * by Frederic Lepied and Raph Levien <raph@gtk.org>.
  27. *
  28. * To do:
  29. * - support pad buttons; (requires access to a model with pad buttons)
  30. * - support (protocol 4-style) tilt (requires access to a > 1.4 rom model)
  31. */
  32. /*
  33. * Wacom serial protocol 4 documentation taken from linuxwacom-0.9.9 code,
  34. * protocol 4 uses 7 or 9 byte of data in the following format:
  35. *
  36. * Byte 1
  37. * bit 7 Sync bit always 1
  38. * bit 6 Pointing device detected
  39. * bit 5 Cursor = 0 / Stylus = 1
  40. * bit 4 Reserved
  41. * bit 3 1 if a button on the pointing device has been pressed
  42. * bit 2 P0 (optional)
  43. * bit 1 X15
  44. * bit 0 X14
  45. *
  46. * Byte 2
  47. * bit 7 Always 0
  48. * bits 6-0 = X13 - X7
  49. *
  50. * Byte 3
  51. * bit 7 Always 0
  52. * bits 6-0 = X6 - X0
  53. *
  54. * Byte 4
  55. * bit 7 Always 0
  56. * bit 6 B3
  57. * bit 5 B2
  58. * bit 4 B1
  59. * bit 3 B0
  60. * bit 2 P1 (optional)
  61. * bit 1 Y15
  62. * bit 0 Y14
  63. *
  64. * Byte 5
  65. * bit 7 Always 0
  66. * bits 6-0 = Y13 - Y7
  67. *
  68. * Byte 6
  69. * bit 7 Always 0
  70. * bits 6-0 = Y6 - Y0
  71. *
  72. * Byte 7
  73. * bit 7 Always 0
  74. * bit 6 Sign of pressure data; or wheel-rel for cursor tool
  75. * bit 5 P7; or REL1 for cursor tool
  76. * bit 4 P6; or REL0 for cursor tool
  77. * bit 3 P5
  78. * bit 2 P4
  79. * bit 1 P3
  80. * bit 0 P2
  81. *
  82. * byte 8 and 9 are optional and present only
  83. * in tilt mode.
  84. *
  85. * Byte 8
  86. * bit 7 Always 0
  87. * bit 6 Sign of tilt X
  88. * bit 5 Xt6
  89. * bit 4 Xt5
  90. * bit 3 Xt4
  91. * bit 2 Xt3
  92. * bit 1 Xt2
  93. * bit 0 Xt1
  94. *
  95. * Byte 9
  96. * bit 7 Always 0
  97. * bit 6 Sign of tilt Y
  98. * bit 5 Yt6
  99. * bit 4 Yt5
  100. * bit 3 Yt4
  101. * bit 2 Yt3
  102. * bit 1 Yt2
  103. * bit 0 Yt1
  104. */
  105. #include <linux/completion.h>
  106. #include <linux/init.h>
  107. #include <linux/input.h>
  108. #include <linux/interrupt.h>
  109. #include <linux/kernel.h>
  110. #include <linux/module.h>
  111. #include <linux/serio.h>
  112. #include <linux/slab.h>
  113. #include <linux/string.h>
  114. MODULE_AUTHOR("Julian Squires <julian@cipht.net>, Hans de Goede <hdegoede@redhat.com>");
  115. MODULE_DESCRIPTION("Wacom protocol 4 serial tablet driver");
  116. MODULE_LICENSE("GPL");
  117. #define REQUEST_MODEL_AND_ROM_VERSION "~#"
  118. #define REQUEST_MAX_COORDINATES "~C\r"
  119. #define REQUEST_CONFIGURATION_STRING "~R\r"
  120. #define REQUEST_RESET_TO_PROTOCOL_IV "\r#"
  121. /*
  122. * Note: sending "\r$\r" causes at least the Digitizer II to send
  123. * packets in ASCII instead of binary. "\r#" seems to undo that.
  124. */
  125. #define COMMAND_START_SENDING_PACKETS "ST\r"
  126. #define COMMAND_STOP_SENDING_PACKETS "SP\r"
  127. #define COMMAND_MULTI_MODE_INPUT "MU1\r"
  128. #define COMMAND_ORIGIN_IN_UPPER_LEFT "OC1\r"
  129. #define COMMAND_ENABLE_ALL_MACRO_BUTTONS "~M0\r"
  130. #define COMMAND_DISABLE_GROUP_1_MACRO_BUTTONS "~M1\r"
  131. #define COMMAND_TRANSMIT_AT_MAX_RATE "IT0\r"
  132. #define COMMAND_DISABLE_INCREMENTAL_MODE "IN0\r"
  133. #define COMMAND_ENABLE_CONTINUOUS_MODE "SR\r"
  134. #define COMMAND_ENABLE_PRESSURE_MODE "PH1\r"
  135. #define COMMAND_Z_FILTER "ZF1\r"
  136. /* Note that this is a protocol 4 packet without tilt information. */
  137. #define PACKET_LENGTH 7
  138. #define DATA_SIZE 32
  139. /* flags */
  140. #define F_COVERS_SCREEN 0x01
  141. #define F_HAS_STYLUS2 0x02
  142. #define F_HAS_SCROLLWHEEL 0x04
  143. /* device IDs */
  144. #define STYLUS_DEVICE_ID 0x02
  145. #define CURSOR_DEVICE_ID 0x06
  146. #define ERASER_DEVICE_ID 0x0A
  147. enum { STYLUS = 1, ERASER, CURSOR };
  148. static const struct {
  149. int device_id;
  150. int input_id;
  151. } tools[] = {
  152. { 0, 0 },
  153. { STYLUS_DEVICE_ID, BTN_TOOL_PEN },
  154. { ERASER_DEVICE_ID, BTN_TOOL_RUBBER },
  155. { CURSOR_DEVICE_ID, BTN_TOOL_MOUSE },
  156. };
  157. struct wacom {
  158. struct input_dev *dev;
  159. struct completion cmd_done;
  160. int result;
  161. u8 expect;
  162. u8 eraser_mask;
  163. unsigned int extra_z_bits;
  164. unsigned int flags;
  165. unsigned int res_x, res_y;
  166. unsigned int max_x, max_y;
  167. unsigned int tool;
  168. unsigned int idx;
  169. u8 data[DATA_SIZE];
  170. char phys[32];
  171. };
  172. enum {
  173. MODEL_CINTIQ = 0x504C, /* PL */
  174. MODEL_CINTIQ2 = 0x4454, /* DT */
  175. MODEL_DIGITIZER_II = 0x5544, /* UD */
  176. MODEL_GRAPHIRE = 0x4554, /* ET */
  177. MODEL_PENPARTNER = 0x4354, /* CT */
  178. MODEL_ARTPAD_II = 0x4B54, /* KT */
  179. };
  180. static void wacom_handle_model_response(struct wacom *wacom)
  181. {
  182. int major_v, minor_v, r = 0;
  183. char *p;
  184. p = strrchr(wacom->data, 'V');
  185. if (p)
  186. r = sscanf(p + 1, "%u.%u", &major_v, &minor_v);
  187. if (r != 2)
  188. major_v = minor_v = 0;
  189. switch (wacom->data[2] << 8 | wacom->data[3]) {
  190. case MODEL_CINTIQ: /* UNTESTED */
  191. case MODEL_CINTIQ2:
  192. if ((wacom->data[2] << 8 | wacom->data[3]) == MODEL_CINTIQ) {
  193. wacom->dev->name = "Wacom Cintiq";
  194. wacom->dev->id.version = MODEL_CINTIQ;
  195. } else {
  196. wacom->dev->name = "Wacom Cintiq II";
  197. wacom->dev->id.version = MODEL_CINTIQ2;
  198. }
  199. wacom->res_x = 508;
  200. wacom->res_y = 508;
  201. switch (wacom->data[5] << 8 | wacom->data[6]) {
  202. case 0x3731: /* PL-710 */
  203. wacom->res_x = 2540;
  204. wacom->res_y = 2540;
  205. /* fall through */
  206. case 0x3535: /* PL-550 */
  207. case 0x3830: /* PL-800 */
  208. wacom->extra_z_bits = 2;
  209. }
  210. wacom->flags = F_COVERS_SCREEN;
  211. break;
  212. case MODEL_PENPARTNER:
  213. wacom->dev->name = "Wacom Penpartner";
  214. wacom->dev->id.version = MODEL_PENPARTNER;
  215. wacom->res_x = 1000;
  216. wacom->res_y = 1000;
  217. break;
  218. case MODEL_GRAPHIRE:
  219. wacom->dev->name = "Wacom Graphire";
  220. wacom->dev->id.version = MODEL_GRAPHIRE;
  221. wacom->res_x = 1016;
  222. wacom->res_y = 1016;
  223. wacom->max_x = 5103;
  224. wacom->max_y = 3711;
  225. wacom->extra_z_bits = 2;
  226. wacom->eraser_mask = 0x08;
  227. wacom->flags = F_HAS_STYLUS2 | F_HAS_SCROLLWHEEL;
  228. break;
  229. case MODEL_ARTPAD_II:
  230. case MODEL_DIGITIZER_II:
  231. wacom->dev->name = "Wacom Digitizer II";
  232. wacom->dev->id.version = MODEL_DIGITIZER_II;
  233. if (major_v == 1 && minor_v <= 2)
  234. wacom->extra_z_bits = 0; /* UNTESTED */
  235. break;
  236. default:
  237. dev_err(&wacom->dev->dev, "Unsupported Wacom model %s\n",
  238. wacom->data);
  239. wacom->result = -ENODEV;
  240. return;
  241. }
  242. dev_info(&wacom->dev->dev, "%s tablet, version %u.%u\n",
  243. wacom->dev->name, major_v, minor_v);
  244. }
  245. static void wacom_handle_configuration_response(struct wacom *wacom)
  246. {
  247. int r, skip;
  248. dev_dbg(&wacom->dev->dev, "Configuration string: %s\n", wacom->data);
  249. r = sscanf(wacom->data, "~R%x,%u,%u,%u,%u", &skip, &skip, &skip,
  250. &wacom->res_x, &wacom->res_y);
  251. if (r != 5)
  252. dev_warn(&wacom->dev->dev, "could not get resolution\n");
  253. }
  254. static void wacom_handle_coordinates_response(struct wacom *wacom)
  255. {
  256. int r;
  257. dev_dbg(&wacom->dev->dev, "Coordinates string: %s\n", wacom->data);
  258. r = sscanf(wacom->data, "~C%u,%u", &wacom->max_x, &wacom->max_y);
  259. if (r != 2)
  260. dev_warn(&wacom->dev->dev, "could not get max coordinates\n");
  261. }
  262. static void wacom_handle_response(struct wacom *wacom)
  263. {
  264. if (wacom->data[0] != '~' || wacom->data[1] != wacom->expect) {
  265. dev_err(&wacom->dev->dev,
  266. "Wacom got an unexpected response: %s\n", wacom->data);
  267. wacom->result = -EIO;
  268. } else {
  269. wacom->result = 0;
  270. switch (wacom->data[1]) {
  271. case '#':
  272. wacom_handle_model_response(wacom);
  273. break;
  274. case 'R':
  275. wacom_handle_configuration_response(wacom);
  276. break;
  277. case 'C':
  278. wacom_handle_coordinates_response(wacom);
  279. break;
  280. }
  281. }
  282. complete(&wacom->cmd_done);
  283. }
  284. static void wacom_handle_packet(struct wacom *wacom)
  285. {
  286. u8 in_proximity_p, stylus_p, button;
  287. unsigned int tool;
  288. int x, y, z;
  289. in_proximity_p = wacom->data[0] & 0x40;
  290. stylus_p = wacom->data[0] & 0x20;
  291. button = (wacom->data[3] & 0x78) >> 3;
  292. x = (wacom->data[0] & 3) << 14 | wacom->data[1]<<7 | wacom->data[2];
  293. y = (wacom->data[3] & 3) << 14 | wacom->data[4]<<7 | wacom->data[5];
  294. if (in_proximity_p && stylus_p) {
  295. z = wacom->data[6] & 0x7f;
  296. if (wacom->extra_z_bits >= 1)
  297. z = z << 1 | (wacom->data[3] & 0x4) >> 2;
  298. if (wacom->extra_z_bits > 1)
  299. z = z << 1 | (wacom->data[0] & 0x4) >> 2;
  300. z = z ^ (0x40 << wacom->extra_z_bits);
  301. } else {
  302. z = -1;
  303. }
  304. if (stylus_p)
  305. tool = (button & wacom->eraser_mask) ? ERASER : STYLUS;
  306. else
  307. tool = CURSOR;
  308. if (tool != wacom->tool && wacom->tool != 0) {
  309. input_report_key(wacom->dev, tools[wacom->tool].input_id, 0);
  310. input_sync(wacom->dev);
  311. }
  312. wacom->tool = tool;
  313. input_report_key(wacom->dev, tools[tool].input_id, in_proximity_p);
  314. input_report_abs(wacom->dev, ABS_MISC,
  315. in_proximity_p ? tools[tool].device_id : 0);
  316. input_report_abs(wacom->dev, ABS_X, x);
  317. input_report_abs(wacom->dev, ABS_Y, y);
  318. input_report_abs(wacom->dev, ABS_PRESSURE, z);
  319. if (stylus_p) {
  320. input_report_key(wacom->dev, BTN_TOUCH, button & 1);
  321. input_report_key(wacom->dev, BTN_STYLUS, button & 2);
  322. input_report_key(wacom->dev, BTN_STYLUS2, button & 4);
  323. } else {
  324. input_report_key(wacom->dev, BTN_LEFT, button & 1);
  325. input_report_key(wacom->dev, BTN_RIGHT, button & 2);
  326. input_report_key(wacom->dev, BTN_MIDDLE, button & 4);
  327. /* handle relative wheel for non-stylus device */
  328. z = (wacom->data[6] & 0x30) >> 4;
  329. if (wacom->data[6] & 0x40)
  330. z = -z;
  331. input_report_rel(wacom->dev, REL_WHEEL, z);
  332. }
  333. input_sync(wacom->dev);
  334. }
  335. static void wacom_clear_data_buf(struct wacom *wacom)
  336. {
  337. memset(wacom->data, 0, DATA_SIZE);
  338. wacom->idx = 0;
  339. }
  340. static irqreturn_t wacom_interrupt(struct serio *serio, unsigned char data,
  341. unsigned int flags)
  342. {
  343. struct wacom *wacom = serio_get_drvdata(serio);
  344. if (data & 0x80)
  345. wacom->idx = 0;
  346. /*
  347. * We're either expecting a carriage return-terminated ASCII
  348. * response string, or a seven-byte packet with the MSB set on
  349. * the first byte.
  350. *
  351. * Note however that some tablets (the PenPartner, for
  352. * example) don't send a carriage return at the end of a
  353. * command. We handle these by waiting for timeout.
  354. */
  355. if (data == '\r' && !(wacom->data[0] & 0x80)) {
  356. wacom_handle_response(wacom);
  357. wacom_clear_data_buf(wacom);
  358. return IRQ_HANDLED;
  359. }
  360. /* Leave place for 0 termination */
  361. if (wacom->idx > (DATA_SIZE - 2)) {
  362. dev_dbg(&wacom->dev->dev,
  363. "throwing away %d bytes of garbage\n", wacom->idx);
  364. wacom_clear_data_buf(wacom);
  365. }
  366. wacom->data[wacom->idx++] = data;
  367. if (wacom->idx == PACKET_LENGTH && (wacom->data[0] & 0x80)) {
  368. wacom_handle_packet(wacom);
  369. wacom_clear_data_buf(wacom);
  370. }
  371. return IRQ_HANDLED;
  372. }
  373. static void wacom_disconnect(struct serio *serio)
  374. {
  375. struct wacom *wacom = serio_get_drvdata(serio);
  376. serio_close(serio);
  377. serio_set_drvdata(serio, NULL);
  378. input_unregister_device(wacom->dev);
  379. kfree(wacom);
  380. }
  381. static int wacom_send(struct serio *serio, const u8 *command)
  382. {
  383. int err = 0;
  384. for (; !err && *command; command++)
  385. err = serio_write(serio, *command);
  386. return err;
  387. }
  388. static int wacom_send_setup_string(struct wacom *wacom, struct serio *serio)
  389. {
  390. const u8 *cmd;
  391. switch (wacom->dev->id.version) {
  392. case MODEL_CINTIQ: /* UNTESTED */
  393. cmd = COMMAND_ORIGIN_IN_UPPER_LEFT
  394. COMMAND_TRANSMIT_AT_MAX_RATE
  395. COMMAND_ENABLE_CONTINUOUS_MODE
  396. COMMAND_START_SENDING_PACKETS;
  397. break;
  398. case MODEL_PENPARTNER:
  399. cmd = COMMAND_ENABLE_PRESSURE_MODE
  400. COMMAND_START_SENDING_PACKETS;
  401. break;
  402. default:
  403. cmd = COMMAND_MULTI_MODE_INPUT
  404. COMMAND_ORIGIN_IN_UPPER_LEFT
  405. COMMAND_ENABLE_ALL_MACRO_BUTTONS
  406. COMMAND_DISABLE_GROUP_1_MACRO_BUTTONS
  407. COMMAND_TRANSMIT_AT_MAX_RATE
  408. COMMAND_DISABLE_INCREMENTAL_MODE
  409. COMMAND_ENABLE_CONTINUOUS_MODE
  410. COMMAND_Z_FILTER
  411. COMMAND_START_SENDING_PACKETS;
  412. break;
  413. }
  414. return wacom_send(serio, cmd);
  415. }
  416. static int wacom_send_and_wait(struct wacom *wacom, struct serio *serio,
  417. const u8 *cmd, const char *desc)
  418. {
  419. int err;
  420. unsigned long u;
  421. wacom->expect = cmd[1];
  422. init_completion(&wacom->cmd_done);
  423. err = wacom_send(serio, cmd);
  424. if (err)
  425. return err;
  426. u = wait_for_completion_timeout(&wacom->cmd_done, HZ);
  427. if (u == 0) {
  428. /* Timeout, process what we've received. */
  429. wacom_handle_response(wacom);
  430. }
  431. wacom->expect = 0;
  432. return wacom->result;
  433. }
  434. static int wacom_setup(struct wacom *wacom, struct serio *serio)
  435. {
  436. int err;
  437. /* Note that setting the link speed is the job of inputattach.
  438. * We assume that reset negotiation has already happened,
  439. * here. */
  440. err = wacom_send_and_wait(wacom, serio, REQUEST_MODEL_AND_ROM_VERSION,
  441. "model and version");
  442. if (err)
  443. return err;
  444. if (!(wacom->res_x && wacom->res_y)) {
  445. err = wacom_send_and_wait(wacom, serio,
  446. REQUEST_CONFIGURATION_STRING,
  447. "configuration string");
  448. if (err)
  449. return err;
  450. }
  451. if (!(wacom->max_x && wacom->max_y)) {
  452. err = wacom_send_and_wait(wacom, serio,
  453. REQUEST_MAX_COORDINATES,
  454. "coordinates string");
  455. if (err)
  456. return err;
  457. }
  458. return wacom_send_setup_string(wacom, serio);
  459. }
  460. static int wacom_connect(struct serio *serio, struct serio_driver *drv)
  461. {
  462. struct wacom *wacom;
  463. struct input_dev *input_dev;
  464. int err = -ENOMEM;
  465. wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
  466. input_dev = input_allocate_device();
  467. if (!wacom || !input_dev)
  468. goto free_device;
  469. wacom->dev = input_dev;
  470. wacom->extra_z_bits = 1;
  471. wacom->eraser_mask = 0x04;
  472. wacom->tool = wacom->idx = 0;
  473. snprintf(wacom->phys, sizeof(wacom->phys), "%s/input0", serio->phys);
  474. input_dev->phys = wacom->phys;
  475. input_dev->id.bustype = BUS_RS232;
  476. input_dev->id.vendor = SERIO_WACOM_IV;
  477. input_dev->id.product = serio->id.extra;
  478. input_dev->dev.parent = &serio->dev;
  479. input_dev->evbit[0] =
  480. BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | BIT_MASK(EV_REL);
  481. set_bit(ABS_MISC, input_dev->absbit);
  482. set_bit(BTN_TOOL_PEN, input_dev->keybit);
  483. set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  484. set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  485. set_bit(BTN_TOUCH, input_dev->keybit);
  486. set_bit(BTN_STYLUS, input_dev->keybit);
  487. set_bit(BTN_LEFT, input_dev->keybit);
  488. set_bit(BTN_RIGHT, input_dev->keybit);
  489. set_bit(BTN_MIDDLE, input_dev->keybit);
  490. serio_set_drvdata(serio, wacom);
  491. err = serio_open(serio, drv);
  492. if (err)
  493. goto free_device;
  494. err = wacom_setup(wacom, serio);
  495. if (err)
  496. goto close_serio;
  497. set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  498. if (!(wacom->flags & F_COVERS_SCREEN))
  499. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  500. if (wacom->flags & F_HAS_STYLUS2)
  501. __set_bit(BTN_STYLUS2, input_dev->keybit);
  502. if (wacom->flags & F_HAS_SCROLLWHEEL)
  503. __set_bit(REL_WHEEL, input_dev->relbit);
  504. input_abs_set_res(wacom->dev, ABS_X, wacom->res_x);
  505. input_abs_set_res(wacom->dev, ABS_Y, wacom->res_y);
  506. input_set_abs_params(wacom->dev, ABS_X, 0, wacom->max_x, 0, 0);
  507. input_set_abs_params(wacom->dev, ABS_Y, 0, wacom->max_y, 0, 0);
  508. input_set_abs_params(wacom->dev, ABS_PRESSURE, -1,
  509. (1 << (7 + wacom->extra_z_bits)) - 1, 0, 0);
  510. err = input_register_device(wacom->dev);
  511. if (err)
  512. goto close_serio;
  513. return 0;
  514. close_serio:
  515. serio_close(serio);
  516. free_device:
  517. serio_set_drvdata(serio, NULL);
  518. input_free_device(input_dev);
  519. kfree(wacom);
  520. return err;
  521. }
  522. static struct serio_device_id wacom_serio_ids[] = {
  523. {
  524. .type = SERIO_RS232,
  525. .proto = SERIO_WACOM_IV,
  526. .id = SERIO_ANY,
  527. .extra = SERIO_ANY,
  528. },
  529. { 0 }
  530. };
  531. MODULE_DEVICE_TABLE(serio, wacom_serio_ids);
  532. static struct serio_driver wacom_drv = {
  533. .driver = {
  534. .name = "wacom_serial4",
  535. },
  536. .description = "Wacom protocol 4 serial tablet driver",
  537. .id_table = wacom_serio_ids,
  538. .interrupt = wacom_interrupt,
  539. .connect = wacom_connect,
  540. .disconnect = wacom_disconnect,
  541. };
  542. module_serio_driver(wacom_drv);