diff options
-rw-r--r-- | drivers/hid/Kconfig | 8 | ||||
-rw-r--r-- | drivers/hid/Makefile | 1 | ||||
-rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 3 | ||||
-rw-r--r-- | drivers/hid/hid-primax.c | 117 |
5 files changed, 130 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 306b15f39c9c..121eed528496 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -441,6 +441,14 @@ config HID_PICOLCD_LEDS | |||
441 | ---help--- | 441 | ---help--- |
442 | Provide access to PicoLCD's GPO pins via leds class. | 442 | Provide access to PicoLCD's GPO pins via leds class. |
443 | 443 | ||
444 | config HID_PRIMAX | ||
445 | tristate "Primax non-fully HID-compliant devices" if EXPERT | ||
446 | depends on USB_HID | ||
447 | default !EXPERT | ||
448 | ---help--- | ||
449 | Support for Primax devices that are not fully compliant with the | ||
450 | HID standard. | ||
451 | |||
444 | config HID_QUANTA | 452 | config HID_QUANTA |
445 | tristate "Quanta Optical Touch panels" | 453 | tristate "Quanta Optical Touch panels" |
446 | depends on USB_HID | 454 | depends on USB_HID |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 0a0a38e9fd28..735b8cce2c88 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -54,6 +54,7 @@ obj-$(CONFIG_HID_QUANTA) += hid-quanta.o | |||
54 | obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o | 54 | obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o |
55 | obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o | 55 | obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o |
56 | obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o | 56 | obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o |
57 | obj-$(CONFIG_HID_PRIMAX) += hid-primax.o | ||
57 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o | 58 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o |
58 | obj-$(CONFIG_HID_ROCCAT_COMMON) += hid-roccat-common.o | 59 | obj-$(CONFIG_HID_ROCCAT_COMMON) += hid-roccat-common.o |
59 | obj-$(CONFIG_HID_ROCCAT_ARVO) += hid-roccat-arvo.o | 60 | obj-$(CONFIG_HID_ROCCAT_ARVO) += hid-roccat-arvo.o |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index d5dae955cc42..df693e7ccc9e 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1480,6 +1480,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1480 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, | 1480 | { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, |
1481 | { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) }, | 1481 | { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_PCI) }, |
1482 | { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, | 1482 | { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, |
1483 | { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, | ||
1483 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, | 1484 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, |
1484 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, | 1485 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, |
1485 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, | 1486 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index aa7419350603..fa7579b6b06f 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -692,4 +692,7 @@ | |||
692 | #define USB_VENDOR_ID_ZYDACRON 0x13EC | 692 | #define USB_VENDOR_ID_ZYDACRON 0x13EC |
693 | #define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006 | 693 | #define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006 |
694 | 694 | ||
695 | #define USB_VENDOR_ID_PRIMAX 0x0461 | ||
696 | #define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05 | ||
697 | |||
695 | #endif | 698 | #endif |
diff --git a/drivers/hid/hid-primax.c b/drivers/hid/hid-primax.c new file mode 100644 index 000000000000..4d3c60d88318 --- /dev/null +++ b/drivers/hid/hid-primax.c | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * HID driver for primax and similar keyboards with in-band modifiers | ||
3 | * | ||
4 | * Copyright 2011 Google Inc. All Rights Reserved | ||
5 | * | ||
6 | * Author: | ||
7 | * Terry Lambert <tlambert@google.com> | ||
8 | * | ||
9 | * This software is licensed under the terms of the GNU General Public | ||
10 | * License version 2, as published by the Free Software Foundation, and | ||
11 | * may be copied, distributed, and modified under those terms. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | */ | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | #include <linux/hid.h> | ||
21 | #include <linux/module.h> | ||
22 | |||
23 | #include "hid-ids.h" | ||
24 | |||
25 | static int px_raw_event(struct hid_device *hid, struct hid_report *report, | ||
26 | u8 *data, int size) | ||
27 | { | ||
28 | int idx = size; | ||
29 | |||
30 | switch (report->id) { | ||
31 | case 0: /* keyboard input */ | ||
32 | /* | ||
33 | * Convert in-band modifier key values into out of band | ||
34 | * modifier bits and pull the key strokes from the report. | ||
35 | * Thus a report data set which looked like: | ||
36 | * | ||
37 | * [00][00][E0][30][00][00][00][00] | ||
38 | * (no modifier bits + "Left Shift" key + "1" key) | ||
39 | * | ||
40 | * Would be converted to: | ||
41 | * | ||
42 | * [01][00][00][30][00][00][00][00] | ||
43 | * (Left Shift modifier bit + "1" key) | ||
44 | * | ||
45 | * As long as it's in the size range, the upper level | ||
46 | * drivers don't particularly care if there are in-band | ||
47 | * 0-valued keys, so they don't stop parsing. | ||
48 | */ | ||
49 | while (--idx > 1) { | ||
50 | if (data[idx] < 0xE0 || data[idx] > 0xE7) | ||
51 | continue; | ||
52 | data[0] |= (1 << (data[idx] - 0xE0)); | ||
53 | data[idx] = 0; | ||
54 | } | ||
55 | hid_report_raw_event(hid, HID_INPUT_REPORT, data, size, 0); | ||
56 | return 1; | ||
57 | |||
58 | default: /* unknown report */ | ||
59 | /* Unknown report type; pass upstream */ | ||
60 | hid_info(hid, "unknown report type %d\n", report->id); | ||
61 | break; | ||
62 | } | ||
63 | |||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | static int px_probe(struct hid_device *hid, const struct hid_device_id *id) | ||
68 | { | ||
69 | int ret; | ||
70 | |||
71 | ret = hid_parse(hid); | ||
72 | if (ret) { | ||
73 | hid_err(hid, "parse failed\n"); | ||
74 | goto fail; | ||
75 | } | ||
76 | |||
77 | ret = hid_hw_start(hid, HID_CONNECT_DEFAULT); | ||
78 | if (ret) | ||
79 | hid_err(hid, "hw start failed\n"); | ||
80 | |||
81 | fail: | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | static void px_remove(struct hid_device *hid) | ||
86 | { | ||
87 | hid_hw_stop(hid); | ||
88 | } | ||
89 | |||
90 | static const struct hid_device_id px_devices[] = { | ||
91 | { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, | ||
92 | { } | ||
93 | }; | ||
94 | MODULE_DEVICE_TABLE(hid, px_devices); | ||
95 | |||
96 | static struct hid_driver px_driver = { | ||
97 | .name = "primax", | ||
98 | .id_table = px_devices, | ||
99 | .raw_event = px_raw_event, | ||
100 | .probe = px_probe, | ||
101 | .remove = px_remove, | ||
102 | }; | ||
103 | |||
104 | static int __init px_init(void) | ||
105 | { | ||
106 | return hid_register_driver(&px_driver); | ||
107 | } | ||
108 | |||
109 | static void __exit px_exit(void) | ||
110 | { | ||
111 | hid_unregister_driver(&px_driver); | ||
112 | } | ||
113 | |||
114 | module_init(px_init); | ||
115 | module_exit(px_exit); | ||
116 | MODULE_AUTHOR("Terry Lambert <tlambert@google.com>"); | ||
117 | MODULE_LICENSE("GPL"); | ||