Commit 1f243e302cea1561ac881eb5d27041c5342beba4
Committed by
Jiri Kosina
1 parent
3b239cd739
Exists in
master
and in
39 other branches
HID: move ezkey quirks
Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Showing 8 changed files with 107 additions and 40 deletions Inline Diff
drivers/hid/Kconfig
1 | # | 1 | # |
2 | # HID driver configuration | 2 | # HID driver configuration |
3 | # | 3 | # |
4 | menuconfig HID_SUPPORT | 4 | menuconfig HID_SUPPORT |
5 | bool "HID Devices" | 5 | bool "HID Devices" |
6 | depends on INPUT | 6 | depends on INPUT |
7 | default y | 7 | default y |
8 | ---help--- | 8 | ---help--- |
9 | Say Y here to get to see options for various computer-human interface | 9 | Say Y here to get to see options for various computer-human interface |
10 | device drivers. This option alone does not add any kernel code. | 10 | device drivers. This option alone does not add any kernel code. |
11 | 11 | ||
12 | If you say N, all options in this submenu will be skipped and disabled. | 12 | If you say N, all options in this submenu will be skipped and disabled. |
13 | 13 | ||
14 | if HID_SUPPORT | 14 | if HID_SUPPORT |
15 | 15 | ||
16 | config HID | 16 | config HID |
17 | tristate "Generic HID support" | 17 | tristate "Generic HID support" |
18 | depends on INPUT | 18 | depends on INPUT |
19 | default y | 19 | default y |
20 | ---help--- | 20 | ---help--- |
21 | A human interface device (HID) is a type of computer device that | 21 | A human interface device (HID) is a type of computer device that |
22 | interacts directly with and takes input from humans. The term "HID" | 22 | interacts directly with and takes input from humans. The term "HID" |
23 | most commonly used to refer to the USB-HID specification, but other | 23 | most commonly used to refer to the USB-HID specification, but other |
24 | devices (such as, but not strictly limited to, Bluetooth) are | 24 | devices (such as, but not strictly limited to, Bluetooth) are |
25 | designed using HID specification (this involves certain keyboards, | 25 | designed using HID specification (this involves certain keyboards, |
26 | mice, tablets, etc). This option compiles into kernel the generic | 26 | mice, tablets, etc). This option compiles into kernel the generic |
27 | HID layer code (parser, usages, etc.), which can then be used by | 27 | HID layer code (parser, usages, etc.), which can then be used by |
28 | transport-specific HID implementation (like USB or Bluetooth). | 28 | transport-specific HID implementation (like USB or Bluetooth). |
29 | 29 | ||
30 | For docs and specs, see http://www.usb.org/developers/hidpage/ | 30 | For docs and specs, see http://www.usb.org/developers/hidpage/ |
31 | 31 | ||
32 | If unsure, say Y | 32 | If unsure, say Y |
33 | 33 | ||
34 | config HID_DEBUG | 34 | config HID_DEBUG |
35 | bool "HID debugging support" | 35 | bool "HID debugging support" |
36 | default y if !EMBEDDED | 36 | default y if !EMBEDDED |
37 | depends on HID | 37 | depends on HID |
38 | ---help--- | 38 | ---help--- |
39 | This option lets the HID layer output diagnostics about its internal | 39 | This option lets the HID layer output diagnostics about its internal |
40 | state, resolve HID usages, dump HID fields, etc. Individual HID drivers | 40 | state, resolve HID usages, dump HID fields, etc. Individual HID drivers |
41 | use this debugging facility to output information about individual HID | 41 | use this debugging facility to output information about individual HID |
42 | devices, etc. | 42 | devices, etc. |
43 | 43 | ||
44 | This feature is useful for those who are either debugging the HID parser | 44 | This feature is useful for those who are either debugging the HID parser |
45 | or any HID hardware device. | 45 | or any HID hardware device. |
46 | 46 | ||
47 | If unsure, say N | 47 | If unsure, say N |
48 | 48 | ||
49 | config HIDRAW | 49 | config HIDRAW |
50 | bool "/dev/hidraw raw HID device support" | 50 | bool "/dev/hidraw raw HID device support" |
51 | depends on HID | 51 | depends on HID |
52 | ---help--- | 52 | ---help--- |
53 | Say Y here if you want to support HID devices (from the USB | 53 | Say Y here if you want to support HID devices (from the USB |
54 | specification standpoint) that aren't strictly user interface | 54 | specification standpoint) that aren't strictly user interface |
55 | devices, like monitor controls and Uninterruptable Power Supplies. | 55 | devices, like monitor controls and Uninterruptable Power Supplies. |
56 | 56 | ||
57 | This module supports these devices separately using a separate | 57 | This module supports these devices separately using a separate |
58 | event interface on /dev/hidraw. | 58 | event interface on /dev/hidraw. |
59 | 59 | ||
60 | There is also a /dev/hiddev configuration option in the USB HID | 60 | There is also a /dev/hiddev configuration option in the USB HID |
61 | configuration menu. In comparison to hiddev, this device does not process | 61 | configuration menu. In comparison to hiddev, this device does not process |
62 | the hid events at all (no parsing, no lookups). This lets applications | 62 | the hid events at all (no parsing, no lookups). This lets applications |
63 | to work on raw hid events when they want to, and avoid using transport-specific | 63 | to work on raw hid events when they want to, and avoid using transport-specific |
64 | userspace libhid/libusb libraries. | 64 | userspace libhid/libusb libraries. |
65 | 65 | ||
66 | If unsure, say Y. | 66 | If unsure, say Y. |
67 | 67 | ||
68 | source "drivers/hid/usbhid/Kconfig" | 68 | source "drivers/hid/usbhid/Kconfig" |
69 | 69 | ||
70 | menu "Special HID drivers" | 70 | menu "Special HID drivers" |
71 | depends on HID | 71 | depends on HID |
72 | 72 | ||
73 | config HID_COMPAT | 73 | config HID_COMPAT |
74 | bool "Load all HID drivers on hid core load" | 74 | bool "Load all HID drivers on hid core load" |
75 | default y | 75 | default y |
76 | ---help--- | 76 | ---help--- |
77 | Compatible option for older userspace. If you have system without udev | 77 | Compatible option for older userspace. If you have system without udev |
78 | support of module loading through aliases and also old | 78 | support of module loading through aliases and also old |
79 | module-init-tools which can't handle hid bus, choose Y here. Otherwise | 79 | module-init-tools which can't handle hid bus, choose Y here. Otherwise |
80 | say N. If you say N and your userspace is old enough, the only | 80 | say N. If you say N and your userspace is old enough, the only |
81 | functionality you loose is modules autoloading. | 81 | functionality you loose is modules autoloading. |
82 | 82 | ||
83 | If unsure, say Y. | 83 | If unsure, say Y. |
84 | 84 | ||
85 | config HID_A4TECH | 85 | config HID_A4TECH |
86 | tristate "A4 tech" | 86 | tristate "A4 tech" |
87 | default m | 87 | default m |
88 | depends on USB_HID | 88 | depends on USB_HID |
89 | ---help--- | 89 | ---help--- |
90 | Support for A4 tech X5 and WOP-35 / Trust 450L mice. | 90 | Support for A4 tech X5 and WOP-35 / Trust 450L mice. |
91 | 91 | ||
92 | config HID_APPLE | 92 | config HID_APPLE |
93 | tristate "Apple" | 93 | tristate "Apple" |
94 | default m | 94 | default m |
95 | depends on (USB_HID || BT_HIDP) | 95 | depends on (USB_HID || BT_HIDP) |
96 | ---help--- | 96 | ---help--- |
97 | Support for some Apple devices which less or more break | 97 | Support for some Apple devices which less or more break |
98 | HID specification. | 98 | HID specification. |
99 | 99 | ||
100 | Say Y here if you want support for the special keys (Fn, Numlock) on | 100 | Say Y here if you want support for the special keys (Fn, Numlock) on |
101 | Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB | 101 | Apple iBooks, PowerBooks, MacBooks, MacBook Pros and aluminum USB |
102 | keyboards. | 102 | keyboards. |
103 | 103 | ||
104 | If unsure, say M. | 104 | If unsure, say M. |
105 | 105 | ||
106 | config HID_CHERRY | 106 | config HID_CHERRY |
107 | tristate "Cherry" | 107 | tristate "Cherry" |
108 | default m | 108 | default m |
109 | depends on USB_HID | 109 | depends on USB_HID |
110 | ---help--- | 110 | ---help--- |
111 | Support for Cherry Cymotion. | 111 | Support for Cherry Cymotion. |
112 | 112 | ||
113 | config HID_CYPRESS | 113 | config HID_CYPRESS |
114 | tristate "Cypress" | 114 | tristate "Cypress" |
115 | default m | 115 | default m |
116 | depends on USB_HID | 116 | depends on USB_HID |
117 | ---help--- | 117 | ---help--- |
118 | Support for Cypress mouse and barcodes. | 118 | Support for Cypress mouse and barcodes. |
119 | 119 | ||
120 | config HID_EZKEY | ||
121 | tristate "Ezkey" | ||
122 | default m | ||
123 | depends on USB_HID | ||
124 | ---help--- | ||
125 | Support for Ezkey mouse and barcodes. | ||
126 | |||
120 | config HID_LOGITECH | 127 | config HID_LOGITECH |
121 | tristate "Logitech" | 128 | tristate "Logitech" |
122 | default m | 129 | default m |
123 | depends on USB_HID | 130 | depends on USB_HID |
124 | ---help--- | 131 | ---help--- |
125 | Support for some Logitech devices which breaks less or more | 132 | Support for some Logitech devices which breaks less or more |
126 | HID specification. | 133 | HID specification. |
127 | 134 | ||
128 | config HID_MICROSOFT | 135 | config HID_MICROSOFT |
129 | tristate "Microsoft" | 136 | tristate "Microsoft" |
130 | default m | 137 | default m |
131 | depends on USB_HID | 138 | depends on USB_HID |
132 | ---help--- | 139 | ---help--- |
133 | Support for some Microsoft devices which breaks less or more | 140 | Support for some Microsoft devices which breaks less or more |
134 | HID specification. | 141 | HID specification. |
135 | 142 | ||
136 | config HID_SUNPLUS | 143 | config HID_SUNPLUS |
137 | tristate "Sunplus" | 144 | tristate "Sunplus" |
138 | default m | 145 | default m |
139 | depends on USB_HID | 146 | depends on USB_HID |
140 | ---help--- | 147 | ---help--- |
141 | Support for Sunplus WDesktop input device. | 148 | Support for Sunplus WDesktop input device. |
142 | 149 | ||
143 | endmenu | 150 | endmenu |
144 | 151 | ||
145 | endif # HID_SUPPORT | 152 | endif # HID_SUPPORT |
146 | 153 |
drivers/hid/Makefile
1 | # | 1 | # |
2 | # Makefile for the HID driver | 2 | # Makefile for the HID driver |
3 | # | 3 | # |
4 | hid-objs := hid-core.o hid-input.o hid-input-quirks.o | 4 | hid-objs := hid-core.o hid-input.o hid-input-quirks.o |
5 | 5 | ||
6 | obj-$(CONFIG_HID) += hid.o | 6 | obj-$(CONFIG_HID) += hid.o |
7 | 7 | ||
8 | hid-$(CONFIG_HID_DEBUG) += hid-debug.o | 8 | hid-$(CONFIG_HID_DEBUG) += hid-debug.o |
9 | hid-$(CONFIG_HIDRAW) += hidraw.o | 9 | hid-$(CONFIG_HIDRAW) += hidraw.o |
10 | 10 | ||
11 | ifdef CONFIG_HID_COMPAT | 11 | ifdef CONFIG_HID_COMPAT |
12 | obj-m += hid-dummy.o | 12 | obj-m += hid-dummy.o |
13 | endif | 13 | endif |
14 | 14 | ||
15 | obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o | 15 | obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o |
16 | obj-$(CONFIG_HID_APPLE) += hid-apple.o | 16 | obj-$(CONFIG_HID_APPLE) += hid-apple.o |
17 | obj-$(CONFIG_HID_CHERRY) += hid-cherry.o | 17 | obj-$(CONFIG_HID_CHERRY) += hid-cherry.o |
18 | obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o | 18 | obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o |
19 | obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o | ||
19 | obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o | 20 | obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o |
20 | obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o | 21 | obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o |
21 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o | 22 | obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o |
22 | 23 | ||
23 | obj-$(CONFIG_USB_HID) += usbhid/ | 24 | obj-$(CONFIG_USB_HID) += usbhid/ |
24 | obj-$(CONFIG_USB_MOUSE) += usbhid/ | 25 | obj-$(CONFIG_USB_MOUSE) += usbhid/ |
25 | obj-$(CONFIG_USB_KBD) += usbhid/ | 26 | obj-$(CONFIG_USB_KBD) += usbhid/ |
26 | 27 | ||
27 | 28 |
drivers/hid/hid-core.c
1 | /* | 1 | /* |
2 | * HID support for Linux | 2 | * HID support for Linux |
3 | * | 3 | * |
4 | * Copyright (c) 1999 Andreas Gal | 4 | * Copyright (c) 1999 Andreas Gal |
5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> | 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc | 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
7 | * Copyright (c) 2006-2007 Jiri Kosina | 7 | * Copyright (c) 2006-2007 Jiri Kosina |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * This program is free software; you can redistribute it and/or modify it | 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 | 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) | 13 | * Software Foundation; either version 2 of the License, or (at your option) |
14 | * any later version. | 14 | * any later version. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/spinlock.h> | 23 | #include <linux/spinlock.h> |
24 | #include <asm/unaligned.h> | 24 | #include <asm/unaligned.h> |
25 | #include <asm/byteorder.h> | 25 | #include <asm/byteorder.h> |
26 | #include <linux/input.h> | 26 | #include <linux/input.h> |
27 | #include <linux/wait.h> | 27 | #include <linux/wait.h> |
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <linux/sched.h> | 29 | #include <linux/sched.h> |
30 | 30 | ||
31 | #include <linux/hid.h> | 31 | #include <linux/hid.h> |
32 | #include <linux/hiddev.h> | 32 | #include <linux/hiddev.h> |
33 | #include <linux/hid-debug.h> | 33 | #include <linux/hid-debug.h> |
34 | #include <linux/hidraw.h> | 34 | #include <linux/hidraw.h> |
35 | 35 | ||
36 | #include "hid-ids.h" | 36 | #include "hid-ids.h" |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * Version Information | 39 | * Version Information |
40 | */ | 40 | */ |
41 | 41 | ||
42 | #define DRIVER_VERSION "v2.6" | 42 | #define DRIVER_VERSION "v2.6" |
43 | #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik, Jiri Kosina" | 43 | #define DRIVER_AUTHOR "Andreas Gal, Vojtech Pavlik, Jiri Kosina" |
44 | #define DRIVER_DESC "HID core driver" | 44 | #define DRIVER_DESC "HID core driver" |
45 | #define DRIVER_LICENSE "GPL" | 45 | #define DRIVER_LICENSE "GPL" |
46 | 46 | ||
47 | #ifdef CONFIG_HID_DEBUG | 47 | #ifdef CONFIG_HID_DEBUG |
48 | int hid_debug = 0; | 48 | int hid_debug = 0; |
49 | module_param_named(debug, hid_debug, int, 0600); | 49 | module_param_named(debug, hid_debug, int, 0600); |
50 | MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)"); | 50 | MODULE_PARM_DESC(debug, "HID debugging (0=off, 1=probing info, 2=continuous data dumping)"); |
51 | EXPORT_SYMBOL_GPL(hid_debug); | 51 | EXPORT_SYMBOL_GPL(hid_debug); |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | /* | 54 | /* |
55 | * Register a new report for a device. | 55 | * Register a new report for a device. |
56 | */ | 56 | */ |
57 | 57 | ||
58 | static struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) | 58 | static struct hid_report *hid_register_report(struct hid_device *device, unsigned type, unsigned id) |
59 | { | 59 | { |
60 | struct hid_report_enum *report_enum = device->report_enum + type; | 60 | struct hid_report_enum *report_enum = device->report_enum + type; |
61 | struct hid_report *report; | 61 | struct hid_report *report; |
62 | 62 | ||
63 | if (report_enum->report_id_hash[id]) | 63 | if (report_enum->report_id_hash[id]) |
64 | return report_enum->report_id_hash[id]; | 64 | return report_enum->report_id_hash[id]; |
65 | 65 | ||
66 | if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL))) | 66 | if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL))) |
67 | return NULL; | 67 | return NULL; |
68 | 68 | ||
69 | if (id != 0) | 69 | if (id != 0) |
70 | report_enum->numbered = 1; | 70 | report_enum->numbered = 1; |
71 | 71 | ||
72 | report->id = id; | 72 | report->id = id; |
73 | report->type = type; | 73 | report->type = type; |
74 | report->size = 0; | 74 | report->size = 0; |
75 | report->device = device; | 75 | report->device = device; |
76 | report_enum->report_id_hash[id] = report; | 76 | report_enum->report_id_hash[id] = report; |
77 | 77 | ||
78 | list_add_tail(&report->list, &report_enum->report_list); | 78 | list_add_tail(&report->list, &report_enum->report_list); |
79 | 79 | ||
80 | return report; | 80 | return report; |
81 | } | 81 | } |
82 | 82 | ||
83 | /* | 83 | /* |
84 | * Register a new field for this report. | 84 | * Register a new field for this report. |
85 | */ | 85 | */ |
86 | 86 | ||
87 | static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) | 87 | static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) |
88 | { | 88 | { |
89 | struct hid_field *field; | 89 | struct hid_field *field; |
90 | 90 | ||
91 | if (report->maxfield == HID_MAX_FIELDS) { | 91 | if (report->maxfield == HID_MAX_FIELDS) { |
92 | dbg_hid("too many fields in report\n"); | 92 | dbg_hid("too many fields in report\n"); |
93 | return NULL; | 93 | return NULL; |
94 | } | 94 | } |
95 | 95 | ||
96 | if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) | 96 | if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) |
97 | + values * sizeof(unsigned), GFP_KERNEL))) return NULL; | 97 | + values * sizeof(unsigned), GFP_KERNEL))) return NULL; |
98 | 98 | ||
99 | field->index = report->maxfield++; | 99 | field->index = report->maxfield++; |
100 | report->field[field->index] = field; | 100 | report->field[field->index] = field; |
101 | field->usage = (struct hid_usage *)(field + 1); | 101 | field->usage = (struct hid_usage *)(field + 1); |
102 | field->value = (s32 *)(field->usage + usages); | 102 | field->value = (s32 *)(field->usage + usages); |
103 | field->report = report; | 103 | field->report = report; |
104 | 104 | ||
105 | return field; | 105 | return field; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* | 108 | /* |
109 | * Open a collection. The type/usage is pushed on the stack. | 109 | * Open a collection. The type/usage is pushed on the stack. |
110 | */ | 110 | */ |
111 | 111 | ||
112 | static int open_collection(struct hid_parser *parser, unsigned type) | 112 | static int open_collection(struct hid_parser *parser, unsigned type) |
113 | { | 113 | { |
114 | struct hid_collection *collection; | 114 | struct hid_collection *collection; |
115 | unsigned usage; | 115 | unsigned usage; |
116 | 116 | ||
117 | usage = parser->local.usage[0]; | 117 | usage = parser->local.usage[0]; |
118 | 118 | ||
119 | if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { | 119 | if (parser->collection_stack_ptr == HID_COLLECTION_STACK_SIZE) { |
120 | dbg_hid("collection stack overflow\n"); | 120 | dbg_hid("collection stack overflow\n"); |
121 | return -1; | 121 | return -1; |
122 | } | 122 | } |
123 | 123 | ||
124 | if (parser->device->maxcollection == parser->device->collection_size) { | 124 | if (parser->device->maxcollection == parser->device->collection_size) { |
125 | collection = kmalloc(sizeof(struct hid_collection) * | 125 | collection = kmalloc(sizeof(struct hid_collection) * |
126 | parser->device->collection_size * 2, GFP_KERNEL); | 126 | parser->device->collection_size * 2, GFP_KERNEL); |
127 | if (collection == NULL) { | 127 | if (collection == NULL) { |
128 | dbg_hid("failed to reallocate collection array\n"); | 128 | dbg_hid("failed to reallocate collection array\n"); |
129 | return -1; | 129 | return -1; |
130 | } | 130 | } |
131 | memcpy(collection, parser->device->collection, | 131 | memcpy(collection, parser->device->collection, |
132 | sizeof(struct hid_collection) * | 132 | sizeof(struct hid_collection) * |
133 | parser->device->collection_size); | 133 | parser->device->collection_size); |
134 | memset(collection + parser->device->collection_size, 0, | 134 | memset(collection + parser->device->collection_size, 0, |
135 | sizeof(struct hid_collection) * | 135 | sizeof(struct hid_collection) * |
136 | parser->device->collection_size); | 136 | parser->device->collection_size); |
137 | kfree(parser->device->collection); | 137 | kfree(parser->device->collection); |
138 | parser->device->collection = collection; | 138 | parser->device->collection = collection; |
139 | parser->device->collection_size *= 2; | 139 | parser->device->collection_size *= 2; |
140 | } | 140 | } |
141 | 141 | ||
142 | parser->collection_stack[parser->collection_stack_ptr++] = | 142 | parser->collection_stack[parser->collection_stack_ptr++] = |
143 | parser->device->maxcollection; | 143 | parser->device->maxcollection; |
144 | 144 | ||
145 | collection = parser->device->collection + | 145 | collection = parser->device->collection + |
146 | parser->device->maxcollection++; | 146 | parser->device->maxcollection++; |
147 | collection->type = type; | 147 | collection->type = type; |
148 | collection->usage = usage; | 148 | collection->usage = usage; |
149 | collection->level = parser->collection_stack_ptr - 1; | 149 | collection->level = parser->collection_stack_ptr - 1; |
150 | 150 | ||
151 | if (type == HID_COLLECTION_APPLICATION) | 151 | if (type == HID_COLLECTION_APPLICATION) |
152 | parser->device->maxapplication++; | 152 | parser->device->maxapplication++; |
153 | 153 | ||
154 | return 0; | 154 | return 0; |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * Close a collection. | 158 | * Close a collection. |
159 | */ | 159 | */ |
160 | 160 | ||
161 | static int close_collection(struct hid_parser *parser) | 161 | static int close_collection(struct hid_parser *parser) |
162 | { | 162 | { |
163 | if (!parser->collection_stack_ptr) { | 163 | if (!parser->collection_stack_ptr) { |
164 | dbg_hid("collection stack underflow\n"); | 164 | dbg_hid("collection stack underflow\n"); |
165 | return -1; | 165 | return -1; |
166 | } | 166 | } |
167 | parser->collection_stack_ptr--; | 167 | parser->collection_stack_ptr--; |
168 | return 0; | 168 | return 0; |
169 | } | 169 | } |
170 | 170 | ||
171 | /* | 171 | /* |
172 | * Climb up the stack, search for the specified collection type | 172 | * Climb up the stack, search for the specified collection type |
173 | * and return the usage. | 173 | * and return the usage. |
174 | */ | 174 | */ |
175 | 175 | ||
176 | static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) | 176 | static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) |
177 | { | 177 | { |
178 | int n; | 178 | int n; |
179 | for (n = parser->collection_stack_ptr - 1; n >= 0; n--) | 179 | for (n = parser->collection_stack_ptr - 1; n >= 0; n--) |
180 | if (parser->device->collection[parser->collection_stack[n]].type == type) | 180 | if (parser->device->collection[parser->collection_stack[n]].type == type) |
181 | return parser->device->collection[parser->collection_stack[n]].usage; | 181 | return parser->device->collection[parser->collection_stack[n]].usage; |
182 | return 0; /* we know nothing about this usage type */ | 182 | return 0; /* we know nothing about this usage type */ |
183 | } | 183 | } |
184 | 184 | ||
185 | /* | 185 | /* |
186 | * Add a usage to the temporary parser table. | 186 | * Add a usage to the temporary parser table. |
187 | */ | 187 | */ |
188 | 188 | ||
189 | static int hid_add_usage(struct hid_parser *parser, unsigned usage) | 189 | static int hid_add_usage(struct hid_parser *parser, unsigned usage) |
190 | { | 190 | { |
191 | if (parser->local.usage_index >= HID_MAX_USAGES) { | 191 | if (parser->local.usage_index >= HID_MAX_USAGES) { |
192 | dbg_hid("usage index exceeded\n"); | 192 | dbg_hid("usage index exceeded\n"); |
193 | return -1; | 193 | return -1; |
194 | } | 194 | } |
195 | parser->local.usage[parser->local.usage_index] = usage; | 195 | parser->local.usage[parser->local.usage_index] = usage; |
196 | parser->local.collection_index[parser->local.usage_index] = | 196 | parser->local.collection_index[parser->local.usage_index] = |
197 | parser->collection_stack_ptr ? | 197 | parser->collection_stack_ptr ? |
198 | parser->collection_stack[parser->collection_stack_ptr - 1] : 0; | 198 | parser->collection_stack[parser->collection_stack_ptr - 1] : 0; |
199 | parser->local.usage_index++; | 199 | parser->local.usage_index++; |
200 | return 0; | 200 | return 0; |
201 | } | 201 | } |
202 | 202 | ||
203 | /* | 203 | /* |
204 | * Register a new field for this report. | 204 | * Register a new field for this report. |
205 | */ | 205 | */ |
206 | 206 | ||
207 | static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) | 207 | static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsigned flags) |
208 | { | 208 | { |
209 | struct hid_report *report; | 209 | struct hid_report *report; |
210 | struct hid_field *field; | 210 | struct hid_field *field; |
211 | int usages; | 211 | int usages; |
212 | unsigned offset; | 212 | unsigned offset; |
213 | int i; | 213 | int i; |
214 | 214 | ||
215 | if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) { | 215 | if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) { |
216 | dbg_hid("hid_register_report failed\n"); | 216 | dbg_hid("hid_register_report failed\n"); |
217 | return -1; | 217 | return -1; |
218 | } | 218 | } |
219 | 219 | ||
220 | if (parser->global.logical_maximum < parser->global.logical_minimum) { | 220 | if (parser->global.logical_maximum < parser->global.logical_minimum) { |
221 | dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); | 221 | dbg_hid("logical range invalid %d %d\n", parser->global.logical_minimum, parser->global.logical_maximum); |
222 | return -1; | 222 | return -1; |
223 | } | 223 | } |
224 | 224 | ||
225 | offset = report->size; | 225 | offset = report->size; |
226 | report->size += parser->global.report_size * parser->global.report_count; | 226 | report->size += parser->global.report_size * parser->global.report_count; |
227 | 227 | ||
228 | if (!parser->local.usage_index) /* Ignore padding fields */ | 228 | if (!parser->local.usage_index) /* Ignore padding fields */ |
229 | return 0; | 229 | return 0; |
230 | 230 | ||
231 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); | 231 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); |
232 | 232 | ||
233 | if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL) | 233 | if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL) |
234 | return 0; | 234 | return 0; |
235 | 235 | ||
236 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); | 236 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); |
237 | field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); | 237 | field->logical = hid_lookup_collection(parser, HID_COLLECTION_LOGICAL); |
238 | field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); | 238 | field->application = hid_lookup_collection(parser, HID_COLLECTION_APPLICATION); |
239 | 239 | ||
240 | for (i = 0; i < usages; i++) { | 240 | for (i = 0; i < usages; i++) { |
241 | int j = i; | 241 | int j = i; |
242 | /* Duplicate the last usage we parsed if we have excess values */ | 242 | /* Duplicate the last usage we parsed if we have excess values */ |
243 | if (i >= parser->local.usage_index) | 243 | if (i >= parser->local.usage_index) |
244 | j = parser->local.usage_index - 1; | 244 | j = parser->local.usage_index - 1; |
245 | field->usage[i].hid = parser->local.usage[j]; | 245 | field->usage[i].hid = parser->local.usage[j]; |
246 | field->usage[i].collection_index = | 246 | field->usage[i].collection_index = |
247 | parser->local.collection_index[j]; | 247 | parser->local.collection_index[j]; |
248 | } | 248 | } |
249 | 249 | ||
250 | field->maxusage = usages; | 250 | field->maxusage = usages; |
251 | field->flags = flags; | 251 | field->flags = flags; |
252 | field->report_offset = offset; | 252 | field->report_offset = offset; |
253 | field->report_type = report_type; | 253 | field->report_type = report_type; |
254 | field->report_size = parser->global.report_size; | 254 | field->report_size = parser->global.report_size; |
255 | field->report_count = parser->global.report_count; | 255 | field->report_count = parser->global.report_count; |
256 | field->logical_minimum = parser->global.logical_minimum; | 256 | field->logical_minimum = parser->global.logical_minimum; |
257 | field->logical_maximum = parser->global.logical_maximum; | 257 | field->logical_maximum = parser->global.logical_maximum; |
258 | field->physical_minimum = parser->global.physical_minimum; | 258 | field->physical_minimum = parser->global.physical_minimum; |
259 | field->physical_maximum = parser->global.physical_maximum; | 259 | field->physical_maximum = parser->global.physical_maximum; |
260 | field->unit_exponent = parser->global.unit_exponent; | 260 | field->unit_exponent = parser->global.unit_exponent; |
261 | field->unit = parser->global.unit; | 261 | field->unit = parser->global.unit; |
262 | 262 | ||
263 | return 0; | 263 | return 0; |
264 | } | 264 | } |
265 | 265 | ||
266 | /* | 266 | /* |
267 | * Read data value from item. | 267 | * Read data value from item. |
268 | */ | 268 | */ |
269 | 269 | ||
270 | static u32 item_udata(struct hid_item *item) | 270 | static u32 item_udata(struct hid_item *item) |
271 | { | 271 | { |
272 | switch (item->size) { | 272 | switch (item->size) { |
273 | case 1: return item->data.u8; | 273 | case 1: return item->data.u8; |
274 | case 2: return item->data.u16; | 274 | case 2: return item->data.u16; |
275 | case 4: return item->data.u32; | 275 | case 4: return item->data.u32; |
276 | } | 276 | } |
277 | return 0; | 277 | return 0; |
278 | } | 278 | } |
279 | 279 | ||
280 | static s32 item_sdata(struct hid_item *item) | 280 | static s32 item_sdata(struct hid_item *item) |
281 | { | 281 | { |
282 | switch (item->size) { | 282 | switch (item->size) { |
283 | case 1: return item->data.s8; | 283 | case 1: return item->data.s8; |
284 | case 2: return item->data.s16; | 284 | case 2: return item->data.s16; |
285 | case 4: return item->data.s32; | 285 | case 4: return item->data.s32; |
286 | } | 286 | } |
287 | return 0; | 287 | return 0; |
288 | } | 288 | } |
289 | 289 | ||
290 | /* | 290 | /* |
291 | * Process a global item. | 291 | * Process a global item. |
292 | */ | 292 | */ |
293 | 293 | ||
294 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) | 294 | static int hid_parser_global(struct hid_parser *parser, struct hid_item *item) |
295 | { | 295 | { |
296 | switch (item->tag) { | 296 | switch (item->tag) { |
297 | case HID_GLOBAL_ITEM_TAG_PUSH: | 297 | case HID_GLOBAL_ITEM_TAG_PUSH: |
298 | 298 | ||
299 | if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { | 299 | if (parser->global_stack_ptr == HID_GLOBAL_STACK_SIZE) { |
300 | dbg_hid("global enviroment stack overflow\n"); | 300 | dbg_hid("global enviroment stack overflow\n"); |
301 | return -1; | 301 | return -1; |
302 | } | 302 | } |
303 | 303 | ||
304 | memcpy(parser->global_stack + parser->global_stack_ptr++, | 304 | memcpy(parser->global_stack + parser->global_stack_ptr++, |
305 | &parser->global, sizeof(struct hid_global)); | 305 | &parser->global, sizeof(struct hid_global)); |
306 | return 0; | 306 | return 0; |
307 | 307 | ||
308 | case HID_GLOBAL_ITEM_TAG_POP: | 308 | case HID_GLOBAL_ITEM_TAG_POP: |
309 | 309 | ||
310 | if (!parser->global_stack_ptr) { | 310 | if (!parser->global_stack_ptr) { |
311 | dbg_hid("global enviroment stack underflow\n"); | 311 | dbg_hid("global enviroment stack underflow\n"); |
312 | return -1; | 312 | return -1; |
313 | } | 313 | } |
314 | 314 | ||
315 | memcpy(&parser->global, parser->global_stack + | 315 | memcpy(&parser->global, parser->global_stack + |
316 | --parser->global_stack_ptr, sizeof(struct hid_global)); | 316 | --parser->global_stack_ptr, sizeof(struct hid_global)); |
317 | return 0; | 317 | return 0; |
318 | 318 | ||
319 | case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: | 319 | case HID_GLOBAL_ITEM_TAG_USAGE_PAGE: |
320 | parser->global.usage_page = item_udata(item); | 320 | parser->global.usage_page = item_udata(item); |
321 | return 0; | 321 | return 0; |
322 | 322 | ||
323 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: | 323 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM: |
324 | parser->global.logical_minimum = item_sdata(item); | 324 | parser->global.logical_minimum = item_sdata(item); |
325 | return 0; | 325 | return 0; |
326 | 326 | ||
327 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: | 327 | case HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM: |
328 | if (parser->global.logical_minimum < 0) | 328 | if (parser->global.logical_minimum < 0) |
329 | parser->global.logical_maximum = item_sdata(item); | 329 | parser->global.logical_maximum = item_sdata(item); |
330 | else | 330 | else |
331 | parser->global.logical_maximum = item_udata(item); | 331 | parser->global.logical_maximum = item_udata(item); |
332 | return 0; | 332 | return 0; |
333 | 333 | ||
334 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: | 334 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM: |
335 | parser->global.physical_minimum = item_sdata(item); | 335 | parser->global.physical_minimum = item_sdata(item); |
336 | return 0; | 336 | return 0; |
337 | 337 | ||
338 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: | 338 | case HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM: |
339 | if (parser->global.physical_minimum < 0) | 339 | if (parser->global.physical_minimum < 0) |
340 | parser->global.physical_maximum = item_sdata(item); | 340 | parser->global.physical_maximum = item_sdata(item); |
341 | else | 341 | else |
342 | parser->global.physical_maximum = item_udata(item); | 342 | parser->global.physical_maximum = item_udata(item); |
343 | return 0; | 343 | return 0; |
344 | 344 | ||
345 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: | 345 | case HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT: |
346 | parser->global.unit_exponent = item_sdata(item); | 346 | parser->global.unit_exponent = item_sdata(item); |
347 | return 0; | 347 | return 0; |
348 | 348 | ||
349 | case HID_GLOBAL_ITEM_TAG_UNIT: | 349 | case HID_GLOBAL_ITEM_TAG_UNIT: |
350 | parser->global.unit = item_udata(item); | 350 | parser->global.unit = item_udata(item); |
351 | return 0; | 351 | return 0; |
352 | 352 | ||
353 | case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: | 353 | case HID_GLOBAL_ITEM_TAG_REPORT_SIZE: |
354 | parser->global.report_size = item_udata(item); | 354 | parser->global.report_size = item_udata(item); |
355 | if (parser->global.report_size > 32) { | 355 | if (parser->global.report_size > 32) { |
356 | dbg_hid("invalid report_size %d\n", | 356 | dbg_hid("invalid report_size %d\n", |
357 | parser->global.report_size); | 357 | parser->global.report_size); |
358 | return -1; | 358 | return -1; |
359 | } | 359 | } |
360 | return 0; | 360 | return 0; |
361 | 361 | ||
362 | case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: | 362 | case HID_GLOBAL_ITEM_TAG_REPORT_COUNT: |
363 | parser->global.report_count = item_udata(item); | 363 | parser->global.report_count = item_udata(item); |
364 | if (parser->global.report_count > HID_MAX_USAGES) { | 364 | if (parser->global.report_count > HID_MAX_USAGES) { |
365 | dbg_hid("invalid report_count %d\n", | 365 | dbg_hid("invalid report_count %d\n", |
366 | parser->global.report_count); | 366 | parser->global.report_count); |
367 | return -1; | 367 | return -1; |
368 | } | 368 | } |
369 | return 0; | 369 | return 0; |
370 | 370 | ||
371 | case HID_GLOBAL_ITEM_TAG_REPORT_ID: | 371 | case HID_GLOBAL_ITEM_TAG_REPORT_ID: |
372 | parser->global.report_id = item_udata(item); | 372 | parser->global.report_id = item_udata(item); |
373 | if (parser->global.report_id == 0) { | 373 | if (parser->global.report_id == 0) { |
374 | dbg_hid("report_id 0 is invalid\n"); | 374 | dbg_hid("report_id 0 is invalid\n"); |
375 | return -1; | 375 | return -1; |
376 | } | 376 | } |
377 | return 0; | 377 | return 0; |
378 | 378 | ||
379 | default: | 379 | default: |
380 | dbg_hid("unknown global tag 0x%x\n", item->tag); | 380 | dbg_hid("unknown global tag 0x%x\n", item->tag); |
381 | return -1; | 381 | return -1; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | /* | 385 | /* |
386 | * Process a local item. | 386 | * Process a local item. |
387 | */ | 387 | */ |
388 | 388 | ||
389 | static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) | 389 | static int hid_parser_local(struct hid_parser *parser, struct hid_item *item) |
390 | { | 390 | { |
391 | __u32 data; | 391 | __u32 data; |
392 | unsigned n; | 392 | unsigned n; |
393 | 393 | ||
394 | if (item->size == 0) { | 394 | if (item->size == 0) { |
395 | dbg_hid("item data expected for local item\n"); | 395 | dbg_hid("item data expected for local item\n"); |
396 | return -1; | 396 | return -1; |
397 | } | 397 | } |
398 | 398 | ||
399 | data = item_udata(item); | 399 | data = item_udata(item); |
400 | 400 | ||
401 | switch (item->tag) { | 401 | switch (item->tag) { |
402 | case HID_LOCAL_ITEM_TAG_DELIMITER: | 402 | case HID_LOCAL_ITEM_TAG_DELIMITER: |
403 | 403 | ||
404 | if (data) { | 404 | if (data) { |
405 | /* | 405 | /* |
406 | * We treat items before the first delimiter | 406 | * We treat items before the first delimiter |
407 | * as global to all usage sets (branch 0). | 407 | * as global to all usage sets (branch 0). |
408 | * In the moment we process only these global | 408 | * In the moment we process only these global |
409 | * items and the first delimiter set. | 409 | * items and the first delimiter set. |
410 | */ | 410 | */ |
411 | if (parser->local.delimiter_depth != 0) { | 411 | if (parser->local.delimiter_depth != 0) { |
412 | dbg_hid("nested delimiters\n"); | 412 | dbg_hid("nested delimiters\n"); |
413 | return -1; | 413 | return -1; |
414 | } | 414 | } |
415 | parser->local.delimiter_depth++; | 415 | parser->local.delimiter_depth++; |
416 | parser->local.delimiter_branch++; | 416 | parser->local.delimiter_branch++; |
417 | } else { | 417 | } else { |
418 | if (parser->local.delimiter_depth < 1) { | 418 | if (parser->local.delimiter_depth < 1) { |
419 | dbg_hid("bogus close delimiter\n"); | 419 | dbg_hid("bogus close delimiter\n"); |
420 | return -1; | 420 | return -1; |
421 | } | 421 | } |
422 | parser->local.delimiter_depth--; | 422 | parser->local.delimiter_depth--; |
423 | } | 423 | } |
424 | return 1; | 424 | return 1; |
425 | 425 | ||
426 | case HID_LOCAL_ITEM_TAG_USAGE: | 426 | case HID_LOCAL_ITEM_TAG_USAGE: |
427 | 427 | ||
428 | if (parser->local.delimiter_branch > 1) { | 428 | if (parser->local.delimiter_branch > 1) { |
429 | dbg_hid("alternative usage ignored\n"); | 429 | dbg_hid("alternative usage ignored\n"); |
430 | return 0; | 430 | return 0; |
431 | } | 431 | } |
432 | 432 | ||
433 | if (item->size <= 2) | 433 | if (item->size <= 2) |
434 | data = (parser->global.usage_page << 16) + data; | 434 | data = (parser->global.usage_page << 16) + data; |
435 | 435 | ||
436 | return hid_add_usage(parser, data); | 436 | return hid_add_usage(parser, data); |
437 | 437 | ||
438 | case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: | 438 | case HID_LOCAL_ITEM_TAG_USAGE_MINIMUM: |
439 | 439 | ||
440 | if (parser->local.delimiter_branch > 1) { | 440 | if (parser->local.delimiter_branch > 1) { |
441 | dbg_hid("alternative usage ignored\n"); | 441 | dbg_hid("alternative usage ignored\n"); |
442 | return 0; | 442 | return 0; |
443 | } | 443 | } |
444 | 444 | ||
445 | if (item->size <= 2) | 445 | if (item->size <= 2) |
446 | data = (parser->global.usage_page << 16) + data; | 446 | data = (parser->global.usage_page << 16) + data; |
447 | 447 | ||
448 | parser->local.usage_minimum = data; | 448 | parser->local.usage_minimum = data; |
449 | return 0; | 449 | return 0; |
450 | 450 | ||
451 | case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: | 451 | case HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM: |
452 | 452 | ||
453 | if (parser->local.delimiter_branch > 1) { | 453 | if (parser->local.delimiter_branch > 1) { |
454 | dbg_hid("alternative usage ignored\n"); | 454 | dbg_hid("alternative usage ignored\n"); |
455 | return 0; | 455 | return 0; |
456 | } | 456 | } |
457 | 457 | ||
458 | if (item->size <= 2) | 458 | if (item->size <= 2) |
459 | data = (parser->global.usage_page << 16) + data; | 459 | data = (parser->global.usage_page << 16) + data; |
460 | 460 | ||
461 | for (n = parser->local.usage_minimum; n <= data; n++) | 461 | for (n = parser->local.usage_minimum; n <= data; n++) |
462 | if (hid_add_usage(parser, n)) { | 462 | if (hid_add_usage(parser, n)) { |
463 | dbg_hid("hid_add_usage failed\n"); | 463 | dbg_hid("hid_add_usage failed\n"); |
464 | return -1; | 464 | return -1; |
465 | } | 465 | } |
466 | return 0; | 466 | return 0; |
467 | 467 | ||
468 | default: | 468 | default: |
469 | 469 | ||
470 | dbg_hid("unknown local item tag 0x%x\n", item->tag); | 470 | dbg_hid("unknown local item tag 0x%x\n", item->tag); |
471 | return 0; | 471 | return 0; |
472 | } | 472 | } |
473 | return 0; | 473 | return 0; |
474 | } | 474 | } |
475 | 475 | ||
476 | /* | 476 | /* |
477 | * Process a main item. | 477 | * Process a main item. |
478 | */ | 478 | */ |
479 | 479 | ||
480 | static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) | 480 | static int hid_parser_main(struct hid_parser *parser, struct hid_item *item) |
481 | { | 481 | { |
482 | __u32 data; | 482 | __u32 data; |
483 | int ret; | 483 | int ret; |
484 | 484 | ||
485 | data = item_udata(item); | 485 | data = item_udata(item); |
486 | 486 | ||
487 | switch (item->tag) { | 487 | switch (item->tag) { |
488 | case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: | 488 | case HID_MAIN_ITEM_TAG_BEGIN_COLLECTION: |
489 | ret = open_collection(parser, data & 0xff); | 489 | ret = open_collection(parser, data & 0xff); |
490 | break; | 490 | break; |
491 | case HID_MAIN_ITEM_TAG_END_COLLECTION: | 491 | case HID_MAIN_ITEM_TAG_END_COLLECTION: |
492 | ret = close_collection(parser); | 492 | ret = close_collection(parser); |
493 | break; | 493 | break; |
494 | case HID_MAIN_ITEM_TAG_INPUT: | 494 | case HID_MAIN_ITEM_TAG_INPUT: |
495 | ret = hid_add_field(parser, HID_INPUT_REPORT, data); | 495 | ret = hid_add_field(parser, HID_INPUT_REPORT, data); |
496 | break; | 496 | break; |
497 | case HID_MAIN_ITEM_TAG_OUTPUT: | 497 | case HID_MAIN_ITEM_TAG_OUTPUT: |
498 | ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); | 498 | ret = hid_add_field(parser, HID_OUTPUT_REPORT, data); |
499 | break; | 499 | break; |
500 | case HID_MAIN_ITEM_TAG_FEATURE: | 500 | case HID_MAIN_ITEM_TAG_FEATURE: |
501 | ret = hid_add_field(parser, HID_FEATURE_REPORT, data); | 501 | ret = hid_add_field(parser, HID_FEATURE_REPORT, data); |
502 | break; | 502 | break; |
503 | default: | 503 | default: |
504 | dbg_hid("unknown main item tag 0x%x\n", item->tag); | 504 | dbg_hid("unknown main item tag 0x%x\n", item->tag); |
505 | ret = 0; | 505 | ret = 0; |
506 | } | 506 | } |
507 | 507 | ||
508 | memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ | 508 | memset(&parser->local, 0, sizeof(parser->local)); /* Reset the local parser environment */ |
509 | 509 | ||
510 | return ret; | 510 | return ret; |
511 | } | 511 | } |
512 | 512 | ||
513 | /* | 513 | /* |
514 | * Process a reserved item. | 514 | * Process a reserved item. |
515 | */ | 515 | */ |
516 | 516 | ||
517 | static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) | 517 | static int hid_parser_reserved(struct hid_parser *parser, struct hid_item *item) |
518 | { | 518 | { |
519 | dbg_hid("reserved item type, tag 0x%x\n", item->tag); | 519 | dbg_hid("reserved item type, tag 0x%x\n", item->tag); |
520 | return 0; | 520 | return 0; |
521 | } | 521 | } |
522 | 522 | ||
523 | /* | 523 | /* |
524 | * Free a report and all registered fields. The field->usage and | 524 | * Free a report and all registered fields. The field->usage and |
525 | * field->value table's are allocated behind the field, so we need | 525 | * field->value table's are allocated behind the field, so we need |
526 | * only to free(field) itself. | 526 | * only to free(field) itself. |
527 | */ | 527 | */ |
528 | 528 | ||
529 | static void hid_free_report(struct hid_report *report) | 529 | static void hid_free_report(struct hid_report *report) |
530 | { | 530 | { |
531 | unsigned n; | 531 | unsigned n; |
532 | 532 | ||
533 | for (n = 0; n < report->maxfield; n++) | 533 | for (n = 0; n < report->maxfield; n++) |
534 | kfree(report->field[n]); | 534 | kfree(report->field[n]); |
535 | kfree(report); | 535 | kfree(report); |
536 | } | 536 | } |
537 | 537 | ||
538 | /* | 538 | /* |
539 | * Free a device structure, all reports, and all fields. | 539 | * Free a device structure, all reports, and all fields. |
540 | */ | 540 | */ |
541 | 541 | ||
542 | static void hid_device_release(struct device *dev) | 542 | static void hid_device_release(struct device *dev) |
543 | { | 543 | { |
544 | struct hid_device *device = container_of(dev, struct hid_device, dev); | 544 | struct hid_device *device = container_of(dev, struct hid_device, dev); |
545 | unsigned i, j; | 545 | unsigned i, j; |
546 | 546 | ||
547 | for (i = 0; i < HID_REPORT_TYPES; i++) { | 547 | for (i = 0; i < HID_REPORT_TYPES; i++) { |
548 | struct hid_report_enum *report_enum = device->report_enum + i; | 548 | struct hid_report_enum *report_enum = device->report_enum + i; |
549 | 549 | ||
550 | for (j = 0; j < 256; j++) { | 550 | for (j = 0; j < 256; j++) { |
551 | struct hid_report *report = report_enum->report_id_hash[j]; | 551 | struct hid_report *report = report_enum->report_id_hash[j]; |
552 | if (report) | 552 | if (report) |
553 | hid_free_report(report); | 553 | hid_free_report(report); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | kfree(device->rdesc); | 557 | kfree(device->rdesc); |
558 | kfree(device->collection); | 558 | kfree(device->collection); |
559 | kfree(device); | 559 | kfree(device); |
560 | } | 560 | } |
561 | 561 | ||
562 | /* | 562 | /* |
563 | * Fetch a report description item from the data stream. We support long | 563 | * Fetch a report description item from the data stream. We support long |
564 | * items, though they are not used yet. | 564 | * items, though they are not used yet. |
565 | */ | 565 | */ |
566 | 566 | ||
567 | static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) | 567 | static u8 *fetch_item(__u8 *start, __u8 *end, struct hid_item *item) |
568 | { | 568 | { |
569 | u8 b; | 569 | u8 b; |
570 | 570 | ||
571 | if ((end - start) <= 0) | 571 | if ((end - start) <= 0) |
572 | return NULL; | 572 | return NULL; |
573 | 573 | ||
574 | b = *start++; | 574 | b = *start++; |
575 | 575 | ||
576 | item->type = (b >> 2) & 3; | 576 | item->type = (b >> 2) & 3; |
577 | item->tag = (b >> 4) & 15; | 577 | item->tag = (b >> 4) & 15; |
578 | 578 | ||
579 | if (item->tag == HID_ITEM_TAG_LONG) { | 579 | if (item->tag == HID_ITEM_TAG_LONG) { |
580 | 580 | ||
581 | item->format = HID_ITEM_FORMAT_LONG; | 581 | item->format = HID_ITEM_FORMAT_LONG; |
582 | 582 | ||
583 | if ((end - start) < 2) | 583 | if ((end - start) < 2) |
584 | return NULL; | 584 | return NULL; |
585 | 585 | ||
586 | item->size = *start++; | 586 | item->size = *start++; |
587 | item->tag = *start++; | 587 | item->tag = *start++; |
588 | 588 | ||
589 | if ((end - start) < item->size) | 589 | if ((end - start) < item->size) |
590 | return NULL; | 590 | return NULL; |
591 | 591 | ||
592 | item->data.longdata = start; | 592 | item->data.longdata = start; |
593 | start += item->size; | 593 | start += item->size; |
594 | return start; | 594 | return start; |
595 | } | 595 | } |
596 | 596 | ||
597 | item->format = HID_ITEM_FORMAT_SHORT; | 597 | item->format = HID_ITEM_FORMAT_SHORT; |
598 | item->size = b & 3; | 598 | item->size = b & 3; |
599 | 599 | ||
600 | switch (item->size) { | 600 | switch (item->size) { |
601 | case 0: | 601 | case 0: |
602 | return start; | 602 | return start; |
603 | 603 | ||
604 | case 1: | 604 | case 1: |
605 | if ((end - start) < 1) | 605 | if ((end - start) < 1) |
606 | return NULL; | 606 | return NULL; |
607 | item->data.u8 = *start++; | 607 | item->data.u8 = *start++; |
608 | return start; | 608 | return start; |
609 | 609 | ||
610 | case 2: | 610 | case 2: |
611 | if ((end - start) < 2) | 611 | if ((end - start) < 2) |
612 | return NULL; | 612 | return NULL; |
613 | item->data.u16 = get_unaligned_le16(start); | 613 | item->data.u16 = get_unaligned_le16(start); |
614 | start = (__u8 *)((__le16 *)start + 1); | 614 | start = (__u8 *)((__le16 *)start + 1); |
615 | return start; | 615 | return start; |
616 | 616 | ||
617 | case 3: | 617 | case 3: |
618 | item->size++; | 618 | item->size++; |
619 | if ((end - start) < 4) | 619 | if ((end - start) < 4) |
620 | return NULL; | 620 | return NULL; |
621 | item->data.u32 = get_unaligned_le32(start); | 621 | item->data.u32 = get_unaligned_le32(start); |
622 | start = (__u8 *)((__le32 *)start + 1); | 622 | start = (__u8 *)((__le32 *)start + 1); |
623 | return start; | 623 | return start; |
624 | } | 624 | } |
625 | 625 | ||
626 | return NULL; | 626 | return NULL; |
627 | } | 627 | } |
628 | 628 | ||
629 | /** | 629 | /** |
630 | * hid_parse_report - parse device report | 630 | * hid_parse_report - parse device report |
631 | * | 631 | * |
632 | * @device: hid device | 632 | * @device: hid device |
633 | * @start: report start | 633 | * @start: report start |
634 | * @size: report size | 634 | * @size: report size |
635 | * | 635 | * |
636 | * Parse a report description into a hid_device structure. Reports are | 636 | * Parse a report description into a hid_device structure. Reports are |
637 | * enumerated, fields are attached to these reports. | 637 | * enumerated, fields are attached to these reports. |
638 | * 0 returned on success, otherwise nonzero error value. | 638 | * 0 returned on success, otherwise nonzero error value. |
639 | */ | 639 | */ |
640 | int hid_parse_report(struct hid_device *device, __u8 *start, | 640 | int hid_parse_report(struct hid_device *device, __u8 *start, |
641 | unsigned size) | 641 | unsigned size) |
642 | { | 642 | { |
643 | struct hid_parser *parser; | 643 | struct hid_parser *parser; |
644 | struct hid_item item; | 644 | struct hid_item item; |
645 | __u8 *end; | 645 | __u8 *end; |
646 | int ret; | 646 | int ret; |
647 | static int (*dispatch_type[])(struct hid_parser *parser, | 647 | static int (*dispatch_type[])(struct hid_parser *parser, |
648 | struct hid_item *item) = { | 648 | struct hid_item *item) = { |
649 | hid_parser_main, | 649 | hid_parser_main, |
650 | hid_parser_global, | 650 | hid_parser_global, |
651 | hid_parser_local, | 651 | hid_parser_local, |
652 | hid_parser_reserved | 652 | hid_parser_reserved |
653 | }; | 653 | }; |
654 | 654 | ||
655 | if (device->driver->report_fixup) | 655 | if (device->driver->report_fixup) |
656 | device->driver->report_fixup(device, start, size); | 656 | device->driver->report_fixup(device, start, size); |
657 | 657 | ||
658 | device->rdesc = kmalloc(size, GFP_KERNEL); | 658 | device->rdesc = kmalloc(size, GFP_KERNEL); |
659 | if (device->rdesc == NULL) | 659 | if (device->rdesc == NULL) |
660 | return -ENOMEM; | 660 | return -ENOMEM; |
661 | memcpy(device->rdesc, start, size); | 661 | memcpy(device->rdesc, start, size); |
662 | device->rsize = size; | 662 | device->rsize = size; |
663 | 663 | ||
664 | parser = vmalloc(sizeof(struct hid_parser)); | 664 | parser = vmalloc(sizeof(struct hid_parser)); |
665 | if (!parser) { | 665 | if (!parser) { |
666 | ret = -ENOMEM; | 666 | ret = -ENOMEM; |
667 | goto err; | 667 | goto err; |
668 | } | 668 | } |
669 | 669 | ||
670 | memset(parser, 0, sizeof(struct hid_parser)); | 670 | memset(parser, 0, sizeof(struct hid_parser)); |
671 | parser->device = device; | 671 | parser->device = device; |
672 | 672 | ||
673 | end = start + size; | 673 | end = start + size; |
674 | ret = -EINVAL; | 674 | ret = -EINVAL; |
675 | while ((start = fetch_item(start, end, &item)) != NULL) { | 675 | while ((start = fetch_item(start, end, &item)) != NULL) { |
676 | 676 | ||
677 | if (item.format != HID_ITEM_FORMAT_SHORT) { | 677 | if (item.format != HID_ITEM_FORMAT_SHORT) { |
678 | dbg_hid("unexpected long global item\n"); | 678 | dbg_hid("unexpected long global item\n"); |
679 | goto err; | 679 | goto err; |
680 | } | 680 | } |
681 | 681 | ||
682 | if (dispatch_type[item.type](parser, &item)) { | 682 | if (dispatch_type[item.type](parser, &item)) { |
683 | dbg_hid("item %u %u %u %u parsing failed\n", | 683 | dbg_hid("item %u %u %u %u parsing failed\n", |
684 | item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag); | 684 | item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag); |
685 | goto err; | 685 | goto err; |
686 | } | 686 | } |
687 | 687 | ||
688 | if (start == end) { | 688 | if (start == end) { |
689 | if (parser->collection_stack_ptr) { | 689 | if (parser->collection_stack_ptr) { |
690 | dbg_hid("unbalanced collection at end of report description\n"); | 690 | dbg_hid("unbalanced collection at end of report description\n"); |
691 | goto err; | 691 | goto err; |
692 | } | 692 | } |
693 | if (parser->local.delimiter_depth) { | 693 | if (parser->local.delimiter_depth) { |
694 | dbg_hid("unbalanced delimiter at end of report description\n"); | 694 | dbg_hid("unbalanced delimiter at end of report description\n"); |
695 | goto err; | 695 | goto err; |
696 | } | 696 | } |
697 | vfree(parser); | 697 | vfree(parser); |
698 | return 0; | 698 | return 0; |
699 | } | 699 | } |
700 | } | 700 | } |
701 | 701 | ||
702 | dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); | 702 | dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); |
703 | err: | 703 | err: |
704 | vfree(parser); | 704 | vfree(parser); |
705 | return ret; | 705 | return ret; |
706 | } | 706 | } |
707 | EXPORT_SYMBOL_GPL(hid_parse_report); | 707 | EXPORT_SYMBOL_GPL(hid_parse_report); |
708 | 708 | ||
709 | /* | 709 | /* |
710 | * Convert a signed n-bit integer to signed 32-bit integer. Common | 710 | * Convert a signed n-bit integer to signed 32-bit integer. Common |
711 | * cases are done through the compiler, the screwed things has to be | 711 | * cases are done through the compiler, the screwed things has to be |
712 | * done by hand. | 712 | * done by hand. |
713 | */ | 713 | */ |
714 | 714 | ||
715 | static s32 snto32(__u32 value, unsigned n) | 715 | static s32 snto32(__u32 value, unsigned n) |
716 | { | 716 | { |
717 | switch (n) { | 717 | switch (n) { |
718 | case 8: return ((__s8)value); | 718 | case 8: return ((__s8)value); |
719 | case 16: return ((__s16)value); | 719 | case 16: return ((__s16)value); |
720 | case 32: return ((__s32)value); | 720 | case 32: return ((__s32)value); |
721 | } | 721 | } |
722 | return value & (1 << (n - 1)) ? value | (-1 << n) : value; | 722 | return value & (1 << (n - 1)) ? value | (-1 << n) : value; |
723 | } | 723 | } |
724 | 724 | ||
725 | /* | 725 | /* |
726 | * Convert a signed 32-bit integer to a signed n-bit integer. | 726 | * Convert a signed 32-bit integer to a signed n-bit integer. |
727 | */ | 727 | */ |
728 | 728 | ||
729 | static u32 s32ton(__s32 value, unsigned n) | 729 | static u32 s32ton(__s32 value, unsigned n) |
730 | { | 730 | { |
731 | s32 a = value >> (n - 1); | 731 | s32 a = value >> (n - 1); |
732 | if (a && a != -1) | 732 | if (a && a != -1) |
733 | return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; | 733 | return value < 0 ? 1 << (n - 1) : (1 << (n - 1)) - 1; |
734 | return value & ((1 << n) - 1); | 734 | return value & ((1 << n) - 1); |
735 | } | 735 | } |
736 | 736 | ||
737 | /* | 737 | /* |
738 | * Extract/implement a data field from/to a little endian report (bit array). | 738 | * Extract/implement a data field from/to a little endian report (bit array). |
739 | * | 739 | * |
740 | * Code sort-of follows HID spec: | 740 | * Code sort-of follows HID spec: |
741 | * http://www.usb.org/developers/devclass_docs/HID1_11.pdf | 741 | * http://www.usb.org/developers/devclass_docs/HID1_11.pdf |
742 | * | 742 | * |
743 | * While the USB HID spec allows unlimited length bit fields in "report | 743 | * While the USB HID spec allows unlimited length bit fields in "report |
744 | * descriptors", most devices never use more than 16 bits. | 744 | * descriptors", most devices never use more than 16 bits. |
745 | * One model of UPS is claimed to report "LINEV" as a 32-bit field. | 745 | * One model of UPS is claimed to report "LINEV" as a 32-bit field. |
746 | * Search linux-kernel and linux-usb-devel archives for "hid-core extract". | 746 | * Search linux-kernel and linux-usb-devel archives for "hid-core extract". |
747 | */ | 747 | */ |
748 | 748 | ||
749 | static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) | 749 | static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) |
750 | { | 750 | { |
751 | u64 x; | 751 | u64 x; |
752 | 752 | ||
753 | if (n > 32) | 753 | if (n > 32) |
754 | printk(KERN_WARNING "HID: extract() called with n (%d) > 32! (%s)\n", | 754 | printk(KERN_WARNING "HID: extract() called with n (%d) > 32! (%s)\n", |
755 | n, current->comm); | 755 | n, current->comm); |
756 | 756 | ||
757 | report += offset >> 3; /* adjust byte index */ | 757 | report += offset >> 3; /* adjust byte index */ |
758 | offset &= 7; /* now only need bit offset into one byte */ | 758 | offset &= 7; /* now only need bit offset into one byte */ |
759 | x = get_unaligned_le64(report); | 759 | x = get_unaligned_le64(report); |
760 | x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ | 760 | x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */ |
761 | return (u32) x; | 761 | return (u32) x; |
762 | } | 762 | } |
763 | 763 | ||
764 | /* | 764 | /* |
765 | * "implement" : set bits in a little endian bit stream. | 765 | * "implement" : set bits in a little endian bit stream. |
766 | * Same concepts as "extract" (see comments above). | 766 | * Same concepts as "extract" (see comments above). |
767 | * The data mangled in the bit stream remains in little endian | 767 | * The data mangled in the bit stream remains in little endian |
768 | * order the whole time. It make more sense to talk about | 768 | * order the whole time. It make more sense to talk about |
769 | * endianness of register values by considering a register | 769 | * endianness of register values by considering a register |
770 | * a "cached" copy of the little endiad bit stream. | 770 | * a "cached" copy of the little endiad bit stream. |
771 | */ | 771 | */ |
772 | static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) | 772 | static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) |
773 | { | 773 | { |
774 | u64 x; | 774 | u64 x; |
775 | u64 m = (1ULL << n) - 1; | 775 | u64 m = (1ULL << n) - 1; |
776 | 776 | ||
777 | if (n > 32) | 777 | if (n > 32) |
778 | printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n", | 778 | printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n", |
779 | n, current->comm); | 779 | n, current->comm); |
780 | 780 | ||
781 | if (value > m) | 781 | if (value > m) |
782 | printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n", | 782 | printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n", |
783 | value, current->comm); | 783 | value, current->comm); |
784 | WARN_ON(value > m); | 784 | WARN_ON(value > m); |
785 | value &= m; | 785 | value &= m; |
786 | 786 | ||
787 | report += offset >> 3; | 787 | report += offset >> 3; |
788 | offset &= 7; | 788 | offset &= 7; |
789 | 789 | ||
790 | x = get_unaligned_le64(report); | 790 | x = get_unaligned_le64(report); |
791 | x &= ~(m << offset); | 791 | x &= ~(m << offset); |
792 | x |= ((u64)value) << offset; | 792 | x |= ((u64)value) << offset; |
793 | put_unaligned_le64(x, report); | 793 | put_unaligned_le64(x, report); |
794 | } | 794 | } |
795 | 795 | ||
796 | /* | 796 | /* |
797 | * Search an array for a value. | 797 | * Search an array for a value. |
798 | */ | 798 | */ |
799 | 799 | ||
800 | static __inline__ int search(__s32 *array, __s32 value, unsigned n) | 800 | static __inline__ int search(__s32 *array, __s32 value, unsigned n) |
801 | { | 801 | { |
802 | while (n--) { | 802 | while (n--) { |
803 | if (*array++ == value) | 803 | if (*array++ == value) |
804 | return 0; | 804 | return 0; |
805 | } | 805 | } |
806 | return -1; | 806 | return -1; |
807 | } | 807 | } |
808 | 808 | ||
809 | /** | 809 | /** |
810 | * hid_match_report - check if driver's raw_event should be called | 810 | * hid_match_report - check if driver's raw_event should be called |
811 | * | 811 | * |
812 | * @hid: hid device | 812 | * @hid: hid device |
813 | * @report_type: type to match against | 813 | * @report_type: type to match against |
814 | * | 814 | * |
815 | * compare hid->driver->report_table->report_type to report->type | 815 | * compare hid->driver->report_table->report_type to report->type |
816 | */ | 816 | */ |
817 | static int hid_match_report(struct hid_device *hid, struct hid_report *report) | 817 | static int hid_match_report(struct hid_device *hid, struct hid_report *report) |
818 | { | 818 | { |
819 | const struct hid_report_id *id = hid->driver->report_table; | 819 | const struct hid_report_id *id = hid->driver->report_table; |
820 | 820 | ||
821 | if (!id) /* NULL means all */ | 821 | if (!id) /* NULL means all */ |
822 | return 1; | 822 | return 1; |
823 | 823 | ||
824 | for (; id->report_type != HID_TERMINATOR; id++) | 824 | for (; id->report_type != HID_TERMINATOR; id++) |
825 | if (id->report_type == HID_ANY_ID || | 825 | if (id->report_type == HID_ANY_ID || |
826 | id->report_type == report->type) | 826 | id->report_type == report->type) |
827 | return 1; | 827 | return 1; |
828 | return 0; | 828 | return 0; |
829 | } | 829 | } |
830 | 830 | ||
831 | /** | 831 | /** |
832 | * hid_match_usage - check if driver's event should be called | 832 | * hid_match_usage - check if driver's event should be called |
833 | * | 833 | * |
834 | * @hid: hid device | 834 | * @hid: hid device |
835 | * @usage: usage to match against | 835 | * @usage: usage to match against |
836 | * | 836 | * |
837 | * compare hid->driver->usage_table->usage_{type,code} to | 837 | * compare hid->driver->usage_table->usage_{type,code} to |
838 | * usage->usage_{type,code} | 838 | * usage->usage_{type,code} |
839 | */ | 839 | */ |
840 | static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) | 840 | static int hid_match_usage(struct hid_device *hid, struct hid_usage *usage) |
841 | { | 841 | { |
842 | const struct hid_usage_id *id = hid->driver->usage_table; | 842 | const struct hid_usage_id *id = hid->driver->usage_table; |
843 | 843 | ||
844 | if (!id) /* NULL means all */ | 844 | if (!id) /* NULL means all */ |
845 | return 1; | 845 | return 1; |
846 | 846 | ||
847 | for (; id->usage_type != HID_ANY_ID - 1; id++) | 847 | for (; id->usage_type != HID_ANY_ID - 1; id++) |
848 | if ((id->usage_hid == HID_ANY_ID || | 848 | if ((id->usage_hid == HID_ANY_ID || |
849 | id->usage_hid == usage->hid) && | 849 | id->usage_hid == usage->hid) && |
850 | (id->usage_type == HID_ANY_ID || | 850 | (id->usage_type == HID_ANY_ID || |
851 | id->usage_type == usage->type) && | 851 | id->usage_type == usage->type) && |
852 | (id->usage_code == HID_ANY_ID || | 852 | (id->usage_code == HID_ANY_ID || |
853 | id->usage_code == usage->code)) | 853 | id->usage_code == usage->code)) |
854 | return 1; | 854 | return 1; |
855 | return 0; | 855 | return 0; |
856 | } | 856 | } |
857 | 857 | ||
858 | static void hid_process_event(struct hid_device *hid, struct hid_field *field, | 858 | static void hid_process_event(struct hid_device *hid, struct hid_field *field, |
859 | struct hid_usage *usage, __s32 value, int interrupt) | 859 | struct hid_usage *usage, __s32 value, int interrupt) |
860 | { | 860 | { |
861 | struct hid_driver *hdrv = hid->driver; | 861 | struct hid_driver *hdrv = hid->driver; |
862 | int ret; | 862 | int ret; |
863 | 863 | ||
864 | hid_dump_input(usage, value); | 864 | hid_dump_input(usage, value); |
865 | 865 | ||
866 | if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { | 866 | if (hdrv && hdrv->event && hid_match_usage(hid, usage)) { |
867 | ret = hdrv->event(hid, field, usage, value); | 867 | ret = hdrv->event(hid, field, usage, value); |
868 | if (ret != 0) { | 868 | if (ret != 0) { |
869 | if (ret < 0) | 869 | if (ret < 0) |
870 | dbg_hid("%s's event failed with %d\n", | 870 | dbg_hid("%s's event failed with %d\n", |
871 | hdrv->name, ret); | 871 | hdrv->name, ret); |
872 | return; | 872 | return; |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | if (hid->claimed & HID_CLAIMED_INPUT) | 876 | if (hid->claimed & HID_CLAIMED_INPUT) |
877 | hidinput_hid_event(hid, field, usage, value); | 877 | hidinput_hid_event(hid, field, usage, value); |
878 | if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) | 878 | if (hid->claimed & HID_CLAIMED_HIDDEV && interrupt && hid->hiddev_hid_event) |
879 | hid->hiddev_hid_event(hid, field, usage, value); | 879 | hid->hiddev_hid_event(hid, field, usage, value); |
880 | } | 880 | } |
881 | 881 | ||
882 | /* | 882 | /* |
883 | * Analyse a received field, and fetch the data from it. The field | 883 | * Analyse a received field, and fetch the data from it. The field |
884 | * content is stored for next report processing (we do differential | 884 | * content is stored for next report processing (we do differential |
885 | * reporting to the layer). | 885 | * reporting to the layer). |
886 | */ | 886 | */ |
887 | 887 | ||
888 | static void hid_input_field(struct hid_device *hid, struct hid_field *field, | 888 | static void hid_input_field(struct hid_device *hid, struct hid_field *field, |
889 | __u8 *data, int interrupt) | 889 | __u8 *data, int interrupt) |
890 | { | 890 | { |
891 | unsigned n; | 891 | unsigned n; |
892 | unsigned count = field->report_count; | 892 | unsigned count = field->report_count; |
893 | unsigned offset = field->report_offset; | 893 | unsigned offset = field->report_offset; |
894 | unsigned size = field->report_size; | 894 | unsigned size = field->report_size; |
895 | __s32 min = field->logical_minimum; | 895 | __s32 min = field->logical_minimum; |
896 | __s32 max = field->logical_maximum; | 896 | __s32 max = field->logical_maximum; |
897 | __s32 *value; | 897 | __s32 *value; |
898 | 898 | ||
899 | if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC))) | 899 | if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC))) |
900 | return; | 900 | return; |
901 | 901 | ||
902 | for (n = 0; n < count; n++) { | 902 | for (n = 0; n < count; n++) { |
903 | 903 | ||
904 | value[n] = min < 0 ? snto32(extract(data, offset + n * size, size), size) : | 904 | value[n] = min < 0 ? snto32(extract(data, offset + n * size, size), size) : |
905 | extract(data, offset + n * size, size); | 905 | extract(data, offset + n * size, size); |
906 | 906 | ||
907 | if (!(field->flags & HID_MAIN_ITEM_VARIABLE) /* Ignore report if ErrorRollOver */ | 907 | if (!(field->flags & HID_MAIN_ITEM_VARIABLE) /* Ignore report if ErrorRollOver */ |
908 | && value[n] >= min && value[n] <= max | 908 | && value[n] >= min && value[n] <= max |
909 | && field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) | 909 | && field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) |
910 | goto exit; | 910 | goto exit; |
911 | } | 911 | } |
912 | 912 | ||
913 | for (n = 0; n < count; n++) { | 913 | for (n = 0; n < count; n++) { |
914 | 914 | ||
915 | if (HID_MAIN_ITEM_VARIABLE & field->flags) { | 915 | if (HID_MAIN_ITEM_VARIABLE & field->flags) { |
916 | hid_process_event(hid, field, &field->usage[n], value[n], interrupt); | 916 | hid_process_event(hid, field, &field->usage[n], value[n], interrupt); |
917 | continue; | 917 | continue; |
918 | } | 918 | } |
919 | 919 | ||
920 | if (field->value[n] >= min && field->value[n] <= max | 920 | if (field->value[n] >= min && field->value[n] <= max |
921 | && field->usage[field->value[n] - min].hid | 921 | && field->usage[field->value[n] - min].hid |
922 | && search(value, field->value[n], count)) | 922 | && search(value, field->value[n], count)) |
923 | hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); | 923 | hid_process_event(hid, field, &field->usage[field->value[n] - min], 0, interrupt); |
924 | 924 | ||
925 | if (value[n] >= min && value[n] <= max | 925 | if (value[n] >= min && value[n] <= max |
926 | && field->usage[value[n] - min].hid | 926 | && field->usage[value[n] - min].hid |
927 | && search(field->value, value[n], count)) | 927 | && search(field->value, value[n], count)) |
928 | hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); | 928 | hid_process_event(hid, field, &field->usage[value[n] - min], 1, interrupt); |
929 | } | 929 | } |
930 | 930 | ||
931 | memcpy(field->value, value, count * sizeof(__s32)); | 931 | memcpy(field->value, value, count * sizeof(__s32)); |
932 | exit: | 932 | exit: |
933 | kfree(value); | 933 | kfree(value); |
934 | } | 934 | } |
935 | 935 | ||
936 | /* | 936 | /* |
937 | * Output the field into the report. | 937 | * Output the field into the report. |
938 | */ | 938 | */ |
939 | 939 | ||
940 | static void hid_output_field(struct hid_field *field, __u8 *data) | 940 | static void hid_output_field(struct hid_field *field, __u8 *data) |
941 | { | 941 | { |
942 | unsigned count = field->report_count; | 942 | unsigned count = field->report_count; |
943 | unsigned offset = field->report_offset; | 943 | unsigned offset = field->report_offset; |
944 | unsigned size = field->report_size; | 944 | unsigned size = field->report_size; |
945 | unsigned bitsused = offset + count * size; | 945 | unsigned bitsused = offset + count * size; |
946 | unsigned n; | 946 | unsigned n; |
947 | 947 | ||
948 | /* make sure the unused bits in the last byte are zeros */ | 948 | /* make sure the unused bits in the last byte are zeros */ |
949 | if (count > 0 && size > 0 && (bitsused % 8) != 0) | 949 | if (count > 0 && size > 0 && (bitsused % 8) != 0) |
950 | data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1; | 950 | data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1; |
951 | 951 | ||
952 | for (n = 0; n < count; n++) { | 952 | for (n = 0; n < count; n++) { |
953 | if (field->logical_minimum < 0) /* signed values */ | 953 | if (field->logical_minimum < 0) /* signed values */ |
954 | implement(data, offset + n * size, size, s32ton(field->value[n], size)); | 954 | implement(data, offset + n * size, size, s32ton(field->value[n], size)); |
955 | else /* unsigned values */ | 955 | else /* unsigned values */ |
956 | implement(data, offset + n * size, size, field->value[n]); | 956 | implement(data, offset + n * size, size, field->value[n]); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | 959 | ||
960 | /* | 960 | /* |
961 | * Create a report. | 961 | * Create a report. |
962 | */ | 962 | */ |
963 | 963 | ||
964 | void hid_output_report(struct hid_report *report, __u8 *data) | 964 | void hid_output_report(struct hid_report *report, __u8 *data) |
965 | { | 965 | { |
966 | unsigned n; | 966 | unsigned n; |
967 | 967 | ||
968 | if (report->id > 0) | 968 | if (report->id > 0) |
969 | *data++ = report->id; | 969 | *data++ = report->id; |
970 | 970 | ||
971 | for (n = 0; n < report->maxfield; n++) | 971 | for (n = 0; n < report->maxfield; n++) |
972 | hid_output_field(report->field[n], data); | 972 | hid_output_field(report->field[n], data); |
973 | } | 973 | } |
974 | EXPORT_SYMBOL_GPL(hid_output_report); | 974 | EXPORT_SYMBOL_GPL(hid_output_report); |
975 | 975 | ||
976 | /* | 976 | /* |
977 | * Set a field value. The report this field belongs to has to be | 977 | * Set a field value. The report this field belongs to has to be |
978 | * created and transferred to the device, to set this value in the | 978 | * created and transferred to the device, to set this value in the |
979 | * device. | 979 | * device. |
980 | */ | 980 | */ |
981 | 981 | ||
982 | int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) | 982 | int hid_set_field(struct hid_field *field, unsigned offset, __s32 value) |
983 | { | 983 | { |
984 | unsigned size = field->report_size; | 984 | unsigned size = field->report_size; |
985 | 985 | ||
986 | hid_dump_input(field->usage + offset, value); | 986 | hid_dump_input(field->usage + offset, value); |
987 | 987 | ||
988 | if (offset >= field->report_count) { | 988 | if (offset >= field->report_count) { |
989 | dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); | 989 | dbg_hid("offset (%d) exceeds report_count (%d)\n", offset, field->report_count); |
990 | hid_dump_field(field, 8); | 990 | hid_dump_field(field, 8); |
991 | return -1; | 991 | return -1; |
992 | } | 992 | } |
993 | if (field->logical_minimum < 0) { | 993 | if (field->logical_minimum < 0) { |
994 | if (value != snto32(s32ton(value, size), size)) { | 994 | if (value != snto32(s32ton(value, size), size)) { |
995 | dbg_hid("value %d is out of range\n", value); | 995 | dbg_hid("value %d is out of range\n", value); |
996 | return -1; | 996 | return -1; |
997 | } | 997 | } |
998 | } | 998 | } |
999 | field->value[offset] = value; | 999 | field->value[offset] = value; |
1000 | return 0; | 1000 | return 0; |
1001 | } | 1001 | } |
1002 | EXPORT_SYMBOL_GPL(hid_set_field); | 1002 | EXPORT_SYMBOL_GPL(hid_set_field); |
1003 | 1003 | ||
1004 | static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, | 1004 | static struct hid_report *hid_get_report(struct hid_report_enum *report_enum, |
1005 | const u8 *data) | 1005 | const u8 *data) |
1006 | { | 1006 | { |
1007 | struct hid_report *report; | 1007 | struct hid_report *report; |
1008 | unsigned int n = 0; /* Normally report number is 0 */ | 1008 | unsigned int n = 0; /* Normally report number is 0 */ |
1009 | 1009 | ||
1010 | /* Device uses numbered reports, data[0] is report number */ | 1010 | /* Device uses numbered reports, data[0] is report number */ |
1011 | if (report_enum->numbered) | 1011 | if (report_enum->numbered) |
1012 | n = *data; | 1012 | n = *data; |
1013 | 1013 | ||
1014 | report = report_enum->report_id_hash[n]; | 1014 | report = report_enum->report_id_hash[n]; |
1015 | if (report == NULL) | 1015 | if (report == NULL) |
1016 | dbg_hid("undefined report_id %u received\n", n); | 1016 | dbg_hid("undefined report_id %u received\n", n); |
1017 | 1017 | ||
1018 | return report; | 1018 | return report; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, | 1021 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
1022 | int interrupt) | 1022 | int interrupt) |
1023 | { | 1023 | { |
1024 | struct hid_report_enum *report_enum = hid->report_enum + type; | 1024 | struct hid_report_enum *report_enum = hid->report_enum + type; |
1025 | struct hid_report *report; | 1025 | struct hid_report *report; |
1026 | unsigned int a; | 1026 | unsigned int a; |
1027 | int rsize, csize = size; | 1027 | int rsize, csize = size; |
1028 | u8 *cdata = data; | 1028 | u8 *cdata = data; |
1029 | 1029 | ||
1030 | report = hid_get_report(report_enum, data); | 1030 | report = hid_get_report(report_enum, data); |
1031 | if (!report) | 1031 | if (!report) |
1032 | return; | 1032 | return; |
1033 | 1033 | ||
1034 | if (report_enum->numbered) { | 1034 | if (report_enum->numbered) { |
1035 | cdata++; | 1035 | cdata++; |
1036 | csize--; | 1036 | csize--; |
1037 | } | 1037 | } |
1038 | 1038 | ||
1039 | rsize = ((report->size - 1) >> 3) + 1; | 1039 | rsize = ((report->size - 1) >> 3) + 1; |
1040 | 1040 | ||
1041 | if (csize < rsize) { | 1041 | if (csize < rsize) { |
1042 | dbg_hid("report %d is too short, (%d < %d)\n", report->id, | 1042 | dbg_hid("report %d is too short, (%d < %d)\n", report->id, |
1043 | csize, rsize); | 1043 | csize, rsize); |
1044 | memset(cdata + csize, 0, rsize - csize); | 1044 | memset(cdata + csize, 0, rsize - csize); |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) | 1047 | if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event) |
1048 | hid->hiddev_report_event(hid, report); | 1048 | hid->hiddev_report_event(hid, report); |
1049 | if (hid->claimed & HID_CLAIMED_HIDRAW) { | 1049 | if (hid->claimed & HID_CLAIMED_HIDRAW) { |
1050 | /* numbered reports need to be passed with the report num */ | 1050 | /* numbered reports need to be passed with the report num */ |
1051 | if (report_enum->numbered) | 1051 | if (report_enum->numbered) |
1052 | hidraw_report_event(hid, data - 1, size + 1); | 1052 | hidraw_report_event(hid, data - 1, size + 1); |
1053 | else | 1053 | else |
1054 | hidraw_report_event(hid, data, size); | 1054 | hidraw_report_event(hid, data, size); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | for (a = 0; a < report->maxfield; a++) | 1057 | for (a = 0; a < report->maxfield; a++) |
1058 | hid_input_field(hid, report->field[a], cdata, interrupt); | 1058 | hid_input_field(hid, report->field[a], cdata, interrupt); |
1059 | 1059 | ||
1060 | if (hid->claimed & HID_CLAIMED_INPUT) | 1060 | if (hid->claimed & HID_CLAIMED_INPUT) |
1061 | hidinput_report_event(hid, report); | 1061 | hidinput_report_event(hid, report); |
1062 | } | 1062 | } |
1063 | EXPORT_SYMBOL_GPL(hid_report_raw_event); | 1063 | EXPORT_SYMBOL_GPL(hid_report_raw_event); |
1064 | 1064 | ||
1065 | /** | 1065 | /** |
1066 | * hid_input_report - report data from lower layer (usb, bt...) | 1066 | * hid_input_report - report data from lower layer (usb, bt...) |
1067 | * | 1067 | * |
1068 | * @hid: hid device | 1068 | * @hid: hid device |
1069 | * @type: HID report type (HID_*_REPORT) | 1069 | * @type: HID report type (HID_*_REPORT) |
1070 | * @data: report contents | 1070 | * @data: report contents |
1071 | * @size: size of data parameter | 1071 | * @size: size of data parameter |
1072 | * @interrupt: called from atomic? | 1072 | * @interrupt: called from atomic? |
1073 | * | 1073 | * |
1074 | * This is data entry for lower layers. | 1074 | * This is data entry for lower layers. |
1075 | */ | 1075 | */ |
1076 | int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) | 1076 | int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt) |
1077 | { | 1077 | { |
1078 | struct hid_report_enum *report_enum = hid->report_enum + type; | 1078 | struct hid_report_enum *report_enum = hid->report_enum + type; |
1079 | struct hid_driver *hdrv = hid->driver; | 1079 | struct hid_driver *hdrv = hid->driver; |
1080 | struct hid_report *report; | 1080 | struct hid_report *report; |
1081 | unsigned int i; | 1081 | unsigned int i; |
1082 | int ret; | 1082 | int ret; |
1083 | 1083 | ||
1084 | if (!hid || !hid->driver) | 1084 | if (!hid || !hid->driver) |
1085 | return -ENODEV; | 1085 | return -ENODEV; |
1086 | 1086 | ||
1087 | if (!size) { | 1087 | if (!size) { |
1088 | dbg_hid("empty report\n"); | 1088 | dbg_hid("empty report\n"); |
1089 | return -1; | 1089 | return -1; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un"); | 1092 | dbg_hid("report (size %u) (%snumbered)\n", size, report_enum->numbered ? "" : "un"); |
1093 | 1093 | ||
1094 | report = hid_get_report(report_enum, data); | 1094 | report = hid_get_report(report_enum, data); |
1095 | if (!report) | 1095 | if (!report) |
1096 | return -1; | 1096 | return -1; |
1097 | 1097 | ||
1098 | /* dump the report */ | 1098 | /* dump the report */ |
1099 | dbg_hid("report %d (size %u) = ", report->id, size); | 1099 | dbg_hid("report %d (size %u) = ", report->id, size); |
1100 | for (i = 0; i < size; i++) | 1100 | for (i = 0; i < size; i++) |
1101 | dbg_hid_line(" %02x", data[i]); | 1101 | dbg_hid_line(" %02x", data[i]); |
1102 | dbg_hid_line("\n"); | 1102 | dbg_hid_line("\n"); |
1103 | 1103 | ||
1104 | if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { | 1104 | if (hdrv && hdrv->raw_event && hid_match_report(hid, report)) { |
1105 | ret = hdrv->raw_event(hid, report, data, size); | 1105 | ret = hdrv->raw_event(hid, report, data, size); |
1106 | if (ret != 0) | 1106 | if (ret != 0) |
1107 | return ret < 0 ? ret : 0; | 1107 | return ret < 0 ? ret : 0; |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | hid_report_raw_event(hid, type, data, size, interrupt); | 1110 | hid_report_raw_event(hid, type, data, size, interrupt); |
1111 | 1111 | ||
1112 | return 0; | 1112 | return 0; |
1113 | } | 1113 | } |
1114 | EXPORT_SYMBOL_GPL(hid_input_report); | 1114 | EXPORT_SYMBOL_GPL(hid_input_report); |
1115 | 1115 | ||
1116 | static bool hid_match_one_id(struct hid_device *hdev, | 1116 | static bool hid_match_one_id(struct hid_device *hdev, |
1117 | const struct hid_device_id *id) | 1117 | const struct hid_device_id *id) |
1118 | { | 1118 | { |
1119 | return id->bus == hdev->bus && | 1119 | return id->bus == hdev->bus && |
1120 | (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && | 1120 | (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && |
1121 | (id->product == HID_ANY_ID || id->product == hdev->product); | 1121 | (id->product == HID_ANY_ID || id->product == hdev->product); |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | static const struct hid_device_id *hid_match_id(struct hid_device *hdev, | 1124 | static const struct hid_device_id *hid_match_id(struct hid_device *hdev, |
1125 | const struct hid_device_id *id) | 1125 | const struct hid_device_id *id) |
1126 | { | 1126 | { |
1127 | for (; id->bus; id++) | 1127 | for (; id->bus; id++) |
1128 | if (hid_match_one_id(hdev, id)) | 1128 | if (hid_match_one_id(hdev, id)) |
1129 | return id; | 1129 | return id; |
1130 | 1130 | ||
1131 | return NULL; | 1131 | return NULL; |
1132 | } | 1132 | } |
1133 | 1133 | ||
1134 | static const struct hid_device_id hid_blacklist[] = { | 1134 | static const struct hid_device_id hid_blacklist[] = { |
1135 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, | 1135 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, |
1136 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, | 1136 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, |
1137 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, | 1137 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IRCONTROL4) }, |
1138 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, | 1138 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, |
1139 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, | 1139 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, |
1140 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, | 1140 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, |
1141 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, | 1141 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, |
1142 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, | 1142 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, |
1143 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, | 1143 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, |
1144 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, | 1144 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, |
1145 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, | 1145 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, |
1146 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, | 1146 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, |
1147 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, | 1147 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, |
1148 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, | 1148 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, |
1149 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, | 1149 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, |
1150 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, | 1150 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI) }, |
1151 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, | 1151 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO) }, |
1152 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, | 1152 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS) }, |
1153 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, | 1153 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, |
1154 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, | 1154 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, |
1155 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, | 1155 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, |
1156 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, | 1156 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI) }, |
1157 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, | 1157 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO) }, |
1158 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, | 1158 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS) }, |
1159 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, | 1159 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, |
1160 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, | 1160 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, |
1161 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, | 1161 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, |
1162 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, | 1162 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, |
1163 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, | 1163 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, |
1164 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, | 1164 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, |
1165 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1165 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
1166 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1166 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
1167 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, | 1167 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, |
1168 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, | 1168 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, |
1169 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, | 1169 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, |
1170 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, | 1170 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, |
1171 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, | ||
1171 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, | 1172 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER) }, |
1172 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, | 1173 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER) }, |
1173 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, | 1174 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, |
1174 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, | 1175 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, |
1175 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, | 1176 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, |
1176 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, | 1177 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, |
1177 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, | 1178 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, |
1178 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD) }, | 1179 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KBD) }, |
1179 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, | 1180 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_ELITE_KBD) }, |
1180 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, | 1181 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500) }, |
1181 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_LX3) }, | 1182 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_LX3) }, |
1182 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_V150) }, | 1183 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_V150) }, |
1183 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, | 1184 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_EXTREME_3D) }, |
1184 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, | 1185 | { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WHEEL) }, |
1185 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, | 1186 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, |
1186 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, | 1187 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, |
1187 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, | 1188 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, |
1188 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, | 1189 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, |
1189 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, | 1190 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, |
1190 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, | 1191 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, |
1191 | 1192 | ||
1192 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) }, | 1193 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, 0x030c) }, |
1193 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, | 1194 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, |
1194 | { } | 1195 | { } |
1195 | }; | 1196 | }; |
1196 | 1197 | ||
1197 | static int hid_bus_match(struct device *dev, struct device_driver *drv) | 1198 | static int hid_bus_match(struct device *dev, struct device_driver *drv) |
1198 | { | 1199 | { |
1199 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); | 1200 | struct hid_driver *hdrv = container_of(drv, struct hid_driver, driver); |
1200 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1201 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
1201 | 1202 | ||
1202 | if (!hid_match_id(hdev, hdrv->id_table)) | 1203 | if (!hid_match_id(hdev, hdrv->id_table)) |
1203 | return 0; | 1204 | return 0; |
1204 | 1205 | ||
1205 | /* generic wants all non-blacklisted */ | 1206 | /* generic wants all non-blacklisted */ |
1206 | if (!strncmp(hdrv->name, "generic-", 8)) | 1207 | if (!strncmp(hdrv->name, "generic-", 8)) |
1207 | return !hid_match_id(hdev, hid_blacklist); | 1208 | return !hid_match_id(hdev, hid_blacklist); |
1208 | 1209 | ||
1209 | return 1; | 1210 | return 1; |
1210 | } | 1211 | } |
1211 | 1212 | ||
1212 | static int hid_device_probe(struct device *dev) | 1213 | static int hid_device_probe(struct device *dev) |
1213 | { | 1214 | { |
1214 | struct hid_driver *hdrv = container_of(dev->driver, | 1215 | struct hid_driver *hdrv = container_of(dev->driver, |
1215 | struct hid_driver, driver); | 1216 | struct hid_driver, driver); |
1216 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1217 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
1217 | const struct hid_device_id *id; | 1218 | const struct hid_device_id *id; |
1218 | int ret = 0; | 1219 | int ret = 0; |
1219 | 1220 | ||
1220 | if (!hdev->driver) { | 1221 | if (!hdev->driver) { |
1221 | id = hid_match_id(hdev, hdrv->id_table); | 1222 | id = hid_match_id(hdev, hdrv->id_table); |
1222 | if (id == NULL) | 1223 | if (id == NULL) |
1223 | return -ENODEV; | 1224 | return -ENODEV; |
1224 | 1225 | ||
1225 | hdev->driver = hdrv; | 1226 | hdev->driver = hdrv; |
1226 | if (hdrv->probe) { | 1227 | if (hdrv->probe) { |
1227 | ret = hdrv->probe(hdev, id); | 1228 | ret = hdrv->probe(hdev, id); |
1228 | } else { /* default probe */ | 1229 | } else { /* default probe */ |
1229 | ret = hid_parse(hdev); | 1230 | ret = hid_parse(hdev); |
1230 | if (!ret) | 1231 | if (!ret) |
1231 | ret = hid_hw_start(hdev); | 1232 | ret = hid_hw_start(hdev); |
1232 | } | 1233 | } |
1233 | if (ret) | 1234 | if (ret) |
1234 | hdev->driver = NULL; | 1235 | hdev->driver = NULL; |
1235 | } | 1236 | } |
1236 | return ret; | 1237 | return ret; |
1237 | } | 1238 | } |
1238 | 1239 | ||
1239 | static int hid_device_remove(struct device *dev) | 1240 | static int hid_device_remove(struct device *dev) |
1240 | { | 1241 | { |
1241 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1242 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
1242 | struct hid_driver *hdrv = hdev->driver; | 1243 | struct hid_driver *hdrv = hdev->driver; |
1243 | 1244 | ||
1244 | if (hdrv) { | 1245 | if (hdrv) { |
1245 | if (hdrv->remove) | 1246 | if (hdrv->remove) |
1246 | hdrv->remove(hdev); | 1247 | hdrv->remove(hdev); |
1247 | else /* default remove */ | 1248 | else /* default remove */ |
1248 | hid_hw_stop(hdev); | 1249 | hid_hw_stop(hdev); |
1249 | hdev->driver = NULL; | 1250 | hdev->driver = NULL; |
1250 | } | 1251 | } |
1251 | 1252 | ||
1252 | return 0; | 1253 | return 0; |
1253 | } | 1254 | } |
1254 | 1255 | ||
1255 | static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) | 1256 | static int hid_uevent(struct device *dev, struct kobj_uevent_env *env) |
1256 | { | 1257 | { |
1257 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | 1258 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); |
1258 | 1259 | ||
1259 | if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", | 1260 | if (add_uevent_var(env, "HID_ID=%04X:%08X:%08X", |
1260 | hdev->bus, hdev->vendor, hdev->product)) | 1261 | hdev->bus, hdev->vendor, hdev->product)) |
1261 | return -ENOMEM; | 1262 | return -ENOMEM; |
1262 | 1263 | ||
1263 | if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) | 1264 | if (add_uevent_var(env, "HID_NAME=%s", hdev->name)) |
1264 | return -ENOMEM; | 1265 | return -ENOMEM; |
1265 | 1266 | ||
1266 | if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) | 1267 | if (add_uevent_var(env, "HID_PHYS=%s", hdev->phys)) |
1267 | return -ENOMEM; | 1268 | return -ENOMEM; |
1268 | 1269 | ||
1269 | if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) | 1270 | if (add_uevent_var(env, "HID_UNIQ=%s", hdev->uniq)) |
1270 | return -ENOMEM; | 1271 | return -ENOMEM; |
1271 | 1272 | ||
1272 | if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", | 1273 | if (add_uevent_var(env, "MODALIAS=hid:b%04Xv%08Xp%08X", |
1273 | hdev->bus, hdev->vendor, hdev->product)) | 1274 | hdev->bus, hdev->vendor, hdev->product)) |
1274 | return -ENOMEM; | 1275 | return -ENOMEM; |
1275 | 1276 | ||
1276 | return 0; | 1277 | return 0; |
1277 | } | 1278 | } |
1278 | 1279 | ||
1279 | static struct bus_type hid_bus_type = { | 1280 | static struct bus_type hid_bus_type = { |
1280 | .name = "hid", | 1281 | .name = "hid", |
1281 | .match = hid_bus_match, | 1282 | .match = hid_bus_match, |
1282 | .probe = hid_device_probe, | 1283 | .probe = hid_device_probe, |
1283 | .remove = hid_device_remove, | 1284 | .remove = hid_device_remove, |
1284 | .uevent = hid_uevent, | 1285 | .uevent = hid_uevent, |
1285 | }; | 1286 | }; |
1286 | 1287 | ||
1287 | static const struct hid_device_id hid_ignore_list[] = { | 1288 | static const struct hid_device_id hid_ignore_list[] = { |
1288 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, | 1289 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, |
1289 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, | 1290 | { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, |
1290 | { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, | 1291 | { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, |
1291 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, | 1292 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, |
1292 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, | 1293 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, |
1293 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, | 1294 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, |
1294 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, | 1295 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, |
1295 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, | 1296 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, |
1296 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, | 1297 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, |
1297 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, | 1298 | { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, |
1298 | { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, | 1299 | { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, |
1299 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, | 1300 | { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, |
1300 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, | 1301 | { HID_USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM)}, |
1301 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, | 1302 | { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, |
1302 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, | 1303 | { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, |
1303 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, | 1304 | { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, |
1304 | { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, | 1305 | { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, |
1305 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, | 1306 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, |
1306 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, | 1307 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, |
1307 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, | 1308 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, |
1308 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, | 1309 | { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, |
1309 | { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, | 1310 | { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, |
1310 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, | 1311 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, |
1311 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, | 1312 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, |
1312 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, | 1313 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0003) }, |
1313 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, | 1314 | { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, |
1314 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, | 1315 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, |
1315 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, | 1316 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, |
1316 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, | 1317 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, |
1317 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, | 1318 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, |
1318 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, | 1319 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, |
1319 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, | 1320 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, |
1320 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, | 1321 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, |
1321 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, | 1322 | { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, |
1322 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, | 1323 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, |
1323 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, | 1324 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, |
1324 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, | 1325 | { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, |
1325 | { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, | 1326 | { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, |
1326 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, | 1327 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, |
1327 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, | 1328 | { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, |
1328 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, | 1329 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, |
1329 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, | 1330 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, |
1330 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, | 1331 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, |
1331 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, | 1332 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, |
1332 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, | 1333 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, |
1333 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, | 1334 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, |
1334 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, | 1335 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, |
1335 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, | 1336 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, |
1336 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, | 1337 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, |
1337 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, | 1338 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, |
1338 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, | 1339 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, |
1339 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, | 1340 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, |
1340 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, | 1341 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, |
1341 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, | 1342 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, |
1342 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, | 1343 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, |
1343 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, | 1344 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, |
1344 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, | 1345 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, |
1345 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, | 1346 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, |
1346 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, | 1347 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, |
1347 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, | 1348 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, |
1348 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, | 1349 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, |
1349 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, | 1350 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, |
1350 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, | 1351 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, |
1351 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, | 1352 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, |
1352 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, | 1353 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, |
1353 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, | 1354 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, |
1354 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, | 1355 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, |
1355 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, | 1356 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, |
1356 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, | 1357 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, |
1357 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, | 1358 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, |
1358 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, | 1359 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, |
1359 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, | 1360 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, |
1360 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, | 1361 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, |
1361 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, | 1362 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, |
1362 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, | 1363 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, |
1363 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, | 1364 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, |
1364 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, | 1365 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, |
1365 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, | 1366 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, |
1366 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, | 1367 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, |
1367 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, | 1368 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, |
1368 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, | 1369 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, |
1369 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, | 1370 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, |
1370 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, | 1371 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, |
1371 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, | 1372 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, |
1372 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, | 1373 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, |
1373 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, | 1374 | { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, |
1374 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, | 1375 | { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, |
1375 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, | 1376 | { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, |
1376 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, | 1377 | { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, |
1377 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, | 1378 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, |
1378 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, | 1379 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, |
1379 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, | 1380 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, |
1380 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, | 1381 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, |
1381 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, | 1382 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, |
1382 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, | 1383 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, |
1383 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) }, | 1384 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY1) }, |
1384 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, | 1385 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, |
1385 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, | 1386 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, |
1386 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, | 1387 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, |
1387 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, | 1388 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, |
1388 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, | 1389 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, |
1389 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, | 1390 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, |
1390 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, | 1391 | { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, |
1391 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, | 1392 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, |
1392 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, | 1393 | { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, |
1393 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, | 1394 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) }, |
1394 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, | 1395 | { HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) }, |
1395 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, | 1396 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, |
1396 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, | 1397 | { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, |
1397 | { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, | 1398 | { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, |
1398 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, | 1399 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, |
1399 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, | 1400 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, |
1400 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, | 1401 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, |
1401 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, | 1402 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, |
1402 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, | 1403 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, |
1403 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, | 1404 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, |
1404 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, | 1405 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, |
1405 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, | 1406 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, |
1406 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, | 1407 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, |
1407 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, | 1408 | { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, |
1408 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, | 1409 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, |
1409 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, | 1410 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, |
1410 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, | 1411 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, |
1411 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, | 1412 | { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, |
1412 | { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, | 1413 | { HID_USB_DEVICE(USB_VENDOR_ID_SOUNDGRAPH, USB_DEVICE_ID_SOUNDGRAPH_IMON_LCD) }, |
1413 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, | 1414 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, |
1414 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, | 1415 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, |
1415 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, | 1416 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, |
1416 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, | 1417 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, |
1417 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, | 1418 | { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, |
1418 | { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, | 1419 | { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, |
1419 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, | 1420 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, |
1420 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, | 1421 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, |
1421 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, | 1422 | { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, |
1422 | { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, | 1423 | { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, |
1423 | { } | 1424 | { } |
1424 | }; | 1425 | }; |
1425 | 1426 | ||
1426 | static bool hid_ignore(struct hid_device *hdev) | 1427 | static bool hid_ignore(struct hid_device *hdev) |
1427 | { | 1428 | { |
1428 | switch (hdev->vendor) { | 1429 | switch (hdev->vendor) { |
1429 | case USB_VENDOR_ID_CODEMERCS: | 1430 | case USB_VENDOR_ID_CODEMERCS: |
1430 | /* ignore all Code Mercenaries IOWarrior devices */ | 1431 | /* ignore all Code Mercenaries IOWarrior devices */ |
1431 | if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && | 1432 | if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && |
1432 | hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) | 1433 | hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) |
1433 | return true; | 1434 | return true; |
1434 | break; | 1435 | break; |
1435 | case USB_VENDOR_ID_LOGITECH: | 1436 | case USB_VENDOR_ID_LOGITECH: |
1436 | if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && | 1437 | if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && |
1437 | hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) | 1438 | hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) |
1438 | return true; | 1439 | return true; |
1439 | break; | 1440 | break; |
1440 | } | 1441 | } |
1441 | 1442 | ||
1442 | return !!hid_match_id(hdev, hid_ignore_list); | 1443 | return !!hid_match_id(hdev, hid_ignore_list); |
1443 | } | 1444 | } |
1444 | 1445 | ||
1445 | int hid_add_device(struct hid_device *hdev) | 1446 | int hid_add_device(struct hid_device *hdev) |
1446 | { | 1447 | { |
1447 | static atomic_t id = ATOMIC_INIT(0); | 1448 | static atomic_t id = ATOMIC_INIT(0); |
1448 | int ret; | 1449 | int ret; |
1449 | 1450 | ||
1450 | if (WARN_ON(hdev->status & HID_STAT_ADDED)) | 1451 | if (WARN_ON(hdev->status & HID_STAT_ADDED)) |
1451 | return -EBUSY; | 1452 | return -EBUSY; |
1452 | 1453 | ||
1453 | /* we need to kill them here, otherwise they will stay allocated to | 1454 | /* we need to kill them here, otherwise they will stay allocated to |
1454 | * wait for coming driver */ | 1455 | * wait for coming driver */ |
1455 | if (hid_ignore(hdev)) | 1456 | if (hid_ignore(hdev)) |
1456 | return -ENODEV; | 1457 | return -ENODEV; |
1457 | 1458 | ||
1458 | /* XXX hack, any other cleaner solution < 20 bus_id bytes? */ | 1459 | /* XXX hack, any other cleaner solution < 20 bus_id bytes? */ |
1459 | sprintf(hdev->dev.bus_id, "%04X:%04X:%04X.%04X", hdev->bus, | 1460 | sprintf(hdev->dev.bus_id, "%04X:%04X:%04X.%04X", hdev->bus, |
1460 | hdev->vendor, hdev->product, atomic_inc_return(&id)); | 1461 | hdev->vendor, hdev->product, atomic_inc_return(&id)); |
1461 | 1462 | ||
1462 | ret = device_add(&hdev->dev); | 1463 | ret = device_add(&hdev->dev); |
1463 | if (!ret) | 1464 | if (!ret) |
1464 | hdev->status |= HID_STAT_ADDED; | 1465 | hdev->status |= HID_STAT_ADDED; |
1465 | 1466 | ||
1466 | return ret; | 1467 | return ret; |
1467 | } | 1468 | } |
1468 | EXPORT_SYMBOL_GPL(hid_add_device); | 1469 | EXPORT_SYMBOL_GPL(hid_add_device); |
1469 | 1470 | ||
1470 | /** | 1471 | /** |
1471 | * hid_allocate_device - allocate new hid device descriptor | 1472 | * hid_allocate_device - allocate new hid device descriptor |
1472 | * | 1473 | * |
1473 | * Allocate and initialize hid device, so that hid_destroy_device might be | 1474 | * Allocate and initialize hid device, so that hid_destroy_device might be |
1474 | * used to free it. | 1475 | * used to free it. |
1475 | * | 1476 | * |
1476 | * New hid_device pointer is returned on success, otherwise ERR_PTR encoded | 1477 | * New hid_device pointer is returned on success, otherwise ERR_PTR encoded |
1477 | * error value. | 1478 | * error value. |
1478 | */ | 1479 | */ |
1479 | struct hid_device *hid_allocate_device(void) | 1480 | struct hid_device *hid_allocate_device(void) |
1480 | { | 1481 | { |
1481 | struct hid_device *hdev; | 1482 | struct hid_device *hdev; |
1482 | unsigned int i; | 1483 | unsigned int i; |
1483 | int ret = -ENOMEM; | 1484 | int ret = -ENOMEM; |
1484 | 1485 | ||
1485 | hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); | 1486 | hdev = kzalloc(sizeof(*hdev), GFP_KERNEL); |
1486 | if (hdev == NULL) | 1487 | if (hdev == NULL) |
1487 | return ERR_PTR(ret); | 1488 | return ERR_PTR(ret); |
1488 | 1489 | ||
1489 | device_initialize(&hdev->dev); | 1490 | device_initialize(&hdev->dev); |
1490 | hdev->dev.release = hid_device_release; | 1491 | hdev->dev.release = hid_device_release; |
1491 | hdev->dev.bus = &hid_bus_type; | 1492 | hdev->dev.bus = &hid_bus_type; |
1492 | 1493 | ||
1493 | hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, | 1494 | hdev->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, |
1494 | sizeof(struct hid_collection), GFP_KERNEL); | 1495 | sizeof(struct hid_collection), GFP_KERNEL); |
1495 | if (hdev->collection == NULL) | 1496 | if (hdev->collection == NULL) |
1496 | goto err; | 1497 | goto err; |
1497 | hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; | 1498 | hdev->collection_size = HID_DEFAULT_NUM_COLLECTIONS; |
1498 | 1499 | ||
1499 | for (i = 0; i < HID_REPORT_TYPES; i++) | 1500 | for (i = 0; i < HID_REPORT_TYPES; i++) |
1500 | INIT_LIST_HEAD(&hdev->report_enum[i].report_list); | 1501 | INIT_LIST_HEAD(&hdev->report_enum[i].report_list); |
1501 | 1502 | ||
1502 | return hdev; | 1503 | return hdev; |
1503 | err: | 1504 | err: |
1504 | put_device(&hdev->dev); | 1505 | put_device(&hdev->dev); |
1505 | return ERR_PTR(ret); | 1506 | return ERR_PTR(ret); |
1506 | } | 1507 | } |
1507 | EXPORT_SYMBOL_GPL(hid_allocate_device); | 1508 | EXPORT_SYMBOL_GPL(hid_allocate_device); |
1508 | 1509 | ||
1509 | static void hid_remove_device(struct hid_device *hdev) | 1510 | static void hid_remove_device(struct hid_device *hdev) |
1510 | { | 1511 | { |
1511 | if (hdev->status & HID_STAT_ADDED) { | 1512 | if (hdev->status & HID_STAT_ADDED) { |
1512 | device_del(&hdev->dev); | 1513 | device_del(&hdev->dev); |
1513 | hdev->status &= ~HID_STAT_ADDED; | 1514 | hdev->status &= ~HID_STAT_ADDED; |
1514 | } | 1515 | } |
1515 | } | 1516 | } |
1516 | 1517 | ||
1517 | /** | 1518 | /** |
1518 | * hid_destroy_device - free previously allocated device | 1519 | * hid_destroy_device - free previously allocated device |
1519 | * | 1520 | * |
1520 | * @hdev: hid device | 1521 | * @hdev: hid device |
1521 | * | 1522 | * |
1522 | * If you allocate hid_device through hid_allocate_device, you should ever | 1523 | * If you allocate hid_device through hid_allocate_device, you should ever |
1523 | * free by this function. | 1524 | * free by this function. |
1524 | */ | 1525 | */ |
1525 | void hid_destroy_device(struct hid_device *hdev) | 1526 | void hid_destroy_device(struct hid_device *hdev) |
1526 | { | 1527 | { |
1527 | hid_remove_device(hdev); | 1528 | hid_remove_device(hdev); |
1528 | put_device(&hdev->dev); | 1529 | put_device(&hdev->dev); |
1529 | } | 1530 | } |
1530 | EXPORT_SYMBOL_GPL(hid_destroy_device); | 1531 | EXPORT_SYMBOL_GPL(hid_destroy_device); |
1531 | 1532 | ||
1532 | int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, | 1533 | int __hid_register_driver(struct hid_driver *hdrv, struct module *owner, |
1533 | const char *mod_name) | 1534 | const char *mod_name) |
1534 | { | 1535 | { |
1535 | hdrv->driver.name = hdrv->name; | 1536 | hdrv->driver.name = hdrv->name; |
1536 | hdrv->driver.bus = &hid_bus_type; | 1537 | hdrv->driver.bus = &hid_bus_type; |
1537 | hdrv->driver.owner = owner; | 1538 | hdrv->driver.owner = owner; |
1538 | hdrv->driver.mod_name = mod_name; | 1539 | hdrv->driver.mod_name = mod_name; |
1539 | 1540 | ||
1540 | return driver_register(&hdrv->driver); | 1541 | return driver_register(&hdrv->driver); |
1541 | } | 1542 | } |
1542 | EXPORT_SYMBOL_GPL(__hid_register_driver); | 1543 | EXPORT_SYMBOL_GPL(__hid_register_driver); |
1543 | 1544 | ||
1544 | void hid_unregister_driver(struct hid_driver *hdrv) | 1545 | void hid_unregister_driver(struct hid_driver *hdrv) |
1545 | { | 1546 | { |
1546 | driver_unregister(&hdrv->driver); | 1547 | driver_unregister(&hdrv->driver); |
1547 | } | 1548 | } |
1548 | EXPORT_SYMBOL_GPL(hid_unregister_driver); | 1549 | EXPORT_SYMBOL_GPL(hid_unregister_driver); |
1549 | 1550 | ||
1550 | #ifdef CONFIG_HID_COMPAT | 1551 | #ifdef CONFIG_HID_COMPAT |
1551 | static void hid_compat_load(struct work_struct *ws) | 1552 | static void hid_compat_load(struct work_struct *ws) |
1552 | { | 1553 | { |
1553 | request_module("hid-dummy"); | 1554 | request_module("hid-dummy"); |
1554 | } | 1555 | } |
1555 | static DECLARE_WORK(hid_compat_work, hid_compat_load); | 1556 | static DECLARE_WORK(hid_compat_work, hid_compat_load); |
1556 | #endif | 1557 | #endif |
1557 | 1558 | ||
1558 | static int __init hid_init(void) | 1559 | static int __init hid_init(void) |
1559 | { | 1560 | { |
1560 | int ret; | 1561 | int ret; |
1561 | 1562 | ||
1562 | ret = bus_register(&hid_bus_type); | 1563 | ret = bus_register(&hid_bus_type); |
1563 | if (ret) { | 1564 | if (ret) { |
1564 | printk(KERN_ERR "HID: can't register hid bus\n"); | 1565 | printk(KERN_ERR "HID: can't register hid bus\n"); |
1565 | goto err; | 1566 | goto err; |
1566 | } | 1567 | } |
1567 | 1568 | ||
1568 | ret = hidraw_init(); | 1569 | ret = hidraw_init(); |
1569 | if (ret) | 1570 | if (ret) |
1570 | goto err_bus; | 1571 | goto err_bus; |
1571 | 1572 | ||
1572 | #ifdef CONFIG_HID_COMPAT | 1573 | #ifdef CONFIG_HID_COMPAT |
1573 | schedule_work(&hid_compat_work); | 1574 | schedule_work(&hid_compat_work); |
1574 | #endif | 1575 | #endif |
1575 | 1576 | ||
1576 | return 0; | 1577 | return 0; |
1577 | err_bus: | 1578 | err_bus: |
1578 | bus_unregister(&hid_bus_type); | 1579 | bus_unregister(&hid_bus_type); |
1579 | err: | 1580 | err: |
1580 | return ret; | 1581 | return ret; |
1581 | } | 1582 | } |
1582 | 1583 | ||
1583 | static void __exit hid_exit(void) | 1584 | static void __exit hid_exit(void) |
1584 | { | 1585 | { |
1585 | hidraw_exit(); | 1586 | hidraw_exit(); |
1586 | bus_unregister(&hid_bus_type); | 1587 | bus_unregister(&hid_bus_type); |
1587 | } | 1588 | } |
1588 | 1589 | ||
1589 | module_init(hid_init); | 1590 | module_init(hid_init); |
1590 | module_exit(hid_exit); | 1591 | module_exit(hid_exit); |
1591 | 1592 | ||
1592 | MODULE_LICENSE(DRIVER_LICENSE); | 1593 | MODULE_LICENSE(DRIVER_LICENSE); |
1593 | 1594 | ||
1594 | 1595 |
drivers/hid/hid-dummy.c
1 | #include <linux/autoconf.h> | 1 | #include <linux/autoconf.h> |
2 | #include <linux/module.h> | 2 | #include <linux/module.h> |
3 | #include <linux/hid.h> | 3 | #include <linux/hid.h> |
4 | 4 | ||
5 | static int __init hid_dummy_init(void) | 5 | static int __init hid_dummy_init(void) |
6 | { | 6 | { |
7 | #ifdef CONFIG_HID_A4TECH_MODULE | 7 | #ifdef CONFIG_HID_A4TECH_MODULE |
8 | HID_COMPAT_CALL_DRIVER(a4tech); | 8 | HID_COMPAT_CALL_DRIVER(a4tech); |
9 | #endif | 9 | #endif |
10 | #ifdef CONFIG_HID_APPLE_MODULE | 10 | #ifdef CONFIG_HID_APPLE_MODULE |
11 | HID_COMPAT_CALL_DRIVER(apple); | 11 | HID_COMPAT_CALL_DRIVER(apple); |
12 | #endif | 12 | #endif |
13 | #ifdef CONFIG_HID_CHERRY_MODULE | 13 | #ifdef CONFIG_HID_CHERRY_MODULE |
14 | HID_COMPAT_CALL_DRIVER(cherry); | 14 | HID_COMPAT_CALL_DRIVER(cherry); |
15 | #endif | 15 | #endif |
16 | #ifdef CONFIG_HID_CYPRESS_MODULE | 16 | #ifdef CONFIG_HID_CYPRESS_MODULE |
17 | HID_COMPAT_CALL_DRIVER(cypress); | 17 | HID_COMPAT_CALL_DRIVER(cypress); |
18 | #endif | 18 | #endif |
19 | #ifdef CONFIG_HID_EZKEY_MODULE | ||
20 | HID_COMPAT_CALL_DRIVER(ezkey); | ||
21 | #endif | ||
19 | #ifdef CONFIG_HID_LOGITECH_MODULE | 22 | #ifdef CONFIG_HID_LOGITECH_MODULE |
20 | HID_COMPAT_CALL_DRIVER(logitech); | 23 | HID_COMPAT_CALL_DRIVER(logitech); |
21 | #endif | 24 | #endif |
22 | #ifdef CONFIG_HID_MICROSOFT_MODULE | 25 | #ifdef CONFIG_HID_MICROSOFT_MODULE |
23 | HID_COMPAT_CALL_DRIVER(microsoft); | 26 | HID_COMPAT_CALL_DRIVER(microsoft); |
24 | #endif | 27 | #endif |
25 | #ifdef CONFIG_HID_SUNPLUS_MODULE | 28 | #ifdef CONFIG_HID_SUNPLUS_MODULE |
26 | HID_COMPAT_CALL_DRIVER(sunplus); | 29 | HID_COMPAT_CALL_DRIVER(sunplus); |
27 | #endif | 30 | #endif |
28 | 31 | ||
29 | return -EIO; | 32 | return -EIO; |
30 | } | 33 | } |
31 | module_init(hid_dummy_init); | 34 | module_init(hid_dummy_init); |
32 | 35 | ||
33 | MODULE_LICENSE("GPL"); | 36 | MODULE_LICENSE("GPL"); |
34 | 37 |
drivers/hid/hid-ezkey.c
File was created | 1 | /* | |
2 | * HID driver for some ezkey "special" devices | ||
3 | * | ||
4 | * Copyright (c) 1999 Andreas Gal | ||
5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> | ||
6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc | ||
7 | * Copyright (c) 2006-2007 Jiri Kosina | ||
8 | * Copyright (c) 2007 Paul Walmsley | ||
9 | * Copyright (c) 2008 Jiri Slaby | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * This program is free software; you can redistribute it and/or modify it | ||
14 | * under the terms of the GNU General Public License as published by the Free | ||
15 | * Software Foundation; either version 2 of the License, or (at your option) | ||
16 | * any later version. | ||
17 | */ | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | #include <linux/input.h> | ||
21 | #include <linux/hid.h> | ||
22 | #include <linux/module.h> | ||
23 | |||
24 | #include "hid-ids.h" | ||
25 | |||
26 | #define ez_map_rel(c) hid_map_usage(hi, usage, bit, max, EV_REL, (c)) | ||
27 | #define ez_map_key(c) hid_map_usage(hi, usage, bit, max, EV_KEY, (c)) | ||
28 | |||
29 | static int ez_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
30 | struct hid_field *field, struct hid_usage *usage, | ||
31 | unsigned long **bit, int *max) | ||
32 | { | ||
33 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) | ||
34 | return 0; | ||
35 | |||
36 | switch (usage->hid & HID_USAGE) { | ||
37 | case 0x230: ez_map_key(BTN_MOUSE); break; | ||
38 | case 0x231: ez_map_rel(REL_WHEEL); break; | ||
39 | /* | ||
40 | * this keyboard has a scrollwheel implemented in | ||
41 | * totally broken way. We map this usage temporarily | ||
42 | * to HWHEEL and handle it in the event quirk handler | ||
43 | */ | ||
44 | case 0x232: ez_map_rel(REL_HWHEEL); break; | ||
45 | default: | ||
46 | return 0; | ||
47 | } | ||
48 | return 1; | ||
49 | } | ||
50 | |||
51 | static int ez_event(struct hid_device *hdev, struct hid_field *field, | ||
52 | struct hid_usage *usage, __s32 value) | ||
53 | { | ||
54 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || | ||
55 | !usage->type) | ||
56 | return 0; | ||
57 | |||
58 | /* handle the temporary quirky mapping to HWHEEL */ | ||
59 | if (usage->type == EV_REL && usage->code == REL_HWHEEL) { | ||
60 | struct input_dev *input = field->hidinput->input; | ||
61 | input_event(input, usage->type, REL_WHEEL, -value); | ||
62 | return 1; | ||
63 | } | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static const struct hid_device_id ez_devices[] = { | ||
69 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, | ||
70 | { } | ||
71 | }; | ||
72 | MODULE_DEVICE_TABLE(hid, ez_devices); | ||
73 | |||
74 | static struct hid_driver ez_driver = { | ||
75 | .name = "ezkey", | ||
76 | .id_table = ez_devices, | ||
77 | .input_mapping = ez_input_mapping, | ||
78 | .event = ez_event, | ||
79 | }; | ||
80 | |||
81 | static int ez_init(void) | ||
82 | { | ||
83 | return hid_register_driver(&ez_driver); | ||
84 | } | ||
85 | |||
86 | static void ez_exit(void) | ||
87 | { | ||
88 | hid_unregister_driver(&ez_driver); | ||
89 | } | ||
90 | |||
91 | module_init(ez_init); | ||
92 | module_exit(ez_exit); | ||
93 | MODULE_LICENSE("GPL"); | ||
94 | |||
95 | HID_COMPAT_LOAD_DRIVER(ezkey); | ||
96 |
drivers/hid/hid-input-quirks.c
1 | /* | 1 | /* |
2 | * HID-input usage mapping quirks | 2 | * HID-input usage mapping quirks |
3 | * | 3 | * |
4 | * This is used to handle HID-input mappings for devices violating | 4 | * This is used to handle HID-input mappings for devices violating |
5 | * HUT 1.12 specification. | 5 | * HUT 1.12 specification. |
6 | * | 6 | * |
7 | * Copyright (c) 2007-2008 Jiri Kosina | 7 | * Copyright (c) 2007-2008 Jiri Kosina |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * This program is free software; you can redistribute it and/or modify it | 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 | 12 | * under the terms of the GNU General Public License as published by the Free |
13 | * Software Foundation; either version 2 of the License | 13 | * Software Foundation; either version 2 of the License |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/input.h> | 16 | #include <linux/input.h> |
17 | #include <linux/hid.h> | 17 | #include <linux/hid.h> |
18 | 18 | ||
19 | #define map_rel(c) hid_map_usage(hidinput, usage, bit, max, EV_REL, (c)) | ||
20 | #define map_key(c) hid_map_usage(hidinput, usage, bit, max, EV_KEY, (c)) | ||
21 | |||
22 | #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, bit, \ | 19 | #define map_key_clear(c) hid_map_usage_clear(hidinput, usage, bit, \ |
23 | max, EV_KEY, (c)) | 20 | max, EV_KEY, (c)) |
24 | 21 | ||
25 | static int quirk_belkin_wkbd(struct hid_usage *usage, | 22 | static int quirk_belkin_wkbd(struct hid_usage *usage, |
26 | struct hid_input *hidinput, unsigned long **bit, int *max) | 23 | struct hid_input *hidinput, unsigned long **bit, int *max) |
27 | { | 24 | { |
28 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) | 25 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) |
29 | return 0; | 26 | return 0; |
30 | 27 | ||
31 | switch (usage->hid & HID_USAGE) { | 28 | switch (usage->hid & HID_USAGE) { |
32 | case 0x03a: map_key_clear(KEY_SOUND); break; | 29 | case 0x03a: map_key_clear(KEY_SOUND); break; |
33 | case 0x03b: map_key_clear(KEY_CAMERA); break; | 30 | case 0x03b: map_key_clear(KEY_CAMERA); break; |
34 | case 0x03c: map_key_clear(KEY_DOCUMENTS); break; | 31 | case 0x03c: map_key_clear(KEY_DOCUMENTS); break; |
35 | default: | 32 | default: |
36 | return 0; | 33 | return 0; |
37 | } | 34 | } |
38 | return 1; | 35 | return 1; |
39 | } | 36 | } |
40 | 37 | ||
41 | static int quirk_gyration_remote(struct hid_usage *usage, | 38 | static int quirk_gyration_remote(struct hid_usage *usage, |
42 | struct hid_input *hidinput, unsigned long **bit, int *max) | 39 | struct hid_input *hidinput, unsigned long **bit, int *max) |
43 | { | 40 | { |
44 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) | 41 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) |
45 | return 0; | 42 | return 0; |
46 | 43 | ||
47 | set_bit(EV_REP, hidinput->input->evbit); | 44 | set_bit(EV_REP, hidinput->input->evbit); |
48 | switch(usage->hid & HID_USAGE) { | 45 | switch(usage->hid & HID_USAGE) { |
49 | /* Reported on Gyration MCE Remote */ | 46 | /* Reported on Gyration MCE Remote */ |
50 | case 0x00d: map_key_clear(KEY_HOME); break; | 47 | case 0x00d: map_key_clear(KEY_HOME); break; |
51 | case 0x024: map_key_clear(KEY_DVD); break; | 48 | case 0x024: map_key_clear(KEY_DVD); break; |
52 | case 0x025: map_key_clear(KEY_PVR); break; | 49 | case 0x025: map_key_clear(KEY_PVR); break; |
53 | case 0x046: map_key_clear(KEY_MEDIA); break; | 50 | case 0x046: map_key_clear(KEY_MEDIA); break; |
54 | case 0x047: map_key_clear(KEY_MP3); break; | 51 | case 0x047: map_key_clear(KEY_MP3); break; |
55 | case 0x049: map_key_clear(KEY_CAMERA); break; | 52 | case 0x049: map_key_clear(KEY_CAMERA); break; |
56 | case 0x04a: map_key_clear(KEY_VIDEO); break; | 53 | case 0x04a: map_key_clear(KEY_VIDEO); break; |
57 | 54 | ||
58 | default: | 55 | default: |
59 | return 0; | 56 | return 0; |
60 | } | 57 | } |
61 | return 1; | 58 | return 1; |
62 | } | 59 | } |
63 | 60 | ||
64 | static int quirk_chicony_tactical_pad(struct hid_usage *usage, | 61 | static int quirk_chicony_tactical_pad(struct hid_usage *usage, |
65 | struct hid_input *hidinput, unsigned long **bit, int *max) | 62 | struct hid_input *hidinput, unsigned long **bit, int *max) |
66 | { | 63 | { |
67 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR) | 64 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR) |
68 | return 0; | 65 | return 0; |
69 | 66 | ||
70 | set_bit(EV_REP, hidinput->input->evbit); | 67 | set_bit(EV_REP, hidinput->input->evbit); |
71 | switch (usage->hid & HID_USAGE) { | 68 | switch (usage->hid & HID_USAGE) { |
72 | case 0xff01: map_key_clear(BTN_1); break; | 69 | case 0xff01: map_key_clear(BTN_1); break; |
73 | case 0xff02: map_key_clear(BTN_2); break; | 70 | case 0xff02: map_key_clear(BTN_2); break; |
74 | case 0xff03: map_key_clear(BTN_3); break; | 71 | case 0xff03: map_key_clear(BTN_3); break; |
75 | case 0xff04: map_key_clear(BTN_4); break; | 72 | case 0xff04: map_key_clear(BTN_4); break; |
76 | case 0xff05: map_key_clear(BTN_5); break; | 73 | case 0xff05: map_key_clear(BTN_5); break; |
77 | case 0xff06: map_key_clear(BTN_6); break; | 74 | case 0xff06: map_key_clear(BTN_6); break; |
78 | case 0xff07: map_key_clear(BTN_7); break; | 75 | case 0xff07: map_key_clear(BTN_7); break; |
79 | case 0xff08: map_key_clear(BTN_8); break; | 76 | case 0xff08: map_key_clear(BTN_8); break; |
80 | case 0xff09: map_key_clear(BTN_9); break; | 77 | case 0xff09: map_key_clear(BTN_9); break; |
81 | case 0xff0a: map_key_clear(BTN_A); break; | 78 | case 0xff0a: map_key_clear(BTN_A); break; |
82 | case 0xff0b: map_key_clear(BTN_B); break; | 79 | case 0xff0b: map_key_clear(BTN_B); break; |
83 | default: | 80 | default: |
84 | return 0; | 81 | return 0; |
85 | } | 82 | } |
86 | return 1; | 83 | return 1; |
87 | } | 84 | } |
88 | 85 | ||
89 | static int quirk_petalynx_remote(struct hid_usage *usage, | 86 | static int quirk_petalynx_remote(struct hid_usage *usage, |
90 | struct hid_input *hidinput, unsigned long **bit, int *max) | 87 | struct hid_input *hidinput, unsigned long **bit, int *max) |
91 | { | 88 | { |
92 | if (((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) && | 89 | if (((usage->hid & HID_USAGE_PAGE) != HID_UP_LOGIVENDOR) && |
93 | ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)) | 90 | ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)) |
94 | return 0; | 91 | return 0; |
95 | 92 | ||
96 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_LOGIVENDOR) | 93 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_LOGIVENDOR) |
97 | switch(usage->hid & HID_USAGE) { | 94 | switch(usage->hid & HID_USAGE) { |
98 | case 0x05a: map_key_clear(KEY_TEXT); break; | 95 | case 0x05a: map_key_clear(KEY_TEXT); break; |
99 | case 0x05b: map_key_clear(KEY_RED); break; | 96 | case 0x05b: map_key_clear(KEY_RED); break; |
100 | case 0x05c: map_key_clear(KEY_GREEN); break; | 97 | case 0x05c: map_key_clear(KEY_GREEN); break; |
101 | case 0x05d: map_key_clear(KEY_YELLOW); break; | 98 | case 0x05d: map_key_clear(KEY_YELLOW); break; |
102 | case 0x05e: map_key_clear(KEY_BLUE); break; | 99 | case 0x05e: map_key_clear(KEY_BLUE); break; |
103 | default: | 100 | default: |
104 | return 0; | 101 | return 0; |
105 | } | 102 | } |
106 | 103 | ||
107 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) | 104 | if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) |
108 | switch(usage->hid & HID_USAGE) { | 105 | switch(usage->hid & HID_USAGE) { |
109 | case 0x0f6: map_key_clear(KEY_NEXT); break; | 106 | case 0x0f6: map_key_clear(KEY_NEXT); break; |
110 | case 0x0fa: map_key_clear(KEY_BACK); break; | 107 | case 0x0fa: map_key_clear(KEY_BACK); break; |
111 | default: | 108 | default: |
112 | return 0; | 109 | return 0; |
113 | } | 110 | } |
114 | return 1; | 111 | return 1; |
115 | } | 112 | } |
116 | 113 | ||
117 | static int quirk_cherry_genius_29e(struct hid_usage *usage, | 114 | static int quirk_cherry_genius_29e(struct hid_usage *usage, |
118 | struct hid_input *hidinput, unsigned long **bit, int *max) | 115 | struct hid_input *hidinput, unsigned long **bit, int *max) |
119 | { | 116 | { |
120 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) | 117 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) |
121 | return 0; | 118 | return 0; |
122 | 119 | ||
123 | switch (usage->hid & HID_USAGE) { | 120 | switch (usage->hid & HID_USAGE) { |
124 | case 0x156: map_key_clear(KEY_WORDPROCESSOR); break; | 121 | case 0x156: map_key_clear(KEY_WORDPROCESSOR); break; |
125 | case 0x157: map_key_clear(KEY_SPREADSHEET); break; | 122 | case 0x157: map_key_clear(KEY_SPREADSHEET); break; |
126 | case 0x158: map_key_clear(KEY_PRESENTATION); break; | 123 | case 0x158: map_key_clear(KEY_PRESENTATION); break; |
127 | case 0x15c: map_key_clear(KEY_STOP); break; | 124 | case 0x15c: map_key_clear(KEY_STOP); break; |
128 | 125 | ||
129 | default: | 126 | default: |
130 | return 0; | 127 | return 0; |
131 | } | 128 | } |
132 | return 1; | 129 | return 1; |
133 | } | 130 | } |
134 | 131 | ||
135 | static int quirk_btc_8193(struct hid_usage *usage, struct hid_input *hidinput, | ||
136 | unsigned long **bit, int *max) | ||
137 | { | ||
138 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) | ||
139 | return 0; | ||
140 | |||
141 | switch (usage->hid & HID_USAGE) { | ||
142 | case 0x230: map_key(BTN_MOUSE); break; | ||
143 | case 0x231: map_rel(REL_WHEEL); break; | ||
144 | /* | ||
145 | * this keyboard has a scrollwheel implemented in | ||
146 | * totally broken way. We map this usage temporarily | ||
147 | * to HWHEEL and handle it in the event quirk handler | ||
148 | */ | ||
149 | case 0x232: map_rel(REL_HWHEEL); break; | ||
150 | |||
151 | default: | ||
152 | return 0; | ||
153 | } | ||
154 | return 1; | ||
155 | } | ||
156 | |||
157 | #define VENDOR_ID_BELKIN 0x1020 | 132 | #define VENDOR_ID_BELKIN 0x1020 |
158 | #define DEVICE_ID_BELKIN_WIRELESS_KEYBOARD 0x0006 | 133 | #define DEVICE_ID_BELKIN_WIRELESS_KEYBOARD 0x0006 |
159 | 134 | ||
160 | #define VENDOR_ID_CHICONY 0x04f2 | 135 | #define VENDOR_ID_CHICONY 0x04f2 |
161 | #define DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418 | 136 | #define DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418 |
162 | 137 | ||
163 | #define VENDOR_ID_EZKEY 0x0518 | ||
164 | #define DEVICE_ID_BTC_8193 0x0002 | ||
165 | |||
166 | #define VENDOR_ID_GYRATION 0x0c16 | 138 | #define VENDOR_ID_GYRATION 0x0c16 |
167 | #define DEVICE_ID_GYRATION_REMOTE 0x0002 | 139 | #define DEVICE_ID_GYRATION_REMOTE 0x0002 |
168 | 140 | ||
169 | #define VENDOR_ID_MONTEREY 0x0566 | 141 | #define VENDOR_ID_MONTEREY 0x0566 |
170 | #define DEVICE_ID_GENIUS_KB29E 0x3004 | 142 | #define DEVICE_ID_GENIUS_KB29E 0x3004 |
171 | 143 | ||
172 | #define VENDOR_ID_PETALYNX 0x18b1 | 144 | #define VENDOR_ID_PETALYNX 0x18b1 |
173 | #define DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037 | 145 | #define DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037 |
174 | 146 | ||
175 | static const struct hid_input_blacklist { | 147 | static const struct hid_input_blacklist { |
176 | __u16 idVendor; | 148 | __u16 idVendor; |
177 | __u16 idProduct; | 149 | __u16 idProduct; |
178 | int (*quirk)(struct hid_usage *, struct hid_input *, unsigned long **, | 150 | int (*quirk)(struct hid_usage *, struct hid_input *, unsigned long **, |
179 | int *); | 151 | int *); |
180 | } hid_input_blacklist[] = { | 152 | } hid_input_blacklist[] = { |
181 | { VENDOR_ID_BELKIN, DEVICE_ID_BELKIN_WIRELESS_KEYBOARD, quirk_belkin_wkbd }, | 153 | { VENDOR_ID_BELKIN, DEVICE_ID_BELKIN_WIRELESS_KEYBOARD, quirk_belkin_wkbd }, |
182 | 154 | ||
183 | { VENDOR_ID_CHICONY, DEVICE_ID_CHICONY_TACTICAL_PAD, quirk_chicony_tactical_pad }, | 155 | { VENDOR_ID_CHICONY, DEVICE_ID_CHICONY_TACTICAL_PAD, quirk_chicony_tactical_pad }, |
184 | 156 | ||
185 | { VENDOR_ID_EZKEY, DEVICE_ID_BTC_8193, quirk_btc_8193 }, | ||
186 | |||
187 | { VENDOR_ID_GYRATION, DEVICE_ID_GYRATION_REMOTE, quirk_gyration_remote }, | 157 | { VENDOR_ID_GYRATION, DEVICE_ID_GYRATION_REMOTE, quirk_gyration_remote }, |
188 | 158 | ||
189 | { VENDOR_ID_MONTEREY, DEVICE_ID_GENIUS_KB29E, quirk_cherry_genius_29e }, | 159 | { VENDOR_ID_MONTEREY, DEVICE_ID_GENIUS_KB29E, quirk_cherry_genius_29e }, |
190 | 160 | ||
191 | { VENDOR_ID_PETALYNX, DEVICE_ID_PETALYNX_MAXTER_REMOTE, quirk_petalynx_remote }, | 161 | { VENDOR_ID_PETALYNX, DEVICE_ID_PETALYNX_MAXTER_REMOTE, quirk_petalynx_remote }, |
192 | 162 | ||
193 | { 0, 0, NULL } | 163 | { 0, 0, NULL } |
194 | }; | 164 | }; |
195 | 165 | ||
196 | int hidinput_mapping_quirks(struct hid_usage *usage, | 166 | int hidinput_mapping_quirks(struct hid_usage *usage, |
197 | struct hid_input *hi, unsigned long **bit, int *max) | 167 | struct hid_input *hi, unsigned long **bit, int *max) |
198 | { | 168 | { |
199 | struct hid_device *device = input_get_drvdata(hi->input); | 169 | struct hid_device *device = input_get_drvdata(hi->input); |
200 | int i = 0; | 170 | int i = 0; |
201 | 171 | ||
202 | while (hid_input_blacklist[i].quirk) { | 172 | while (hid_input_blacklist[i].quirk) { |
203 | if (hid_input_blacklist[i].idVendor == device->vendor && | 173 | if (hid_input_blacklist[i].idVendor == device->vendor && |
204 | hid_input_blacklist[i].idProduct == device->product) | 174 | hid_input_blacklist[i].idProduct == device->product) |
205 | return hid_input_blacklist[i].quirk(usage, hi, bit, | 175 | return hid_input_blacklist[i].quirk(usage, hi, bit, |
206 | max); | 176 | max); |
207 | i++; | 177 | i++; |
208 | } | 178 | } |
209 | return 0; | 179 | return 0; |
210 | } | 180 | } |
211 | 181 | ||
212 | int hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) | 182 | int hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) |
213 | { | 183 | { |
214 | struct input_dev *input; | 184 | struct input_dev *input; |
215 | 185 | ||
216 | input = field->hidinput->input; | 186 | input = field->hidinput->input; |
217 | |||
218 | /* handle the temporary quirky mapping to HWHEEL */ | ||
219 | if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT && | ||
220 | usage->type == EV_REL && usage->code == REL_HWHEEL) { | ||
221 | input_event(input, usage->type, REL_WHEEL, -value); | ||
222 | return 1; | ||
223 | } | ||
224 | 187 | ||
225 | /* Gyration MCE remote "Sleep" key */ | 188 | /* Gyration MCE remote "Sleep" key */ |
226 | if (hid->vendor == VENDOR_ID_GYRATION && | 189 | if (hid->vendor == VENDOR_ID_GYRATION && |
227 | hid->product == DEVICE_ID_GYRATION_REMOTE && | 190 | hid->product == DEVICE_ID_GYRATION_REMOTE && |
228 | (usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK && | 191 | (usage->hid & HID_USAGE_PAGE) == HID_UP_GENDESK && |
229 | (usage->hid & 0xff) == 0x82) { | 192 | (usage->hid & 0xff) == 0x82) { |
230 | input_event(input, usage->type, usage->code, 1); | 193 | input_event(input, usage->type, usage->code, 1); |
231 | input_sync(input); | 194 | input_sync(input); |
232 | input_event(input, usage->type, usage->code, 0); | 195 | input_event(input, usage->type, usage->code, 0); |
233 | input_sync(input); | 196 | input_sync(input); |
234 | return 1; | 197 | return 1; |
235 | } | 198 | } |
236 | return 0; | 199 | return 0; |
237 | } | 200 | } |
238 | 201 | ||
239 | 202 | ||
240 | 203 |
drivers/hid/usbhid/hid-quirks.c
1 | /* | 1 | /* |
2 | * USB HID quirks support for Linux | 2 | * USB HID quirks support for Linux |
3 | * | 3 | * |
4 | * Copyright (c) 1999 Andreas Gal | 4 | * Copyright (c) 1999 Andreas Gal |
5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> | 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc | 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
7 | * Copyright (c) 2006-2007 Jiri Kosina | 7 | * Copyright (c) 2006-2007 Jiri Kosina |
8 | * Copyright (c) 2007 Paul Walmsley | 8 | * Copyright (c) 2007 Paul Walmsley |
9 | */ | 9 | */ |
10 | 10 | ||
11 | /* | 11 | /* |
12 | * This program is free software; you can redistribute it and/or modify it | 12 | * This program is free software; you can redistribute it and/or modify it |
13 | * under the terms of the GNU General Public License as published by the Free | 13 | * under the terms of the GNU General Public License as published by the Free |
14 | * Software Foundation; either version 2 of the License, or (at your option) | 14 | * Software Foundation; either version 2 of the License, or (at your option) |
15 | * any later version. | 15 | * any later version. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/hid.h> | 18 | #include <linux/hid.h> |
19 | 19 | ||
20 | #include "../hid-ids.h" | 20 | #include "../hid-ids.h" |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * Alphabetically sorted blacklist by quirk type. | 23 | * Alphabetically sorted blacklist by quirk type. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | static const struct hid_blacklist { | 26 | static const struct hid_blacklist { |
27 | __u16 idVendor; | 27 | __u16 idVendor; |
28 | __u16 idProduct; | 28 | __u16 idProduct; |
29 | __u32 quirks; | 29 | __u32 quirks; |
30 | } hid_blacklist[] = { | 30 | } hid_blacklist[] = { |
31 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, | 31 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_GAMEPAD, HID_QUIRK_BADPAD }, |
32 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, | 32 | { USB_VENDOR_ID_AASHIMA, USB_DEVICE_ID_AASHIMA_PREDATOR, HID_QUIRK_BADPAD }, |
33 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, | 33 | { USB_VENDOR_ID_ALPS, USB_DEVICE_ID_IBM_GAMEPAD, HID_QUIRK_BADPAD }, |
34 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, | 34 | { USB_VENDOR_ID_CHIC, USB_DEVICE_ID_CHIC_GAMEPAD, HID_QUIRK_BADPAD }, |
35 | { USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR, HID_QUIRK_MULTI_INPUT }, | 35 | { USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR, HID_QUIRK_MULTI_INPUT }, |
36 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 36 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_DRIVING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
37 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 37 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FLYING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
38 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, | 38 | { USB_VENDOR_ID_HAPP, USB_DEVICE_ID_UGCI_FIGHTING, HID_QUIRK_BADPAD | HID_QUIRK_MULTI_INPUT }, |
39 | { USB_VENDOR_ID_NATSU, USB_DEVICE_ID_NATSU_GAMEPAD, HID_QUIRK_BADPAD }, | 39 | { USB_VENDOR_ID_NATSU, USB_DEVICE_ID_NATSU_GAMEPAD, HID_QUIRK_BADPAD }, |
40 | { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD }, | 40 | { USB_VENDOR_ID_NEC, USB_DEVICE_ID_NEC_USB_GAME_PAD, HID_QUIRK_BADPAD }, |
41 | { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, | 41 | { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RUMBLEPAD, HID_QUIRK_BADPAD }, |
42 | { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, | 42 | { USB_VENDOR_ID_TOPMAX, USB_DEVICE_ID_TOPMAX_COBRAPAD, HID_QUIRK_BADPAD }, |
43 | 43 | ||
44 | { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL }, | 44 | { USB_VENDOR_ID_AFATECH, USB_DEVICE_ID_AFATECH_AF9016, HID_QUIRK_FULLSPEED_INTERVAL }, |
45 | 45 | ||
46 | { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV }, | 46 | { USB_VENDOR_ID_BELKIN, USB_DEVICE_ID_FLIP_KVM, HID_QUIRK_HIDDEV }, |
47 | { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_HIDDEV | HID_QUIRK_IGNORE_HIDINPUT }, | 47 | { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_HIDDEV | HID_QUIRK_IGNORE_HIDINPUT }, |
48 | 48 | ||
49 | { USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193, HID_QUIRK_HWHEEL_WHEEL_INVERT }, | ||
50 | |||
51 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, | 49 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, |
52 | { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, | 50 | { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, |
53 | 51 | ||
54 | { USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, HID_QUIRK_SONY_PS3_CONTROLLER | HID_QUIRK_HIDDEV }, | 52 | { USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, HID_QUIRK_SONY_PS3_CONTROLLER | HID_QUIRK_HIDDEV }, |
55 | 53 | ||
56 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, | 54 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_UC100KM, HID_QUIRK_NOGET }, |
57 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, | 55 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS124U, HID_QUIRK_NOGET }, |
58 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, | 56 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_2PORTKVM, HID_QUIRK_NOGET }, |
59 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, | 57 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVM, HID_QUIRK_NOGET }, |
60 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, | 58 | { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET }, |
61 | { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, | 59 | { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET }, |
62 | { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, | 60 | { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET }, |
63 | { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_NOGET }, | 61 | { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_NOGET }, |
64 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, | 62 | { USB_VENDOR_ID_SUN, USB_DEVICE_ID_RARITAN_KVM_DONGLE, HID_QUIRK_NOGET }, |
65 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, | 63 | { USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_TURBOX_KEYBOARD, HID_QUIRK_NOGET }, |
66 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, | 64 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, |
67 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, | 65 | { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_QUAD_USB_JOYPAD, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
68 | 66 | ||
69 | { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, | 67 | { USB_VENDOR_ID_WISEGROUP_LTD, USB_DEVICE_ID_SMARTJOY_DUAL_PLUS, HID_QUIRK_NOGET | HID_QUIRK_MULTI_INPUT }, |
70 | 68 | ||
71 | { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, | 69 | { USB_VENDOR_ID_DELL, USB_DEVICE_ID_DELL_W7658, HID_QUIRK_RESET_LEDS }, |
72 | 70 | ||
73 | { 0, 0 } | 71 | { 0, 0 } |
74 | }; | 72 | }; |
75 | 73 | ||
76 | /* Quirks for devices which require report descriptor fixup go here */ | 74 | /* Quirks for devices which require report descriptor fixup go here */ |
77 | static const struct hid_rdesc_blacklist { | 75 | static const struct hid_rdesc_blacklist { |
78 | __u16 idVendor; | 76 | __u16 idVendor; |
79 | __u16 idProduct; | 77 | __u16 idProduct; |
80 | __u32 quirks; | 78 | __u32 quirks; |
81 | } hid_rdesc_blacklist[] = { | 79 | } hid_rdesc_blacklist[] = { |
82 | { USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER }, | 80 | { USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E, HID_QUIRK_RDESC_BUTTON_CONSUMER }, |
83 | 81 | ||
84 | { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_RDESC_PETALYNX }, | 82 | { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_RDESC_PETALYNX }, |
85 | 83 | ||
86 | { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_RDESC_SAMSUNG_REMOTE }, | 84 | { USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE, HID_QUIRK_RDESC_SAMSUNG_REMOTE }, |
87 | 85 | ||
88 | { 0, 0 } | 86 | { 0, 0 } |
89 | }; | 87 | }; |
90 | 88 | ||
91 | /* Dynamic HID quirks list - specified at runtime */ | 89 | /* Dynamic HID quirks list - specified at runtime */ |
92 | struct quirks_list_struct { | 90 | struct quirks_list_struct { |
93 | struct hid_blacklist hid_bl_item; | 91 | struct hid_blacklist hid_bl_item; |
94 | struct list_head node; | 92 | struct list_head node; |
95 | }; | 93 | }; |
96 | 94 | ||
97 | static LIST_HEAD(dquirks_list); | 95 | static LIST_HEAD(dquirks_list); |
98 | static DECLARE_RWSEM(dquirks_rwsem); | 96 | static DECLARE_RWSEM(dquirks_rwsem); |
99 | 97 | ||
100 | /* Runtime ("dynamic") quirks manipulation functions */ | 98 | /* Runtime ("dynamic") quirks manipulation functions */ |
101 | 99 | ||
102 | /** | 100 | /** |
103 | * usbhid_exists_dquirk: find any dynamic quirks for a USB HID device | 101 | * usbhid_exists_dquirk: find any dynamic quirks for a USB HID device |
104 | * @idVendor: the 16-bit USB vendor ID, in native byteorder | 102 | * @idVendor: the 16-bit USB vendor ID, in native byteorder |
105 | * @idProduct: the 16-bit USB product ID, in native byteorder | 103 | * @idProduct: the 16-bit USB product ID, in native byteorder |
106 | * | 104 | * |
107 | * Description: | 105 | * Description: |
108 | * Scans dquirks_list for a matching dynamic quirk and returns | 106 | * Scans dquirks_list for a matching dynamic quirk and returns |
109 | * the pointer to the relevant struct hid_blacklist if found. | 107 | * the pointer to the relevant struct hid_blacklist if found. |
110 | * Must be called with a read lock held on dquirks_rwsem. | 108 | * Must be called with a read lock held on dquirks_rwsem. |
111 | * | 109 | * |
112 | * Returns: NULL if no quirk found, struct hid_blacklist * if found. | 110 | * Returns: NULL if no quirk found, struct hid_blacklist * if found. |
113 | */ | 111 | */ |
114 | static struct hid_blacklist *usbhid_exists_dquirk(const u16 idVendor, | 112 | static struct hid_blacklist *usbhid_exists_dquirk(const u16 idVendor, |
115 | const u16 idProduct) | 113 | const u16 idProduct) |
116 | { | 114 | { |
117 | struct quirks_list_struct *q; | 115 | struct quirks_list_struct *q; |
118 | struct hid_blacklist *bl_entry = NULL; | 116 | struct hid_blacklist *bl_entry = NULL; |
119 | 117 | ||
120 | list_for_each_entry(q, &dquirks_list, node) { | 118 | list_for_each_entry(q, &dquirks_list, node) { |
121 | if (q->hid_bl_item.idVendor == idVendor && | 119 | if (q->hid_bl_item.idVendor == idVendor && |
122 | q->hid_bl_item.idProduct == idProduct) { | 120 | q->hid_bl_item.idProduct == idProduct) { |
123 | bl_entry = &q->hid_bl_item; | 121 | bl_entry = &q->hid_bl_item; |
124 | break; | 122 | break; |
125 | } | 123 | } |
126 | } | 124 | } |
127 | 125 | ||
128 | if (bl_entry != NULL) | 126 | if (bl_entry != NULL) |
129 | dbg_hid("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", | 127 | dbg_hid("Found dynamic quirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", |
130 | bl_entry->quirks, bl_entry->idVendor, | 128 | bl_entry->quirks, bl_entry->idVendor, |
131 | bl_entry->idProduct); | 129 | bl_entry->idProduct); |
132 | 130 | ||
133 | return bl_entry; | 131 | return bl_entry; |
134 | } | 132 | } |
135 | 133 | ||
136 | 134 | ||
137 | /** | 135 | /** |
138 | * usbhid_modify_dquirk: add/replace a HID quirk | 136 | * usbhid_modify_dquirk: add/replace a HID quirk |
139 | * @idVendor: the 16-bit USB vendor ID, in native byteorder | 137 | * @idVendor: the 16-bit USB vendor ID, in native byteorder |
140 | * @idProduct: the 16-bit USB product ID, in native byteorder | 138 | * @idProduct: the 16-bit USB product ID, in native byteorder |
141 | * @quirks: the u32 quirks value to add/replace | 139 | * @quirks: the u32 quirks value to add/replace |
142 | * | 140 | * |
143 | * Description: | 141 | * Description: |
144 | * If an dynamic quirk exists in memory for this (idVendor, | 142 | * If an dynamic quirk exists in memory for this (idVendor, |
145 | * idProduct) pair, replace its quirks value with what was | 143 | * idProduct) pair, replace its quirks value with what was |
146 | * provided. Otherwise, add the quirk to the dynamic quirks list. | 144 | * provided. Otherwise, add the quirk to the dynamic quirks list. |
147 | * | 145 | * |
148 | * Returns: 0 OK, -error on failure. | 146 | * Returns: 0 OK, -error on failure. |
149 | */ | 147 | */ |
150 | static int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct, | 148 | static int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct, |
151 | const u32 quirks) | 149 | const u32 quirks) |
152 | { | 150 | { |
153 | struct quirks_list_struct *q_new, *q; | 151 | struct quirks_list_struct *q_new, *q; |
154 | int list_edited = 0; | 152 | int list_edited = 0; |
155 | 153 | ||
156 | if (!idVendor) { | 154 | if (!idVendor) { |
157 | dbg_hid("Cannot add a quirk with idVendor = 0\n"); | 155 | dbg_hid("Cannot add a quirk with idVendor = 0\n"); |
158 | return -EINVAL; | 156 | return -EINVAL; |
159 | } | 157 | } |
160 | 158 | ||
161 | q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL); | 159 | q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL); |
162 | if (!q_new) { | 160 | if (!q_new) { |
163 | dbg_hid("Could not allocate quirks_list_struct\n"); | 161 | dbg_hid("Could not allocate quirks_list_struct\n"); |
164 | return -ENOMEM; | 162 | return -ENOMEM; |
165 | } | 163 | } |
166 | 164 | ||
167 | q_new->hid_bl_item.idVendor = idVendor; | 165 | q_new->hid_bl_item.idVendor = idVendor; |
168 | q_new->hid_bl_item.idProduct = idProduct; | 166 | q_new->hid_bl_item.idProduct = idProduct; |
169 | q_new->hid_bl_item.quirks = quirks; | 167 | q_new->hid_bl_item.quirks = quirks; |
170 | 168 | ||
171 | down_write(&dquirks_rwsem); | 169 | down_write(&dquirks_rwsem); |
172 | 170 | ||
173 | list_for_each_entry(q, &dquirks_list, node) { | 171 | list_for_each_entry(q, &dquirks_list, node) { |
174 | 172 | ||
175 | if (q->hid_bl_item.idVendor == idVendor && | 173 | if (q->hid_bl_item.idVendor == idVendor && |
176 | q->hid_bl_item.idProduct == idProduct) { | 174 | q->hid_bl_item.idProduct == idProduct) { |
177 | 175 | ||
178 | list_replace(&q->node, &q_new->node); | 176 | list_replace(&q->node, &q_new->node); |
179 | kfree(q); | 177 | kfree(q); |
180 | list_edited = 1; | 178 | list_edited = 1; |
181 | break; | 179 | break; |
182 | 180 | ||
183 | } | 181 | } |
184 | 182 | ||
185 | } | 183 | } |
186 | 184 | ||
187 | if (!list_edited) | 185 | if (!list_edited) |
188 | list_add_tail(&q_new->node, &dquirks_list); | 186 | list_add_tail(&q_new->node, &dquirks_list); |
189 | 187 | ||
190 | up_write(&dquirks_rwsem); | 188 | up_write(&dquirks_rwsem); |
191 | 189 | ||
192 | return 0; | 190 | return 0; |
193 | } | 191 | } |
194 | 192 | ||
195 | /** | 193 | /** |
196 | * usbhid_remove_all_dquirks: remove all runtime HID quirks from memory | 194 | * usbhid_remove_all_dquirks: remove all runtime HID quirks from memory |
197 | * | 195 | * |
198 | * Description: | 196 | * Description: |
199 | * Free all memory associated with dynamic quirks - called before | 197 | * Free all memory associated with dynamic quirks - called before |
200 | * module unload. | 198 | * module unload. |
201 | * | 199 | * |
202 | */ | 200 | */ |
203 | static void usbhid_remove_all_dquirks(void) | 201 | static void usbhid_remove_all_dquirks(void) |
204 | { | 202 | { |
205 | struct quirks_list_struct *q, *temp; | 203 | struct quirks_list_struct *q, *temp; |
206 | 204 | ||
207 | down_write(&dquirks_rwsem); | 205 | down_write(&dquirks_rwsem); |
208 | list_for_each_entry_safe(q, temp, &dquirks_list, node) { | 206 | list_for_each_entry_safe(q, temp, &dquirks_list, node) { |
209 | list_del(&q->node); | 207 | list_del(&q->node); |
210 | kfree(q); | 208 | kfree(q); |
211 | } | 209 | } |
212 | up_write(&dquirks_rwsem); | 210 | up_write(&dquirks_rwsem); |
213 | 211 | ||
214 | } | 212 | } |
215 | 213 | ||
216 | /** | 214 | /** |
217 | * usbhid_quirks_init: apply USB HID quirks specified at module load time | 215 | * usbhid_quirks_init: apply USB HID quirks specified at module load time |
218 | */ | 216 | */ |
219 | int usbhid_quirks_init(char **quirks_param) | 217 | int usbhid_quirks_init(char **quirks_param) |
220 | { | 218 | { |
221 | u16 idVendor, idProduct; | 219 | u16 idVendor, idProduct; |
222 | u32 quirks; | 220 | u32 quirks; |
223 | int n = 0, m; | 221 | int n = 0, m; |
224 | 222 | ||
225 | for (; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) { | 223 | for (; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) { |
226 | 224 | ||
227 | m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x", | 225 | m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x", |
228 | &idVendor, &idProduct, &quirks); | 226 | &idVendor, &idProduct, &quirks); |
229 | 227 | ||
230 | if (m != 3 || | 228 | if (m != 3 || |
231 | usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) { | 229 | usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) { |
232 | printk(KERN_WARNING | 230 | printk(KERN_WARNING |
233 | "Could not parse HID quirk module param %s\n", | 231 | "Could not parse HID quirk module param %s\n", |
234 | quirks_param[n]); | 232 | quirks_param[n]); |
235 | } | 233 | } |
236 | } | 234 | } |
237 | 235 | ||
238 | return 0; | 236 | return 0; |
239 | } | 237 | } |
240 | 238 | ||
241 | /** | 239 | /** |
242 | * usbhid_quirks_exit: release memory associated with dynamic_quirks | 240 | * usbhid_quirks_exit: release memory associated with dynamic_quirks |
243 | * | 241 | * |
244 | * Description: | 242 | * Description: |
245 | * Release all memory associated with dynamic quirks. Called upon | 243 | * Release all memory associated with dynamic quirks. Called upon |
246 | * module unload. | 244 | * module unload. |
247 | * | 245 | * |
248 | * Returns: nothing | 246 | * Returns: nothing |
249 | */ | 247 | */ |
250 | void usbhid_quirks_exit(void) | 248 | void usbhid_quirks_exit(void) |
251 | { | 249 | { |
252 | usbhid_remove_all_dquirks(); | 250 | usbhid_remove_all_dquirks(); |
253 | } | 251 | } |
254 | 252 | ||
255 | /** | 253 | /** |
256 | * usbhid_exists_squirk: return any static quirks for a USB HID device | 254 | * usbhid_exists_squirk: return any static quirks for a USB HID device |
257 | * @idVendor: the 16-bit USB vendor ID, in native byteorder | 255 | * @idVendor: the 16-bit USB vendor ID, in native byteorder |
258 | * @idProduct: the 16-bit USB product ID, in native byteorder | 256 | * @idProduct: the 16-bit USB product ID, in native byteorder |
259 | * | 257 | * |
260 | * Description: | 258 | * Description: |
261 | * Given a USB vendor ID and product ID, return a pointer to | 259 | * Given a USB vendor ID and product ID, return a pointer to |
262 | * the hid_blacklist entry associated with that device. | 260 | * the hid_blacklist entry associated with that device. |
263 | * | 261 | * |
264 | * Returns: pointer if quirk found, or NULL if no quirks found. | 262 | * Returns: pointer if quirk found, or NULL if no quirks found. |
265 | */ | 263 | */ |
266 | static const struct hid_blacklist *usbhid_exists_squirk(const u16 idVendor, | 264 | static const struct hid_blacklist *usbhid_exists_squirk(const u16 idVendor, |
267 | const u16 idProduct) | 265 | const u16 idProduct) |
268 | { | 266 | { |
269 | const struct hid_blacklist *bl_entry = NULL; | 267 | const struct hid_blacklist *bl_entry = NULL; |
270 | int n = 0; | 268 | int n = 0; |
271 | 269 | ||
272 | for (; hid_blacklist[n].idVendor; n++) | 270 | for (; hid_blacklist[n].idVendor; n++) |
273 | if (hid_blacklist[n].idVendor == idVendor && | 271 | if (hid_blacklist[n].idVendor == idVendor && |
274 | hid_blacklist[n].idProduct == idProduct) | 272 | hid_blacklist[n].idProduct == idProduct) |
275 | bl_entry = &hid_blacklist[n]; | 273 | bl_entry = &hid_blacklist[n]; |
276 | 274 | ||
277 | if (bl_entry != NULL) | 275 | if (bl_entry != NULL) |
278 | dbg_hid("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", | 276 | dbg_hid("Found squirk 0x%x for USB HID vendor 0x%hx prod 0x%hx\n", |
279 | bl_entry->quirks, bl_entry->idVendor, | 277 | bl_entry->quirks, bl_entry->idVendor, |
280 | bl_entry->idProduct); | 278 | bl_entry->idProduct); |
281 | return bl_entry; | 279 | return bl_entry; |
282 | } | 280 | } |
283 | 281 | ||
284 | /** | 282 | /** |
285 | * usbhid_lookup_quirk: return any quirks associated with a USB HID device | 283 | * usbhid_lookup_quirk: return any quirks associated with a USB HID device |
286 | * @idVendor: the 16-bit USB vendor ID, in native byteorder | 284 | * @idVendor: the 16-bit USB vendor ID, in native byteorder |
287 | * @idProduct: the 16-bit USB product ID, in native byteorder | 285 | * @idProduct: the 16-bit USB product ID, in native byteorder |
288 | * | 286 | * |
289 | * Description: | 287 | * Description: |
290 | * Given a USB vendor ID and product ID, return any quirks associated | 288 | * Given a USB vendor ID and product ID, return any quirks associated |
291 | * with that device. | 289 | * with that device. |
292 | * | 290 | * |
293 | * Returns: a u32 quirks value. | 291 | * Returns: a u32 quirks value. |
294 | */ | 292 | */ |
295 | u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct) | 293 | u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct) |
296 | { | 294 | { |
297 | u32 quirks = 0; | 295 | u32 quirks = 0; |
298 | const struct hid_blacklist *bl_entry = NULL; | 296 | const struct hid_blacklist *bl_entry = NULL; |
299 | 297 | ||
300 | /* NCR devices must not be queried for reports */ | 298 | /* NCR devices must not be queried for reports */ |
301 | if (idVendor == USB_VENDOR_ID_NCR && | 299 | if (idVendor == USB_VENDOR_ID_NCR && |
302 | idProduct >= USB_DEVICE_ID_NCR_FIRST && | 300 | idProduct >= USB_DEVICE_ID_NCR_FIRST && |
303 | idProduct <= USB_DEVICE_ID_NCR_LAST) | 301 | idProduct <= USB_DEVICE_ID_NCR_LAST) |
304 | return HID_QUIRK_NOGET; | 302 | return HID_QUIRK_NOGET; |
305 | 303 | ||
306 | down_read(&dquirks_rwsem); | 304 | down_read(&dquirks_rwsem); |
307 | bl_entry = usbhid_exists_dquirk(idVendor, idProduct); | 305 | bl_entry = usbhid_exists_dquirk(idVendor, idProduct); |
308 | if (!bl_entry) | 306 | if (!bl_entry) |
309 | bl_entry = usbhid_exists_squirk(idVendor, idProduct); | 307 | bl_entry = usbhid_exists_squirk(idVendor, idProduct); |
310 | if (bl_entry) | 308 | if (bl_entry) |
311 | quirks = bl_entry->quirks; | 309 | quirks = bl_entry->quirks; |
312 | up_read(&dquirks_rwsem); | 310 | up_read(&dquirks_rwsem); |
313 | 311 | ||
314 | return quirks; | 312 | return quirks; |
315 | } | 313 | } |
316 | 314 | ||
317 | EXPORT_SYMBOL_GPL(usbhid_lookup_quirk); | 315 | EXPORT_SYMBOL_GPL(usbhid_lookup_quirk); |
318 | 316 | ||
319 | /* | 317 | /* |
320 | * Samsung IrDA remote controller (reports as Cypress USB Mouse). | 318 | * Samsung IrDA remote controller (reports as Cypress USB Mouse). |
321 | * | 319 | * |
322 | * Vendor specific report #4 has a size of 48 bit, | 320 | * Vendor specific report #4 has a size of 48 bit, |
323 | * and therefore is not accepted when inspecting the descriptors. | 321 | * and therefore is not accepted when inspecting the descriptors. |
324 | * As a workaround we reinterpret the report as: | 322 | * As a workaround we reinterpret the report as: |
325 | * Variable type, count 6, size 8 bit, log. maximum 255 | 323 | * Variable type, count 6, size 8 bit, log. maximum 255 |
326 | * The burden to reconstruct the data is moved into user space. | 324 | * The burden to reconstruct the data is moved into user space. |
327 | */ | 325 | */ |
328 | static void usbhid_fixup_samsung_irda_descriptor(unsigned char *rdesc, | 326 | static void usbhid_fixup_samsung_irda_descriptor(unsigned char *rdesc, |
329 | int rsize) | 327 | int rsize) |
330 | { | 328 | { |
331 | if (rsize >= 182 && rdesc[175] == 0x25 | 329 | if (rsize >= 182 && rdesc[175] == 0x25 |
332 | && rdesc[176] == 0x40 | 330 | && rdesc[176] == 0x40 |
333 | && rdesc[177] == 0x75 | 331 | && rdesc[177] == 0x75 |
334 | && rdesc[178] == 0x30 | 332 | && rdesc[178] == 0x30 |
335 | && rdesc[179] == 0x95 | 333 | && rdesc[179] == 0x95 |
336 | && rdesc[180] == 0x01 | 334 | && rdesc[180] == 0x01 |
337 | && rdesc[182] == 0x40) { | 335 | && rdesc[182] == 0x40) { |
338 | printk(KERN_INFO "Fixing up Samsung IrDA report descriptor\n"); | 336 | printk(KERN_INFO "Fixing up Samsung IrDA report descriptor\n"); |
339 | rdesc[176] = 0xff; | 337 | rdesc[176] = 0xff; |
340 | rdesc[178] = 0x08; | 338 | rdesc[178] = 0x08; |
341 | rdesc[180] = 0x06; | 339 | rdesc[180] = 0x06; |
342 | rdesc[182] = 0x42; | 340 | rdesc[182] = 0x42; |
343 | } | 341 | } |
344 | } | 342 | } |
345 | 343 | ||
346 | /* Petalynx Maxter Remote has maximum for consumer page set too low */ | 344 | /* Petalynx Maxter Remote has maximum for consumer page set too low */ |
347 | static void usbhid_fixup_petalynx_descriptor(unsigned char *rdesc, int rsize) | 345 | static void usbhid_fixup_petalynx_descriptor(unsigned char *rdesc, int rsize) |
348 | { | 346 | { |
349 | if (rsize >= 60 && rdesc[39] == 0x2a | 347 | if (rsize >= 60 && rdesc[39] == 0x2a |
350 | && rdesc[40] == 0xf5 | 348 | && rdesc[40] == 0xf5 |
351 | && rdesc[41] == 0x00 | 349 | && rdesc[41] == 0x00 |
352 | && rdesc[59] == 0x26 | 350 | && rdesc[59] == 0x26 |
353 | && rdesc[60] == 0xf9 | 351 | && rdesc[60] == 0xf9 |
354 | && rdesc[61] == 0x00) { | 352 | && rdesc[61] == 0x00) { |
355 | printk(KERN_INFO "Fixing up Petalynx Maxter Remote report descriptor\n"); | 353 | printk(KERN_INFO "Fixing up Petalynx Maxter Remote report descriptor\n"); |
356 | rdesc[60] = 0xfa; | 354 | rdesc[60] = 0xfa; |
357 | rdesc[40] = 0xfa; | 355 | rdesc[40] = 0xfa; |
358 | } | 356 | } |
359 | } | 357 | } |
360 | 358 | ||
361 | static void usbhid_fixup_button_consumer_descriptor(unsigned char *rdesc, int rsize) | 359 | static void usbhid_fixup_button_consumer_descriptor(unsigned char *rdesc, int rsize) |
362 | { | 360 | { |
363 | if (rsize >= 30 && rdesc[29] == 0x05 | 361 | if (rsize >= 30 && rdesc[29] == 0x05 |
364 | && rdesc[30] == 0x09) { | 362 | && rdesc[30] == 0x09) { |
365 | printk(KERN_INFO "Fixing up button/consumer in HID report descriptor\n"); | 363 | printk(KERN_INFO "Fixing up button/consumer in HID report descriptor\n"); |
366 | rdesc[30] = 0x0c; | 364 | rdesc[30] = 0x0c; |
367 | } | 365 | } |
368 | } | 366 | } |
369 | 367 | ||
370 | static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize) | 368 | static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize) |
371 | { | 369 | { |
372 | if (quirks & HID_QUIRK_RDESC_PETALYNX) | 370 | if (quirks & HID_QUIRK_RDESC_PETALYNX) |
373 | usbhid_fixup_petalynx_descriptor(rdesc, rsize); | 371 | usbhid_fixup_petalynx_descriptor(rdesc, rsize); |
374 | 372 | ||
375 | if (quirks & HID_QUIRK_RDESC_BUTTON_CONSUMER) | 373 | if (quirks & HID_QUIRK_RDESC_BUTTON_CONSUMER) |
376 | usbhid_fixup_button_consumer_descriptor(rdesc, rsize); | 374 | usbhid_fixup_button_consumer_descriptor(rdesc, rsize); |
377 | 375 | ||
378 | if (quirks & HID_QUIRK_RDESC_SAMSUNG_REMOTE) | 376 | if (quirks & HID_QUIRK_RDESC_SAMSUNG_REMOTE) |
379 | usbhid_fixup_samsung_irda_descriptor(rdesc, rsize); | 377 | usbhid_fixup_samsung_irda_descriptor(rdesc, rsize); |
380 | } | 378 | } |
381 | 379 | ||
382 | /** | 380 | /** |
383 | * usbhid_fixup_report_descriptor: check if report descriptor needs fixup | 381 | * usbhid_fixup_report_descriptor: check if report descriptor needs fixup |
384 | * | 382 | * |
385 | * Description: | 383 | * Description: |
386 | * Walks the hid_rdesc_blacklist[] array and checks whether the device | 384 | * Walks the hid_rdesc_blacklist[] array and checks whether the device |
387 | * is known to have broken report descriptor that needs to be fixed up | 385 | * is known to have broken report descriptor that needs to be fixed up |
388 | * prior to entering the HID parser | 386 | * prior to entering the HID parser |
389 | * | 387 | * |
390 | * Returns: nothing | 388 | * Returns: nothing |
391 | */ | 389 | */ |
392 | void usbhid_fixup_report_descriptor(const u16 idVendor, const u16 idProduct, | 390 | void usbhid_fixup_report_descriptor(const u16 idVendor, const u16 idProduct, |
393 | char *rdesc, unsigned rsize, char **quirks_param) | 391 | char *rdesc, unsigned rsize, char **quirks_param) |
394 | { | 392 | { |
395 | int n, m; | 393 | int n, m; |
396 | u16 paramVendor, paramProduct; | 394 | u16 paramVendor, paramProduct; |
397 | u32 quirks; | 395 | u32 quirks; |
398 | 396 | ||
399 | /* static rdesc quirk entries */ | 397 | /* static rdesc quirk entries */ |
400 | for (n = 0; hid_rdesc_blacklist[n].idVendor; n++) | 398 | for (n = 0; hid_rdesc_blacklist[n].idVendor; n++) |
401 | if (hid_rdesc_blacklist[n].idVendor == idVendor && | 399 | if (hid_rdesc_blacklist[n].idVendor == idVendor && |
402 | hid_rdesc_blacklist[n].idProduct == idProduct) | 400 | hid_rdesc_blacklist[n].idProduct == idProduct) |
403 | __usbhid_fixup_report_descriptor(hid_rdesc_blacklist[n].quirks, | 401 | __usbhid_fixup_report_descriptor(hid_rdesc_blacklist[n].quirks, |
404 | rdesc, rsize); | 402 | rdesc, rsize); |
405 | 403 | ||
406 | /* runtime rdesc quirk entries handling */ | 404 | /* runtime rdesc quirk entries handling */ |
407 | for (n = 0; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) { | 405 | for (n = 0; quirks_param[n] && n < MAX_USBHID_BOOT_QUIRKS; n++) { |
408 | m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x", | 406 | m = sscanf(quirks_param[n], "0x%hx:0x%hx:0x%x", |
409 | ¶mVendor, ¶mProduct, &quirks); | 407 | ¶mVendor, ¶mProduct, &quirks); |
410 | 408 | ||
411 | if (m != 3) | 409 | if (m != 3) |
412 | printk(KERN_WARNING | 410 | printk(KERN_WARNING |
413 | "Could not parse HID quirk module param %s\n", | 411 | "Could not parse HID quirk module param %s\n", |
414 | quirks_param[n]); | 412 | quirks_param[n]); |
415 | else if (paramVendor == idVendor && paramProduct == idProduct) | 413 | else if (paramVendor == idVendor && paramProduct == idProduct) |
416 | __usbhid_fixup_report_descriptor(quirks, rdesc, rsize); | 414 | __usbhid_fixup_report_descriptor(quirks, rdesc, rsize); |
417 | } | 415 | } |
418 | } | 416 | } |
419 | 417 |
include/linux/hid.h
1 | #ifndef __HID_H | 1 | #ifndef __HID_H |
2 | #define __HID_H | 2 | #define __HID_H |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * Copyright (c) 1999 Andreas Gal | 5 | * Copyright (c) 1999 Andreas Gal |
6 | * Copyright (c) 2000-2001 Vojtech Pavlik | 6 | * Copyright (c) 2000-2001 Vojtech Pavlik |
7 | * Copyright (c) 2006-2007 Jiri Kosina | 7 | * Copyright (c) 2006-2007 Jiri Kosina |
8 | */ | 8 | */ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or | 13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. | 14 | * (at your option) any later version. |
15 | * | 15 | * |
16 | * This program is distributed in the hope that it will be useful, | 16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. | 19 | * GNU General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU General Public License | 21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software | 22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 | * | 24 | * |
25 | * Should you need to contact me, the author, you can do so either by | 25 | * Should you need to contact me, the author, you can do so either by |
26 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: | 26 | * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail: |
27 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | 27 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * USB HID (Human Interface Device) interface class code | 31 | * USB HID (Human Interface Device) interface class code |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #define USB_INTERFACE_CLASS_HID 3 | 34 | #define USB_INTERFACE_CLASS_HID 3 |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * USB HID interface subclass and protocol codes | 37 | * USB HID interface subclass and protocol codes |
38 | */ | 38 | */ |
39 | 39 | ||
40 | #define USB_INTERFACE_SUBCLASS_BOOT 1 | 40 | #define USB_INTERFACE_SUBCLASS_BOOT 1 |
41 | #define USB_INTERFACE_PROTOCOL_KEYBOARD 1 | 41 | #define USB_INTERFACE_PROTOCOL_KEYBOARD 1 |
42 | #define USB_INTERFACE_PROTOCOL_MOUSE 2 | 42 | #define USB_INTERFACE_PROTOCOL_MOUSE 2 |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * HID class requests | 45 | * HID class requests |
46 | */ | 46 | */ |
47 | 47 | ||
48 | #define HID_REQ_GET_REPORT 0x01 | 48 | #define HID_REQ_GET_REPORT 0x01 |
49 | #define HID_REQ_GET_IDLE 0x02 | 49 | #define HID_REQ_GET_IDLE 0x02 |
50 | #define HID_REQ_GET_PROTOCOL 0x03 | 50 | #define HID_REQ_GET_PROTOCOL 0x03 |
51 | #define HID_REQ_SET_REPORT 0x09 | 51 | #define HID_REQ_SET_REPORT 0x09 |
52 | #define HID_REQ_SET_IDLE 0x0A | 52 | #define HID_REQ_SET_IDLE 0x0A |
53 | #define HID_REQ_SET_PROTOCOL 0x0B | 53 | #define HID_REQ_SET_PROTOCOL 0x0B |
54 | 54 | ||
55 | /* | 55 | /* |
56 | * HID class descriptor types | 56 | * HID class descriptor types |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #define HID_DT_HID (USB_TYPE_CLASS | 0x01) | 59 | #define HID_DT_HID (USB_TYPE_CLASS | 0x01) |
60 | #define HID_DT_REPORT (USB_TYPE_CLASS | 0x02) | 60 | #define HID_DT_REPORT (USB_TYPE_CLASS | 0x02) |
61 | #define HID_DT_PHYSICAL (USB_TYPE_CLASS | 0x03) | 61 | #define HID_DT_PHYSICAL (USB_TYPE_CLASS | 0x03) |
62 | 62 | ||
63 | #define HID_MAX_DESCRIPTOR_SIZE 4096 | 63 | #define HID_MAX_DESCRIPTOR_SIZE 4096 |
64 | 64 | ||
65 | #ifdef __KERNEL__ | 65 | #ifdef __KERNEL__ |
66 | 66 | ||
67 | #include <linux/types.h> | 67 | #include <linux/types.h> |
68 | #include <linux/slab.h> | 68 | #include <linux/slab.h> |
69 | #include <linux/list.h> | 69 | #include <linux/list.h> |
70 | #include <linux/mod_devicetable.h> /* hid_device_id */ | 70 | #include <linux/mod_devicetable.h> /* hid_device_id */ |
71 | #include <linux/timer.h> | 71 | #include <linux/timer.h> |
72 | #include <linux/workqueue.h> | 72 | #include <linux/workqueue.h> |
73 | #include <linux/input.h> | 73 | #include <linux/input.h> |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * We parse each description item into this structure. Short items data | 76 | * We parse each description item into this structure. Short items data |
77 | * values are expanded to 32-bit signed int, long items contain a pointer | 77 | * values are expanded to 32-bit signed int, long items contain a pointer |
78 | * into the data area. | 78 | * into the data area. |
79 | */ | 79 | */ |
80 | 80 | ||
81 | struct hid_item { | 81 | struct hid_item { |
82 | unsigned format; | 82 | unsigned format; |
83 | __u8 size; | 83 | __u8 size; |
84 | __u8 type; | 84 | __u8 type; |
85 | __u8 tag; | 85 | __u8 tag; |
86 | union { | 86 | union { |
87 | __u8 u8; | 87 | __u8 u8; |
88 | __s8 s8; | 88 | __s8 s8; |
89 | __u16 u16; | 89 | __u16 u16; |
90 | __s16 s16; | 90 | __s16 s16; |
91 | __u32 u32; | 91 | __u32 u32; |
92 | __s32 s32; | 92 | __s32 s32; |
93 | __u8 *longdata; | 93 | __u8 *longdata; |
94 | } data; | 94 | } data; |
95 | }; | 95 | }; |
96 | 96 | ||
97 | /* | 97 | /* |
98 | * HID report item format | 98 | * HID report item format |
99 | */ | 99 | */ |
100 | 100 | ||
101 | #define HID_ITEM_FORMAT_SHORT 0 | 101 | #define HID_ITEM_FORMAT_SHORT 0 |
102 | #define HID_ITEM_FORMAT_LONG 1 | 102 | #define HID_ITEM_FORMAT_LONG 1 |
103 | 103 | ||
104 | /* | 104 | /* |
105 | * Special tag indicating long items | 105 | * Special tag indicating long items |
106 | */ | 106 | */ |
107 | 107 | ||
108 | #define HID_ITEM_TAG_LONG 15 | 108 | #define HID_ITEM_TAG_LONG 15 |
109 | 109 | ||
110 | /* | 110 | /* |
111 | * HID report descriptor item type (prefix bit 2,3) | 111 | * HID report descriptor item type (prefix bit 2,3) |
112 | */ | 112 | */ |
113 | 113 | ||
114 | #define HID_ITEM_TYPE_MAIN 0 | 114 | #define HID_ITEM_TYPE_MAIN 0 |
115 | #define HID_ITEM_TYPE_GLOBAL 1 | 115 | #define HID_ITEM_TYPE_GLOBAL 1 |
116 | #define HID_ITEM_TYPE_LOCAL 2 | 116 | #define HID_ITEM_TYPE_LOCAL 2 |
117 | #define HID_ITEM_TYPE_RESERVED 3 | 117 | #define HID_ITEM_TYPE_RESERVED 3 |
118 | 118 | ||
119 | /* | 119 | /* |
120 | * HID report descriptor main item tags | 120 | * HID report descriptor main item tags |
121 | */ | 121 | */ |
122 | 122 | ||
123 | #define HID_MAIN_ITEM_TAG_INPUT 8 | 123 | #define HID_MAIN_ITEM_TAG_INPUT 8 |
124 | #define HID_MAIN_ITEM_TAG_OUTPUT 9 | 124 | #define HID_MAIN_ITEM_TAG_OUTPUT 9 |
125 | #define HID_MAIN_ITEM_TAG_FEATURE 11 | 125 | #define HID_MAIN_ITEM_TAG_FEATURE 11 |
126 | #define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10 | 126 | #define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10 |
127 | #define HID_MAIN_ITEM_TAG_END_COLLECTION 12 | 127 | #define HID_MAIN_ITEM_TAG_END_COLLECTION 12 |
128 | 128 | ||
129 | /* | 129 | /* |
130 | * HID report descriptor main item contents | 130 | * HID report descriptor main item contents |
131 | */ | 131 | */ |
132 | 132 | ||
133 | #define HID_MAIN_ITEM_CONSTANT 0x001 | 133 | #define HID_MAIN_ITEM_CONSTANT 0x001 |
134 | #define HID_MAIN_ITEM_VARIABLE 0x002 | 134 | #define HID_MAIN_ITEM_VARIABLE 0x002 |
135 | #define HID_MAIN_ITEM_RELATIVE 0x004 | 135 | #define HID_MAIN_ITEM_RELATIVE 0x004 |
136 | #define HID_MAIN_ITEM_WRAP 0x008 | 136 | #define HID_MAIN_ITEM_WRAP 0x008 |
137 | #define HID_MAIN_ITEM_NONLINEAR 0x010 | 137 | #define HID_MAIN_ITEM_NONLINEAR 0x010 |
138 | #define HID_MAIN_ITEM_NO_PREFERRED 0x020 | 138 | #define HID_MAIN_ITEM_NO_PREFERRED 0x020 |
139 | #define HID_MAIN_ITEM_NULL_STATE 0x040 | 139 | #define HID_MAIN_ITEM_NULL_STATE 0x040 |
140 | #define HID_MAIN_ITEM_VOLATILE 0x080 | 140 | #define HID_MAIN_ITEM_VOLATILE 0x080 |
141 | #define HID_MAIN_ITEM_BUFFERED_BYTE 0x100 | 141 | #define HID_MAIN_ITEM_BUFFERED_BYTE 0x100 |
142 | 142 | ||
143 | /* | 143 | /* |
144 | * HID report descriptor collection item types | 144 | * HID report descriptor collection item types |
145 | */ | 145 | */ |
146 | 146 | ||
147 | #define HID_COLLECTION_PHYSICAL 0 | 147 | #define HID_COLLECTION_PHYSICAL 0 |
148 | #define HID_COLLECTION_APPLICATION 1 | 148 | #define HID_COLLECTION_APPLICATION 1 |
149 | #define HID_COLLECTION_LOGICAL 2 | 149 | #define HID_COLLECTION_LOGICAL 2 |
150 | 150 | ||
151 | /* | 151 | /* |
152 | * HID report descriptor global item tags | 152 | * HID report descriptor global item tags |
153 | */ | 153 | */ |
154 | 154 | ||
155 | #define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0 | 155 | #define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0 |
156 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1 | 156 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1 |
157 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2 | 157 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2 |
158 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3 | 158 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3 |
159 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4 | 159 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4 |
160 | #define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5 | 160 | #define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5 |
161 | #define HID_GLOBAL_ITEM_TAG_UNIT 6 | 161 | #define HID_GLOBAL_ITEM_TAG_UNIT 6 |
162 | #define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7 | 162 | #define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7 |
163 | #define HID_GLOBAL_ITEM_TAG_REPORT_ID 8 | 163 | #define HID_GLOBAL_ITEM_TAG_REPORT_ID 8 |
164 | #define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9 | 164 | #define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9 |
165 | #define HID_GLOBAL_ITEM_TAG_PUSH 10 | 165 | #define HID_GLOBAL_ITEM_TAG_PUSH 10 |
166 | #define HID_GLOBAL_ITEM_TAG_POP 11 | 166 | #define HID_GLOBAL_ITEM_TAG_POP 11 |
167 | 167 | ||
168 | /* | 168 | /* |
169 | * HID report descriptor local item tags | 169 | * HID report descriptor local item tags |
170 | */ | 170 | */ |
171 | 171 | ||
172 | #define HID_LOCAL_ITEM_TAG_USAGE 0 | 172 | #define HID_LOCAL_ITEM_TAG_USAGE 0 |
173 | #define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1 | 173 | #define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1 |
174 | #define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2 | 174 | #define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2 |
175 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3 | 175 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3 |
176 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4 | 176 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4 |
177 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5 | 177 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5 |
178 | #define HID_LOCAL_ITEM_TAG_STRING_INDEX 7 | 178 | #define HID_LOCAL_ITEM_TAG_STRING_INDEX 7 |
179 | #define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8 | 179 | #define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8 |
180 | #define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9 | 180 | #define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9 |
181 | #define HID_LOCAL_ITEM_TAG_DELIMITER 10 | 181 | #define HID_LOCAL_ITEM_TAG_DELIMITER 10 |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * HID usage tables | 184 | * HID usage tables |
185 | */ | 185 | */ |
186 | 186 | ||
187 | #define HID_USAGE_PAGE 0xffff0000 | 187 | #define HID_USAGE_PAGE 0xffff0000 |
188 | 188 | ||
189 | #define HID_UP_UNDEFINED 0x00000000 | 189 | #define HID_UP_UNDEFINED 0x00000000 |
190 | #define HID_UP_GENDESK 0x00010000 | 190 | #define HID_UP_GENDESK 0x00010000 |
191 | #define HID_UP_SIMULATION 0x00020000 | 191 | #define HID_UP_SIMULATION 0x00020000 |
192 | #define HID_UP_KEYBOARD 0x00070000 | 192 | #define HID_UP_KEYBOARD 0x00070000 |
193 | #define HID_UP_LED 0x00080000 | 193 | #define HID_UP_LED 0x00080000 |
194 | #define HID_UP_BUTTON 0x00090000 | 194 | #define HID_UP_BUTTON 0x00090000 |
195 | #define HID_UP_ORDINAL 0x000a0000 | 195 | #define HID_UP_ORDINAL 0x000a0000 |
196 | #define HID_UP_CONSUMER 0x000c0000 | 196 | #define HID_UP_CONSUMER 0x000c0000 |
197 | #define HID_UP_DIGITIZER 0x000d0000 | 197 | #define HID_UP_DIGITIZER 0x000d0000 |
198 | #define HID_UP_PID 0x000f0000 | 198 | #define HID_UP_PID 0x000f0000 |
199 | #define HID_UP_HPVENDOR 0xff7f0000 | 199 | #define HID_UP_HPVENDOR 0xff7f0000 |
200 | #define HID_UP_MSVENDOR 0xff000000 | 200 | #define HID_UP_MSVENDOR 0xff000000 |
201 | #define HID_UP_CUSTOM 0x00ff0000 | 201 | #define HID_UP_CUSTOM 0x00ff0000 |
202 | #define HID_UP_LOGIVENDOR 0xffbc0000 | 202 | #define HID_UP_LOGIVENDOR 0xffbc0000 |
203 | 203 | ||
204 | #define HID_USAGE 0x0000ffff | 204 | #define HID_USAGE 0x0000ffff |
205 | 205 | ||
206 | #define HID_GD_POINTER 0x00010001 | 206 | #define HID_GD_POINTER 0x00010001 |
207 | #define HID_GD_MOUSE 0x00010002 | 207 | #define HID_GD_MOUSE 0x00010002 |
208 | #define HID_GD_JOYSTICK 0x00010004 | 208 | #define HID_GD_JOYSTICK 0x00010004 |
209 | #define HID_GD_GAMEPAD 0x00010005 | 209 | #define HID_GD_GAMEPAD 0x00010005 |
210 | #define HID_GD_KEYBOARD 0x00010006 | 210 | #define HID_GD_KEYBOARD 0x00010006 |
211 | #define HID_GD_KEYPAD 0x00010007 | 211 | #define HID_GD_KEYPAD 0x00010007 |
212 | #define HID_GD_MULTIAXIS 0x00010008 | 212 | #define HID_GD_MULTIAXIS 0x00010008 |
213 | #define HID_GD_X 0x00010030 | 213 | #define HID_GD_X 0x00010030 |
214 | #define HID_GD_Y 0x00010031 | 214 | #define HID_GD_Y 0x00010031 |
215 | #define HID_GD_Z 0x00010032 | 215 | #define HID_GD_Z 0x00010032 |
216 | #define HID_GD_RX 0x00010033 | 216 | #define HID_GD_RX 0x00010033 |
217 | #define HID_GD_RY 0x00010034 | 217 | #define HID_GD_RY 0x00010034 |
218 | #define HID_GD_RZ 0x00010035 | 218 | #define HID_GD_RZ 0x00010035 |
219 | #define HID_GD_SLIDER 0x00010036 | 219 | #define HID_GD_SLIDER 0x00010036 |
220 | #define HID_GD_DIAL 0x00010037 | 220 | #define HID_GD_DIAL 0x00010037 |
221 | #define HID_GD_WHEEL 0x00010038 | 221 | #define HID_GD_WHEEL 0x00010038 |
222 | #define HID_GD_HATSWITCH 0x00010039 | 222 | #define HID_GD_HATSWITCH 0x00010039 |
223 | #define HID_GD_BUFFER 0x0001003a | 223 | #define HID_GD_BUFFER 0x0001003a |
224 | #define HID_GD_BYTECOUNT 0x0001003b | 224 | #define HID_GD_BYTECOUNT 0x0001003b |
225 | #define HID_GD_MOTION 0x0001003c | 225 | #define HID_GD_MOTION 0x0001003c |
226 | #define HID_GD_START 0x0001003d | 226 | #define HID_GD_START 0x0001003d |
227 | #define HID_GD_SELECT 0x0001003e | 227 | #define HID_GD_SELECT 0x0001003e |
228 | #define HID_GD_VX 0x00010040 | 228 | #define HID_GD_VX 0x00010040 |
229 | #define HID_GD_VY 0x00010041 | 229 | #define HID_GD_VY 0x00010041 |
230 | #define HID_GD_VZ 0x00010042 | 230 | #define HID_GD_VZ 0x00010042 |
231 | #define HID_GD_VBRX 0x00010043 | 231 | #define HID_GD_VBRX 0x00010043 |
232 | #define HID_GD_VBRY 0x00010044 | 232 | #define HID_GD_VBRY 0x00010044 |
233 | #define HID_GD_VBRZ 0x00010045 | 233 | #define HID_GD_VBRZ 0x00010045 |
234 | #define HID_GD_VNO 0x00010046 | 234 | #define HID_GD_VNO 0x00010046 |
235 | #define HID_GD_FEATURE 0x00010047 | 235 | #define HID_GD_FEATURE 0x00010047 |
236 | #define HID_GD_UP 0x00010090 | 236 | #define HID_GD_UP 0x00010090 |
237 | #define HID_GD_DOWN 0x00010091 | 237 | #define HID_GD_DOWN 0x00010091 |
238 | #define HID_GD_RIGHT 0x00010092 | 238 | #define HID_GD_RIGHT 0x00010092 |
239 | #define HID_GD_LEFT 0x00010093 | 239 | #define HID_GD_LEFT 0x00010093 |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * HID report types --- Ouch! HID spec says 1 2 3! | 242 | * HID report types --- Ouch! HID spec says 1 2 3! |
243 | */ | 243 | */ |
244 | 244 | ||
245 | #define HID_INPUT_REPORT 0 | 245 | #define HID_INPUT_REPORT 0 |
246 | #define HID_OUTPUT_REPORT 1 | 246 | #define HID_OUTPUT_REPORT 1 |
247 | #define HID_FEATURE_REPORT 2 | 247 | #define HID_FEATURE_REPORT 2 |
248 | 248 | ||
249 | /* | 249 | /* |
250 | * HID device quirks. | 250 | * HID device quirks. |
251 | */ | 251 | */ |
252 | 252 | ||
253 | /* | 253 | /* |
254 | * Increase this if you need to configure more HID quirks at module load time | 254 | * Increase this if you need to configure more HID quirks at module load time |
255 | */ | 255 | */ |
256 | #define MAX_USBHID_BOOT_QUIRKS 4 | 256 | #define MAX_USBHID_BOOT_QUIRKS 4 |
257 | 257 | ||
258 | #define HID_QUIRK_INVERT 0x00000001 | 258 | #define HID_QUIRK_INVERT 0x00000001 |
259 | #define HID_QUIRK_NOTOUCH 0x00000002 | 259 | #define HID_QUIRK_NOTOUCH 0x00000002 |
260 | #define HID_QUIRK_NOGET 0x00000008 | 260 | #define HID_QUIRK_NOGET 0x00000008 |
261 | #define HID_QUIRK_HIDDEV 0x00000010 | 261 | #define HID_QUIRK_HIDDEV 0x00000010 |
262 | #define HID_QUIRK_BADPAD 0x00000020 | 262 | #define HID_QUIRK_BADPAD 0x00000020 |
263 | #define HID_QUIRK_MULTI_INPUT 0x00000040 | 263 | #define HID_QUIRK_MULTI_INPUT 0x00000040 |
264 | #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 | 264 | #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 |
265 | #define HID_QUIRK_SONY_PS3_CONTROLLER 0x00040000 | 265 | #define HID_QUIRK_SONY_PS3_CONTROLLER 0x00040000 |
266 | #define HID_QUIRK_RESET_LEDS 0x00100000 | 266 | #define HID_QUIRK_RESET_LEDS 0x00100000 |
267 | #define HID_QUIRK_HIDINPUT 0x00200000 | 267 | #define HID_QUIRK_HIDINPUT 0x00200000 |
268 | #define HID_QUIRK_IGNORE_HIDINPUT 0x01000000 | 268 | #define HID_QUIRK_IGNORE_HIDINPUT 0x01000000 |
269 | #define HID_QUIRK_HWHEEL_WHEEL_INVERT 0x04000000 | ||
270 | #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 | 269 | #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 |
271 | 270 | ||
272 | /* | 271 | /* |
273 | * Separate quirks for runtime report descriptor fixup | 272 | * Separate quirks for runtime report descriptor fixup |
274 | */ | 273 | */ |
275 | 274 | ||
276 | #define HID_QUIRK_RDESC_PETALYNX 0x00000008 | 275 | #define HID_QUIRK_RDESC_PETALYNX 0x00000008 |
277 | #define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020 | 276 | #define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020 |
278 | #define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040 | 277 | #define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040 |
279 | 278 | ||
280 | /* | 279 | /* |
281 | * This is the global environment of the parser. This information is | 280 | * This is the global environment of the parser. This information is |
282 | * persistent for main-items. The global environment can be saved and | 281 | * persistent for main-items. The global environment can be saved and |
283 | * restored with PUSH/POP statements. | 282 | * restored with PUSH/POP statements. |
284 | */ | 283 | */ |
285 | 284 | ||
286 | struct hid_global { | 285 | struct hid_global { |
287 | unsigned usage_page; | 286 | unsigned usage_page; |
288 | __s32 logical_minimum; | 287 | __s32 logical_minimum; |
289 | __s32 logical_maximum; | 288 | __s32 logical_maximum; |
290 | __s32 physical_minimum; | 289 | __s32 physical_minimum; |
291 | __s32 physical_maximum; | 290 | __s32 physical_maximum; |
292 | __s32 unit_exponent; | 291 | __s32 unit_exponent; |
293 | unsigned unit; | 292 | unsigned unit; |
294 | unsigned report_id; | 293 | unsigned report_id; |
295 | unsigned report_size; | 294 | unsigned report_size; |
296 | unsigned report_count; | 295 | unsigned report_count; |
297 | }; | 296 | }; |
298 | 297 | ||
299 | /* | 298 | /* |
300 | * This is the local environment. It is persistent up the next main-item. | 299 | * This is the local environment. It is persistent up the next main-item. |
301 | */ | 300 | */ |
302 | 301 | ||
303 | #define HID_MAX_USAGES 12288 | 302 | #define HID_MAX_USAGES 12288 |
304 | #define HID_DEFAULT_NUM_COLLECTIONS 16 | 303 | #define HID_DEFAULT_NUM_COLLECTIONS 16 |
305 | 304 | ||
306 | struct hid_local { | 305 | struct hid_local { |
307 | unsigned usage[HID_MAX_USAGES]; /* usage array */ | 306 | unsigned usage[HID_MAX_USAGES]; /* usage array */ |
308 | unsigned collection_index[HID_MAX_USAGES]; /* collection index array */ | 307 | unsigned collection_index[HID_MAX_USAGES]; /* collection index array */ |
309 | unsigned usage_index; | 308 | unsigned usage_index; |
310 | unsigned usage_minimum; | 309 | unsigned usage_minimum; |
311 | unsigned delimiter_depth; | 310 | unsigned delimiter_depth; |
312 | unsigned delimiter_branch; | 311 | unsigned delimiter_branch; |
313 | }; | 312 | }; |
314 | 313 | ||
315 | /* | 314 | /* |
316 | * This is the collection stack. We climb up the stack to determine | 315 | * This is the collection stack. We climb up the stack to determine |
317 | * application and function of each field. | 316 | * application and function of each field. |
318 | */ | 317 | */ |
319 | 318 | ||
320 | struct hid_collection { | 319 | struct hid_collection { |
321 | unsigned type; | 320 | unsigned type; |
322 | unsigned usage; | 321 | unsigned usage; |
323 | unsigned level; | 322 | unsigned level; |
324 | }; | 323 | }; |
325 | 324 | ||
326 | struct hid_usage { | 325 | struct hid_usage { |
327 | unsigned hid; /* hid usage code */ | 326 | unsigned hid; /* hid usage code */ |
328 | unsigned collection_index; /* index into collection array */ | 327 | unsigned collection_index; /* index into collection array */ |
329 | /* hidinput data */ | 328 | /* hidinput data */ |
330 | __u16 code; /* input driver code */ | 329 | __u16 code; /* input driver code */ |
331 | __u8 type; /* input driver type */ | 330 | __u8 type; /* input driver type */ |
332 | __s8 hat_min; /* hat switch fun */ | 331 | __s8 hat_min; /* hat switch fun */ |
333 | __s8 hat_max; /* ditto */ | 332 | __s8 hat_max; /* ditto */ |
334 | __s8 hat_dir; /* ditto */ | 333 | __s8 hat_dir; /* ditto */ |
335 | }; | 334 | }; |
336 | 335 | ||
337 | struct hid_input; | 336 | struct hid_input; |
338 | 337 | ||
339 | struct hid_field { | 338 | struct hid_field { |
340 | unsigned physical; /* physical usage for this field */ | 339 | unsigned physical; /* physical usage for this field */ |
341 | unsigned logical; /* logical usage for this field */ | 340 | unsigned logical; /* logical usage for this field */ |
342 | unsigned application; /* application usage for this field */ | 341 | unsigned application; /* application usage for this field */ |
343 | struct hid_usage *usage; /* usage table for this function */ | 342 | struct hid_usage *usage; /* usage table for this function */ |
344 | unsigned maxusage; /* maximum usage index */ | 343 | unsigned maxusage; /* maximum usage index */ |
345 | unsigned flags; /* main-item flags (i.e. volatile,array,constant) */ | 344 | unsigned flags; /* main-item flags (i.e. volatile,array,constant) */ |
346 | unsigned report_offset; /* bit offset in the report */ | 345 | unsigned report_offset; /* bit offset in the report */ |
347 | unsigned report_size; /* size of this field in the report */ | 346 | unsigned report_size; /* size of this field in the report */ |
348 | unsigned report_count; /* number of this field in the report */ | 347 | unsigned report_count; /* number of this field in the report */ |
349 | unsigned report_type; /* (input,output,feature) */ | 348 | unsigned report_type; /* (input,output,feature) */ |
350 | __s32 *value; /* last known value(s) */ | 349 | __s32 *value; /* last known value(s) */ |
351 | __s32 logical_minimum; | 350 | __s32 logical_minimum; |
352 | __s32 logical_maximum; | 351 | __s32 logical_maximum; |
353 | __s32 physical_minimum; | 352 | __s32 physical_minimum; |
354 | __s32 physical_maximum; | 353 | __s32 physical_maximum; |
355 | __s32 unit_exponent; | 354 | __s32 unit_exponent; |
356 | unsigned unit; | 355 | unsigned unit; |
357 | struct hid_report *report; /* associated report */ | 356 | struct hid_report *report; /* associated report */ |
358 | unsigned index; /* index into report->field[] */ | 357 | unsigned index; /* index into report->field[] */ |
359 | /* hidinput data */ | 358 | /* hidinput data */ |
360 | struct hid_input *hidinput; /* associated input structure */ | 359 | struct hid_input *hidinput; /* associated input structure */ |
361 | __u16 dpad; /* dpad input code */ | 360 | __u16 dpad; /* dpad input code */ |
362 | }; | 361 | }; |
363 | 362 | ||
364 | #define HID_MAX_FIELDS 64 | 363 | #define HID_MAX_FIELDS 64 |
365 | 364 | ||
366 | struct hid_report { | 365 | struct hid_report { |
367 | struct list_head list; | 366 | struct list_head list; |
368 | unsigned id; /* id of this report */ | 367 | unsigned id; /* id of this report */ |
369 | unsigned type; /* report type */ | 368 | unsigned type; /* report type */ |
370 | struct hid_field *field[HID_MAX_FIELDS]; /* fields of the report */ | 369 | struct hid_field *field[HID_MAX_FIELDS]; /* fields of the report */ |
371 | unsigned maxfield; /* maximum valid field index */ | 370 | unsigned maxfield; /* maximum valid field index */ |
372 | unsigned size; /* size of the report (bits) */ | 371 | unsigned size; /* size of the report (bits) */ |
373 | struct hid_device *device; /* associated device */ | 372 | struct hid_device *device; /* associated device */ |
374 | }; | 373 | }; |
375 | 374 | ||
376 | struct hid_report_enum { | 375 | struct hid_report_enum { |
377 | unsigned numbered; | 376 | unsigned numbered; |
378 | struct list_head report_list; | 377 | struct list_head report_list; |
379 | struct hid_report *report_id_hash[256]; | 378 | struct hid_report *report_id_hash[256]; |
380 | }; | 379 | }; |
381 | 380 | ||
382 | #define HID_REPORT_TYPES 3 | 381 | #define HID_REPORT_TYPES 3 |
383 | 382 | ||
384 | #define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */ | 383 | #define HID_MIN_BUFFER_SIZE 64 /* make sure there is at least a packet size of space */ |
385 | #define HID_MAX_BUFFER_SIZE 4096 /* 4kb */ | 384 | #define HID_MAX_BUFFER_SIZE 4096 /* 4kb */ |
386 | #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */ | 385 | #define HID_CONTROL_FIFO_SIZE 256 /* to init devices with >100 reports */ |
387 | #define HID_OUTPUT_FIFO_SIZE 64 | 386 | #define HID_OUTPUT_FIFO_SIZE 64 |
388 | 387 | ||
389 | struct hid_control_fifo { | 388 | struct hid_control_fifo { |
390 | unsigned char dir; | 389 | unsigned char dir; |
391 | struct hid_report *report; | 390 | struct hid_report *report; |
392 | }; | 391 | }; |
393 | 392 | ||
394 | #define HID_CLAIMED_INPUT 1 | 393 | #define HID_CLAIMED_INPUT 1 |
395 | #define HID_CLAIMED_HIDDEV 2 | 394 | #define HID_CLAIMED_HIDDEV 2 |
396 | #define HID_CLAIMED_HIDRAW 4 | 395 | #define HID_CLAIMED_HIDRAW 4 |
397 | 396 | ||
398 | #define HID_STAT_ADDED 1 | 397 | #define HID_STAT_ADDED 1 |
399 | #define HID_STAT_PARSED 2 | 398 | #define HID_STAT_PARSED 2 |
400 | 399 | ||
401 | #define HID_CTRL_RUNNING 1 | 400 | #define HID_CTRL_RUNNING 1 |
402 | #define HID_OUT_RUNNING 2 | 401 | #define HID_OUT_RUNNING 2 |
403 | #define HID_IN_RUNNING 3 | 402 | #define HID_IN_RUNNING 3 |
404 | #define HID_RESET_PENDING 4 | 403 | #define HID_RESET_PENDING 4 |
405 | #define HID_SUSPENDED 5 | 404 | #define HID_SUSPENDED 5 |
406 | #define HID_CLEAR_HALT 6 | 405 | #define HID_CLEAR_HALT 6 |
407 | #define HID_DISCONNECTED 7 | 406 | #define HID_DISCONNECTED 7 |
408 | 407 | ||
409 | struct hid_input { | 408 | struct hid_input { |
410 | struct list_head list; | 409 | struct list_head list; |
411 | struct hid_report *report; | 410 | struct hid_report *report; |
412 | struct input_dev *input; | 411 | struct input_dev *input; |
413 | }; | 412 | }; |
414 | 413 | ||
415 | struct hid_driver; | 414 | struct hid_driver; |
416 | struct hid_ll_driver; | 415 | struct hid_ll_driver; |
417 | 416 | ||
418 | struct hid_device { /* device report descriptor */ | 417 | struct hid_device { /* device report descriptor */ |
419 | __u8 *rdesc; | 418 | __u8 *rdesc; |
420 | unsigned rsize; | 419 | unsigned rsize; |
421 | struct hid_collection *collection; /* List of HID collections */ | 420 | struct hid_collection *collection; /* List of HID collections */ |
422 | unsigned collection_size; /* Number of allocated hid_collections */ | 421 | unsigned collection_size; /* Number of allocated hid_collections */ |
423 | unsigned maxcollection; /* Number of parsed collections */ | 422 | unsigned maxcollection; /* Number of parsed collections */ |
424 | unsigned maxapplication; /* Number of applications */ | 423 | unsigned maxapplication; /* Number of applications */ |
425 | __u16 bus; /* BUS ID */ | 424 | __u16 bus; /* BUS ID */ |
426 | __u32 vendor; /* Vendor ID */ | 425 | __u32 vendor; /* Vendor ID */ |
427 | __u32 product; /* Product ID */ | 426 | __u32 product; /* Product ID */ |
428 | __u32 version; /* HID version */ | 427 | __u32 version; /* HID version */ |
429 | unsigned country; /* HID country */ | 428 | unsigned country; /* HID country */ |
430 | struct hid_report_enum report_enum[HID_REPORT_TYPES]; | 429 | struct hid_report_enum report_enum[HID_REPORT_TYPES]; |
431 | 430 | ||
432 | struct device dev; /* device */ | 431 | struct device dev; /* device */ |
433 | struct hid_driver *driver; | 432 | struct hid_driver *driver; |
434 | struct hid_ll_driver *ll_driver; | 433 | struct hid_ll_driver *ll_driver; |
435 | 434 | ||
436 | unsigned int status; /* see STAT flags above */ | 435 | unsigned int status; /* see STAT flags above */ |
437 | unsigned claimed; /* Claimed by hidinput, hiddev? */ | 436 | unsigned claimed; /* Claimed by hidinput, hiddev? */ |
438 | unsigned quirks; /* Various quirks the device can pull on us */ | 437 | unsigned quirks; /* Various quirks the device can pull on us */ |
439 | 438 | ||
440 | struct list_head inputs; /* The list of inputs */ | 439 | struct list_head inputs; /* The list of inputs */ |
441 | void *hiddev; /* The hiddev structure */ | 440 | void *hiddev; /* The hiddev structure */ |
442 | void *hidraw; | 441 | void *hidraw; |
443 | int minor; /* Hiddev minor number */ | 442 | int minor; /* Hiddev minor number */ |
444 | 443 | ||
445 | int open; /* is the device open by anyone? */ | 444 | int open; /* is the device open by anyone? */ |
446 | char name[128]; /* Device name */ | 445 | char name[128]; /* Device name */ |
447 | char phys[64]; /* Device physical location */ | 446 | char phys[64]; /* Device physical location */ |
448 | char uniq[64]; /* Device unique identifier (serial #) */ | 447 | char uniq[64]; /* Device unique identifier (serial #) */ |
449 | 448 | ||
450 | void *driver_data; | 449 | void *driver_data; |
451 | 450 | ||
452 | /* hiddev event handler */ | 451 | /* hiddev event handler */ |
453 | void (*hiddev_hid_event) (struct hid_device *, struct hid_field *field, | 452 | void (*hiddev_hid_event) (struct hid_device *, struct hid_field *field, |
454 | struct hid_usage *, __s32); | 453 | struct hid_usage *, __s32); |
455 | void (*hiddev_report_event) (struct hid_device *, struct hid_report *); | 454 | void (*hiddev_report_event) (struct hid_device *, struct hid_report *); |
456 | 455 | ||
457 | /* handler for raw output data, used by hidraw */ | 456 | /* handler for raw output data, used by hidraw */ |
458 | int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t); | 457 | int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t); |
459 | }; | 458 | }; |
460 | 459 | ||
461 | static inline void *hid_get_drvdata(struct hid_device *hdev) | 460 | static inline void *hid_get_drvdata(struct hid_device *hdev) |
462 | { | 461 | { |
463 | return dev_get_drvdata(&hdev->dev); | 462 | return dev_get_drvdata(&hdev->dev); |
464 | } | 463 | } |
465 | 464 | ||
466 | static inline void hid_set_drvdata(struct hid_device *hdev, void *data) | 465 | static inline void hid_set_drvdata(struct hid_device *hdev, void *data) |
467 | { | 466 | { |
468 | dev_set_drvdata(&hdev->dev, data); | 467 | dev_set_drvdata(&hdev->dev, data); |
469 | } | 468 | } |
470 | 469 | ||
471 | #define HID_GLOBAL_STACK_SIZE 4 | 470 | #define HID_GLOBAL_STACK_SIZE 4 |
472 | #define HID_COLLECTION_STACK_SIZE 4 | 471 | #define HID_COLLECTION_STACK_SIZE 4 |
473 | 472 | ||
474 | struct hid_parser { | 473 | struct hid_parser { |
475 | struct hid_global global; | 474 | struct hid_global global; |
476 | struct hid_global global_stack[HID_GLOBAL_STACK_SIZE]; | 475 | struct hid_global global_stack[HID_GLOBAL_STACK_SIZE]; |
477 | unsigned global_stack_ptr; | 476 | unsigned global_stack_ptr; |
478 | struct hid_local local; | 477 | struct hid_local local; |
479 | unsigned collection_stack[HID_COLLECTION_STACK_SIZE]; | 478 | unsigned collection_stack[HID_COLLECTION_STACK_SIZE]; |
480 | unsigned collection_stack_ptr; | 479 | unsigned collection_stack_ptr; |
481 | struct hid_device *device; | 480 | struct hid_device *device; |
482 | }; | 481 | }; |
483 | 482 | ||
484 | struct hid_class_descriptor { | 483 | struct hid_class_descriptor { |
485 | __u8 bDescriptorType; | 484 | __u8 bDescriptorType; |
486 | __le16 wDescriptorLength; | 485 | __le16 wDescriptorLength; |
487 | } __attribute__ ((packed)); | 486 | } __attribute__ ((packed)); |
488 | 487 | ||
489 | struct hid_descriptor { | 488 | struct hid_descriptor { |
490 | __u8 bLength; | 489 | __u8 bLength; |
491 | __u8 bDescriptorType; | 490 | __u8 bDescriptorType; |
492 | __le16 bcdHID; | 491 | __le16 bcdHID; |
493 | __u8 bCountryCode; | 492 | __u8 bCountryCode; |
494 | __u8 bNumDescriptors; | 493 | __u8 bNumDescriptors; |
495 | 494 | ||
496 | struct hid_class_descriptor desc[1]; | 495 | struct hid_class_descriptor desc[1]; |
497 | } __attribute__ ((packed)); | 496 | } __attribute__ ((packed)); |
498 | 497 | ||
499 | #define HID_DEVICE(b, ven, prod) \ | 498 | #define HID_DEVICE(b, ven, prod) \ |
500 | .bus = (b), \ | 499 | .bus = (b), \ |
501 | .vendor = (ven), .product = (prod) | 500 | .vendor = (ven), .product = (prod) |
502 | 501 | ||
503 | #define HID_USB_DEVICE(ven, prod) HID_DEVICE(BUS_USB, ven, prod) | 502 | #define HID_USB_DEVICE(ven, prod) HID_DEVICE(BUS_USB, ven, prod) |
504 | #define HID_BLUETOOTH_DEVICE(ven, prod) HID_DEVICE(BUS_BLUETOOTH, ven, prod) | 503 | #define HID_BLUETOOTH_DEVICE(ven, prod) HID_DEVICE(BUS_BLUETOOTH, ven, prod) |
505 | 504 | ||
506 | #define HID_REPORT_ID(rep) \ | 505 | #define HID_REPORT_ID(rep) \ |
507 | .report_type = (rep) | 506 | .report_type = (rep) |
508 | #define HID_USAGE_ID(uhid, utype, ucode) \ | 507 | #define HID_USAGE_ID(uhid, utype, ucode) \ |
509 | .usage_hid = (uhid), .usage_type = (utype), .usage_code = (ucode) | 508 | .usage_hid = (uhid), .usage_type = (utype), .usage_code = (ucode) |
510 | /* we don't want to catch types and codes equal to 0 */ | 509 | /* we don't want to catch types and codes equal to 0 */ |
511 | #define HID_TERMINATOR (HID_ANY_ID - 1) | 510 | #define HID_TERMINATOR (HID_ANY_ID - 1) |
512 | 511 | ||
513 | struct hid_report_id { | 512 | struct hid_report_id { |
514 | __u32 report_type; | 513 | __u32 report_type; |
515 | }; | 514 | }; |
516 | struct hid_usage_id { | 515 | struct hid_usage_id { |
517 | __u32 usage_hid; | 516 | __u32 usage_hid; |
518 | __u32 usage_type; | 517 | __u32 usage_type; |
519 | __u32 usage_code; | 518 | __u32 usage_code; |
520 | }; | 519 | }; |
521 | 520 | ||
522 | /** | 521 | /** |
523 | * struct hid_driver | 522 | * struct hid_driver |
524 | * @name: driver name (e.g. "Footech_bar-wheel") | 523 | * @name: driver name (e.g. "Footech_bar-wheel") |
525 | * @id_table: which devices is this driver for (must be non-NULL for probe | 524 | * @id_table: which devices is this driver for (must be non-NULL for probe |
526 | * to be called) | 525 | * to be called) |
527 | * @probe: new device inserted | 526 | * @probe: new device inserted |
528 | * @remove: device removed (NULL if not a hot-plug capable driver) | 527 | * @remove: device removed (NULL if not a hot-plug capable driver) |
529 | * @report_table: on which reports to call raw_event (NULL means all) | 528 | * @report_table: on which reports to call raw_event (NULL means all) |
530 | * @raw_event: if report in report_table, this hook is called (NULL means nop) | 529 | * @raw_event: if report in report_table, this hook is called (NULL means nop) |
531 | * @usage_table: on which events to call event (NULL means all) | 530 | * @usage_table: on which events to call event (NULL means all) |
532 | * @event: if usage in usage_table, this hook is called (NULL means nop) | 531 | * @event: if usage in usage_table, this hook is called (NULL means nop) |
533 | * @report_fixup: called before report descriptor parsing (NULL means nop) | 532 | * @report_fixup: called before report descriptor parsing (NULL means nop) |
534 | * @input_mapping: invoked on input registering before mapping an usage | 533 | * @input_mapping: invoked on input registering before mapping an usage |
535 | * @input_mapped: invoked on input registering after mapping an usage | 534 | * @input_mapped: invoked on input registering after mapping an usage |
536 | * | 535 | * |
537 | * raw_event and event should return 0 on no action performed, 1 when no | 536 | * raw_event and event should return 0 on no action performed, 1 when no |
538 | * further processing should be done and negative on error | 537 | * further processing should be done and negative on error |
539 | * | 538 | * |
540 | * input_mapping shall return a negative value to completely ignore this usage | 539 | * input_mapping shall return a negative value to completely ignore this usage |
541 | * (e.g. doubled or invalid usage), zero to continue with parsing of this | 540 | * (e.g. doubled or invalid usage), zero to continue with parsing of this |
542 | * usage by generic code (no special handling needed) or positive to skip | 541 | * usage by generic code (no special handling needed) or positive to skip |
543 | * generic parsing (needed special handling which was done in the hook already) | 542 | * generic parsing (needed special handling which was done in the hook already) |
544 | * input_mapped shall return negative to inform the layer that this usage | 543 | * input_mapped shall return negative to inform the layer that this usage |
545 | * should not be considered for further processing or zero to notify that | 544 | * should not be considered for further processing or zero to notify that |
546 | * no processing was performed and should be done in a generic manner | 545 | * no processing was performed and should be done in a generic manner |
547 | * Both these functions may be NULL which means the same behavior as returning | 546 | * Both these functions may be NULL which means the same behavior as returning |
548 | * zero from them. | 547 | * zero from them. |
549 | */ | 548 | */ |
550 | struct hid_driver { | 549 | struct hid_driver { |
551 | char *name; | 550 | char *name; |
552 | const struct hid_device_id *id_table; | 551 | const struct hid_device_id *id_table; |
553 | 552 | ||
554 | int (*probe)(struct hid_device *dev, const struct hid_device_id *id); | 553 | int (*probe)(struct hid_device *dev, const struct hid_device_id *id); |
555 | void (*remove)(struct hid_device *dev); | 554 | void (*remove)(struct hid_device *dev); |
556 | 555 | ||
557 | const struct hid_report_id *report_table; | 556 | const struct hid_report_id *report_table; |
558 | int (*raw_event)(struct hid_device *hdev, struct hid_report *report, | 557 | int (*raw_event)(struct hid_device *hdev, struct hid_report *report, |
559 | u8 *data, int size); | 558 | u8 *data, int size); |
560 | const struct hid_usage_id *usage_table; | 559 | const struct hid_usage_id *usage_table; |
561 | int (*event)(struct hid_device *hdev, struct hid_field *field, | 560 | int (*event)(struct hid_device *hdev, struct hid_field *field, |
562 | struct hid_usage *usage, __s32 value); | 561 | struct hid_usage *usage, __s32 value); |
563 | 562 | ||
564 | void (*report_fixup)(struct hid_device *hdev, __u8 *buf, | 563 | void (*report_fixup)(struct hid_device *hdev, __u8 *buf, |
565 | unsigned int size); | 564 | unsigned int size); |
566 | 565 | ||
567 | int (*input_mapping)(struct hid_device *hdev, | 566 | int (*input_mapping)(struct hid_device *hdev, |
568 | struct hid_input *hidinput, struct hid_field *field, | 567 | struct hid_input *hidinput, struct hid_field *field, |
569 | struct hid_usage *usage, unsigned long **bit, int *max); | 568 | struct hid_usage *usage, unsigned long **bit, int *max); |
570 | int (*input_mapped)(struct hid_device *hdev, | 569 | int (*input_mapped)(struct hid_device *hdev, |
571 | struct hid_input *hidinput, struct hid_field *field, | 570 | struct hid_input *hidinput, struct hid_field *field, |
572 | struct hid_usage *usage, unsigned long **bit, int *max); | 571 | struct hid_usage *usage, unsigned long **bit, int *max); |
573 | /* private: */ | 572 | /* private: */ |
574 | struct device_driver driver; | 573 | struct device_driver driver; |
575 | }; | 574 | }; |
576 | 575 | ||
577 | /** | 576 | /** |
578 | * hid_ll_driver - low level driver callbacks | 577 | * hid_ll_driver - low level driver callbacks |
579 | * @start: called on probe to start the device | 578 | * @start: called on probe to start the device |
580 | * @stop: called on remove | 579 | * @stop: called on remove |
581 | * @open: called by input layer on open | 580 | * @open: called by input layer on open |
582 | * @close: called by input layer on close | 581 | * @close: called by input layer on close |
583 | * @hidinput_input_event: event input event (e.g. ff or leds) | 582 | * @hidinput_input_event: event input event (e.g. ff or leds) |
584 | * @parse: this method is called only once to parse the device data, | 583 | * @parse: this method is called only once to parse the device data, |
585 | * shouldn't allocate anything to not leak memory | 584 | * shouldn't allocate anything to not leak memory |
586 | */ | 585 | */ |
587 | struct hid_ll_driver { | 586 | struct hid_ll_driver { |
588 | int (*start)(struct hid_device *hdev); | 587 | int (*start)(struct hid_device *hdev); |
589 | void (*stop)(struct hid_device *hdev); | 588 | void (*stop)(struct hid_device *hdev); |
590 | 589 | ||
591 | int (*open)(struct hid_device *hdev); | 590 | int (*open)(struct hid_device *hdev); |
592 | void (*close)(struct hid_device *hdev); | 591 | void (*close)(struct hid_device *hdev); |
593 | 592 | ||
594 | int (*hidinput_input_event) (struct input_dev *idev, unsigned int type, | 593 | int (*hidinput_input_event) (struct input_dev *idev, unsigned int type, |
595 | unsigned int code, int value); | 594 | unsigned int code, int value); |
596 | 595 | ||
597 | int (*parse)(struct hid_device *hdev); | 596 | int (*parse)(struct hid_device *hdev); |
598 | }; | 597 | }; |
599 | 598 | ||
600 | /* Applications from HID Usage Tables 4/8/99 Version 1.1 */ | 599 | /* Applications from HID Usage Tables 4/8/99 Version 1.1 */ |
601 | /* We ignore a few input applications that are not widely used */ | 600 | /* We ignore a few input applications that are not widely used */ |
602 | #define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001) || (a == 0x000d0002)) | 601 | #define IS_INPUT_APPLICATION(a) (((a >= 0x00010000) && (a <= 0x00010008)) || (a == 0x00010080) || (a == 0x000c0001) || (a == 0x000d0002)) |
603 | 602 | ||
604 | /* HID core API */ | 603 | /* HID core API */ |
605 | 604 | ||
606 | #ifdef CONFIG_HID_DEBUG | 605 | #ifdef CONFIG_HID_DEBUG |
607 | extern int hid_debug; | 606 | extern int hid_debug; |
608 | #endif | 607 | #endif |
609 | 608 | ||
610 | extern int hid_add_device(struct hid_device *); | 609 | extern int hid_add_device(struct hid_device *); |
611 | extern void hid_destroy_device(struct hid_device *); | 610 | extern void hid_destroy_device(struct hid_device *); |
612 | 611 | ||
613 | extern int __must_check __hid_register_driver(struct hid_driver *, | 612 | extern int __must_check __hid_register_driver(struct hid_driver *, |
614 | struct module *, const char *mod_name); | 613 | struct module *, const char *mod_name); |
615 | static inline int __must_check hid_register_driver(struct hid_driver *driver) | 614 | static inline int __must_check hid_register_driver(struct hid_driver *driver) |
616 | { | 615 | { |
617 | return __hid_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); | 616 | return __hid_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); |
618 | } | 617 | } |
619 | extern void hid_unregister_driver(struct hid_driver *); | 618 | extern void hid_unregister_driver(struct hid_driver *); |
620 | 619 | ||
621 | extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); | 620 | extern void hidinput_hid_event(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); |
622 | extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); | 621 | extern void hidinput_report_event(struct hid_device *hid, struct hid_report *report); |
623 | extern int hidinput_connect(struct hid_device *); | 622 | extern int hidinput_connect(struct hid_device *); |
624 | extern void hidinput_disconnect(struct hid_device *); | 623 | extern void hidinput_disconnect(struct hid_device *); |
625 | 624 | ||
626 | int hid_set_field(struct hid_field *, unsigned, __s32); | 625 | int hid_set_field(struct hid_field *, unsigned, __s32); |
627 | int hid_input_report(struct hid_device *, int type, u8 *, int, int); | 626 | int hid_input_report(struct hid_device *, int type, u8 *, int, int); |
628 | int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); | 627 | int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); |
629 | int hidinput_mapping_quirks(struct hid_usage *, struct hid_input *, | 628 | int hidinput_mapping_quirks(struct hid_usage *, struct hid_input *, |
630 | unsigned long **, int *); | 629 | unsigned long **, int *); |
631 | int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); | 630 | int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); |
632 | void hid_output_report(struct hid_report *report, __u8 *data); | 631 | void hid_output_report(struct hid_report *report, __u8 *data); |
633 | struct hid_device *hid_allocate_device(void); | 632 | struct hid_device *hid_allocate_device(void); |
634 | int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size); | 633 | int hid_parse_report(struct hid_device *hid, __u8 *start, unsigned size); |
635 | 634 | ||
636 | /** | 635 | /** |
637 | * hid_map_usage - map usage input bits | 636 | * hid_map_usage - map usage input bits |
638 | * | 637 | * |
639 | * @hidinput: hidinput which we are interested in | 638 | * @hidinput: hidinput which we are interested in |
640 | * @usage: usage to fill in | 639 | * @usage: usage to fill in |
641 | * @bit: pointer to input->{}bit (out parameter) | 640 | * @bit: pointer to input->{}bit (out parameter) |
642 | * @max: maximal valid usage->code to consider later (out parameter) | 641 | * @max: maximal valid usage->code to consider later (out parameter) |
643 | * @type: input event type (EV_KEY, EV_REL, ...) | 642 | * @type: input event type (EV_KEY, EV_REL, ...) |
644 | * @c: code which corresponds to this usage and type | 643 | * @c: code which corresponds to this usage and type |
645 | */ | 644 | */ |
646 | static inline void hid_map_usage(struct hid_input *hidinput, | 645 | static inline void hid_map_usage(struct hid_input *hidinput, |
647 | struct hid_usage *usage, unsigned long **bit, int *max, | 646 | struct hid_usage *usage, unsigned long **bit, int *max, |
648 | __u8 type, __u16 c) | 647 | __u8 type, __u16 c) |
649 | { | 648 | { |
650 | struct input_dev *input = hidinput->input; | 649 | struct input_dev *input = hidinput->input; |
651 | 650 | ||
652 | usage->type = type; | 651 | usage->type = type; |
653 | usage->code = c; | 652 | usage->code = c; |
654 | 653 | ||
655 | switch (type) { | 654 | switch (type) { |
656 | case EV_ABS: | 655 | case EV_ABS: |
657 | *bit = input->absbit; | 656 | *bit = input->absbit; |
658 | *max = ABS_MAX; | 657 | *max = ABS_MAX; |
659 | break; | 658 | break; |
660 | case EV_REL: | 659 | case EV_REL: |
661 | *bit = input->relbit; | 660 | *bit = input->relbit; |
662 | *max = REL_MAX; | 661 | *max = REL_MAX; |
663 | break; | 662 | break; |
664 | case EV_KEY: | 663 | case EV_KEY: |
665 | *bit = input->keybit; | 664 | *bit = input->keybit; |
666 | *max = KEY_MAX; | 665 | *max = KEY_MAX; |
667 | break; | 666 | break; |
668 | case EV_LED: | 667 | case EV_LED: |
669 | *bit = input->ledbit; | 668 | *bit = input->ledbit; |
670 | *max = LED_MAX; | 669 | *max = LED_MAX; |
671 | break; | 670 | break; |
672 | } | 671 | } |
673 | } | 672 | } |
674 | 673 | ||
675 | /** | 674 | /** |
676 | * hid_map_usage_clear - map usage input bits and clear the input bit | 675 | * hid_map_usage_clear - map usage input bits and clear the input bit |
677 | * | 676 | * |
678 | * The same as hid_map_usage, except the @c bit is also cleared in supported | 677 | * The same as hid_map_usage, except the @c bit is also cleared in supported |
679 | * bits (@bit). | 678 | * bits (@bit). |
680 | */ | 679 | */ |
681 | static inline void hid_map_usage_clear(struct hid_input *hidinput, | 680 | static inline void hid_map_usage_clear(struct hid_input *hidinput, |
682 | struct hid_usage *usage, unsigned long **bit, int *max, | 681 | struct hid_usage *usage, unsigned long **bit, int *max, |
683 | __u8 type, __u16 c) | 682 | __u8 type, __u16 c) |
684 | { | 683 | { |
685 | hid_map_usage(hidinput, usage, bit, max, type, c); | 684 | hid_map_usage(hidinput, usage, bit, max, type, c); |
686 | clear_bit(c, *bit); | 685 | clear_bit(c, *bit); |
687 | } | 686 | } |
688 | 687 | ||
689 | /** | 688 | /** |
690 | * hid_parse - parse HW reports | 689 | * hid_parse - parse HW reports |
691 | * | 690 | * |
692 | * @hdev: hid device | 691 | * @hdev: hid device |
693 | * | 692 | * |
694 | * Call this from probe after you set up the device (if needed). Your | 693 | * Call this from probe after you set up the device (if needed). Your |
695 | * report_fixup will be called (if non-NULL) after reading raw report from | 694 | * report_fixup will be called (if non-NULL) after reading raw report from |
696 | * device before passing it to hid layer for real parsing. | 695 | * device before passing it to hid layer for real parsing. |
697 | */ | 696 | */ |
698 | static inline int __must_check hid_parse(struct hid_device *hdev) | 697 | static inline int __must_check hid_parse(struct hid_device *hdev) |
699 | { | 698 | { |
700 | int ret; | 699 | int ret; |
701 | 700 | ||
702 | if (hdev->status & HID_STAT_PARSED) | 701 | if (hdev->status & HID_STAT_PARSED) |
703 | return 0; | 702 | return 0; |
704 | 703 | ||
705 | ret = hdev->ll_driver->parse(hdev); | 704 | ret = hdev->ll_driver->parse(hdev); |
706 | if (!ret) | 705 | if (!ret) |
707 | hdev->status |= HID_STAT_PARSED; | 706 | hdev->status |= HID_STAT_PARSED; |
708 | 707 | ||
709 | return ret; | 708 | return ret; |
710 | } | 709 | } |
711 | 710 | ||
712 | /** | 711 | /** |
713 | * hid_hw_start - start underlaying HW | 712 | * hid_hw_start - start underlaying HW |
714 | * | 713 | * |
715 | * @hdev: hid device | 714 | * @hdev: hid device |
716 | * | 715 | * |
717 | * Call this in probe function *after* hid_parse. This will setup HW buffers | 716 | * Call this in probe function *after* hid_parse. This will setup HW buffers |
718 | * and start the device (if not deffered to device open). hid_hw_stop must be | 717 | * and start the device (if not deffered to device open). hid_hw_stop must be |
719 | * called if this was successfull. | 718 | * called if this was successfull. |
720 | */ | 719 | */ |
721 | static inline int __must_check hid_hw_start(struct hid_device *hdev) | 720 | static inline int __must_check hid_hw_start(struct hid_device *hdev) |
722 | { | 721 | { |
723 | return hdev->ll_driver->start(hdev); | 722 | return hdev->ll_driver->start(hdev); |
724 | } | 723 | } |
725 | 724 | ||
726 | /** | 725 | /** |
727 | * hid_hw_stop - stop underlaying HW | 726 | * hid_hw_stop - stop underlaying HW |
728 | * | 727 | * |
729 | * @hdev: hid device | 728 | * @hdev: hid device |
730 | * | 729 | * |
731 | * This is usually called from remove function or from probe when something | 730 | * This is usually called from remove function or from probe when something |
732 | * failed and hid_hw_start was called already. | 731 | * failed and hid_hw_start was called already. |
733 | */ | 732 | */ |
734 | static inline void hid_hw_stop(struct hid_device *hdev) | 733 | static inline void hid_hw_stop(struct hid_device *hdev) |
735 | { | 734 | { |
736 | hdev->ll_driver->stop(hdev); | 735 | hdev->ll_driver->stop(hdev); |
737 | } | 736 | } |
738 | 737 | ||
739 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, | 738 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
740 | int interrupt); | 739 | int interrupt); |
741 | 740 | ||
742 | extern int hid_generic_init(void); | 741 | extern int hid_generic_init(void); |
743 | extern void hid_generic_exit(void); | 742 | extern void hid_generic_exit(void); |
744 | 743 | ||
745 | /* HID quirks API */ | 744 | /* HID quirks API */ |
746 | u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct); | 745 | u32 usbhid_lookup_quirk(const u16 idVendor, const u16 idProduct); |
747 | int usbhid_quirks_init(char **quirks_param); | 746 | int usbhid_quirks_init(char **quirks_param); |
748 | void usbhid_quirks_exit(void); | 747 | void usbhid_quirks_exit(void); |
749 | void usbhid_fixup_report_descriptor(const u16, const u16, char *, unsigned, char **); | 748 | void usbhid_fixup_report_descriptor(const u16, const u16, char *, unsigned, char **); |
750 | 749 | ||
751 | #ifdef CONFIG_HID_FF | 750 | #ifdef CONFIG_HID_FF |
752 | int hid_ff_init(struct hid_device *hid); | 751 | int hid_ff_init(struct hid_device *hid); |
753 | 752 | ||
754 | int hid_lgff_init(struct hid_device *hid); | 753 | int hid_lgff_init(struct hid_device *hid); |
755 | int hid_lg2ff_init(struct hid_device *hid); | 754 | int hid_lg2ff_init(struct hid_device *hid); |
756 | int hid_plff_init(struct hid_device *hid); | 755 | int hid_plff_init(struct hid_device *hid); |
757 | int hid_tmff_init(struct hid_device *hid); | 756 | int hid_tmff_init(struct hid_device *hid); |
758 | int hid_zpff_init(struct hid_device *hid); | 757 | int hid_zpff_init(struct hid_device *hid); |
759 | #ifdef CONFIG_HID_PID | 758 | #ifdef CONFIG_HID_PID |
760 | int hid_pidff_init(struct hid_device *hid); | 759 | int hid_pidff_init(struct hid_device *hid); |
761 | #else | 760 | #else |
762 | static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; } | 761 | static inline int hid_pidff_init(struct hid_device *hid) { return -ENODEV; } |
763 | #endif | 762 | #endif |
764 | 763 | ||
765 | #else | 764 | #else |
766 | static inline int hid_ff_init(struct hid_device *hid) { return -1; } | 765 | static inline int hid_ff_init(struct hid_device *hid) { return -1; } |
767 | #endif | 766 | #endif |
768 | 767 | ||
769 | #ifdef CONFIG_HID_DEBUG | 768 | #ifdef CONFIG_HID_DEBUG |
770 | #define dbg_hid(format, arg...) if (hid_debug) \ | 769 | #define dbg_hid(format, arg...) if (hid_debug) \ |
771 | printk(KERN_DEBUG "%s: " format ,\ | 770 | printk(KERN_DEBUG "%s: " format ,\ |
772 | __FILE__ , ## arg) | 771 | __FILE__ , ## arg) |
773 | #define dbg_hid_line(format, arg...) if (hid_debug) \ | 772 | #define dbg_hid_line(format, arg...) if (hid_debug) \ |
774 | printk(format, ## arg) | 773 | printk(format, ## arg) |
775 | #else | 774 | #else |
776 | static inline int __attribute__((format(printf, 1, 2))) | 775 | static inline int __attribute__((format(printf, 1, 2))) |
777 | dbg_hid(const char *fmt, ...) | 776 | dbg_hid(const char *fmt, ...) |
778 | { | 777 | { |
779 | return 0; | 778 | return 0; |
780 | } | 779 | } |
781 | #define dbg_hid_line dbg_hid | 780 | #define dbg_hid_line dbg_hid |
782 | #endif /* HID_DEBUG */ | 781 | #endif /* HID_DEBUG */ |
783 | 782 | ||
784 | #define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ | 783 | #define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ |
785 | __FILE__ , ## arg) | 784 | __FILE__ , ## arg) |
786 | #endif /* HID_FF */ | 785 | #endif /* HID_FF */ |
787 | 786 | ||
788 | #ifdef CONFIG_HID_COMPAT | 787 | #ifdef CONFIG_HID_COMPAT |
789 | #define HID_COMPAT_LOAD_DRIVER(name) \ | 788 | #define HID_COMPAT_LOAD_DRIVER(name) \ |
790 | void hid_compat_##name(void) { } \ | 789 | void hid_compat_##name(void) { } \ |
791 | EXPORT_SYMBOL(hid_compat_##name) | 790 | EXPORT_SYMBOL(hid_compat_##name) |
792 | #else | 791 | #else |
793 | #define HID_COMPAT_LOAD_DRIVER(name) | 792 | #define HID_COMPAT_LOAD_DRIVER(name) |
794 | #endif /* HID_COMPAT */ | 793 | #endif /* HID_COMPAT */ |
795 | #define HID_COMPAT_CALL_DRIVER(name) do { \ | 794 | #define HID_COMPAT_CALL_DRIVER(name) do { \ |
796 | extern void hid_compat_##name(void); \ | 795 | extern void hid_compat_##name(void); \ |
797 | hid_compat_##name(); \ | 796 | hid_compat_##name(); \ |
798 | } while (0) | 797 | } while (0) |
799 | 798 | ||
800 | #endif | 799 | #endif |
801 | 800 | ||
802 | 801 |