Commit | Line | Data |
---|---|---|
980a3da6 JS |
1 | /* |
2 | * HID driver for some samsung "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 | ||
25 | /* | |
26 | * Samsung IrDA remote controller (reports as Cypress USB Mouse). | |
27 | * | |
28 | * Vendor specific report #4 has a size of 48 bit, | |
29 | * and therefore is not accepted when inspecting the descriptors. | |
30 | * As a workaround we reinterpret the report as: | |
31 | * Variable type, count 6, size 8 bit, log. maximum 255 | |
32 | * The burden to reconstruct the data is moved into user space. | |
33 | */ | |
34 | static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |
35 | unsigned int rsize) | |
36 | { | |
37 | if (rsize >= 182 && rdesc[175] == 0x25 && rdesc[176] == 0x40 && | |
38 | rdesc[177] == 0x75 && rdesc[178] == 0x30 && | |
39 | rdesc[179] == 0x95 && rdesc[180] == 0x01 && | |
40 | rdesc[182] == 0x40) { | |
41 | dev_info(&hdev->dev, "fixing up Samsung IrDA report " | |
42 | "descriptor\n"); | |
43 | rdesc[176] = 0xff; | |
44 | rdesc[178] = 0x08; | |
45 | rdesc[180] = 0x06; | |
46 | rdesc[182] = 0x42; | |
47 | } | |
48 | } | |
49 | ||
50 | static int samsung_probe(struct hid_device *hdev, | |
51 | const struct hid_device_id *id) | |
52 | { | |
53 | int ret; | |
54 | ||
980a3da6 JS |
55 | ret = hid_parse(hdev); |
56 | if (ret) { | |
57 | dev_err(&hdev->dev, "parse failed\n"); | |
58 | goto err_free; | |
59 | } | |
60 | ||
93c10132 JS |
61 | ret = hid_hw_start(hdev, (HID_CONNECT_DEFAULT & ~HID_CONNECT_HIDINPUT) | |
62 | HID_CONNECT_HIDDEV_FORCE); | |
980a3da6 JS |
63 | if (ret) { |
64 | dev_err(&hdev->dev, "hw start failed\n"); | |
65 | goto err_free; | |
66 | } | |
67 | ||
68 | return 0; | |
69 | err_free: | |
70 | return ret; | |
71 | } | |
72 | ||
73 | static const struct hid_device_id samsung_devices[] = { | |
74 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, | |
75 | { } | |
76 | }; | |
77 | MODULE_DEVICE_TABLE(hid, samsung_devices); | |
78 | ||
79 | static struct hid_driver samsung_driver = { | |
80 | .name = "samsung", | |
81 | .id_table = samsung_devices, | |
82 | .report_fixup = samsung_report_fixup, | |
83 | .probe = samsung_probe, | |
84 | }; | |
85 | ||
86 | static int samsung_init(void) | |
87 | { | |
88 | return hid_register_driver(&samsung_driver); | |
89 | } | |
90 | ||
91 | static void samsung_exit(void) | |
92 | { | |
93 | hid_unregister_driver(&samsung_driver); | |
94 | } | |
95 | ||
96 | module_init(samsung_init); | |
97 | module_exit(samsung_exit); | |
98 | MODULE_LICENSE("GPL"); | |
99 | ||
100 | HID_COMPAT_LOAD_DRIVER(samsung); |