diff options
| author | Jaya Kumar <jayakumar.lkml@gmail.com> | 2008-11-19 16:58:50 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-11-24 11:41:38 -0500 |
| commit | 3eb1aa43ef5cb871ba3fb2f08633675eca374d2e (patch) | |
| tree | a370e60ff68dcdf54e789496f4f3c2ff9499ea96 | |
| parent | e42b6646a8298fe06a33a0f68dab661335f5db6e (diff) | |
Input: add support for Wacom W8001 penabled serial touchscreen
The Wacom W8001 sensor is a sensor device (uses electromagnetic
resonance) and it is interfaced via its serial microcontroller
to the host.
Signed-off-by: Jaya Kumar <jayakumar.lkml@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
| -rw-r--r-- | drivers/input/touchscreen/Kconfig | 13 | ||||
| -rw-r--r-- | drivers/input/touchscreen/Makefile | 1 | ||||
| -rw-r--r-- | drivers/input/touchscreen/wacom_w8001.c | 325 | ||||
| -rw-r--r-- | include/linux/serio.h | 1 |
4 files changed, 340 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 3d1ab8fa9acc..20eb52ed176d 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
| @@ -95,6 +95,19 @@ config TOUCHSCREEN_ELO | |||
| 95 | To compile this driver as a module, choose M here: the | 95 | To compile this driver as a module, choose M here: the |
| 96 | module will be called elo. | 96 | module will be called elo. |
| 97 | 97 | ||
| 98 | config TOUCHSCREEN_WACOM_W8001 | ||
| 99 | tristate "Wacom W8001 penabled serial touchscreen" | ||
| 100 | select SERIO | ||
| 101 | help | ||
| 102 | Say Y here if you have an Wacom W8001 penabled serial touchscreen | ||
| 103 | connected to your system. | ||
| 104 | |||
| 105 | If unsure, say N. | ||
| 106 | |||
| 107 | To compile this driver as a module, choose M here: the | ||
| 108 | module will be called wacom_w8001. | ||
| 109 | |||
| 110 | |||
| 98 | config TOUCHSCREEN_MTOUCH | 111 | config TOUCHSCREEN_MTOUCH |
| 99 | tristate "MicroTouch serial touchscreens" | 112 | tristate "MicroTouch serial touchscreens" |
| 100 | select SERIO | 113 | select SERIO |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 15cf29079489..3dc84d3846c1 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
| @@ -26,6 +26,7 @@ obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o | |||
| 26 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o | 26 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o |
| 27 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o | 27 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o |
| 28 | obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o | 28 | obj-$(CONFIG_TOUCHSCREEN_UCB1400) += ucb1400_ts.o |
| 29 | obj-$(CONFIG_TOUCHSCREEN_WACOM_W8001) += wacom_w8001.o | ||
| 29 | obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o | 30 | obj-$(CONFIG_TOUCHSCREEN_WM97XX) += wm97xx-ts.o |
| 30 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o | 31 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9705) += wm9705.o |
| 31 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o | 32 | wm97xx-ts-$(CONFIG_TOUCHSCREEN_WM9712) += wm9712.o |
diff --git a/drivers/input/touchscreen/wacom_w8001.c b/drivers/input/touchscreen/wacom_w8001.c new file mode 100644 index 000000000000..2f33a0167644 --- /dev/null +++ b/drivers/input/touchscreen/wacom_w8001.c | |||
| @@ -0,0 +1,325 @@ | |||
| 1 | /* | ||
| 2 | * Wacom W8001 penabled serial touchscreen driver | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Jaya Kumar | ||
| 5 | * | ||
| 6 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 7 | * License. See the file COPYING in the main directory of this archive for | ||
| 8 | * more details. | ||
| 9 | * | ||
| 10 | * Layout based on Elo serial touchscreen driver by Vojtech Pavlik | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/errno.h> | ||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/module.h> | ||
| 16 | #include <linux/slab.h> | ||
| 17 | #include <linux/input.h> | ||
| 18 | #include <linux/serio.h> | ||
| 19 | #include <linux/init.h> | ||
| 20 | #include <linux/ctype.h> | ||
| 21 | |||
| 22 | #define DRIVER_DESC "Wacom W8001 serial touchscreen driver" | ||
| 23 | |||
| 24 | MODULE_AUTHOR("Jaya Kumar <jayakumar.lkml@gmail.com>"); | ||
| 25 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 26 | MODULE_LICENSE("GPL"); | ||
| 27 | |||
| 28 | /* | ||
| 29 | * Definitions & global arrays. | ||
| 30 | */ | ||
| 31 | |||
| 32 | #define W8001_MAX_LENGTH 11 | ||
| 33 | #define W8001_PACKET_LEN 11 | ||
| 34 | #define W8001_LEAD_MASK 0x80 | ||
| 35 | #define W8001_LEAD_BYTE 0x80 | ||
| 36 | #define W8001_TAB_MASK 0x40 | ||
| 37 | #define W8001_TAB_BYTE 0x40 | ||
| 38 | |||
| 39 | #define W8001_QUERY_PACKET 0x20 | ||
| 40 | |||
| 41 | struct w8001_coord { | ||
| 42 | u8 rdy; | ||
| 43 | u8 tsw; | ||
| 44 | u8 f1; | ||
| 45 | u8 f2; | ||
| 46 | u16 x; | ||
| 47 | u16 y; | ||
| 48 | u16 pen_pressure; | ||
| 49 | u8 tilt_x; | ||
| 50 | u8 tilt_y; | ||
| 51 | }; | ||
| 52 | |||
| 53 | /* | ||
| 54 | * Per-touchscreen data. | ||
| 55 | */ | ||
| 56 | |||
| 57 | struct w8001 { | ||
| 58 | struct input_dev *dev; | ||
| 59 | struct serio *serio; | ||
| 60 | struct mutex cmd_mutex; | ||
| 61 | struct completion cmd_done; | ||
| 62 | int id; | ||
| 63 | int idx; | ||
| 64 | unsigned char expected_packet; | ||
| 65 | unsigned char data[W8001_MAX_LENGTH]; | ||
| 66 | unsigned char response[W8001_PACKET_LEN]; | ||
| 67 | char phys[32]; | ||
| 68 | }; | ||
| 69 | |||
| 70 | static int parse_data(u8 *data, struct w8001_coord *coord) | ||
| 71 | { | ||
| 72 | coord->rdy = data[0] & 0x20; | ||
| 73 | coord->tsw = data[0] & 0x01; | ||
| 74 | coord->f1 = data[0] & 0x02; | ||
| 75 | coord->f2 = data[0] & 0x04; | ||
| 76 | |||
| 77 | coord->x = (data[1] & 0x7F) << 9; | ||
| 78 | coord->x |= (data[2] & 0x7F) << 2; | ||
| 79 | coord->x |= (data[6] & 0x60) >> 5; | ||
| 80 | |||
| 81 | coord->y = (data[3] & 0x7F) << 9; | ||
| 82 | coord->y |= (data[4] & 0x7F) << 2; | ||
| 83 | coord->y |= (data[6] & 0x18) >> 3; | ||
| 84 | |||
| 85 | coord->pen_pressure = data[5] & 0x7F; | ||
| 86 | coord->pen_pressure |= (data[6] & 0x07) << 7 ; | ||
| 87 | |||
| 88 | coord->tilt_x = data[7] & 0x7F; | ||
| 89 | coord->tilt_y = data[8] & 0x7F; | ||
| 90 | |||
| 91 | return 0; | ||
| 92 | } | ||
| 93 | |||
| 94 | static void w8001_process_data(struct w8001 *w8001, unsigned char data) | ||
| 95 | { | ||
| 96 | struct input_dev *dev = w8001->dev; | ||
| 97 | u8 tmp; | ||
| 98 | struct w8001_coord coord; | ||
| 99 | |||
| 100 | w8001->data[w8001->idx] = data; | ||
| 101 | switch (w8001->idx++) { | ||
| 102 | case 0: | ||
| 103 | if ((data & W8001_LEAD_MASK) != W8001_LEAD_BYTE) { | ||
| 104 | pr_debug("w8001: unsynchronized data: 0x%02x\n", data); | ||
| 105 | w8001->idx = 0; | ||
| 106 | } | ||
| 107 | break; | ||
| 108 | case 8: | ||
| 109 | tmp = w8001->data[0] & W8001_TAB_MASK; | ||
| 110 | if (unlikely(tmp == W8001_TAB_BYTE)) | ||
| 111 | break; | ||
| 112 | w8001->idx = 0; | ||
| 113 | memset(&coord, 0, sizeof(coord)); | ||
| 114 | parse_data(w8001->data, &coord); | ||
| 115 | input_report_abs(dev, ABS_X, coord.x); | ||
| 116 | input_report_abs(dev, ABS_Y, coord.y); | ||
| 117 | input_report_abs(dev, ABS_PRESSURE, coord.pen_pressure); | ||
| 118 | input_report_key(dev, BTN_TOUCH, coord.tsw); | ||
| 119 | input_sync(dev); | ||
| 120 | break; | ||
| 121 | case 10: | ||
| 122 | w8001->idx = 0; | ||
| 123 | memcpy(w8001->response, &w8001->data, W8001_PACKET_LEN); | ||
| 124 | w8001->expected_packet = W8001_QUERY_PACKET; | ||
| 125 | complete(&w8001->cmd_done); | ||
| 126 | break; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | |||
| 131 | static irqreturn_t w8001_interrupt(struct serio *serio, | ||
| 132 | unsigned char data, unsigned int flags) | ||
| 133 | { | ||
| 134 | struct w8001 *w8001 = serio_get_drvdata(serio); | ||
| 135 | |||
| 136 | w8001_process_data(w8001, data); | ||
| 137 | |||
| 138 | return IRQ_HANDLED; | ||
| 139 | } | ||
| 140 | |||
| 141 | static int w8001_async_command(struct w8001 *w8001, unsigned char *packet, | ||
| 142 | int len) | ||
| 143 | { | ||
| 144 | int rc = -1; | ||
| 145 | int i; | ||
| 146 | |||
| 147 | mutex_lock(&w8001->cmd_mutex); | ||
| 148 | |||
| 149 | |||
