diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-driver-hid | 10 | ||||
-rw-r--r-- | drivers/hid/Kconfig | 45 | ||||
-rw-r--r-- | drivers/hid/Makefile | 7 | ||||
-rw-r--r-- | drivers/hid/hid-axff.c | 31 | ||||
-rw-r--r-- | drivers/hid/hid-core.c | 41 | ||||
-rw-r--r-- | drivers/hid/hid-dr.c (renamed from drivers/hid/hid-drff.c) | 117 | ||||
-rw-r--r-- | drivers/hid/hid-egalax.c | 279 | ||||
-rw-r--r-- | drivers/hid/hid-gyration.c | 5 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 11 | ||||
-rw-r--r-- | drivers/hid/hid-input.c | 31 | ||||
-rw-r--r-- | drivers/hid/hid-keytouch.c | 66 | ||||
-rw-r--r-- | drivers/hid/hid-lcpower.c | 70 | ||||
-rw-r--r-- | drivers/hid/hid-lg.c | 2 | ||||
-rw-r--r-- | drivers/hid/hid-magicmouse.c | 4 | ||||
-rw-r--r-- | drivers/hid/hid-multitouch.c | 76 | ||||
-rw-r--r-- | drivers/hid/hid-ntrig.c | 519 | ||||
-rw-r--r-- | drivers/hid/hid-ortek.c | 6 | ||||
-rw-r--r-- | drivers/hid/hid-sony.c | 20 | ||||
-rw-r--r-- | drivers/hid/hidraw.c | 112 | ||||
-rw-r--r-- | drivers/hid/usbhid/hid-core.c | 35 | ||||
-rw-r--r-- | include/linux/hid.h | 5 | ||||
-rw-r--r-- | include/linux/hidraw.h | 3 | ||||
-rw-r--r-- | net/bluetooth/hidp/core.c | 197 | ||||
-rw-r--r-- | net/bluetooth/hidp/hidp.h | 15 |
24 files changed, 1122 insertions, 585 deletions
diff --git a/Documentation/ABI/testing/sysfs-driver-hid b/Documentation/ABI/testing/sysfs-driver-hid new file mode 100644 index 000000000000..b6490e14fe83 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-hid | |||
@@ -0,0 +1,10 @@ | |||
1 | What: For USB devices : /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor | ||
2 | For BT devices : /sys/class/bluetooth/hci<addr>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor | ||
3 | Symlink : /sys/class/hidraw/hidraw<num>/device/report_descriptor | ||
4 | Date: Jan 2011 | ||
5 | KernelVersion: 2.0.39 | ||
6 | Contact: Alan Ott <alan@signal11.us> | ||
7 | Description: When read, this file returns the device's raw binary HID | ||
8 | report descriptor. | ||
9 | This file cannot be written. | ||
10 | Users: HIDAPI library (http://www.signal11.us/oss/hidapi) | ||
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 022515fdd6fe..d8123920f79c 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -68,9 +68,15 @@ config HID_A4TECH | |||
68 | ---help--- | 68 | ---help--- |
69 | Support for A4 tech X5 and WOP-35 / Trust 450L mice. | 69 | Support for A4 tech X5 and WOP-35 / Trust 450L mice. |
70 | 70 | ||
71 | config HID_ACRUX_FF | 71 | config HID_ACRUX |
72 | tristate "ACRUX force feedback" | 72 | tristate "ACRUX game controller support" |
73 | depends on USB_HID | 73 | depends on USB_HID |
74 | ---help--- | ||
75 | Say Y here if you want to enable support for ACRUX game controllers. | ||
76 | |||
77 | config HID_ACRUX_FF | ||
78 | tristate "ACRUX force feedback support" | ||
79 | depends on HID_ACRUX | ||
74 | select INPUT_FF_MEMLESS | 80 | select INPUT_FF_MEMLESS |
75 | ---help--- | 81 | ---help--- |
76 | Say Y here if you want to enable force feedback support for ACRUX | 82 | Say Y here if you want to enable force feedback support for ACRUX |
@@ -140,7 +146,12 @@ config HID_DRAGONRISE | |||
140 | tristate "DragonRise Inc. game controller" | 146 | tristate "DragonRise Inc. game controller" |
141 | depends on USB_HID | 147 | depends on USB_HID |
142 | ---help--- | 148 | ---help--- |
143 | Say Y here if you have DragonRise Inc.game controllers. | 149 | Say Y here if you have DragonRise Inc. game controllers. |
150 | These might be branded as: | ||
151 | - Tesun USB-703 | ||
152 | - Media-tech MT1504 "Rogue" | ||
153 | - DVTech JS19 "Gear" | ||
154 | - Defender Game Master | ||
144 | 155 | ||
145 | config DRAGONRISE_FF | 156 | config DRAGONRISE_FF |
146 | bool "DragonRise Inc. force feedback" | 157 | bool "DragonRise Inc. force feedback" |
@@ -160,13 +171,6 @@ config HID_EMS_FF | |||
160 | Currently the following devices are known to be supported: | 171 | Currently the following devices are known to be supported: |
161 | - Trio Linker Plus II | 172 | - Trio Linker Plus II |
162 | 173 | ||
163 | config HID_EGALAX | ||
164 | tristate "eGalax multi-touch panel" | ||
165 | depends on USB_HID | ||
166 | ---help--- | ||
167 | Support for the eGalax dual-touch panels, including the | ||
168 | Joojoo and Wetab tablets. | ||
169 | |||
170 | config HID_ELECOM | 174 | config HID_ELECOM |
171 | tristate "ELECOM BM084 bluetooth mouse" | 175 | tristate "ELECOM BM084 bluetooth mouse" |
172 | depends on BT_HIDP | 176 | depends on BT_HIDP |
@@ -180,6 +184,14 @@ config HID_EZKEY | |||
180 | ---help--- | 184 | ---help--- |
181 | Support for Ezkey BTC 8193 keyboard. | 185 | Support for Ezkey BTC 8193 keyboard. |
182 | 186 | ||
187 | config HID_KEYTOUCH | ||
188 | tristate "Keyoutch HID devices" | ||
189 | depends on USB_HID | ||
190 | ---help--- | ||
191 | Support for Keytouch HID devices not fully compliant with | ||
192 | the specification. Currently supported: | ||
193 | - Keytouch IEC 60945 | ||
194 | |||
183 | config HID_KYE | 195 | config HID_KYE |
184 | tristate "Kye/Genius Ergo Mouse" if EMBEDDED | 196 | tristate "Kye/Genius Ergo Mouse" if EMBEDDED |
185 | depends on USB_HID | 197 | depends on USB_HID |
@@ -218,6 +230,12 @@ config HID_KENSINGTON | |||
218 | ---help--- | 230 | ---help--- |
219 | Support for Kensington Slimblade Trackball. | 231 | Support for Kensington Slimblade Trackball. |
220 | 232 | ||
233 | config HID_LCPOWER | ||
234 | tristate "LC-Power" | ||
235 | depends on USB_HID | ||
236 | ---help--- | ||
237 | Support for LC-Power RC1000MCE RF remote control. | ||
238 | |||
221 | config HID_LOGITECH | 239 | config HID_LOGITECH |
222 | tristate "Logitech devices" if EMBEDDED | 240 | tristate "Logitech devices" if EMBEDDED |
223 | depends on USB_HID | 241 | depends on USB_HID |
@@ -304,8 +322,11 @@ config HID_MULTITOUCH | |||
304 | Say Y here if you have one of the following devices: | 322 | Say Y here if you have one of the following devices: |
305 | - Cypress TrueTouch panels | 323 | - Cypress TrueTouch panels |
306 | - Hanvon dual touch panels | 324 | - Hanvon dual touch panels |
325 | - IrTouch Infrared USB panels | ||
307 | - Pixcir dual touch panels | 326 | - Pixcir dual touch panels |
308 | - 'Sensing Win7-TwoFinger' panel by GeneralTouch | 327 | - 'Sensing Win7-TwoFinger' panel by GeneralTouch |
328 | - eGalax dual-touch panels, including the | ||
329 | Joojoo and Wetab tablets | ||
309 | 330 | ||
310 | If unsure, say N. | 331 | If unsure, say N. |
311 | 332 | ||
@@ -319,10 +340,10 @@ config HID_NTRIG | |||
319 | Support for N-Trig touch screen. | 340 | Support for N-Trig touch screen. |
320 | 341 | ||
321 | config HID_ORTEK | 342 | config HID_ORTEK |
322 | tristate "Ortek WKB-2000 wireless keyboard and mouse trackpad" | 343 | tristate "Ortek PKB-1700/WKB-2000 wireless keyboard and mouse trackpad" |
323 | depends on USB_HID | 344 | depends on USB_HID |
324 | ---help--- | 345 | ---help--- |
325 | Support for Ortek WKB-2000 wireless keyboard + mouse trackpad. | 346 | Support for Ortek PKB-1700/WKB-2000 wireless keyboard + mouse trackpad. |
326 | 347 | ||
327 | config HID_PANTHERLORD | 348 | config HID_PANTHERLORD |
328 | tristate "Pantherlord/GreenAsia game controller" | 349 | tristate "Pantherlord/GreenAsia game controller" |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index cb80181da905..06c68ae3abee 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -27,21 +27,22 @@ endif | |||
27 | 27 | ||
28 | obj-$(CONFIG_HID_3M_PCT) += hid-3m-pct.o | 28 | obj-$(CONFIG_HID_3M_PCT) += hid-3m-pct.o |
29 | obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o | 29 | obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o |
30 | obj-$(CONFIG_HID_ACRUX_FF) += hid-axff.o | 30 | obj-$(CONFIG_HID_ACRUX) += hid-axff.o |
31 | obj-$(CONFIG_HID_APPLE) += hid-apple.o | 31 | obj-$(CONFIG_HID_APPLE) += hid-apple.o |
32 | obj-$(CONFIG_HID_BELKIN) += hid-belkin.o | 32 | obj-$(CONFIG_HID_BELKIN) += hid-belkin.o |
33 | obj-$(CONFIG_HID_CANDO) += hid-cando.o | 33 | obj-$(CONFIG_HID_CANDO) += hid-cando.o |
34 | obj-$(CONFIG_HID_CHERRY) += hid-cherry.o | 34 | obj-$(CONFIG_HID_CHERRY) += hid-cherry.o |
35 | obj-$(CONFIG_HID_CHICONY) += hid-chicony.o | 35 | obj-$(CONFIG_HID_CHICONY) += hid-chicony.o |
36 | obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o | 36 | obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o |
37 | obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o | 37 | obj-$(CONFIG_HID_DRAGONRISE) += hid-dr.o |
38 | obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o | 38 | obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o |
39 | obj-$(CONFIG_HID_EGALAX) += hid-egalax.o | ||
40 | obj-$(CONFIG_HID_ELECOM) += hid-elecom.o | 39 | obj-$(CONFIG_HID_ELECOM) += hid-elecom.o |
41 | obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o | 40 | obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o |
42 | obj-$(CONFIG_HID_GYRATION) += hid-gyration.o | 41 | obj-$(CONFIG_HID_GYRATION) += hid-gyration.o |
43 | obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o | 42 | obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o |
43 | obj-$(CONFIG_HID_KEYTOUCH) += hid-keytouch.o | ||
44 | obj-$(CONFIG_HID_KYE) += hid-kye.o | 44 | obj-$(CONFIG_HID_KYE) += hid-kye.o |
45 | obj-$(CONFIG_HID_LCPOWER) += hid-lcpower.o | ||
45 | obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o | 46 | obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o |
46 | obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o | 47 | obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o |
47 | obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o | 48 | obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o |
diff --git a/drivers/hid/hid-axff.c b/drivers/hid/hid-axff.c index e5b961d6ff22..b4554288de00 100644 --- a/drivers/hid/hid-axff.c +++ b/drivers/hid/hid-axff.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/hid.h> | 33 | #include <linux/hid.h> |
34 | 34 | ||
35 | #include "hid-ids.h" | 35 | #include "hid-ids.h" |
36 | |||
37 | #ifdef CONFIG_HID_ACRUX_FF | ||
36 | #include "usbhid/usbhid.h" | 38 | #include "usbhid/usbhid.h" |
37 | 39 | ||
38 | struct axff_device { | 40 | struct axff_device { |
@@ -109,6 +111,12 @@ err_free_mem: | |||
109 | kfree(axff); | 111 | kfree(axff); |
110 | return error; | 112 | return error; |
111 | } | 113 | } |
114 | #else | ||
115 | static inline int axff_init(struct hid_device *hid) | ||
116 | { | ||
117 | return 0; | ||
118 | } | ||
119 | #endif | ||
112 | 120 | ||
113 | static int ax_probe(struct hid_device *hdev, const struct hid_device_id *id) | 121 | static int ax_probe(struct hid_device *hdev, const struct hid_device_id *id) |
114 | { | 122 | { |
@@ -139,9 +147,25 @@ static int ax_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
139 | error); | 147 | error); |
140 | } | 148 | } |
141 | 149 | ||
150 | /* | ||
151 | * We need to start polling device right away, otherwise | ||
152 | * it will go into a coma. | ||
153 | */ | ||
154 | error = hid_hw_open(hdev); | ||
155 | if (error) { | ||
156 | dev_err(&hdev->dev, "hw open failed\n"); | ||
157 | return error; | ||
158 | } | ||
159 | |||
142 | return 0; | 160 | return 0; |
143 | } | 161 | } |
144 | 162 | ||
163 | static void ax_remove(struct hid_device *hdev) | ||
164 | { | ||
165 | hid_hw_close(hdev); | ||
166 | hid_hw_stop(hdev); | ||
167 | } | ||
168 | |||
145 | static const struct hid_device_id ax_devices[] = { | 169 | static const struct hid_device_id ax_devices[] = { |
146 | { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802), }, | 170 | { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802), }, |
147 | { } | 171 | { } |
@@ -149,9 +173,10 @@ static const struct hid_device_id ax_devices[] = { | |||
149 | MODULE_DEVICE_TABLE(hid, ax_devices); | 173 | MODULE_DEVICE_TABLE(hid, ax_devices); |
150 | 174 | ||
151 | static struct hid_driver ax_driver = { | 175 | static struct hid_driver ax_driver = { |
152 | .name = "acrux", | 176 | .name = "acrux", |
153 | .id_table = ax_devices, | 177 | .id_table = ax_devices, |
154 | .probe = ax_probe, | 178 | .probe = ax_probe, |
179 | .remove = ax_remove, | ||
155 | }; | 180 | }; |
156 | 181 | ||
157 | static int __init ax_init(void) | 182 | static int __init ax_init(void) |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 0180f20d4fa7..c3d66269ed7d 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1159,6 +1159,32 @@ static bool hid_hiddev(struct hid_device *hdev) | |||
1159 | return !!hid_match_id(hdev, hid_hiddev_list); | 1159 | return !!hid_match_id(hdev, hid_hiddev_list); |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | |||
1163 | static ssize_t | ||
1164 | read_report_descriptor(struct file *filp, struct kobject *kobj, | ||
1165 | struct bin_attribute *attr, | ||
1166 | char *buf, loff_t off, size_t count) | ||
1167 | { | ||
1168 | struct device *dev = container_of(kobj, struct device, kobj); | ||
1169 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | ||
1170 | |||
1171 | if (off >= hdev->rsize) | ||
1172 | return 0; | ||
1173 | |||
1174 | if (off + count > hdev->rsize) | ||
1175 | count = hdev->rsize - off; | ||
1176 | |||
1177 | memcpy(buf, hdev->rdesc + off, count); | ||
1178 | |||
1179 | return count; | ||
1180 | } | ||
1181 | |||
1182 | static struct bin_attribute dev_bin_attr_report_desc = { | ||
1183 | .attr = { .name = "report_descriptor", .mode = 0444 }, | ||
1184 | .read = read_report_descriptor, | ||
1185 | .size = HID_MAX_DESCRIPTOR_SIZE, | ||
1186 | }; | ||
1187 | |||
1162 | int hid_connect(struct hid_device *hdev, unsigned int connect_mask) | 1188 | int hid_connect(struct hid_device *hdev, unsigned int connect_mask) |
1163 | { | 1189 | { |
1164 | static const char *types[] = { "Device", "Pointer", "Mouse", "Device", | 1190 | static const char *types[] = { "Device", "Pointer", "Mouse", "Device", |
@@ -1169,6 +1195,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) | |||
1169 | char buf[64]; | 1195 | char buf[64]; |
1170 | unsigned int i; | 1196 | unsigned int i; |
1171 | int len; | 1197 | int len; |
1198 | int ret; | ||
1172 | 1199 | ||
1173 | if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) | 1200 | if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE) |
1174 | connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); | 1201 | connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV); |
@@ -1230,6 +1257,11 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) | |||
1230 | bus = "<UNKNOWN>"; | 1257 | bus = "<UNKNOWN>"; |
1231 | } | 1258 | } |
1232 | 1259 | ||
1260 | ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc); | ||
1261 | if (ret) | ||
1262 | hid_warn(hdev, | ||
1263 | "can't create sysfs report descriptor attribute err: %d\n", ret); | ||
1264 | |||
1233 | hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", | 1265 | hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", |
1234 | buf, bus, hdev->version >> 8, hdev->version & 0xff, | 1266 | buf, bus, hdev->version >> 8, hdev->version & 0xff, |
1235 | type, hdev->name, hdev->phys); | 1267 | type, hdev->name, hdev->phys); |
@@ -1240,6 +1272,7 @@ EXPORT_SYMBOL_GPL(hid_connect); | |||
1240 | 1272 | ||
1241 | void hid_disconnect(struct hid_device *hdev) | 1273 | void hid_disconnect(struct hid_device *hdev) |
1242 | { | 1274 | { |
1275 | device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc); | ||
1243 | if (hdev->claimed & HID_CLAIMED_INPUT) | 1276 | if (hdev->claimed & HID_CLAIMED_INPUT) |
1244 | hidinput_disconnect(hdev); | 1277 | hidinput_disconnect(hdev); |
1245 | if (hdev->claimed & HID_CLAIMED_HIDDEV) | 1278 | if (hdev->claimed & HID_CLAIMED_HIDDEV) |
@@ -1256,9 +1289,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1256 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, | 1289 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, |
1257 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, | 1290 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, |
1258 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, | 1291 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, |
1259 | #if defined(CONFIG_HID_ACRUX_FF) || defined(CONFIG_HID_ACRUX_FF_MODULE) | ||
1260 | { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, | 1292 | { HID_USB_DEVICE(USB_VENDOR_ID_ACRUX, 0x0802) }, |
1261 | #endif | ||
1262 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, | 1293 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ATV_IRCONTROL) }, |
1263 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, | 1294 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, |
1264 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, | 1295 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, |
@@ -1328,6 +1359,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1328 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, | 1359 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, |
1329 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, | 1360 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, |
1330 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, | 1361 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, |
1362 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011) }, | ||
1331 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, | 1363 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, |
1332 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, | 1364 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, |
1333 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) }, | 1365 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) }, |
@@ -1345,9 +1377,12 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1345 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, | 1377 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_2) }, |
1346 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, | 1378 | { HID_USB_DEVICE(USB_VENDOR_ID_GYRATION, USB_DEVICE_ID_GYRATION_REMOTE_3) }, |
1347 | { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, | 1379 | { HID_USB_DEVICE(USB_VENDOR_ID_HANVON, USB_DEVICE_ID_HANVON_MULTITOUCH) }, |
1380 | { HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, | ||
1348 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, | 1381 | { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) }, |
1382 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, | ||
1349 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, | 1383 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_ERGO_525V) }, |
1350 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, | 1384 | { HID_USB_DEVICE(USB_VENDOR_ID_LABTEC, USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD) }, |
1385 | { HID_USB_DEVICE(USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000 ) }, | ||
1351 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, | 1386 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, |
1352 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, | 1387 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, |
1353 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, | 1388 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, |
@@ -1368,6 +1403,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1368 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, | 1403 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) }, |
1369 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, | 1404 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL) }, |
1370 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, | 1405 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2) }, |
1406 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL) }, | ||
1371 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, | 1407 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL) }, |
1372 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, | 1408 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL) }, |
1373 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, | 1409 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2) }, |
@@ -1400,6 +1436,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1400 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, | 1436 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16) }, |
1401 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, | 1437 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17) }, |
1402 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, | 1438 | { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18) }, |
1439 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) }, | ||
1403 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, | 1440 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, |
1404 | { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, | 1441 | { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, |
1405 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, | 1442 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, |
diff --git a/drivers/hid/hid-drff.c b/drivers/hid/hid-dr.c index afcf3d67eb02..61eece47204d 100644 --- a/drivers/hid/hid-drff.c +++ b/drivers/hid/hid-dr.c | |||
@@ -145,6 +145,110 @@ static inline int drff_init(struct hid_device *hid) | |||
145 | } | 145 | } |
146 | #endif | 146 | #endif |
147 | 147 | ||
148 | /* | ||
149 | * The original descriptor of joystick with PID 0x0011, represented by DVTech PC | ||
150 | * JS19. It seems both copied from another device and a result of confusion | ||
151 | * either about the specification or about the program used to create the | ||
152 | * descriptor. In any case, it's a wonder it works on Windows. | ||
153 | * | ||
154 | * Usage Page (Desktop), ; Generic desktop controls (01h) | ||
155 | * Usage (Joystik), ; Joystik (04h, application collection) | ||
156 | * Collection (Application), | ||
157 | * Collection (Logical), | ||
158 | * Report Size (8), | ||
159 | * Report Count (5), | ||
160 | * Logical Minimum (0), | ||
161 | * Logical Maximum (255), | ||
162 | * Physical Minimum (0), | ||
163 | * Physical Maximum (255), | ||
164 | * Usage (X), ; X (30h, dynamic value) | ||
165 | * Usage (X), ; X (30h, dynamic value) | ||
166 | * Usage (X), ; X (30h, dynamic value) | ||
167 | * Usage (X), ; X (30h, dynamic value) | ||
168 | * Usage (Y), ; Y (31h, dynamic value) | ||
169 | * Input (Variable), | ||
170 | * Report Size (4), | ||
171 | * Report Count (1), | ||
172 | * Logical Maximum (7), | ||
173 | * Physical Maximum (315), | ||
174 | * Unit (Degrees), | ||
175 | * Usage (00h), | ||
176 | * Input (Variable, Null State), | ||
177 | * Unit, | ||
178 | * Report Size (1), | ||
179 | * Report Count (10), | ||
180 | * Logical Maximum (1), | ||
181 | * Physical Maximum (1), | ||
182 | * Usage Page (Button), ; Button (09h) | ||
183 | * Usage Minimum (01h), | ||
184 | * Usage Maximum (0Ah), | ||
185 | * Input (Variable), | ||
186 | * Usage Page (FF00h), ; FF00h, vendor-defined | ||
187 | * Report Size (1), | ||
188 | * Report Count (10), | ||
189 | * Logical Maximum (1), | ||
190 | * Physical Maximum (1), | ||
191 | * Usage (01h), | ||
192 | * Input (Variable), | ||
193 | * End Collection, | ||
194 | * Collection (Logical), | ||
195 | * Report Size (8), | ||
196 | * Report Count (4), | ||
197 | * Physical Maximum (255), | ||
198 | * Logical Maximum (255), | ||
199 | * Usage (02h), | ||
200 | * Output (Variable), | ||
201 | * End Collection, | ||
202 | * End Collection | ||
203 | */ | ||
204 | |||
205 | /* Size of the original descriptor of the PID 0x0011 joystick */ | ||
206 | #define PID0011_RDESC_ORIG_SIZE 101 | ||
207 | |||
208 | /* Fixed report descriptor for PID 0x011 joystick */ | ||
209 | static __u8 pid0011_rdesc_fixed[] = { | ||
210 | 0x05, 0x01, /* Usage Page (Desktop), */ | ||
211 | 0x09, 0x04, /* Usage (Joystik), */ | ||
212 | 0xA1, 0x01, /* Collection (Application), */ | ||
213 | 0xA1, 0x02, /* Collection (Logical), */ | ||
214 | 0x14, /* Logical Minimum (0), */ | ||
215 | 0x75, 0x08, /* Report Size (8), */ | ||
216 | 0x95, 0x03, /* Report Count (3), */ | ||
217 | 0x81, 0x01, /* Input (Constant), */ | ||
218 | 0x26, 0xFF, 0x00, /* Logical Maximum (255), */ | ||
219 | 0x95, 0x02, /* Report Count (2), */ | ||
220 | 0x09, 0x30, /* Usage (X), */ | ||
221 | 0x09, 0x31, /* Usage (Y), */ | ||
222 | 0x81, 0x02, /* Input (Variable), */ | ||
223 | 0x75, 0x01, /* Report Size (1), */ | ||
224 | 0x95, 0x04, /* Report Count (4), */ | ||
225 | 0x81, 0x01, /* Input (Constant), */ | ||
226 | 0x25, 0x01, /* Logical Maximum (1), */ | ||
227 | 0x95, 0x0A, /* Report Count (10), */ | ||
228 | 0x05, 0x09, /* Usage Page (Button), */ | ||
229 | 0x19, 0x01, /* Usage Minimum (01h), */ | ||
230 | 0x29, 0x0A, /* Usage Maximum (0Ah), */ | ||
231 | 0x81, 0x02, /* Input (Variable), */ | ||
232 | 0x95, 0x0A, /* Report Count (10), */ | ||
233 | 0x81, 0x01, /* Input (Constant), */ | ||
234 | 0xC0, /* End Collection, */ | ||
235 | 0xC0 /* End Collection */ | ||
236 | }; | ||
237 | |||
238 | static __u8 *dr_report_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
239 | unsigned int *rsize) | ||
240 | { | ||
241 | switch (hdev->product) { | ||
242 | case 0x0011: | ||
243 | if (*rsize == PID0011_RDESC_ORIG_SIZE) { | ||
244 | rdesc = pid0011_rdesc_fixed; | ||
245 | *rsize = sizeof(pid0011_rdesc_fixed); | ||
246 | } | ||
247 | break; | ||
248 | } | ||
249 | return rdesc; | ||
250 | } | ||
251 | |||
148 | static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id) | 252 | static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id) |
149 | { | 253 | { |
150 | int ret; | 254 | int ret; |
@@ -163,7 +267,16 @@ static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
163 | goto err; | 267 | goto err; |
164 | } | 268 | } |
165 | 269 | ||
166 | drff_init(hdev); | 270 | switch (hdev->product) { |
271 | case 0x0006: | ||
272 | ret = drff_init(hdev); | ||
273 | if (ret) { | ||
274 | dev_err(&hdev->dev, "force feedback init failed\n"); | ||
275 | hid_hw_stop(hdev); | ||
276 | goto err; | ||
277 | } | ||
278 | break; | ||
279 | } | ||
167 | 280 | ||
168 | return 0; | 281 | return 0; |
169 | err: | 282 | err: |
@@ -172,6 +285,7 @@ err: | |||
172 | 285 | ||
173 | static const struct hid_device_id dr_devices[] = { | 286 | static const struct hid_device_id dr_devices[] = { |
174 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006), }, | 287 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006), }, |
288 | { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011), }, | ||
175 | { } | 289 | { } |
176 | }; | 290 | }; |
177 | MODULE_DEVICE_TABLE(hid, dr_devices); | 291 | MODULE_DEVICE_TABLE(hid, dr_devices); |
@@ -179,6 +293,7 @@ MODULE_DEVICE_TABLE(hid, dr_devices); | |||
179 | static struct hid_driver dr_driver = { | 293 | static struct hid_driver dr_driver = { |
180 | .name = "dragonrise", | 294 | .name = "dragonrise", |
181 | .id_table = dr_devices, | 295 | .id_table = dr_devices, |
296 | .report_fixup = dr_report_fixup, | ||
182 | .probe = dr_probe, | 297 | .probe = dr_probe, |
183 | }; | 298 | }; |
184 | 299 | ||
diff --git a/drivers/hid/hid-egalax.c b/drivers/hid/hid-egalax.c deleted file mode 100644 index 03bee1970d70..000000000000 --- a/drivers/hid/hid-egalax.c +++ /dev/null | |||
@@ -1,279 +0,0 @@ | |||
1 | /* | ||
2 | * HID driver for eGalax dual-touch panels | ||
3 | * | ||
4 | * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr> | ||
5 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> | ||
6 | * Copyright (c) 2010 Canonical, Ltd. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License as published by the Free | ||
13 | * Software Foundation; either version 2 of the License, or (at your option) | ||
14 | * any later version. | ||
15 | */ | ||
16 | |||
17 | #include <linux/device.h> | ||
18 | #include <linux/hid.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/usb.h> | ||
21 | #include <linux/input/mt.h> | ||
22 | #include <linux/slab.h> | ||
23 | #include "usbhid/usbhid.h" | ||
24 | |||
25 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); | ||
26 | MODULE_DESCRIPTION("eGalax dual-touch panel"); | ||
27 | MODULE_LICENSE("GPL"); | ||
28 | |||
29 | #include "hid-ids.h" | ||
30 | |||
31 | #define MAX_SLOTS 2 | ||
32 | |||
33 | /* estimated signal-to-noise ratios */ | ||
34 | #define SN_MOVE 4096 | ||
35 | #define SN_PRESSURE 32 | ||
36 | |||
37 | struct egalax_data { | ||
38 | int valid; | ||
39 | int slot; | ||
40 | int touch; | ||
41 | int x, y, z; | ||
42 | }; | ||
43 | |||
44 | static void set_abs(struct input_dev *input, unsigned int code, | ||
45 | struct hid_field *field, int snratio) | ||
46 | { | ||
47 | int fmin = field->logical_minimum; | ||
48 | int fmax = field->logical_maximum; | ||
49 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; | ||
50 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | ||
51 | } | ||
52 | |||
53 | static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
54 | struct hid_field *field, struct hid_usage *usage, | ||
55 | unsigned long **bit, int *max) | ||
56 | { | ||
57 | struct input_dev *input = hi->input; | ||
58 | |||
59 | switch (usage->hid & HID_USAGE_PAGE) { | ||
60 | |||
61 | case HID_UP_GENDESK: | ||
62 | switch (usage->hid) { | ||
63 | case HID_GD_X: | ||
64 | field->logical_maximum = 32760; | ||
65 | hid_map_usage(hi, usage, bit, max, | ||
66 | EV_ABS, ABS_MT_POSITION_X); | ||
67 | set_abs(input, ABS_MT_POSITION_X, field, SN_MOVE); | ||
68 | /* touchscreen emulation */ | ||
69 | set_abs(input, ABS_X, field, SN_MOVE); | ||
70 | return 1; | ||
71 | case HID_GD_Y: | ||
72 | field->logical_maximum = 32760; | ||
73 | hid_map_usage(hi, usage, bit, max, | ||
74 | EV_ABS, ABS_MT_POSITION_Y); | ||
75 | set_abs(input, ABS_MT_POSITION_Y, field, SN_MOVE); | ||
76 | /* touchscreen emulation */ | ||
77 | set_abs(input, ABS_Y, field, SN_MOVE); | ||
78 | return 1; | ||
79 | } | ||
80 | return 0; | ||
81 | |||
82 | case HID_UP_DIGITIZER: | ||
83 | switch (usage->hid) { | ||
84 | case HID_DG_TIPSWITCH: | ||
85 | /* touchscreen emulation */ | ||
86 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); | ||
87 | input_set_capability(input, EV_KEY, BTN_TOUCH); | ||
88 | return 1; | ||
89 | case HID_DG_INRANGE: | ||
90 | case HID_DG_CONFIDENCE: | ||
91 | case HID_DG_CONTACTCOUNT: | ||
92 | case HID_DG_CONTACTMAX: | ||
93 | return -1; | ||
94 | case HID_DG_CONTACTID: | ||
95 | input_mt_init_slots(input, MAX_SLOTS); | ||
96 | return 1; | ||
97 | case HID_DG_TIPPRESSURE: | ||
98 | field->logical_minimum = 0; | ||
99 | hid_map_usage(hi, usage, bit, max, | ||
100 | EV_ABS, ABS_MT_PRESSURE); | ||
101 | set_abs(input, ABS_MT_PRESSURE, field, SN_PRESSURE); | ||
102 | /* touchscreen emulation */ | ||
103 | set_abs(input, ABS_PRESSURE, field, SN_PRESSURE); | ||
104 | return 1; | ||
105 | } | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | /* ignore others (from other reports we won't get anyway) */ | ||
110 | return -1; | ||
111 | } | ||
112 | |||
113 | static int egalax_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
114 | struct hid_field *field, struct hid_usage *usage, | ||
115 | unsigned long **bit, int *max) | ||
116 | { | ||
117 | /* tell hid-input to skip setup of these event types */ | ||
118 | if (usage->type == EV_KEY || usage->type == EV_ABS) | ||
119 | set_bit(usage->type, hi->input->evbit); | ||
120 | return -1; | ||
121 | } | ||
122 | |||
123 | /* | ||
124 | * this function is called when a whole finger has been parsed, | ||
125 | * so that it can decide what to send to the input layer. | ||
126 | */ | ||
127 | static void egalax_filter_event(struct egalax_data *td, struct input_dev *input) | ||
128 | { | ||
129 | input_mt_slot(input, td->slot); | ||
130 | input_mt_report_slot_state(input, MT_TOOL_FINGER, td->touch); | ||
131 | if (td->touch) { | ||
132 | input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x); | ||
133 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y); | ||
134 | input_event(input, EV_ABS, ABS_MT_PRESSURE, td->z); | ||
135 | } | ||
136 | input_mt_report_pointer_emulation(input, true); | ||
137 | } | ||
138 | |||
139 | static int egalax_event(struct hid_device *hid, struct hid_field *field, | ||
140 | struct hid_usage *usage, __s32 value) | ||
141 | { | ||
142 | struct egalax_data *td = hid_get_drvdata(hid); | ||
143 | |||
144 | /* Note, eGalax has two product lines: the first is resistive and | ||
145 | * uses a standard parallel multitouch protocol (product ID == | ||
146 | * 48xx). The second is capacitive and uses an unusual "serial" | ||
147 | * protocol with a different message for each multitouch finger | ||
148 | * (product ID == 72xx). | ||
149 | */ | ||
150 | if (hid->claimed & HID_CLAIMED_INPUT) { | ||
151 | struct input_dev *input = field->hidinput->input; | ||
152 | |||
153 | switch (usage->hid) { | ||
154 | case HID_DG_INRANGE: | ||
155 | td->valid = value; | ||
156 | break; | ||
157 | case HID_DG_CONFIDENCE: | ||
158 | /* avoid interference from generic hidinput handling */ | ||
159 | break; | ||
160 | case HID_DG_TIPSWITCH: | ||
161 | td->touch = value; | ||
162 | break; | ||
163 | case HID_DG_TIPPRESSURE: | ||
164 | td->z = value; | ||
165 | break; | ||
166 | case HID_DG_CONTACTID: | ||
167 | td->slot = clamp_val(value, 0, MAX_SLOTS - 1); | ||
168 | break; | ||
169 | case HID_GD_X: | ||
170 | td->x = value; | ||
171 | break; | ||
172 | case HID_GD_Y: | ||
173 | td->y = value; | ||
174 | /* this is the last field in a finger */ | ||
175 | if (td->valid) | ||
176 | egalax_filter_event(td, input); | ||
177 | break; | ||
178 | case HID_DG_CONTACTCOUNT: | ||
179 | /* touch emulation: this is the last field in a frame */ | ||
180 | break; | ||
181 | |||
182 | default: | ||
183 | /* fallback to the generic hidinput handling */ | ||
184 | return 0; | ||
185 | } | ||
186 | } | ||
187 | |||
188 | /* we have handled the hidinput part, now remains hiddev */ | ||
189 | if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event) | ||
190 | hid->hiddev_hid_event(hid, field, usage, value); | ||
191 | |||
192 | return 1; | ||
193 | } | ||
194 | |||
195 | static int egalax_probe(struct hid_device *hdev, const struct hid_device_id *id) | ||
196 | { | ||
197 | int ret; | ||
198 | struct egalax_data *td; | ||
199 | struct hid_report *report; | ||
200 | |||
201 | td = kzalloc(sizeof(struct egalax_data), GFP_KERNEL); | ||
202 | if (!td) { | ||
203 | hid_err(hdev, "cannot allocate eGalax data\n"); | ||
204 | return -ENOMEM; | ||
205 | } | ||
206 | hid_set_drvdata(hdev, td); | ||
207 | |||
208 | ret = hid_parse(hdev); | ||
209 | if (ret) | ||
210 | goto end; | ||
211 | |||
212 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | ||
213 | if (ret) | ||
214 | goto end; | ||
215 | |||
216 | report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[5]; | ||
217 | if (report) { | ||
218 | report->field[0]->value[0] = 2; | ||
219 | usbhid_submit_report(hdev, report, USB_DIR_OUT); | ||
220 | } | ||
221 | |||
222 | end: | ||
223 | if (ret) | ||
224 | kfree(td); | ||
225 | |||
226 | return ret; | ||
227 | } | ||
228 | |||
229 | static void egalax_remove(struct hid_device *hdev) | ||
230 | { | ||
231 | hid_hw_stop(hdev); | ||
232 | kfree(hid_get_drvdata(hdev)); | ||
233 | hid_set_drvdata(hdev, NULL); | ||
234 | } | ||
235 | |||
236 | static const struct hid_device_id egalax_devices[] = { | ||
237 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
238 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, | ||
239 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
240 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, | ||
241 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
242 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) }, | ||
243 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
244 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) }, | ||
245 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
246 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, | ||
247 | { } | ||
248 | }; | ||
249 | MODULE_DEVICE_TABLE(hid, egalax_devices); | ||
250 | |||
251 | static const struct hid_usage_id egalax_grabbed_usages[] = { | ||
252 | { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID }, | ||
253 | { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} | ||
254 | }; | ||
255 | |||
256 | static struct hid_driver egalax_driver = { | ||
257 | .name = "egalax-touch", | ||
258 | .id_table = egalax_devices, | ||
259 | .probe = egalax_probe, | ||
260 | .remove = egalax_remove, | ||
261 | .input_mapping = egalax_input_mapping, | ||
262 | .input_mapped = egalax_input_mapped, | ||
263 | .usage_table = egalax_grabbed_usages, | ||
264 | .event = egalax_event, | ||
265 | }; | ||
266 | |||
267 | static int __init egalax_init(void) | ||
268 | { | ||
269 | return hid_register_driver(&egalax_driver); | ||
270 | } | ||
271 | |||
272 | static void __exit egalax_exit(void) | ||
273 | { | ||
274 | hid_unregister_driver(&egalax_driver); | ||
275 | } | ||
276 | |||
277 | module_init(egalax_init); | ||
278 | module_exit(egalax_exit); | ||
279 | |||
diff --git a/drivers/hid/hid-gyration.c b/drivers/hid/hid-gyration.c index 3975e039c3dd..e88b951cd10d 100644 --- a/drivers/hid/hid-gyration.c +++ b/drivers/hid/hid-gyration.c | |||
@@ -43,6 +43,11 @@ static int gyration_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
43 | case 0x048: gy_map_key_clear(KEY_MEDIA); break; | 43 | case 0x048: gy_map_key_clear(KEY_MEDIA); break; |
44 | case 0x049: gy_map_key_clear(KEY_CAMERA); break; | 44 | case 0x049: gy_map_key_clear(KEY_CAMERA); break; |
45 | case 0x04a: gy_map_key_clear(KEY_VIDEO); break; | 45 | case 0x04a: gy_map_key_clear(KEY_VIDEO); break; |
46 | case 0x05a: gy_map_key_clear(KEY_TEXT); break; | ||
47 | case 0x05b: gy_map_key_clear(KEY_RED); break; | ||
48 | case 0x05c: gy_map_key_clear(KEY_GREEN); break; | ||
49 | case 0x05d: gy_map_key_clear(KEY_YELLOW); break; | ||
50 | case 0x05e: gy_map_key_clear(KEY_BLUE); break; | ||
46 | 51 | ||
47 | default: | 52 | default: |
48 | return 0; | 53 | return 0; |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 75f2e1430a55..d485894ff4db 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -333,6 +333,9 @@ | |||
333 | #define USB_VENDOR_ID_IMATION 0x0718 | 333 | #define USB_VENDOR_ID_IMATION 0x0718 |
334 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 | 334 | #define USB_DEVICE_ID_DISC_STAKKA 0xd000 |
335 | 335 | ||
336 | #define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615 | ||
337 | #define USB_DEVICE_ID_IRTOUCH_INFRARED_USB 0x0070 | ||
338 | |||
336 | #define USB_VENDOR_ID_JESS 0x0c45 | 339 | #define USB_VENDOR_ID_JESS 0x0c45 |
337 | #define USB_DEVICE_ID_JESS_YUREX 0x1010 | 340 | #define USB_DEVICE_ID_JESS_YUREX 0x1010 |
338 | 341 | ||
@@ -345,6 +348,9 @@ | |||
345 | #define USB_VENDOR_ID_KWORLD 0x1b80 | 348 | #define USB_VENDOR_ID_KWORLD 0x1b80 |
346 | #define USB_DEVICE_ID_KWORLD_RADIO_FM700 0xd700 | 349 | #define USB_DEVICE_ID_KWORLD_RADIO_FM700 0xd700 |
347 | 350 | ||
351 | #define USB_VENDOR_ID_KEYTOUCH 0x0926 | ||
352 | #define USB_DEVICE_ID_KEYTOUCH_IEC 0x3333 | ||
353 | |||
348 | #define USB_VENDOR_ID_KYE 0x0458 | 354 | #define USB_VENDOR_ID_KYE 0x0458 |
349 | #define USB_DEVICE_ID_KYE_ERGO_525V 0x0087 | 355 | #define USB_DEVICE_ID_KYE_ERGO_525V 0x0087 |
350 | #define USB_DEVICE_ID_KYE_GPEN_560 0x5003 | 356 | #define USB_DEVICE_ID_KYE_GPEN_560 0x5003 |
@@ -352,6 +358,9 @@ | |||
352 | #define USB_VENDOR_ID_LABTEC 0x1020 | 358 | #define USB_VENDOR_ID_LABTEC 0x1020 |
353 | #define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 | 359 | #define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 |
354 | 360 | ||
361 | #define USB_VENDOR_ID_LCPOWER 0x1241 | ||
362 | #define USB_DEVICE_ID_LCPOWER_LC1000 0xf767 | ||
363 | |||
355 | #define USB_VENDOR_ID_LD 0x0f11 | 364 | #define USB_VENDOR_ID_LD 0x0f11 |
356 | #define USB_DEVICE_ID_LD_CASSY 0x1000 | 365 | #define USB_DEVICE_ID_LD_CASSY 0x1000 |
357 | #define USB_DEVICE_ID_LD_POCKETCASSY 0x1010 | 366 | #define USB_DEVICE_ID_LD_POCKETCASSY 0x1010 |
@@ -383,6 +392,7 @@ | |||
383 | #define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 | 392 | #define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 |
384 | #define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG 0xc293 | 393 | #define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG 0xc293 |
385 | #define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295 | 394 | #define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295 |
395 | #define USB_DEVICE_ID_LOGITECH_DFP_WHEEL 0xc298 | ||
386 | #define USB_DEVICE_ID_LOGITECH_G25_WHEEL 0xc299 | 396 | #define USB_DEVICE_ID_LOGITECH_G25_WHEEL 0xc299 |
387 | #define USB_DEVICE_ID_LOGITECH_WII_WHEEL 0xc29c | 397 | #define USB_DEVICE_ID_LOGITECH_WII_WHEEL 0xc29c |
388 | #define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a | 398 | #define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a |
@@ -466,6 +476,7 @@ | |||
466 | #define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 | 476 | #define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 |
467 | 477 | ||
468 | #define USB_VENDOR_ID_ORTEK 0x05a4 | 478 | #define USB_VENDOR_ID_ORTEK 0x05a4 |
479 | #define USB_DEVICE_ID_ORTEK_PKB1700 0x1700 | ||
469 | #define USB_DEVICE_ID_ORTEK_WKB2000 0x2000 | 480 | #define USB_DEVICE_ID_ORTEK_WKB2000 0x2000 |
470 | 481 | ||
471 | #define USB_VENDOR_ID_PANJIT 0x134c | 482 | #define USB_VENDOR_ID_PANJIT 0x134c |
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 7f552bfad32c..cd74203c8178 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -290,14 +290,6 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
290 | goto ignore; | 290 | goto ignore; |
291 | } | 291 | } |
292 | 292 | ||
293 | if (field->report_type == HID_FEATURE_REPORT) { | ||
294 | if (device->driver->feature_mapping) { | ||
295 | device->driver->feature_mapping(device, hidinput, field, | ||
296 | usage); | ||
297 | } | ||
298 | goto ignore; | ||
299 | } | ||
300 | |||
301 | if (device->driver->input_mapping) { | 293 | if (device->driver->input_mapping) { |
302 | int ret = device->driver->input_mapping(device, hidinput, field, | 294 | int ret = device->driver->input_mapping(device, hidinput, field, |
303 | usage, &bit, &max); | 295 | usage, &bit, &max); |
@@ -835,6 +827,24 @@ static void hidinput_close(struct input_dev *dev) | |||
835 | hid_hw_close(hid); | 827 | hid_hw_close(hid); |
836 | } | 828 | } |
837 | 829 | ||
830 | static void report_features(struct hid_device *hid) | ||
831 | { | ||
832 | struct hid_driver *drv = hid->driver; | ||
833 | struct hid_report_enum *rep_enum; | ||
834 | struct hid_report *rep; | ||
835 | int i, j; | ||
836 | |||
837 | if (!drv->feature_mapping) | ||
838 | return; | ||
839 | |||
840 | rep_enum = &hid->report_enum[HID_FEATURE_REPORT]; | ||
841 | list_for_each_entry(rep, &rep_enum->report_list, list) | ||
842 | for (i = 0; i < rep->maxfield; i++) | ||
843 | for (j = 0; j < rep->field[i]->maxusage; j++) | ||
844 | drv->feature_mapping(hid, rep->field[i], | ||
845 | rep->field[i]->usage + j); | ||
846 | } | ||
847 | |||
838 | /* | 848 | /* |
839 | * Register the input device; print a message. | 849 | * Register the input device; print a message. |
840 | * Configure the input layer interface | 850 | * Configure the input layer interface |
@@ -863,7 +873,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
863 | return -1; | 873 | return -1; |
864 | } | 874 | } |
865 | 875 | ||
866 | for (k = HID_INPUT_REPORT; k <= HID_FEATURE_REPORT; k++) { | 876 | report_features(hid); |
877 | |||
878 | for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) { | ||
867 | if (k == HID_OUTPUT_REPORT && | 879 | if (k == HID_OUTPUT_REPORT && |
868 | hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) | 880 | hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS) |
869 | continue; | 881 | continue; |
@@ -928,6 +940,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
928 | return 0; | 940 | return 0; |
929 | 941 | ||
930 | out_cleanup: | 942 | out_cleanup: |
943 | list_del(&hidinput->list); | ||
931 | input_free_device(hidinput->input); | 944 | input_free_device(hidinput->input); |
932 | kfree(hidinput); | 945 | kfree(hidinput); |
933 | out_unwind: | 946 | out_unwind: |
diff --git a/drivers/hid/hid-keytouch.c b/drivers/hid/hid-keytouch.c new file mode 100644 index 000000000000..07cd825f6f01 --- /dev/null +++ b/drivers/hid/hid-keytouch.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * HID driver for Keytouch devices not fully compliant with HID standard | ||
3 | * | ||
4 | * Copyright (c) 2011 Jiri Kosina | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the Free | ||
10 | * Software Foundation; either version 2 of the License, or (at your option) | ||
11 | * any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/device.h> | ||
15 | #include <linux/hid.h> | ||
16 | #include <linux/module.h> | ||
17 | |||
18 | #include "hid-ids.h" | ||
19 | |||
20 | /* Replace the broken report descriptor of this device with rather | ||
21 | * a default one */ | ||
22 | static __u8 keytouch_fixed_rdesc[] = { | ||
23 | 0x05, 0x01, 0x09, 0x06, 0xa1, 0x01, 0x05, 0x07, 0x19, 0xe0, 0x29, 0xe7, 0x15, | ||
24 | 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02, 0x95, 0x01, 0x75, 0x08, | ||
25 | 0x81, 0x01, 0x95, 0x03, 0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x03, 0x91, | ||
26 | 0x02, 0x95, 0x05, 0x75, 0x01, 0x91, 0x01, 0x95, 0x06, 0x75, 0x08, 0x15, 0x00, | ||
27 | 0x26, 0xff, 0x00, 0x05, 0x07, 0x19, 0x00, 0x2a, 0xff, 0x00, 0x81, 0x00, 0xc0 | ||
28 | }; | ||
29 | |||
30 | static __u8 *keytouch_report_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
31 | unsigned int *rsize) | ||
32 | { | ||
33 | hid_info(hdev, "fixing up Keytouch IEC report descriptor\n"); | ||
34 | |||
35 | rdesc = keytouch_fixed_rdesc; | ||
36 | *rsize = sizeof(keytouch_fixed_rdesc); | ||
37 | |||
38 | return rdesc; | ||
39 | } | ||
40 | |||
41 | static const struct hid_device_id keytouch_devices[] = { | ||
42 | { HID_USB_DEVICE(USB_VENDOR_ID_KEYTOUCH, USB_DEVICE_ID_KEYTOUCH_IEC) }, | ||
43 | { } | ||
44 | }; | ||
45 | MODULE_DEVICE_TABLE(hid, keytouch_devices); | ||
46 | |||
47 | static struct hid_driver keytouch_driver = { | ||
48 | .name = "keytouch", | ||
49 | .id_table = keytouch_devices, | ||
50 | .report_fixup = keytouch_report_fixup, | ||
51 | }; | ||
52 | |||
53 | static int __init keytouch_init(void) | ||
54 | { | ||
55 | return hid_register_driver(&keytouch_driver); | ||
56 | } | ||
57 | |||
58 | static void __exit keytouch_exit(void) | ||
59 | { | ||
60 | hid_unregister_driver(&keytouch_driver); | ||
61 | } | ||
62 | |||
63 | module_init(keytouch_init); | ||
64 | module_exit(keytouch_exit); | ||
65 | MODULE_LICENSE("GPL"); | ||
66 | MODULE_AUTHOR("Jiri Kosina"); | ||
diff --git a/drivers/hid/hid-lcpower.c b/drivers/hid/hid-lcpower.c new file mode 100644 index 000000000000..c4fe9bd095b7 --- /dev/null +++ b/drivers/hid/hid-lcpower.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * HID driver for LC Power Model RC1000MCE | ||
3 | * | ||
4 | * Copyright (c) 2011 Chris Schlund | ||
5 | * based on hid-topseed module | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the Free | ||
11 | * Software Foundation; either version 2 of the License, or (at your option) | ||
12 | * any later version. | ||
13 | */ | ||
14 | |||
15 | #include <linux/device.h> | ||
16 | #include <linux/hid.h> | ||
17 | #include <linux/module.h> | ||
18 | |||
19 | #include "hid-ids.h" | ||
20 | |||
21 | #define ts_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ | ||
22 | EV_KEY, (c)) | ||
23 | static int ts_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
24 | struct hid_field *field, struct hid_usage *usage, | ||
25 | unsigned long **bit, int *max) | ||
26 | { | ||
27 | if ((usage->hid & HID_USAGE_PAGE) != 0x0ffbc0000) | ||
28 | return 0; | ||
29 | |||
30 | switch (usage->hid & HID_USAGE) { | ||
31 | case 0x046: ts_map_key_clear(KEY_YELLOW); break; | ||
32 | case 0x047: ts_map_key_clear(KEY_GREEN); break; | ||
33 | case 0x049: ts_map_key_clear(KEY_BLUE); break; | ||
34 | case 0x04a: ts_map_key_clear(KEY_RED); break; | ||
35 | case 0x00d: ts_map_key_clear(KEY_HOME); break; | ||
36 | case 0x025: ts_map_key_clear(KEY_TV); break; | ||
37 | case 0x048: ts_map_key_clear(KEY_VCR); break; | ||
38 | case 0x024: ts_map_key_clear(KEY_MENU); break; | ||
39 | default: | ||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | return 1; | ||
44 | } | ||
45 | |||
46 | static const struct hid_device_id ts_devices[] = { | ||
47 | { HID_USB_DEVICE( USB_VENDOR_ID_LCPOWER, USB_DEVICE_ID_LCPOWER_LC1000) }, | ||
48 | { } | ||
49 | }; | ||
50 | MODULE_DEVICE_TABLE(hid, ts_devices); | ||
51 | |||
52 | static struct hid_driver ts_driver = { | ||
53 | .name = "LC RC1000MCE", | ||
54 | .id_table = ts_devices, | ||
55 | .input_mapping = ts_input_mapping, | ||
56 | }; | ||
57 | |||
58 | static int __init ts_init(void) | ||
59 | { | ||
60 | return hid_register_driver(&ts_driver); | ||
61 | } | ||
62 | |||
63 | static void __exit ts_exit(void) | ||
64 | { | ||
65 | hid_unregister_driver(&ts_driver); | ||
66 | } | ||
67 | |||
68 | module_init(ts_init); | ||
69 | module_exit(ts_exit); | ||
70 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c index aef4104da141..3da90402ee81 100644 --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c | |||
@@ -377,6 +377,8 @@ static const struct hid_device_id lg_devices[] = { | |||
377 | .driver_data = LG_FF }, | 377 | .driver_data = LG_FF }, |
378 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL), | 378 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G25_WHEEL), |
379 | .driver_data = LG_FF }, | 379 | .driver_data = LG_FF }, |
380 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_DFP_WHEEL), | ||
381 | .driver_data = LG_FF }, | ||
380 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL), | 382 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL), |
381 | .driver_data = LG_FF4 }, | 383 | .driver_data = LG_FF4 }, |
382 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ), | 384 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG ), |
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 698e6459fd0b..318cc40df92d 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c | |||
@@ -258,7 +258,7 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda | |||
258 | input_report_abs(input, ABS_MT_TRACKING_ID, id); | 258 | input_report_abs(input, ABS_MT_TRACKING_ID, id); |
259 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, touch_major << 2); | 259 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, touch_major << 2); |
260 | input_report_abs(input, ABS_MT_TOUCH_MINOR, touch_minor << 2); | 260 | input_report_abs(input, ABS_MT_TOUCH_MINOR, touch_minor << 2); |
261 | input_report_abs(input, ABS_MT_ORIENTATION, orientation); | 261 | input_report_abs(input, ABS_MT_ORIENTATION, -orientation); |
262 | input_report_abs(input, ABS_MT_POSITION_X, x); | 262 | input_report_abs(input, ABS_MT_POSITION_X, x); |
263 | input_report_abs(input, ABS_MT_POSITION_Y, y); | 263 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
264 | 264 | ||
@@ -397,7 +397,7 @@ static void magicmouse_setup_input(struct input_dev *input, struct hid_device *h | |||
397 | input_set_abs_params(input, ABS_MT_TRACKING_ID, 0, 15, 0, 0); | 397 | input_set_abs_params(input, ABS_MT_TRACKING_ID, 0, 15, 0, 0); |
398 | input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 4, 0); | 398 | input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255, 4, 0); |
399 | input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 255, 4, 0); | 399 | input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 255, 4, 0); |
400 | input_set_abs_params(input, ABS_MT_ORIENTATION, -32, 31, 1, 0); | 400 | input_set_abs_params(input, ABS_MT_ORIENTATION, -31, 32, 1, 0); |
401 | 401 | ||
402 | /* Note: Touch Y position from the device is inverted relative | 402 | /* Note: Touch Y position from the device is inverted relative |
403 | * to how pointer motion is reported (and relative to how USB | 403 | * to how pointer motion is reported (and relative to how USB |
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index 07d3183fdde5..ee01e65e22d6 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
@@ -5,6 +5,12 @@ | |||
5 | * Copyright (c) 2010-2011 Benjamin Tissoires <benjamin.tissoires@gmail.com> | 5 | * Copyright (c) 2010-2011 Benjamin Tissoires <benjamin.tissoires@gmail.com> |
6 | * Copyright (c) 2010-2011 Ecole Nationale de l'Aviation Civile, France | 6 | * Copyright (c) 2010-2011 Ecole Nationale de l'Aviation Civile, France |
7 | * | 7 | * |
8 | * This code is partly based on hid-egalax.c: | ||
9 | * | ||
10 | * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr> | ||
11 | * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se> | ||
12 | * Copyright (c) 2010 Canonical, Ltd. | ||
13 | * | ||
8 | */ | 14 | */ |
9 | 15 | ||
10 | /* | 16 | /* |
@@ -24,6 +30,7 @@ | |||
24 | 30 | ||
25 | 31 | ||
26 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); | 32 | MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>"); |
33 | MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); | ||
27 | MODULE_DESCRIPTION("HID multitouch panels"); | 34 | MODULE_DESCRIPTION("HID multitouch panels"); |
28 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
29 | 36 | ||
@@ -36,6 +43,7 @@ MODULE_LICENSE("GPL"); | |||
36 | #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3) | 43 | #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3) |
37 | #define MT_QUIRK_VALID_IS_INRANGE (1 << 4) | 44 | #define MT_QUIRK_VALID_IS_INRANGE (1 << 4) |
38 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 5) | 45 | #define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 5) |
46 | #define MT_QUIRK_EGALAX_XYZ_FIXUP (1 << 6) | ||
39 | 47 | ||
40 | struct mt_slot { | 48 | struct mt_slot { |
41 | __s32 x, y, p, w, h; | 49 | __s32 x, y, p, w, h; |
@@ -65,10 +73,11 @@ struct mt_class { | |||
65 | }; | 73 | }; |
66 | 74 | ||
67 | /* classes of device behavior */ | 75 | /* classes of device behavior */ |
68 | #define MT_CLS_DEFAULT 1 | 76 | #define MT_CLS_DEFAULT 1 |
69 | #define MT_CLS_DUAL1 2 | 77 | #define MT_CLS_DUAL_INRANGE_CONTACTID 2 |
70 | #define MT_CLS_DUAL2 3 | 78 | #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 3 |
71 | #define MT_CLS_CYPRESS 4 | 79 | #define MT_CLS_CYPRESS 4 |
80 | #define MT_CLS_EGALAX 5 | ||
72 | 81 | ||
73 | /* | 82 | /* |
74 | * these device-dependent functions determine what slot corresponds | 83 | * these device-dependent functions determine what slot corresponds |
@@ -104,13 +113,13 @@ static int find_slot_from_contactid(struct mt_device *td) | |||
104 | 113 | ||
105 | struct mt_class mt_classes[] = { | 114 | struct mt_class mt_classes[] = { |
106 | { .name = MT_CLS_DEFAULT, | 115 | { .name = MT_CLS_DEFAULT, |
107 | .quirks = MT_QUIRK_VALID_IS_INRANGE, | 116 | .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP, |
108 | .maxcontacts = 10 }, | 117 | .maxcontacts = 10 }, |
109 | { .name = MT_CLS_DUAL1, | 118 | { .name = MT_CLS_DUAL_INRANGE_CONTACTID, |
110 | .quirks = MT_QUIRK_VALID_IS_INRANGE | | 119 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
111 | MT_QUIRK_SLOT_IS_CONTACTID, | 120 | MT_QUIRK_SLOT_IS_CONTACTID, |
112 | .maxcontacts = 2 }, | 121 | .maxcontacts = 2 }, |
113 | { .name = MT_CLS_DUAL2, | 122 | { .name = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
114 | .quirks = MT_QUIRK_VALID_IS_INRANGE | | 123 | .quirks = MT_QUIRK_VALID_IS_INRANGE | |
115 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, | 124 | MT_QUIRK_SLOT_IS_CONTACTNUMBER, |
116 | .maxcontacts = 2 }, | 125 | .maxcontacts = 2 }, |
@@ -119,10 +128,18 @@ struct mt_class mt_classes[] = { | |||
119 | MT_QUIRK_CYPRESS, | 128 | MT_QUIRK_CYPRESS, |
120 | .maxcontacts = 10 }, | 129 | .maxcontacts = 10 }, |
121 | 130 | ||
131 | { .name = MT_CLS_EGALAX, | ||
132 | .quirks = MT_QUIRK_SLOT_IS_CONTACTID | | ||
133 | MT_QUIRK_VALID_IS_INRANGE | | ||
134 | MT_QUIRK_EGALAX_XYZ_FIXUP, | ||
135 | .maxcontacts = 2, | ||
136 | .sn_move = 4096, | ||
137 | .sn_pressure = 32, | ||
138 | }, | ||
122 | { } | 139 | { } |
123 | }; | 140 | }; |
124 | 141 | ||
125 | static void mt_feature_mapping(struct hid_device *hdev, struct hid_input *hi, | 142 | static void mt_feature_mapping(struct hid_device *hdev, |
126 | struct hid_field *field, struct hid_usage *usage) | 143 | struct hid_field *field, struct hid_usage *usage) |
127 | { | 144 | { |
128 | if (usage->hid == HID_DG_INPUTMODE) { | 145 | if (usage->hid == HID_DG_INPUTMODE) { |
@@ -146,11 +163,15 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
146 | { | 163 | { |
147 | struct mt_device *td = hid_get_drvdata(hdev); | 164 | struct mt_device *td = hid_get_drvdata(hdev); |
148 | struct mt_class *cls = td->mtclass; | 165 | struct mt_class *cls = td->mtclass; |
166 | __s32 quirks = cls->quirks; | ||
167 | |||
149 | switch (usage->hid & HID_USAGE_PAGE) { | 168 | switch (usage->hid & HID_USAGE_PAGE) { |
150 | 169 | ||
151 | case HID_UP_GENDESK: | 170 | case HID_UP_GENDESK: |
152 | switch (usage->hid) { | 171 | switch (usage->hid) { |
153 | case HID_GD_X: | 172 | case HID_GD_X: |
173 | if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP) | ||
174 | field->logical_maximum = 32760; | ||
154 | hid_map_usage(hi, usage, bit, max, | 175 | hid_map_usage(hi, usage, bit, max, |
155 | EV_ABS, ABS_MT_POSITION_X); | 176 | EV_ABS, ABS_MT_POSITION_X); |
156 | set_abs(hi->input, ABS_MT_POSITION_X, field, | 177 | set_abs(hi->input, ABS_MT_POSITION_X, field, |
@@ -160,6 +181,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
160 | td->last_slot_field = usage->hid; | 181 | td->last_slot_field = usage->hid; |
161 | return 1; | 182 | return 1; |
162 | case HID_GD_Y: | 183 | case HID_GD_Y: |
184 | if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP) | ||
185 | field->logical_maximum = 32760; | ||
163 | hid_map_usage(hi, usage, bit, max, | 186 | hid_map_usage(hi, usage, bit, max, |
164 | EV_ABS, ABS_MT_POSITION_Y); | 187 | EV_ABS, ABS_MT_POSITION_Y); |
165 | set_abs(hi->input, ABS_MT_POSITION_Y, field, | 188 | set_abs(hi->input, ABS_MT_POSITION_Y, field, |
@@ -203,6 +226,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
203 | td->last_slot_field = usage->hid; | 226 | td->last_slot_field = usage->hid; |
204 | return 1; | 227 | return 1; |
205 | case HID_DG_TIPPRESSURE: | 228 | case HID_DG_TIPPRESSURE: |
229 | if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP) | ||
230 | field->logical_minimum = 0; | ||
206 | hid_map_usage(hi, usage, bit, max, | 231 | hid_map_usage(hi, usage, bit, max, |
207 | EV_ABS, ABS_MT_PRESSURE); | 232 | EV_ABS, ABS_MT_PRESSURE); |
208 | set_abs(hi->input, ABS_MT_PRESSURE, field, | 233 | set_abs(hi->input, ABS_MT_PRESSURE, field, |
@@ -363,8 +388,11 @@ static int mt_event(struct hid_device *hid, struct hid_field *field, | |||
363 | return 0; | 388 | return 0; |
364 | } | 389 | } |
365 | 390 | ||
366 | if (usage->hid == td->last_slot_field) | 391 | if (usage->hid == td->last_slot_field) { |
367 | mt_complete_slot(td); | 392 | mt_complete_slot(td); |
393 | if (!td->last_field_index) | ||
394 | mt_emit_event(td, field->hidinput->input); | ||
395 | } | ||
368 | 396 | ||
369 | if (field->index == td->last_field_index | 397 | if (field->index == td->last_field_index |
370 | && td->num_received >= td->num_expected) | 398 | && td->num_received >= td->num_expected) |
@@ -466,18 +494,42 @@ static const struct hid_device_id mt_devices[] = { | |||
466 | USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, | 494 | USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, |
467 | 495 | ||
468 | /* GeneralTouch panel */ | 496 | /* GeneralTouch panel */ |
469 | { .driver_data = MT_CLS_DUAL2, | 497 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER, |
470 | HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, | 498 | HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, |
471 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, | 499 | USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS) }, |
472 | 500 | ||
501 | /* IRTOUCH panels */ | ||
502 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, | ||
503 | HID_USB_DEVICE(USB_VENDOR_ID_IRTOUCHSYSTEMS, | ||
504 | USB_DEVICE_ID_IRTOUCH_INFRARED_USB) }, | ||
505 | |||
473 | /* PixCir-based panels */ | 506 | /* PixCir-based panels */ |
474 | { .driver_data = MT_CLS_DUAL1, | 507 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
475 | HID_USB_DEVICE(USB_VENDOR_ID_HANVON, | 508 | HID_USB_DEVICE(USB_VENDOR_ID_HANVON, |
476 | USB_DEVICE_ID_HANVON_MULTITOUCH) }, | 509 | USB_DEVICE_ID_HANVON_MULTITOUCH) }, |
477 | { .driver_data = MT_CLS_DUAL1, | 510 | { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTID, |
478 | HID_USB_DEVICE(USB_VENDOR_ID_CANDO, | 511 | HID_USB_DEVICE(USB_VENDOR_ID_CANDO, |
479 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, | 512 | USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, |
480 | 513 | ||
514 | /* Resistive eGalax devices */ | ||
515 | { .driver_data = MT_CLS_EGALAX, | ||
516 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
517 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) }, | ||
518 | { .driver_data = MT_CLS_EGALAX, | ||
519 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
520 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) }, | ||
521 | |||
522 | /* Capacitive eGalax devices */ | ||
523 | { .driver_data = MT_CLS_EGALAX, | ||
524 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
525 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) }, | ||
526 | { .driver_data = MT_CLS_EGALAX, | ||
527 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
528 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) }, | ||
529 | { .driver_data = MT_CLS_EGALAX, | ||
530 | HID_USB_DEVICE(USB_VENDOR_ID_DWAV, | ||
531 | USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, | ||
532 | |||
481 | { } | 533 | { } |
482 | }; | 534 | }; |
483 | MODULE_DEVICE_TABLE(hid, mt_devices); | 535 | MODULE_DEVICE_TABLE(hid, mt_devices); |
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index beb403421e72..9fae2ebdd758 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c | |||
@@ -110,6 +110,36 @@ static int ntrig_version_string(unsigned char *raw, char *buf) | |||
110 | return sprintf(buf, "%u.%u.%u.%u.%u", a, b, c, d, e); | 110 | return sprintf(buf, "%u.%u.%u.%u.%u", a, b, c, d, e); |
111 | } | 111 | } |
112 | 112 | ||
113 | static inline int ntrig_get_mode(struct hid_device *hdev) | ||
114 | { | ||
115 | struct hid_report *report = hdev->report_enum[HID_FEATURE_REPORT]. | ||
116 | report_id_hash[0x0d]; | ||
117 | |||
118 | if (!report) | ||
119 | return -EINVAL; | ||
120 | |||
121 | usbhid_submit_report(hdev, report, USB_DIR_IN); | ||
122 | usbhid_wait_io(hdev); | ||
123 | return (int)report->field[0]->value[0]; | ||
124 | } | ||
125 | |||
126 | static inline void ntrig_set_mode(struct hid_device *hdev, const int mode) | ||
127 | { | ||
128 | struct hid_report *report; | ||
129 | __u8 mode_commands[4] = { 0xe, 0xf, 0x1b, 0x10 }; | ||
130 | |||
131 | if (mode < 0 || mode > 3) | ||
132 | return; | ||
133 | |||
134 | report = hdev->report_enum[HID_FEATURE_REPORT]. | ||
135 | report_id_hash[mode_commands[mode]]; | ||
136 | |||
137 | if (!report) | ||
138 | return; | ||
139 | |||
140 | usbhid_submit_report(hdev, report, USB_DIR_IN); | ||
141 | } | ||
142 | |||
113 | static void ntrig_report_version(struct hid_device *hdev) | 143 | static void ntrig_report_version(struct hid_device *hdev) |
114 | { | 144 | { |
115 | int ret; | 145 | int ret; |
@@ -539,277 +569,288 @@ static int ntrig_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |||
539 | static int ntrig_event (struct hid_device *hid, struct hid_field *field, | 569 | static int ntrig_event (struct hid_device *hid, struct hid_field *field, |
540 | struct hid_usage *usage, __s32 value) | 570 | struct hid_usage *usage, __s32 value) |
541 | { | 571 | { |
542 | struct input_dev *input = field->hidinput->input; | ||
543 | struct ntrig_data *nd = hid_get_drvdata(hid); | 572 | struct ntrig_data *nd = hid_get_drvdata(hid); |
573 | struct input_dev *input; | ||
574 | |||
575 | /* Skip processing if not a claimed input */ | ||
576 | if (!(hid->claimed & HID_CLAIMED_INPUT)) | ||
577 | goto not_claimed_input; | ||
578 | |||
579 | /* This function is being called before the structures are fully | ||
580 | * initialized */ | ||
581 | if(!(field->hidinput && field->hidinput->input)) | ||
582 | return -EINVAL; | ||
583 | |||
584 | input = field->hidinput->input; | ||
544 | 585 | ||
545 | /* No special handling needed for the pen */ | 586 | /* No special handling needed for the pen */ |
546 | if (field->application == HID_DG_PEN) | 587 | if (field->application == HID_DG_PEN) |
547 | return 0; | 588 | return 0; |
548 | 589 | ||
549 | if (hid->claimed & HID_CLAIMED_INPUT) { | 590 | switch (usage->hid) { |
550 | switch (usage->hid) { | 591 | case 0xff000001: |
551 | case 0xff000001: | 592 | /* Tag indicating the start of a multitouch group */ |
552 | /* Tag indicating the start of a multitouch group */ | 593 | nd->reading_mt = 1; |
553 | nd->reading_mt = 1; | 594 | nd->first_contact_touch = 0; |
554 | nd->first_contact_touch = 0; | 595 | break; |
555 | break; | 596 | case HID_DG_TIPSWITCH: |
556 | case HID_DG_TIPSWITCH: | 597 | nd->tipswitch = value; |
557 | nd->tipswitch = value; | 598 | /* Prevent emission of touch until validated */ |
558 | /* Prevent emission of touch until validated */ | 599 | return 1; |
559 | return 1; | 600 | case HID_DG_CONFIDENCE: |
560 | case HID_DG_CONFIDENCE: | 601 | nd->confidence = value; |
561 | nd->confidence = value; | 602 | break; |
562 | break; | 603 | case HID_GD_X: |
563 | case HID_GD_X: | 604 | nd->x = value; |
564 | nd->x = value; | 605 | /* Clear the contact footer */ |
565 | /* Clear the contact footer */ | 606 | nd->mt_foot_count = 0; |
566 | nd->mt_foot_count = 0; | 607 | break; |
567 | break; | 608 | case HID_GD_Y: |
568 | case HID_GD_Y: | 609 | nd->y = value; |
569 | nd->y = value; | 610 | break; |
570 | break; | 611 | case HID_DG_CONTACTID: |
571 | case HID_DG_CONTACTID: | 612 | nd->id = value; |
572 | nd->id = value; | 613 | break; |
573 | break; | 614 | case HID_DG_WIDTH: |
574 | case HID_DG_WIDTH: | 615 | nd->w = value; |
575 | nd->w = value; | 616 | break; |
576 | break; | 617 | case HID_DG_HEIGHT: |
577 | case HID_DG_HEIGHT: | 618 | nd->h = value; |
578 | nd->h = value; | 619 | /* |
620 | * when in single touch mode, this is the last | ||
621 | * report received in a finger event. We want | ||
622 | * to emit a normal (X, Y) position | ||
623 | */ | ||
624 | if (!nd->reading_mt) { | ||
579 | /* | 625 | /* |
580 | * when in single touch mode, this is the last | 626 | * TipSwitch indicates the presence of a |
581 | * report received in a finger event. We want | 627 | * finger in single touch mode. |
582 | * to emit a normal (X, Y) position | ||
583 | */ | 628 | */ |
584 | if (!nd->reading_mt) { | 629 | input_report_key(input, BTN_TOUCH, |
585 | /* | 630 | nd->tipswitch); |
586 | * TipSwitch indicates the presence of a | 631 | input_report_key(input, BTN_TOOL_DOUBLETAP, |
587 | * finger in single touch mode. | 632 | nd->tipswitch); |
588 | */ | 633 | input_event(input, EV_ABS, ABS_X, nd->x); |
589 | input_report_key(input, BTN_TOUCH, | 634 | input_event(input, EV_ABS, ABS_Y, nd->y); |
590 | nd->tipswitch); | 635 | } |
591 | input_report_key(input, BTN_TOOL_DOUBLETAP, | 636 | break; |
592 | nd->tipswitch); | 637 | case 0xff000002: |
593 | input_event(input, EV_ABS, ABS_X, nd->x); | 638 | /* |
594 | input_event(input, EV_ABS, ABS_Y, nd->y); | 639 | * we receive this when the device is in multitouch |
595 | } | 640 | * mode. The first of the three values tagged with |
641 | * this usage tells if the contact point is real | ||
642 | * or a placeholder | ||
643 | */ | ||
644 | |||
645 | /* Shouldn't get more than 4 footer packets, so skip */ | ||
646 | if (nd->mt_foot_count >= 4) | ||
596 | break; | 647 | break; |
597 | case 0xff000002: | ||
598 | /* | ||
599 | * we receive this when the device is in multitouch | ||
600 | * mode. The first of the three values tagged with | ||
601 | * this usage tells if the contact point is real | ||
602 | * or a placeholder | ||
603 | */ | ||
604 | 648 | ||
605 | /* Shouldn't get more than 4 footer packets, so skip */ | 649 | nd->mt_footer[nd->mt_foot_count++] = value; |
606 | if (nd->mt_foot_count >= 4) | ||
607 | break; | ||
608 | 650 | ||
609 | nd->mt_footer[nd->mt_foot_count++] = value; | 651 | /* if the footer isn't complete break */ |
652 | if (nd->mt_foot_count != 4) | ||
653 | break; | ||
610 | 654 | ||
611 | /* if the footer isn't complete break */ | 655 | /* Pen activity signal. */ |
612 | if (nd->mt_foot_count != 4) | 656 | if (nd->mt_footer[2]) { |
613 | break; | 657 | /* |
658 | * When the pen deactivates touch, we see a | ||
659 | * bogus frame with ContactCount > 0. | ||
660 | * We can | ||
661 | * save a bit of work by ensuring act_state < 0 | ||
662 | * even if deactivation slack is turned off. | ||
663 | */ | ||
664 | nd->act_state = deactivate_slack - 1; | ||
665 | nd->confidence = 0; | ||
666 | break; | ||
667 | } | ||
614 | 668 | ||
615 | /* Pen activity signal. */ | 669 | /* |
616 | if (nd->mt_footer[2]) { | 670 | * The first footer value indicates the presence of a |
617 | /* | 671 | * finger. |
618 | * When the pen deactivates touch, we see a | 672 | */ |
619 | * bogus frame with ContactCount > 0. | 673 | if (nd->mt_footer[0]) { |
620 | * We can | 674 | /* |
621 | * save a bit of work by ensuring act_state < 0 | 675 | * We do not want to process contacts under |
622 | * even if deactivation slack is turned off. | 676 | * the size threshold, but do not want to |
623 | */ | 677 | * ignore them for activation state |
624 | nd->act_state = deactivate_slack - 1; | 678 | */ |
679 | if (nd->w < nd->min_width || | ||
680 | nd->h < nd->min_height) | ||
625 | nd->confidence = 0; | 681 | nd->confidence = 0; |
626 | break; | 682 | } else |
627 | } | 683 | break; |
628 | 684 | ||
685 | if (nd->act_state > 0) { | ||
629 | /* | 686 | /* |
630 | * The first footer value indicates the presence of a | 687 | * Contact meets the activation size threshold |
631 | * finger. | ||
632 | */ | 688 | */ |
633 | if (nd->mt_footer[0]) { | 689 | if (nd->w >= nd->activation_width && |
634 | /* | 690 | nd->h >= nd->activation_height) { |
635 | * We do not want to process contacts under | 691 | if (nd->id) |
636 | * the size threshold, but do not want to | ||
637 | * ignore them for activation state | ||
638 | */ | ||
639 | if (nd->w < nd->min_width || | ||
640 | nd->h < nd->min_height) | ||
641 | nd->confidence = 0; | ||
642 | } else | ||
643 | break; | ||
644 | |||
645 | if (nd->act_state > 0) { | ||
646 | /* | ||
647 | * Contact meets the activation size threshold | ||
648 | */ | ||
649 | if (nd->w >= nd->activation_width && | ||
650 | nd->h >= nd->activation_height) { | ||
651 | if (nd->id) | ||
652 | /* | ||
653 | * first contact, activate now | ||
654 | */ | ||
655 | nd->act_state = 0; | ||
656 | else { | ||
657 | /* | ||
658 | * avoid corrupting this frame | ||
659 | * but ensure next frame will | ||
660 | * be active | ||
661 | */ | ||
662 | nd->act_state = 1; | ||
663 | break; | ||
664 | } | ||
665 | } else | ||
666 | /* | 692 | /* |
667 | * Defer adjusting the activation state | 693 | * first contact, activate now |
668 | * until the end of the frame. | ||
669 | */ | 694 | */ |
695 | nd->act_state = 0; | ||
696 | else { | ||
697 | /* | ||
698 | * avoid corrupting this frame | ||
699 | * but ensure next frame will | ||
700 | * be active | ||
701 | */ | ||
702 | nd->act_state = 1; | ||
670 | break; | 703 | break; |
671 | } | 704 | } |
672 | 705 | } else | |
673 | /* Discarding this contact */ | ||
674 | if (!nd->confidence) | ||
675 | break; | ||
676 | |||
677 | /* emit a normal (X, Y) for the first point only */ | ||
678 | if (nd->id == 0) { | ||
679 | /* | 706 | /* |
680 | * TipSwitch is superfluous in multitouch | 707 | * Defer adjusting the activation state |
681 | * mode. The footer events tell us | 708 | * until the end of the frame. |
682 | * if there is a finger on the screen or | ||
683 | * not. | ||
684 | */ | 709 | */ |
685 | nd->first_contact_touch = nd->confidence; | 710 | break; |
686 | input_event(input, EV_ABS, ABS_X, nd->x); | 711 | } |
687 | input_event(input, EV_ABS, ABS_Y, nd->y); | ||
688 | } | ||
689 | 712 | ||
690 | /* Emit MT events */ | 713 | /* Discarding this contact */ |
691 | input_event(input, EV_ABS, ABS_MT_POSITION_X, nd->x); | 714 | if (!nd->confidence) |
692 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, nd->y); | 715 | break; |
693 | 716 | ||
717 | /* emit a normal (X, Y) for the first point only */ | ||
718 | if (nd->id == 0) { | ||
694 | /* | 719 | /* |
695 | * Translate from height and width to size | 720 | * TipSwitch is superfluous in multitouch |
696 | * and orientation. | 721 | * mode. The footer events tell us |
722 | * if there is a finger on the screen or | ||
723 | * not. | ||
697 | */ | 724 | */ |
698 | if (nd->w > nd->h) { | 725 | nd->first_contact_touch = nd->confidence; |
699 | input_event(input, EV_ABS, | 726 | input_event(input, EV_ABS, ABS_X, nd->x); |
700 | ABS_MT_ORIENTATION, 1); | 727 | input_event(input, EV_ABS, ABS_Y, nd->y); |
701 | input_event(input, EV_ABS, | 728 | } |
702 | ABS_MT_TOUCH_MAJOR, nd->w); | ||
703 | input_event(input, EV_ABS, | ||
704 | ABS_MT_TOUCH_MINOR, nd->h); | ||
705 | } else { | ||
706 | input_event(input, EV_ABS, | ||
707 | ABS_MT_ORIENTATION, 0); | ||
708 | input_event(input, EV_ABS, | ||
709 | ABS_MT_TOUCH_MAJOR, nd->h); | ||
710 | input_event(input, EV_ABS, | ||
711 | ABS_MT_TOUCH_MINOR, nd->w); | ||
712 | } | ||
713 | input_mt_sync(field->hidinput->input); | ||
714 | break; | ||
715 | 729 | ||
716 | case HID_DG_CONTACTCOUNT: /* End of a multitouch group */ | 730 | /* Emit MT events */ |
717 | if (!nd->reading_mt) /* Just to be sure */ | 731 | input_event(input, EV_ABS, ABS_MT_POSITION_X, nd->x); |
718 | break; | 732 | input_event(input, EV_ABS, ABS_MT_POSITION_Y, nd->y); |
733 | |||
734 | /* | ||
735 | * Translate from height and width to size | ||
736 | * and orientation. | ||
737 | */ | ||
738 | if (nd->w > nd->h) { | ||
739 | input_event(input, EV_ABS, | ||
740 | ABS_MT_ORIENTATION, 1); | ||
741 | input_event(input, EV_ABS, | ||
742 | ABS_MT_TOUCH_MAJOR, nd->w); | ||
743 | input_event(input, EV_ABS, | ||
744 | ABS_MT_TOUCH_MINOR, nd->h); | ||
745 | } else { | ||
746 | input_event(input, EV_ABS, | ||
747 | ABS_MT_ORIENTATION, 0); | ||
748 | input_event(input, EV_ABS, | ||
749 | ABS_MT_TOUCH_MAJOR, nd->h); | ||
750 | input_event(input, EV_ABS, | ||
751 | ABS_MT_TOUCH_MINOR, nd->w); | ||
752 | } | ||
753 | input_mt_sync(field->hidinput->input); | ||
754 | break; | ||
719 | 755 | ||
720 | nd->reading_mt = 0; | 756 | case HID_DG_CONTACTCOUNT: /* End of a multitouch group */ |
757 | if (!nd->reading_mt) /* Just to be sure */ | ||
758 | break; | ||
721 | 759 | ||
760 | nd->reading_mt = 0; | ||
761 | |||
762 | |||
763 | /* | ||
764 | * Activation state machine logic: | ||
765 | * | ||
766 | * Fundamental states: | ||
767 | * state > 0: Inactive | ||
768 | * state <= 0: Active | ||
769 | * state < -deactivate_slack: | ||
770 | * Pen termination of touch | ||
771 | * | ||
772 | * Specific values of interest | ||
773 | * state == activate_slack | ||
774 | * no valid input since the last reset | ||
775 | * | ||
776 | * state == 0 | ||
777 | * general operational state | ||
778 | * | ||
779 | * state == -deactivate_slack | ||
780 | * read sufficient empty frames to accept | ||
781 | * the end of input and reset | ||
782 | */ | ||
783 | |||
784 | if (nd->act_state > 0) { /* Currently inactive */ | ||
785 | if (value) | ||
786 | /* | ||
787 | * Consider each live contact as | ||
788 | * evidence of intentional activity. | ||
789 | */ | ||
790 | nd->act_state = (nd->act_state > value) | ||
791 | ? nd->act_state - value | ||
792 | : 0; | ||
793 | else | ||
794 | /* | ||
795 | * Empty frame before we hit the | ||
796 | * activity threshold, reset. | ||
797 | */ | ||
798 | nd->act_state = nd->activate_slack; | ||
722 | 799 | ||
723 | /* | 800 | /* |
724 | * Activation state machine logic: | 801 | * Entered this block inactive and no |
725 | * | 802 | * coordinates sent this frame, so hold off |
726 | * Fundamental states: | 803 | * on button state. |
727 | * state > 0: Inactive | ||
728 | * state <= 0: Active | ||
729 | * state < -deactivate_slack: | ||
730 | * Pen termination of touch | ||
731 | * | ||
732 | * Specific values of interest | ||
733 | * state == activate_slack | ||
734 | * no valid input since the last reset | ||
735 | * | ||
736 | * state == 0 | ||
737 | * general operational state | ||
738 | * | ||
739 | * state == -deactivate_slack | ||
740 | * read sufficient empty frames to accept | ||
741 | * the end of input and reset | ||
742 | */ | 804 | */ |
743 | 805 | break; | |
744 | if (nd->act_state > 0) { /* Currently inactive */ | 806 | } else { /* Currently active */ |
745 | if (value) | 807 | if (value && nd->act_state >= |
746 | /* | 808 | nd->deactivate_slack) |
747 | * Consider each live contact as | ||
748 | * evidence of intentional activity. | ||
749 | */ | ||
750 | nd->act_state = (nd->act_state > value) | ||
751 | ? nd->act_state - value | ||
752 | : 0; | ||
753 | else | ||
754 | /* | ||
755 | * Empty frame before we hit the | ||
756 | * activity threshold, reset. | ||
757 | */ | ||
758 | nd->act_state = nd->activate_slack; | ||
759 | |||
760 | /* | 809 | /* |
761 | * Entered this block inactive and no | 810 | * Live point: clear accumulated |
762 | * coordinates sent this frame, so hold off | 811 | * deactivation count. |
763 | * on button state. | ||
764 | */ | 812 | */ |
765 | break; | 813 | nd->act_state = 0; |
766 | } else { /* Currently active */ | 814 | else if (nd->act_state <= nd->deactivate_slack) |
767 | if (value && nd->act_state >= | ||
768 | nd->deactivate_slack) | ||
769 | /* | ||
770 | * Live point: clear accumulated | ||
771 | * deactivation count. | ||
772 | */ | ||
773 | nd->act_state = 0; | ||
774 | else if (nd->act_state <= nd->deactivate_slack) | ||
775 | /* | ||
776 | * We've consumed the deactivation | ||
777 | * slack, time to deactivate and reset. | ||
778 | */ | ||
779 | nd->act_state = | ||
780 | nd->activate_slack; | ||
781 | else { /* Move towards deactivation */ | ||
782 | nd->act_state--; | ||
783 | break; | ||
784 | } | ||
785 | } | ||
786 | |||
787 | if (nd->first_contact_touch && nd->act_state <= 0) { | ||
788 | /* | 815 | /* |
789 | * Check to see if we're ready to start | 816 | * We've consumed the deactivation |
790 | * emitting touch events. | 817 | * slack, time to deactivate and reset. |
791 | * | ||
792 | * Note: activation slack will decrease over | ||
793 | * the course of the frame, and it will be | ||
794 | * inconsistent from the start to the end of | ||
795 | * the frame. However if the frame starts | ||
796 | * with slack, first_contact_touch will still | ||
797 | * be 0 and we will not get to this point. | ||
798 | */ | 818 | */ |
799 | input_report_key(input, BTN_TOOL_DOUBLETAP, 1); | 819 | nd->act_state = |
800 | input_report_key(input, BTN_TOUCH, 1); | 820 | nd->activate_slack; |
801 | } else { | 821 | else { /* Move towards deactivation */ |
802 | input_report_key(input, BTN_TOOL_DOUBLETAP, 0); | 822 | nd->act_state--; |
803 | input_report_key(input, BTN_TOUCH, 0); | 823 | break; |
804 | } | 824 | } |
805 | break; | 825 | } |
806 | 826 | ||
807 | default: | 827 | if (nd->first_contact_touch && nd->act_state <= 0) { |
808 | /* fall-back to the generic hidinput handling */ | 828 | /* |
809 | return 0; | 829 | * Check to see if we're ready to start |
830 | * emitting touch events. | ||
831 | * | ||
832 | * Note: activation slack will decrease over | ||
833 | * the course of the frame, and it will be | ||
834 | * inconsistent from the start to the end of | ||
835 | * the frame. However if the frame starts | ||
836 | * with slack, first_contact_touch will still | ||
837 | * be 0 and we will not get to this point. | ||
838 | */ | ||
839 | input_report_key(input, BTN_TOOL_DOUBLETAP, 1); | ||
840 | input_report_key(input, BTN_TOUCH, 1); | ||
841 | } else { | ||
842 | input_report_key(input, BTN_TOOL_DOUBLETAP, 0); | ||
843 | input_report_key(input, BTN_TOUCH, 0); | ||
810 | } | 844 | } |
845 | break; | ||
846 | |||
847 | default: | ||
848 | /* fall-back to the generic hidinput handling */ | ||
849 | return 0; | ||
811 | } | 850 | } |
812 | 851 | ||
852 | not_claimed_input: | ||
853 | |||
813 | /* we have handled the hidinput part, now remains hiddev */ | 854 | /* we have handled the hidinput part, now remains hiddev */ |
814 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event) | 855 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_hid_event) |
815 | hid->hiddev_hid_event(hid, field, usage, value); | 856 | hid->hiddev_hid_event(hid, field, usage, value); |
@@ -826,7 +867,8 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
826 | struct hid_report *report; | 867 | struct hid_report *report; |
827 | 868 | ||
828 | if (id->driver_data) | 869 | if (id->driver_data) |
829 | hdev->quirks |= HID_QUIRK_MULTI_INPUT; | 870 | hdev->quirks |= HID_QUIRK_MULTI_INPUT |
871 | | HID_QUIRK_NO_INIT_REPORTS; | ||
830 | 872 | ||
831 | nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL); | 873 | nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL); |
832 | if (!nd) { | 874 | if (!nd) { |
@@ -893,8 +935,19 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
893 | 935 | ||
894 | /* This is needed for devices with more recent firmware versions */ | 936 | /* This is needed for devices with more recent firmware versions */ |
895 | report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a]; | 937 | report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0x0a]; |
896 | if (report) | 938 | if (report) { |
897 | usbhid_submit_report(hdev, report, USB_DIR_OUT); | 939 | /* Let the device settle to ensure the wakeup message gets |
940 | * through */ | ||
941 | usbhid_wait_io(hdev); | ||
942 | usbhid_submit_report(hdev, report, USB_DIR_IN); | ||
943 | |||
944 | /* | ||
945 | * Sanity check: if the current mode is invalid reset it to | ||
946 | * something reasonable. | ||
947 | */ | ||
948 | if (ntrig_get_mode(hdev) >= 4) | ||
949 | ntrig_set_mode(hdev, 3); | ||
950 | } | ||
898 | 951 | ||
899 | ntrig_report_version(hdev); | 952 | ntrig_report_version(hdev); |
900 | 953 | ||
diff --git a/drivers/hid/hid-ortek.c b/drivers/hid/hid-ortek.c index e90edfc63051..f9b7dd4f607f 100644 --- a/drivers/hid/hid-ortek.c +++ b/drivers/hid/hid-ortek.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * HID driver for Ortek WKB-2000 (wireless keyboard + mouse trackpad). | 2 | * HID driver for Ortek PKB-1700/WKB-2000 (wireless keyboard + mouse trackpad). |
3 | * Fixes LogicalMaximum error in USB report description, see | 3 | * Fixes LogicalMaximum error in HID report description. |
4 | * http://bugzilla.kernel.org/show_bug.cgi?id=14787 | ||
5 | * | 4 | * |
6 | * Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com> | 5 | * Copyright (c) 2010 Johnathon Harris <jmharris@gmail.com> |
7 | */ | 6 | */ |
@@ -30,6 +29,7 @@ static __u8 *ortek_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
30 | } | 29 | } |
31 | 30 | ||
32 | static const struct hid_device_id ortek_devices[] = { | 31 | static const struct hid_device_id ortek_devices[] = { |
32 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_PKB1700) }, | ||
33 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, | 33 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, |
34 | { } | 34 | { } |
35 | }; | 35 | }; |
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 68d7b36e31e4..93819a08121a 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
@@ -46,6 +46,16 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
46 | return rdesc; | 46 | return rdesc; |
47 | } | 47 | } |
48 | 48 | ||
49 | /* | ||
50 | * The Sony Sixaxis does not handle HID Output Reports on the Interrupt EP | ||
51 | * like it should according to usbhid/hid-core.c::usbhid_output_raw_report() | ||
52 | * so we need to override that forcing HID Output Reports on the Control EP. | ||
53 | * | ||
54 | * There is also another issue about HID Output Reports via USB, the Sixaxis | ||
55 | * does not want the report_id as part of the data packet, so we have to | ||
56 | * discard buf[0] when sending the actual control message, even for numbered | ||
57 | * reports, humpf! | ||
58 | */ | ||
49 | static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, | 59 | static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, |
50 | size_t count, unsigned char report_type) | 60 | size_t count, unsigned char report_type) |
51 | { | 61 | { |
@@ -55,6 +65,12 @@ static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, | |||
55 | int report_id = buf[0]; | 65 | int report_id = buf[0]; |
56 | int ret; | 66 | int ret; |
57 | 67 | ||
68 | if (report_type == HID_OUTPUT_REPORT) { | ||
69 | /* Don't send the Report ID */ | ||
70 | buf++; | ||
71 | count--; | ||
72 | } | ||
73 | |||
58 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 74 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), |
59 | HID_REQ_SET_REPORT, | 75 | HID_REQ_SET_REPORT, |
60 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | 76 | USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, |
@@ -62,6 +78,10 @@ static int sixaxis_usb_output_raw_report(struct hid_device *hid, __u8 *buf, | |||
62 | interface->desc.bInterfaceNumber, buf, count, | 78 | interface->desc.bInterfaceNumber, buf, count, |
63 | USB_CTRL_SET_TIMEOUT); | 79 | USB_CTRL_SET_TIMEOUT); |
64 | 80 | ||
81 | /* Count also the Report ID, in case of an Output report. */ | ||
82 | if (ret > 0 && report_type == HID_OUTPUT_REPORT) | ||
83 | ret++; | ||
84 | |||
65 | return ret; | 85 | return ret; |
66 | } | 86 | } |
67 | 87 | ||
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 468e87b53ed2..54409cba018c 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -91,7 +91,7 @@ static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, | |||
91 | ret = -EFAULT; | 91 | ret = -EFAULT; |
92 | goto out; | 92 | goto out; |
93 | } | 93 | } |
94 | ret += len; | 94 | ret = len; |
95 | 95 | ||
96 | kfree(list->buffer[list->tail].value); | 96 | kfree(list->buffer[list->tail].value); |
97 | list->tail = (list->tail + 1) & (HIDRAW_BUFFER_SIZE - 1); | 97 | list->tail = (list->tail + 1) & (HIDRAW_BUFFER_SIZE - 1); |
@@ -102,15 +102,14 @@ out: | |||
102 | } | 102 | } |
103 | 103 | ||
104 | /* the first byte is expected to be a report number */ | 104 | /* the first byte is expected to be a report number */ |
105 | static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) | 105 | /* This function is to be called with the minors_lock mutex held */ |
106 | static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, size_t count, unsigned char report_type) | ||
106 | { | 107 | { |
107 | unsigned int minor = iminor(file->f_path.dentry->d_inode); | 108 | unsigned int minor = iminor(file->f_path.dentry->d_inode); |
108 | struct hid_device *dev; | 109 | struct hid_device *dev; |
109 | __u8 *buf; | 110 | __u8 *buf; |
110 | int ret = 0; | 111 | int ret = 0; |
111 | 112 | ||
112 | mutex_lock(&minors_lock); | ||
113 | |||
114 | if (!hidraw_table[minor]) { | 113 | if (!hidraw_table[minor]) { |
115 | ret = -ENODEV; | 114 | ret = -ENODEV; |
116 | goto out; | 115 | goto out; |
@@ -148,14 +147,92 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t | |||
148 | goto out_free; | 147 | goto out_free; |
149 | } | 148 | } |
150 | 149 | ||
151 | ret = dev->hid_output_raw_report(dev, buf, count, HID_OUTPUT_REPORT); | 150 | ret = dev->hid_output_raw_report(dev, buf, count, report_type); |
152 | out_free: | 151 | out_free: |
153 | kfree(buf); | 152 | kfree(buf); |
154 | out: | 153 | out: |
154 | return ret; | ||
155 | } | ||
156 | |||
157 | /* the first byte is expected to be a report number */ | ||
158 | static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) | ||
159 | { | ||
160 | ssize_t ret; | ||
161 | mutex_lock(&minors_lock); | ||
162 | ret = hidraw_send_report(file, buffer, count, HID_OUTPUT_REPORT); | ||
155 | mutex_unlock(&minors_lock); | 163 | mutex_unlock(&minors_lock); |
156 | return ret; | 164 | return ret; |
157 | } | 165 | } |
158 | 166 | ||
167 | |||
168 | /* This function performs a Get_Report transfer over the control endpoint | ||
169 | per section 7.2.1 of the HID specification, version 1.1. The first byte | ||
170 | of buffer is the report number to request, or 0x0 if the defice does not | ||
171 | use numbered reports. The report_type parameter can be HID_FEATURE_REPORT | ||
172 | or HID_INPUT_REPORT. This function is to be called with the minors_lock | ||
173 | mutex held. */ | ||
174 | static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t count, unsigned char report_type) | ||
175 | { | ||
176 | unsigned int minor = iminor(file->f_path.dentry->d_inode); | ||
177 | struct hid_device *dev; | ||
178 | __u8 *buf; | ||
179 | int ret = 0, len; | ||
180 | unsigned char report_number; | ||
181 | |||
182 | dev = hidraw_table[minor]->hid; | ||
183 | |||
184 | if (!dev->hid_get_raw_report) { | ||
185 | ret = -ENODEV; | ||
186 | goto out; | ||
187 | } | ||
188 | |||
189 | if (count > HID_MAX_BUFFER_SIZE) { | ||
190 | printk(KERN_WARNING "hidraw: pid %d passed too large report\n", | ||
191 | task_pid_nr(current)); | ||
192 | ret = -EINVAL; | ||
193 | goto out; | ||
194 | } | ||
195 | |||
196 | if (count < 2) { | ||
197 | printk(KERN_WARNING "hidraw: pid %d passed too short report\n", | ||
198 | task_pid_nr(current)); | ||
199 | ret = -EINVAL; | ||
200 | goto out; | ||
201 | } | ||
202 | |||
203 | buf = kmalloc(count * sizeof(__u8), GFP_KERNEL); | ||
204 | if (!buf) { | ||
205 | ret = -ENOMEM; | ||
206 | goto out; | ||
207 | } | ||
208 | |||
209 | /* Read the first byte from the user. This is the report number, | ||
210 | which is passed to dev->hid_get_raw_report(). */ | ||
211 | if (copy_from_user(&report_number, buffer, 1)) { | ||
212 | ret = -EFAULT; | ||
213 | goto out_free; | ||
214 | } | ||
215 | |||
216 | ret = dev->hid_get_raw_report(dev, report_number, buf, count, report_type); | ||
217 | |||
218 | if (ret < 0) | ||
219 | goto out_free; | ||
220 | |||
221 | len = (ret < count) ? ret : count; | ||
222 | |||
223 | if (copy_to_user(buffer, buf, len)) { | ||
224 | ret = -EFAULT; | ||
225 | goto out_free; | ||
226 | } | ||
227 | |||
228 | ret = len; | ||
229 | |||
230 | out_free: | ||
231 | kfree(buf); | ||
232 | out: | ||
233 | return ret; | ||
234 | } | ||
235 | |||
159 | static unsigned int hidraw_poll(struct file *file, poll_table *wait) | 236 | static unsigned int hidraw_poll(struct file *file, poll_table *wait) |
160 | { | 237 | { |
161 | struct hidraw_list *list = file->private_data; | 238 | struct hidraw_list *list = file->private_data; |
@@ -295,7 +372,24 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
295 | default: | 372 | default: |
296 | { | 373 | { |
297 | struct hid_device *hid = dev->hid; | 374 | struct hid_device *hid = dev->hid; |
298 | if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) { | 375 | if (_IOC_TYPE(cmd) != 'H') { |
376 | ret = -EINVAL; | ||
377 | break; | ||
378 | } | ||
379 | |||
380 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCSFEATURE(0))) { | ||
381 | int len = _IOC_SIZE(cmd); | ||
382 | ret = hidraw_send_report(file, user_arg, len, HID_FEATURE_REPORT); | ||
383 | break; | ||
384 | } | ||
385 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGFEATURE(0))) { | ||
386 | int len = _IOC_SIZE(cmd); | ||
387 | ret = hidraw_get_report(file, user_arg, len, HID_FEATURE_REPORT); | ||
388 | break; | ||
389 | } | ||
390 | |||
391 | /* Begin Read-only ioctls. */ | ||
392 | if (_IOC_DIR(cmd) != _IOC_READ) { | ||
299 | ret = -EINVAL; | 393 | ret = -EINVAL; |
300 | break; | 394 | break; |
301 | } | 395 | } |
@@ -327,7 +421,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
327 | -EFAULT : len; | 421 | -EFAULT : len; |
328 | break; | 422 | break; |
329 | } | 423 | } |
330 | } | 424 | } |
331 | 425 | ||
332 | ret = -ENOTTY; | 426 | ret = -ENOTTY; |
333 | } | 427 | } |
@@ -428,12 +522,12 @@ void hidraw_disconnect(struct hid_device *hid) | |||
428 | 522 | ||
429 | hidraw->exist = 0; | 523 | hidraw->exist = 0; |
430 | 524 | ||
525 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); | ||
526 | |||
431 | mutex_lock(&minors_lock); | 527 | mutex_lock(&minors_lock); |
432 | hidraw_table[hidraw->minor] = NULL; | 528 | hidraw_table[hidraw->minor] = NULL; |
433 | mutex_unlock(&minors_lock); | 529 | mutex_unlock(&minors_lock); |
434 | 530 | ||
435 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); | ||
436 | |||
437 | if (hidraw->open) { | 531 | if (hidraw->open) { |
438 | hid_hw_close(hid); | 532 | hid_hw_close(hid); |
439 | wake_up_interruptible(&hidraw->wait); | 533 | wake_up_interruptible(&hidraw->wait); |
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index b336dd84036f..38c261a40c74 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -799,6 +799,40 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) | |||
799 | return 0; | 799 | return 0; |
800 | } | 800 | } |
801 | 801 | ||
802 | static int usbhid_get_raw_report(struct hid_device *hid, | ||
803 | unsigned char report_number, __u8 *buf, size_t count, | ||
804 | unsigned char report_type) | ||
805 | { | ||
806 | struct usbhid_device *usbhid = hid->driver_data; | ||
807 | struct usb_device *dev = hid_to_usb_dev(hid); | ||
808 | struct usb_interface *intf = usbhid->intf; | ||
809 | struct usb_host_interface *interface = intf->cur_altsetting; | ||
810 | int skipped_report_id = 0; | ||
811 | int ret; | ||
812 | |||
813 | /* Byte 0 is the report number. Report data starts at byte 1.*/ | ||
814 | buf[0] = report_number; | ||
815 | if (report_number == 0x0) { | ||
816 | /* Offset the return buffer by 1, so that the report ID | ||
817 | will remain in byte 0. */ | ||
818 | buf++; | ||
819 | count--; | ||
820 | skipped_report_id = 1; | ||
821 | } | ||
822 | ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), | ||
823 | HID_REQ_GET_REPORT, | ||
824 | USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
825 | ((report_type + 1) << 8) | report_number, | ||
826 | interface->desc.bInterfaceNumber, buf, count, | ||
827 | USB_CTRL_SET_TIMEOUT); | ||
828 | |||
829 | /* count also the report id */ | ||
830 | if (ret > 0 && skipped_report_id) | ||
831 | ret++; | ||
832 | |||
833 | return ret; | ||
834 | } | ||
835 | |||
802 | static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count, | 836 | static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count, |
803 | unsigned char report_type) | 837 | unsigned char report_type) |
804 | { | 838 | { |
@@ -1139,6 +1173,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1139 | 1173 | ||
1140 | usb_set_intfdata(intf, hid); | 1174 | usb_set_intfdata(intf, hid); |
1141 | hid->ll_driver = &usb_hid_driver; | 1175 | hid->ll_driver = &usb_hid_driver; |
1176 | hid->hid_get_raw_report = usbhid_get_raw_report; | ||
1142 | hid->hid_output_raw_report = usbhid_output_raw_report; | 1177 | hid->hid_output_raw_report = usbhid_output_raw_report; |
1143 | hid->ff_init = hid_pidff_init; | 1178 | hid->ff_init = hid_pidff_init; |
1144 | #ifdef CONFIG_USB_HIDDEV | 1179 | #ifdef CONFIG_USB_HIDDEV |
diff --git a/include/linux/hid.h b/include/linux/hid.h index d91c25e253c8..bb29bb1dbd2f 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
@@ -504,6 +504,9 @@ struct hid_device { /* device report descriptor */ | |||
504 | struct hid_usage *, __s32); | 504 | struct hid_usage *, __s32); |
505 | void (*hiddev_report_event) (struct hid_device *, struct hid_report *); | 505 | void (*hiddev_report_event) (struct hid_device *, struct hid_report *); |
506 | 506 | ||
507 | /* handler for raw input (Get_Report) data, used by hidraw */ | ||
508 | int (*hid_get_raw_report) (struct hid_device *, unsigned char, __u8 *, size_t, unsigned char); | ||
509 | |||
507 | /* handler for raw output data, used by hidraw */ | 510 | /* handler for raw output data, used by hidraw */ |
508 | int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t, unsigned char); | 511 | int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t, unsigned char); |
509 | 512 | ||
@@ -638,7 +641,7 @@ struct hid_driver { | |||
638 | struct hid_input *hidinput, struct hid_field *field, | 641 | struct hid_input *hidinput, struct hid_field *field, |
639 | struct hid_usage *usage, unsigned long **bit, int *max); | 642 | struct hid_usage *usage, unsigned long **bit, int *max); |
640 | void (*feature_mapping)(struct hid_device *hdev, | 643 | void (*feature_mapping)(struct hid_device *hdev, |
641 | struct hid_input *hidinput, struct hid_field *field, | 644 | struct hid_field *field, |
642 | struct hid_usage *usage); | 645 | struct hid_usage *usage); |
643 | #ifdef CONFIG_PM | 646 | #ifdef CONFIG_PM |
644 | int (*suspend)(struct hid_device *hdev, pm_message_t message); | 647 | int (*suspend)(struct hid_device *hdev, pm_message_t message); |
diff --git a/include/linux/hidraw.h b/include/linux/hidraw.h index dd8d69269176..4b88e697c4e9 100644 --- a/include/linux/hidraw.h +++ b/include/linux/hidraw.h | |||
@@ -35,6 +35,9 @@ struct hidraw_devinfo { | |||
35 | #define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo) | 35 | #define HIDIOCGRAWINFO _IOR('H', 0x03, struct hidraw_devinfo) |
36 | #define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len) | 36 | #define HIDIOCGRAWNAME(len) _IOC(_IOC_READ, 'H', 0x04, len) |
37 | #define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len) | 37 | #define HIDIOCGRAWPHYS(len) _IOC(_IOC_READ, 'H', 0x05, len) |
38 | /* The first byte of SFEATURE and GFEATURE is the report number */ | ||
39 | #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len) | ||
40 | #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len) | ||
38 | 41 | ||
39 | #define HIDRAW_FIRST_MINOR 0 | 42 | #define HIDRAW_FIRST_MINOR 0 |
40 | #define HIDRAW_MAX_DEVICES 64 | 43 | #define HIDRAW_MAX_DEVICES 64 |
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 29544c21f4b5..3c036b0933c1 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/file.h> | 36 | #include <linux/file.h> |
37 | #include <linux/init.h> | 37 | #include <linux/init.h> |
38 | #include <linux/wait.h> | 38 | #include <linux/wait.h> |
39 | #include <linux/mutex.h> | ||
39 | #include <net/sock.h> | 40 | #include <net/sock.h> |
40 | 41 | ||
41 | #include <linux/input.h> | 42 | #include <linux/input.h> |
@@ -313,24 +314,144 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep | |||
313 | return hidp_queue_report(session, buf, rsize); | 314 | return hidp_queue_report(session, buf, rsize); |
314 | } | 315 | } |
315 | 316 | ||
317 | static int hidp_get_raw_report(struct hid_device *hid, | ||
318 | unsigned char report_number, | ||
319 | unsigned char *data, size_t count, | ||
320 | unsigned char report_type) | ||
321 | { | ||
322 | struct hidp_session *session = hid->driver_data; | ||
323 | struct sk_buff *skb; | ||
324 | size_t len; | ||
325 | int numbered_reports = hid->report_enum[report_type].numbered; | ||
326 | |||
327 | switch (report_type) { | ||
328 | case HID_FEATURE_REPORT: | ||
329 | report_type = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_FEATURE; | ||
330 | break; | ||
331 | case HID_INPUT_REPORT: | ||
332 | report_type = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_INPUT; | ||
333 | break; | ||
334 | case HID_OUTPUT_REPORT: | ||
335 | report_type = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_OUPUT; | ||
336 | break; | ||
337 | default: | ||
338 | return -EINVAL; | ||
339 | } | ||
340 | |||
341 | if (mutex_lock_interruptible(&session->report_mutex)) | ||
342 | return -ERESTARTSYS; | ||
343 | |||
344 | /* Set up our wait, and send the report request to the device. */ | ||
345 | session->waiting_report_type = report_type & HIDP_DATA_RTYPE_MASK; | ||
346 | session->waiting_report_number = numbered_reports ? report_number : -1; | ||
347 | set_bit(HIDP_WAITING_FOR_RETURN, &session->flags); | ||
348 | data[0] = report_number; | ||
349 | if (hidp_send_ctrl_message(hid->driver_data, report_type, data, 1)) | ||
350 | goto err_eio; | ||
351 | |||
352 | /* Wait for the return of the report. The returned report | ||
353 | gets put in session->report_return. */ | ||
354 | while (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) { | ||
355 | int res; | ||
356 | |||
357 | res = wait_event_interruptible_timeout(session->report_queue, | ||
358 | !test_bit(HIDP_WAITING_FOR_RETURN, &session->flags), | ||
359 | 5*HZ); | ||
360 | if (res == 0) { | ||
361 | /* timeout */ | ||
362 | goto err_eio; | ||
363 | } | ||
364 | if (res < 0) { | ||
365 | /* signal */ | ||
366 | goto err_restartsys; | ||
367 | } | ||
368 | } | ||
369 | |||
370 | skb = session->report_return; | ||
371 | if (skb) { | ||
372 | len = skb->len < count ? skb->len : count; | ||
373 | memcpy(data, skb->data, len); | ||
374 | |||
375 | kfree_skb(skb); | ||
376 | session->report_return = NULL; | ||
377 | } else { | ||
378 | /* Device returned a HANDSHAKE, indicating protocol error. */ | ||
379 | len = -EIO; | ||
380 | } | ||
381 | |||
382 | clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); | ||
383 | mutex_unlock(&session->report_mutex); | ||
384 | |||
385 | return len; | ||
386 | |||
387 | err_restartsys: | ||
388 | clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); | ||
389 | mutex_unlock(&session->report_mutex); | ||
390 | return -ERESTARTSYS; | ||
391 | err_eio: | ||
392 | clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); | ||
393 | mutex_unlock(&session->report_mutex); | ||
394 | return -EIO; | ||
395 | } | ||
396 | |||
316 | static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, | 397 | static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, |
317 | unsigned char report_type) | 398 | unsigned char report_type) |
318 | { | 399 | { |
400 | struct hidp_session *session = hid->driver_data; | ||
401 | int ret; | ||
402 | |||
319 | switch (report_type) { | 403 | switch (report_type) { |
320 | case HID_FEATURE_REPORT: | 404 | case HID_FEATURE_REPORT: |
321 | report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; | 405 | report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE; |
322 | break; | 406 | break; |
323 | case HID_OUTPUT_REPORT: | 407 | case HID_OUTPUT_REPORT: |
324 | report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT; | 408 | report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_OUPUT; |
325 | break; | 409 | break; |
326 | default: | 410 | default: |
327 | return -EINVAL; | 411 | return -EINVAL; |
328 | } | 412 | } |
329 | 413 | ||
414 | if (mutex_lock_interruptible(&session->report_mutex)) | ||
415 | return -ERESTARTSYS; | ||
416 | |||
417 | /* Set up our wait, and send the report request to the device. */ | ||
418 | set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); | ||
330 | if (hidp_send_ctrl_message(hid->driver_data, report_type, | 419 | if (hidp_send_ctrl_message(hid->driver_data, report_type, |
331 | data, count)) | 420 | data, count)) { |
332 | return -ENOMEM; | 421 | ret = -ENOMEM; |
333 | return count; | 422 | goto err; |
423 | } | ||
424 | |||
425 | /* Wait for the ACK from the device. */ | ||
426 | while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { | ||
427 | int res; | ||
428 | |||
429 | res = wait_event_interruptible_timeout(session->report_queue, | ||
430 | !test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags), | ||
431 | 10*HZ); | ||
432 | if (res == 0) { | ||
433 | /* timeout */ | ||
434 | ret = -EIO; | ||
435 | goto err; | ||
436 | } | ||
437 | if (res < 0) { | ||
438 | /* signal */ | ||
439 | ret = -ERESTARTSYS; | ||
440 | goto err; | ||
441 | } | ||
442 | } | ||
443 | |||
444 | if (!session->output_report_success) { | ||
445 | ret = -EIO; | ||
446 | goto err; | ||
447 | } | ||
448 | |||
449 | ret = count; | ||
450 | |||
451 | err: | ||
452 | clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); | ||
453 | mutex_unlock(&session->report_mutex); | ||
454 | return ret; | ||
334 | } | 455 | } |
335 | 456 | ||
336 | static void hidp_idle_timeout(unsigned long arg) | 457 | static void hidp_idle_timeout(unsigned long arg) |
@@ -357,16 +478,22 @@ static void hidp_process_handshake(struct hidp_session *session, | |||
357 | unsigned char param) | 478 | unsigned char param) |
358 | { | 479 | { |
359 | BT_DBG("session %p param 0x%02x", session, param); | 480 | BT_DBG("session %p param 0x%02x", session, param); |
481 | session->output_report_success = 0; /* default condition */ | ||
360 | 482 | ||
361 | switch (param) { | 483 | switch (param) { |
362 | case HIDP_HSHK_SUCCESSFUL: | 484 | case HIDP_HSHK_SUCCESSFUL: |
363 | /* FIXME: Call into SET_ GET_ handlers here */ | 485 | /* FIXME: Call into SET_ GET_ handlers here */ |
486 | session->output_report_success = 1; | ||
364 | break; | 487 | break; |
365 | 488 | ||
366 | case HIDP_HSHK_NOT_READY: | 489 | case HIDP_HSHK_NOT_READY: |
367 | case HIDP_HSHK_ERR_INVALID_REPORT_ID: | 490 | case HIDP_HSHK_ERR_INVALID_REPORT_ID: |
368 | case HIDP_HSHK_ERR_UNSUPPORTED_REQUEST: | 491 | case HIDP_HSHK_ERR_UNSUPPORTED_REQUEST: |
369 | case HIDP_HSHK_ERR_INVALID_PARAMETER: | 492 | case HIDP_HSHK_ERR_INVALID_PARAMETER: |
493 | if (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) { | ||
494 | clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); | ||
495 | wake_up_interruptible(&session->report_queue); | ||
496 | } | ||
370 | /* FIXME: Call into SET_ GET_ handlers here */ | 497 | /* FIXME: Call into SET_ GET_ handlers here */ |
371 | break; | 498 | break; |
372 | 499 | ||
@@ -385,6 +512,12 @@ static void hidp_process_handshake(struct hidp_session *session, | |||
385 | HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_INVALID_PARAMETER, NULL, 0); | 512 | HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_INVALID_PARAMETER, NULL, 0); |
386 | break; | 513 | break; |
387 | } | 514 | } |
515 | |||
516 | /* Wake up the waiting thread. */ | ||
517 | if (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { | ||
518 | clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); | ||
519 | wake_up_interruptible(&session->report_queue); | ||
520 | } | ||
388 | } | 521 | } |
389 | 522 | ||
390 | static void hidp_process_hid_control(struct hidp_session *session, | 523 | static void hidp_process_hid_control(struct hidp_session *session, |
@@ -403,9 +536,11 @@ static void hidp_process_hid_control(struct hidp_session *session, | |||
403 | } | 536 | } |
404 | } | 537 | } |
405 | 538 | ||
406 | static void hidp_process_data(struct hidp_session *session, struct sk_buff *skb, | 539 | /* Returns true if the passed-in skb should be freed by the caller. */ |
540 | static int hidp_process_data(struct hidp_session *session, struct sk_buff *skb, | ||
407 | unsigned char param) | 541 | unsigned char param) |
408 | { | 542 | { |
543 | int done_with_skb = 1; | ||
409 | BT_DBG("session %p skb %p len %d param 0x%02x", session, skb, skb->len, param); | 544 | BT_DBG("session %p skb %p len %d param 0x%02x", session, skb, skb->len, param); |
410 | 545 | ||
411 | switch (param) { | 546 | switch (param) { |
@@ -417,7 +552,6 @@ static void hidp_process_data(struct hidp_session *session, struct sk_buff *skb, | |||
417 | 552 | ||
418 | if (session->hid) | 553 | if (session->hid) |
419 | hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 0); | 554 | hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 0); |
420 | |||
421 | break; | 555 | break; |
422 | 556 | ||
423 | case HIDP_DATA_RTYPE_OTHER: | 557 | case HIDP_DATA_RTYPE_OTHER: |
@@ -429,12 +563,27 @@ static void hidp_process_data(struct hidp_session *session, struct sk_buff *skb, | |||
429 | __hidp_send_ctrl_message(session, | 563 | __hidp_send_ctrl_message(session, |
430 | HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_INVALID_PARAMETER, NULL, 0); | 564 | HIDP_TRANS_HANDSHAKE | HIDP_HSHK_ERR_INVALID_PARAMETER, NULL, 0); |
431 | } | 565 | } |
566 | |||
567 | if (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags) && | ||
568 | param == session->waiting_report_type) { | ||
569 | if (session->waiting_report_number < 0 || | ||
570 | session->waiting_report_number == skb->data[0]) { | ||
571 | /* hidp_get_raw_report() is waiting on this report. */ | ||
572 | session->report_return = skb; | ||
573 | done_with_skb = 0; | ||
574 | clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); | ||
575 | wake_up_interruptible(&session->report_queue); | ||
576 | } | ||
577 | } | ||
578 | |||
579 | return done_with_skb; | ||
432 | } | 580 | } |
433 | 581 | ||
434 | static void hidp_recv_ctrl_frame(struct hidp_session *session, | 582 | static void hidp_recv_ctrl_frame(struct hidp_session *session, |
435 | struct sk_buff *skb) | 583 | struct sk_buff *skb) |
436 | { | 584 | { |
437 | unsigned char hdr, type, param; | 585 | unsigned char hdr, type, param; |
586 | int free_skb = 1; | ||
438 | 587 | ||
439 | BT_DBG("session %p skb %p len %d", session, skb, skb->len); | 588 | BT_DBG("session %p skb %p len %d", session, skb, skb->len); |
440 | 589 | ||
@@ -454,7 +603,7 @@ static void hidp_recv_ctrl_frame(struct hidp_session *session, | |||
454 | break; | 603 | break; |
455 | 604 | ||
456 | case HIDP_TRANS_DATA: | 605 | case HIDP_TRANS_DATA: |
457 | hidp_process_data(session, skb, param); | 606 | free_skb = hidp_process_data(session, skb, param); |
458 | break; | 607 | break; |
459 | 608 | ||
460 | default: | 609 | default: |
@@ -463,7 +612,8 @@ static void hidp_recv_ctrl_frame(struct hidp_session *session, | |||
463 | break; | 612 | break; |
464 | } | 613 | } |
465 | 614 | ||
466 | kfree_skb(skb); | 615 | if (free_skb) |
616 | kfree_skb(skb); | ||
467 | } | 617 | } |
468 | 618 | ||
469 | static void hidp_recv_intr_frame(struct hidp_session *session, | 619 | static void hidp_recv_intr_frame(struct hidp_session *session, |
@@ -563,6 +713,8 @@ static int hidp_session(void *arg) | |||
563 | init_waitqueue_entry(&intr_wait, current); | 713 | init_waitqueue_entry(&intr_wait, current); |
564 | add_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait); | 714 | add_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait); |
565 | add_wait_queue(sk_sleep(intr_sk), &intr_wait); | 715 | add_wait_queue(sk_sleep(intr_sk), &intr_wait); |
716 | session->waiting_for_startup = 0; | ||
717 | wake_up_interruptible(&session->startup_queue); | ||
566 | while (!atomic_read(&session->terminate)) { | 718 | while (!atomic_read(&session->terminate)) { |
567 | set_current_state(TASK_INTERRUPTIBLE); | 719 | set_current_state(TASK_INTERRUPTIBLE); |
568 | 720 | ||
@@ -754,6 +906,8 @@ static struct hid_ll_driver hidp_hid_driver = { | |||
754 | .hidinput_input_event = hidp_hidinput_event, | 906 | .hidinput_input_event = hidp_hidinput_event, |
755 | }; | 907 | }; |
756 | 908 | ||
909 | /* This function sets up the hid device. It does not add it | ||
910 | to the HID system. That is done in hidp_add_connection(). */ | ||
757 | static int hidp_setup_hid(struct hidp_session *session, | 911 | static int hidp_setup_hid(struct hidp_session *session, |
758 | struct hidp_connadd_req *req) | 912 | struct hidp_connadd_req *req) |
759 | { | 913 | { |
@@ -793,18 +947,11 @@ static int hidp_setup_hid(struct hidp_session *session, | |||
793 | hid->dev.parent = hidp_get_device(session); | 947 | hid->dev.parent = hidp_get_device(session); |
794 | hid->ll_driver = &hidp_hid_driver; | 948 | hid->ll_driver = &hidp_hid_driver; |
795 | 949 | ||
950 | hid->hid_get_raw_report = hidp_get_raw_report; | ||
796 | hid->hid_output_raw_report = hidp_output_raw_report; | 951 | hid->hid_output_raw_report = hidp_output_raw_report; |
797 | 952 | ||
798 | err = hid_add_device(hid); | ||
799 | if (err < 0) | ||
800 | goto failed; | ||
801 | |||
802 | return 0; | 953 | return 0; |
803 | 954 | ||
804 | failed: | ||
805 | hid_destroy_device(hid); | ||
806 | session->hid = NULL; | ||
807 | |||
808 | fault: | 955 | fault: |
809 | kfree(session->rd_data); | 956 | kfree(session->rd_data); |
810 | session->rd_data = NULL; | 957 | session->rd_data = NULL; |
@@ -853,6 +1000,10 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
853 | skb_queue_head_init(&session->ctrl_transmit); | 1000 | skb_queue_head_init(&session->ctrl_transmit); |
854 | skb_queue_head_init(&session->intr_transmit); | 1001 | skb_queue_head_init(&session->intr_transmit); |
855 | 1002 | ||
1003 | mutex_init(&session->report_mutex); | ||
1004 | init_waitqueue_head(&session->report_queue); | ||
1005 | init_waitqueue_head(&session->startup_queue); | ||
1006 | session->waiting_for_startup = 1; | ||
856 | session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID); | 1007 | session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID); |
857 | session->idle_to = req->idle_to; | 1008 | session->idle_to = req->idle_to; |
858 | 1009 | ||
@@ -875,6 +1026,14 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
875 | err = kernel_thread(hidp_session, session, CLONE_KERNEL); | 1026 | err = kernel_thread(hidp_session, session, CLONE_KERNEL); |
876 | if (err < 0) | 1027 | if (err < 0) |
877 | goto unlink; | 1028 | goto unlink; |
1029 | while (session->waiting_for_startup) { | ||
1030 | wait_event_interruptible(session->startup_queue, | ||
1031 | !session->waiting_for_startup); | ||
1032 | } | ||
1033 | |||
1034 | err = hid_add_device(session->hid); | ||
1035 | if (err < 0) | ||
1036 | goto err_add_device; | ||
878 | 1037 | ||
879 | if (session->input) { | 1038 | if (session->input) { |
880 | hidp_send_ctrl_message(session, | 1039 | hidp_send_ctrl_message(session, |
@@ -888,6 +1047,12 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, | |||
888 | up_write(&hidp_session_sem); | 1047 | up_write(&hidp_session_sem); |
889 | return 0; | 1048 | return 0; |
890 | 1049 | ||
1050 | err_add_device: | ||
1051 | hid_destroy_device(session->hid); | ||
1052 | session->hid = NULL; | ||
1053 | atomic_inc(&session->terminate); | ||
1054 | hidp_schedule(session); | ||
1055 | |||
891 | unlink: | 1056 | unlink: |
892 | hidp_del_timer(session); | 1057 | hidp_del_timer(session); |
893 | 1058 | ||
diff --git a/net/bluetooth/hidp/hidp.h b/net/bluetooth/hidp/hidp.h index 8d934a19da0a..13de5fa03480 100644 --- a/net/bluetooth/hidp/hidp.h +++ b/net/bluetooth/hidp/hidp.h | |||
@@ -80,6 +80,8 @@ | |||
80 | #define HIDP_VIRTUAL_CABLE_UNPLUG 0 | 80 | #define HIDP_VIRTUAL_CABLE_UNPLUG 0 |
81 | #define HIDP_BOOT_PROTOCOL_MODE 1 | 81 | #define HIDP_BOOT_PROTOCOL_MODE 1 |
82 | #define HIDP_BLUETOOTH_VENDOR_ID 9 | 82 | #define HIDP_BLUETOOTH_VENDOR_ID 9 |
83 | #define HIDP_WAITING_FOR_RETURN 10 | ||
84 | #define HIDP_WAITING_FOR_SEND_ACK 11 | ||
83 | 85 | ||
84 | struct hidp_connadd_req { | 86 | struct hidp_connadd_req { |
85 | int ctrl_sock; // Connected control socket | 87 | int ctrl_sock; // Connected control socket |
@@ -154,9 +156,22 @@ struct hidp_session { | |||
154 | struct sk_buff_head ctrl_transmit; | 156 | struct sk_buff_head ctrl_transmit; |
155 | struct sk_buff_head intr_transmit; | 157 | struct sk_buff_head intr_transmit; |
156 | 158 | ||
159 | /* Used in hidp_get_raw_report() */ | ||
160 | int waiting_report_type; /* HIDP_DATA_RTYPE_* */ | ||
161 | int waiting_report_number; /* -1 for not numbered */ | ||
162 | struct mutex report_mutex; | ||
163 | struct sk_buff *report_return; | ||
164 | wait_queue_head_t report_queue; | ||
165 | |||
166 | /* Used in hidp_output_raw_report() */ | ||
167 | int output_report_success; /* boolean */ | ||
168 | |||
157 | /* Report descriptor */ | 169 | /* Report descriptor */ |
158 | __u8 *rd_data; | 170 | __u8 *rd_data; |
159 | uint rd_size; | 171 | uint rd_size; |
172 | |||
173 | wait_queue_head_t startup_queue; | ||
174 | int waiting_for_startup; | ||
160 | }; | 175 | }; |
161 | 176 | ||
162 | static inline void hidp_schedule(struct hidp_session *session) | 177 | static inline void hidp_schedule(struct hidp_session *session) |