diff options
author | Stelian Pop <stelian@popies.net> | 2008-10-28 23:20:46 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-29 00:28:30 -0400 |
commit | 09779678d12482024e06380cacc4c3ff2f129f23 (patch) | |
tree | 92908b3da994e9d19b707c657bda431dcf0c1375 /drivers | |
parent | b67b4b117746aef686e527c3205792db0f2c9e16 (diff) |
Input: appletouch - driver refactoring
The appletouch driver has grown up from supporting only a couple of
touchpads into supporting many touchpads, which can have different
number of sensors, different aspect ratios etc.
This patch cleans up the current driver code and makes it easy to
support the features of each different touchpad.
As a side effect, this patch also modifies the 'Y' multiplication factor
of the 'geyser3' and 'geyser4' touchpads (found on Core Duo and Core2
Duo MacBook and MacBook Pro laptops) in order to make the touchpad
output match the aspect ratio of the touchpad (Y factor changed from 43
to 64).
[dtor@mail.ru: make atp_info constant]
Signed-off-by: Stelian Pop <stelian@popies.net>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/mouse/appletouch.c | 274 |
1 files changed, 136 insertions, 138 deletions
diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c index 079816e6b23b..454b96112f03 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) | 4 | * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) |
5 | * Copyright (C) 2005-2008 Johannes Berg (johannes@sipsolutions.net) | 5 | * Copyright (C) 2005-2008 Johannes Berg (johannes@sipsolutions.net) |
6 | * Copyright (C) 2005 Stelian Pop (stelian@popies.net) | 6 | * Copyright (C) 2005-2008 Stelian Pop (stelian@popies.net) |
7 | * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) | 7 | * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) |
8 | * Copyright (C) 2005 Peter Osterlund (petero2@telia.com) | 8 | * Copyright (C) 2005 Peter Osterlund (petero2@telia.com) |
9 | * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) | 9 | * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) |
@@ -35,16 +35,74 @@ | |||
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/usb/input.h> | 36 | #include <linux/usb/input.h> |
37 | 37 | ||
38 | /* Type of touchpad */ | 38 | /* |
39 | enum atp_touchpad_type { | 39 | * Note: We try to keep the touchpad aspect ratio while still doing only |
40 | ATP_FOUNTAIN, | 40 | * simple arithmetics: |
41 | ATP_GEYSER1, | 41 | * 0 <= x <= (xsensors - 1) * xfact |
42 | ATP_GEYSER2, | 42 | * 0 <= y <= (ysensors - 1) * yfact |
43 | ATP_GEYSER3, | 43 | */ |
44 | ATP_GEYSER4 | 44 | struct atp_info { |
45 | int xsensors; /* number of X sensors */ | ||
46 | int xsensors_17; /* 17" models have more sensors */ | ||
47 | int ysensors; /* number of Y sensors */ | ||
48 | int xfact; /* X multiplication factor */ | ||
49 | int yfact; /* Y multiplication factor */ | ||
50 | int datalen; /* size of USB transfers */ | ||
51 | void (*callback)(struct urb *); /* callback function */ | ||
52 | }; | ||
53 | |||
54 | static void atp_complete_geyser_1_2(struct urb *urb); | ||
55 | static void atp_complete_geyser_3_4(struct urb *urb); | ||
56 | |||
57 | static const struct atp_info fountain_info = { | ||
58 | .xsensors = 16, | ||
59 | .xsensors_17 = 26, | ||
60 | .ysensors = 16, | ||
61 | .xfact = 64, | ||
62 | .yfact = 43, | ||
63 | .datalen = 81, | ||
64 | .callback = atp_complete_geyser_1_2, | ||
65 | }; | ||
66 | |||
67 | static const struct atp_info geyser1_info = { | ||
68 | .xsensors = 16, | ||
69 | .xsensors_17 = 26, | ||
70 | .ysensors = 16, | ||
71 | .xfact = 64, | ||
72 | .yfact = 43, | ||
73 | .datalen = 81, | ||
74 | .callback = atp_complete_geyser_1_2, | ||
75 | }; | ||
76 | |||
77 | static const struct atp_info geyser2_info = { | ||
78 | .xsensors = 15, | ||
79 | .xsensors_17 = 20, | ||
80 | .ysensors = 9, | ||
81 | .xfact = 64, | ||
82 | .yfact = 43, | ||
83 | .datalen = 64, | ||
84 | .callback = atp_complete_geyser_1_2, | ||
85 | }; | ||
86 | |||
87 | static const struct atp_info geyser3_info = { | ||
88 | .xsensors = 20, | ||
89 | .ysensors = 10, | ||
90 | .xfact = 64, | ||
91 | .yfact = 64, | ||
92 | .datalen = 64, | ||
93 | .callback = atp_complete_geyser_3_4, | ||
45 | }; | 94 | }; |
46 | 95 | ||
47 | #define ATP_DEVICE(prod, type) \ | 96 | static const struct atp_info geyser4_info = { |
97 | .xsensors = 20, | ||
98 | .ysensors = 10, | ||
99 | .xfact = 64, | ||
100 | .yfact = 64, | ||
101 | .datalen = 64, | ||
102 | .callback = atp_complete_geyser_3_4, | ||
103 | }; | ||
104 | |||
105 | #define ATP_DEVICE(prod, info) \ | ||
48 | { \ | 106 | { \ |
49 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ | 107 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ |
50 | USB_DEVICE_ID_MATCH_INT_CLASS | \ | 108 | USB_DEVICE_ID_MATCH_INT_CLASS | \ |
@@ -53,7 +111,7 @@ enum atp_touchpad_type { | |||
53 | .idProduct = (prod), \ | 111 | .idProduct = (prod), \ |
54 | .bInterfaceClass = 0x03, \ | 112 | .bInterfaceClass = 0x03, \ |
55 | .bInterfaceProtocol = 0x02, \ | 113 | .bInterfaceProtocol = 0x02, \ |
56 | .driver_info = ATP_ ## type, \ | 114 | .driver_info = (unsigned long) &info, \ |
57 | } | 115 | } |
58 | 116 | ||
59 | /* | 117 | /* |
@@ -62,43 +120,39 @@ enum atp_touchpad_type { | |||
62 | * According to Info.plist Geyser IV is the same as Geyser III.) | 120 | * According to Info.plist Geyser IV is the same as Geyser III.) |
63 | */ | 121 | */ |
64 | 122 | ||
65 | static struct usb_device_id atp_table [] = { | 123 | static struct usb_device_id atp_table[] = { |
66 | /* PowerBooks Feb 2005, iBooks G4 */ | 124 | /* PowerBooks Feb 2005, iBooks G4 */ |
67 | ATP_DEVICE(0x020e, FOUNTAIN), /* FOUNTAIN ANSI */ | 125 | ATP_DEVICE(0x020e, fountain_info), /* FOUNTAIN ANSI */ |
68 | ATP_DEVICE(0x020f, FOUNTAIN), /* FOUNTAIN ISO */ | 126 | ATP_DEVICE(0x020f, fountain_info), /* FOUNTAIN ISO */ |
69 | ATP_DEVICE(0x030a, FOUNTAIN), /* FOUNTAIN TP ONLY */ | 127 | ATP_DEVICE(0x030a, fountain_info), /* FOUNTAIN TP ONLY */ |
70 | ATP_DEVICE(0x030b, GEYSER1), /* GEYSER 1 TP ONLY */ | 128 | ATP_DEVICE(0x030b, geyser1_info), /* GEYSER 1 TP ONLY */ |
71 | 129 | ||
72 | /* PowerBooks Oct 2005 */ | 130 | /* PowerBooks Oct 2005 */ |
73 | ATP_DEVICE(0x0214, GEYSER2), /* GEYSER 2 ANSI */ | 131 | ATP_DEVICE(0x0214, geyser2_info), /* GEYSER 2 ANSI */ |
74 | ATP_DEVICE(0x0215, GEYSER2), /* GEYSER 2 ISO */ | 132 | ATP_DEVICE(0x0215, geyser2_info), /* GEYSER 2 ISO */ |
75 | ATP_DEVICE(0x0216, GEYSER2), /* GEYSER 2 JIS */ | 133 | ATP_DEVICE(0x0216, geyser2_info), /* GEYSER 2 JIS */ |
76 | 134 | ||
77 | /* Core Duo MacBook & MacBook Pro */ | 135 | /* Core Duo MacBook & MacBook Pro */ |
78 | ATP_DEVICE(0x0217, GEYSER3), /* GEYSER 3 ANSI */ | 136 | ATP_DEVICE(0x0217, geyser3_info), /* GEYSER 3 ANSI */ |
79 | ATP_DEVICE(0x0218, GEYSER3), /* GEYSER 3 ISO */ | 137 | ATP_DEVICE(0x0218, geyser3_info), /* GEYSER 3 ISO */ |
80 | ATP_DEVICE(0x0219, GEYSER3), /* GEYSER 3 JIS */ | 138 | ATP_DEVICE(0x0219, geyser3_info), /* GEYSER 3 JIS */ |
81 | 139 | ||
82 | /* Core2 Duo MacBook & MacBook Pro */ | 140 | /* Core2 Duo MacBook & MacBook Pro */ |
83 | ATP_DEVICE(0x021a, GEYSER4), /* GEYSER 4 ANSI */ | 141 | ATP_DEVICE(0x021a, geyser4_info), /* GEYSER 4 ANSI */ |
84 | ATP_DEVICE(0x021b, GEYSER4), /* GEYSER 4 ISO */ | 142 | ATP_DEVICE(0x021b, geyser4_info), /* GEYSER 4 ISO */ |
85 | ATP_DEVICE(0x021c, GEYSER4), /* GEYSER 4 JIS */ | 143 | ATP_DEVICE(0x021c, geyser4_info), /* GEYSER 4 JIS */ |
86 | 144 | ||
87 | /* Core2 Duo MacBook3,1 */ | 145 | /* Core2 Duo MacBook3,1 */ |
88 | ATP_DEVICE(0x0229, GEYSER4), /* GEYSER 4 HF ANSI */ | 146 | ATP_DEVICE(0x0229, geyser4_info), /* GEYSER 4 HF ANSI */ |
89 | ATP_DEVICE(0x022a, GEYSER4), /* GEYSER 4 HF ISO */ | 147 | ATP_DEVICE(0x022a, geyser4_info), /* GEYSER 4 HF ISO */ |
90 | ATP_DEVICE(0x022b, GEYSER4), /* GEYSER 4 HF JIS */ | 148 | ATP_DEVICE(0x022b, geyser4_info), /* GEYSER 4 HF JIS */ |
91 | 149 | ||
92 | /* Terminating entry */ | 150 | /* Terminating entry */ |
93 | { } | 151 | { } |
94 | }; | 152 | }; |
95 | MODULE_DEVICE_TABLE(usb, atp_table); | 153 | MODULE_DEVICE_TABLE(usb, atp_table); |
96 | 154 | ||
97 | /* | 155 | /* maximum number of sensors */ |
98 | * number of sensors. Note that only 16 instead of 26 X (horizontal) | ||
99 | * sensors exist on 12" and 15" PowerBooks. All models have 16 Y | ||
100 | * (vertical) sensors. | ||
101 | */ | ||
102 | #define ATP_XSENSORS 26 | 156 | #define ATP_XSENSORS 26 |
103 | #define ATP_YSENSORS 16 | 157 | #define ATP_YSENSORS 16 |
104 | 158 | ||
@@ -107,21 +161,6 @@ MODULE_DEVICE_TABLE(usb, atp_table); | |||
107 | 161 | ||
108 | /* maximum pressure this driver will report */ | 162 | /* maximum pressure this driver will report */ |
109 | #define ATP_PRESSURE 300 | 163 | #define ATP_PRESSURE 300 |
110 | /* | ||
111 | * multiplication factor for the X and Y coordinates. | ||
112 | * We try to keep the touchpad aspect ratio while still doing only simple | ||
113 | * arithmetics. | ||
114 | * The factors below give coordinates like: | ||
115 | * | ||
116 | * 0 <= x < 960 on 12" and 15" Powerbooks | ||
117 | * 0 <= x < 1600 on 17" Powerbooks and 17" MacBook Pro | ||
118 | * 0 <= x < 1216 on MacBooks and 15" MacBook Pro | ||
119 | * | ||
120 | * 0 <= y < 646 on all Powerbooks | ||
121 | * 0 <= y < 774 on all MacBooks | ||
122 | */ | ||
123 | #define ATP_XFACT 64 | ||
124 | #define ATP_YFACT 43 | ||
125 | 164 | ||
126 | /* | 165 | /* |
127 | * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is | 166 | * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is |
@@ -159,7 +198,7 @@ struct atp { | |||
159 | struct urb *urb; /* usb request block */ | 198 | struct urb *urb; /* usb request block */ |
160 | u8 *data; /* transferred data */ | 199 | u8 *data; /* transferred data */ |
161 | struct input_dev *input; /* input dev */ | 200 | struct input_dev *input; /* input dev */ |
162 | enum atp_touchpad_type type; /* type of touchpad */ | 201 | const struct atp_info *info; /* touchpad model */ |
163 | bool open; | 202 | bool open; |
164 | bool valid; /* are the samples valid? */ | 203 | bool valid; /* are the samples valid? */ |
165 | bool size_detect_done; | 204 | bool size_detect_done; |
@@ -169,7 +208,6 @@ struct atp { | |||
169 | signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; | 208 | signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS]; |
170 | signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; | 209 | signed char xy_old[ATP_XSENSORS + ATP_YSENSORS]; |
171 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; | 210 | int xy_acc[ATP_XSENSORS + ATP_YSENSORS]; |
172 | int datalen; /* size of USB transfer */ | ||
173 | int idlecount; /* number of empty packets */ | 211 | int idlecount; /* number of empty packets */ |
174 | struct work_struct work; | 212 | struct work_struct work; |
175 | }; | 213 | }; |
@@ -359,7 +397,7 @@ static int atp_status_check(struct urb *urb) | |||
359 | if (!dev->overflow_warned) { | 397 | if (!dev->overflow_warned) { |
360 | printk(KERN_WARNING "appletouch: OVERFLOW with data " | 398 | printk(KERN_WARNING "appletouch: OVERFLOW with data " |
361 | "length %d, actual length is %d\n", | 399 | "length %d, actual length is %d\n", |
362 | dev->datalen, dev->urb->actual_length); | 400 | dev->info->datalen, dev->urb->actual_length); |
363 | dev->overflow_warned = true; | 401 | dev->overflow_warned = true; |
364 | } | 402 | } |
365 | case -ECONNRESET: | 403 | case -ECONNRESET: |
@@ -377,7 +415,7 @@ static int atp_status_check(struct urb *urb) | |||
377 | } | 415 | } |
378 | 416 | ||
379 | /* drop incomplete datasets */ | 417 | /* drop incomplete datasets */ |
380 | if (dev->urb->actual_length != dev->datalen) { | 418 | if (dev->urb->actual_length != dev->info->datalen) { |
381 | dprintk("appletouch: incomplete data package" | 419 | dprintk("appletouch: incomplete data package" |
382 | " (first byte: %d, length: %d).\n", | 420 | " (first byte: %d, length: %d).\n", |
383 | dev->data[0], dev->urb->actual_length); | 421 | dev->data[0], dev->urb->actual_length); |
@@ -387,6 +425,25 @@ static int atp_status_check(struct urb *urb) | |||
387 | return ATP_URB_STATUS_SUCCESS; | 425 | return ATP_URB_STATUS_SUCCESS; |
388 | } | 426 | } |
389 | 427 | ||
428 | static void atp_detect_size(struct atp *dev) | ||
429 | { | ||
430 | int i; | ||
431 | |||
432 | /* 17" Powerbooks have extra X sensors */ | ||
433 | for (i = dev->info->xsensors; i < ATP_XSENSORS; i++) { | ||
434 | if (dev->xy_cur[i]) { | ||
435 | |||
436 | printk(KERN_INFO "appletouch: 17\" model detected.\n"); | ||
437 | |||
438 | input_set_abs_params(dev->input, ABS_X, 0, | ||
439 | (dev->info->xsensors_17 - 1) * | ||
440 | dev->info->xfact - 1, | ||
441 | ATP_FUZZ, 0); | ||
442 | break; | ||
443 | } | ||
444 | } | ||
445 | } | ||
446 | |||
390 | /* | 447 | /* |
391 | * USB interrupt callback functions | 448 | * USB interrupt callback functions |
392 | */ | 449 | */ |
@@ -407,7 +464,7 @@ static void atp_complete_geyser_1_2(struct urb *urb) | |||
407 | goto exit; | 464 | goto exit; |
408 | 465 | ||
409 | /* reorder the sensors values */ | 466 | /* reorder the sensors values */ |
410 | if (dev->type == ATP_GEYSER2) { | 467 | if (dev->info == &geyser2_info) { |
411 | memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); | 468 | memset(dev->xy_cur, 0, sizeof(dev->xy_cur)); |
412 | 469 | ||
413 | /* | 470 | /* |
@@ -437,8 +494,8 @@ static void atp_complete_geyser_1_2(struct urb *urb) | |||
437 | dev->xy_cur[i + 24] = dev->data[5 * i + 44]; | 494 | dev->xy_cur[i + 24] = dev->data[5 * i + 44]; |
438 | 495 | ||
439 | /* Y values */ | 496 | /* Y values */ |
440 | dev->xy_cur[i + 26] = dev->data[5 * i + 1]; | 497 | dev->xy_cur[ATP_XSENSORS + i] = dev->data[5 * i + 1]; |
441 | dev->xy_cur[i + 34] = dev->data[5 * i + 3]; | 498 | dev->xy_cur[ATP_XSENSORS + i + 8] = dev->data[5 * i + 3]; |
442 | } | 499 | } |
443 | } | 500 | } |
444 | 501 | ||
@@ -453,32 +510,8 @@ static void atp_complete_geyser_1_2(struct urb *urb) | |||
453 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); | 510 | memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old)); |
454 | 511 | ||
455 | /* Perform size detection, if not done already */ | 512 | /* Perform size detection, if not done already */ |
456 | if (!dev->size_detect_done) { | 513 | if (unlikely(!dev->size_detect_done)) { |
457 | 514 | atp_detect_size(dev); | |
458 | /* 17" Powerbooks have extra X sensors */ | ||
459 | for (i = (dev->type == ATP_GEYSER2 ? 15 : 16); | ||
460 | i < ATP_XSENSORS; i++) { | ||
461 | if (!dev->xy_cur[i]) | ||
462 | continue; | ||
463 | |||
464 | printk(KERN_INFO | ||
465 | "appletouch: 17\" model detected.\n"); | ||
466 | |||
467 | if (dev->type == ATP_GEYSER2) | ||
468 | input_set_abs_params(dev->input, ABS_X, | ||
469 | 0, | ||
470 | (20 - 1) * | ||
471 | ATP_XFACT - 1, | ||
472 | ATP_FUZZ, 0); | ||
473 | else | ||
474 | input_set_abs_params(dev->input, ABS_X, | ||
475 | 0, | ||
476 | (26 - 1) * | ||
477 | ATP_XFACT - 1, | ||
478 | ATP_FUZZ, 0); | ||
479 | break; | ||
480 | } | ||
481 | |||
482 | dev->size_detect_done = 1; | 515 | dev->size_detect_done = 1; |
483 | goto exit; | 516 | goto exit; |
484 | } | 517 | } |
@@ -499,10 +532,10 @@ static void atp_complete_geyser_1_2(struct urb *urb) | |||
499 | dbg_dump("accumulator", dev->xy_acc); | 532 | dbg_dump("accumulator", dev->xy_acc); |
500 | 533 | ||
501 | x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, | 534 | x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, |
502 | ATP_XFACT, &x_z, &x_f); | 535 | dev->info->xfact, &x_z, &x_f); |
503 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, | 536 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, |
504 | ATP_YFACT, &y_z, &y_f); | 537 | dev->info->yfact, &y_z, &y_f); |
505 | key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON; | 538 | key = dev->data[dev->info->datalen - 1] & ATP_STATUS_BUTTON; |
506 | 539 | ||
507 | if (x && y) { | 540 | if (x && y) { |
508 | if (dev->x_old != -1) { | 541 | if (dev->x_old != -1) { |
@@ -583,7 +616,7 @@ static void atp_complete_geyser_3_4(struct urb *urb) | |||
583 | dbg_dump("sample", dev->xy_cur); | 616 | dbg_dump("sample", dev->xy_cur); |
584 | 617 | ||
585 | /* Just update the base values (i.e. touchpad in untouched state) */ | 618 | /* Just update the base values (i.e. touchpad in untouched state) */ |
586 | if (dev->data[dev->datalen - 1] & ATP_STATUS_BASE_UPDATE) { | 619 | if (dev->data[dev->info->datalen - 1] & ATP_STATUS_BASE_UPDATE) { |
587 | 620 | ||
588 | dprintk(KERN_DEBUG "appletouch: updated base values\n"); | 621 | dprintk(KERN_DEBUG "appletouch: updated base values\n"); |
589 | 622 | ||
@@ -610,10 +643,10 @@ static void atp_complete_geyser_3_4(struct urb *urb) | |||
610 | dbg_dump("accumulator", dev->xy_acc); | 643 | dbg_dump("accumulator", dev->xy_acc); |
611 | 644 | ||
612 | x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, | 645 | x = atp_calculate_abs(dev->xy_acc, ATP_XSENSORS, |
613 | ATP_XFACT, &x_z, &x_f); | 646 | dev->info->xfact, &x_z, &x_f); |
614 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, | 647 | y = atp_calculate_abs(dev->xy_acc + ATP_XSENSORS, ATP_YSENSORS, |
615 | ATP_YFACT, &y_z, &y_f); | 648 | dev->info->yfact, &y_z, &y_f); |
616 | key = dev->data[dev->datalen - 1] & ATP_STATUS_BUTTON; | 649 | key = dev->data[dev->info->datalen - 1] & ATP_STATUS_BUTTON; |
617 | 650 | ||
618 | if (x && y) { | 651 | if (x && y) { |
619 | if (dev->x_old != -1) { | 652 | if (dev->x_old != -1) { |
@@ -705,7 +738,7 @@ static int atp_handle_geyser(struct atp *dev) | |||
705 | { | 738 | { |
706 | struct usb_device *udev = dev->udev; | 739 | struct usb_device *udev = dev->udev; |
707 | 740 | ||
708 | if (dev->type != ATP_FOUNTAIN) { | 741 | if (dev->info != &fountain_info) { |
709 | /* switch to raw sensor mode */ | 742 | /* switch to raw sensor mode */ |
710 | if (atp_geyser_init(udev)) | 743 | if (atp_geyser_init(udev)) |
711 | return -EIO; | 744 | return -EIO; |
@@ -726,6 +759,7 @@ static int atp_probe(struct usb_interface *iface, | |||
726 | struct usb_endpoint_descriptor *endpoint; | 759 | struct usb_endpoint_descriptor *endpoint; |
727 | int int_in_endpointAddr = 0; | 760 | int int_in_endpointAddr = 0; |
728 | int i, error = -ENOMEM; | 761 | int i, error = -ENOMEM; |
762 | const struct atp_info *info = (const struct atp_info *)id->driver_info; | ||
729 | 763 | ||
730 | /* set up the endpoint information */ | 764 | /* set up the endpoint information */ |
731 | /* use only the first interrupt-in endpoint */ | 765 | /* use only the first interrupt-in endpoint */ |
@@ -753,35 +787,22 @@ static int atp_probe(struct usb_interface *iface, | |||
753 | 787 | ||
754 | dev->udev = udev; | 788 | dev->udev = udev; |
755 | dev->input = input_dev; | 789 | dev->input = input_dev; |
756 | dev->type = id->driver_info; | 790 | dev->info = info; |
757 | dev->overflow_warned = false; | 791 | dev->overflow_warned = false; |
758 | if (dev->type == ATP_FOUNTAIN || dev->type == ATP_GEYSER1) | ||
759 | dev->datalen = 81; | ||
760 | else | ||
761 | dev->datalen = 64; | ||
762 | 792 | ||
763 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); | 793 | dev->urb = usb_alloc_urb(0, GFP_KERNEL); |
764 | if (!dev->urb) | 794 | if (!dev->urb) |
765 | goto err_free_devs; | 795 | goto err_free_devs; |
766 | 796 | ||
767 | dev->data = usb_buffer_alloc(dev->udev, dev->datalen, GFP_KERNEL, | 797 | dev->data = usb_buffer_alloc(dev->udev, dev->info->datalen, GFP_KERNEL, |
768 | &dev->urb->transfer_dma); | 798 | &dev->urb->transfer_dma); |
769 | if (!dev->data) | 799 | if (!dev->data) |
770 | goto err_free_urb; | 800 | goto err_free_urb; |
771 | 801 | ||
772 | /* Select the USB complete (callback) function */ | 802 | usb_fill_int_urb(dev->urb, udev, |
773 | if (dev->type == ATP_FOUNTAIN || | 803 | usb_rcvintpipe(udev, int_in_endpointAddr), |
774 | dev->type == ATP_GEYSER1 || | 804 | dev->data, dev->info->datalen, |
775 | dev->type == ATP_GEYSER2) | 805 | dev->info->callback, dev, 1); |
776 | usb_fill_int_urb(dev->urb, udev, | ||
777 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
778 | dev->data, dev->datalen, | ||
779 | atp_complete_geyser_1_2, dev, 1); | ||
780 | else | ||
781 | usb_fill_int_urb(dev->urb, udev, | ||
782 | usb_rcvintpipe(udev, int_in_endpointAddr), | ||
783 | dev->data, dev->datalen, | ||
784 | atp_complete_geyser_3_4, dev, 1); | ||
785 | 806 | ||
786 | error = atp_handle_geyser(dev); | 807 | error = atp_handle_geyser(dev); |
787 | if (error) | 808 | if (error) |
@@ -802,35 +823,12 @@ static int atp_probe(struct usb_interface *iface, | |||
802 | 823 | ||
803 | set_bit(EV_ABS, input_dev->evbit); | 824 | set_bit(EV_ABS, input_dev->evbit); |
804 | 825 | ||
805 | if (dev->type == ATP_GEYSER3 || dev->type == ATP_GEYSER4) { | 826 | input_set_abs_params(input_dev, ABS_X, 0, |
806 | /* | 827 | (dev->info->xsensors - 1) * dev->info->xfact - 1, |
807 | * MacBook have 20 X sensors, 10 Y sensors | 828 | ATP_FUZZ, 0); |
808 | */ | 829 | input_set_abs_params(input_dev, ABS_Y, 0, |
809 | input_set_abs_params(input_dev, ABS_X, 0, | 830 | (dev->info->ysensors - 1) * dev->info->yfact - 1, |
810 | ((20 - 1) * ATP_XFACT) - 1, ATP_FUZZ, 0); | 831 | ATP_FUZZ, 0); |
811 | input_set_abs_params(input_dev, ABS_Y, 0, | ||
812 | ((10 - 1) * ATP_YFACT) - 1, ATP_FUZZ, 0); | ||
813 | } else if (dev->type == ATP_GEYSER2) { | ||
814 | /* | ||
815 | * Oct 2005 15" PowerBooks have 15 X sensors, 17" are detected | ||
816 | * later. | ||
817 | */ | ||
818 | input_set_abs_params(input_dev, ABS_X, 0, | ||
819 | ((15 - 1) * ATP_XFACT) - 1, ATP_FUZZ, 0); | ||
820 | input_set_abs_params(input_dev, ABS_Y, 0, | ||
821 | ((9 - 1) * ATP_YFACT) - 1, ATP_FUZZ, 0); | ||
822 | } else { | ||
823 | /* | ||
824 | * 12" and 15" Powerbooks only have 16 x sensors, | ||
825 | * 17" models are detected later. | ||
826 | */ | ||
827 | input_set_abs_params(input_dev, ABS_X, 0, | ||
828 | (16 - 1) * ATP_XFACT - 1, | ||
829 | ATP_FUZZ, 0); | ||
830 | input_set_abs_params(input_dev, ABS_Y, 0, | ||
831 | (ATP_YSENSORS - 1) * ATP_YFACT - 1, | ||
832 | ATP_FUZZ, 0); | ||
833 | } | ||
834 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); | 832 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, ATP_PRESSURE, 0, 0); |
835 | 833 | ||
836 | set_bit(EV_KEY, input_dev->evbit); | 834 | set_bit(EV_KEY, input_dev->evbit); |
@@ -852,7 +850,7 @@ static int atp_probe(struct usb_interface *iface, | |||
852 | return 0; | 850 | return 0; |
853 | 851 | ||
854 | err_free_buffer: | 852 | err_free_buffer: |
855 | usb_buffer_free(dev->udev, dev->datalen, | 853 | usb_buffer_free(dev->udev, dev->info->datalen, |
856 | dev->data, dev->urb->transfer_dma); | 854 | dev->data, dev->urb->transfer_dma); |
857 | err_free_urb: | 855 | err_free_urb: |
858 | usb_free_urb(dev->urb); | 856 | usb_free_urb(dev->urb); |
@@ -871,7 +869,7 @@ static void atp_disconnect(struct usb_interface *iface) | |||
871 | if (dev) { | 869 | if (dev) { |
872 | usb_kill_urb(dev->urb); | 870 | usb_kill_urb(dev->urb); |
873 | input_unregister_device(dev->input); | 871 | input_unregister_device(dev->input); |
874 | usb_buffer_free(dev->udev, dev->datalen, | 872 | usb_buffer_free(dev->udev, dev->info->datalen, |
875 | dev->data, dev->urb->transfer_dma); | 873 | dev->data, dev->urb->transfer_dma); |
876 | usb_free_urb(dev->urb); | 874 | usb_free_urb(dev->urb); |
877 | kfree(dev); | 875 | kfree(dev); |