wacom_serial4.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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. };
  179. static void wacom_handle_model_response(struct wacom *wacom)
  180. {
  181. int major_v, minor_v, r = 0;
  182. char *p;
  183. p = strrchr(wacom->data, 'V');
  184. if (p)
  185. r = sscanf(p + 1, "%u.%u", &major_v, &minor_v);
  186. if (r != 2)
  187. major_v = minor_v = 0;
  188. switch (wacom->data[2] << 8 | wacom->data[3]) {
  189. case MODEL_CINTIQ: /* UNTESTED */
  190. case MODEL_CINTIQ2:
  191. if ((wacom->data[2] << 8 | wacom->data[3]) == MODEL_CINTIQ) {
  192. wacom->dev->name = "Wacom Cintiq";
  193. wacom->dev->id.version = MODEL_CINTIQ;
  194. } else {
  195. wacom->dev->name = "Wacom Cintiq II";
  196. wacom->dev->id.version = MODEL_CINTIQ2;
  197. }
  198. wacom->res_x = 508;
  199. wacom->res_y = 508;
  200. switch (wacom->data[5] << 8 | wacom->data[6]) {
  201. case 0x3731: /* PL-710 */
  202. wacom->res_x = 2540;
  203. wacom->res_y = 2540;
  204. /* fall through */
  205. case 0x3535: /* PL-550 */
  206. case 0x3830: /* PL-800 */
  207. wacom->extra_z_bits = 2;
  208. }
  209. wacom->flags = F_COVERS_SCREEN;
  210. break;
  211. case MODEL_PENPARTNER:
  212. wacom->dev->name = "Wacom Penpartner";
  213. wacom->dev->id.version = MODEL_PENPARTNER;
  214. wacom->res_x = 1000;
  215. wacom->res_y = 1000;
  216. break;
  217. case MODEL_GRAPHIRE:
  218. wacom->dev->name = "Wacom Graphire";
  219. wacom->dev->id.version = MODEL_GRAPHIRE;
  220. wacom->res_x = 1016;
  221. wacom->res_y = 1016;
  222. wacom->max_x = 5103;
  223. wacom->max_y = 3711;
  224. wacom->extra_z_bits = 2;
  225. wacom->eraser_mask = 0x08;
  226. wacom->flags = F_HAS_STYLUS2 | F_HAS_SCROLLWHEEL;
  227. break;
  228. case MODEL_DIGITIZER_II:
  229. wacom->dev->name = "Wacom Digitizer II";
  230. wacom->dev->id.version = MODEL_DIGITIZER_II;
  231. if (major_v == 1 && minor_v <= 2)
  232. wacom->extra_z_bits = 0; /* UNTESTED */
  233. break;
  234. default:
  235. dev_err(&wacom->dev->dev, "Unsupported Wacom model %s\n",
  236. wacom->data);
  237. wacom->result = -ENODEV;
  238. return;
  239. }
  240. dev_info(&wacom->dev->dev, "%s tablet, version %u.%u\n",
  241. wacom->dev->name, major_v, minor_v);
  242. }
  243. static void wacom_handle_configuration_response(struct wacom *wacom)
  244. {
  245. int r, skip;
  246. dev_dbg(&wacom->dev->dev, "Configuration string: %s\n", wacom->data);
  247. r = sscanf(wacom->data, "~R%x,%u,%u,%u,%u", &skip, &skip, &skip,
  248. &wacom->res_x, &wacom->res_y);
  249. if (r != 5)
  250. dev_warn(&wacom->dev->dev, "could not get resolution\n");
  251. }
  252. static void wacom_handle_coordinates_response(struct wacom *wacom)
  253. {
  254. int r;
  255. dev_dbg(&wacom->dev->dev, "Coordinates string: %s\n", wacom->data);
  256. r = sscanf(wacom->data, "~C%u,%u", &wacom->max_x, &wacom->max_y);
  257. if (r != 2)
  258. dev_warn(&wacom->dev->dev, "could not get max coordinates\n");
  259. }
  260. static void wacom_handle_response(struct wacom *wacom)
  261. {
  262. if (wacom->data[0] != '~' || wacom->data[1] != wacom->expect) {
  263. dev_err(&wacom->dev->dev,
  264. "Wacom got an unexpected response: %s\n", wacom->data);
  265. wacom->result = -EIO;
  266. } else {
  267. wacom->result = 0;
  268. switch (wacom->data[1]) {
  269. case '#':
  270. wacom_handle_model_response(wacom);
  271. break;
  272. case 'R':
  273. wacom_handle_configuration_response(wacom);
  274. break;
  275. case 'C':
  276. wacom_handle_coordinates_response(wacom);
  277. break;
  278. }
  279. }
  280. complete(&wacom->cmd_done);
  281. }
  282. static void wacom_handle_packet(struct wacom *wacom)
  283. {
  284. u8 in_proximity_p, stylus_p, button;
  285. unsigned int tool;
  286. int x, y, z;
  287. in_proximity_p = wacom->data[0] & 0x40;
  288. stylus_p = wacom->data[0] & 0x20;
  289. button = (wacom->data[3] & 0x78) >> 3;
  290. x = (wacom->data[0] & 3) << 14 | wacom->data[1]<<7 | wacom->data[2];
  291. y = (wacom->data[3] & 3) << 14 | wacom->data[4]<<7 | wacom->data[5];
  292. if (in_proximity_p && stylus_p) {
  293. z = wacom->data[6] & 0x7f;
  294. if (wacom->extra_z_bits >= 1)
  295. z = z << 1 | (wacom->data[3] & 0x4) >> 2;
  296. if (wacom->extra_z_bits > 1)
  297. z = z << 1 | (wacom->data[0] & 0x4) >> 2;
  298. z = z ^ (0x40 << wacom->extra_z_bits);
  299. } else {
  300. z = -1;
  301. }
  302. if (stylus_p)
  303. tool = (button & wacom->eraser_mask) ? ERASER : STYLUS;
  304. else
  305. tool = CURSOR;
  306. if (tool != wacom->tool && wacom->tool != 0) {
  307. input_report_key(wacom->dev, tools[wacom->tool].input_id, 0);
  308. input_sync(wacom->dev);
  309. }
  310. wacom->tool = tool;
  311. input_report_key(wacom->dev, tools[tool].input_id, in_proximity_p);
  312. input_report_abs(wacom->dev, ABS_MISC,
  313. in_proximity_p ? tools[tool].device_id : 0);
  314. input_report_abs(wacom->dev, ABS_X, x);
  315. input_report_abs(wacom->dev, ABS_Y, y);
  316. input_report_abs(wacom->dev, ABS_PRESSURE, z);
  317. if (stylus_p) {
  318. input_report_key(wacom->dev, BTN_TOUCH, button & 1);
  319. input_report_key(wacom->dev, BTN_STYLUS, button & 2);
  320. input_report_key(wacom->dev, BTN_STYLUS2, button & 4);
  321. } else {
  322. input_report_key(wacom->dev, BTN_LEFT, button & 1);
  323. input_report_key(wacom->dev, BTN_RIGHT, button & 2);
  324. input_report_key(wacom->dev, BTN_MIDDLE, button & 4);
  325. /* handle relative wheel for non-stylus device */
  326. z = (wacom->data[6] & 0x30) >> 4;
  327. if (wacom->data[6] & 0x40)
  328. z = -z;
  329. input_report_rel(wacom->dev, REL_WHEEL, z);
  330. }
  331. input_sync(wacom->dev);
  332. }
  333. static void wacom_clear_data_buf(struct wacom *wacom)
  334. {
  335. memset(wacom->data, 0, DATA_SIZE);
  336. wacom->idx = 0;
  337. }
  338. static irqreturn_t wacom_interrupt(struct serio *serio, unsigned char data,
  339. unsigned int flags)
  340. {
  341. struct wacom *wacom = serio_get_drvdata(serio);
  342. if (data & 0x80)
  343. wacom->idx = 0;
  344. /*
  345. * We're either expecting a carriage return-terminated ASCII
  346. * response string, or a seven-byte packet with the MSB set on
  347. * the first byte.
  348. *
  349. * Note however that some tablets (the PenPartner, for
  350. * example) don't send a carriage return at the end of a
  351. * command. We handle these by waiting for timeout.
  352. */
  353. if (data == '\r' && !(wacom->data[0] & 0x80)) {
  354. wacom_handle_response(wacom);
  355. wacom_clear_data_buf(wacom);
  356. return IRQ_HANDLED;
  357. }
  358. /* Leave place for 0 termination */
  359. if (wacom->idx > (DATA_SIZE - 2)) {
  360. dev_dbg(&wacom->dev->dev,
  361. "throwing away %d bytes of garbage\n", wacom->idx);
  362. wacom_clear_data_buf(wacom);
  363. }
  364. wacom->data[wacom->idx++] = data;
  365. if (wacom->idx == PACKET_LENGTH && (wacom->data[0] & 0x80)) {
  366. wacom_handle_packet(wacom);
  367. wacom_clear_data_buf(wacom);
  368. }
  369. return IRQ_HANDLED;
  370. }
  371. static void wacom_disconnect(struct serio *serio)
  372. {
  373. struct wacom *wacom = serio_get_drvdata(serio);
  374. serio_close(serio);
  375. serio_set_drvdata(serio, NULL);
  376. input_unregister_device(wacom->dev);
  377. kfree(wacom);
  378. }
  379. static int wacom_send(struct serio *serio, const u8 *command)
  380. {
  381. int err = 0;
  382. for (; !err && *command; command++)
  383. err = serio_write(serio, *command);
  384. return err;
  385. }
  386. static int wacom_send_setup_string(struct wacom *wacom, struct serio *serio)
  387. {
  388. const u8 *cmd;
  389. switch (wacom->dev->id.version) {
  390. case MODEL_CINTIQ: /* UNTESTED */
  391. cmd = COMMAND_ORIGIN_IN_UPPER_LEFT
  392. COMMAND_TRANSMIT_AT_MAX_RATE
  393. COMMAND_ENABLE_CONTINUOUS_MODE
  394. COMMAND_START_SENDING_PACKETS;
  395. break;
  396. case MODEL_PENPARTNER:
  397. cmd = COMMAND_ENABLE_PRESSURE_MODE
  398. COMMAND_START_SENDING_PACKETS;
  399. break;
  400. default:
  401. cmd = COMMAND_MULTI_MODE_INPUT
  402. COMMAND_ORIGIN_IN_UPPER_LEFT
  403. COMMAND_ENABLE_ALL_MACRO_BUTTONS
  404. COMMAND_DISABLE_GROUP_1_MACRO_BUTTONS
  405. COMMAND_TRANSMIT_AT_MAX_RATE
  406. COMMAND_DISABLE_INCREMENTAL_MODE
  407. COMMAND_ENABLE_CONTINUOUS_MODE
  408. COMMAND_Z_FILTER
  409. COMMAND_START_SENDING_PACKETS;
  410. break;
  411. }
  412. return wacom_send(serio, cmd);
  413. }
  414. static int wacom_send_and_wait(struct wacom *wacom, struct serio *serio,
  415. const u8 *cmd, const char *desc)
  416. {
  417. int err;
  418. unsigned long u;
  419. wacom->expect = cmd[1];
  420. init_completion(&wacom->cmd_done);
  421. err = wacom_send(serio, cmd);
  422. if (err)
  423. return err;
  424. u = wait_for_completion_timeout(&wacom->cmd_done, HZ);
  425. if (u == 0) {
  426. /* Timeout, process what we've received. */
  427. wacom_handle_response(wacom);
  428. }
  429. wacom->expect = 0;
  430. return wacom->result;
  431. }
  432. static int wacom_setup(struct wacom *wacom, struct serio *serio)
  433. {
  434. int err;
  435. /* Note that setting the link speed is the job of inputattach.
  436. * We assume that reset negotiation has already happened,
  437. * here. */
  438. err = wacom_send_and_wait(wacom, serio, REQUEST_MODEL_AND_ROM_VERSION,
  439. "model and version");
  440. if (err)
  441. return err;
  442. if (!(wacom->res_x && wacom->res_y)) {
  443. err = wacom_send_and_wait(wacom, serio,
  444. REQUEST_CONFIGURATION_STRING,
  445. "configuration string");
  446. if (err)
  447. return err;
  448. }
  449. if (!(wacom->max_x && wacom->max_y)) {
  450. err = wacom_send_and_wait(wacom, serio,
  451. REQUEST_MAX_COORDINATES,
  452. "coordinates string");
  453. if (err)
  454. return err;
  455. }
  456. return wacom_send_setup_string(wacom, serio);
  457. }
  458. static int wacom_connect(struct serio *serio, struct serio_driver *drv)
  459. {
  460. struct wacom *wacom;
  461. struct input_dev *input_dev;
  462. int err = -ENOMEM;
  463. wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
  464. input_dev = input_allocate_device();
  465. if (!wacom || !input_dev)
  466. goto free_device;
  467. wacom->dev = input_dev;
  468. wacom->extra_z_bits = 1;
  469. wacom->eraser_mask = 0x04;
  470. wacom->tool = wacom->idx = 0;
  471. snprintf(wacom->phys, sizeof(wacom->phys), "%s/input0", serio->phys);
  472. input_dev->phys = wacom->phys;
  473. input_dev->id.bustype = BUS_RS232;
  474. input_dev->id.vendor = SERIO_WACOM_IV;
  475. input_dev->id.product = serio->id.extra;
  476. input_dev->dev.parent = &serio->dev;
  477. input_dev->evbit[0] =
  478. BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS) | BIT_MASK(EV_REL);
  479. set_bit(ABS_MISC, input_dev->absbit);
  480. set_bit(BTN_TOOL_PEN, input_dev->keybit);
  481. set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
  482. set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
  483. set_bit(BTN_TOUCH, input_dev->keybit);
  484. set_bit(BTN_STYLUS, input_dev->keybit);
  485. set_bit(BTN_LEFT, input_dev->keybit);
  486. set_bit(BTN_RIGHT, input_dev->keybit);
  487. set_bit(BTN_MIDDLE, input_dev->keybit);
  488. serio_set_drvdata(serio, wacom);
  489. err = serio_open(serio, drv);
  490. if (err)
  491. goto free_device;
  492. err = wacom_setup(wacom, serio);
  493. if (err)
  494. goto close_serio;
  495. set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
  496. if (!(wacom->flags & F_COVERS_SCREEN))
  497. __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
  498. if (wacom->flags & F_HAS_STYLUS2)
  499. __set_bit(BTN_STYLUS2, input_dev->keybit);
  500. if (wacom->flags & F_HAS_SCROLLWHEEL)
  501. __set_bit(REL_WHEEL, input_dev->relbit);
  502. input_abs_set_res(wacom->dev, ABS_X, wacom->res_x);
  503. input_abs_set_res(wacom->dev, ABS_Y, wacom->res_y);
  504. input_set_abs_params(wacom->dev, ABS_X, 0, wacom->max_x, 0, 0);
  505. input_set_abs_params(wacom->dev, ABS_Y, 0, wacom->max_y, 0, 0);
  506. input_set_abs_params(wacom->dev, ABS_PRESSURE, -1,
  507. (1 << (7 + wacom->extra_z_bits)) - 1, 0, 0);
  508. err = input_register_device(wacom->dev);
  509. if (err)
  510. goto close_serio;
  511. return 0;
  512. close_serio:
  513. serio_close(serio);
  514. free_device:
  515. serio_set_drvdata(serio, NULL);
  516. input_free_device(input_dev);
  517. kfree(wacom);
  518. return err;
  519. }
  520. static struct serio_device_id wacom_serio_ids[] = {
  521. {
  522. .type = SERIO_RS232,
  523. .proto = SERIO_WACOM_IV,
  524. .id = SERIO_ANY,
  525. .extra = SERIO_ANY,
  526. },
  527. { 0 }
  528. };
  529. MODULE_DEVICE_TABLE(serio, wacom_serio_ids);
  530. static struct serio_driver wacom_drv = {
  531. .driver = {
  532. .name = "wacom_serial4",
  533. },
  534. .description = "Wacom protocol 4 serial tablet driver",
  535. .id_table = wacom_serio_ids,
  536. .interrupt = wacom_interrupt,
  537. .connect = wacom_connect,
  538. .disconnect = wacom_disconnect,
  539. };
  540. module_serio_driver(wacom_drv);