Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 2 | /* |
| 3 | * HID driver for some sunplus "special" devices |
| 4 | * |
| 5 | * Copyright (c) 1999 Andreas Gal |
| 6 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
| 7 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
| 8 | * Copyright (c) 2006-2007 Jiri Kosina |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 9 | * Copyright (c) 2008 Jiri Slaby |
| 10 | */ |
| 11 | |
| 12 | /* |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <linux/device.h> |
| 16 | #include <linux/hid.h> |
| 17 | #include <linux/module.h> |
| 18 | |
| 19 | #include "hid-ids.h" |
| 20 | |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 21 | static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 22 | unsigned int *rsize) |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 23 | { |
Jiri Kosina | 4ab2578 | 2014-08-21 09:57:48 -0500 | [diff] [blame] | 24 | if (*rsize >= 112 && rdesc[104] == 0x26 && rdesc[105] == 0x80 && |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 25 | rdesc[106] == 0x03) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 26 | hid_info(hdev, "fixing up Sunplus Wireless Desktop report descriptor\n"); |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 27 | rdesc[105] = rdesc[110] = 0x03; |
| 28 | rdesc[106] = rdesc[111] = 0x21; |
| 29 | } |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 30 | return rdesc; |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | #define sp_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ |
| 34 | EV_KEY, (c)) |
| 35 | static int sp_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 36 | struct hid_field *field, struct hid_usage *usage, |
| 37 | unsigned long **bit, int *max) |
| 38 | { |
| 39 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) |
| 40 | return 0; |
| 41 | |
| 42 | switch (usage->hid & HID_USAGE) { |
| 43 | case 0x2003: sp_map_key_clear(KEY_ZOOMIN); break; |
| 44 | case 0x2103: sp_map_key_clear(KEY_ZOOMOUT); break; |
| 45 | default: |
| 46 | return 0; |
| 47 | } |
| 48 | return 1; |
| 49 | } |
| 50 | |
| 51 | static const struct hid_device_id sp_devices[] = { |
| 52 | { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, |
| 53 | { } |
| 54 | }; |
| 55 | MODULE_DEVICE_TABLE(hid, sp_devices); |
| 56 | |
| 57 | static struct hid_driver sp_driver = { |
| 58 | .name = "sunplus", |
| 59 | .id_table = sp_devices, |
| 60 | .report_fixup = sp_report_fixup, |
| 61 | .input_mapping = sp_input_mapping, |
| 62 | }; |
H Hartley Sweeten | f425458 | 2012-12-17 15:28:26 -0700 | [diff] [blame] | 63 | module_hid_driver(sp_driver); |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 64 | |
Jiri Slaby | 90231e7 | 2008-06-23 21:56:07 +0200 | [diff] [blame] | 65 | MODULE_LICENSE("GPL"); |