Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 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 |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 8 | * Copyright (c) 2008 Jiri Slaby |
| 9 | */ |
| 10 | |
| 11 | /* |
| 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 |
| 14 | * Software Foundation; either version 2 of the License, or (at your option) |
| 15 | * any later version. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/device.h> |
| 19 | #include <linux/hid.h> |
| 20 | #include <linux/module.h> |
| 21 | |
| 22 | #include "hid-ids.h" |
| 23 | |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 24 | static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 25 | unsigned int *rsize) |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 26 | { |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 27 | if (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 && |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 28 | rdesc[106] == 0x03) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 29 | hid_info(hdev, "fixing up Sunplus Wireless Desktop report descriptor\n"); |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 30 | rdesc[105] = rdesc[110] = 0x03; |
| 31 | rdesc[106] = rdesc[111] = 0x21; |
| 32 | } |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 33 | return rdesc; |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | #define sp_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ |
| 37 | EV_KEY, (c)) |
| 38 | static int sp_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 39 | struct hid_field *field, struct hid_usage *usage, |
| 40 | unsigned long **bit, int *max) |
| 41 | { |
| 42 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) |
| 43 | return 0; |
| 44 | |
| 45 | switch (usage->hid & HID_USAGE) { |
| 46 | case 0x2003: sp_map_key_clear(KEY_ZOOMIN); break; |
| 47 | case 0x2103: sp_map_key_clear(KEY_ZOOMOUT); break; |
| 48 | default: |
| 49 | return 0; |
| 50 | } |
| 51 | return 1; |
| 52 | } |
| 53 | |
| 54 | static const struct hid_device_id sp_devices[] = { |
| 55 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, |
| 56 | { } |
| 57 | }; |
| 58 | MODULE_DEVICE_TABLE(hid, sp_devices); |
| 59 | |
| 60 | static struct hid_driver sp_driver = { |
| 61 | .name = "sunplus", |
| 62 | .id_table = sp_devices, |
| 63 | .report_fixup = sp_report_fixup, |
| 64 | .input_mapping = sp_input_mapping, |
| 65 | }; |
| 66 | |
Peter Huewe | a24f423 | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 67 | static int __init sp_init(void) |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 68 | { |
| 69 | return hid_register_driver(&sp_driver); |
| 70 | } |
| 71 | |
Peter Huewe | a24f423 | 2009-07-02 19:08:38 +0200 | [diff] [blame] | 72 | static void __exit sp_exit(void) |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 73 | { |
| 74 | hid_unregister_driver(&sp_driver); |
| 75 | } |
| 76 | |
| 77 | module_init(sp_init); |
| 78 | module_exit(sp_exit); |
| 79 | MODULE_LICENSE("GPL"); |