aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-08-20 05:52:15 -0400
committerIngo Molnar <mingo@elte.hu>2008-08-20 05:52:15 -0400
commit7393423dd9b5790a3115873be355e9fc862bce8f (patch)
treefc83214602c8ce41dc06d5c8e21deada679521f7 /drivers/input
parent8df9676d6402563da91427e8d9f2da8a4598aede (diff)
parent1fca25427482387689fa27594c992a961d98768f (diff)
Merge branch 'linus' into x86/cleanups
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/evdev.c63
-rw-r--r--drivers/input/joystick/xpad.c1
-rw-r--r--drivers/input/keyboard/gpio_keys.c3
-rw-r--r--drivers/input/mouse/Kconfig23
-rw-r--r--drivers/input/mouse/Makefile1
-rw-r--r--drivers/input/mouse/bcm5974.c681
-rw-r--r--drivers/input/serio/i8042-sparcio.h3
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h7
-rw-r--r--drivers/input/serio/xilinx_ps2.c4
-rw-r--r--drivers/input/touchscreen/Kconfig21
10 files changed, 771 insertions, 36 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 2d65411f6763..a92d81567559 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -647,6 +647,47 @@ static int str_to_user(const char *str, unsigned int maxlen, void __user *p)
647 return copy_to_user(p, str, len) ? -EFAULT : len; 647 return copy_to_user(p, str, len) ? -EFAULT : len;
648} 648}
649 649
650#define OLD_KEY_MAX 0x1ff
651static int handle_eviocgbit(struct input_dev *dev, unsigned int cmd, void __user *p, int compat_mode)
652{
653 static unsigned long keymax_warn_time;
654 unsigned long *bits;
655 int len;
656
657 switch (_IOC_NR(cmd) & EV_MAX) {
658
659 case 0: bits = dev->evbit; len = EV_MAX; break;
660 case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
661 case EV_REL: bits = dev->relbit; len = REL_MAX; break;
662 case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
663 case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
664 case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
665 case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
666 case EV_FF: bits = dev->ffbit; len = FF_MAX; break;
667 case EV_SW: bits = dev->swbit; len = SW_MAX; break;
668 default: return -EINVAL;
669 }
670
671 /*
672 * Work around bugs in userspace programs that like to do
673 * EVIOCGBIT(EV_KEY, KEY_MAX) and not realize that 'len'
674 * should be in bytes, not in bits.
675 */
676 if ((_IOC_NR(cmd) & EV_MAX) == EV_KEY && _IOC_SIZE(cmd) == OLD_KEY_MAX) {
677 len = OLD_KEY_MAX;
678 if (printk_timed_ratelimit(&keymax_warn_time, 10 * 1000))
679 printk(KERN_WARNING
680 "evdev.c(EVIOCGBIT): Suspicious buffer size %d, "
681 "limiting output to %d bytes. See "
682 "http://userweb.kernel.org/~dtor/eviocgbit-bug.html\n",
683 OLD_KEY_MAX,
684 BITS_TO_LONGS(OLD_KEY_MAX) * sizeof(long));
685 }
686
687 return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
688}
689#undef OLD_KEY_MAX
690
650static long evdev_do_ioctl(struct file *file, unsigned int cmd, 691static long evdev_do_ioctl(struct file *file, unsigned int cmd,
651 void __user *p, int compat_mode) 692 void __user *p, int compat_mode)
652{ 693{
@@ -733,26 +774,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
733 774
734 if (_IOC_DIR(cmd) == _IOC_READ) { 775 if (_IOC_DIR(cmd) == _IOC_READ) {
735 776
736 if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0))) { 777 if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0)))
737 778 return handle_eviocgbit(dev, cmd, p, compat_mode);
738 unsigned long *bits;
739 int len;
740
741 switch (_IOC_NR(cmd) & EV_MAX) {
742
743 case 0: bits = dev->evbit; len = EV_MAX; break;
744 case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
745 case EV_REL: bits = dev->relbit; len = REL_MAX; break;
746 case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
747 case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
748 case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
749 case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
750 case EV_FF: bits = dev->ffbit; len = FF_MAX; break;
751 case EV_SW: bits = dev->swbit; len = SW_MAX; break;
752 default: return -EINVAL;
753 }
754 return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
755 }
756 779
757 if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) 780 if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0)))
758 return bits_to_user(dev->key, KEY_MAX, _IOC_SIZE(cmd), 781 return bits_to_user(dev->key, KEY_MAX, _IOC_SIZE(cmd),
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 87d3e7eabffd..6791be81eb29 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -127,6 +127,7 @@ static const struct xpad_device {
127 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, 127 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
128 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, 128 { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
129 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 129 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
130 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", MAP_DPAD_TO_AXES, XTYPE_XBOX },
130 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 131 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
131 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 132 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES, XTYPE_XBOX },
132 { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, 133 { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX },
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index be58730e636a..3f48279f2195 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -118,6 +118,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
118 unsigned int type = button->type ?: EV_KEY; 118 unsigned int type = button->type ?: EV_KEY;
119 119
120 bdata->input = input; 120 bdata->input = input;
121 bdata->button = button;
121 setup_timer(&bdata->timer, 122 setup_timer(&bdata->timer,
122 gpio_check_button, (unsigned long)bdata); 123 gpio_check_button, (unsigned long)bdata);
123 124
@@ -256,7 +257,7 @@ static int gpio_keys_resume(struct platform_device *pdev)
256#define gpio_keys_resume NULL 257#define gpio_keys_resume NULL
257#endif 258#endif
258 259
259struct platform_driver gpio_keys_device_driver = { 260static struct platform_driver gpio_keys_device_driver = {
260 .probe = gpio_keys_probe, 261 .probe = gpio_keys_probe,
261 .remove = __devexit_p(gpio_keys_remove), 262 .remove = __devexit_p(gpio_keys_remove),
262 .suspend = gpio_keys_suspend, 263 .suspend = gpio_keys_suspend,
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 7bbea097cda2..f996546fc443 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -130,6 +130,29 @@ config MOUSE_APPLETOUCH
130 To compile this driver as a module, choose M here: the 130 To compile this driver as a module, choose M here: the
131 module will be called appletouch. 131 module will be called appletouch.
132 132
133config MOUSE_BCM5974
134 tristate "Apple USB BCM5974 Multitouch trackpad support"
135 depends on USB_ARCH_HAS_HCD
136 select USB
137 help
138 Say Y here if you have an Apple USB BCM5974 Multitouch
139 trackpad.
140
141 The BCM5974 is the multitouch trackpad found in the Macbook
142 Air (JAN2008) and Macbook Pro Penryn (FEB2008) laptops.
143
144 It is also found in the IPhone (2007) and Ipod Touch (2008).
145
146 This driver provides multitouch functionality together with
147 the synaptics X11 driver.
148
149 The interface is currently identical to the appletouch interface,
150 for further information, see
151 <file:Documentation/input/appletouch.txt>.
152
153 To compile this driver as a module, choose M here: the
154 module will be called bcm5974.
155
133config MOUSE_INPORT 156config MOUSE_INPORT
134 tristate "InPort/MS/ATIXL busmouse" 157 tristate "InPort/MS/ATIXL busmouse"
135 depends on ISA 158 depends on ISA
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 9e6e36330820..d4d202516090 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -6,6 +6,7 @@
6 6
7obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o 7obj-$(CONFIG_MOUSE_AMIGA) += amimouse.o
8obj-$(CONFIG_MOUSE_APPLETOUCH) += appletouch.o 8obj-$(CONFIG_MOUSE_APPLETOUCH) += appletouch.o
9obj-$(CONFIG_MOUSE_BCM5974) += bcm5974.o
9obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o 10obj-$(CONFIG_MOUSE_ATARI) += atarimouse.o
10obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o 11obj-$(CONFIG_MOUSE_RISCPC) += rpcmouse.o
11obj-$(CONFIG_MOUSE_INPORT) += inport.o 12obj-$(CONFIG_MOUSE_INPORT) += inport.o
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
new file mode 100644
index 000000000000..2ec921bf3c60
--- /dev/null
+++ b/drivers/input/mouse/bcm5974.c
@@ -0,0 +1,681 @@
1/*
2 * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver
3 *
4 * Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se)
5 *
6 * The USB initialization and package decoding was made by
7 * Scott Shawcroft as part of the touchd user-space driver project:
8 * Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com)
9 *
10 * The BCM5974 driver is based on the appletouch driver:
11 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
12 * Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net)
13 * Copyright (C) 2005 Stelian Pop (stelian@popies.net)
14 * Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de)
15 * Copyright (C) 2005 Peter Osterlund (petero2@telia.com)
16 * Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
17 * Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch)
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 *
33 */
34
35#include <linux/kernel.h>
36#include <linux/errno.h>
37#include <linux/init.h>
38#include <linux/slab.h>
39#include <linux/module.h>
40#include <linux/usb/input.h>
41#include <linux/hid.h>
42#include <linux/mutex.h>
43
44#define USB_VENDOR_ID_APPLE 0x05ac
45
46/* MacbookAir, aka wellspring */
47#define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223
48#define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224
49#define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225
50/* MacbookProPenryn, aka wellspring2 */
51#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230
52#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231
53#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232
54
55#define BCM5974_DEVICE(prod) { \
56 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
57 USB_DEVICE_ID_MATCH_INT_CLASS | \
58 USB_DEVICE_ID_MATCH_INT_PROTOCOL), \
59 .idVendor = USB_VENDOR_ID_APPLE, \
60 .idProduct = (prod), \
61 .bInterfaceClass = USB_INTERFACE_CLASS_HID, \
62 .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE \
63}
64
65/* table of devices that work with this driver */
66static const struct usb_device_id bcm5974_table [] = {
67 /* MacbookAir1.1 */
68 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
69 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
70 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_JIS),
71 /* MacbookProPenryn */
72 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI),
73 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO),
74 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS),
75 /* Terminating entry */
76 {}
77};
78MODULE_DEVICE_TABLE(usb, bcm5974_table);
79
80MODULE_AUTHOR("Henrik Rydberg");
81MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver");
82MODULE_LICENSE("GPL");
83
84#define dprintk(level, format, a...)\
85 { if (debug >= level) printk(KERN_DEBUG format, ##a); }
86
87static int debug = 1;
88module_param(debug, int, 0644);
89MODULE_PARM_DESC(debug, "Activate debugging output");
90
91/* button data structure */
92struct bt_data {
93 u8 unknown1; /* constant */
94 u8 button; /* left button */
95 u8 rel_x; /* relative x coordinate */
96 u8 rel_y; /* relative y coordinate */
97};
98
99/* trackpad header structure */
100struct tp_header {
101 u8 unknown1[16]; /* constants, timers, etc */
102 u8 fingers; /* number of fingers on trackpad */
103 u8 unknown2[9]; /* constants, timers, etc */
104};
105
106/* trackpad finger structure */
107struct tp_finger {
108 __le16 origin; /* left/right origin? */
109 __le16 abs_x; /* absolute x coodinate */
110 __le16 abs_y; /* absolute y coodinate */
111 __le16 rel_x; /* relative x coodinate */
112 __le16 rel_y; /* relative y coodinate */
113 __le16 size_major; /* finger size, major axis? */
114 __le16 size_minor; /* finger size, minor axis? */
115 __le16 orientation; /* 16384 when point, else 15 bit angle */
116 __le16 force_major; /* trackpad force, major axis? */
117 __le16 force_minor; /* trackpad force, minor axis? */
118 __le16 unused[3]; /* zeros */
119 __le16 multi; /* one finger: varies, more fingers: constant */
120};
121
122/* trackpad data structure, empirically at least ten fingers */
123struct tp_data {
124 struct tp_header header;
125 struct tp_finger finger[16];
126};
127
128/* device-specific parameters */
129struct bcm5974_param {
130 int dim; /* logical dimension */
131 int fuzz; /* logical noise value */
132 int devmin; /* device minimum reading */
133 int devmax; /* device maximum reading */
134};
135
136/* device-specific configuration */
137struct bcm5974_config {
138 int ansi, iso, jis; /* the product id of this device */
139 int bt_ep; /* the endpoint of the button interface */
140 int bt_datalen; /* data length of the button interface */
141 int tp_ep; /* the endpoint of the trackpad interface */
142 int tp_datalen; /* data length of the trackpad interface */
143 struct bcm5974_param p; /* finger pressure limits */
144 struct bcm5974_param w; /* finger width limits */
145 struct bcm5974_param x; /* horizontal limits */
146 struct bcm5974_param y; /* vertical limits */
147};
148
149/* logical device structure */
150struct bcm5974 {
151 char phys[64];
152 struct usb_device *udev; /* usb device */
153 struct usb_interface *intf; /* our interface */
154 struct input_dev *input; /* input dev */
155 struct bcm5974_config cfg; /* device configuration */
156 struct mutex pm_mutex; /* serialize access to open/suspend */
157 int opened; /* 1: opened, 0: closed */
158 struct urb *bt_urb; /* button usb request block */
159 struct bt_data *bt_data; /* button transferred data */
160 struct urb *tp_urb; /* trackpad usb request block */
161 struct tp_data *tp_data; /* trackpad transferred data */
162};
163
164/* logical dimensions */
165#define DIM_PRESSURE 256 /* maximum finger pressure */
166#define DIM_WIDTH 16 /* maximum finger width */
167#define DIM_X 1280 /* maximum trackpad x value */
168#define DIM_Y 800 /* maximum trackpad y value */
169
170/* logical signal quality */
171#define SN_PRESSURE 45 /* pressure signal-to-noise ratio */
172#define SN_WIDTH 100 /* width signal-to-noise ratio */
173#define SN_COORD 250 /* coordinate signal-to-noise ratio */
174
175/* device constants */
176static const struct bcm5974_config bcm5974_config_table[] = {
177 {
178 USB_DEVICE_ID_APPLE_WELLSPRING_ANSI,
179 USB_DEVICE_ID_APPLE_WELLSPRING_ISO,
180 USB_DEVICE_ID_APPLE_WELLSPRING_JIS,
181 0x84, sizeof(struct bt_data),
182 0x81, sizeof(struct tp_data),
183 { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 },
184 { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
185 { DIM_X, DIM_X / SN_COORD, -4824, 5342 },
186 { DIM_Y, DIM_Y / SN_COORD, -172, 5820 }
187 },
188 {
189 USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI,
190 USB_DEVICE_ID_APPLE_WELLSPRING2_ISO,
191 USB_DEVICE_ID_APPLE_WELLSPRING2_JIS,
192 0x84, sizeof(struct bt_data),
193 0x81, sizeof(struct tp_data),
194 { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 },
195 { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 },
196 { DIM_X, DIM_X / SN_COORD, -4824, 4824 },
197 { DIM_Y, DIM_Y / SN_COORD, -172, 4290 }
198 },
199 {}
200};
201
202/* return the device-specific configuration by device */
203static const struct bcm5974_config *bcm5974_get_config(struct usb_device *udev)
204{
205 u16 id = le16_to_cpu(udev->descriptor.idProduct);
206 const struct bcm5974_config *cfg;
207
208 for (cfg = bcm5974_config_table; cfg->ansi; ++cfg)
209 if (cfg->ansi == id || cfg->iso == id || cfg->jis == id)
210 return cfg;
211
212 return bcm5974_config_table;
213}
214
215/* convert 16-bit little endian to signed integer */
216static inline int raw2int(__le16 x)
217{
218 return (signed short)le16_to_cpu(x);
219}
220
221/* scale device data to logical dimensions (asserts devmin < devmax) */
222static inline int int2scale(const struct bcm5974_param *p, int x)
223{
224 return x * p->dim / (p->devmax - p->devmin);
225}
226
227/* all logical value ranges are [0,dim). */
228static inline int int2bound(const struct bcm5974_param *p, int x)
229{
230 int s = int2scale(p, x);
231
232 return clamp_val(s, 0, p->dim - 1);
233}
234
235/* setup which logical events to report */
236static void setup_events_to_report(struct input_dev *input_dev,
237 const struct bcm5974_config *cfg)
238{
239 __set_bit(EV_ABS, input_dev->evbit);
240
241 input_set_abs_params(input_dev, ABS_PRESSURE,
242 0, cfg->p.dim, cfg->p.fuzz, 0);
243 input_set_abs_params(input_dev, ABS_TOOL_WIDTH,
244 0, cfg->w.dim, cfg->w.fuzz, 0);
245 input_set_abs_params(input_dev, ABS_X,
246 0, cfg->x.dim, cfg->x.fuzz, 0);
247 input_set_abs_params(input_dev, ABS_Y,
248 0, cfg->y.dim, cfg->y.fuzz, 0);
249
250 __set_bit(EV_KEY, input_dev->evbit);
251 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
252 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
253 __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
254 __set_bit(BTN_LEFT, input_dev->keybit);
255}
256
257/* report button data as logical button state */
258static int report_bt_state(struct bcm5974 *dev, int size)
259{
260 if (size != sizeof(struct bt_data))
261 return -EIO;
262
263 input_report_key(dev->input, BTN_LEFT, dev->bt_data->button);
264 input_sync(dev->input);
265
266 return 0;
267}
268
269/* report trackpad data as logical trackpad state */
270static int report_tp_state(struct bcm5974 *dev, int size)
271{
272 const struct bcm5974_config *c = &dev->cfg;
273 const struct tp_finger *f = dev->tp_data->finger;
274 struct input_dev *input = dev->input;
275 const int fingers = (size - 26) / 28;
276 int p = 0, w, x, y, n = 0;
277
278 if (size < 26 || (size - 26) % 28 != 0)
279 return -EIO;
280
281 if (fingers) {
282 p = raw2int(f->force_major);
283 w = raw2int(f->size_major);
284 x = raw2int(f->abs_x);
285 y = raw2int(f->abs_y);
286 n = p > 0 ? fingers : 0;
287
288 dprintk(9,
289 "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n",
290 p, w, x, y, n);
291
292 input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w));
293 input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin));
294 input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y));
295 }
296
297 input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p));
298
299 input_report_key(input, BTN_TOOL_FINGER, n == 1);
300 input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2);
301 input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2);
302
303 input_sync(input);
304
305 return 0;
306}
307
308/* Wellspring initialization constants */
309#define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1
310#define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9
311#define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300
312#define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0
313#define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01
314
315static int bcm5974_wellspring_mode(struct bcm5974 *dev)
316{
317 char *data = kmalloc(8, GFP_KERNEL);
318 int retval = 0, size;
319
320 if (!data) {
321 err("bcm5974: out of memory");
322 retval = -ENOMEM;
323 goto out;
324 }
325
326 /* read configuration */
327 size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
328 BCM5974_WELLSPRING_MODE_READ_REQUEST_ID,
329 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
330 BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
331 BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
332
333 if (size != 8) {
334 err("bcm5974: could not read from device");
335 retval = -EIO;
336 goto out;
337 }
338
339 /* apply the mode switch */
340 data[0] = BCM5974_WELLSPRING_MODE_VENDOR_VALUE;
341
342 /* write configuration */
343 size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
344 BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID,
345 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
346 BCM5974_WELLSPRING_MODE_REQUEST_VALUE,
347 BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000);
348
349 if (size != 8) {
350 err("bcm5974: could not write to device");
351 retval = -EIO;
352 goto out;
353 }
354
355 dprintk(2, "bcm5974: switched to wellspring mode.\n");
356
357 out:
358 kfree(data);
359 return retval;
360}
361
362static void bcm5974_irq_button(struct urb *urb)
363{
364 struct bcm5974 *dev = urb->context;
365 int error;
366
367 switch (urb->status) {
368 case 0:
369 break;
370 case -EOVERFLOW:
371 case -ECONNRESET:
372 case -ENOENT:
373 case -ESHUTDOWN:
374 dbg("bcm5974: button urb shutting down: %d", urb->status);
375 return;
376 default:
377 dbg("bcm5974: button urb status: %d", urb->status);
378 goto exit;
379 }
380
381 if (report_bt_state(dev, dev->bt_urb->actual_length))
382 dprintk(1, "bcm5974: bad button package, length: %d\n",
383 dev->bt_urb->actual_length);
384
385exit:
386 error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC);
387 if (error)
388 err("bcm5974: button urb failed: %d", error);
389}
390
391static void bcm5974_irq_trackpad(struct urb *urb)
392{
393 struct bcm5974 *dev = urb->context;
394 int error;
395
396 switch (urb->status) {
397 case 0:
398 break;
399 case -EOVERFLOW:
400 case -ECONNRESET:
401 case -ENOENT:
402 case -ESHUTDOWN:
403 dbg("bcm5974: trackpad urb shutting down: %d", urb->status);
404 return;
405 default:
406 dbg("bcm5974: trackpad urb status: %d", urb->status);
407 goto exit;
408 }
409
410 /* control response ignored */
411 if (dev->tp_urb->actual_length == 2)
412 goto exit;
413
414 if (report_tp_state(dev, dev->tp_urb->actual_length))
415 dprintk(1, "bcm5974: bad trackpad package, length: %d\n",
416 dev->tp_urb->actual_length);
417
418exit:
419 error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC);
420 if (error)
421 err("bcm5974: trackpad urb failed: %d", error);
422}
423
424/*
425 * The Wellspring trackpad, like many recent Apple trackpads, share
426 * the usb device with the keyboard. Since keyboards are usually
427 * handled by the HID system, the device ends up being handled by two
428 * modules. Setting up the device therefore becomes slightly
429 * complicated. To enable multitouch features, a mode switch is
430 * required, which is usually applied via the control interface of the
431 * device. It can be argued where this switch should take place. In
432 * some drivers, like appletouch, the switch is made during
433 * probe. However, the hid module may also alter the state of the
434 * device, resulting in trackpad malfunction under certain
435 * circumstances. To get around this problem, there is at least one
436 * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to
437 * recieve a reset_resume request rather than the normal resume.
438 * Since the implementation of reset_resume is equal to mode switch
439 * plus start_traffic, it seems easier to always do the switch when
440 * starting traffic on the device.
441 */
442static int bcm5974_start_traffic(struct bcm5974 *dev)
443{
444 if (bcm5974_wellspring_mode(dev)) {
445 dprintk(1, "bcm5974: mode switch failed\n");
446 goto error;
447 }
448
449 if (usb_submit_urb(dev->bt_urb, GFP_KERNEL))
450 goto error;
451
452 if (usb_submit_urb(dev->tp_urb, GFP_KERNEL))
453 goto err_kill_bt;
454
455 return 0;
456
457err_kill_bt:
458 usb_kill_urb(dev->bt_urb);
459error:
460 return -EIO;
461}
462
463static void bcm5974_pause_traffic(struct bcm5974 *dev)
464{
465 usb_kill_urb(dev->tp_urb);
466 usb_kill_urb(dev->bt_urb);
467}
468
469/*
470 * The code below implements open/close and manual suspend/resume.
471 * All functions may be called in random order.
472 *
473 * Opening a suspended device fails with EACCES - permission denied.
474 *
475 * Failing a resume leaves the device resumed but closed.
476 */
477static int bcm5974_open(struct input_dev *input)
478{
479 struct bcm5974 *dev = input_get_drvdata(input);
480 int error;
481
482 error = usb_autopm_get_interface(dev->intf);
483 if (error)
484 return error;
485
486 mutex_lock(&dev->pm_mutex);
487
488 error = bcm5974_start_traffic(dev);
489 if (!error)
490 dev->opened = 1;
491
492 mutex_unlock(&dev->pm_mutex);
493
494 if (error)
495 usb_autopm_put_interface(dev->intf);
496
497 return error;
498}
499
500static void bcm5974_close(struct input_dev *input)
501{
502 struct bcm5974 *dev = input_get_drvdata(input);
503
504 mutex_lock(&dev->pm_mutex);
505
506 bcm5974_pause_traffic(dev);
507 dev->opened = 0;
508
509 mutex_unlock(&dev->pm_mutex);
510
511 usb_autopm_put_interface(dev->intf);
512}
513
514static int bcm5974_suspend(struct usb_interface *iface, pm_message_t message)
515{
516 struct bcm5974 *dev = usb_get_intfdata(iface);
517
518 mutex_lock(&dev->pm_mutex);
519
520 if (dev->opened)
521 bcm5974_pause_traffic(dev);
522
523 mutex_unlock(&dev->pm_mutex);
524
525 return 0;
526}
527
528static int bcm5974_resume(struct usb_interface *iface)
529{
530 struct bcm5974 *dev = usb_get_intfdata(iface);
531 int error = 0;
532
533 mutex_lock(&dev->pm_mutex);
534
535 if (dev->opened)
536 error = bcm5974_start_traffic(dev);
537
538 mutex_unlock(&dev->pm_mutex);
539
540 return error;
541}
542
543static int bcm5974_probe(struct usb_interface *iface,
544 const struct usb_device_id *id)
545{
546 struct usb_device *udev = interface_to_usbdev(iface);
547 const struct bcm5974_config *cfg;
548 struct bcm5974 *dev;
549 struct input_dev *input_dev;
550 int error = -ENOMEM;
551
552 /* find the product index */
553 cfg = bcm5974_get_config(udev);
554
555 /* allocate memory for our device state and initialize it */
556 dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL);
557 input_dev = input_allocate_device();
558 if (!dev || !input_dev) {
559 err("bcm5974: out of memory");
560 goto err_free_devs;
561 }
562
563 dev->udev = udev;
564 dev->intf = iface;
565 dev->input = input_dev;
566 dev->cfg = *cfg;
567 mutex_init(&dev->pm_mutex);
568
569 /* setup urbs */
570 dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL);
571 if (!dev->bt_urb)
572 goto err_free_devs;
573
574 dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL);
575 if (!dev->tp_urb)
576 goto err_free_bt_urb;
577
578 dev->bt_data = usb_buffer_alloc(dev->udev,
579 dev->cfg.bt_datalen, GFP_KERNEL,
580 &dev->bt_urb->transfer_dma);
581 if (!dev->bt_data)
582 goto err_free_urb;
583
584 dev->tp_data = usb_buffer_alloc(dev->udev,
585 dev->cfg.tp_datalen, GFP_KERNEL,
586 &dev->tp_urb->transfer_dma);
587 if (!dev->tp_data)
588 goto err_free_bt_buffer;
589
590 usb_fill_int_urb(dev->bt_urb, udev,
591 usb_rcvintpipe(udev, cfg->bt_ep),
592 dev->bt_data, dev->cfg.bt_datalen,
593 bcm5974_irq_button, dev, 1);
594
595 usb_fill_int_urb(dev->tp_urb, udev,
596 usb_rcvintpipe(udev, cfg->tp_ep),
597 dev->tp_data, dev->cfg.tp_datalen,
598 bcm5974_irq_trackpad, dev, 1);
599
600 /* create bcm5974 device */
601 usb_make_path(udev, dev->phys, sizeof(dev->phys));
602 strlcat(dev->phys, "/input0", sizeof(dev->phys));
603
604 input_dev->name = "bcm5974";
605 input_dev->phys = dev->phys;
606 usb_to_input_id(dev->udev, &input_dev->id);
607 input_dev->dev.parent = &iface->dev;
608
609 input_set_drvdata(input_dev, dev);
610
611 input_dev->open = bcm5974_open;
612 input_dev->close = bcm5974_close;
613
614 setup_events_to_report(input_dev, cfg);
615
616 error = input_register_device(dev->input);
617 if (error)
618 goto err_free_buffer;
619
620 /* save our data pointer in this interface device */
621 usb_set_intfdata(iface, dev);
622
623 return 0;
624
625err_free_buffer:
626 usb_buffer_free(dev->udev, dev->cfg.tp_datalen,
627 dev->tp_data, dev->tp_urb->transfer_dma);
628err_free_bt_buffer:
629 usb_buffer_free(dev->udev, dev->cfg.bt_datalen,
630 dev->bt_data, dev->bt_urb->transfer_dma);
631err_free_urb:
632 usb_free_urb(dev->tp_urb);
633err_free_bt_urb:
634 usb_free_urb(dev->bt_urb);
635err_free_devs:
636 usb_set_intfdata(iface, NULL);
637 input_free_device(input_dev);
638 kfree(dev);
639 return error;
640}
641
642static void bcm5974_disconnect(struct usb_interface *iface)
643{
644 struct bcm5974 *dev = usb_get_intfdata(iface);
645
646 usb_set_intfdata(iface, NULL);
647
648 input_unregister_device(dev->input);
649 usb_buffer_free(dev->udev, dev->cfg.tp_datalen,
650 dev->tp_data, dev->tp_urb->transfer_dma);
651 usb_buffer_free(dev->udev, dev->cfg.bt_datalen,
652 dev->bt_data, dev->bt_urb->transfer_dma);
653 usb_free_urb(dev->tp_urb);
654 usb_free_urb(dev->bt_urb);
655 kfree(dev);
656}
657
658static struct usb_driver bcm5974_driver = {
659 .name = "bcm5974",
660 .probe = bcm5974_probe,
661 .disconnect = bcm5974_disconnect,
662 .suspend = bcm5974_suspend,
663 .resume = bcm5974_resume,
664 .reset_resume = bcm5974_resume,
665 .id_table = bcm5974_table,
666 .supports_autosuspend = 1,
667};
668
669static int __init bcm5974_init(void)
670{
671 return usb_register(&bcm5974_driver);
672}
673
674static void __exit bcm5974_exit(void)
675{
676 usb_deregister(&bcm5974_driver);
677}
678
679module_init(bcm5974_init);
680module_exit(bcm5974_exit);
681
diff --git a/drivers/input/serio/i8042-sparcio.h b/drivers/input/serio/i8042-sparcio.h
index 66bafe308b0c..692a79ec2a22 100644
--- a/drivers/input/serio/i8042-sparcio.h
+++ b/drivers/input/serio/i8042-sparcio.h
@@ -1,10 +1,11 @@
1#ifndef _I8042_SPARCIO_H 1#ifndef _I8042_SPARCIO_H
2#define _I8042_SPARCIO_H 2#define _I8042_SPARCIO_H
3 3
4#include <linux/of_device.h>
5
4#include <asm/io.h> 6#include <asm/io.h>
5#include <asm/oplib.h> 7#include <asm/oplib.h>
6#include <asm/prom.h> 8#include <asm/prom.h>
7#include <asm/of_device.h>
8 9
9static int i8042_kbd_irq = -1; 10static int i8042_kbd_irq = -1;
10static int i8042_aux_irq = -1; 11static int i8042_aux_irq = -1;
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index fe732a574ec2..3282b741e246 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -394,6 +394,13 @@ static struct dmi_system_id __initdata i8042_dmi_dritek_table[] = {
394 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"), 394 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
395 }, 395 },
396 }, 396 },
397 {
398 .ident = "Acer TravelMate 4280",
399 .matches = {
400 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
401 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4280"),
402 },
403 },
397 { } 404 { }
398}; 405};
399 406
diff --git a/drivers/input/serio/xilinx_ps2.c b/drivers/input/serio/xilinx_ps2.c
index 0ed044d5e685..765007899d9a 100644
--- a/drivers/input/serio/xilinx_ps2.c
+++ b/drivers/input/serio/xilinx_ps2.c
@@ -269,8 +269,8 @@ static int xps2_setup(struct device *dev, struct resource *regs_res,
269 * we have the PS2 in a good state */ 269 * we have the PS2 in a good state */
270 out_be32(drvdata->base_address + XPS2_SRST_OFFSET, XPS2_SRST_RESET); 270 out_be32(drvdata->base_address + XPS2_SRST_OFFSET, XPS2_SRST_RESET);
271 271
272 dev_info(dev, "Xilinx PS2 at 0x%08X mapped to 0x%08X, irq=%d\n", 272 dev_info(dev, "Xilinx PS2 at 0x%08X mapped to 0x%p, irq=%d\n",
273 drvdata->phys_addr, (u32)drvdata->base_address, drvdata->irq); 273 drvdata->phys_addr, drvdata->base_address, drvdata->irq);
274 274
275 serio = &drvdata->serio; 275 serio = &drvdata->serio;
276 serio->id.type = SERIO_8042; 276 serio->id.type = SERIO_8042;
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 6e60a97a234c..25287e80e236 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -249,29 +249,26 @@ config TOUCHSCREEN_WM97XX
249config TOUCHSCREEN_WM9705 249config TOUCHSCREEN_WM9705
250 bool "WM9705 Touchscreen interface support" 250 bool "WM9705 Touchscreen interface support"
251 depends on TOUCHSCREEN_WM97XX 251 depends on TOUCHSCREEN_WM97XX
252 default y
252 help 253 help
253 Say Y here if you have a Wolfson Microelectronics WM9705 254 Say Y here to enable support for the Wolfson Microelectronics
254 touchscreen controller connected to your system. 255 WM9705 touchscreen controller.
255
256 If unsure, say N.
257 256
258config TOUCHSCREEN_WM9712 257config TOUCHSCREEN_WM9712
259 bool "WM9712 Touchscreen interface support" 258 bool "WM9712 Touchscreen interface support"
260 depends on TOUCHSCREEN_WM97XX 259 depends on TOUCHSCREEN_WM97XX
260 default y
261 help 261 help
262 Say Y here if you have a Wolfson Microelectronics WM9712 262 Say Y here to enable support for the Wolfson Microelectronics
263 touchscreen controller connected to your system. 263 WM9712 touchscreen controller.
264
265 If unsure, say N.
266 264
267config TOUCHSCREEN_WM9713 265config TOUCHSCREEN_WM9713
268 bool "WM9713 Touchscreen interface support" 266 bool "WM9713 Touchscreen interface support"
269 depends on TOUCHSCREEN_WM97XX 267 depends on TOUCHSCREEN_WM97XX
268 default y
270 help 269 help
271 Say Y here if you have a Wolfson Microelectronics WM9713 touchscreen 270 Say Y here to enable support for the Wolfson Microelectronics
272 controller connected to your system. 271 WM9713 touchscreen controller.
273
274 If unsure, say N.
275 272
276config TOUCHSCREEN_WM97XX_MAINSTONE 273config TOUCHSCREEN_WM97XX_MAINSTONE
277 tristate "WM97xx Mainstone accelerated touch" 274 tristate "WM97xx Mainstone accelerated touch"