blob: dedf757781ae1c9f907ad1e4d390ddc4b9c997cc [file] [log] [blame]
Jiri Slaby3b8006e2008-06-25 00:07:50 +02001/*
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
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
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040025static __u8 *mr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
26 unsigned int *rsize)
Jiri Slaby3b8006e2008-06-25 00:07:50 +020027{
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040028 if (*rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) {
Joe Perches4291ee32010-12-09 19:29:03 -080029 hid_info(hdev, "fixing up button/consumer in HID report descriptor\n");
Jiri Slaby3b8006e2008-06-25 00:07:50 +020030 rdesc[30] = 0x0c;
31 }
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040032 return rdesc;
Jiri Slaby3b8006e2008-06-25 00:07:50 +020033}
34
35#define mr_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
36 EV_KEY, (c))
37static int mr_input_mapping(struct hid_device *hdev, struct hid_input *hi,
38 struct hid_field *field, struct hid_usage *usage,
39 unsigned long **bit, int *max)
40{
41 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
42 return 0;
43
44 switch (usage->hid & HID_USAGE) {
45 case 0x156: mr_map_key_clear(KEY_WORDPROCESSOR); break;
46 case 0x157: mr_map_key_clear(KEY_SPREADSHEET); break;
47 case 0x158: mr_map_key_clear(KEY_PRESENTATION); break;
48 case 0x15c: mr_map_key_clear(KEY_STOP); break;
49 default:
50 return 0;
51 }
52 return 1;
53}
54
55static const struct hid_device_id mr_devices[] = {
56 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
57 { }
58};
59MODULE_DEVICE_TABLE(hid, mr_devices);
60
61static struct hid_driver mr_driver = {
62 .name = "monterey",
63 .id_table = mr_devices,
64 .report_fixup = mr_report_fixup,
65 .input_mapping = mr_input_mapping,
66};
67
Peter Huewea24f423b2009-07-02 19:08:38 +020068static int __init mr_init(void)
Jiri Slaby3b8006e2008-06-25 00:07:50 +020069{
70 return hid_register_driver(&mr_driver);
71}
72
Peter Huewea24f423b2009-07-02 19:08:38 +020073static void __exit mr_exit(void)
Jiri Slaby3b8006e2008-06-25 00:07:50 +020074{
75 hid_unregister_driver(&mr_driver);
76}
77
78module_init(mr_init);
79module_exit(mr_exit);
80MODULE_LICENSE("GPL");