blob: c63f9f1e61b8f1a7f327cfa3205b53487fd0c48e [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Jiri Slaby3b8006e2008-06-25 00:07:50 +02002/*
3 * HID driver for some monterey "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 Slaby3b8006e2008-06-25 00:07:50 +02009 * Copyright (c) 2008 Jiri Slaby
10 */
11
12/*
Jiri Slaby3b8006e2008-06-25 00:07:50 +020013 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18
19#include "hid-ids.h"
20
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040021static __u8 *mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
22 unsigned int *rsize)
Jiri Slaby3b8006e2008-06-25 00:07:50 +020023{
Jiri Kosina4ab25782014-08-21 09:57:48 -050024 if (*rsize >= 31 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
Joe Perches4291ee32010-12-09 19:29:03 -080025 hid_info(hdev, "fixing up button/consumer in HID report descriptor\n");
Jiri Slaby3b8006e2008-06-25 00:07:50 +020026 rdesc[30] = 0x0c;
27 }
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040028 return rdesc;
Jiri Slaby3b8006e2008-06-25 00:07:50 +020029}
30
31#define mr_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
32 EV_KEY, (c))
33static int mr_input_mapping(struct hid_device *hdev, struct hid_input *hi,
34 struct hid_field *field, struct hid_usage *usage,
35 unsigned long **bit, int *max)
36{
37 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
38 return 0;
39
40 switch (usage->hid & HID_USAGE) {
41 case 0x156: mr_map_key_clear(KEY_WORDPROCESSOR); break;
42 case 0x157: mr_map_key_clear(KEY_SPREADSHEET); break;
43 case 0x158: mr_map_key_clear(KEY_PRESENTATION); break;
44 case 0x15c: mr_map_key_clear(KEY_STOP); break;
45 default:
46 return 0;
47 }
48 return 1;
49}
50
51static const struct hid_device_id mr_devices[] = {
52 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
53 { }
54};
55MODULE_DEVICE_TABLE(hid, mr_devices);
56
57static struct hid_driver mr_driver = {
58 .name = "monterey",
59 .id_table = mr_devices,
60 .report_fixup = mr_report_fixup,
61 .input_mapping = mr_input_mapping,
62};
H Hartley Sweetenf4254582012-12-17 15:28:26 -070063module_hid_driver(mr_driver);
Jiri Slaby3b8006e2008-06-25 00:07:50 +020064
Jiri Slaby3b8006e2008-06-25 00:07:50 +020065MODULE_LICENSE("GPL");