2 * HID driver for Logitech Unifying receivers
4 * Copyright (c) 2011 Logitech
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include <linux/device.h>
26 #include <linux/hid.h>
27 #include <linux/module.h>
28 #include <linux/kfifo.h>
29 #include <linux/delay.h>
30 #include <linux/usb.h> /* For to_usb_interface for kvm extra intf check */
31 #include <asm/unaligned.h>
34 #define DJ_MAX_PAIRED_DEVICES 6
35 #define DJ_MAX_NUMBER_NOTIFS 8
36 #define DJ_RECEIVER_INDEX 0
37 #define DJ_DEVICE_INDEX_MIN 1
38 #define DJ_DEVICE_INDEX_MAX 6
40 #define DJREPORT_SHORT_LENGTH 15
41 #define DJREPORT_LONG_LENGTH 32
43 #define REPORT_ID_DJ_SHORT 0x20
44 #define REPORT_ID_DJ_LONG 0x21
46 #define REPORT_ID_HIDPP_SHORT 0x10
47 #define REPORT_ID_HIDPP_LONG 0x11
48 #define REPORT_ID_HIDPP_VERY_LONG 0x12
50 #define HIDPP_REPORT_SHORT_LENGTH 7
51 #define HIDPP_REPORT_LONG_LENGTH 20
53 #define HIDPP_RECEIVER_INDEX 0xff
55 #define REPORT_TYPE_RFREPORT_FIRST 0x01
56 #define REPORT_TYPE_RFREPORT_LAST 0x1F
58 /* Command Switch to DJ mode */
59 #define REPORT_TYPE_CMD_SWITCH 0x80
60 #define CMD_SWITCH_PARAM_DEVBITFIELD 0x00
61 #define CMD_SWITCH_PARAM_TIMEOUT_SECONDS 0x01
62 #define TIMEOUT_NO_KEEPALIVE 0x00
64 /* Command to Get the list of Paired devices */
65 #define REPORT_TYPE_CMD_GET_PAIRED_DEVICES 0x81
67 /* Device Paired Notification */
68 #define REPORT_TYPE_NOTIF_DEVICE_PAIRED 0x41
69 #define SPFUNCTION_MORE_NOTIF_EXPECTED 0x01
70 #define SPFUNCTION_DEVICE_LIST_EMPTY 0x02
71 #define DEVICE_PAIRED_PARAM_SPFUNCTION 0x00
72 #define DEVICE_PAIRED_PARAM_EQUAD_ID_LSB 0x01
73 #define DEVICE_PAIRED_PARAM_EQUAD_ID_MSB 0x02
74 #define DEVICE_PAIRED_RF_REPORT_TYPE 0x03
76 /* Device Un-Paired Notification */
77 #define REPORT_TYPE_NOTIF_DEVICE_UNPAIRED 0x40
79 /* Connection Status Notification */
80 #define REPORT_TYPE_NOTIF_CONNECTION_STATUS 0x42
81 #define CONNECTION_STATUS_PARAM_STATUS 0x00
82 #define STATUS_LINKLOSS 0x01
84 /* Error Notification */
85 #define REPORT_TYPE_NOTIF_ERROR 0x7F
86 #define NOTIF_ERROR_PARAM_ETYPE 0x00
87 #define ETYPE_KEEPALIVE_TIMEOUT 0x01
89 /* supported DJ HID && RF report types */
90 #define REPORT_TYPE_KEYBOARD 0x01
91 #define REPORT_TYPE_MOUSE 0x02
92 #define REPORT_TYPE_CONSUMER_CONTROL 0x03
93 #define REPORT_TYPE_SYSTEM_CONTROL 0x04
94 #define REPORT_TYPE_MEDIA_CENTER 0x08
95 #define REPORT_TYPE_LEDS 0x0E
97 /* RF Report types bitfield */
98 #define STD_KEYBOARD BIT(1)
99 #define STD_MOUSE BIT(2)
100 #define MULTIMEDIA BIT(3)
101 #define POWER_KEYS BIT(4)
102 #define MEDIA_CENTER BIT(8)
103 #define KBD_LEDS BIT(14)
104 /* Fake (bitnr > NUMBER_OF_HID_REPORTS) bit to track HID++ capability */
105 #define HIDPP BIT_ULL(63)
107 /* HID++ Device Connected Notification */
108 #define REPORT_TYPE_NOTIF_DEVICE_CONNECTED 0x41
109 #define HIDPP_PARAM_PROTO_TYPE 0x00
110 #define HIDPP_PARAM_DEVICE_INFO 0x01
111 #define HIDPP_PARAM_EQUAD_LSB 0x02
112 #define HIDPP_PARAM_EQUAD_MSB 0x03
113 #define HIDPP_PARAM_27MHZ_DEVID 0x03
114 #define HIDPP_DEVICE_TYPE_MASK GENMASK(3, 0)
115 #define HIDPP_LINK_STATUS_MASK BIT(6)
116 #define HIDPP_MANUFACTURER_MASK BIT(7)
118 #define HIDPP_DEVICE_TYPE_KEYBOARD 1
119 #define HIDPP_DEVICE_TYPE_MOUSE 2
121 #define HIDPP_SET_REGISTER 0x80
122 #define HIDPP_GET_LONG_REGISTER 0x83
123 #define HIDPP_REG_CONNECTION_STATE 0x02
124 #define HIDPP_REG_PAIRING_INFORMATION 0xB5
125 #define HIDPP_PAIRING_INFORMATION 0x20
126 #define HIDPP_FAKE_DEVICE_ARRIVAL 0x02
131 recvr_type_gaming_hidpp,
132 recvr_type_mouse_only,
134 recvr_type_bluetooth,
141 u8 report_params[DJREPORT_SHORT_LENGTH - 3];
148 u8 params[HIDPP_REPORT_LONG_LENGTH - 3U];
151 struct dj_receiver_dev {
152 struct hid_device *mouse;
153 struct hid_device *keyboard;
154 struct hid_device *hidpp;
155 struct dj_device *paired_dj_devices[DJ_MAX_PAIRED_DEVICES +
156 DJ_DEVICE_INDEX_MIN];
157 struct list_head list;
159 struct work_struct work;
160 struct kfifo notif_fifo;
161 unsigned long last_query; /* in jiffies */
163 enum recvr_type type;
164 unsigned int unnumbered_application;
169 struct hid_device *hdev;
170 struct dj_receiver_dev *dj_receiver_dev;
171 u64 reports_supported;
175 #define WORKITEM_TYPE_EMPTY 0
176 #define WORKITEM_TYPE_PAIRED 1
177 #define WORKITEM_TYPE_UNPAIRED 2
178 #define WORKITEM_TYPE_UNKNOWN 255
181 u8 type; /* WORKITEM_TYPE_* */
186 u64 reports_supported;
189 /* Keyboard descriptor (1) */
190 static const char kbd_descriptor[] = {
191 0x05, 0x01, /* USAGE_PAGE (generic Desktop) */
192 0x09, 0x06, /* USAGE (Keyboard) */
193 0xA1, 0x01, /* COLLECTION (Application) */
194 0x85, 0x01, /* REPORT_ID (1) */
195 0x95, 0x08, /* REPORT_COUNT (8) */
196 0x75, 0x01, /* REPORT_SIZE (1) */
197 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
198 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
199 0x05, 0x07, /* USAGE_PAGE (Keyboard) */
200 0x19, 0xE0, /* USAGE_MINIMUM (Left Control) */
201 0x29, 0xE7, /* USAGE_MAXIMUM (Right GUI) */
202 0x81, 0x02, /* INPUT (Data,Var,Abs) */
203 0x95, 0x06, /* REPORT_COUNT (6) */
204 0x75, 0x08, /* REPORT_SIZE (8) */
205 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
206 0x26, 0xFF, 0x00, /* LOGICAL_MAXIMUM (255) */
207 0x05, 0x07, /* USAGE_PAGE (Keyboard) */
208 0x19, 0x00, /* USAGE_MINIMUM (no event) */
209 0x2A, 0xFF, 0x00, /* USAGE_MAXIMUM (reserved) */
210 0x81, 0x00, /* INPUT (Data,Ary,Abs) */
211 0x85, 0x0e, /* REPORT_ID (14) */
212 0x05, 0x08, /* USAGE PAGE (LED page) */
213 0x95, 0x05, /* REPORT COUNT (5) */
214 0x75, 0x01, /* REPORT SIZE (1) */
215 0x15, 0x00, /* LOGICAL_MINIMUM (0) */
216 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */
217 0x19, 0x01, /* USAGE MINIMUM (1) */
218 0x29, 0x05, /* USAGE MAXIMUM (5) */
219 0x91, 0x02, /* OUTPUT (Data, Variable, Absolute) */
220 0x95, 0x01, /* REPORT COUNT (1) */
221 0x75, 0x03, /* REPORT SIZE (3) */
222 0x91, 0x01, /* OUTPUT (Constant) */
226 /* Mouse descriptor (2) */
227 static const char mse_descriptor[] = {
228 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
229 0x09, 0x02, /* USAGE (Mouse) */
230 0xA1, 0x01, /* COLLECTION (Application) */
231 0x85, 0x02, /* REPORT_ID = 2 */
232 0x09, 0x01, /* USAGE (pointer) */
233 0xA1, 0x00, /* COLLECTION (physical) */
234 0x05, 0x09, /* USAGE_PAGE (buttons) */
235 0x19, 0x01, /* USAGE_MIN (1) */
236 0x29, 0x10, /* USAGE_MAX (16) */
237 0x15, 0x00, /* LOGICAL_MIN (0) */
238 0x25, 0x01, /* LOGICAL_MAX (1) */
239 0x95, 0x10, /* REPORT_COUNT (16) */
240 0x75, 0x01, /* REPORT_SIZE (1) */
241 0x81, 0x02, /* INPUT (data var abs) */
242 0x05, 0x01, /* USAGE_PAGE (generic desktop) */
243 0x16, 0x01, 0xF8, /* LOGICAL_MIN (-2047) */
244 0x26, 0xFF, 0x07, /* LOGICAL_MAX (2047) */
245 0x75, 0x0C, /* REPORT_SIZE (12) */
246 0x95, 0x02, /* REPORT_COUNT (2) */
247 0x09, 0x30, /* USAGE (X) */
248 0x09, 0x31, /* USAGE (Y) */
249 0x81, 0x06, /* INPUT */
250 0x15, 0x81, /* LOGICAL_MIN (-127) */
251 0x25, 0x7F, /* LOGICAL_MAX (127) */
252 0x75, 0x08, /* REPORT_SIZE (8) */
253 0x95, 0x01, /* REPORT_COUNT (1) */
254 0x09, 0x38, /* USAGE (wheel) */
255 0x81, 0x06, /* INPUT */
256 0x05, 0x0C, /* USAGE_PAGE(consumer) */
257 0x0A, 0x38, 0x02, /* USAGE(AC Pan) */
258 0x95, 0x01, /* REPORT_COUNT (1) */
259 0x81, 0x06, /* INPUT */
260 0xC0, /* END_COLLECTION */
261 0xC0, /* END_COLLECTION */
264 /* Mouse descriptor (2) for 27 MHz receiver, only 8 buttons */
265 static const char mse_27mhz_descriptor[] = {
266 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
267 0x09, 0x02, /* USAGE (Mouse) */
268 0xA1, 0x01, /* COLLECTION (Application) */
269 0x85, 0x02, /* REPORT_ID = 2 */
270 0x09, 0x01, /* USAGE (pointer) */
271 0xA1, 0x00, /* COLLECTION (physical) */
272 0x05, 0x09, /* USAGE_PAGE (buttons) */
273 0x19, 0x01, /* USAGE_MIN (1) */
274 0x29, 0x08, /* USAGE_MAX (8) */
275 0x15, 0x00, /* LOGICAL_MIN (0) */
276 0x25, 0x01, /* LOGICAL_MAX (1) */
277 0x95, 0x08, /* REPORT_COUNT (8) */
278 0x75, 0x01, /* REPORT_SIZE (1) */
279 0x81, 0x02, /* INPUT (data var abs) */
280 0x05, 0x01, /* USAGE_PAGE (generic desktop) */
281 0x16, 0x01, 0xF8, /* LOGICAL_MIN (-2047) */
282 0x26, 0xFF, 0x07, /* LOGICAL_MAX (2047) */
283 0x75, 0x0C, /* REPORT_SIZE (12) */
284 0x95, 0x02, /* REPORT_COUNT (2) */
285 0x09, 0x30, /* USAGE (X) */
286 0x09, 0x31, /* USAGE (Y) */
287 0x81, 0x06, /* INPUT */
288 0x15, 0x81, /* LOGICAL_MIN (-127) */
289 0x25, 0x7F, /* LOGICAL_MAX (127) */
290 0x75, 0x08, /* REPORT_SIZE (8) */
291 0x95, 0x01, /* REPORT_COUNT (1) */
292 0x09, 0x38, /* USAGE (wheel) */
293 0x81, 0x06, /* INPUT */
294 0x05, 0x0C, /* USAGE_PAGE(consumer) */
295 0x0A, 0x38, 0x02, /* USAGE(AC Pan) */
296 0x95, 0x01, /* REPORT_COUNT (1) */
297 0x81, 0x06, /* INPUT */
298 0xC0, /* END_COLLECTION */
299 0xC0, /* END_COLLECTION */
302 /* Mouse descriptor (2) for Bluetooth receiver, low-res hwheel, 12 buttons */
303 static const char mse_bluetooth_descriptor[] = {
304 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
305 0x09, 0x02, /* USAGE (Mouse) */
306 0xA1, 0x01, /* COLLECTION (Application) */
307 0x85, 0x02, /* REPORT_ID = 2 */
308 0x09, 0x01, /* USAGE (pointer) */
309 0xA1, 0x00, /* COLLECTION (physical) */
310 0x05, 0x09, /* USAGE_PAGE (buttons) */
311 0x19, 0x01, /* USAGE_MIN (1) */
312 0x29, 0x08, /* USAGE_MAX (8) */
313 0x15, 0x00, /* LOGICAL_MIN (0) */
314 0x25, 0x01, /* LOGICAL_MAX (1) */
315 0x95, 0x08, /* REPORT_COUNT (8) */
316 0x75, 0x01, /* REPORT_SIZE (1) */
317 0x81, 0x02, /* INPUT (data var abs) */
318 0x05, 0x01, /* USAGE_PAGE (generic desktop) */
319 0x16, 0x01, 0xF8, /* LOGICAL_MIN (-2047) */
320 0x26, 0xFF, 0x07, /* LOGICAL_MAX (2047) */
321 0x75, 0x0C, /* REPORT_SIZE (12) */
322 0x95, 0x02, /* REPORT_COUNT (2) */
323 0x09, 0x30, /* USAGE (X) */
324 0x09, 0x31, /* USAGE (Y) */
325 0x81, 0x06, /* INPUT */
326 0x15, 0x81, /* LOGICAL_MIN (-127) */
327 0x25, 0x7F, /* LOGICAL_MAX (127) */
328 0x75, 0x08, /* REPORT_SIZE (8) */
329 0x95, 0x01, /* REPORT_COUNT (1) */
330 0x09, 0x38, /* USAGE (wheel) */
331 0x81, 0x06, /* INPUT */
332 0x05, 0x0C, /* USAGE_PAGE(consumer) */
333 0x0A, 0x38, 0x02, /* USAGE(AC Pan) */
334 0x15, 0xF9, /* LOGICAL_MIN (-7) */
335 0x25, 0x07, /* LOGICAL_MAX (7) */
336 0x75, 0x04, /* REPORT_SIZE (4) */
337 0x95, 0x01, /* REPORT_COUNT (1) */
338 0x81, 0x06, /* INPUT */
339 0x05, 0x09, /* USAGE_PAGE (buttons) */
340 0x19, 0x09, /* USAGE_MIN (9) */
341 0x29, 0x0C, /* USAGE_MAX (12) */
342 0x15, 0x00, /* LOGICAL_MIN (0) */
343 0x25, 0x01, /* LOGICAL_MAX (1) */
344 0x75, 0x01, /* REPORT_SIZE (1) */
345 0x95, 0x04, /* REPORT_COUNT (4) */
346 0x81, 0x06, /* INPUT */
347 0xC0, /* END_COLLECTION */
348 0xC0, /* END_COLLECTION */
351 /* Gaming Mouse descriptor (2) */
352 static const char mse_high_res_descriptor[] = {
353 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
354 0x09, 0x02, /* USAGE (Mouse) */
355 0xA1, 0x01, /* COLLECTION (Application) */
356 0x85, 0x02, /* REPORT_ID = 2 */
357 0x09, 0x01, /* USAGE (pointer) */
358 0xA1, 0x00, /* COLLECTION (physical) */
359 0x05, 0x09, /* USAGE_PAGE (buttons) */
360 0x19, 0x01, /* USAGE_MIN (1) */
361 0x29, 0x10, /* USAGE_MAX (16) */
362 0x15, 0x00, /* LOGICAL_MIN (0) */
363 0x25, 0x01, /* LOGICAL_MAX (1) */
364 0x95, 0x10, /* REPORT_COUNT (16) */
365 0x75, 0x01, /* REPORT_SIZE (1) */
366 0x81, 0x02, /* INPUT (data var abs) */
367 0x05, 0x01, /* USAGE_PAGE (generic desktop) */
368 0x16, 0x01, 0x80, /* LOGICAL_MIN (-32767) */
369 0x26, 0xFF, 0x7F, /* LOGICAL_MAX (32767) */
370 0x75, 0x10, /* REPORT_SIZE (16) */
371 0x95, 0x02, /* REPORT_COUNT (2) */
372 0x09, 0x30, /* USAGE (X) */
373 0x09, 0x31, /* USAGE (Y) */
374 0x81, 0x06, /* INPUT */
375 0x15, 0x81, /* LOGICAL_MIN (-127) */
376 0x25, 0x7F, /* LOGICAL_MAX (127) */
377 0x75, 0x08, /* REPORT_SIZE (8) */
378 0x95, 0x01, /* REPORT_COUNT (1) */
379 0x09, 0x38, /* USAGE (wheel) */
380 0x81, 0x06, /* INPUT */
381 0x05, 0x0C, /* USAGE_PAGE(consumer) */
382 0x0A, 0x38, 0x02, /* USAGE(AC Pan) */
383 0x95, 0x01, /* REPORT_COUNT (1) */
384 0x81, 0x06, /* INPUT */
385 0xC0, /* END_COLLECTION */
386 0xC0, /* END_COLLECTION */
389 /* Consumer Control descriptor (3) */
390 static const char consumer_descriptor[] = {
391 0x05, 0x0C, /* USAGE_PAGE (Consumer Devices) */
392 0x09, 0x01, /* USAGE (Consumer Control) */
393 0xA1, 0x01, /* COLLECTION (Application) */
394 0x85, 0x03, /* REPORT_ID = 3 */
395 0x75, 0x10, /* REPORT_SIZE (16) */
396 0x95, 0x02, /* REPORT_COUNT (2) */
397 0x15, 0x01, /* LOGICAL_MIN (1) */
398 0x26, 0x8C, 0x02, /* LOGICAL_MAX (652) */
399 0x19, 0x01, /* USAGE_MIN (1) */
400 0x2A, 0x8C, 0x02, /* USAGE_MAX (652) */
401 0x81, 0x00, /* INPUT (Data Ary Abs) */
402 0xC0, /* END_COLLECTION */
405 /* System control descriptor (4) */
406 static const char syscontrol_descriptor[] = {
407 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
408 0x09, 0x80, /* USAGE (System Control) */
409 0xA1, 0x01, /* COLLECTION (Application) */
410 0x85, 0x04, /* REPORT_ID = 4 */
411 0x75, 0x02, /* REPORT_SIZE (2) */
412 0x95, 0x01, /* REPORT_COUNT (1) */
413 0x15, 0x01, /* LOGICAL_MIN (1) */
414 0x25, 0x03, /* LOGICAL_MAX (3) */
415 0x09, 0x82, /* USAGE (System Sleep) */
416 0x09, 0x81, /* USAGE (System Power Down) */
417 0x09, 0x83, /* USAGE (System Wake Up) */
418 0x81, 0x60, /* INPUT (Data Ary Abs NPrf Null) */
419 0x75, 0x06, /* REPORT_SIZE (6) */
420 0x81, 0x03, /* INPUT (Cnst Var Abs) */
421 0xC0, /* END_COLLECTION */
424 /* Media descriptor (8) */
425 static const char media_descriptor[] = {
426 0x06, 0xbc, 0xff, /* Usage Page 0xffbc */
427 0x09, 0x88, /* Usage 0x0088 */
428 0xa1, 0x01, /* BeginCollection */
429 0x85, 0x08, /* Report ID 8 */
430 0x19, 0x01, /* Usage Min 0x0001 */
431 0x29, 0xff, /* Usage Max 0x00ff */
432 0x15, 0x01, /* Logical Min 1 */
433 0x26, 0xff, 0x00, /* Logical Max 255 */
434 0x75, 0x08, /* Report Size 8 */
435 0x95, 0x01, /* Report Count 1 */
436 0x81, 0x00, /* Input */
437 0xc0, /* EndCollection */
440 /* HIDPP descriptor */
441 static const char hidpp_descriptor[] = {
442 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */
443 0x09, 0x01, /* Usage (Vendor Usage 1) */
444 0xa1, 0x01, /* Collection (Application) */
445 0x85, 0x10, /* Report ID (16) */
446 0x75, 0x08, /* Report Size (8) */
447 0x95, 0x06, /* Report Count (6) */
448 0x15, 0x00, /* Logical Minimum (0) */
449 0x26, 0xff, 0x00, /* Logical Maximum (255) */
450 0x09, 0x01, /* Usage (Vendor Usage 1) */
451 0x81, 0x00, /* Input (Data,Arr,Abs) */
452 0x09, 0x01, /* Usage (Vendor Usage 1) */
453 0x91, 0x00, /* Output (Data,Arr,Abs) */
454 0xc0, /* End Collection */
455 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */
456 0x09, 0x02, /* Usage (Vendor Usage 2) */
457 0xa1, 0x01, /* Collection (Application) */
458 0x85, 0x11, /* Report ID (17) */
459 0x75, 0x08, /* Report Size (8) */
460 0x95, 0x13, /* Report Count (19) */
461 0x15, 0x00, /* Logical Minimum (0) */
462 0x26, 0xff, 0x00, /* Logical Maximum (255) */
463 0x09, 0x02, /* Usage (Vendor Usage 2) */
464 0x81, 0x00, /* Input (Data,Arr,Abs) */
465 0x09, 0x02, /* Usage (Vendor Usage 2) */
466 0x91, 0x00, /* Output (Data,Arr,Abs) */
467 0xc0, /* End Collection */
468 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */
469 0x09, 0x04, /* Usage (Vendor Usage 0x04) */
470 0xa1, 0x01, /* Collection (Application) */
471 0x85, 0x20, /* Report ID (32) */
472 0x75, 0x08, /* Report Size (8) */
473 0x95, 0x0e, /* Report Count (14) */
474 0x15, 0x00, /* Logical Minimum (0) */
475 0x26, 0xff, 0x00, /* Logical Maximum (255) */
476 0x09, 0x41, /* Usage (Vendor Usage 0x41) */
477 0x81, 0x00, /* Input (Data,Arr,Abs) */
478 0x09, 0x41, /* Usage (Vendor Usage 0x41) */
479 0x91, 0x00, /* Output (Data,Arr,Abs) */
480 0x85, 0x21, /* Report ID (33) */
481 0x95, 0x1f, /* Report Count (31) */
482 0x15, 0x00, /* Logical Minimum (0) */
483 0x26, 0xff, 0x00, /* Logical Maximum (255) */
484 0x09, 0x42, /* Usage (Vendor Usage 0x42) */
485 0x81, 0x00, /* Input (Data,Arr,Abs) */
486 0x09, 0x42, /* Usage (Vendor Usage 0x42) */
487 0x91, 0x00, /* Output (Data,Arr,Abs) */
488 0xc0, /* End Collection */
491 /* Maximum size of all defined hid reports in bytes (including report id) */
492 #define MAX_REPORT_SIZE 8
494 /* Make sure all descriptors are present here */
495 #define MAX_RDESC_SIZE \
496 (sizeof(kbd_descriptor) + \
497 sizeof(mse_bluetooth_descriptor) + \
498 sizeof(consumer_descriptor) + \
499 sizeof(syscontrol_descriptor) + \
500 sizeof(media_descriptor) + \
501 sizeof(hidpp_descriptor))
503 /* Number of possible hid report types that can be created by this driver.
505 * Right now, RF report types have the same report types (or report id's)
506 * than the hid report created from those RF reports. In the future
507 * this doesnt have to be true.
509 * For instance, RF report type 0x01 which has a size of 8 bytes, corresponds
510 * to hid report id 0x01, this is standard keyboard. Same thing applies to mice
511 * reports and consumer control, etc. If a new RF report is created, it doesn't
512 * has to have the same report id as its corresponding hid report, so an
513 * translation may have to take place for future report types.
515 #define NUMBER_OF_HID_REPORTS 32
516 static const u8 hid_reportid_size_map[NUMBER_OF_HID_REPORTS] = {
517 [1] = 8, /* Standard keyboard */
518 [2] = 8, /* Standard mouse */
519 [3] = 5, /* Consumer control */
520 [4] = 2, /* System control */
521 [8] = 2, /* Media Center */
525 #define LOGITECH_DJ_INTERFACE_NUMBER 0x02
527 static struct hid_ll_driver logi_dj_ll_driver;
529 static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev);
530 static void delayedwork_callback(struct work_struct *work);
532 static LIST_HEAD(dj_hdev_list);
533 static DEFINE_MUTEX(dj_hdev_list_lock);
536 * dj/HID++ receivers are really a single logical entity, but for BIOS/Windows
537 * compatibility they have multiple USB interfaces. On HID++ receivers we need
538 * to listen for input reports on both interfaces. The functions below are used
539 * to create a single struct dj_receiver_dev for all interfaces belonging to
540 * a single USB-device / receiver.
542 static struct dj_receiver_dev *dj_find_receiver_dev(struct hid_device *hdev,
543 enum recvr_type type)
545 struct dj_receiver_dev *djrcv_dev;
549 * The bluetooth receiver contains a built-in hub and has separate
550 * USB-devices for the keyboard and mouse interfaces.
552 sep = (type == recvr_type_bluetooth) ? '.' : '/';
554 /* Try to find an already-probed interface from the same device */
555 list_for_each_entry(djrcv_dev, &dj_hdev_list, list) {
556 if (djrcv_dev->mouse &&
557 hid_compare_device_paths(hdev, djrcv_dev->mouse, sep)) {
558 kref_get(&djrcv_dev->kref);
561 if (djrcv_dev->keyboard &&
562 hid_compare_device_paths(hdev, djrcv_dev->keyboard, sep)) {
563 kref_get(&djrcv_dev->kref);
566 if (djrcv_dev->hidpp &&
567 hid_compare_device_paths(hdev, djrcv_dev->hidpp, sep)) {
568 kref_get(&djrcv_dev->kref);
576 static void dj_release_receiver_dev(struct kref *kref)
578 struct dj_receiver_dev *djrcv_dev = container_of(kref, struct dj_receiver_dev, kref);
580 list_del(&djrcv_dev->list);
581 kfifo_free(&djrcv_dev->notif_fifo);
585 static void dj_put_receiver_dev(struct hid_device *hdev)
587 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
589 mutex_lock(&dj_hdev_list_lock);
591 if (djrcv_dev->mouse == hdev)
592 djrcv_dev->mouse = NULL;
593 if (djrcv_dev->keyboard == hdev)
594 djrcv_dev->keyboard = NULL;
595 if (djrcv_dev->hidpp == hdev)
596 djrcv_dev->hidpp = NULL;
598 kref_put(&djrcv_dev->kref, dj_release_receiver_dev);
600 mutex_unlock(&dj_hdev_list_lock);
603 static struct dj_receiver_dev *dj_get_receiver_dev(struct hid_device *hdev,
604 enum recvr_type type,
605 unsigned int application,
608 struct dj_receiver_dev *djrcv_dev;
610 mutex_lock(&dj_hdev_list_lock);
612 djrcv_dev = dj_find_receiver_dev(hdev, type);
614 djrcv_dev = kzalloc(sizeof(*djrcv_dev), GFP_KERNEL);
618 INIT_WORK(&djrcv_dev->work, delayedwork_callback);
619 spin_lock_init(&djrcv_dev->lock);
620 if (kfifo_alloc(&djrcv_dev->notif_fifo,
621 DJ_MAX_NUMBER_NOTIFS * sizeof(struct dj_workitem),
627 kref_init(&djrcv_dev->kref);
628 list_add_tail(&djrcv_dev->list, &dj_hdev_list);
629 djrcv_dev->last_query = jiffies;
630 djrcv_dev->type = type;
633 if (application == HID_GD_KEYBOARD)
634 djrcv_dev->keyboard = hdev;
635 if (application == HID_GD_MOUSE)
636 djrcv_dev->mouse = hdev;
638 djrcv_dev->hidpp = hdev;
640 hid_set_drvdata(hdev, djrcv_dev);
642 mutex_unlock(&dj_hdev_list_lock);
646 static void logi_dj_recv_destroy_djhid_device(struct dj_receiver_dev *djrcv_dev,
647 struct dj_workitem *workitem)
649 /* Called in delayed work context */
650 struct dj_device *dj_dev;
653 spin_lock_irqsave(&djrcv_dev->lock, flags);
654 dj_dev = djrcv_dev->paired_dj_devices[workitem->device_index];
655 djrcv_dev->paired_dj_devices[workitem->device_index] = NULL;
656 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
658 if (dj_dev != NULL) {
659 hid_destroy_device(dj_dev->hdev);
662 hid_err(djrcv_dev->hidpp, "%s: can't destroy a NULL device\n",
667 static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
668 struct dj_workitem *workitem)
670 /* Called in delayed work context */
671 struct hid_device *djrcv_hdev = djrcv_dev->hidpp;
672 struct hid_device *dj_hiddev;
673 struct dj_device *dj_dev;
674 u8 device_index = workitem->device_index;
677 /* Device index goes from 1 to 6, we need 3 bytes to store the
678 * semicolon, the index, and a null terminator
680 unsigned char tmpstr[3];
682 /* We are the only one ever adding a device, no need to lock */
683 if (djrcv_dev->paired_dj_devices[device_index]) {
684 /* The device is already known. No need to reallocate it. */
685 dbg_hid("%s: device is already known\n", __func__);
689 dj_hiddev = hid_allocate_device();
690 if (IS_ERR(dj_hiddev)) {
691 hid_err(djrcv_hdev, "%s: hid_allocate_dev failed\n", __func__);
695 dj_hiddev->ll_driver = &logi_dj_ll_driver;
697 dj_hiddev->dev.parent = &djrcv_hdev->dev;
698 dj_hiddev->bus = BUS_USB;
699 dj_hiddev->vendor = djrcv_hdev->vendor;
700 dj_hiddev->product = (workitem->quad_id_msb << 8) |
701 workitem->quad_id_lsb;
702 if (workitem->device_type) {
703 const char *type_str = "Device";
705 switch (workitem->device_type) {
706 case 0x01: type_str = "Keyboard"; break;
707 case 0x02: type_str = "Mouse"; break;
708 case 0x03: type_str = "Numpad"; break;
709 case 0x04: type_str = "Presenter"; break;
710 case 0x07: type_str = "Remote Control"; break;
711 case 0x08: type_str = "Trackball"; break;
712 case 0x09: type_str = "Touchpad"; break;
714 snprintf(dj_hiddev->name, sizeof(dj_hiddev->name),
715 "Logitech Wireless %s PID:%04x",
716 type_str, dj_hiddev->product);
718 snprintf(dj_hiddev->name, sizeof(dj_hiddev->name),
719 "Logitech Unifying Device. Wireless PID:%04x",
723 if (djrcv_dev->type == recvr_type_27mhz)
724 dj_hiddev->group = HID_GROUP_LOGITECH_27MHZ_DEVICE;
726 dj_hiddev->group = HID_GROUP_LOGITECH_DJ_DEVICE;
728 memcpy(dj_hiddev->phys, djrcv_hdev->phys, sizeof(djrcv_hdev->phys));
729 snprintf(tmpstr, sizeof(tmpstr), ":%d", device_index);
730 strlcat(dj_hiddev->phys, tmpstr, sizeof(dj_hiddev->phys));
732 dj_dev = kzalloc(sizeof(struct dj_device), GFP_KERNEL);
735 hid_err(djrcv_hdev, "%s: failed allocating dj_dev\n", __func__);
736 goto dj_device_allocate_fail;
739 dj_dev->reports_supported = workitem->reports_supported;
740 dj_dev->hdev = dj_hiddev;
741 dj_dev->dj_receiver_dev = djrcv_dev;
742 dj_dev->device_index = device_index;
743 dj_hiddev->driver_data = dj_dev;
745 spin_lock_irqsave(&djrcv_dev->lock, flags);
746 djrcv_dev->paired_dj_devices[device_index] = dj_dev;
747 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
749 if (hid_add_device(dj_hiddev)) {
750 hid_err(djrcv_hdev, "%s: failed adding dj_device\n", __func__);
751 goto hid_add_device_fail;
757 spin_lock_irqsave(&djrcv_dev->lock, flags);
758 djrcv_dev->paired_dj_devices[device_index] = NULL;
759 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
761 dj_device_allocate_fail:
762 hid_destroy_device(dj_hiddev);
765 static void delayedwork_callback(struct work_struct *work)
767 struct dj_receiver_dev *djrcv_dev =
768 container_of(work, struct dj_receiver_dev, work);
770 struct dj_workitem workitem;
775 dbg_hid("%s\n", __func__);
777 spin_lock_irqsave(&djrcv_dev->lock, flags);
780 * Since we attach to multiple interfaces, we may get scheduled before
781 * we are bound to the HID++ interface, catch this.
783 if (!djrcv_dev->ready) {
784 pr_warn("%s: delayedwork queued before hidpp interface was enumerated\n",
786 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
790 count = kfifo_out(&djrcv_dev->notif_fifo, &workitem, sizeof(workitem));
792 if (count != sizeof(workitem)) {
793 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
797 if (!kfifo_is_empty(&djrcv_dev->notif_fifo))
798 schedule_work(&djrcv_dev->work);
800 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
802 switch (workitem.type) {
803 case WORKITEM_TYPE_PAIRED:
804 logi_dj_recv_add_djhid_device(djrcv_dev, &workitem);
806 case WORKITEM_TYPE_UNPAIRED:
807 logi_dj_recv_destroy_djhid_device(djrcv_dev, &workitem);
809 case WORKITEM_TYPE_UNKNOWN:
810 retval = logi_dj_recv_query_paired_devices(djrcv_dev);
812 hid_err(djrcv_dev->hidpp, "%s: logi_dj_recv_query_paired_devices error: %d\n",
816 case WORKITEM_TYPE_EMPTY:
817 dbg_hid("%s: device list is empty\n", __func__);
823 * Sometimes we receive reports for which we do not have a paired dj_device
824 * associated with the device_index or report-type to forward the report to.
825 * This means that the original "device paired" notification corresponding
826 * to the dj_device never arrived to this driver. Possible reasons for this are:
827 * 1) hid-core discards all packets coming from a device during probe().
828 * 2) if the receiver is plugged into a KVM switch then the pairing reports
829 * are only forwarded to it if the focus is on this PC.
830 * This function deals with this by re-asking the receiver for the list of
831 * connected devices in the delayed work callback.
832 * This function MUST be called with djrcv->lock held.
834 static void logi_dj_recv_queue_unknown_work(struct dj_receiver_dev *djrcv_dev)
836 struct dj_workitem workitem = { .type = WORKITEM_TYPE_UNKNOWN };
838 /* Rate limit queries done because of unhandeled reports to 2/sec */
839 if (time_before(jiffies, djrcv_dev->last_query + HZ / 2))
842 kfifo_in(&djrcv_dev->notif_fifo, &workitem, sizeof(workitem));
843 schedule_work(&djrcv_dev->work);
846 static void logi_dj_recv_queue_notification(struct dj_receiver_dev *djrcv_dev,
847 struct dj_report *dj_report)
849 /* We are called from atomic context (tasklet && djrcv->lock held) */
850 struct dj_workitem workitem = {
851 .device_index = dj_report->device_index,
854 switch (dj_report->report_type) {
855 case REPORT_TYPE_NOTIF_DEVICE_PAIRED:
856 workitem.type = WORKITEM_TYPE_PAIRED;
857 if (dj_report->report_params[DEVICE_PAIRED_PARAM_SPFUNCTION] &
858 SPFUNCTION_DEVICE_LIST_EMPTY) {
859 workitem.type = WORKITEM_TYPE_EMPTY;
863 case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED:
864 workitem.quad_id_msb =
865 dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_MSB];
866 workitem.quad_id_lsb =
867 dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_LSB];
868 workitem.reports_supported = get_unaligned_le32(
869 dj_report->report_params +
870 DEVICE_PAIRED_RF_REPORT_TYPE);
871 workitem.reports_supported |= HIDPP;
872 if (dj_report->report_type == REPORT_TYPE_NOTIF_DEVICE_UNPAIRED)
873 workitem.type = WORKITEM_TYPE_UNPAIRED;
876 logi_dj_recv_queue_unknown_work(djrcv_dev);
880 kfifo_in(&djrcv_dev->notif_fifo, &workitem, sizeof(workitem));
881 schedule_work(&djrcv_dev->work);
884 static void logi_hidpp_dev_conn_notif_equad(struct hid_device *hdev,
885 struct hidpp_event *hidpp_report,
886 struct dj_workitem *workitem)
888 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
890 workitem->type = WORKITEM_TYPE_PAIRED;
891 workitem->device_type = hidpp_report->params[HIDPP_PARAM_DEVICE_INFO] &
892 HIDPP_DEVICE_TYPE_MASK;
893 workitem->quad_id_msb = hidpp_report->params[HIDPP_PARAM_EQUAD_MSB];
894 workitem->quad_id_lsb = hidpp_report->params[HIDPP_PARAM_EQUAD_LSB];
895 switch (workitem->device_type) {
896 case REPORT_TYPE_KEYBOARD:
897 workitem->reports_supported |= STD_KEYBOARD | MULTIMEDIA |
898 POWER_KEYS | MEDIA_CENTER |
901 case REPORT_TYPE_MOUSE:
902 workitem->reports_supported |= STD_MOUSE | HIDPP;
903 if (djrcv_dev->type == recvr_type_mouse_only)
904 workitem->reports_supported |= MULTIMEDIA;
909 static void logi_hidpp_dev_conn_notif_27mhz(struct hid_device *hdev,
910 struct hidpp_event *hidpp_report,
911 struct dj_workitem *workitem)
913 workitem->type = WORKITEM_TYPE_PAIRED;
914 workitem->quad_id_lsb = hidpp_report->params[HIDPP_PARAM_27MHZ_DEVID];
915 switch (hidpp_report->device_index) {
916 case 1: /* Index 1 is always a mouse */
917 case 2: /* Index 2 is always a mouse */
918 workitem->device_type = HIDPP_DEVICE_TYPE_MOUSE;
919 workitem->reports_supported |= STD_MOUSE | HIDPP;
921 case 3: /* Index 3 is always the keyboard */
922 case 4: /* Index 4 is used for an optional separate numpad */
923 workitem->device_type = HIDPP_DEVICE_TYPE_KEYBOARD;
924 workitem->reports_supported |= STD_KEYBOARD | MULTIMEDIA |
928 hid_warn(hdev, "%s: unexpected device-index %d", __func__,
929 hidpp_report->device_index);
933 static void logi_hidpp_recv_queue_notif(struct hid_device *hdev,
934 struct hidpp_event *hidpp_report)
936 /* We are called from atomic context (tasklet && djrcv->lock held) */
937 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
938 const char *device_type = "UNKNOWN";
939 struct dj_workitem workitem = {
940 .type = WORKITEM_TYPE_EMPTY,
941 .device_index = hidpp_report->device_index,
944 switch (hidpp_report->params[HIDPP_PARAM_PROTO_TYPE]) {
946 device_type = "Bluetooth";
947 /* Bluetooth connect packet contents is the same as (e)QUAD */
948 logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
949 if (!(hidpp_report->params[HIDPP_PARAM_DEVICE_INFO] &
950 HIDPP_MANUFACTURER_MASK)) {
951 hid_info(hdev, "Non Logitech device connected on slot %d\n",
952 hidpp_report->device_index);
953 workitem.reports_supported &= ~HIDPP;
957 device_type = "27 Mhz";
958 logi_hidpp_dev_conn_notif_27mhz(hdev, hidpp_report, &workitem);
961 device_type = "QUAD or eQUAD";
962 logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
965 device_type = "eQUAD step 4 DJ";
966 logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
969 device_type = "DFU Lite";
972 device_type = "eQUAD step 4 Lite";
973 logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
976 device_type = "eQUAD step 4 Gaming";
979 device_type = "eQUAD step 4 for gamepads";
982 device_type = "eQUAD nano Lite";
983 logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
986 device_type = "eQUAD Lightspeed";
987 logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
988 workitem.reports_supported |= STD_KEYBOARD;
992 if (workitem.type == WORKITEM_TYPE_EMPTY) {
994 "unusable device of type %s (0x%02x) connected on slot %d",
996 hidpp_report->params[HIDPP_PARAM_PROTO_TYPE],
997 hidpp_report->device_index);
1001 hid_info(hdev, "device of type %s (0x%02x) connected on slot %d",
1002 device_type, hidpp_report->params[HIDPP_PARAM_PROTO_TYPE],
1003 hidpp_report->device_index);
1005 kfifo_in(&djrcv_dev->notif_fifo, &workitem, sizeof(workitem));
1006 schedule_work(&djrcv_dev->work);
1009 static void logi_dj_recv_forward_null_report(struct dj_receiver_dev *djrcv_dev,
1010 struct dj_report *dj_report)
1012 /* We are called from atomic context (tasklet && djrcv->lock held) */
1014 u8 reportbuffer[MAX_REPORT_SIZE];
1015 struct dj_device *djdev;
1017 djdev = djrcv_dev->paired_dj_devices[dj_report->device_index];
1019 memset(reportbuffer, 0, sizeof(reportbuffer));
1021 for (i = 0; i < NUMBER_OF_HID_REPORTS; i++) {
1022 if (djdev->reports_supported & (1 << i)) {
1023 reportbuffer[0] = i;
1024 if (hid_input_report(djdev->hdev,
1027 hid_reportid_size_map[i], 1)) {
1028 dbg_hid("hid_input_report error sending null "
1035 static void logi_dj_recv_forward_dj(struct dj_receiver_dev *djrcv_dev,
1036 struct dj_report *dj_report)
1038 /* We are called from atomic context (tasklet && djrcv->lock held) */
1039 struct dj_device *dj_device;
1041 dj_device = djrcv_dev->paired_dj_devices[dj_report->device_index];
1043 if ((dj_report->report_type > ARRAY_SIZE(hid_reportid_size_map) - 1) ||
1044 (hid_reportid_size_map[dj_report->report_type] == 0)) {
1045 dbg_hid("invalid report type:%x\n", dj_report->report_type);
1049 if (hid_input_report(dj_device->hdev,
1050 HID_INPUT_REPORT, &dj_report->report_type,
1051 hid_reportid_size_map[dj_report->report_type], 1)) {
1052 dbg_hid("hid_input_report error\n");
1056 static void logi_dj_recv_forward_report(struct dj_device *dj_dev, u8 *data,
1059 /* We are called from atomic context (tasklet && djrcv->lock held) */
1060 if (hid_input_report(dj_dev->hdev, HID_INPUT_REPORT, data, size, 1))
1061 dbg_hid("hid_input_report error\n");
1064 static void logi_dj_recv_forward_input_report(struct hid_device *hdev,
1067 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
1068 struct dj_device *dj_dev;
1069 unsigned long flags;
1070 u8 report = data[0];
1073 if (report > REPORT_TYPE_RFREPORT_LAST) {
1074 hid_err(hdev, "Unexpected input report number %d\n", report);
1078 spin_lock_irqsave(&djrcv_dev->lock, flags);
1079 for (i = 0; i < (DJ_MAX_PAIRED_DEVICES + DJ_DEVICE_INDEX_MIN); i++) {
1080 dj_dev = djrcv_dev->paired_dj_devices[i];
1081 if (dj_dev && (dj_dev->reports_supported & BIT(report))) {
1082 logi_dj_recv_forward_report(dj_dev, data, size);
1083 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
1088 logi_dj_recv_queue_unknown_work(djrcv_dev);
1089 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
1091 dbg_hid("No dj-devs handling input report number %d\n", report);
1094 static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev,
1095 struct dj_report *dj_report)
1097 struct hid_device *hdev = djrcv_dev->hidpp;
1098 struct hid_report *report;
1099 struct hid_report_enum *output_report_enum;
1100 u8 *data = (u8 *)(&dj_report->device_index);
1103 output_report_enum = &hdev->report_enum[HID_OUTPUT_REPORT];
1104 report = output_report_enum->report_id_hash[REPORT_ID_DJ_SHORT];
1107 hid_err(hdev, "%s: unable to find dj report\n", __func__);
1111 for (i = 0; i < DJREPORT_SHORT_LENGTH - 1; i++)
1112 report->field[0]->value[i] = data[i];
1114 hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
1119 static int logi_dj_recv_query_hidpp_devices(struct dj_receiver_dev *djrcv_dev)
1121 const u8 template[] = {REPORT_ID_HIDPP_SHORT,
1122 HIDPP_RECEIVER_INDEX,
1124 HIDPP_REG_CONNECTION_STATE,
1125 HIDPP_FAKE_DEVICE_ARRIVAL,
1130 hidpp_report = kmemdup(template, sizeof(template), GFP_KERNEL);
1134 retval = hid_hw_raw_request(djrcv_dev->hidpp,
1135 REPORT_ID_HIDPP_SHORT,
1136 hidpp_report, sizeof(template),
1138 HID_REQ_SET_REPORT);
1140 kfree(hidpp_report);
1144 static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
1146 struct dj_report *dj_report;
1149 djrcv_dev->last_query = jiffies;
1151 if (djrcv_dev->type != recvr_type_dj)
1152 return logi_dj_recv_query_hidpp_devices(djrcv_dev);
1154 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
1157 dj_report->report_id = REPORT_ID_DJ_SHORT;
1158 dj_report->device_index = 0xFF;
1159 dj_report->report_type = REPORT_TYPE_CMD_GET_PAIRED_DEVICES;
1160 retval = logi_dj_recv_send_report(djrcv_dev, dj_report);
1166 static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
1169 struct hid_device *hdev = djrcv_dev->hidpp;
1170 struct dj_report *dj_report;
1174 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
1178 if (djrcv_dev->type == recvr_type_dj) {
1179 dj_report->report_id = REPORT_ID_DJ_SHORT;
1180 dj_report->device_index = 0xFF;
1181 dj_report->report_type = REPORT_TYPE_CMD_SWITCH;
1182 dj_report->report_params[CMD_SWITCH_PARAM_DEVBITFIELD] = 0x3F;
1183 dj_report->report_params[CMD_SWITCH_PARAM_TIMEOUT_SECONDS] =
1186 retval = logi_dj_recv_send_report(djrcv_dev, dj_report);
1189 * Ugly sleep to work around a USB 3.0 bug when the receiver is
1190 * still processing the "switch-to-dj" command while we send an
1192 * 50 msec should gives enough time to the receiver to be ready.
1198 * Magical bits to set up hidpp notifications when the dj devices
1199 * are connected/disconnected.
1201 * We can reuse dj_report because HIDPP_REPORT_SHORT_LENGTH is smaller
1202 * than DJREPORT_SHORT_LENGTH.
1204 buf = (u8 *)dj_report;
1206 memset(buf, 0, HIDPP_REPORT_SHORT_LENGTH);
1208 buf[0] = REPORT_ID_HIDPP_SHORT;
1216 hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf,
1217 HIDPP_REPORT_SHORT_LENGTH, HID_OUTPUT_REPORT,
1218 HID_REQ_SET_REPORT);
1225 static int logi_dj_ll_open(struct hid_device *hid)
1227 dbg_hid("%s: %s\n", __func__, hid->phys);
1232 static void logi_dj_ll_close(struct hid_device *hid)
1234 dbg_hid("%s: %s\n", __func__, hid->phys);
1238 * Register 0xB5 is "pairing information". It is solely intended for the
1239 * receiver, so do not overwrite the device index.
1241 static u8 unifying_pairing_query[] = { REPORT_ID_HIDPP_SHORT,
1242 HIDPP_RECEIVER_INDEX,
1243 HIDPP_GET_LONG_REGISTER,
1244 HIDPP_REG_PAIRING_INFORMATION };
1245 static u8 unifying_pairing_answer[] = { REPORT_ID_HIDPP_LONG,
1246 HIDPP_RECEIVER_INDEX,
1247 HIDPP_GET_LONG_REGISTER,
1248 HIDPP_REG_PAIRING_INFORMATION };
1250 static int logi_dj_ll_raw_request(struct hid_device *hid,
1251 unsigned char reportnum, __u8 *buf,
1252 size_t count, unsigned char report_type,
1255 struct dj_device *djdev = hid->driver_data;
1256 struct dj_receiver_dev *djrcv_dev = djdev->dj_receiver_dev;
1260 if ((buf[0] == REPORT_ID_HIDPP_SHORT) ||
1261 (buf[0] == REPORT_ID_HIDPP_LONG) ||
1262 (buf[0] == REPORT_ID_HIDPP_VERY_LONG)) {
1266 /* special case where we should not overwrite
1267 * the device_index */
1268 if (count == 7 && !memcmp(buf, unifying_pairing_query,
1269 sizeof(unifying_pairing_query)))
1270 buf[4] = (buf[4] & 0xf0) | (djdev->device_index - 1);
1272 buf[1] = djdev->device_index;
1273 return hid_hw_raw_request(djrcv_dev->hidpp, reportnum, buf,
1274 count, report_type, reqtype);
1277 if (buf[0] != REPORT_TYPE_LEDS)
1280 if (djrcv_dev->type != recvr_type_dj && count >= 2) {
1281 if (!djrcv_dev->keyboard) {
1282 hid_warn(hid, "Received REPORT_TYPE_LEDS request before the keyboard interface was enumerated\n");
1285 /* usbhid overrides the report ID and ignores the first byte */
1286 return hid_hw_raw_request(djrcv_dev->keyboard, 0, buf, count,
1287 report_type, reqtype);
1290 out_buf = kzalloc(DJREPORT_SHORT_LENGTH, GFP_ATOMIC);
1294 if (count > DJREPORT_SHORT_LENGTH - 2)
1295 count = DJREPORT_SHORT_LENGTH - 2;
1297 out_buf[0] = REPORT_ID_DJ_SHORT;
1298 out_buf[1] = djdev->device_index;
1299 memcpy(out_buf + 2, buf, count);
1301 ret = hid_hw_raw_request(djrcv_dev->hidpp, out_buf[0], out_buf,
1302 DJREPORT_SHORT_LENGTH, report_type, reqtype);
1308 static void rdcat(char *rdesc, unsigned int *rsize, const char *data, unsigned int size)
1310 memcpy(rdesc + *rsize, data, size);
1314 static int logi_dj_ll_parse(struct hid_device *hid)
1316 struct dj_device *djdev = hid->driver_data;
1317 unsigned int rsize = 0;
1321 dbg_hid("%s\n", __func__);
1323 djdev->hdev->version = 0x0111;
1324 djdev->hdev->country = 0x00;
1326 rdesc = kmalloc(MAX_RDESC_SIZE, GFP_KERNEL);
1330 if (djdev->reports_supported & STD_KEYBOARD) {
1331 dbg_hid("%s: sending a kbd descriptor, reports_supported: %llx\n",
1332 __func__, djdev->reports_supported);
1333 rdcat(rdesc, &rsize, kbd_descriptor, sizeof(kbd_descriptor));
1336 if (djdev->reports_supported & STD_MOUSE) {
1337 dbg_hid("%s: sending a mouse descriptor, reports_supported: %llx\n",
1338 __func__, djdev->reports_supported);
1339 if (djdev->dj_receiver_dev->type == recvr_type_gaming_hidpp ||
1340 djdev->dj_receiver_dev->type == recvr_type_mouse_only)
1341 rdcat(rdesc, &rsize, mse_high_res_descriptor,
1342 sizeof(mse_high_res_descriptor));
1343 else if (djdev->dj_receiver_dev->type == recvr_type_27mhz)
1344 rdcat(rdesc, &rsize, mse_27mhz_descriptor,
1345 sizeof(mse_27mhz_descriptor));
1346 else if (djdev->dj_receiver_dev->type == recvr_type_bluetooth)
1347 rdcat(rdesc, &rsize, mse_bluetooth_descriptor,
1348 sizeof(mse_bluetooth_descriptor));
1350 rdcat(rdesc, &rsize, mse_descriptor,
1351 sizeof(mse_descriptor));
1354 if (djdev->reports_supported & MULTIMEDIA) {
1355 dbg_hid("%s: sending a multimedia report descriptor: %llx\n",
1356 __func__, djdev->reports_supported);
1357 rdcat(rdesc, &rsize, consumer_descriptor, sizeof(consumer_descriptor));
1360 if (djdev->reports_supported & POWER_KEYS) {
1361 dbg_hid("%s: sending a power keys report descriptor: %llx\n",
1362 __func__, djdev->reports_supported);
1363 rdcat(rdesc, &rsize, syscontrol_descriptor, sizeof(syscontrol_descriptor));
1366 if (djdev->reports_supported & MEDIA_CENTER) {
1367 dbg_hid("%s: sending a media center report descriptor: %llx\n",
1368 __func__, djdev->reports_supported);
1369 rdcat(rdesc, &rsize, media_descriptor, sizeof(media_descriptor));
1372 if (djdev->reports_supported & KBD_LEDS) {
1373 dbg_hid("%s: need to send kbd leds report descriptor: %llx\n",
1374 __func__, djdev->reports_supported);
1377 if (djdev->reports_supported & HIDPP) {
1378 rdcat(rdesc, &rsize, hidpp_descriptor,
1379 sizeof(hidpp_descriptor));
1382 retval = hid_parse_report(hid, rdesc, rsize);
1388 static int logi_dj_ll_start(struct hid_device *hid)
1390 dbg_hid("%s\n", __func__);
1394 static void logi_dj_ll_stop(struct hid_device *hid)
1396 dbg_hid("%s\n", __func__);
1400 static struct hid_ll_driver logi_dj_ll_driver = {
1401 .parse = logi_dj_ll_parse,
1402 .start = logi_dj_ll_start,
1403 .stop = logi_dj_ll_stop,
1404 .open = logi_dj_ll_open,
1405 .close = logi_dj_ll_close,
1406 .raw_request = logi_dj_ll_raw_request,
1409 static int logi_dj_dj_event(struct hid_device *hdev,
1410 struct hid_report *report, u8 *data,
1413 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
1414 struct dj_report *dj_report = (struct dj_report *) data;
1415 unsigned long flags;
1418 * Here we receive all data coming from iface 2, there are 3 cases:
1420 * 1) Data is intended for this driver i. e. data contains arrival,
1421 * departure, etc notifications, in which case we queue them for delayed
1422 * processing by the work queue. We return 1 to hid-core as no further
1423 * processing is required from it.
1425 * 2) Data informs a connection change, if the change means rf link
1426 * loss, then we must send a null report to the upper layer to discard
1427 * potentially pressed keys that may be repeated forever by the input
1428 * layer. Return 1 to hid-core as no further processing is required.
1430 * 3) Data is an actual input event from a paired DJ device in which
1431 * case we forward it to the correct hid device (via hid_input_report()
1432 * ) and return 1 so hid-core does not anything else with it.
1435 if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) ||
1436 (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) {
1438 * Device index is wrong, bail out.
1439 * This driver can ignore safely the receiver notifications,
1440 * so ignore those reports too.
1442 if (dj_report->device_index != DJ_RECEIVER_INDEX)
1443 hid_err(hdev, "%s: invalid device index:%d\n",
1444 __func__, dj_report->device_index);
1448 spin_lock_irqsave(&djrcv_dev->lock, flags);
1450 if (!djrcv_dev->paired_dj_devices[dj_report->device_index]) {
1451 /* received an event for an unknown device, bail out */
1452 logi_dj_recv_queue_notification(djrcv_dev, dj_report);
1456 switch (dj_report->report_type) {
1457 case REPORT_TYPE_NOTIF_DEVICE_PAIRED:
1458 /* pairing notifications are handled above the switch */
1460 case REPORT_TYPE_NOTIF_DEVICE_UNPAIRED:
1461 logi_dj_recv_queue_notification(djrcv_dev, dj_report);
1463 case REPORT_TYPE_NOTIF_CONNECTION_STATUS:
1464 if (dj_report->report_params[CONNECTION_STATUS_PARAM_STATUS] ==
1466 logi_dj_recv_forward_null_report(djrcv_dev, dj_report);
1470 logi_dj_recv_forward_dj(djrcv_dev, dj_report);
1474 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
1479 static int logi_dj_hidpp_event(struct hid_device *hdev,
1480 struct hid_report *report, u8 *data,
1483 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
1484 struct hidpp_event *hidpp_report = (struct hidpp_event *) data;
1485 struct dj_device *dj_dev;
1486 unsigned long flags;
1487 u8 device_index = hidpp_report->device_index;
1489 if (device_index == HIDPP_RECEIVER_INDEX) {
1490 /* special case were the device wants to know its unifying
1492 if (size == HIDPP_REPORT_LONG_LENGTH &&
1493 !memcmp(data, unifying_pairing_answer,
1494 sizeof(unifying_pairing_answer)))
1495 device_index = (data[4] & 0x0F) + 1;
1501 * Data is from the HID++ collection, in this case, we forward the
1502 * data to the corresponding child dj device and return 0 to hid-core
1503 * so he data also goes to the hidraw device of the receiver. This
1504 * allows a user space application to implement the full HID++ routing
1508 if ((device_index < DJ_DEVICE_INDEX_MIN) ||
1509 (device_index > DJ_DEVICE_INDEX_MAX)) {
1511 * Device index is wrong, bail out.
1512 * This driver can ignore safely the receiver notifications,
1513 * so ignore those reports too.
1515 hid_err(hdev, "%s: invalid device index:%d\n", __func__,
1516 hidpp_report->device_index);
1520 spin_lock_irqsave(&djrcv_dev->lock, flags);
1522 dj_dev = djrcv_dev->paired_dj_devices[device_index];
1525 * With 27 MHz receivers, we do not get an explicit unpair event,
1526 * remove the old device if the user has paired a *different* device.
1528 if (djrcv_dev->type == recvr_type_27mhz && dj_dev &&
1529 hidpp_report->sub_id == REPORT_TYPE_NOTIF_DEVICE_CONNECTED &&
1530 hidpp_report->params[HIDPP_PARAM_PROTO_TYPE] == 0x02 &&
1531 hidpp_report->params[HIDPP_PARAM_27MHZ_DEVID] !=
1532 dj_dev->hdev->product) {
1533 struct dj_workitem workitem = {
1534 .device_index = hidpp_report->device_index,
1535 .type = WORKITEM_TYPE_UNPAIRED,
1537 kfifo_in(&djrcv_dev->notif_fifo, &workitem, sizeof(workitem));
1538 /* logi_hidpp_recv_queue_notif will queue the work */
1543 logi_dj_recv_forward_report(dj_dev, data, size);
1545 if (hidpp_report->sub_id == REPORT_TYPE_NOTIF_DEVICE_CONNECTED)
1546 logi_hidpp_recv_queue_notif(hdev, hidpp_report);
1548 logi_dj_recv_queue_unknown_work(djrcv_dev);
1551 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
1556 static int logi_dj_raw_event(struct hid_device *hdev,
1557 struct hid_report *report, u8 *data,
1560 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
1561 dbg_hid("%s, size:%d\n", __func__, size);
1566 if (!hdev->report_enum[HID_INPUT_REPORT].numbered) {
1568 if (djrcv_dev->unnumbered_application == HID_GD_KEYBOARD) {
1570 * For the keyboard, we can reuse the same report by
1571 * using the second byte which is constant in the USB
1572 * HID report descriptor.
1575 data[0] = REPORT_TYPE_KEYBOARD;
1577 logi_dj_recv_forward_input_report(hdev, data, size);
1579 /* restore previous state */
1584 * Mouse-only receivers send unnumbered mouse data. The 27 MHz
1585 * receiver uses 6 byte packets, the nano receiver 8 bytes.
1587 if (djrcv_dev->unnumbered_application == HID_GD_MOUSE &&
1591 /* Prepend report id */
1592 mouse_report[0] = REPORT_TYPE_MOUSE;
1593 memcpy(mouse_report + 1, data, size);
1594 logi_dj_recv_forward_input_report(hdev, mouse_report,
1602 case REPORT_ID_DJ_SHORT:
1603 if (size != DJREPORT_SHORT_LENGTH) {
1604 hid_err(hdev, "Short DJ report bad size (%d)", size);
1607 return logi_dj_dj_event(hdev, report, data, size);
1608 case REPORT_ID_DJ_LONG:
1609 if (size != DJREPORT_LONG_LENGTH) {
1610 hid_err(hdev, "Long DJ report bad size (%d)", size);
1613 return logi_dj_dj_event(hdev, report, data, size);
1614 case REPORT_ID_HIDPP_SHORT:
1615 if (size != HIDPP_REPORT_SHORT_LENGTH) {
1616 hid_err(hdev, "Short HID++ report bad size (%d)", size);
1619 return logi_dj_hidpp_event(hdev, report, data, size);
1620 case REPORT_ID_HIDPP_LONG:
1621 if (size != HIDPP_REPORT_LONG_LENGTH) {
1622 hid_err(hdev, "Long HID++ report bad size (%d)", size);
1625 return logi_dj_hidpp_event(hdev, report, data, size);
1628 logi_dj_recv_forward_input_report(hdev, data, size);
1633 static int logi_dj_probe(struct hid_device *hdev,
1634 const struct hid_device_id *id)
1636 struct hid_report_enum *rep_enum;
1637 struct hid_report *rep;
1638 struct dj_receiver_dev *djrcv_dev;
1639 struct usb_interface *intf;
1640 unsigned int no_dj_interfaces = 0;
1641 bool has_hidpp = false;
1642 unsigned long flags;
1646 * Call to usbhid to fetch the HID descriptors of the current
1647 * interface subsequently call to the hid/hid-core to parse the
1648 * fetched descriptors.
1650 retval = hid_parse(hdev);
1652 hid_err(hdev, "%s: parse failed\n", __func__);
1657 * Some KVMs add an extra interface for e.g. mouse emulation. If we
1658 * treat these as logitech-dj interfaces then this causes input events
1659 * reported through this extra interface to not be reported correctly.
1660 * To avoid this, we treat these as generic-hid devices.
1662 switch (id->driver_data) {
1663 case recvr_type_dj: no_dj_interfaces = 3; break;
1664 case recvr_type_hidpp: no_dj_interfaces = 2; break;
1665 case recvr_type_gaming_hidpp: no_dj_interfaces = 3; break;
1666 case recvr_type_mouse_only: no_dj_interfaces = 2; break;
1667 case recvr_type_27mhz: no_dj_interfaces = 2; break;
1668 case recvr_type_bluetooth: no_dj_interfaces = 2; break;
1670 if (hid_is_using_ll_driver(hdev, &usb_hid_driver)) {
1671 intf = to_usb_interface(hdev->dev.parent);
1672 if (intf && intf->altsetting->desc.bInterfaceNumber >=
1674 hdev->quirks |= HID_QUIRK_INPUT_PER_APP;
1675 return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
1679 rep_enum = &hdev->report_enum[HID_INPUT_REPORT];
1681 /* no input reports, bail out */
1682 if (list_empty(&rep_enum->report_list))
1686 * Check for the HID++ application.
1687 * Note: we should theoretically check for HID++ and DJ
1688 * collections, but this will do.
1690 list_for_each_entry(rep, &rep_enum->report_list, list) {
1691 if (rep->application == 0xff000001)
1696 * Ignore interfaces without DJ/HID++ collection, they will not carry
1697 * any data, dont create any hid_device for them.
1699 if (!has_hidpp && id->driver_data == recvr_type_dj)
1702 /* get the current application attached to the node */
1703 rep = list_first_entry(&rep_enum->report_list, struct hid_report, list);
1704 djrcv_dev = dj_get_receiver_dev(hdev, id->driver_data,
1705 rep->application, has_hidpp);
1707 hid_err(hdev, "%s: dj_get_receiver_dev failed\n", __func__);
1711 if (!rep_enum->numbered)
1712 djrcv_dev->unnumbered_application = rep->application;
1714 /* Starts the usb device and connects to upper interfaces hiddev and
1716 retval = hid_hw_start(hdev, HID_CONNECT_HIDRAW|HID_CONNECT_HIDDEV);
1718 hid_err(hdev, "%s: hid_hw_start returned error\n", __func__);
1719 goto hid_hw_start_fail;
1723 retval = logi_dj_recv_switch_to_dj_mode(djrcv_dev, 0);
1725 hid_err(hdev, "%s: logi_dj_recv_switch_to_dj_mode returned error:%d\n",
1727 goto switch_to_dj_mode_fail;
1731 /* This is enabling the polling urb on the IN endpoint */
1732 retval = hid_hw_open(hdev);
1734 hid_err(hdev, "%s: hid_hw_open returned error:%d\n",
1739 /* Allow incoming packets to arrive: */
1740 hid_device_io_start(hdev);
1743 spin_lock_irqsave(&djrcv_dev->lock, flags);
1744 djrcv_dev->ready = true;
1745 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
1746 retval = logi_dj_recv_query_paired_devices(djrcv_dev);
1748 hid_err(hdev, "%s: logi_dj_recv_query_paired_devices error:%d\n",
1750 goto logi_dj_recv_query_paired_devices_failed;
1756 logi_dj_recv_query_paired_devices_failed:
1760 switch_to_dj_mode_fail:
1764 dj_put_receiver_dev(hdev);
1769 static int logi_dj_reset_resume(struct hid_device *hdev)
1772 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
1774 if (!djrcv_dev || djrcv_dev->hidpp != hdev)
1777 retval = logi_dj_recv_switch_to_dj_mode(djrcv_dev, 0);
1779 hid_err(hdev, "%s: logi_dj_recv_switch_to_dj_mode returned error:%d\n",
1787 static void logi_dj_remove(struct hid_device *hdev)
1789 struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev);
1790 struct dj_device *dj_dev;
1791 unsigned long flags;
1794 dbg_hid("%s\n", __func__);
1797 return hid_hw_stop(hdev);
1800 * This ensures that if the work gets requeued from another
1801 * interface of the same receiver it will be a no-op.
1803 spin_lock_irqsave(&djrcv_dev->lock, flags);
1804 djrcv_dev->ready = false;
1805 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
1807 cancel_work_sync(&djrcv_dev->work);
1813 * For proper operation we need access to all interfaces, so we destroy
1814 * the paired devices when we're unbound from any interface.
1816 * Note we may still be bound to other interfaces, sharing the same
1817 * djrcv_dev, so we need locking here.
1819 for (i = 0; i < (DJ_MAX_PAIRED_DEVICES + DJ_DEVICE_INDEX_MIN); i++) {
1820 spin_lock_irqsave(&djrcv_dev->lock, flags);
1821 dj_dev = djrcv_dev->paired_dj_devices[i];
1822 djrcv_dev->paired_dj_devices[i] = NULL;
1823 spin_unlock_irqrestore(&djrcv_dev->lock, flags);
1824 if (dj_dev != NULL) {
1825 hid_destroy_device(dj_dev->hdev);
1830 dj_put_receiver_dev(hdev);
1833 static const struct hid_device_id logi_dj_receivers[] = {
1834 {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1835 USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER),
1836 .driver_data = recvr_type_dj},
1837 {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1838 USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2),
1839 .driver_data = recvr_type_dj},
1840 { /* Logitech Nano mouse only receiver */
1841 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1842 USB_DEVICE_ID_LOGITECH_NANO_RECEIVER),
1843 .driver_data = recvr_type_mouse_only},
1844 { /* Logitech Nano (non DJ) receiver */
1845 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1846 USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_2),
1847 .driver_data = recvr_type_hidpp},
1848 { /* Logitech gaming receiver (0xc539) */
1849 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1850 USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_GAMING),
1851 .driver_data = recvr_type_gaming_hidpp},
1852 { /* Logitech 27 MHz HID++ 1.0 receiver (0xc517) */
1853 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1854 USB_DEVICE_ID_S510_RECEIVER_2),
1855 .driver_data = recvr_type_27mhz},
1856 { /* Logitech 27 MHz HID++ 1.0 mouse-only receiver (0xc51b) */
1857 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1858 USB_DEVICE_ID_LOGITECH_27MHZ_MOUSE_RECEIVER),
1859 .driver_data = recvr_type_27mhz},
1860 { /* Logitech MX5000 HID++ / bluetooth receiver keyboard intf. */
1861 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1863 .driver_data = recvr_type_bluetooth},
1864 { /* Logitech MX5000 HID++ / bluetooth receiver mouse intf. */
1865 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1867 .driver_data = recvr_type_bluetooth},
1868 { /* Logitech MX5500 HID++ / bluetooth receiver keyboard intf. */
1869 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1871 .driver_data = recvr_type_bluetooth},
1872 { /* Logitech MX5500 HID++ / bluetooth receiver mouse intf. */
1873 HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
1875 .driver_data = recvr_type_bluetooth},
1879 MODULE_DEVICE_TABLE(hid, logi_dj_receivers);
1881 static struct hid_driver logi_djreceiver_driver = {
1882 .name = "logitech-djreceiver",
1883 .id_table = logi_dj_receivers,
1884 .probe = logi_dj_probe,
1885 .remove = logi_dj_remove,
1886 .raw_event = logi_dj_raw_event,
1888 .reset_resume = logi_dj_reset_resume,
1892 module_hid_driver(logi_djreceiver_driver);
1894 MODULE_LICENSE("GPL");
1895 MODULE_AUTHOR("Logitech");
1896 MODULE_AUTHOR("Nestor Lopez Casado");
1897 MODULE_AUTHOR("nlopezcasad@logitech.com");