Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Elo serial touchscreen driver |
| 3 | * |
| 4 | * Copyright (c) 2004 Vojtech Pavlik |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 2 as published by |
| 10 | * the Free Software Foundation. |
| 11 | */ |
| 12 | |
| 13 | /* |
| 14 | * This driver can handle serial Elo touchscreens using either the Elo standard |
| 15 | * 'E271-2210' 10-byte protocol, Elo legacy 'E281A-4002' 6-byte protocol, Elo |
| 16 | * legacy 'E271-140' 4-byte protocol and Elo legacy 'E261-280' 3-byte protocol. |
| 17 | */ |
| 18 | |
| 19 | #include <linux/errno.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/input.h> |
| 24 | #include <linux/serio.h> |
| 25 | #include <linux/init.h> |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 26 | #include <linux/ctype.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | #define DRIVER_DESC "Elo serial touchscreen driver" |
| 29 | |
| 30 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
| 31 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 32 | MODULE_LICENSE("GPL"); |
| 33 | |
| 34 | /* |
| 35 | * Definitions & global arrays. |
| 36 | */ |
| 37 | |
Shaun Jackman | 1ce316e | 2006-08-05 00:27:59 -0400 | [diff] [blame] | 38 | #define ELO_MAX_LENGTH 10 |
| 39 | |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 40 | #define ELO10_PACKET_LEN 8 |
| 41 | #define ELO10_TOUCH 0x03 |
| 42 | #define ELO10_PRESSURE 0x80 |
| 43 | |
Shaun Jackman | 1ce316e | 2006-08-05 00:27:59 -0400 | [diff] [blame] | 44 | #define ELO10_LEAD_BYTE 'U' |
| 45 | |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 46 | #define ELO10_ID_CMD 'i' |
| 47 | |
Shaun Jackman | 1ce316e | 2006-08-05 00:27:59 -0400 | [diff] [blame] | 48 | #define ELO10_TOUCH_PACKET 'T' |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 49 | #define ELO10_ACK_PACKET 'A' |
| 50 | #define ELI10_ID_PACKET 'I' |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | /* |
| 53 | * Per-touchscreen data. |
| 54 | */ |
| 55 | |
| 56 | struct elo { |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 57 | struct input_dev *dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | struct serio *serio; |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 59 | struct mutex cmd_mutex; |
| 60 | struct completion cmd_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | int id; |
| 62 | int idx; |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 63 | unsigned char expected_packet; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | unsigned char csum; |
| 65 | unsigned char data[ELO_MAX_LENGTH]; |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 66 | unsigned char response[ELO10_PACKET_LEN]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | char phys[32]; |
| 68 | }; |
| 69 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 70 | static void elo_process_data_10(struct elo *elo, unsigned char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 72 | struct input_dev *dev = elo->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
Shaun Jackman | 1ce316e | 2006-08-05 00:27:59 -0400 | [diff] [blame] | 74 | elo->data[elo->idx] = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 76 | switch (elo->idx++) { |
| 77 | case 0: |
| 78 | elo->csum = 0xaa; |
| 79 | if (data != ELO10_LEAD_BYTE) { |
| 80 | dev_dbg(&elo->serio->dev, |
| 81 | "unsynchronized data: 0x%02x\n", data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | elo->idx = 0; |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 83 | } |
| 84 | break; |
| 85 | |
| 86 | case 9: |
| 87 | elo->idx = 0; |
| 88 | if (data != elo->csum) { |
| 89 | dev_dbg(&elo->serio->dev, |
| 90 | "bad checksum: 0x%02x, expected 0x%02x\n", |
| 91 | data, elo->csum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | break; |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 93 | } |
| 94 | if (elo->data[1] != elo->expected_packet) { |
| 95 | if (elo->data[1] != ELO10_TOUCH_PACKET) |
| 96 | dev_dbg(&elo->serio->dev, |
| 97 | "unexpected packet: 0x%02x\n", |
| 98 | elo->data[1]); |
| 99 | break; |
| 100 | } |
| 101 | if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { |
| 102 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); |
| 103 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); |
| 104 | if (elo->data[2] & ELO10_PRESSURE) |
| 105 | input_report_abs(dev, ABS_PRESSURE, |
| 106 | (elo->data[8] << 8) | elo->data[7]); |
| 107 | input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH); |
| 108 | input_sync(dev); |
| 109 | } else if (elo->data[1] == ELO10_ACK_PACKET) { |
| 110 | if (elo->data[2] == '0') |
| 111 | elo->expected_packet = ELO10_TOUCH_PACKET; |
| 112 | complete(&elo->cmd_done); |
| 113 | } else { |
| 114 | memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN); |
| 115 | elo->expected_packet = ELO10_ACK_PACKET; |
| 116 | } |
| 117 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
Shaun Jackman | 1ce316e | 2006-08-05 00:27:59 -0400 | [diff] [blame] | 119 | elo->csum += data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 122 | static void elo_process_data_6(struct elo *elo, unsigned char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | { |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 124 | struct input_dev *dev = elo->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
| 126 | elo->data[elo->idx] = data; |
| 127 | |
| 128 | switch (elo->idx++) { |
| 129 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 130 | case 0: |
| 131 | if ((data & 0xc0) != 0xc0) |
| 132 | elo->idx = 0; |
| 133 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 135 | case 1: |
| 136 | if ((data & 0xc0) != 0x80) |
| 137 | elo->idx = 0; |
| 138 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 140 | case 2: |
| 141 | if ((data & 0xc0) != 0x40) |
| 142 | elo->idx = 0; |
| 143 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 145 | case 3: |
| 146 | if (data & 0xc0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | elo->idx = 0; |
| 148 | break; |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | input_report_abs(dev, ABS_X, ((elo->data[0] & 0x3f) << 6) | (elo->data[1] & 0x3f)); |
| 152 | input_report_abs(dev, ABS_Y, ((elo->data[2] & 0x3f) << 6) | (elo->data[3] & 0x3f)); |
| 153 | |
| 154 | if (elo->id == 2) { |
| 155 | input_report_key(dev, BTN_TOUCH, 1); |
| 156 | input_sync(dev); |
| 157 | elo->idx = 0; |
| 158 | } |
| 159 | |
| 160 | break; |
| 161 | |
| 162 | case 4: |
| 163 | if (data) { |
| 164 | input_sync(dev); |
| 165 | elo->idx = 0; |
| 166 | } |
| 167 | break; |
| 168 | |
| 169 | case 5: |
| 170 | if ((data & 0xf0) == 0) { |
| 171 | input_report_abs(dev, ABS_PRESSURE, elo->data[5]); |
| 172 | input_report_key(dev, BTN_TOUCH, !!elo->data[5]); |
| 173 | } |
| 174 | input_sync(dev); |
| 175 | elo->idx = 0; |
| 176 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 180 | static void elo_process_data_3(struct elo *elo, unsigned char data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | { |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 182 | struct input_dev *dev = elo->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
| 184 | elo->data[elo->idx] = data; |
| 185 | |
| 186 | switch (elo->idx++) { |
| 187 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 188 | case 0: |
| 189 | if ((data & 0x7f) != 0x01) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | elo->idx = 0; |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 191 | break; |
| 192 | case 2: |
| 193 | input_report_key(dev, BTN_TOUCH, !(elo->data[1] & 0x80)); |
| 194 | input_report_abs(dev, ABS_X, elo->data[1]); |
| 195 | input_report_abs(dev, ABS_Y, elo->data[2]); |
| 196 | input_sync(dev); |
| 197 | elo->idx = 0; |
| 198 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
| 200 | } |
| 201 | |
| 202 | static irqreturn_t elo_interrupt(struct serio *serio, |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 203 | unsigned char data, unsigned int flags) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | { |
Shaun Jackman | 1ce316e | 2006-08-05 00:27:59 -0400 | [diff] [blame] | 205 | struct elo *elo = serio_get_drvdata(serio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 207 | switch (elo->id) { |
| 208 | case 0: |
| 209 | elo_process_data_10(elo, data); |
| 210 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 212 | case 1: |
| 213 | case 2: |
| 214 | elo_process_data_6(elo, data); |
| 215 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 217 | case 3: |
| 218 | elo_process_data_3(elo, data); |
| 219 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | return IRQ_HANDLED; |
| 223 | } |
| 224 | |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 225 | static int elo_command_10(struct elo *elo, unsigned char *packet) |
| 226 | { |
| 227 | int rc = -1; |
| 228 | int i; |
| 229 | unsigned char csum = 0xaa + ELO10_LEAD_BYTE; |
| 230 | |
| 231 | mutex_lock(&elo->cmd_mutex); |
| 232 | |
| 233 | serio_pause_rx(elo->serio); |
| 234 | elo->expected_packet = toupper(packet[0]); |
| 235 | init_completion(&elo->cmd_done); |
| 236 | serio_continue_rx(elo->serio); |
| 237 | |
| 238 | if (serio_write(elo->serio, ELO10_LEAD_BYTE)) |
| 239 | goto out; |
| 240 | |
| 241 | for (i = 0; i < ELO10_PACKET_LEN; i++) { |
| 242 | csum += packet[i]; |
| 243 | if (serio_write(elo->serio, packet[i])) |
| 244 | goto out; |
| 245 | } |
| 246 | |
| 247 | if (serio_write(elo->serio, csum)) |
| 248 | goto out; |
| 249 | |
| 250 | wait_for_completion_timeout(&elo->cmd_done, HZ); |
| 251 | |
| 252 | if (elo->expected_packet == ELO10_TOUCH_PACKET) { |
| 253 | /* We are back in reporting mode, the command was ACKed */ |
| 254 | memcpy(packet, elo->response, ELO10_PACKET_LEN); |
| 255 | rc = 0; |
| 256 | } |
| 257 | |
| 258 | out: |
| 259 | mutex_unlock(&elo->cmd_mutex); |
| 260 | return rc; |
| 261 | } |
| 262 | |
| 263 | static int elo_setup_10(struct elo *elo) |
| 264 | { |
| 265 | static const char *elo_types[] = { "Accu", "Dura", "Intelli", "Carroll" }; |
| 266 | struct input_dev *dev = elo->dev; |
| 267 | unsigned char packet[ELO10_PACKET_LEN] = { ELO10_ID_CMD }; |
| 268 | |
| 269 | if (elo_command_10(elo, packet)) |
| 270 | return -1; |
| 271 | |
| 272 | dev->id.version = (packet[5] << 8) | packet[4]; |
| 273 | |
| 274 | input_set_abs_params(dev, ABS_X, 96, 4000, 0, 0); |
| 275 | input_set_abs_params(dev, ABS_Y, 96, 4000, 0, 0); |
| 276 | if (packet[3] & ELO10_PRESSURE) |
| 277 | input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); |
| 278 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 279 | dev_info(&elo->serio->dev, |
| 280 | "%sTouch touchscreen, fw: %02x.%02x, features: 0x%02x, controller: 0x%02x\n", |
| 281 | elo_types[(packet[1] -'0') & 0x03], |
| 282 | packet[5], packet[4], packet[3], packet[7]); |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 283 | |
| 284 | return 0; |
| 285 | } |
| 286 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | /* |
| 288 | * elo_disconnect() is the opposite of elo_connect() |
| 289 | */ |
| 290 | |
| 291 | static void elo_disconnect(struct serio *serio) |
| 292 | { |
Dmitry Torokhov | 6b50d8b | 2006-08-05 00:27:00 -0400 | [diff] [blame] | 293 | struct elo *elo = serio_get_drvdata(serio); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Dmitry Torokhov | 6b50d8b | 2006-08-05 00:27:00 -0400 | [diff] [blame] | 295 | input_get_device(elo->dev); |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 296 | input_unregister_device(elo->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | serio_close(serio); |
| 298 | serio_set_drvdata(serio, NULL); |
Dmitry Torokhov | 6b50d8b | 2006-08-05 00:27:00 -0400 | [diff] [blame] | 299 | input_put_device(elo->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | kfree(elo); |
| 301 | } |
| 302 | |
| 303 | /* |
| 304 | * elo_connect() is the routine that is called when someone adds a |
| 305 | * new serio device that supports Gunze protocol and registers it as |
| 306 | * an input device. |
| 307 | */ |
| 308 | |
| 309 | static int elo_connect(struct serio *serio, struct serio_driver *drv) |
| 310 | { |
| 311 | struct elo *elo; |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 312 | struct input_dev *input_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | int err; |
| 314 | |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 315 | elo = kzalloc(sizeof(struct elo), GFP_KERNEL); |
| 316 | input_dev = input_allocate_device(); |
| 317 | if (!elo || !input_dev) { |
| 318 | err = -ENOMEM; |
Dmitry Torokhov | 6b50d8b | 2006-08-05 00:27:00 -0400 | [diff] [blame] | 319 | goto fail1; |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 320 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 322 | elo->serio = serio; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | elo->id = serio->id.id; |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 324 | elo->dev = input_dev; |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 325 | elo->expected_packet = ELO10_TOUCH_PACKET; |
| 326 | mutex_init(&elo->cmd_mutex); |
| 327 | init_completion(&elo->cmd_done); |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 328 | snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys); |
| 329 | |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 330 | input_dev->name = "Elo Serial TouchScreen"; |
| 331 | input_dev->phys = elo->phys; |
| 332 | input_dev->id.bustype = BUS_RS232; |
| 333 | input_dev->id.vendor = SERIO_ELO; |
| 334 | input_dev->id.product = elo->id; |
| 335 | input_dev->id.version = 0x0100; |
Dmitry Torokhov | a5394fb0 | 2007-04-12 01:35:14 -0400 | [diff] [blame] | 336 | input_dev->dev.parent = &serio->dev; |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 337 | |
Jiri Slaby | 7b19ada | 2007-10-18 23:40:32 -0700 | [diff] [blame] | 338 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
| 339 | input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 341 | serio_set_drvdata(serio, elo); |
| 342 | err = serio_open(serio, drv); |
| 343 | if (err) |
| 344 | goto fail2; |
| 345 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | switch (elo->id) { |
| 347 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 348 | case 0: /* 10-byte protocol */ |
| 349 | if (elo_setup_10(elo)) |
| 350 | goto fail3; |
Shaun Jackman | fae3006 | 2006-08-05 00:29:49 -0400 | [diff] [blame] | 351 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 352 | break; |
Dmitry Torokhov | de1b963 | 2005-05-29 02:28:50 -0500 | [diff] [blame] | 353 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 354 | case 1: /* 6-byte protocol */ |
| 355 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 15, 0, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 357 | case 2: /* 4-byte protocol */ |
| 358 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); |
| 359 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); |
| 360 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | |
Dmitry Torokhov | 8cab9ba | 2010-01-06 23:52:12 -0800 | [diff] [blame] | 362 | case 3: /* 3-byte protocol */ |
| 363 | input_set_abs_params(input_dev, ABS_X, 0, 255, 0, 0); |
| 364 | input_set_abs_params(input_dev, ABS_Y, 0, 255, 0, 0); |
| 365 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | } |
| 367 | |
Dmitry Torokhov | 6b50d8b | 2006-08-05 00:27:00 -0400 | [diff] [blame] | 368 | err = input_register_device(elo->dev); |
| 369 | if (err) |
| 370 | goto fail3; |
| 371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | return 0; |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 373 | |
Dmitry Torokhov | 6b50d8b | 2006-08-05 00:27:00 -0400 | [diff] [blame] | 374 | fail3: serio_close(serio); |
| 375 | fail2: serio_set_drvdata(serio, NULL); |
| 376 | fail1: input_free_device(input_dev); |
Dmitry Torokhov | eca1ed1 | 2005-09-15 02:01:46 -0500 | [diff] [blame] | 377 | kfree(elo); |
| 378 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | /* |
| 382 | * The serio driver structure. |
| 383 | */ |
| 384 | |
| 385 | static struct serio_device_id elo_serio_ids[] = { |
| 386 | { |
| 387 | .type = SERIO_RS232, |
| 388 | .proto = SERIO_ELO, |
| 389 | .id = SERIO_ANY, |
| 390 | .extra = SERIO_ANY, |
| 391 | }, |
| 392 | { 0 } |
| 393 | }; |
| 394 | |
| 395 | MODULE_DEVICE_TABLE(serio, elo_serio_ids); |
| 396 | |
| 397 | static struct serio_driver elo_drv = { |
| 398 | .driver = { |
| 399 | .name = "elo", |
| 400 | }, |
| 401 | .description = DRIVER_DESC, |
| 402 | .id_table = elo_serio_ids, |
| 403 | .interrupt = elo_interrupt, |
| 404 | .connect = elo_connect, |
| 405 | .disconnect = elo_disconnect, |
| 406 | }; |
| 407 | |
Axel Lin | 65ac9f7 | 2012-04-03 23:50:17 -0700 | [diff] [blame^] | 408 | module_serio_driver(elo_drv); |