diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2008-06-23 15:56:07 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2008-10-14 17:50:51 -0400 |
commit | 90231e7eaf752856a2c13f786f36ec7f641bad28 (patch) | |
tree | fd9056ecefeb52709c8ddca651428105552c2a84 /drivers/hid/hid-sunplus.c | |
parent | 78a849a682a1d5ee7b7187b08abdc48656326a4e (diff) |
HID: move sunplus quirks
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-sunplus.c')
-rw-r--r-- | drivers/hid/hid-sunplus.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/drivers/hid/hid-sunplus.c b/drivers/hid/hid-sunplus.c new file mode 100644 index 000000000000..5ba68f7dbb78 --- /dev/null +++ b/drivers/hid/hid-sunplus.c | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * HID driver for some sunplus "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/hid.h> | ||
21 | #include <linux/module.h> | ||
22 | |||
23 | #include "hid-ids.h" | ||
24 | |||
25 | static void sp_report_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
26 | unsigned int rsize) | ||
27 | { | ||
28 | if (rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 && | ||
29 | rdesc[106] == 0x03) { | ||
30 | dev_info(&hdev->dev, "fixing up Sunplus Wireless Desktop " | ||
31 | "report descriptor\n"); | ||
32 | rdesc[105] = rdesc[110] = 0x03; | ||
33 | rdesc[106] = rdesc[111] = 0x21; | ||
34 | } | ||
35 | } | ||
36 | |||
37 | #define sp_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ | ||
38 | EV_KEY, (c)) | ||
39 | static int sp_input_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
40 | struct hid_field *field, struct hid_usage *usage, | ||
41 | unsigned long **bit, int *max) | ||
42 | { | ||
43 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) | ||
44 | return 0; | ||
45 | |||
46 | switch (usage->hid & HID_USAGE) { | ||
47 | case 0x2003: sp_map_key_clear(KEY_ZOOMIN); break; | ||
48 | case 0x2103: sp_map_key_clear(KEY_ZOOMOUT); break; | ||
49 | default: | ||
50 | return 0; | ||
51 | } | ||
52 | return 1; | ||
53 | } | ||
54 | |||
55 | static const struct hid_device_id sp_devices[] = { | ||
56 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, | ||
57 | { } | ||
58 | }; | ||
59 | MODULE_DEVICE_TABLE(hid, sp_devices); | ||
60 | |||
61 | static struct hid_driver sp_driver = { | ||
62 | .name = "sunplus", | ||
63 | .id_table = sp_devices, | ||
64 | .report_fixup = sp_report_fixup, | ||
65 | .input_mapping = sp_input_mapping, | ||
66 | }; | ||
67 | |||
68 | static int sp_init(void) | ||
69 | { | ||
70 | return hid_register_driver(&sp_driver); | ||
71 | } | ||
72 | |||
73 | static void sp_exit(void) | ||
74 | { | ||
75 | hid_unregister_driver(&sp_driver); | ||
76 | } | ||
77 | |||
78 | module_init(sp_init); | ||
79 | module_exit(sp_exit); | ||
80 | MODULE_LICENSE("GPL"); | ||
81 | |||
82 | HID_COMPAT_LOAD_DRIVER(sunplus); | ||