blob: 3a5e0aafa115ed56845a7db5a296f0b9f5e16b7d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Native support for the Aiptek HyperPen USB Tablets
3 * (4000U/5000U/6000U/8000U/12000U)
Dmitry Torokhov05f091a2005-05-29 02:29:01 -05004 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Copyright (c) 2001 Chris Atenasio <chris@crud.net>
6 * Copyright (c) 2002-2004 Bryan W. Headley <bwheadley@earthlink.net>
7 *
8 * based on wacom.c by
9 * Vojtech Pavlik <vojtech@suse.cz>
10 * Andreas Bach Aaen <abach@stofanet.dk>
11 * Clifford Wolf <clifford@clifford.at>
12 * Sam Mosel <sam.mosel@computer.org>
13 * James E. Blair <corvus@gnu.org>
14 * Daniel Egger <egger@suse.de>
15 *
16 * Many thanks to Oliver Kuechemann for his support.
17 *
18 * ChangeLog:
19 * v0.1 - Initial release
20 * v0.2 - Hack to get around fake event 28's. (Bryan W. Headley)
21 * v0.3 - Make URB dynamic (Bryan W. Headley, Jun-8-2002)
22 * Released to Linux 2.4.19 and 2.5.x
23 * v0.4 - Rewrote substantial portions of the code to deal with
24 * corrected control sequences, timing, dynamic configuration,
25 * support of 6000U - 12000U, procfs, and macro key support
26 * (Jan-1-2003 - Feb-5-2003, Bryan W. Headley)
27 * v1.0 - Added support for diagnostic messages, count of messages
28 * received from URB - Mar-8-2003, Bryan W. Headley
29 * v1.1 - added support for tablet resolution, changed DV and proximity
30 * some corrections - Jun-22-2003, martin schneebacher
31 * - Added support for the sysfs interface, deprecating the
32 * procfs interface for 2.5.x kernel. Also added support for
33 * Wheel command. Bryan W. Headley July-15-2003.
Dmitry Torokhov05f091a2005-05-29 02:29:01 -050034 * v1.2 - Reworked jitter timer as a kernel thread.
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 * Bryan W. Headley November-28-2003/Jan-10-2004.
36 * v1.3 - Repaired issue of kernel thread going nuts on single-processor
37 * machines, introduced programmableDelay as a command line
38 * parameter. Feb 7 2004, Bryan W. Headley.
39 * v1.4 - Re-wire jitter so it does not require a thread. Courtesy of
40 * Rene van Paassen. Added reporting of physical pointer device
41 * (e.g., stylus, mouse in reports 2, 3, 4, 5. We don't know
42 * for reports 1, 6.)
43 * what physical device reports for reports 1, 6.) Also enabled
44 * MOUSE and LENS tool button modes. Renamed "rubber" to "eraser".
45 * Feb 20, 2004, Bryan W. Headley.
46 * v1.5 - Added previousJitterable, so we don't do jitter delay when the
47 * user is holding a button down for periods of time.
48 *
49 * NOTE:
50 * This kernel driver is augmented by the "Aiptek" XFree86 input
51 * driver for your X server, as well as the Gaiptek GUI Front-end
Dmitry Torokhov05f091a2005-05-29 02:29:01 -050052 * "Tablet Manager".
53 * These three products are highly interactive with one another,
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 * so therefore it's easier to document them all as one subsystem.
Dmitry Torokhov05f091a2005-05-29 02:29:01 -050055 * Please visit the project's "home page", located at,
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 * http://aiptektablet.sourceforge.net.
57 *
58 * This program is free software; you can redistribute it and/or modify
59 * it under the terms of the GNU General Public License as published by
60 * the Free Software Foundation; either version 2 of the License, or
61 * (at your option) any later version.
62 *
63 * This program is distributed in the hope that it will be useful,
64 * but WITHOUT ANY WARRANTY; without even the implied warranty of
65 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66 * GNU General Public License for more details.
67 *
68 * You should have received a copy of the GNU General Public License
69 * along with this program; if not, write to the Free Software
70 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
71 */
72
73#include <linux/jiffies.h>
74#include <linux/kernel.h>
75#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#include <linux/module.h>
77#include <linux/init.h>
David Brownellae0dadc2006-06-13 10:04:34 -070078#include <linux/usb/input.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#include <asm/uaccess.h>
80#include <asm/unaligned.h>
81
82/*
83 * Version Information
84 */
85#define DRIVER_VERSION "v1.5 (May-15-2004)"
86#define DRIVER_AUTHOR "Bryan W. Headley/Chris Atenasio"
87#define DRIVER_DESC "Aiptek HyperPen USB Tablet Driver (Linux 2.6.x)"
88
89/*
90 * Aiptek status packet:
91 *
92 * (returned as Report 1 - relative coordinates from mouse and stylus)
93 *
94 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
95 * byte0 0 0 0 0 0 0 0 1
96 * byte1 0 0 0 0 0 BS2 BS Tip
97 * byte2 X7 X6 X5 X4 X3 X2 X1 X0
98 * byte3 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
99 *
100 * (returned as Report 2 - absolute coordinates from the stylus)
101 *
102 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
103 * byte0 0 0 0 0 0 0 1 0
104 * byte1 X7 X6 X5 X4 X3 X2 X1 X0
105 * byte2 X15 X14 X13 X12 X11 X10 X9 X8
106 * byte3 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
107 * byte4 Y15 Y14 Y13 Y12 Y11 Y10 Y9 Y8
108 * byte5 * * * BS2 BS1 Tip IR DV
109 * byte6 P7 P6 P5 P4 P3 P2 P1 P0
110 * byte7 P15 P14 P13 P12 P11 P10 P9 P8
111 *
112 * (returned as Report 3 - absolute coordinates from the mouse)
113 *
114 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
115 * byte0 0 0 0 0 0 0 1 0
116 * byte1 X7 X6 X5 X4 X3 X2 X1 X0
117 * byte2 X15 X14 X13 X12 X11 X10 X9 X8
118 * byte3 Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
119 * byte4 Y15 Y14 Y13 Y12 Y11 Y10 Y9 Y8
120 * byte5 * * * BS2 BS1 Tip IR DV
121 * byte6 P7 P6 P5 P4 P3 P2 P1 P0
122 * byte7 P15 P14 P13 P12 P11 P10 P9 P8
123 *
124 * (returned as Report 4 - macrokeys from the stylus)
125 *
126 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
127 * byte0 0 0 0 0 0 1 0 0
128 * byte1 0 0 0 BS2 BS Tip IR DV
129 * byte2 0 0 0 0 0 0 1 0
130 * byte3 0 0 0 K4 K3 K2 K1 K0
131 * byte4 P7 P6 P5 P4 P3 P2 P1 P0
132 * byte5 P15 P14 P13 P12 P11 P10 P9 P8
133 *
134 * (returned as Report 5 - macrokeys from the mouse)
135 *
136 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
137 * byte0 0 0 0 0 0 1 0 0
138 * byte1 0 0 0 BS2 BS Tip IR DV
139 * byte2 0 0 0 0 0 0 1 0
140 * byte3 0 0 0 K4 K3 K2 K1 K0
141 * byte4 P7 P6 P5 P4 P3 P2 P1 P0
142 * byte5 P15 P14 P13 P12 P11 P10 P9 P8
143 *
144 * IR: In Range = Proximity on
145 * DV = Data Valid
146 * BS = Barrel Switch (as in, macro keys)
147 * BS2 also referred to as Tablet Pick
148 *
149 * Command Summary:
150 *
151 * Use report_type CONTROL (3)
152 * Use report_id 2
153 *
154 * Command/Data Description Return Bytes Return Value
155 * 0x10/0x00 SwitchToMouse 0
156 * 0x10/0x01 SwitchToTablet 0
Dmitry Torokhov05f091a2005-05-29 02:29:01 -0500157 * 0x18/0x04 SetResolution 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 * 0x12/0xFF AutoGainOn 0
159 * 0x17/0x00 FilterOn 0
160 * 0x01/0x00 GetXExtension 2 MaxX
161 * 0x01/0x01 GetYExtension 2 MaxY
162 * 0x02/0x00 GetModelCode 2 ModelCode = LOBYTE
163 * 0x03/0x00 GetODMCode 2 ODMCode
164 * 0x08/0x00 GetPressureLevels 2 =512
165 * 0x04/0x00 GetFirmwareVersion 2 Firmware Version
166 * 0x11/0x02 EnableMacroKeys 0
167 *
168 * To initialize the tablet:
169 *
170 * (1) Send Resolution500LPI (Command)
171 * (2) Query for Model code (Option Report)
172 * (3) Query for ODM code (Option Report)
173 * (4) Query for firmware (Option Report)
174 * (5) Query for GetXExtension (Option Report)
175 * (6) Query for GetYExtension (Option Report)
176 * (7) Query for GetPressureLevels (Option Report)
177 * (8) SwitchToTablet for Absolute coordinates, or
178 * SwitchToMouse for Relative coordinates (Command)
179 * (9) EnableMacroKeys (Command)
180 * (10) FilterOn (Command)
181 * (11) AutoGainOn (Command)
182 *
183 * (Step 9 can be omitted, but you'll then have no function keys.)
184 */
185
186#define USB_VENDOR_ID_AIPTEK 0x08ca
187#define USB_REQ_GET_REPORT 0x01
188#define USB_REQ_SET_REPORT 0x09
189
190 /* PointerMode codes
191 */
192#define AIPTEK_POINTER_ONLY_MOUSE_MODE 0
193#define AIPTEK_POINTER_ONLY_STYLUS_MODE 1
194#define AIPTEK_POINTER_EITHER_MODE 2
195
196#define AIPTEK_POINTER_ALLOW_MOUSE_MODE(a) \
197 (a == AIPTEK_POINTER_ONLY_MOUSE_MODE || \
198 a == AIPTEK_POINTER_EITHER_MODE)
199#define AIPTEK_POINTER_ALLOW_STYLUS_MODE(a) \
200 (a == AIPTEK_POINTER_ONLY_STYLUS_MODE || \
201 a == AIPTEK_POINTER_EITHER_MODE)
202
203 /* CoordinateMode code
204 */
205#define AIPTEK_COORDINATE_RELATIVE_MODE 0
206#define AIPTEK_COORDINATE_ABSOLUTE_MODE 1
207
208 /* XTilt and YTilt values
209 */
210#define AIPTEK_TILT_MIN (-128)
211#define AIPTEK_TILT_MAX 127
212#define AIPTEK_TILT_DISABLE (-10101)
213
214 /* Wheel values
215 */
216#define AIPTEK_WHEEL_MIN 0
217#define AIPTEK_WHEEL_MAX 1024
218#define AIPTEK_WHEEL_DISABLE (-10101)
219
220 /* ToolCode values, which BTW are 0x140 .. 0x14f
221 * We have things set up such that if TOOL_BUTTON_FIRED_BIT is
222 * not set, we'll send one instance of AIPTEK_TOOL_BUTTON_xxx.
223 *
224 * Whenever the user resets the value, TOOL_BUTTON_FIRED_BIT will
225 * get reset.
226 */
227#define TOOL_BUTTON(x) ((x) & 0x14f)
228#define TOOL_BUTTON_FIRED(x) ((x) & 0x200)
229#define TOOL_BUTTON_FIRED_BIT 0x200
230 /* toolMode codes
231 */
232#define AIPTEK_TOOL_BUTTON_PEN_MODE BTN_TOOL_PEN
233#define AIPTEK_TOOL_BUTTON_PEN_MODE BTN_TOOL_PEN
234#define AIPTEK_TOOL_BUTTON_PENCIL_MODE BTN_TOOL_PENCIL
235#define AIPTEK_TOOL_BUTTON_BRUSH_MODE BTN_TOOL_BRUSH
236#define AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE BTN_TOOL_AIRBRUSH
237#define AIPTEK_TOOL_BUTTON_ERASER_MODE BTN_TOOL_RUBBER
238#define AIPTEK_TOOL_BUTTON_MOUSE_MODE BTN_TOOL_MOUSE
239#define AIPTEK_TOOL_BUTTON_LENS_MODE BTN_TOOL_LENS
240
241 /* Diagnostic message codes
242 */
243#define AIPTEK_DIAGNOSTIC_NA 0
244#define AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE 1
245#define AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE 2
246#define AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED 3
247
Dmitry Torokhov05f091a2005-05-29 02:29:01 -0500248 /* Time to wait (in ms) to help mask hand jittering
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 * when pressing the stylus buttons.
250 */
251#define AIPTEK_JITTER_DELAY_DEFAULT 50
252
253 /* Time to wait (in ms) in-between sending the tablet
254 * a command and beginning the process of reading the return
255 * sequence from the tablet.
256 */
257#define AIPTEK_PROGRAMMABLE_DELAY_25 25
258#define AIPTEK_PROGRAMMABLE_DELAY_50 50
259#define AIPTEK_PROGRAMMABLE_DELAY_100 100
260#define AIPTEK_PROGRAMMABLE_DELAY_200 200
261#define AIPTEK_PROGRAMMABLE_DELAY_300 300
262#define AIPTEK_PROGRAMMABLE_DELAY_400 400
263#define AIPTEK_PROGRAMMABLE_DELAY_DEFAULT AIPTEK_PROGRAMMABLE_DELAY_400
264
265 /* Mouse button programming
266 */
267#define AIPTEK_MOUSE_LEFT_BUTTON 0x01
268#define AIPTEK_MOUSE_RIGHT_BUTTON 0x02
269#define AIPTEK_MOUSE_MIDDLE_BUTTON 0x04
270
271 /* Stylus button programming
272 */
273#define AIPTEK_STYLUS_LOWER_BUTTON 0x08
274#define AIPTEK_STYLUS_UPPER_BUTTON 0x10
275
276 /* Length of incoming packet from the tablet
277 */
278#define AIPTEK_PACKET_LENGTH 8
279
280 /* We report in EV_MISC both the proximity and
281 * whether the report came from the stylus, tablet mouse
282 * or "unknown" -- Unknown when the tablet is in relative
283 * mode, because we only get report 1's.
284 */
285#define AIPTEK_REPORT_TOOL_UNKNOWN 0x10
286#define AIPTEK_REPORT_TOOL_STYLUS 0x20
287#define AIPTEK_REPORT_TOOL_MOUSE 0x40
288
289static int programmableDelay = AIPTEK_PROGRAMMABLE_DELAY_DEFAULT;
290static int jitterDelay = AIPTEK_JITTER_DELAY_DEFAULT;
291
292struct aiptek_features {
293 int odmCode; /* Tablet manufacturer code */
294 int modelCode; /* Tablet model code (not unique) */
295 int firmwareCode; /* prom/eeprom version */
296 char usbPath[64 + 1]; /* device's physical usb path */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297};
298
299struct aiptek_settings {
300 int pointerMode; /* stylus-, mouse-only or either */
301 int coordinateMode; /* absolute/relative coords */
302 int toolMode; /* pen, pencil, brush, etc. tool */
303 int xTilt; /* synthetic xTilt amount */
304 int yTilt; /* synthetic yTilt amount */
305 int wheel; /* synthetic wheel amount */
306 int stylusButtonUpper; /* stylus upper btn delivers... */
307 int stylusButtonLower; /* stylus lower btn delivers... */
308 int mouseButtonLeft; /* mouse left btn delivers... */
309 int mouseButtonMiddle; /* mouse middle btn delivers... */
310 int mouseButtonRight; /* mouse right btn delivers... */
311 int programmableDelay; /* delay for tablet programming */
312 int jitterDelay; /* delay for hand jittering */
313};
314
315struct aiptek {
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -0500316 struct input_dev *inputdev; /* input device struct */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 struct usb_device *usbdev; /* usb device struct */
318 struct urb *urb; /* urb for incoming reports */
319 dma_addr_t data_dma; /* our dma stuffage */
320 struct aiptek_features features; /* tablet's array of features */
321 struct aiptek_settings curSetting; /* tablet's current programmable */
322 struct aiptek_settings newSetting; /* ... and new param settings */
323 unsigned int ifnum; /* interface number for IO */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 int diagnostic; /* tablet diagnostic codes */
325 unsigned long eventCount; /* event count */
326 int inDelay; /* jitter: in jitter delay? */
327 unsigned long endDelay; /* jitter: time when delay ends */
328 int previousJitterable; /* jitterable prev value */
329 unsigned char *data; /* incoming packet data */
330};
331
332/*
333 * Permit easy lookup of keyboard events to send, versus
334 * the bitmap which comes from the tablet. This hides the
335 * issue that the F_keys are not sequentially numbered.
336 */
Arjan van de Ven4c4c9432005-11-29 09:43:42 +0100337static const int macroKeyEvents[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5,
339 KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11,
340 KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17,
341 KEY_F18, KEY_F19, KEY_F20, KEY_F21, KEY_F22, KEY_F23,
342 KEY_F24, KEY_STOP, KEY_AGAIN, KEY_PROPS, KEY_UNDO,
343 KEY_FRONT, KEY_COPY, KEY_OPEN, KEY_PASTE, 0
344};
345
346/***********************************************************************
Dmitry Torokhovcd438a52007-05-21 00:17:57 -0400347 * Map values to strings and back. Every map shoudl have the following
348 * as its last element: { NULL, AIPTEK_INVALID_VALUE }.
349 */
350#define AIPTEK_INVALID_VALUE -1
351
352struct aiptek_map {
353 const char *string;
354 int value;
355};
356
357static int map_str_to_val(const struct aiptek_map *map, const char *str, size_t count)
358{
359 const struct aiptek_map *p;
360
361 for (p = map; p->string; p++)
362 if (!strncmp(str, p->string, count))
363 return p->value;
364
365 return AIPTEK_INVALID_VALUE;
366}
367
368static const char *map_val_to_str(const struct aiptek_map *map, int val)
369{
370 const struct aiptek_map *p;
371
372 for (p = map; p->value != AIPTEK_INVALID_VALUE; p++)
373 if (val == p->value)
374 return p->string;
375
376 return "unknown";
377}
378
379/***********************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 * aiptek_irq can receive one of six potential reports.
381 * The documentation for each is in the body of the function.
382 *
383 * The tablet reports on several attributes per invocation of
384 * aiptek_irq. Because the Linux Input Event system allows the
385 * transmission of ONE attribute per input_report_xxx() call,
386 * collation has to be done on the other end to reconstitute
387 * a complete tablet report. Further, the number of Input Event reports
388 * submitted varies, depending on what USB report type, and circumstance.
389 * To deal with this, EV_MSC is used to indicate an 'end-of-report'
390 * message. This has been an undocumented convention understood by the kernel
391 * tablet driver and clients such as gpm and XFree86's tablet drivers.
392 *
393 * Of the information received from the tablet, the one piece I
394 * cannot transmit is the proximity bit (without resorting to an EV_MSC
395 * convention above.) I therefore have taken over REL_MISC and ABS_MISC
396 * (for relative and absolute reports, respectively) for communicating
397 * Proximity. Why two events? I thought it interesting to know if the
Steven Cole093cf722005-05-03 19:07:24 -0600398 * Proximity event occurred while the tablet was in absolute or relative
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 * mode.
400 *
401 * Other tablets use the notion of a certain minimum stylus pressure
402 * to infer proximity. While that could have been done, that is yet
403 * another 'by convention' behavior, the documentation for which
404 * would be spread between two (or more) pieces of software.
405 *
406 * EV_MSC usage was terminated for this purpose in Linux 2.5.x, and
407 * replaced with the input_sync() method (which emits EV_SYN.)
408 */
409
David Howells7d12e782006-10-05 14:55:46 +0100410static void aiptek_irq(struct urb *urb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
412 struct aiptek *aiptek = urb->context;
413 unsigned char *data = aiptek->data;
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -0500414 struct input_dev *inputdev = aiptek->inputdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 int jitterable = 0;
416 int retval, macro, x, y, z, left, right, middle, p, dv, tip, bs, pck;
417
418 switch (urb->status) {
419 case 0:
420 /* Success */
421 break;
422
423 case -ECONNRESET:
424 case -ENOENT:
425 case -ESHUTDOWN:
426 /* This urb is terminated, clean up */
427 dbg("%s - urb shutting down with status: %d",
428 __FUNCTION__, urb->status);
429 return;
430
431 default:
432 dbg("%s - nonzero urb status received: %d",
433 __FUNCTION__, urb->status);
434 goto exit;
435 }
436
437 /* See if we are in a delay loop -- throw out report if true.
438 */
439 if (aiptek->inDelay == 1 && time_after(aiptek->endDelay, jiffies)) {
440 goto exit;
441 }
442
443 aiptek->inDelay = 0;
444 aiptek->eventCount++;
445
446 /* Report 1 delivers relative coordinates with either a stylus
447 * or the mouse. You do not know, however, which input
448 * tool generated the event.
449 */
450 if (data[0] == 1) {
451 if (aiptek->curSetting.coordinateMode ==
452 AIPTEK_COORDINATE_ABSOLUTE_MODE) {
453 aiptek->diagnostic =
454 AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE;
455 } else {
Dmitry Torokhov37767b62007-05-21 00:18:08 -0400456 x = (signed char) data[2];
457 y = (signed char) data[3];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
459 /* jitterable keeps track of whether any button has been pressed.
460 * We're also using it to remap the physical mouse button mask
461 * to pseudo-settings. (We don't specifically care about it's
462 * value after moving/transposing mouse button bitmasks, except
463 * that a non-zero value indicates that one or more
464 * mouse button was pressed.)
465 */
466 jitterable = data[5] & 0x07;
467
468 left = (data[5] & aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0;
469 right = (data[5] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0;
470 middle = (data[5] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0;
471
472 input_report_key(inputdev, BTN_LEFT, left);
473 input_report_key(inputdev, BTN_MIDDLE, middle);
474 input_report_key(inputdev, BTN_RIGHT, right);
475 input_report_rel(inputdev, REL_X, x);
476 input_report_rel(inputdev, REL_Y, y);
477 input_report_rel(inputdev, REL_MISC, 1 | AIPTEK_REPORT_TOOL_UNKNOWN);
478
479 /* Wheel support is in the form of a single-event
480 * firing.
481 */
482 if (aiptek->curSetting.wheel != AIPTEK_WHEEL_DISABLE) {
483 input_report_rel(inputdev, REL_WHEEL,
484 aiptek->curSetting.wheel);
485 aiptek->curSetting.wheel = AIPTEK_WHEEL_DISABLE;
486 }
487 input_sync(inputdev);
488 }
489 }
490 /* Report 2 is delivered only by the stylus, and delivers
491 * absolute coordinates.
492 */
493 else if (data[0] == 2) {
494 if (aiptek->curSetting.coordinateMode == AIPTEK_COORDINATE_RELATIVE_MODE) {
495 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
496 } else if (!AIPTEK_POINTER_ALLOW_STYLUS_MODE
497 (aiptek->curSetting.pointerMode)) {
498 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
499 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 x = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
501 y = le16_to_cpu(get_unaligned((__le16 *) (data + 3)));
502 z = le16_to_cpu(get_unaligned((__le16 *) (data + 6)));
503
504 p = (data[5] & 0x01) != 0 ? 1 : 0;
505 dv = (data[5] & 0x02) != 0 ? 1 : 0;
506 tip = (data[5] & 0x04) != 0 ? 1 : 0;
507
508 /* Use jitterable to re-arrange button masks
509 */
510 jitterable = data[5] & 0x18;
511
512 bs = (data[5] & aiptek->curSetting.stylusButtonLower) != 0 ? 1 : 0;
513 pck = (data[5] & aiptek->curSetting.stylusButtonUpper) != 0 ? 1 : 0;
514
515 /* dv indicates 'data valid' (e.g., the tablet is in sync
516 * and has delivered a "correct" report) We will ignore
517 * all 'bad' reports...
518 */
519 if (dv != 0) {
520 /* If we've not already sent a tool_button_?? code, do
521 * so now. Then set FIRED_BIT so it won't be resent unless
522 * the user forces FIRED_BIT off.
523 */
524 if (TOOL_BUTTON_FIRED
525 (aiptek->curSetting.toolMode) == 0) {
526 input_report_key(inputdev,
527 TOOL_BUTTON(aiptek->curSetting.toolMode),
528 1);
529 aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
530 }
531
532 if (p != 0) {
533 input_report_abs(inputdev, ABS_X, x);
534 input_report_abs(inputdev, ABS_Y, y);
535 input_report_abs(inputdev, ABS_PRESSURE, z);
536
537 input_report_key(inputdev, BTN_TOUCH, tip);
538 input_report_key(inputdev, BTN_STYLUS, bs);
539 input_report_key(inputdev, BTN_STYLUS2, pck);
540
541 if (aiptek->curSetting.xTilt !=
542 AIPTEK_TILT_DISABLE) {
543 input_report_abs(inputdev,
544 ABS_TILT_X,
545 aiptek->curSetting.xTilt);
546 }
547 if (aiptek->curSetting.yTilt != AIPTEK_TILT_DISABLE) {
548 input_report_abs(inputdev,
549 ABS_TILT_Y,
550 aiptek->curSetting.yTilt);
551 }
552
553 /* Wheel support is in the form of a single-event
554 * firing.
555 */
556 if (aiptek->curSetting.wheel !=
557 AIPTEK_WHEEL_DISABLE) {
558 input_report_abs(inputdev,
559 ABS_WHEEL,
560 aiptek->curSetting.wheel);
561 aiptek->curSetting.wheel = AIPTEK_WHEEL_DISABLE;
562 }
563 }
564 input_report_abs(inputdev, ABS_MISC, p | AIPTEK_REPORT_TOOL_STYLUS);
565 input_sync(inputdev);
566 }
567 }
568 }
569 /* Report 3's come from the mouse in absolute mode.
570 */
571 else if (data[0] == 3) {
572 if (aiptek->curSetting.coordinateMode == AIPTEK_COORDINATE_RELATIVE_MODE) {
573 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE;
574 } else if (!AIPTEK_POINTER_ALLOW_MOUSE_MODE
575 (aiptek->curSetting.pointerMode)) {
576 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED;
577 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 x = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
579 y = le16_to_cpu(get_unaligned((__le16 *) (data + 3)));
580
581 jitterable = data[5] & 0x1c;
582
583 p = (data[5] & 0x01) != 0 ? 1 : 0;
584 dv = (data[5] & 0x02) != 0 ? 1 : 0;
585 left = (data[5] & aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0;
586 right = (data[5] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0;
587 middle = (data[5] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0;
588
589 if (dv != 0) {
590 /* If we've not already sent a tool_button_?? code, do
591 * so now. Then set FIRED_BIT so it won't be resent unless
592 * the user forces FIRED_BIT off.
593 */
594 if (TOOL_BUTTON_FIRED
595 (aiptek->curSetting.toolMode) == 0) {
596 input_report_key(inputdev,
597 TOOL_BUTTON(aiptek->curSetting.toolMode),
598 1);
599 aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
600 }
601
602 if (p != 0) {
603 input_report_abs(inputdev, ABS_X, x);
604 input_report_abs(inputdev, ABS_Y, y);
605
606 input_report_key(inputdev, BTN_LEFT, left);
607 input_report_key(inputdev, BTN_MIDDLE, middle);
608 input_report_key(inputdev, BTN_RIGHT, right);
609
610 /* Wheel support is in the form of a single-event
611 * firing.
612 */
613 if (aiptek->curSetting.wheel != AIPTEK_WHEEL_DISABLE) {
614 input_report_abs(inputdev,
615 ABS_WHEEL,
616 aiptek->curSetting.wheel);
617 aiptek->curSetting.wheel = AIPTEK_WHEEL_DISABLE;
618 }
619 }
620 input_report_rel(inputdev, REL_MISC, p | AIPTEK_REPORT_TOOL_MOUSE);
621 input_sync(inputdev);
622 }
623 }
624 }
625 /* Report 4s come from the macro keys when pressed by stylus
626 */
627 else if (data[0] == 4) {
628 jitterable = data[1] & 0x18;
629
630 p = (data[1] & 0x01) != 0 ? 1 : 0;
631 dv = (data[1] & 0x02) != 0 ? 1 : 0;
632 tip = (data[1] & 0x04) != 0 ? 1 : 0;
633 bs = (data[1] & aiptek->curSetting.stylusButtonLower) != 0 ? 1 : 0;
634 pck = (data[1] & aiptek->curSetting.stylusButtonUpper) != 0 ? 1 : 0;
635
636 macro = data[3];
637 z = le16_to_cpu(get_unaligned((__le16 *) (data + 4)));
638
639 if (dv != 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 /* If we've not already sent a tool_button_?? code, do
641 * so now. Then set FIRED_BIT so it won't be resent unless
642 * the user forces FIRED_BIT off.
643 */
644 if (TOOL_BUTTON_FIRED(aiptek->curSetting.toolMode) == 0) {
645 input_report_key(inputdev,
646 TOOL_BUTTON(aiptek->curSetting.toolMode),
647 1);
648 aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
649 }
650
651 if (p != 0) {
652 input_report_key(inputdev, BTN_TOUCH, tip);
653 input_report_key(inputdev, BTN_STYLUS, bs);
654 input_report_key(inputdev, BTN_STYLUS2, pck);
655 input_report_abs(inputdev, ABS_PRESSURE, z);
656 }
657
658 /* For safety, we're sending key 'break' codes for the
659 * neighboring macro keys.
660 */
661 if (macro > 0) {
662 input_report_key(inputdev,
663 macroKeyEvents[macro - 1], 0);
664 }
665 if (macro < 25) {
666 input_report_key(inputdev,
667 macroKeyEvents[macro + 1], 0);
668 }
669 input_report_key(inputdev, macroKeyEvents[macro], p);
670 input_report_abs(inputdev, ABS_MISC,
671 p | AIPTEK_REPORT_TOOL_STYLUS);
672 input_sync(inputdev);
673 }
674 }
675 /* Report 5s come from the macro keys when pressed by mouse
676 */
677 else if (data[0] == 5) {
678 jitterable = data[1] & 0x1c;
679
680 p = (data[1] & 0x01) != 0 ? 1 : 0;
681 dv = (data[1] & 0x02) != 0 ? 1 : 0;
682 left = (data[1]& aiptek->curSetting.mouseButtonLeft) != 0 ? 1 : 0;
683 right = (data[1] & aiptek->curSetting.mouseButtonRight) != 0 ? 1 : 0;
684 middle = (data[1] & aiptek->curSetting.mouseButtonMiddle) != 0 ? 1 : 0;
685 macro = data[3];
686
687 if (dv != 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 /* If we've not already sent a tool_button_?? code, do
689 * so now. Then set FIRED_BIT so it won't be resent unless
690 * the user forces FIRED_BIT off.
691 */
692 if (TOOL_BUTTON_FIRED(aiptek->curSetting.toolMode) == 0) {
693 input_report_key(inputdev,
694 TOOL_BUTTON(aiptek->curSetting.toolMode),
695 1);
696 aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
697 }
698
699 if (p != 0) {
700 input_report_key(inputdev, BTN_LEFT, left);
701 input_report_key(inputdev, BTN_MIDDLE, middle);
702 input_report_key(inputdev, BTN_RIGHT, right);
703 }
704
705 /* For safety, we're sending key 'break' codes for the
706 * neighboring macro keys.
707 */
708 if (macro > 0) {
709 input_report_key(inputdev,
710 macroKeyEvents[macro - 1], 0);
711 }
712 if (macro < 25) {
713 input_report_key(inputdev,
714 macroKeyEvents[macro + 1], 0);
715 }
716
717 input_report_key(inputdev, macroKeyEvents[macro], 1);
718 input_report_rel(inputdev, ABS_MISC,
719 p | AIPTEK_REPORT_TOOL_MOUSE);
720 input_sync(inputdev);
721 }
722 }
723 /* We have no idea which tool can generate a report 6. Theoretically,
724 * neither need to, having been given reports 4 & 5 for such use.
725 * However, report 6 is the 'official-looking' report for macroKeys;
726 * reports 4 & 5 supposively are used to support unnamed, unknown
727 * hat switches (which just so happen to be the macroKeys.)
728 */
729 else if (data[0] == 6) {
730 macro = le16_to_cpu(get_unaligned((__le16 *) (data + 1)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 if (macro > 0) {
732 input_report_key(inputdev, macroKeyEvents[macro - 1],
733 0);
734 }
735 if (macro < 25) {
736 input_report_key(inputdev, macroKeyEvents[macro + 1],
737 0);
738 }
739
740 /* If we've not already sent a tool_button_?? code, do
741 * so now. Then set FIRED_BIT so it won't be resent unless
742 * the user forces FIRED_BIT off.
743 */
744 if (TOOL_BUTTON_FIRED(aiptek->curSetting.toolMode) == 0) {
745 input_report_key(inputdev,
746 TOOL_BUTTON(aiptek->curSetting.
747 toolMode), 1);
748 aiptek->curSetting.toolMode |= TOOL_BUTTON_FIRED_BIT;
749 }
750
751 input_report_key(inputdev, macroKeyEvents[macro], 1);
752 input_report_abs(inputdev, ABS_MISC,
753 1 | AIPTEK_REPORT_TOOL_UNKNOWN);
754 input_sync(inputdev);
755 } else {
756 dbg("Unknown report %d", data[0]);
757 }
758
759 /* Jitter may occur when the user presses a button on the stlyus
760 * or the mouse. What we do to prevent that is wait 'x' milliseconds
761 * following a 'jitterable' event, which should give the hand some time
762 * stabilize itself.
763 *
764 * We just introduced aiptek->previousJitterable to carry forth the
765 * notion that jitter occurs when the button state changes from on to off:
766 * a person drawing, holding a button down is not subject to jittering.
767 * With that in mind, changing from upper button depressed to lower button
768 * WILL transition through a jitter delay.
769 */
770
771 if (aiptek->previousJitterable != jitterable &&
772 aiptek->curSetting.jitterDelay != 0 && aiptek->inDelay != 1) {
773 aiptek->endDelay = jiffies +
774 ((aiptek->curSetting.jitterDelay * HZ) / 1000);
775 aiptek->inDelay = 1;
776 }
777 aiptek->previousJitterable = jitterable;
778
779exit:
780 retval = usb_submit_urb(urb, GFP_ATOMIC);
781 if (retval != 0) {
782 err("%s - usb_submit_urb failed with result %d",
783 __FUNCTION__, retval);
784 }
785}
786
787/***********************************************************************
788 * These are the USB id's known so far. We do not identify them to
789 * specific Aiptek model numbers, because there has been overlaps,
790 * use, and reuse of id's in existing models. Certain models have
791 * been known to use more than one ID, indicative perhaps of
Dmitry Torokhov05f091a2005-05-29 02:29:01 -0500792 * manufacturing revisions. In any event, we consider these
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 * IDs to not be model-specific nor unique.
794 */
795static const struct usb_device_id aiptek_ids[] = {
796 {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x01)},
797 {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x10)},
798 {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x20)},
799 {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x21)},
800 {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x22)},
801 {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x23)},
802 {USB_DEVICE(USB_VENDOR_ID_AIPTEK, 0x24)},
803 {}
804};
805
806MODULE_DEVICE_TABLE(usb, aiptek_ids);
807
808/***********************************************************************
809 * Open an instance of the tablet driver.
810 */
811static int aiptek_open(struct input_dev *inputdev)
812{
Dmitry Torokhov7791bda2007-04-12 01:34:39 -0400813 struct aiptek *aiptek = input_get_drvdata(inputdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 aiptek->urb->dev = aiptek->usbdev;
Dmitry Torokhov65cde542005-05-29 02:29:38 -0500816 if (usb_submit_urb(aiptek->urb, GFP_KERNEL) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 return -EIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818
819 return 0;
820}
821
822/***********************************************************************
823 * Close an instance of the tablet driver.
824 */
825static void aiptek_close(struct input_dev *inputdev)
826{
Dmitry Torokhov7791bda2007-04-12 01:34:39 -0400827 struct aiptek *aiptek = input_get_drvdata(inputdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828
Dmitry Torokhov65cde542005-05-29 02:29:38 -0500829 usb_kill_urb(aiptek->urb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830}
831
832/***********************************************************************
Dmitry Torokhov05f091a2005-05-29 02:29:01 -0500833 * aiptek_set_report and aiptek_get_report() are borrowed from Linux 2.4.x,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 * where they were known as usb_set_report and usb_get_report.
835 */
836static int
837aiptek_set_report(struct aiptek *aiptek,
838 unsigned char report_type,
839 unsigned char report_id, void *buffer, int size)
840{
841 return usb_control_msg(aiptek->usbdev,
842 usb_sndctrlpipe(aiptek->usbdev, 0),
843 USB_REQ_SET_REPORT,
844 USB_TYPE_CLASS | USB_RECIP_INTERFACE |
845 USB_DIR_OUT, (report_type << 8) + report_id,
846 aiptek->ifnum, buffer, size, 5000);
847}
848
849static int
850aiptek_get_report(struct aiptek *aiptek,
851 unsigned char report_type,
852 unsigned char report_id, void *buffer, int size)
853{
854 return usb_control_msg(aiptek->usbdev,
855 usb_rcvctrlpipe(aiptek->usbdev, 0),
856 USB_REQ_GET_REPORT,
857 USB_TYPE_CLASS | USB_RECIP_INTERFACE |
858 USB_DIR_IN, (report_type << 8) + report_id,
859 aiptek->ifnum, buffer, size, 5000);
860}
861
862/***********************************************************************
863 * Send a command to the tablet.
864 */
865static int
866aiptek_command(struct aiptek *aiptek, unsigned char command, unsigned char data)
867{
868 const int sizeof_buf = 3 * sizeof(u8);
869 int ret;
870 u8 *buf;
871
872 buf = kmalloc(sizeof_buf, GFP_KERNEL);
873 if (!buf)
874 return -ENOMEM;
875
876 buf[0] = 2;
877 buf[1] = command;
878 buf[2] = data;
879
880 if ((ret =
881 aiptek_set_report(aiptek, 3, 2, buf, sizeof_buf)) != sizeof_buf) {
882 dbg("aiptek_program: failed, tried to send: 0x%02x 0x%02x",
883 command, data);
884 }
885 kfree(buf);
886 return ret < 0 ? ret : 0;
887}
888
889/***********************************************************************
890 * Retrieve information from the tablet. Querying info is defined as first
891 * sending the {command,data} sequence as a command, followed by a wait
892 * (aka, "programmaticDelay") and then a "read" request.
893 */
894static int
895aiptek_query(struct aiptek *aiptek, unsigned char command, unsigned char data)
896{
897 const int sizeof_buf = 3 * sizeof(u8);
898 int ret;
899 u8 *buf;
900
901 buf = kmalloc(sizeof_buf, GFP_KERNEL);
902 if (!buf)
903 return -ENOMEM;
904
905 buf[0] = 2;
906 buf[1] = command;
907 buf[2] = data;
908
909 if (aiptek_command(aiptek, command, data) != 0) {
910 kfree(buf);
911 return -EIO;
912 }
913 msleep(aiptek->curSetting.programmableDelay);
914
915 if ((ret =
916 aiptek_get_report(aiptek, 3, 2, buf, sizeof_buf)) != sizeof_buf) {
917 dbg("aiptek_query failed: returned 0x%02x 0x%02x 0x%02x",
918 buf[0], buf[1], buf[2]);
919 ret = -EIO;
920 } else {
921 ret = le16_to_cpu(get_unaligned((__le16 *) (buf + 1)));
922 }
923 kfree(buf);
924 return ret;
925}
926
927/***********************************************************************
928 * Program the tablet into either absolute or relative mode.
929 * We also get information about the tablet's size.
930 */
931static int aiptek_program_tablet(struct aiptek *aiptek)
932{
933 int ret;
934 /* Execute Resolution500LPI */
935 if ((ret = aiptek_command(aiptek, 0x18, 0x04)) < 0)
936 return ret;
937
938 /* Query getModelCode */
939 if ((ret = aiptek_query(aiptek, 0x02, 0x00)) < 0)
940 return ret;
941 aiptek->features.modelCode = ret & 0xff;
942
943 /* Query getODMCode */
944 if ((ret = aiptek_query(aiptek, 0x03, 0x00)) < 0)
945 return ret;
946 aiptek->features.odmCode = ret;
947
948 /* Query getFirmwareCode */
949 if ((ret = aiptek_query(aiptek, 0x04, 0x00)) < 0)
950 return ret;
951 aiptek->features.firmwareCode = ret;
952
953 /* Query getXextension */
954 if ((ret = aiptek_query(aiptek, 0x01, 0x00)) < 0)
955 return ret;
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -0500956 aiptek->inputdev->absmin[ABS_X] = 0;
957 aiptek->inputdev->absmax[ABS_X] = ret - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958
959 /* Query getYextension */
960 if ((ret = aiptek_query(aiptek, 0x01, 0x01)) < 0)
961 return ret;
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -0500962 aiptek->inputdev->absmin[ABS_Y] = 0;
963 aiptek->inputdev->absmax[ABS_Y] = ret - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964
965 /* Query getPressureLevels */
966 if ((ret = aiptek_query(aiptek, 0x08, 0x00)) < 0)
967 return ret;
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -0500968 aiptek->inputdev->absmin[ABS_PRESSURE] = 0;
969 aiptek->inputdev->absmax[ABS_PRESSURE] = ret - 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970
971 /* Depending on whether we are in absolute or relative mode, we will
972 * do a switchToTablet(absolute) or switchToMouse(relative) command.
973 */
974 if (aiptek->curSetting.coordinateMode ==
975 AIPTEK_COORDINATE_ABSOLUTE_MODE) {
976 /* Execute switchToTablet */
977 if ((ret = aiptek_command(aiptek, 0x10, 0x01)) < 0) {
978 return ret;
979 }
980 } else {
981 /* Execute switchToMouse */
982 if ((ret = aiptek_command(aiptek, 0x10, 0x00)) < 0) {
983 return ret;
984 }
985 }
986
987 /* Enable the macro keys */
988 if ((ret = aiptek_command(aiptek, 0x11, 0x02)) < 0)
989 return ret;
990#if 0
991 /* Execute FilterOn */
992 if ((ret = aiptek_command(aiptek, 0x17, 0x00)) < 0)
993 return ret;
994#endif
995
996 /* Execute AutoGainOn */
997 if ((ret = aiptek_command(aiptek, 0x12, 0xff)) < 0)
998 return ret;
999
1000 /* Reset the eventCount, so we track events from last (re)programming
1001 */
1002 aiptek->diagnostic = AIPTEK_DIAGNOSTIC_NA;
1003 aiptek->eventCount = 0;
1004
1005 return 0;
1006}
1007
1008/***********************************************************************
1009 * Sysfs functions. Sysfs prefers that individually-tunable parameters
1010 * exist in their separate pseudo-files. Summary data that is immutable
1011 * may exist in a singular file so long as you don't define a writeable
1012 * interface.
1013 */
1014
1015/***********************************************************************
1016 * support the 'size' file -- display support
1017 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001018static ssize_t show_tabletSize(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019{
1020 struct aiptek *aiptek = dev_get_drvdata(dev);
1021
Linus Torvalds1da177e2005-04-16 15:20:36 -07001022 return snprintf(buf, PAGE_SIZE, "%dx%d\n",
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001023 aiptek->inputdev->absmax[ABS_X] + 1,
1024 aiptek->inputdev->absmax[ABS_Y] + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025}
1026
1027/* These structs define the sysfs files, param #1 is the name of the
1028 * file, param 2 is the file permissions, param 3 & 4 are to the
1029 * output generator and input parser routines. Absence of a routine is
1030 * permitted -- it only means can't either 'cat' the file, or send data
1031 * to it.
1032 */
1033static DEVICE_ATTR(size, S_IRUGO, show_tabletSize, NULL);
1034
1035/***********************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 * support routines for the 'pointer_mode' file. Note that this file
1037 * both displays current setting and allows reprogramming.
1038 */
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001039static struct aiptek_map pointer_mode_map[] = {
1040 { "stylus", AIPTEK_POINTER_ONLY_STYLUS_MODE },
1041 { "mouse", AIPTEK_POINTER_ONLY_MOUSE_MODE },
1042 { "either", AIPTEK_POINTER_EITHER_MODE },
1043 { NULL, AIPTEK_INVALID_VALUE }
1044};
1045
Yani Ioannou060b8842005-05-17 06:44:04 -04001046static ssize_t show_tabletPointerMode(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047{
1048 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001050 return snprintf(buf, PAGE_SIZE, "%s\n",
1051 map_val_to_str(pointer_mode_map,
1052 aiptek->curSetting.pointerMode));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053}
1054
1055static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001056store_tabletPointerMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057{
1058 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001059 int new_mode = map_str_to_val(pointer_mode_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001061 if (new_mode == AIPTEK_INVALID_VALUE)
1062 return -EINVAL;
1063
1064 aiptek->newSetting.pointerMode = new_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 return count;
1066}
1067
1068static DEVICE_ATTR(pointer_mode,
1069 S_IRUGO | S_IWUGO,
1070 show_tabletPointerMode, store_tabletPointerMode);
1071
1072/***********************************************************************
1073 * support routines for the 'coordinate_mode' file. Note that this file
1074 * both displays current setting and allows reprogramming.
1075 */
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001076
1077static struct aiptek_map coordinate_mode_map[] = {
1078 { "absolute", AIPTEK_COORDINATE_ABSOLUTE_MODE },
1079 { "relative", AIPTEK_COORDINATE_RELATIVE_MODE },
1080 { NULL, AIPTEK_INVALID_VALUE }
1081};
1082
Yani Ioannou060b8842005-05-17 06:44:04 -04001083static ssize_t show_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084{
1085 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001087 return snprintf(buf, PAGE_SIZE, "%s\n",
1088 map_val_to_str(coordinate_mode_map,
1089 aiptek->curSetting.coordinateMode));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090}
1091
1092static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001093store_tabletCoordinateMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094{
1095 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001096 int new_mode = map_str_to_val(coordinate_mode_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001098 if (new_mode == AIPTEK_INVALID_VALUE)
1099 return -EINVAL;
1100
1101 aiptek->newSetting.coordinateMode = new_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 return count;
1103}
1104
1105static DEVICE_ATTR(coordinate_mode,
1106 S_IRUGO | S_IWUGO,
1107 show_tabletCoordinateMode, store_tabletCoordinateMode);
1108
1109/***********************************************************************
1110 * support routines for the 'tool_mode' file. Note that this file
1111 * both displays current setting and allows reprogramming.
1112 */
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001113
1114static struct aiptek_map tool_mode_map[] = {
1115 { "mouse", AIPTEK_TOOL_BUTTON_MOUSE_MODE },
1116 { "eraser", AIPTEK_TOOL_BUTTON_ERASER_MODE },
1117 { "pencil", AIPTEK_TOOL_BUTTON_PENCIL_MODE },
1118 { "pen", AIPTEK_TOOL_BUTTON_PEN_MODE },
1119 { "brush", AIPTEK_TOOL_BUTTON_BRUSH_MODE },
1120 { "airbrush", AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE },
1121 { "lens", AIPTEK_TOOL_BUTTON_LENS_MODE },
1122 { NULL, AIPTEK_INVALID_VALUE }
1123};
1124
Yani Ioannou060b8842005-05-17 06:44:04 -04001125static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126{
1127 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001129 return snprintf(buf, PAGE_SIZE, "%s\n",
1130 map_val_to_str(tool_mode_map,
1131 aiptek->curSetting.toolMode));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132}
1133
1134static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001135store_tabletToolMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136{
1137 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001138 int new_mode = map_str_to_val(tool_mode_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001140 if (new_mode == AIPTEK_INVALID_VALUE)
1141 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001143 aiptek->newSetting.toolMode = new_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 return count;
1145}
1146
1147static DEVICE_ATTR(tool_mode,
1148 S_IRUGO | S_IWUGO,
1149 show_tabletToolMode, store_tabletToolMode);
1150
1151/***********************************************************************
1152 * support routines for the 'xtilt' file. Note that this file
1153 * both displays current setting and allows reprogramming.
1154 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001155static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156{
1157 struct aiptek *aiptek = dev_get_drvdata(dev);
1158
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) {
1160 return snprintf(buf, PAGE_SIZE, "disable\n");
1161 } else {
1162 return snprintf(buf, PAGE_SIZE, "%d\n",
1163 aiptek->curSetting.xTilt);
1164 }
1165}
1166
1167static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001168store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169{
1170 struct aiptek *aiptek = dev_get_drvdata(dev);
1171 int x;
1172
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 if (strcmp(buf, "disable") == 0) {
1174 aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE;
1175 } else {
1176 x = (int)simple_strtol(buf, NULL, 10);
1177 if (x >= AIPTEK_TILT_MIN && x <= AIPTEK_TILT_MAX) {
1178 aiptek->newSetting.xTilt = x;
1179 }
1180 }
1181 return count;
1182}
1183
1184static DEVICE_ATTR(xtilt,
1185 S_IRUGO | S_IWUGO, show_tabletXtilt, store_tabletXtilt);
1186
1187/***********************************************************************
1188 * support routines for the 'ytilt' file. Note that this file
1189 * both displays current setting and allows reprogramming.
1190 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001191static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192{
1193 struct aiptek *aiptek = dev_get_drvdata(dev);
1194
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) {
1196 return snprintf(buf, PAGE_SIZE, "disable\n");
1197 } else {
1198 return snprintf(buf, PAGE_SIZE, "%d\n",
1199 aiptek->curSetting.yTilt);
1200 }
1201}
1202
1203static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001204store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205{
1206 struct aiptek *aiptek = dev_get_drvdata(dev);
1207 int y;
1208
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 if (strcmp(buf, "disable") == 0) {
1210 aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE;
1211 } else {
1212 y = (int)simple_strtol(buf, NULL, 10);
1213 if (y >= AIPTEK_TILT_MIN && y <= AIPTEK_TILT_MAX) {
1214 aiptek->newSetting.yTilt = y;
1215 }
1216 }
1217 return count;
1218}
1219
1220static DEVICE_ATTR(ytilt,
1221 S_IRUGO | S_IWUGO, show_tabletYtilt, store_tabletYtilt);
1222
1223/***********************************************************************
1224 * support routines for the 'jitter' file. Note that this file
1225 * both displays current setting and allows reprogramming.
1226 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001227static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228{
1229 struct aiptek *aiptek = dev_get_drvdata(dev);
1230
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay);
1232}
1233
1234static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001235store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236{
1237 struct aiptek *aiptek = dev_get_drvdata(dev);
1238
Linus Torvalds1da177e2005-04-16 15:20:36 -07001239 aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10);
1240 return count;
1241}
1242
1243static DEVICE_ATTR(jitter,
1244 S_IRUGO | S_IWUGO,
1245 show_tabletJitterDelay, store_tabletJitterDelay);
1246
1247/***********************************************************************
1248 * support routines for the 'delay' file. Note that this file
1249 * both displays current setting and allows reprogramming.
1250 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001251static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252{
1253 struct aiptek *aiptek = dev_get_drvdata(dev);
1254
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 return snprintf(buf, PAGE_SIZE, "%d\n",
1256 aiptek->curSetting.programmableDelay);
1257}
1258
1259static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001260store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261{
1262 struct aiptek *aiptek = dev_get_drvdata(dev);
1263
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10);
1265 return count;
1266}
1267
1268static DEVICE_ATTR(delay,
1269 S_IRUGO | S_IWUGO,
1270 show_tabletProgrammableDelay, store_tabletProgrammableDelay);
1271
1272/***********************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 * support routines for the 'event_count' file. Note that this file
1274 * only displays current setting.
1275 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001276static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277{
1278 struct aiptek *aiptek = dev_get_drvdata(dev);
1279
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount);
1281}
1282
1283static DEVICE_ATTR(event_count, S_IRUGO, show_tabletEventsReceived, NULL);
1284
1285/***********************************************************************
1286 * support routines for the 'diagnostic' file. Note that this file
1287 * only displays current setting.
1288 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001289static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290{
1291 struct aiptek *aiptek = dev_get_drvdata(dev);
1292 char *retMsg;
1293
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 switch (aiptek->diagnostic) {
1295 case AIPTEK_DIAGNOSTIC_NA:
1296 retMsg = "no errors\n";
1297 break;
1298
1299 case AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE:
1300 retMsg = "Error: receiving relative reports\n";
1301 break;
1302
1303 case AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE:
1304 retMsg = "Error: receiving absolute reports\n";
1305 break;
1306
1307 case AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED:
1308 if (aiptek->curSetting.pointerMode ==
1309 AIPTEK_POINTER_ONLY_MOUSE_MODE) {
1310 retMsg = "Error: receiving stylus reports\n";
1311 } else {
1312 retMsg = "Error: receiving mouse reports\n";
1313 }
1314 break;
1315
1316 default:
1317 return 0;
1318 }
1319 return snprintf(buf, PAGE_SIZE, retMsg);
1320}
1321
1322static DEVICE_ATTR(diagnostic, S_IRUGO, show_tabletDiagnosticMessage, NULL);
1323
1324/***********************************************************************
1325 * support routines for the 'stylus_upper' file. Note that this file
1326 * both displays current setting and allows for setting changing.
1327 */
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001328
1329static struct aiptek_map stylus_button_map[] = {
1330 { "upper", AIPTEK_STYLUS_UPPER_BUTTON },
1331 { "lower", AIPTEK_STYLUS_LOWER_BUTTON },
1332 { NULL, AIPTEK_INVALID_VALUE }
1333};
1334
Yani Ioannou060b8842005-05-17 06:44:04 -04001335static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336{
1337 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001339 return snprintf(buf, PAGE_SIZE, "%s\n",
1340 map_val_to_str(stylus_button_map,
1341 aiptek->curSetting.stylusButtonUpper));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342}
1343
1344static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001345store_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346{
1347 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001348 int new_button = map_str_to_val(stylus_button_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001350 if (new_button == AIPTEK_INVALID_VALUE)
1351 return -EINVAL;
1352
1353 aiptek->newSetting.stylusButtonUpper = new_button;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001354 return count;
1355}
1356
1357static DEVICE_ATTR(stylus_upper,
1358 S_IRUGO | S_IWUGO,
1359 show_tabletStylusUpper, store_tabletStylusUpper);
1360
1361/***********************************************************************
1362 * support routines for the 'stylus_lower' file. Note that this file
1363 * both displays current setting and allows for setting changing.
1364 */
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001365
Yani Ioannou060b8842005-05-17 06:44:04 -04001366static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367{
1368 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001370 return snprintf(buf, PAGE_SIZE, "%s\n",
1371 map_val_to_str(stylus_button_map,
1372 aiptek->curSetting.stylusButtonLower));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373}
1374
1375static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001376store_tabletStylusLower(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377{
1378 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001379 int new_button = map_str_to_val(stylus_button_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001381 if (new_button == AIPTEK_INVALID_VALUE)
1382 return -EINVAL;
1383
1384 aiptek->newSetting.stylusButtonLower = new_button;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 return count;
1386}
1387
1388static DEVICE_ATTR(stylus_lower,
1389 S_IRUGO | S_IWUGO,
1390 show_tabletStylusLower, store_tabletStylusLower);
1391
1392/***********************************************************************
1393 * support routines for the 'mouse_left' file. Note that this file
1394 * both displays current setting and allows for setting changing.
1395 */
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001396
1397static struct aiptek_map mouse_button_map[] = {
1398 { "left", AIPTEK_MOUSE_LEFT_BUTTON },
1399 { "middle", AIPTEK_MOUSE_MIDDLE_BUTTON },
1400 { "right", AIPTEK_MOUSE_RIGHT_BUTTON },
1401 { NULL, AIPTEK_INVALID_VALUE }
1402};
1403
Yani Ioannou060b8842005-05-17 06:44:04 -04001404static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405{
1406 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001408 return snprintf(buf, PAGE_SIZE, "%s\n",
1409 map_val_to_str(mouse_button_map,
1410 aiptek->curSetting.mouseButtonLeft));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411}
1412
1413static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001414store_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001415{
1416 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001417 int new_button = map_str_to_val(mouse_button_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001419 if (new_button == AIPTEK_INVALID_VALUE)
1420 return -EINVAL;
1421
1422 aiptek->newSetting.mouseButtonLeft = new_button;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 return count;
1424}
1425
1426static DEVICE_ATTR(mouse_left,
1427 S_IRUGO | S_IWUGO,
1428 show_tabletMouseLeft, store_tabletMouseLeft);
1429
1430/***********************************************************************
1431 * support routines for the 'mouse_middle' file. Note that this file
1432 * both displays current setting and allows for setting changing.
1433 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001434static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435{
1436 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001438 return snprintf(buf, PAGE_SIZE, "%s\n",
1439 map_val_to_str(mouse_button_map,
1440 aiptek->curSetting.mouseButtonMiddle));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441}
1442
1443static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001444store_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445{
1446 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001447 int new_button = map_str_to_val(mouse_button_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001449 if (new_button == AIPTEK_INVALID_VALUE)
1450 return -EINVAL;
1451
1452 aiptek->newSetting.mouseButtonMiddle = new_button;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 return count;
1454}
1455
1456static DEVICE_ATTR(mouse_middle,
1457 S_IRUGO | S_IWUGO,
1458 show_tabletMouseMiddle, store_tabletMouseMiddle);
1459
1460/***********************************************************************
1461 * support routines for the 'mouse_right' file. Note that this file
1462 * both displays current setting and allows for setting changing.
1463 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001464static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465{
1466 struct aiptek *aiptek = dev_get_drvdata(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001468 return snprintf(buf, PAGE_SIZE, "%s\n",
1469 map_val_to_str(mouse_button_map,
1470 aiptek->curSetting.mouseButtonRight));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471}
1472
1473static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001474store_tabletMouseRight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475{
1476 struct aiptek *aiptek = dev_get_drvdata(dev);
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001477 int new_button = map_str_to_val(mouse_button_map, buf, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478
Dmitry Torokhovcd438a52007-05-21 00:17:57 -04001479 if (new_button == AIPTEK_INVALID_VALUE)
1480 return -EINVAL;
1481
1482 aiptek->newSetting.mouseButtonRight = new_button;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 return count;
1484}
1485
1486static DEVICE_ATTR(mouse_right,
1487 S_IRUGO | S_IWUGO,
1488 show_tabletMouseRight, store_tabletMouseRight);
1489
1490/***********************************************************************
1491 * support routines for the 'wheel' file. Note that this file
1492 * both displays current setting and allows for setting changing.
1493 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001494static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495{
1496 struct aiptek *aiptek = dev_get_drvdata(dev);
1497
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) {
1499 return snprintf(buf, PAGE_SIZE, "disable\n");
1500 } else {
1501 return snprintf(buf, PAGE_SIZE, "%d\n",
1502 aiptek->curSetting.wheel);
1503 }
1504}
1505
1506static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001507store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508{
1509 struct aiptek *aiptek = dev_get_drvdata(dev);
1510
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 aiptek->newSetting.wheel = (int)simple_strtol(buf, NULL, 10);
1512 return count;
1513}
1514
1515static DEVICE_ATTR(wheel,
1516 S_IRUGO | S_IWUGO, show_tabletWheel, store_tabletWheel);
1517
1518/***********************************************************************
1519 * support routines for the 'execute' file. Note that this file
1520 * both displays current setting and allows for setting changing.
1521 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001522static ssize_t show_tabletExecute(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001524 /* There is nothing useful to display, so a one-line manual
1525 * is in order...
1526 */
1527 return snprintf(buf, PAGE_SIZE,
1528 "Write anything to this file to program your tablet.\n");
1529}
1530
1531static ssize_t
Yani Ioannou060b8842005-05-17 06:44:04 -04001532store_tabletExecute(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533{
1534 struct aiptek *aiptek = dev_get_drvdata(dev);
1535
Linus Torvalds1da177e2005-04-16 15:20:36 -07001536 /* We do not care what you write to this file. Merely the action
1537 * of writing to this file triggers a tablet reprogramming.
1538 */
1539 memcpy(&aiptek->curSetting, &aiptek->newSetting,
1540 sizeof(struct aiptek_settings));
1541
1542 if (aiptek_program_tablet(aiptek) < 0)
1543 return -EIO;
1544
1545 return count;
1546}
1547
1548static DEVICE_ATTR(execute,
1549 S_IRUGO | S_IWUGO, show_tabletExecute, store_tabletExecute);
1550
1551/***********************************************************************
1552 * support routines for the 'odm_code' file. Note that this file
1553 * only displays current setting.
1554 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001555static ssize_t show_tabletODMCode(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556{
1557 struct aiptek *aiptek = dev_get_drvdata(dev);
1558
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.odmCode);
1560}
1561
1562static DEVICE_ATTR(odm_code, S_IRUGO, show_tabletODMCode, NULL);
1563
1564/***********************************************************************
1565 * support routines for the 'model_code' file. Note that this file
1566 * only displays current setting.
1567 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001568static ssize_t show_tabletModelCode(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569{
1570 struct aiptek *aiptek = dev_get_drvdata(dev);
1571
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 return snprintf(buf, PAGE_SIZE, "0x%04x\n", aiptek->features.modelCode);
1573}
1574
1575static DEVICE_ATTR(model_code, S_IRUGO, show_tabletModelCode, NULL);
1576
1577/***********************************************************************
1578 * support routines for the 'firmware_code' file. Note that this file
1579 * only displays current setting.
1580 */
Yani Ioannou060b8842005-05-17 06:44:04 -04001581static ssize_t show_firmwareCode(struct device *dev, struct device_attribute *attr, char *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582{
1583 struct aiptek *aiptek = dev_get_drvdata(dev);
1584
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585 return snprintf(buf, PAGE_SIZE, "%04x\n",
1586 aiptek->features.firmwareCode);
1587}
1588
1589static DEVICE_ATTR(firmware_code, S_IRUGO, show_firmwareCode, NULL);
1590
Dmitry Torokhovb087e1f2007-05-21 00:17:37 -04001591static struct attribute *aiptek_attributes[] = {
1592 &dev_attr_size.attr,
1593 &dev_attr_pointer_mode.attr,
1594 &dev_attr_coordinate_mode.attr,
1595 &dev_attr_tool_mode.attr,
1596 &dev_attr_xtilt.attr,
1597 &dev_attr_ytilt.attr,
1598 &dev_attr_jitter.attr,
1599 &dev_attr_delay.attr,
1600 &dev_attr_event_count.attr,
1601 &dev_attr_diagnostic.attr,
1602 &dev_attr_odm_code.attr,
1603 &dev_attr_model_code.attr,
1604 &dev_attr_firmware_code.attr,
1605 &dev_attr_stylus_lower.attr,
1606 &dev_attr_stylus_upper.attr,
1607 &dev_attr_mouse_left.attr,
1608 &dev_attr_mouse_middle.attr,
1609 &dev_attr_mouse_right.attr,
1610 &dev_attr_wheel.attr,
1611 &dev_attr_execute.attr,
1612 NULL
1613};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001614
Dmitry Torokhovb087e1f2007-05-21 00:17:37 -04001615static struct attribute_group aiptek_attribute_group = {
1616 .attrs = aiptek_attributes,
1617};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618
1619/***********************************************************************
1620 * This routine is called when a tablet has been identified. It basically
1621 * sets up the tablet and the driver's internal structures.
1622 */
1623static int
1624aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1625{
1626 struct usb_device *usbdev = interface_to_usbdev(intf);
1627 struct usb_endpoint_descriptor *endpoint;
1628 struct aiptek *aiptek;
1629 struct input_dev *inputdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 int i;
1631 int speeds[] = { 0,
1632 AIPTEK_PROGRAMMABLE_DELAY_50,
1633 AIPTEK_PROGRAMMABLE_DELAY_400,
1634 AIPTEK_PROGRAMMABLE_DELAY_25,
1635 AIPTEK_PROGRAMMABLE_DELAY_100,
1636 AIPTEK_PROGRAMMABLE_DELAY_200,
1637 AIPTEK_PROGRAMMABLE_DELAY_300
1638 };
Dmitry Torokhov50141862007-04-12 01:33:39 -04001639 int err = -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640
1641 /* programmableDelay is where the command-line specified
1642 * delay is kept. We make it the first element of speeds[],
1643 * so therefore, your override speed is tried first, then the
1644 * remainder. Note that the default value of 400ms will be tried
1645 * if you do not specify any command line parameter.
1646 */
1647 speeds[0] = programmableDelay;
1648
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001649 aiptek = kzalloc(sizeof(struct aiptek), GFP_KERNEL);
1650 inputdev = input_allocate_device();
1651 if (!aiptek || !inputdev)
1652 goto fail1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653
1654 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
Christoph Lameter54e6ecb2006-12-06 20:33:16 -08001655 GFP_ATOMIC, &aiptek->data_dma);
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001656 if (!aiptek->data)
1657 goto fail1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658
1659 aiptek->urb = usb_alloc_urb(0, GFP_KERNEL);
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001660 if (!aiptek->urb)
1661 goto fail2;
1662
1663 aiptek->inputdev = inputdev;
1664 aiptek->usbdev = usbdev;
1665 aiptek->ifnum = intf->altsetting[0].desc.bInterfaceNumber;
1666 aiptek->inDelay = 0;
1667 aiptek->endDelay = 0;
1668 aiptek->previousJitterable = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669
1670 /* Set up the curSettings struct. Said struct contains the current
1671 * programmable parameters. The newSetting struct contains changes
1672 * the user makes to the settings via the sysfs interface. Those
1673 * changes are not "committed" to curSettings until the user
1674 * writes to the sysfs/.../execute file.
1675 */
1676 aiptek->curSetting.pointerMode = AIPTEK_POINTER_EITHER_MODE;
1677 aiptek->curSetting.coordinateMode = AIPTEK_COORDINATE_ABSOLUTE_MODE;
1678 aiptek->curSetting.toolMode = AIPTEK_TOOL_BUTTON_PEN_MODE;
1679 aiptek->curSetting.xTilt = AIPTEK_TILT_DISABLE;
1680 aiptek->curSetting.yTilt = AIPTEK_TILT_DISABLE;
1681 aiptek->curSetting.mouseButtonLeft = AIPTEK_MOUSE_LEFT_BUTTON;
1682 aiptek->curSetting.mouseButtonMiddle = AIPTEK_MOUSE_MIDDLE_BUTTON;
1683 aiptek->curSetting.mouseButtonRight = AIPTEK_MOUSE_RIGHT_BUTTON;
1684 aiptek->curSetting.stylusButtonUpper = AIPTEK_STYLUS_UPPER_BUTTON;
1685 aiptek->curSetting.stylusButtonLower = AIPTEK_STYLUS_LOWER_BUTTON;
1686 aiptek->curSetting.jitterDelay = jitterDelay;
1687 aiptek->curSetting.programmableDelay = programmableDelay;
1688
1689 /* Both structs should have equivalent settings
1690 */
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001691 aiptek->newSetting = aiptek->curSetting;
1692
1693 /* Determine the usb devices' physical path.
1694 * Asketh not why we always pretend we're using "../input0",
1695 * but I suspect this will have to be refactored one
1696 * day if a single USB device can be a keyboard & a mouse
1697 * & a tablet, and the inputX number actually will tell
1698 * us something...
1699 */
1700 usb_make_path(usbdev, aiptek->features.usbPath,
1701 sizeof(aiptek->features.usbPath));
1702 strlcat(aiptek->features.usbPath, "/input0",
1703 sizeof(aiptek->features.usbPath));
1704
1705 /* Set up client data, pointers to open and close routines
1706 * for the input device.
1707 */
1708 inputdev->name = "Aiptek";
1709 inputdev->phys = aiptek->features.usbPath;
1710 usb_to_input_id(usbdev, &inputdev->id);
Dmitry Torokhovc0f82d52007-04-12 01:35:03 -04001711 inputdev->dev.parent = &intf->dev;
Dmitry Torokhov7791bda2007-04-12 01:34:39 -04001712
1713 input_set_drvdata(inputdev, aiptek);
1714
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001715 inputdev->open = aiptek_open;
1716 inputdev->close = aiptek_close;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717
1718 /* Now program the capacities of the tablet, in terms of being
1719 * an input device.
1720 */
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001721 inputdev->evbit[0] |= BIT(EV_KEY)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 | BIT(EV_ABS)
1723 | BIT(EV_REL)
1724 | BIT(EV_MSC);
1725
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001726 inputdev->absbit[0] |= BIT(ABS_MISC);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001728 inputdev->relbit[0] |=
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 (BIT(REL_X) | BIT(REL_Y) | BIT(REL_WHEEL) | BIT(REL_MISC));
1730
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001731 inputdev->keybit[LONG(BTN_LEFT)] |=
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732 (BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE));
1733
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001734 inputdev->keybit[LONG(BTN_DIGI)] |=
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 (BIT(BTN_TOOL_PEN) |
1736 BIT(BTN_TOOL_RUBBER) |
1737 BIT(BTN_TOOL_PENCIL) |
1738 BIT(BTN_TOOL_AIRBRUSH) |
1739 BIT(BTN_TOOL_BRUSH) |
1740 BIT(BTN_TOOL_MOUSE) |
1741 BIT(BTN_TOOL_LENS) |
1742 BIT(BTN_TOUCH) | BIT(BTN_STYLUS) | BIT(BTN_STYLUS2));
1743
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001744 inputdev->mscbit[0] = BIT(MSC_SERIAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745
1746 /* Programming the tablet macro keys needs to be done with a for loop
1747 * as the keycodes are discontiguous.
1748 */
Tobias Klauser52950ed2005-12-11 16:20:08 +01001749 for (i = 0; i < ARRAY_SIZE(macroKeyEvents); ++i)
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001750 set_bit(macroKeyEvents[i], inputdev->keybit);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001752 /*
1753 * Program the input device coordinate capacities. We do not yet
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 * know what maximum X, Y, and Z values are, so we're putting fake
1755 * values in. Later, we'll ask the tablet to put in the correct
1756 * values.
1757 */
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001758 input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0);
Riccardo Magliocchettif873e3e2005-12-28 20:44:48 -05001759 input_set_abs_params(inputdev, ABS_Y, 0, 2249, 0, 0);
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001760 input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0);
1761 input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);
1762 input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);
1763 input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764
1765 endpoint = &intf->altsetting[0].endpoint[0].desc;
1766
1767 /* Go set up our URB, which is called when the tablet receives
1768 * input.
1769 */
1770 usb_fill_int_urb(aiptek->urb,
1771 aiptek->usbdev,
1772 usb_rcvintpipe(aiptek->usbdev,
1773 endpoint->bEndpointAddress),
1774 aiptek->data, 8, aiptek_irq, aiptek,
1775 endpoint->bInterval);
1776
1777 aiptek->urb->transfer_dma = aiptek->data_dma;
1778 aiptek->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1779
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780 /* Program the tablet. This sets the tablet up in the mode
1781 * specified in newSetting, and also queries the tablet's
1782 * physical capacities.
1783 *
1784 * Sanity check: if a tablet doesn't like the slow programmatic
1785 * delay, we often get sizes of 0x0. Let's use that as an indicator
1786 * to try faster delays, up to 25 ms. If that logic fails, well, you'll
1787 * have to explain to us how your tablet thinks it's 0x0, and yet that's
1788 * not an error :-)
1789 */
1790
Tobias Klauser52950ed2005-12-11 16:20:08 +01001791 for (i = 0; i < ARRAY_SIZE(speeds); ++i) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001792 aiptek->curSetting.programmableDelay = speeds[i];
1793 (void)aiptek_program_tablet(aiptek);
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001794 if (aiptek->inputdev->absmax[ABS_X] > 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795 info("input: Aiptek using %d ms programming speed\n",
1796 aiptek->curSetting.programmableDelay);
1797 break;
1798 }
1799 }
1800
1801 /* Associate this driver's struct with the usb interface.
1802 */
1803 usb_set_intfdata(intf, aiptek);
1804
1805 /* Set up the sysfs files
1806 */
Dmitry Torokhovb087e1f2007-05-21 00:17:37 -04001807 err = sysfs_create_group(&intf->dev.kobj, &aiptek_attribute_group);
1808 if (err)
1809 goto fail3;
1810
1811 /* Register the tablet as an Input Device
1812 */
1813 err = input_register_device(aiptek->inputdev);
1814 if (err)
1815 goto fail4;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001816
Linus Torvalds1da177e2005-04-16 15:20:36 -07001817 return 0;
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001818
Dmitry Torokhovb087e1f2007-05-21 00:17:37 -04001819 fail4: sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
1820 fail3: usb_free_urb(aiptek->urb);
Dmitry Torokhov50141862007-04-12 01:33:39 -04001821 fail2: usb_buffer_free(usbdev, AIPTEK_PACKET_LENGTH, aiptek->data,
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001822 aiptek->data_dma);
Dmitry Torokhovb087e1f2007-05-21 00:17:37 -04001823 fail1: usb_set_intfdata(intf, NULL);
1824 input_free_device(inputdev);
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001825 kfree(aiptek);
Dmitry Torokhov50141862007-04-12 01:33:39 -04001826 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001827}
1828
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829/***********************************************************************
1830 * Deal with tablet disconnecting from the system.
1831 */
1832static void aiptek_disconnect(struct usb_interface *intf)
1833{
1834 struct aiptek *aiptek = usb_get_intfdata(intf);
1835
1836 /* Disassociate driver's struct with usb interface
1837 */
1838 usb_set_intfdata(intf, NULL);
1839 if (aiptek != NULL) {
1840 /* Free & unhook everything from the system.
1841 */
1842 usb_kill_urb(aiptek->urb);
Dmitry Torokhovc5b7c7c2005-09-15 02:01:47 -05001843 input_unregister_device(aiptek->inputdev);
Dmitry Torokhovb087e1f2007-05-21 00:17:37 -04001844 sysfs_remove_group(&intf->dev.kobj, &aiptek_attribute_group);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845 usb_free_urb(aiptek->urb);
1846 usb_buffer_free(interface_to_usbdev(intf),
1847 AIPTEK_PACKET_LENGTH,
1848 aiptek->data, aiptek->data_dma);
1849 kfree(aiptek);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850 }
1851}
1852
Dmitry Torokhov50141862007-04-12 01:33:39 -04001853static struct usb_driver aiptek_driver = {
1854 .name = "aiptek",
1855 .probe = aiptek_probe,
1856 .disconnect = aiptek_disconnect,
1857 .id_table = aiptek_ids,
1858};
1859
Linus Torvalds1da177e2005-04-16 15:20:36 -07001860static int __init aiptek_init(void)
1861{
1862 int result = usb_register(&aiptek_driver);
1863 if (result == 0) {
1864 info(DRIVER_VERSION ": " DRIVER_AUTHOR);
1865 info(DRIVER_DESC);
1866 }
1867 return result;
1868}
1869
1870static void __exit aiptek_exit(void)
1871{
1872 usb_deregister(&aiptek_driver);
1873}
1874
1875MODULE_AUTHOR(DRIVER_AUTHOR);
1876MODULE_DESCRIPTION(DRIVER_DESC);
1877MODULE_LICENSE("GPL");
1878
1879module_param(programmableDelay, int, 0);
1880MODULE_PARM_DESC(programmableDelay, "delay used during tablet programming");
1881module_param(jitterDelay, int, 0);
1882MODULE_PARM_DESC(jitterDelay, "stylus/mouse settlement delay");
1883
1884module_init(aiptek_init);
1885module_exit(aiptek_exit);