blob: 164ed568f6cf73bf4640b6f4080d99dde37d6d91 [file] [log] [blame]
Jiri Slaby90231e72008-06-23 21:56:07 +02001/*
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
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 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
26 unsigned int *rsize)
Jiri Slaby90231e72008-06-23 21:56:07 +020027{
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040028 if (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
Jiri Slaby90231e72008-06-23 21:56:07 +020029 rdesc[106] == 0x03) {
30 dev_info(&hdev->dev, "fixing up Sunplus Wireless Desktop "
31 "report descriptor\n");
32 rdesc[105] = rdesc[110] = 0x03;
33 rdesc[106] = rdesc[111] = 0x21;
34 }
Nikolai Kondrashov73e40082010-08-06 23:03:06 +040035 return rdesc;
Jiri Slaby90231e72008-06-23 21:56:07 +020036}
37
38#define sp_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
39 EV_KEY, (c))
40static int sp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
41 struct hid_field *field, struct hid_usage *usage,
42 unsigned long **bit, int *max)
43{
44 if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
45 return 0;
46
47 switch (usage->hid & HID_USAGE) {
48 case 0x2003: sp_map_key_clear(KEY_ZOOMIN); break;
49 case 0x2103: sp_map_key_clear(KEY_ZOOMOUT); break;
50 default:
51 return 0;
52 }
53 return 1;
54}
55
56static const struct hid_device_id sp_devices[] = {
57 { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
58 { }
59};
60MODULE_DEVICE_TABLE(hid, sp_devices);
61
62static struct hid_driver sp_driver = {
63 .name = "sunplus",
64 .id_table = sp_devices,
65 .report_fixup = sp_report_fixup,
66 .input_mapping = sp_input_mapping,
67};
68
Peter Huewea24f4232009-07-02 19:08:38 +020069static int __init sp_init(void)
Jiri Slaby90231e72008-06-23 21:56:07 +020070{
71 return hid_register_driver(&sp_driver);
72}
73
Peter Huewea24f4232009-07-02 19:08:38 +020074static void __exit sp_exit(void)
Jiri Slaby90231e72008-06-23 21:56:07 +020075{
76 hid_unregister_driver(&sp_driver);
77}
78
79module_init(sp_init);
80module_exit(sp_exit);
81MODULE_LICENSE("GPL");