Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * HID driver for some monterey "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 | 3b8006e | 2008-06-25 00:07:50 +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 *mr_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 25 | unsigned int *rsize) |
Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 26 | { |
Jiri Kosina | 4ab2578 | 2014-08-21 09:57:48 -0500 | [diff] [blame] | 27 | if (*rsize >= 31 && rdesc[29] == 0x05 && rdesc[30] == 0x09) { |
Joe Perches | 4291ee3 | 2010-12-09 19:29:03 -0800 | [diff] [blame] | 28 | hid_info(hdev, "fixing up button/consumer in HID report descriptor\n"); |
Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 29 | rdesc[30] = 0x0c; |
| 30 | } |
Nikolai Kondrashov | 73e4008 | 2010-08-06 23:03:06 +0400 | [diff] [blame] | 31 | return rdesc; |
Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | #define mr_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \ |
| 35 | EV_KEY, (c)) |
| 36 | static int mr_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
| 37 | struct hid_field *field, struct hid_usage *usage, |
| 38 | unsigned long **bit, int *max) |
| 39 | { |
| 40 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER) |
| 41 | return 0; |
| 42 | |
| 43 | switch (usage->hid & HID_USAGE) { |
| 44 | case 0x156: mr_map_key_clear(KEY_WORDPROCESSOR); break; |
| 45 | case 0x157: mr_map_key_clear(KEY_SPREADSHEET); break; |
| 46 | case 0x158: mr_map_key_clear(KEY_PRESENTATION); break; |
| 47 | case 0x15c: mr_map_key_clear(KEY_STOP); break; |
| 48 | default: |
| 49 | return 0; |
| 50 | } |
| 51 | return 1; |
| 52 | } |
| 53 | |
| 54 | static const struct hid_device_id mr_devices[] = { |
| 55 | { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, |
| 56 | { } |
| 57 | }; |
| 58 | MODULE_DEVICE_TABLE(hid, mr_devices); |
| 59 | |
| 60 | static struct hid_driver mr_driver = { |
| 61 | .name = "monterey", |
| 62 | .id_table = mr_devices, |
| 63 | .report_fixup = mr_report_fixup, |
| 64 | .input_mapping = mr_input_mapping, |
| 65 | }; |
H Hartley Sweeten | f425458 | 2012-12-17 15:28:26 -0700 | [diff] [blame] | 66 | module_hid_driver(mr_driver); |
Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 67 | |
Jiri Slaby | 3b8006e | 2008-06-25 00:07:50 +0200 | [diff] [blame] | 68 | MODULE_LICENSE("GPL"); |