tsdev.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /*
  2. * $Id: tsdev.c,v 1.15 2002/04/10 16:50:19 jsimmons Exp $
  3. *
  4. * Copyright (c) 2001 "Crazy" james Simmons
  5. *
  6. * Compaq touchscreen protocol driver. The protocol emulated by this driver
  7. * is obsolete; for new programs use the tslib library which can read directly
  8. * from evdev and perform dejittering, variance filtering and calibration -
  9. * all in user space, not at kernel level. The meaning of this driver is
  10. * to allow usage of newer input drivers with old applications that use the
  11. * old /dev/h3600_ts and /dev/h3600_tsraw devices.
  12. *
  13. * 09-Apr-2004: Andrew Zabolotny <zap@homelink.ru>
  14. * Fixed to actually work, not just output random numbers.
  15. * Added support for both h3600_ts and h3600_tsraw protocol
  16. * emulation.
  17. */
  18. /*
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License as published by
  21. * the Free Software Foundation; either version 2 of the License, or
  22. * (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License
  30. * along with this program; if not, write to the Free Software
  31. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  32. *
  33. * Should you need to contact me, the author, you can do so either by
  34. * e-mail - mail your message to <jsimmons@infradead.org>.
  35. */
  36. #define TSDEV_MINOR_BASE 128
  37. #define TSDEV_MINORS 32
  38. /* First 16 devices are h3600_ts compatible; second 16 are h3600_tsraw */
  39. #define TSDEV_MINOR_MASK 15
  40. #define TSDEV_BUFFER_SIZE 64
  41. #include <linux/slab.h>
  42. #include <linux/poll.h>
  43. #include <linux/module.h>
  44. #include <linux/moduleparam.h>
  45. #include <linux/init.h>
  46. #include <linux/input.h>
  47. #include <linux/major.h>
  48. #include <linux/random.h>
  49. #include <linux/time.h>
  50. #include <linux/device.h>
  51. #ifndef CONFIG_INPUT_TSDEV_SCREEN_X
  52. #define CONFIG_INPUT_TSDEV_SCREEN_X 240
  53. #endif
  54. #ifndef CONFIG_INPUT_TSDEV_SCREEN_Y
  55. #define CONFIG_INPUT_TSDEV_SCREEN_Y 320
  56. #endif
  57. /* This driver emulates both protocols of the old h3600_ts and h3600_tsraw
  58. * devices. The first one must output X/Y data in 'cooked' format, e.g.
  59. * filtered, dejittered and calibrated. Second device just outputs raw
  60. * data received from the hardware.
  61. *
  62. * This driver doesn't support filtering and dejittering; it supports only
  63. * calibration. Filtering and dejittering must be done in the low-level
  64. * driver, if needed, because it may gain additional benefits from knowing
  65. * the low-level details, the nature of noise and so on.
  66. *
  67. * The driver precomputes a calibration matrix given the initial xres and
  68. * yres values (quite innacurate for most touchscreens) that will result
  69. * in a more or less expected range of output values. The driver supports
  70. * the TS_SET_CAL ioctl, which will replace the calibration matrix with a
  71. * new one, supposedly generated from the values taken from the raw device.
  72. */
  73. MODULE_AUTHOR("James Simmons <jsimmons@transvirtual.com>");
  74. MODULE_DESCRIPTION("Input driver to touchscreen converter");
  75. MODULE_LICENSE("GPL");
  76. static int xres = CONFIG_INPUT_TSDEV_SCREEN_X;
  77. module_param(xres, uint, 0);
  78. MODULE_PARM_DESC(xres, "Horizontal screen resolution (can be negative for X-mirror)");
  79. static int yres = CONFIG_INPUT_TSDEV_SCREEN_Y;
  80. module_param(yres, uint, 0);
  81. MODULE_PARM_DESC(yres, "Vertical screen resolution (can be negative for Y-mirror)");
  82. /* From Compaq's Touch Screen Specification version 0.2 (draft) */
  83. struct ts_event {
  84. short pressure;
  85. short x;
  86. short y;
  87. short millisecs;
  88. };
  89. struct ts_calibration {
  90. int xscale;
  91. int xtrans;
  92. int yscale;
  93. int ytrans;
  94. int xyswap;
  95. };
  96. struct tsdev {
  97. int exist;
  98. int open;
  99. int minor;
  100. char name[8];
  101. struct input_handle handle;
  102. wait_queue_head_t wait;
  103. struct list_head client_list;
  104. spinlock_t client_lock; /* protects client_list */
  105. struct mutex mutex;
  106. struct device dev;
  107. int x, y, pressure;
  108. struct ts_calibration cal;
  109. };
  110. struct tsdev_client {
  111. struct fasync_struct *fasync;
  112. struct list_head node;
  113. struct tsdev *tsdev;
  114. struct ts_event buffer[TSDEV_BUFFER_SIZE];
  115. int head, tail;
  116. spinlock_t buffer_lock; /* protects access to buffer, head and tail */
  117. int raw;
  118. };
  119. /* The following ioctl codes are defined ONLY for backward compatibility.
  120. * Don't use tsdev for new developement; use the tslib library instead.
  121. * Touchscreen calibration is a fully userspace task.
  122. */
  123. /* Use 'f' as magic number */
  124. #define IOC_H3600_TS_MAGIC 'f'
  125. #define TS_GET_CAL _IOR(IOC_H3600_TS_MAGIC, 10, struct ts_calibration)
  126. #define TS_SET_CAL _IOW(IOC_H3600_TS_MAGIC, 11, struct ts_calibration)
  127. static struct tsdev *tsdev_table[TSDEV_MINORS/2];
  128. static DEFINE_MUTEX(tsdev_table_mutex);
  129. static int tsdev_fasync(int fd, struct file *file, int on)
  130. {
  131. struct tsdev_client *client = file->private_data;
  132. int retval;
  133. retval = fasync_helper(fd, file, on, &client->fasync);
  134. return retval < 0 ? retval : 0;
  135. }
  136. static void tsdev_free(struct device *dev)
  137. {
  138. struct tsdev *tsdev = container_of(dev, struct tsdev, dev);
  139. kfree(tsdev);
  140. }
  141. static void tsdev_attach_client(struct tsdev *tsdev, struct tsdev_client *client)
  142. {
  143. spin_lock(&tsdev->client_lock);
  144. list_add_tail_rcu(&client->node, &tsdev->client_list);
  145. spin_unlock(&tsdev->client_lock);
  146. synchronize_sched();
  147. }
  148. static void tsdev_detach_client(struct tsdev *tsdev, struct tsdev_client *client)
  149. {
  150. spin_lock(&tsdev->client_lock);
  151. list_del_rcu(&client->node);
  152. spin_unlock(&tsdev->client_lock);
  153. synchronize_sched();
  154. }
  155. static int tsdev_open_device(struct tsdev *tsdev)
  156. {
  157. int retval;
  158. retval = mutex_lock_interruptible(&tsdev->mutex);
  159. if (retval)
  160. return retval;
  161. if (!tsdev->exist)
  162. retval = -ENODEV;
  163. else if (!tsdev->open++) {
  164. retval = input_open_device(&tsdev->handle);
  165. if (retval)
  166. tsdev->open--;
  167. }
  168. mutex_unlock(&tsdev->mutex);
  169. return retval;
  170. }
  171. static void tsdev_close_device(struct tsdev *tsdev)
  172. {
  173. mutex_lock(&tsdev->mutex);
  174. if (tsdev->exist && !--tsdev->open)
  175. input_close_device(&tsdev->handle);
  176. mutex_unlock(&tsdev->mutex);
  177. }
  178. /*
  179. * Wake up users waiting for IO so they can disconnect from
  180. * dead device.
  181. */
  182. static void tsdev_hangup(struct tsdev *tsdev)
  183. {
  184. struct tsdev_client *client;
  185. spin_lock(&tsdev->client_lock);
  186. list_for_each_entry(client, &tsdev->client_list, node)
  187. kill_fasync(&client->fasync, SIGIO, POLL_HUP);
  188. spin_unlock(&tsdev->client_lock);
  189. wake_up_interruptible(&tsdev->wait);
  190. }
  191. static int tsdev_release(struct inode *inode, struct file *file)
  192. {
  193. struct tsdev_client *client = file->private_data;
  194. struct tsdev *tsdev = client->tsdev;
  195. tsdev_fasync(-1, file, 0);
  196. tsdev_detach_client(tsdev, client);
  197. kfree(client);
  198. tsdev_close_device(tsdev);
  199. put_device(&tsdev->dev);
  200. return 0;
  201. }
  202. static int tsdev_open(struct inode *inode, struct file *file)
  203. {
  204. int i = iminor(inode) - TSDEV_MINOR_BASE;
  205. struct tsdev_client *client;
  206. struct tsdev *tsdev;
  207. int error;
  208. printk(KERN_WARNING "tsdev (compaq touchscreen emulation) is scheduled "
  209. "for removal.\nSee Documentation/feature-removal-schedule.txt "
  210. "for details.\n");
  211. if (i >= TSDEV_MINORS)
  212. return -ENODEV;
  213. error = mutex_lock_interruptible(&tsdev_table_mutex);
  214. if (error)
  215. return error;
  216. tsdev = tsdev_table[i & TSDEV_MINOR_MASK];
  217. if (tsdev)
  218. get_device(&tsdev->dev);
  219. mutex_unlock(&tsdev_table_mutex);
  220. if (!tsdev)
  221. return -ENODEV;
  222. client = kzalloc(sizeof(struct tsdev_client), GFP_KERNEL);
  223. if (!client) {
  224. error = -ENOMEM;
  225. goto err_put_tsdev;
  226. }
  227. spin_lock_init(&client->buffer_lock);
  228. client->tsdev = tsdev;
  229. client->raw = i >= TSDEV_MINORS / 2;
  230. tsdev_attach_client(tsdev, client);
  231. error = tsdev_open_device(tsdev);
  232. if (error)
  233. goto err_free_client;
  234. file->private_data = client;
  235. return 0;
  236. err_free_client:
  237. tsdev_detach_client(tsdev, client);
  238. kfree(client);
  239. err_put_tsdev:
  240. put_device(&tsdev->dev);
  241. return error;
  242. }
  243. static int tsdev_fetch_next_event(struct tsdev_client *client,
  244. struct ts_event *event)
  245. {
  246. int have_event;
  247. spin_lock_irq(&client->buffer_lock);
  248. have_event = client->head != client->tail;
  249. if (have_event) {
  250. *event = client->buffer[client->tail++];
  251. client->tail &= TSDEV_BUFFER_SIZE - 1;
  252. }
  253. spin_unlock_irq(&client->buffer_lock);
  254. return have_event;
  255. }
  256. static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count,
  257. loff_t *ppos)
  258. {
  259. struct tsdev_client *client = file->private_data;
  260. struct tsdev *tsdev = client->tsdev;
  261. struct ts_event event;
  262. int retval;
  263. if (client->head == client->tail && tsdev->exist &&
  264. (file->f_flags & O_NONBLOCK))
  265. return -EAGAIN;
  266. retval = wait_event_interruptible(tsdev->wait,
  267. client->head != client->tail || !tsdev->exist);
  268. if (retval)
  269. return retval;
  270. if (!tsdev->exist)
  271. return -ENODEV;
  272. while (retval + sizeof(struct ts_event) <= count &&
  273. tsdev_fetch_next_event(client, &event)) {
  274. if (copy_to_user(buffer + retval, &event,
  275. sizeof(struct ts_event)))
  276. return -EFAULT;
  277. retval += sizeof(struct ts_event);
  278. }
  279. return retval;
  280. }
  281. /* No kernel lock - fine */
  282. static unsigned int tsdev_poll(struct file *file, poll_table *wait)
  283. {
  284. struct tsdev_client *client = file->private_data;
  285. struct tsdev *tsdev = client->tsdev;
  286. poll_wait(file, &tsdev->wait, wait);
  287. return ((client->head == client->tail) ? 0 : (POLLIN | POLLRDNORM)) |
  288. (tsdev->exist ? 0 : (POLLHUP | POLLERR));
  289. }
  290. static long tsdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  291. {
  292. struct tsdev_client *client = file->private_data;
  293. struct tsdev *tsdev = client->tsdev;
  294. int retval = 0;
  295. retval = mutex_lock_interruptible(&tsdev->mutex);
  296. if (retval)
  297. return retval;
  298. if (!tsdev->exist) {
  299. retval = -ENODEV;
  300. goto out;
  301. }
  302. switch (cmd) {
  303. case TS_GET_CAL:
  304. if (copy_to_user((void __user *)arg, &tsdev->cal,
  305. sizeof (struct ts_calibration)))
  306. retval = -EFAULT;
  307. break;
  308. case TS_SET_CAL:
  309. if (copy_from_user(&tsdev->cal, (void __user *)arg,
  310. sizeof(struct ts_calibration)))
  311. retval = -EFAULT;
  312. break;
  313. default:
  314. retval = -EINVAL;
  315. break;
  316. }
  317. out:
  318. mutex_unlock(&tsdev->mutex);
  319. return retval;
  320. }
  321. static const struct file_operations tsdev_fops = {
  322. .owner = THIS_MODULE,
  323. .open = tsdev_open,
  324. .release = tsdev_release,
  325. .read = tsdev_read,
  326. .poll = tsdev_poll,
  327. .fasync = tsdev_fasync,
  328. .unlocked_ioctl = tsdev_ioctl,
  329. };
  330. static void tsdev_pass_event(struct tsdev *tsdev, struct tsdev_client *client,
  331. int x, int y, int pressure, int millisecs)
  332. {
  333. struct ts_event *event;
  334. int tmp;
  335. /* Interrupts are already disabled, just acquire the lock */
  336. spin_lock(&client->buffer_lock);
  337. event = &client->buffer[client->head++];
  338. client->head &= TSDEV_BUFFER_SIZE - 1;
  339. /* Calibration */
  340. if (!client->raw) {
  341. x = ((x * tsdev->cal.xscale) >> 8) + tsdev->cal.xtrans;
  342. y = ((y * tsdev->cal.yscale) >> 8) + tsdev->cal.ytrans;
  343. if (tsdev->cal.xyswap) {
  344. tmp = x; x = y; y = tmp;
  345. }
  346. }
  347. event->millisecs = millisecs;
  348. event->x = x;
  349. event->y = y;
  350. event->pressure = pressure;
  351. spin_unlock(&client->buffer_lock);
  352. kill_fasync(&client->fasync, SIGIO, POLL_IN);
  353. }
  354. static void tsdev_distribute_event(struct tsdev *tsdev)
  355. {
  356. struct tsdev_client *client;
  357. struct timeval time;
  358. int millisecs;
  359. do_gettimeofday(&time);
  360. millisecs = time.tv_usec / 1000;
  361. list_for_each_entry_rcu(client, &tsdev->client_list, node)
  362. tsdev_pass_event(tsdev, client,
  363. tsdev->x, tsdev->y,
  364. tsdev->pressure, millisecs);
  365. }
  366. static void tsdev_event(struct input_handle *handle, unsigned int type,
  367. unsigned int code, int value)
  368. {
  369. struct tsdev *tsdev = handle->private;
  370. struct input_dev *dev = handle->dev;
  371. int wake_up_readers = 0;
  372. switch (type) {
  373. case EV_ABS:
  374. switch (code) {
  375. case ABS_X:
  376. tsdev->x = value;
  377. break;
  378. case ABS_Y:
  379. tsdev->y = value;
  380. break;
  381. case ABS_PRESSURE:
  382. if (value > dev->absmax[ABS_PRESSURE])
  383. value = dev->absmax[ABS_PRESSURE];
  384. value -= dev->absmin[ABS_PRESSURE];
  385. if (value < 0)
  386. value = 0;
  387. tsdev->pressure = value;
  388. break;
  389. }
  390. break;
  391. case EV_REL:
  392. switch (code) {
  393. case REL_X:
  394. tsdev->x += value;
  395. if (tsdev->x < 0)
  396. tsdev->x = 0;
  397. else if (tsdev->x > xres)
  398. tsdev->x = xres;
  399. break;
  400. case REL_Y:
  401. tsdev->y += value;
  402. if (tsdev->y < 0)
  403. tsdev->y = 0;
  404. else if (tsdev->y > yres)
  405. tsdev->y = yres;
  406. break;
  407. }
  408. break;
  409. case EV_KEY:
  410. if (code == BTN_TOUCH || code == BTN_MOUSE) {
  411. switch (value) {
  412. case 0:
  413. tsdev->pressure = 0;
  414. break;
  415. case 1:
  416. if (!tsdev->pressure)
  417. tsdev->pressure = 1;
  418. break;
  419. }
  420. }
  421. break;
  422. case EV_SYN:
  423. if (code == SYN_REPORT) {
  424. tsdev_distribute_event(tsdev);
  425. wake_up_readers = 1;
  426. }
  427. break;
  428. }
  429. if (wake_up_readers)
  430. wake_up_interruptible(&tsdev->wait);
  431. }
  432. static int tsdev_install_chrdev(struct tsdev *tsdev)
  433. {
  434. tsdev_table[tsdev->minor] = tsdev;
  435. return 0;
  436. }
  437. static void tsdev_remove_chrdev(struct tsdev *tsdev)
  438. {
  439. mutex_lock(&tsdev_table_mutex);
  440. tsdev_table[tsdev->minor] = NULL;
  441. mutex_unlock(&tsdev_table_mutex);
  442. }
  443. /*
  444. * Mark device non-existant. This disables writes, ioctls and
  445. * prevents new users from opening the device. Already posted
  446. * blocking reads will stay, however new ones will fail.
  447. */
  448. static void tsdev_mark_dead(struct tsdev *tsdev)
  449. {
  450. mutex_lock(&tsdev->mutex);
  451. tsdev->exist = 0;
  452. mutex_unlock(&tsdev->mutex);
  453. }
  454. static void tsdev_cleanup(struct tsdev *tsdev)
  455. {
  456. struct input_handle *handle = &tsdev->handle;
  457. tsdev_mark_dead(tsdev);
  458. tsdev_hangup(tsdev);
  459. tsdev_remove_chrdev(tsdev);
  460. /* tsdev is marked dead so noone else accesses tsdev->open */
  461. if (tsdev->open)
  462. input_close_device(handle);
  463. }
  464. static int tsdev_connect(struct input_handler *handler, struct input_dev *dev,
  465. const struct input_device_id *id)
  466. {
  467. struct tsdev *tsdev;
  468. int delta;
  469. int minor;
  470. int error;
  471. for (minor = 0; minor < TSDEV_MINORS / 2; minor++)
  472. if (!tsdev_table[minor])
  473. break;
  474. if (minor == TSDEV_MINORS) {
  475. printk(KERN_ERR "tsdev: no more free tsdev devices\n");
  476. return -ENFILE;
  477. }
  478. tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL);
  479. if (!tsdev)
  480. return -ENOMEM;
  481. INIT_LIST_HEAD(&tsdev->client_list);
  482. spin_lock_init(&tsdev->client_lock);
  483. mutex_init(&tsdev->mutex);
  484. init_waitqueue_head(&tsdev->wait);
  485. snprintf(tsdev->name, sizeof(tsdev->name), "ts%d", minor);
  486. tsdev->exist = 1;
  487. tsdev->minor = minor;
  488. tsdev->handle.dev = dev;
  489. tsdev->handle.name = tsdev->name;
  490. tsdev->handle.handler = handler;
  491. tsdev->handle.private = tsdev;
  492. /* Precompute the rough calibration matrix */
  493. delta = dev->absmax [ABS_X] - dev->absmin [ABS_X] + 1;
  494. if (delta == 0)
  495. delta = 1;
  496. tsdev->cal.xscale = (xres << 8) / delta;
  497. tsdev->cal.xtrans = - ((dev->absmin [ABS_X] * tsdev->cal.xscale) >> 8);
  498. delta = dev->absmax [ABS_Y] - dev->absmin [ABS_Y] + 1;
  499. if (delta == 0)
  500. delta = 1;
  501. tsdev->cal.yscale = (yres << 8) / delta;
  502. tsdev->cal.ytrans = - ((dev->absmin [ABS_Y] * tsdev->cal.yscale) >> 8);
  503. strlcpy(tsdev->dev.bus_id, tsdev->name, sizeof(tsdev->dev.bus_id));
  504. tsdev->dev.devt = MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor);
  505. tsdev->dev.class = &input_class;
  506. tsdev->dev.parent = &dev->dev;
  507. tsdev->dev.release = tsdev_free;
  508. device_initialize(&tsdev->dev);
  509. error = input_register_handle(&tsdev->handle);
  510. if (error)
  511. goto err_free_tsdev;
  512. error = tsdev_install_chrdev(tsdev);
  513. if (error)
  514. goto err_unregister_handle;
  515. error = device_add(&tsdev->dev);
  516. if (error)
  517. goto err_cleanup_tsdev;
  518. return 0;
  519. err_cleanup_tsdev:
  520. tsdev_cleanup(tsdev);
  521. err_unregister_handle:
  522. input_unregister_handle(&tsdev->handle);
  523. err_free_tsdev:
  524. put_device(&tsdev->dev);
  525. return error;
  526. }
  527. static void tsdev_disconnect(struct input_handle *handle)
  528. {
  529. struct tsdev *tsdev = handle->private;
  530. device_del(&tsdev->dev);
  531. tsdev_cleanup(tsdev);
  532. input_unregister_handle(handle);
  533. put_device(&tsdev->dev);
  534. }
  535. static const struct input_device_id tsdev_ids[] = {
  536. {
  537. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_RELBIT,
  538. .evbit = { BIT(EV_KEY) | BIT(EV_REL) },
  539. .keybit = { [LONG(BTN_LEFT)] = BIT(BTN_LEFT) },
  540. .relbit = { BIT(REL_X) | BIT(REL_Y) },
  541. }, /* A mouse like device, at least one button, two relative axes */
  542. {
  543. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_KEYBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  544. .evbit = { BIT(EV_KEY) | BIT(EV_ABS) },
  545. .keybit = { [LONG(BTN_TOUCH)] = BIT(BTN_TOUCH) },
  546. .absbit = { BIT(ABS_X) | BIT(ABS_Y) },
  547. }, /* A tablet like device, at least touch detection, two absolute axes */
  548. {
  549. .flags = INPUT_DEVICE_ID_MATCH_EVBIT | INPUT_DEVICE_ID_MATCH_ABSBIT,
  550. .evbit = { BIT(EV_ABS) },
  551. .absbit = { BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE) },
  552. }, /* A tablet like device with several gradations of pressure */
  553. {} /* Terminating entry */
  554. };
  555. MODULE_DEVICE_TABLE(input, tsdev_ids);
  556. static struct input_handler tsdev_handler = {
  557. .event = tsdev_event,
  558. .connect = tsdev_connect,
  559. .disconnect = tsdev_disconnect,
  560. .fops = &tsdev_fops,
  561. .minor = TSDEV_MINOR_BASE,
  562. .name = "tsdev",
  563. .id_table = tsdev_ids,
  564. };
  565. static int __init tsdev_init(void)
  566. {
  567. return input_register_handler(&tsdev_handler);
  568. }
  569. static void __exit tsdev_exit(void)
  570. {
  571. input_unregister_handler(&tsdev_handler);
  572. }
  573. module_init(tsdev_init);
  574. module_exit(tsdev_exit);