aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDon Prince <dhprince.devel@yahoo.co.uk>2010-05-17 06:42:39 -0400
committerJiri Kosina <jkosina@suse.cz>2010-05-17 07:36:44 -0400
commitb355850ba383232d4e0e357c1cda8cb7bfcc60bc (patch)
tree760dfd1b7fe7aaf5ef45ffa5ec28ef7dc54b9dd3 /drivers
parenta9885c8f7bf62e251fc178f838b9f0ee897c158a (diff)
HID: hid-samsung: add support for Creative Desktop Wireless 6000
Add support for the multimedia buttons of the Creative Desktop Wireless 6000 keyboard/mouse combo which are not currently handled by the default/samsung HID driver. Signed-off-by: Don Prince <dhprince-devel@yahoo.co.uk> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/Kconfig2
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-ids.h1
-rw-r--r--drivers/hid/hid-samsung.c102
4 files changed, 93 insertions, 13 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 3cf69a0a8b77..ac8e12d00c0f 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -273,7 +273,7 @@ config HID_SAMSUNG
273 depends on USB_HID 273 depends on USB_HID
274 default !EMBEDDED 274 default !EMBEDDED
275 ---help--- 275 ---help---
276 Support for Samsung InfraRed remote control. 276 Support for Samsung InfraRed remote control or keyboards.
277 277
278config HID_SONY 278config HID_SONY
279 tristate "Sony" if EMBEDDED 279 tristate "Sony" if EMBEDDED
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 7c77c64d3e99..c625c3419a8c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1346,6 +1346,7 @@ static const struct hid_device_id hid_blacklist[] = {
1346 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, 1346 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
1347 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, 1347 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
1348 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1348 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
1349 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1350 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1350 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) }, 1351 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
1351 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) }, 1352 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 30cba94cfb0c..ba071b1aba3e 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -415,6 +415,7 @@
415 415
416#define USB_VENDOR_ID_SAMSUNG 0x0419 416#define USB_VENDOR_ID_SAMSUNG 0x0419
417#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 417#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
418#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600
418 419
419#define USB_VENDOR_ID_SONY 0x054c 420#define USB_VENDOR_ID_SONY 0x054c
420#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b 421#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b
diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
index 510dd1340597..869a5acfc0ba 100644
--- a/drivers/hid/hid-samsung.c
+++ b/drivers/hid/hid-samsung.c
@@ -7,6 +7,18 @@
7 * Copyright (c) 2006-2007 Jiri Kosina 7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley 8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby 9 * Copyright (c) 2008 Jiri Slaby
10 * Copyright (c) 2010 Don Prince <dhprince.devel@yahoo.co.uk>
11 *
12 *
13 * This driver supports several HID devices:
14 *
15 * [0419:0001] Samsung IrDA remote controller (reports as Cypress USB Mouse).
16 * various hid report fixups for different variants.
17 *
18 * [0419:0600] Creative Desktop Wireless 6000 keyboard/mouse combo
19 * several key mappings used from the consumer usage page
20 * deviate from the USB HUT 1.12 standard.
21 *
10 */ 22 */
11 23
12/* 24/*
@@ -17,14 +29,13 @@
17 */ 29 */
18 30
19#include <linux/device.h> 31#include <linux/device.h>
32#include <linux/usb.h>
20#include <linux/hid.h> 33#include <linux/hid.h>
21#include <linux/module.h> 34#include <linux/module.h>
22 35
23#include "hid-ids.h" 36#include "hid-ids.h"
24 37
25/* 38/*
26 * Samsung IrDA remote controller (reports as Cypress USB Mouse).
27 *
28 * There are several variants for 0419:0001: 39 * There are several variants for 0419:0001:
29 * 40 *
30 * 1. 184 byte report descriptor 41 * 1. 184 byte report descriptor
@@ -43,21 +54,21 @@
43 * 4. 171 byte report descriptor 54 * 4. 171 byte report descriptor
44 * Report #3 has an array field with logical range 0..1 instead of 1..3. 55 * Report #3 has an array field with logical range 0..1 instead of 1..3.
45 */ 56 */
46static inline void samsung_dev_trace(struct hid_device *hdev, 57static inline void samsung_irda_dev_trace(struct hid_device *hdev,
47 unsigned int rsize) 58 unsigned int rsize)
48{ 59{
49 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report " 60 dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report "
50 "descriptor\n", rsize); 61 "descriptor\n", rsize);
51} 62}
52 63
53static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc, 64static void samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc,
54 unsigned int rsize) 65 unsigned int rsize)
55{ 66{
56 if (rsize == 184 && rdesc[175] == 0x25 && rdesc[176] == 0x40 && 67 if (rsize == 184 && rdesc[175] == 0x25 && rdesc[176] == 0x40 &&
57 rdesc[177] == 0x75 && rdesc[178] == 0x30 && 68 rdesc[177] == 0x75 && rdesc[178] == 0x30 &&
58 rdesc[179] == 0x95 && rdesc[180] == 0x01 && 69 rdesc[179] == 0x95 && rdesc[180] == 0x01 &&
59 rdesc[182] == 0x40) { 70 rdesc[182] == 0x40) {
60 samsung_dev_trace(hdev, 184); 71 samsung_irda_dev_trace(hdev, 184);
61 rdesc[176] = 0xff; 72 rdesc[176] = 0xff;
62 rdesc[178] = 0x08; 73 rdesc[178] = 0x08;
63 rdesc[180] = 0x06; 74 rdesc[180] = 0x06;
@@ -65,24 +76,87 @@ static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
65 } else 76 } else
66 if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 && 77 if (rsize == 203 && rdesc[192] == 0x15 && rdesc[193] == 0x0 &&
67 rdesc[194] == 0x25 && rdesc[195] == 0x12) { 78 rdesc[194] == 0x25 && rdesc[195] == 0x12) {
68 samsung_dev_trace(hdev, 203); 79 samsung_irda_dev_trace(hdev, 203);
69 rdesc[193] = 0x1; 80 rdesc[193] = 0x1;
70 rdesc[195] = 0xf; 81 rdesc[195] = 0xf;
71 } else 82 } else
72 if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 && 83 if (rsize == 135 && rdesc[124] == 0x15 && rdesc[125] == 0x0 &&
73 rdesc[126] == 0x25 && rdesc[127] == 0x11) { 84 rdesc[126] == 0x25 && rdesc[127] == 0x11) {
74 samsung_dev_trace(hdev, 135); 85 samsung_irda_dev_trace(hdev, 135);
75 rdesc[125] = 0x1; 86 rdesc[125] = 0x1;
76 rdesc[127] = 0xe; 87 rdesc[127] = 0xe;
77 } else 88 } else
78 if (rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 && 89 if (rsize == 171 && rdesc[160] == 0x15 && rdesc[161] == 0x0 &&
79 rdesc[162] == 0x25 && rdesc[163] == 0x01) { 90 rdesc[162] == 0x25 && rdesc[163] == 0x01) {
80 samsung_dev_trace(hdev, 171); 91 samsung_irda_dev_trace(hdev, 171);
81 rdesc[161] = 0x1; 92 rdesc[161] = 0x1;
82 rdesc[163] = 0x3; 93 rdesc[163] = 0x3;
83 } 94 }
84} 95}
85 96
97#define samsung_kbd_mouse_map_key_clear(c) \
98 hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c))
99
100static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
101 struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
102 unsigned long **bit, int *max)
103{
104 struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
105 unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
106
107 if (1 != ifnum || HID_UP_CONSUMER != (usage->hid & HID_USAGE_PAGE))
108 return 0;
109
110 dbg_hid("samsung wireless keyboard/mouse input mapping event [0x%x]\n",
111 usage->hid & HID_USAGE);
112
113 switch (usage->hid & HID_USAGE) {
114 /* report 2 */
115 case 0x0b5: samsung_kbd_mouse_map_key_clear(KEY_NEXTSONG); break;
116 case 0x0b6: samsung_kbd_mouse_map_key_clear(KEY_PREVIOUSSONG); break;
117 case 0x0b7: samsung_kbd_mouse_map_key_clear(KEY_STOPCD); break;
118 case 0x0cd: samsung_kbd_mouse_map_key_clear(KEY_PLAYPAUSE); break;
119 case 0x0e2: samsung_kbd_mouse_map_key_clear(KEY_MUTE); break;
120 case 0x0e9: samsung_kbd_mouse_map_key_clear(KEY_VOLUMEUP); break;
121 case 0x0ea: samsung_kbd_mouse_map_key_clear(KEY_VOLUMEDOWN); break;
122 case 0x183: samsung_kbd_mouse_map_key_clear(KEY_MEDIA); break;
123 case 0x195: samsung_kbd_mouse_map_key_clear(KEY_EMAIL); break;
124 case 0x196: samsung_kbd_mouse_map_key_clear(KEY_CALC); break;
125 case 0x197: samsung_kbd_mouse_map_key_clear(KEY_COMPUTER); break;
126 case 0x22b: samsung_kbd_mouse_map_key_clear(KEY_SEARCH); break;
127 case 0x22c: samsung_kbd_mouse_map_key_clear(KEY_WWW); break;
128 case 0x22d: samsung_kbd_mouse_map_key_clear(KEY_BACK); break;
129 case 0x22e: samsung_kbd_mouse_map_key_clear(KEY_FORWARD); break;
130 case 0x22f: samsung_kbd_mouse_map_key_clear(KEY_FAVORITES); break;
131 case 0x230: samsung_kbd_mouse_map_key_clear(KEY_REFRESH); break;
132 case 0x231: samsung_kbd_mouse_map_key_clear(KEY_STOP); break;
133 default:
134 return 0;
135 }
136
137 return 1;
138}
139
140static void samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
141 unsigned int rsize)
142{
143 if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product)
144 samsung_irda_report_fixup(hdev, rdesc, rsize);
145}
146
147static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
148 struct hid_field *field, struct hid_usage *usage,
149 unsigned long **bit, int *max)
150{
151 int ret = 0;
152
153 if (USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE == hdev->product)
154 ret = samsung_kbd_mouse_input_mapping(hdev,
155 hi, field, usage, bit, max);
156
157 return ret;
158}
159
86static int samsung_probe(struct hid_device *hdev, 160static int samsung_probe(struct hid_device *hdev,
87 const struct hid_device_id *id) 161 const struct hid_device_id *id)
88{ 162{
@@ -95,10 +169,12 @@ static int samsung_probe(struct hid_device *hdev,
95 goto err_free; 169 goto err_free;
96 } 170 }
97 171
98 if (hdev->rsize == 184) { 172 if (USB_DEVICE_ID_SAMSUNG_IR_REMOTE == hdev->product) {
99 /* disable hidinput, force hiddev */ 173 if (hdev->rsize == 184) {
100 cmask = (cmask & ~HID_CONNECT_HIDINPUT) | 174 /* disable hidinput, force hiddev */
101 HID_CONNECT_HIDDEV_FORCE; 175 cmask = (cmask & ~HID_CONNECT_HIDINPUT) |
176 HID_CONNECT_HIDDEV_FORCE;
177 }
102 } 178 }
103 179
104 ret = hid_hw_start(hdev, cmask); 180 ret = hid_hw_start(hdev, cmask);
@@ -114,6 +190,7 @@ err_free:
114 190
115static const struct hid_device_id samsung_devices[] = { 191static const struct hid_device_id samsung_devices[] = {
116 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 192 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
193 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
117 { } 194 { }
118}; 195};
119MODULE_DEVICE_TABLE(hid, samsung_devices); 196MODULE_DEVICE_TABLE(hid, samsung_devices);
@@ -122,6 +199,7 @@ static struct hid_driver samsung_driver = {
122 .name = "samsung", 199 .name = "samsung",
123 .id_table = samsung_devices, 200 .id_table = samsung_devices,
124 .report_fixup = samsung_report_fixup, 201 .report_fixup = samsung_report_fixup,
202 .input_mapping = samsung_input_mapping,
125 .probe = samsung_probe, 203 .probe = samsung_probe,
126}; 204};
127 205