]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/hid/hid-logitech-hidpp.c
HID: logitech-hidpp: prefix the name with "Logitech"
[mirror_ubuntu-artful-kernel.git] / drivers / hid / hid-logitech-hidpp.c
CommitLineData
2f31c525
BT
1/*
2 * HIDPP protocol for Logitech Unifying receivers
3 *
4 * Copyright (c) 2011 Logitech (c)
5 * Copyright (c) 2012-2013 Google (c)
6 * Copyright (c) 2013-2014 Red Hat Inc.
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; version 2 of the License.
13 */
14
15#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
16
17#include <linux/device.h>
18#include <linux/hid.h>
19#include <linux/module.h>
20#include <linux/slab.h>
21#include <linux/sched.h>
22#include <linux/kfifo.h>
23#include <linux/input/mt.h>
24#include <asm/unaligned.h>
25#include "hid-ids.h"
26
27MODULE_LICENSE("GPL");
28MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>");
29MODULE_AUTHOR("Nestor Lopez Casado <nlopezcasad@logitech.com>");
30
31#define REPORT_ID_HIDPP_SHORT 0x10
32#define REPORT_ID_HIDPP_LONG 0x11
33
34#define HIDPP_REPORT_SHORT_LENGTH 7
35#define HIDPP_REPORT_LONG_LENGTH 20
36
37#define HIDPP_QUIRK_CLASS_WTP BIT(0)
38
c39e3d5f
BT
39/* bits 1..20 are reserved for classes */
40#define HIDPP_QUIRK_DELAYED_INIT BIT(21)
57ac86cf 41#define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22)
3a61e975 42#define HIDPP_QUIRK_MULTI_INPUT BIT(23)
c39e3d5f 43
2f31c525
BT
44/*
45 * There are two hidpp protocols in use, the first version hidpp10 is known
46 * as register access protocol or RAP, the second version hidpp20 is known as
47 * feature access protocol or FAP
48 *
49 * Most older devices (including the Unifying usb receiver) use the RAP protocol
50 * where as most newer devices use the FAP protocol. Both protocols are
51 * compatible with the underlying transport, which could be usb, Unifiying, or
52 * bluetooth. The message lengths are defined by the hid vendor specific report
53 * descriptor for the HIDPP_SHORT report type (total message lenth 7 bytes) and
54 * the HIDPP_LONG report type (total message length 20 bytes)
55 *
56 * The RAP protocol uses both report types, whereas the FAP only uses HIDPP_LONG
57 * messages. The Unifying receiver itself responds to RAP messages (device index
58 * is 0xFF for the receiver), and all messages (short or long) with a device
59 * index between 1 and 6 are passed untouched to the corresponding paired
60 * Unifying device.
61 *
62 * The paired device can be RAP or FAP, it will receive the message untouched
63 * from the Unifiying receiver.
64 */
65
66struct fap {
67 u8 feature_index;
68 u8 funcindex_clientid;
69 u8 params[HIDPP_REPORT_LONG_LENGTH - 4U];
70};
71
72struct rap {
73 u8 sub_id;
74 u8 reg_address;
75 u8 params[HIDPP_REPORT_LONG_LENGTH - 4U];
76};
77
78struct hidpp_report {
79 u8 report_id;
80 u8 device_index;
81 union {
82 struct fap fap;
83 struct rap rap;
84 u8 rawbytes[sizeof(struct fap)];
85 };
86} __packed;
87
88struct hidpp_device {
89 struct hid_device *hid_dev;
90 struct mutex send_mutex;
91 void *send_receive_buf;
92 wait_queue_head_t wait;
93 bool answer_available;
94 u8 protocol_major;
95 u8 protocol_minor;
96
97 void *private_data;
98
c39e3d5f
BT
99 struct work_struct work;
100 struct kfifo delayed_work_fifo;
101 atomic_t connected;
102 struct input_dev *delayed_input;
103
2f31c525
BT
104 unsigned long quirks;
105};
106
107
108#define HIDPP_ERROR 0x8f
109#define HIDPP_ERROR_SUCCESS 0x00
110#define HIDPP_ERROR_INVALID_SUBID 0x01
111#define HIDPP_ERROR_INVALID_ADRESS 0x02
112#define HIDPP_ERROR_INVALID_VALUE 0x03
113#define HIDPP_ERROR_CONNECT_FAIL 0x04
114#define HIDPP_ERROR_TOO_MANY_DEVICES 0x05
115#define HIDPP_ERROR_ALREADY_EXISTS 0x06
116#define HIDPP_ERROR_BUSY 0x07
117#define HIDPP_ERROR_UNKNOWN_DEVICE 0x08
118#define HIDPP_ERROR_RESOURCE_ERROR 0x09
119#define HIDPP_ERROR_REQUEST_UNAVAILABLE 0x0a
120#define HIDPP_ERROR_INVALID_PARAM_VALUE 0x0b
121#define HIDPP_ERROR_WRONG_PIN_CODE 0x0c
122
c39e3d5f
BT
123static void hidpp_connect_event(struct hidpp_device *hidpp_dev);
124
2f31c525
BT
125static int __hidpp_send_report(struct hid_device *hdev,
126 struct hidpp_report *hidpp_report)
127{
128 int fields_count, ret;
129
130 switch (hidpp_report->report_id) {
131 case REPORT_ID_HIDPP_SHORT:
132 fields_count = HIDPP_REPORT_SHORT_LENGTH;
133 break;
134 case REPORT_ID_HIDPP_LONG:
135 fields_count = HIDPP_REPORT_LONG_LENGTH;
136 break;
137 default:
138 return -ENODEV;
139 }
140
141 /*
142 * set the device_index as the receiver, it will be overwritten by
143 * hid_hw_request if needed
144 */
145 hidpp_report->device_index = 0xff;
146
147 ret = hid_hw_raw_request(hdev, hidpp_report->report_id,
148 (u8 *)hidpp_report, fields_count, HID_OUTPUT_REPORT,
149 HID_REQ_SET_REPORT);
150
151 return ret == fields_count ? 0 : -1;
152}
153
8c9952b2
BT
154/**
155 * hidpp_send_message_sync() returns 0 in case of success, and something else
156 * in case of a failure.
157 * - If ' something else' is positive, that means that an error has been raised
158 * by the protocol itself.
159 * - If ' something else' is negative, that means that we had a classic error
160 * (-ENOMEM, -EPIPE, etc...)
161 */
2f31c525
BT
162static int hidpp_send_message_sync(struct hidpp_device *hidpp,
163 struct hidpp_report *message,
164 struct hidpp_report *response)
165{
166 int ret;
167
168 mutex_lock(&hidpp->send_mutex);
169
170 hidpp->send_receive_buf = response;
171 hidpp->answer_available = false;
172
173 /*
174 * So that we can later validate the answer when it arrives
175 * in hidpp_raw_event
176 */
177 *response = *message;
178
179 ret = __hidpp_send_report(hidpp->hid_dev, message);
180
181 if (ret) {
182 dbg_hid("__hidpp_send_report returned err: %d\n", ret);
183 memset(response, 0, sizeof(struct hidpp_report));
184 goto exit;
185 }
186
187 if (!wait_event_timeout(hidpp->wait, hidpp->answer_available,
188 5*HZ)) {
189 dbg_hid("%s:timeout waiting for response\n", __func__);
190 memset(response, 0, sizeof(struct hidpp_report));
191 ret = -ETIMEDOUT;
192 }
193
194 if (response->report_id == REPORT_ID_HIDPP_SHORT &&
195 response->fap.feature_index == HIDPP_ERROR) {
196 ret = response->fap.params[1];
197 dbg_hid("__hidpp_send_report got hidpp error %02X\n", ret);
198 goto exit;
199 }
200
201exit:
202 mutex_unlock(&hidpp->send_mutex);
203 return ret;
204
205}
206
207static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp,
208 u8 feat_index, u8 funcindex_clientid, u8 *params, int param_count,
209 struct hidpp_report *response)
210{
3e7830ce 211 struct hidpp_report *message;
2f31c525
BT
212 int ret;
213
214 if (param_count > sizeof(message->fap.params))
215 return -EINVAL;
216
3e7830ce
DC
217 message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL);
218 if (!message)
219 return -ENOMEM;
2f31c525
BT
220 message->report_id = REPORT_ID_HIDPP_LONG;
221 message->fap.feature_index = feat_index;
222 message->fap.funcindex_clientid = funcindex_clientid;
223 memcpy(&message->fap.params, params, param_count);
224
225 ret = hidpp_send_message_sync(hidpp, message, response);
226 kfree(message);
227 return ret;
228}
229
33797820
BT
230static int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev,
231 u8 report_id, u8 sub_id, u8 reg_address, u8 *params, int param_count,
232 struct hidpp_report *response)
233{
3e7830ce 234 struct hidpp_report *message;
33797820
BT
235 int ret;
236
237 if ((report_id != REPORT_ID_HIDPP_SHORT) &&
238 (report_id != REPORT_ID_HIDPP_LONG))
239 return -EINVAL;
240
241 if (param_count > sizeof(message->rap.params))
242 return -EINVAL;
243
3e7830ce
DC
244 message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL);
245 if (!message)
246 return -ENOMEM;
33797820
BT
247 message->report_id = report_id;
248 message->rap.sub_id = sub_id;
249 message->rap.reg_address = reg_address;
250 memcpy(&message->rap.params, params, param_count);
251
252 ret = hidpp_send_message_sync(hidpp_dev, message, response);
253 kfree(message);
254 return ret;
255}
256
c39e3d5f
BT
257static void delayed_work_cb(struct work_struct *work)
258{
259 struct hidpp_device *hidpp = container_of(work, struct hidpp_device,
260 work);
261 hidpp_connect_event(hidpp);
262}
263
2f31c525
BT
264static inline bool hidpp_match_answer(struct hidpp_report *question,
265 struct hidpp_report *answer)
266{
267 return (answer->fap.feature_index == question->fap.feature_index) &&
268 (answer->fap.funcindex_clientid == question->fap.funcindex_clientid);
269}
270
271static inline bool hidpp_match_error(struct hidpp_report *question,
272 struct hidpp_report *answer)
273{
274 return (answer->fap.feature_index == HIDPP_ERROR) &&
275 (answer->fap.funcindex_clientid == question->fap.feature_index) &&
276 (answer->fap.params[0] == question->fap.funcindex_clientid);
277}
278
c39e3d5f
BT
279static inline bool hidpp_report_is_connect_event(struct hidpp_report *report)
280{
281 return (report->report_id == REPORT_ID_HIDPP_SHORT) &&
282 (report->rap.sub_id == 0x41);
283}
284
b1ac9487
BT
285/**
286 * hidpp_prefix_name() prefixes the current given name with "Logitech ".
287 */
288static void hidpp_prefix_name(char **name, int name_length)
289{
290#define PREFIX_LENGTH 9 /* "Logitech " */
291
292 int new_length;
293 char *new_name;
294
295 if (name_length > PREFIX_LENGTH &&
296 strncmp(*name, "Logitech ", PREFIX_LENGTH) == 0)
297 /* The prefix has is already in the name */
298 return;
299
300 new_length = PREFIX_LENGTH + name_length;
301 new_name = kzalloc(new_length, GFP_KERNEL);
302 if (!new_name)
303 return;
304
305 snprintf(new_name, new_length, "Logitech %s", *name);
306
307 kfree(*name);
308
309 *name = new_name;
310}
311
33797820
BT
312/* -------------------------------------------------------------------------- */
313/* HIDP++ 1.0 commands */
314/* -------------------------------------------------------------------------- */
315
316#define HIDPP_SET_REGISTER 0x80
317#define HIDPP_GET_REGISTER 0x81
318#define HIDPP_SET_LONG_REGISTER 0x82
319#define HIDPP_GET_LONG_REGISTER 0x83
320
321#define HIDPP_REG_PAIRING_INFORMATION 0xB5
322#define DEVICE_NAME 0x40
323
324static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev)
325{
326 struct hidpp_report response;
327 int ret;
328 /* hid-logitech-dj is in charge of setting the right device index */
329 u8 params[1] = { DEVICE_NAME };
330 char *name;
331 int len;
332
333 ret = hidpp_send_rap_command_sync(hidpp_dev,
334 REPORT_ID_HIDPP_SHORT,
335 HIDPP_GET_LONG_REGISTER,
336 HIDPP_REG_PAIRING_INFORMATION,
337 params, 1, &response);
338 if (ret)
339 return NULL;
340
341 len = response.rap.params[1];
342
3a034a7a
PW
343 if (2 + len > sizeof(response.rap.params))
344 return NULL;
345
33797820
BT
346 name = kzalloc(len + 1, GFP_KERNEL);
347 if (!name)
348 return NULL;
349
350 memcpy(name, &response.rap.params[2], len);
b1ac9487
BT
351
352 /* include the terminating '\0' */
353 hidpp_prefix_name(&name, len + 1);
354
33797820
BT
355 return name;
356}
357
2f31c525
BT
358/* -------------------------------------------------------------------------- */
359/* 0x0000: Root */
360/* -------------------------------------------------------------------------- */
361
362#define HIDPP_PAGE_ROOT 0x0000
363#define HIDPP_PAGE_ROOT_IDX 0x00
364
365#define CMD_ROOT_GET_FEATURE 0x01
366#define CMD_ROOT_GET_PROTOCOL_VERSION 0x11
367
368static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature,
369 u8 *feature_index, u8 *feature_type)
370{
371 struct hidpp_report response;
372 int ret;
373 u8 params[2] = { feature >> 8, feature & 0x00FF };
374
375 ret = hidpp_send_fap_command_sync(hidpp,
376 HIDPP_PAGE_ROOT_IDX,
377 CMD_ROOT_GET_FEATURE,
378 params, 2, &response);
379 if (ret)
380 return ret;
381
382 *feature_index = response.fap.params[0];
383 *feature_type = response.fap.params[1];
384
385 return ret;
386}
387
388static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp)
389{
390 struct hidpp_report response;
391 int ret;
392
393 ret = hidpp_send_fap_command_sync(hidpp,
394 HIDPP_PAGE_ROOT_IDX,
395 CMD_ROOT_GET_PROTOCOL_VERSION,
396 NULL, 0, &response);
397
552f12eb 398 if (ret == HIDPP_ERROR_INVALID_SUBID) {
2f31c525
BT
399 hidpp->protocol_major = 1;
400 hidpp->protocol_minor = 0;
401 return 0;
402 }
403
552f12eb
BT
404 /* the device might not be connected */
405 if (ret == HIDPP_ERROR_RESOURCE_ERROR)
406 return -EIO;
407
8c9952b2
BT
408 if (ret > 0) {
409 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
410 __func__, ret);
411 return -EPROTO;
412 }
2f31c525 413 if (ret)
8c9952b2 414 return ret;
2f31c525
BT
415
416 hidpp->protocol_major = response.fap.params[0];
417 hidpp->protocol_minor = response.fap.params[1];
418
419 return ret;
420}
421
422static bool hidpp_is_connected(struct hidpp_device *hidpp)
423{
424 int ret;
425
426 ret = hidpp_root_get_protocol_version(hidpp);
427 if (!ret)
428 hid_dbg(hidpp->hid_dev, "HID++ %u.%u device connected.\n",
429 hidpp->protocol_major, hidpp->protocol_minor);
430 return ret == 0;
431}
432
433/* -------------------------------------------------------------------------- */
434/* 0x0005: GetDeviceNameType */
435/* -------------------------------------------------------------------------- */
436
437#define HIDPP_PAGE_GET_DEVICE_NAME_TYPE 0x0005
438
439#define CMD_GET_DEVICE_NAME_TYPE_GET_COUNT 0x01
440#define CMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME 0x11
441#define CMD_GET_DEVICE_NAME_TYPE_GET_TYPE 0x21
442
443static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp,
444 u8 feature_index, u8 *nameLength)
445{
446 struct hidpp_report response;
447 int ret;
448
449 ret = hidpp_send_fap_command_sync(hidpp, feature_index,
450 CMD_GET_DEVICE_NAME_TYPE_GET_COUNT, NULL, 0, &response);
451
8c9952b2
BT
452 if (ret > 0) {
453 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
454 __func__, ret);
455 return -EPROTO;
456 }
2f31c525 457 if (ret)
8c9952b2 458 return ret;
2f31c525
BT
459
460 *nameLength = response.fap.params[0];
461
462 return ret;
463}
464
465static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp,
466 u8 feature_index, u8 char_index, char *device_name, int len_buf)
467{
468 struct hidpp_report response;
469 int ret, i;
470 int count;
471
472 ret = hidpp_send_fap_command_sync(hidpp, feature_index,
473 CMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME, &char_index, 1,
474 &response);
475
8c9952b2
BT
476 if (ret > 0) {
477 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
478 __func__, ret);
479 return -EPROTO;
480 }
2f31c525 481 if (ret)
8c9952b2 482 return ret;
2f31c525
BT
483
484 if (response.report_id == REPORT_ID_HIDPP_LONG)
485 count = HIDPP_REPORT_LONG_LENGTH - 4;
486 else
487 count = HIDPP_REPORT_SHORT_LENGTH - 4;
488
489 if (len_buf < count)
490 count = len_buf;
491
492 for (i = 0; i < count; i++)
493 device_name[i] = response.fap.params[i];
494
495 return count;
496}
497
02cc097e 498static char *hidpp_get_device_name(struct hidpp_device *hidpp)
2f31c525
BT
499{
500 u8 feature_type;
501 u8 feature_index;
502 u8 __name_length;
503 char *name;
504 unsigned index = 0;
505 int ret;
506
507 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE,
508 &feature_index, &feature_type);
509 if (ret)
02cc097e 510 return NULL;
2f31c525
BT
511
512 ret = hidpp_devicenametype_get_count(hidpp, feature_index,
513 &__name_length);
514 if (ret)
02cc097e 515 return NULL;
2f31c525
BT
516
517 name = kzalloc(__name_length + 1, GFP_KERNEL);
518 if (!name)
02cc097e 519 return NULL;
2f31c525 520
1430ee73
PW
521 while (index < __name_length) {
522 ret = hidpp_devicenametype_get_device_name(hidpp,
2f31c525
BT
523 feature_index, index, name + index,
524 __name_length - index);
1430ee73
PW
525 if (ret <= 0) {
526 kfree(name);
527 return NULL;
528 }
529 index += ret;
530 }
2f31c525 531
b1ac9487
BT
532 /* include the terminating '\0' */
533 hidpp_prefix_name(&name, __name_length + 1);
534
2f31c525 535 return name;
2f31c525
BT
536}
537
538/* -------------------------------------------------------------------------- */
539/* 0x6100: TouchPadRawXY */
540/* -------------------------------------------------------------------------- */
541
542#define HIDPP_PAGE_TOUCHPAD_RAW_XY 0x6100
543
544#define CMD_TOUCHPAD_GET_RAW_INFO 0x01
586bdc4e
BT
545#define CMD_TOUCHPAD_SET_RAW_REPORT_STATE 0x21
546
547#define EVENT_TOUCHPAD_RAW_XY 0x00
2f31c525
BT
548
549#define TOUCHPAD_RAW_XY_ORIGIN_LOWER_LEFT 0x01
550#define TOUCHPAD_RAW_XY_ORIGIN_UPPER_LEFT 0x03
551
552struct hidpp_touchpad_raw_info {
553 u16 x_size;
554 u16 y_size;
555 u8 z_range;
556 u8 area_range;
557 u8 timestamp_unit;
558 u8 maxcontacts;
559 u8 origin;
560 u16 res;
561};
562
563struct hidpp_touchpad_raw_xy_finger {
564 u8 contact_type;
565 u8 contact_status;
566 u16 x;
567 u16 y;
568 u8 z;
569 u8 area;
570 u8 finger_id;
571};
572
573struct hidpp_touchpad_raw_xy {
574 u16 timestamp;
575 struct hidpp_touchpad_raw_xy_finger fingers[2];
576 u8 spurious_flag;
577 u8 end_of_frame;
578 u8 finger_count;
579 u8 button;
580};
581
582static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp,
583 u8 feature_index, struct hidpp_touchpad_raw_info *raw_info)
584{
585 struct hidpp_report response;
586 int ret;
587 u8 *params = (u8 *)response.fap.params;
588
589 ret = hidpp_send_fap_command_sync(hidpp, feature_index,
590 CMD_TOUCHPAD_GET_RAW_INFO, NULL, 0, &response);
591
8c9952b2
BT
592 if (ret > 0) {
593 hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
594 __func__, ret);
595 return -EPROTO;
596 }
2f31c525 597 if (ret)
8c9952b2 598 return ret;
2f31c525
BT
599
600 raw_info->x_size = get_unaligned_be16(&params[0]);
601 raw_info->y_size = get_unaligned_be16(&params[2]);
602 raw_info->z_range = params[4];
603 raw_info->area_range = params[5];
604 raw_info->maxcontacts = params[7];
605 raw_info->origin = params[8];
606 /* res is given in unit per inch */
607 raw_info->res = get_unaligned_be16(&params[13]) * 2 / 51;
608
609 return ret;
610}
611
586bdc4e
BT
612static int hidpp_touchpad_set_raw_report_state(struct hidpp_device *hidpp_dev,
613 u8 feature_index, bool send_raw_reports,
614 bool sensor_enhanced_settings)
615{
616 struct hidpp_report response;
617
618 /*
619 * Params:
620 * bit 0 - enable raw
621 * bit 1 - 16bit Z, no area
622 * bit 2 - enhanced sensitivity
623 * bit 3 - width, height (4 bits each) instead of area
624 * bit 4 - send raw + gestures (degrades smoothness)
625 * remaining bits - reserved
626 */
627 u8 params = send_raw_reports | (sensor_enhanced_settings << 2);
628
629 return hidpp_send_fap_command_sync(hidpp_dev, feature_index,
630 CMD_TOUCHPAD_SET_RAW_REPORT_STATE, &params, 1, &response);
631}
632
633static void hidpp_touchpad_touch_event(u8 *data,
634 struct hidpp_touchpad_raw_xy_finger *finger)
635{
636 u8 x_m = data[0] << 2;
637 u8 y_m = data[2] << 2;
638
639 finger->x = x_m << 6 | data[1];
640 finger->y = y_m << 6 | data[3];
641
642 finger->contact_type = data[0] >> 6;
643 finger->contact_status = data[2] >> 6;
644
645 finger->z = data[4];
646 finger->area = data[5];
647 finger->finger_id = data[6] >> 4;
648}
649
650static void hidpp_touchpad_raw_xy_event(struct hidpp_device *hidpp_dev,
651 u8 *data, struct hidpp_touchpad_raw_xy *raw_xy)
652{
653 memset(raw_xy, 0, sizeof(struct hidpp_touchpad_raw_xy));
654 raw_xy->end_of_frame = data[8] & 0x01;
655 raw_xy->spurious_flag = (data[8] >> 1) & 0x01;
656 raw_xy->finger_count = data[15] & 0x0f;
657 raw_xy->button = (data[8] >> 2) & 0x01;
658
659 if (raw_xy->finger_count) {
660 hidpp_touchpad_touch_event(&data[2], &raw_xy->fingers[0]);
661 hidpp_touchpad_touch_event(&data[9], &raw_xy->fingers[1]);
662 }
663}
664
2f31c525
BT
665/* ************************************************************************** */
666/* */
667/* Device Support */
668/* */
669/* ************************************************************************** */
670
671/* -------------------------------------------------------------------------- */
672/* Touchpad HID++ devices */
673/* -------------------------------------------------------------------------- */
674
57ac86cf
BT
675#define WTP_MANUAL_RESOLUTION 39
676
2f31c525
BT
677struct wtp_data {
678 struct input_dev *input;
679 u16 x_size, y_size;
680 u8 finger_count;
681 u8 mt_feature_index;
682 u8 button_feature_index;
683 u8 maxcontacts;
684 bool flip_y;
685 unsigned int resolution;
686};
687
688static int wtp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
689 struct hid_field *field, struct hid_usage *usage,
690 unsigned long **bit, int *max)
691{
3a61e975
BT
692 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
693
694 if ((hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) &&
695 (field->application == HID_GD_KEYBOARD))
696 return 0;
697
2f31c525
BT
698 return -1;
699}
700
c39e3d5f
BT
701static void wtp_populate_input(struct hidpp_device *hidpp,
702 struct input_dev *input_dev, bool origin_is_hid_core)
2f31c525 703{
2f31c525 704 struct wtp_data *wd = hidpp->private_data;
2f31c525 705
3a61e975
BT
706 if ((hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) && origin_is_hid_core)
707 /* this is the generic hid-input call */
708 return;
709
2f31c525
BT
710 __set_bit(EV_ABS, input_dev->evbit);
711 __set_bit(EV_KEY, input_dev->evbit);
712 __clear_bit(EV_REL, input_dev->evbit);
713 __clear_bit(EV_LED, input_dev->evbit);
714
715 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, wd->x_size, 0, 0);
716 input_abs_set_res(input_dev, ABS_MT_POSITION_X, wd->resolution);
717 input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, wd->y_size, 0, 0);
718 input_abs_set_res(input_dev, ABS_MT_POSITION_Y, wd->resolution);
719
720 /* Max pressure is not given by the devices, pick one */
721 input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 50, 0, 0);
722
723 input_set_capability(input_dev, EV_KEY, BTN_LEFT);
724
57ac86cf
BT
725 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)
726 input_set_capability(input_dev, EV_KEY, BTN_RIGHT);
727 else
728 __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
2f31c525
BT
729
730 input_mt_init_slots(input_dev, wd->maxcontacts, INPUT_MT_POINTER |
731 INPUT_MT_DROP_UNUSED);
732
733 wd->input = input_dev;
734}
735
736static void wtp_touch_event(struct wtp_data *wd,
737 struct hidpp_touchpad_raw_xy_finger *touch_report)
738{
739 int slot;
740
741 if (!touch_report->finger_id || touch_report->contact_type)
742 /* no actual data */
743 return;
744
745 slot = input_mt_get_slot_by_key(wd->input, touch_report->finger_id);
746
747 input_mt_slot(wd->input, slot);
748 input_mt_report_slot_state(wd->input, MT_TOOL_FINGER,
749 touch_report->contact_status);
750 if (touch_report->contact_status) {
751 input_event(wd->input, EV_ABS, ABS_MT_POSITION_X,
752 touch_report->x);
753 input_event(wd->input, EV_ABS, ABS_MT_POSITION_Y,
754 wd->flip_y ? wd->y_size - touch_report->y :
755 touch_report->y);
756 input_event(wd->input, EV_ABS, ABS_MT_PRESSURE,
757 touch_report->area);
758 }
759}
760
761static void wtp_send_raw_xy_event(struct hidpp_device *hidpp,
762 struct hidpp_touchpad_raw_xy *raw)
763{
764 struct wtp_data *wd = hidpp->private_data;
765 int i;
766
767 for (i = 0; i < 2; i++)
768 wtp_touch_event(wd, &(raw->fingers[i]));
769
57ac86cf
BT
770 if (raw->end_of_frame &&
771 !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS))
2f31c525
BT
772 input_event(wd->input, EV_KEY, BTN_LEFT, raw->button);
773
774 if (raw->end_of_frame || raw->finger_count <= 2) {
775 input_mt_sync_frame(wd->input);
776 input_sync(wd->input);
777 }
778}
779
780static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data)
781{
782 struct wtp_data *wd = hidpp->private_data;
783 u8 c1_area = ((data[7] & 0xf) * (data[7] & 0xf) +
784 (data[7] >> 4) * (data[7] >> 4)) / 2;
785 u8 c2_area = ((data[13] & 0xf) * (data[13] & 0xf) +
786 (data[13] >> 4) * (data[13] >> 4)) / 2;
787 struct hidpp_touchpad_raw_xy raw = {
788 .timestamp = data[1],
789 .fingers = {
790 {
791 .contact_type = 0,
792 .contact_status = !!data[7],
793 .x = get_unaligned_le16(&data[3]),
794 .y = get_unaligned_le16(&data[5]),
795 .z = c1_area,
796 .area = c1_area,
797 .finger_id = data[2],
798 }, {
799 .contact_type = 0,
800 .contact_status = !!data[13],
801 .x = get_unaligned_le16(&data[9]),
802 .y = get_unaligned_le16(&data[11]),
803 .z = c2_area,
804 .area = c2_area,
805 .finger_id = data[8],
806 }
807 },
808 .finger_count = wd->maxcontacts,
809 .spurious_flag = 0,
810 .end_of_frame = (data[0] >> 7) == 0,
811 .button = data[0] & 0x01,
812 };
813
814 wtp_send_raw_xy_event(hidpp, &raw);
815
816 return 1;
817}
818
819static int wtp_raw_event(struct hid_device *hdev, u8 *data, int size)
820{
821 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
822 struct wtp_data *wd = hidpp->private_data;
586bdc4e
BT
823 struct hidpp_report *report = (struct hidpp_report *)data;
824 struct hidpp_touchpad_raw_xy raw;
2f31c525 825
586bdc4e 826 if (!wd || !wd->input)
2f31c525
BT
827 return 1;
828
586bdc4e
BT
829 switch (data[0]) {
830 case 0x02:
57ac86cf
BT
831 if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) {
832 input_event(wd->input, EV_KEY, BTN_LEFT,
833 !!(data[1] & 0x01));
834 input_event(wd->input, EV_KEY, BTN_RIGHT,
835 !!(data[1] & 0x02));
836 input_sync(wd->input);
837 } else {
838 if (size < 21)
839 return 1;
840 return wtp_mouse_raw_xy_event(hidpp, &data[7]);
841 }
586bdc4e
BT
842 case REPORT_ID_HIDPP_LONG:
843 if ((report->fap.feature_index != wd->mt_feature_index) ||
844 (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY))
845 return 1;
846 hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw);
847
848 wtp_send_raw_xy_event(hidpp, &raw);
849 return 0;
850 }
851
852 return 0;
2f31c525
BT
853}
854
855static int wtp_get_config(struct hidpp_device *hidpp)
856{
857 struct wtp_data *wd = hidpp->private_data;
858 struct hidpp_touchpad_raw_info raw_info = {0};
859 u8 feature_type;
860 int ret;
861
862 ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY,
863 &wd->mt_feature_index, &feature_type);
864 if (ret)
865 /* means that the device is not powered up */
866 return ret;
867
868 ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index,
869 &raw_info);
870 if (ret)
871 return ret;
872
873 wd->x_size = raw_info.x_size;
874 wd->y_size = raw_info.y_size;
875 wd->maxcontacts = raw_info.maxcontacts;
876 wd->flip_y = raw_info.origin == TOUCHPAD_RAW_XY_ORIGIN_LOWER_LEFT;
877 wd->resolution = raw_info.res;
57ac86cf
BT
878 if (!wd->resolution)
879 wd->resolution = WTP_MANUAL_RESOLUTION;
2f31c525
BT
880
881 return 0;
882}
883
884static int wtp_allocate(struct hid_device *hdev, const struct hid_device_id *id)
885{
886 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
887 struct wtp_data *wd;
888
889 wd = devm_kzalloc(&hdev->dev, sizeof(struct wtp_data),
890 GFP_KERNEL);
891 if (!wd)
892 return -ENOMEM;
893
894 hidpp->private_data = wd;
895
896 return 0;
897};
898
bf159447 899static int wtp_connect(struct hid_device *hdev, bool connected)
586bdc4e
BT
900{
901 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
902 struct wtp_data *wd = hidpp->private_data;
903 int ret;
904
905 if (!connected)
bf159447 906 return 0;
586bdc4e
BT
907
908 if (!wd->x_size) {
909 ret = wtp_get_config(hidpp);
910 if (ret) {
911 hid_err(hdev, "Can not get wtp config: %d\n", ret);
bf159447 912 return ret;
586bdc4e
BT
913 }
914 }
915
bf159447 916 return hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index,
586bdc4e
BT
917 true, true);
918}
919
2f31c525
BT
920/* -------------------------------------------------------------------------- */
921/* Generic HID++ devices */
922/* -------------------------------------------------------------------------- */
923
924static int hidpp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
925 struct hid_field *field, struct hid_usage *usage,
926 unsigned long **bit, int *max)
927{
928 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
929
930 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
931 return wtp_input_mapping(hdev, hi, field, usage, bit, max);
932
933 return 0;
934}
935
c39e3d5f
BT
936static void hidpp_populate_input(struct hidpp_device *hidpp,
937 struct input_dev *input, bool origin_is_hid_core)
938{
939 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
940 wtp_populate_input(hidpp, input, origin_is_hid_core);
941}
942
2f31c525
BT
943static void hidpp_input_configured(struct hid_device *hdev,
944 struct hid_input *hidinput)
945{
946 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
c39e3d5f 947 struct input_dev *input = hidinput->input;
2f31c525 948
c39e3d5f 949 hidpp_populate_input(hidpp, input, true);
2f31c525
BT
950}
951
952static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
953 int size)
954{
955 struct hidpp_report *question = hidpp->send_receive_buf;
956 struct hidpp_report *answer = hidpp->send_receive_buf;
957 struct hidpp_report *report = (struct hidpp_report *)data;
958
959 /*
960 * If the mutex is locked then we have a pending answer from a
e529fea9 961 * previously sent command.
2f31c525
BT
962 */
963 if (unlikely(mutex_is_locked(&hidpp->send_mutex))) {
964 /*
965 * Check for a correct hidpp20 answer or the corresponding
966 * error
967 */
968 if (hidpp_match_answer(question, report) ||
969 hidpp_match_error(question, report)) {
970 *answer = *report;
971 hidpp->answer_available = true;
972 wake_up(&hidpp->wait);
973 /*
974 * This was an answer to a command that this driver sent
975 * We return 1 to hid-core to avoid forwarding the
976 * command upstream as it has been treated by the driver
977 */
978
979 return 1;
980 }
981 }
982
c39e3d5f
BT
983 if (unlikely(hidpp_report_is_connect_event(report))) {
984 atomic_set(&hidpp->connected,
985 !(report->rap.params[0] & (1 << 6)));
986 if ((hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) &&
987 (schedule_work(&hidpp->work) == 0))
988 dbg_hid("%s: connect event already queued\n", __func__);
989 return 1;
990 }
991
2f31c525
BT
992 return 0;
993}
994
995static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report,
996 u8 *data, int size)
997{
998 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
e529fea9 999 int ret = 0;
2f31c525 1000
e529fea9 1001 /* Generic HID++ processing. */
2f31c525
BT
1002 switch (data[0]) {
1003 case REPORT_ID_HIDPP_LONG:
1004 if (size != HIDPP_REPORT_LONG_LENGTH) {
1005 hid_err(hdev, "received hid++ report of bad size (%d)",
1006 size);
1007 return 1;
1008 }
e529fea9
PW
1009 ret = hidpp_raw_hidpp_event(hidpp, data, size);
1010 break;
2f31c525
BT
1011 case REPORT_ID_HIDPP_SHORT:
1012 if (size != HIDPP_REPORT_SHORT_LENGTH) {
1013 hid_err(hdev, "received hid++ report of bad size (%d)",
1014 size);
1015 return 1;
1016 }
e529fea9
PW
1017 ret = hidpp_raw_hidpp_event(hidpp, data, size);
1018 break;
2f31c525
BT
1019 }
1020
e529fea9
PW
1021 /* If no report is available for further processing, skip calling
1022 * raw_event of subclasses. */
1023 if (ret != 0)
1024 return ret;
1025
2f31c525
BT
1026 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)
1027 return wtp_raw_event(hdev, data, size);
1028
1029 return 0;
1030}
1031
33797820 1032static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying)
2f31c525
BT
1033{
1034 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
1035 char *name;
2f31c525 1036
33797820
BT
1037 if (use_unifying)
1038 /*
1039 * the device is connected through an Unifying receiver, and
1040 * might not be already connected.
1041 * Ask the receiver for its name.
1042 */
1043 name = hidpp_get_unifying_name(hidpp);
1044 else
02cc097e 1045 name = hidpp_get_device_name(hidpp);
2f31c525
BT
1046
1047 if (!name)
1048 hid_err(hdev, "unable to retrieve the name of the device");
1049 else
1050 snprintf(hdev->name, sizeof(hdev->name), "%s", name);
1051
1052 kfree(name);
1053}
1054
c39e3d5f
BT
1055static int hidpp_input_open(struct input_dev *dev)
1056{
1057 struct hid_device *hid = input_get_drvdata(dev);
1058
1059 return hid_hw_open(hid);
1060}
1061
1062static void hidpp_input_close(struct input_dev *dev)
1063{
1064 struct hid_device *hid = input_get_drvdata(dev);
1065
1066 hid_hw_close(hid);
1067}
1068
1069static struct input_dev *hidpp_allocate_input(struct hid_device *hdev)
1070{
1071 struct input_dev *input_dev = devm_input_allocate_device(&hdev->dev);
1072
1073 if (!input_dev)
1074 return NULL;
1075
1076 input_set_drvdata(input_dev, hdev);
1077 input_dev->open = hidpp_input_open;
1078 input_dev->close = hidpp_input_close;
1079
1080 input_dev->name = hdev->name;
1081 input_dev->phys = hdev->phys;
1082 input_dev->uniq = hdev->uniq;
1083 input_dev->id.bustype = hdev->bus;
1084 input_dev->id.vendor = hdev->vendor;
1085 input_dev->id.product = hdev->product;
1086 input_dev->id.version = hdev->version;
1087 input_dev->dev.parent = &hdev->dev;
1088
1089 return input_dev;
1090}
1091
1092static void hidpp_connect_event(struct hidpp_device *hidpp)
1093{
1094 struct hid_device *hdev = hidpp->hid_dev;
1095 int ret = 0;
1096 bool connected = atomic_read(&hidpp->connected);
1097 struct input_dev *input;
1098 char *name, *devm_name;
c39e3d5f 1099
bf159447
BT
1100 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
1101 ret = wtp_connect(hdev, connected);
1102 if (ret)
1103 return;
1104 }
586bdc4e 1105
c39e3d5f
BT
1106 if (!connected || hidpp->delayed_input)
1107 return;
1108
1109 if (!hidpp->protocol_major) {
1110 ret = !hidpp_is_connected(hidpp);
1111 if (ret) {
1112 hid_err(hdev, "Can not get the protocol version.\n");
1113 return;
1114 }
1115 }
1116
1117 /* the device is already connected, we can ask for its name and
1118 * protocol */
1119 hid_info(hdev, "HID++ %u.%u device connected.\n",
1120 hidpp->protocol_major, hidpp->protocol_minor);
1121
1122 input = hidpp_allocate_input(hdev);
1123 if (!input) {
1124 hid_err(hdev, "cannot allocate new input device: %d\n", ret);
1125 return;
1126 }
1127
02cc097e 1128 name = hidpp_get_device_name(hidpp);
c39e3d5f
BT
1129 if (!name) {
1130 hid_err(hdev, "unable to retrieve the name of the device");
1131 } else {
1132 devm_name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "%s", name);
1133 if (devm_name)
1134 input->name = devm_name;
1135 kfree(name);
1136 }
1137
1138 hidpp_populate_input(hidpp, input, false);
1139
1140 ret = input_register_device(input);
1141 if (ret)
1142 input_free_device(input);
1143
1144 hidpp->delayed_input = input;
1145}
1146
2f31c525
BT
1147static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
1148{
1149 struct hidpp_device *hidpp;
1150 int ret;
1151 bool connected;
c39e3d5f 1152 unsigned int connect_mask = HID_CONNECT_DEFAULT;
2f31c525
BT
1153
1154 hidpp = devm_kzalloc(&hdev->dev, sizeof(struct hidpp_device),
1155 GFP_KERNEL);
1156 if (!hidpp)
1157 return -ENOMEM;
1158
1159 hidpp->hid_dev = hdev;
1160 hid_set_drvdata(hdev, hidpp);
1161
1162 hidpp->quirks = id->driver_data;
1163
1164 if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
1165 ret = wtp_allocate(hdev, id);
1166 if (ret)
f486d9db 1167 goto wtp_allocate_fail;
2f31c525
BT
1168 }
1169
c39e3d5f 1170 INIT_WORK(&hidpp->work, delayed_work_cb);
2f31c525
BT
1171 mutex_init(&hidpp->send_mutex);
1172 init_waitqueue_head(&hidpp->wait);
1173
1174 ret = hid_parse(hdev);
1175 if (ret) {
1176 hid_err(hdev, "%s:parse failed\n", __func__);
1177 goto hid_parse_fail;
1178 }
1179
1180 /* Allow incoming packets */
1181 hid_device_io_start(hdev);
1182
1183 connected = hidpp_is_connected(hidpp);
ab94e562
BT
1184 if (id->group != HID_GROUP_LOGITECH_DJ_DEVICE) {
1185 if (!connected) {
1186 hid_err(hdev, "Device not connected");
f486d9db 1187 hid_device_io_stop(hdev);
ab94e562
BT
1188 goto hid_parse_fail;
1189 }
2f31c525 1190
ab94e562
BT
1191 hid_info(hdev, "HID++ %u.%u device connected.\n",
1192 hidpp->protocol_major, hidpp->protocol_minor);
ab94e562 1193 }
2f31c525 1194
33797820 1195 hidpp_overwrite_name(hdev, id->group == HID_GROUP_LOGITECH_DJ_DEVICE);
c39e3d5f 1196 atomic_set(&hidpp->connected, connected);
33797820 1197
c39e3d5f 1198 if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) {
2f31c525
BT
1199 ret = wtp_get_config(hidpp);
1200 if (ret)
1201 goto hid_parse_fail;
1202 }
1203
1204 /* Block incoming packets */
1205 hid_device_io_stop(hdev);
1206
c39e3d5f
BT
1207 if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT)
1208 connect_mask &= ~HID_CONNECT_HIDINPUT;
1209
3a61e975
BT
1210 /* Re-enable hidinput for multi-input devices */
1211 if (hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT)
1212 connect_mask |= HID_CONNECT_HIDINPUT;
1213
c39e3d5f 1214 ret = hid_hw_start(hdev, connect_mask);
2f31c525
BT
1215 if (ret) {
1216 hid_err(hdev, "%s:hid_hw_start returned error\n", __func__);
1217 goto hid_hw_start_fail;
1218 }
1219
c39e3d5f
BT
1220 if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) {
1221 /* Allow incoming packets */
1222 hid_device_io_start(hdev);
1223
1224 hidpp_connect_event(hidpp);
1225 }
1226
2f31c525
BT
1227 return ret;
1228
1229hid_hw_start_fail:
1230hid_parse_fail:
c39e3d5f 1231 cancel_work_sync(&hidpp->work);
2f31c525 1232 mutex_destroy(&hidpp->send_mutex);
f486d9db 1233wtp_allocate_fail:
2f31c525
BT
1234 hid_set_drvdata(hdev, NULL);
1235 return ret;
1236}
1237
1238static void hidpp_remove(struct hid_device *hdev)
1239{
1240 struct hidpp_device *hidpp = hid_get_drvdata(hdev);
1241
c39e3d5f 1242 cancel_work_sync(&hidpp->work);
2f31c525
BT
1243 mutex_destroy(&hidpp->send_mutex);
1244 hid_hw_stop(hdev);
1245}
1246
1247static const struct hid_device_id hidpp_devices[] = {
57ac86cf
BT
1248 { /* wireless touchpad */
1249 HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
1250 USB_VENDOR_ID_LOGITECH, 0x4011),
1251 .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT |
1252 HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS },
586bdc4e
BT
1253 { /* wireless touchpad T650 */
1254 HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
1255 USB_VENDOR_ID_LOGITECH, 0x4101),
1256 .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT },
2f31c525
BT
1257 { /* wireless touchpad T651 */
1258 HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH,
1259 USB_DEVICE_ID_LOGITECH_T651),
1260 .driver_data = HIDPP_QUIRK_CLASS_WTP },
3a61e975
BT
1261 { /* Keyboard TK820 */
1262 HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
1263 USB_VENDOR_ID_LOGITECH, 0x4102),
1264 .driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_MULTI_INPUT |
1265 HIDPP_QUIRK_CLASS_WTP },
ab94e562
BT
1266
1267 { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
1268 USB_VENDOR_ID_LOGITECH, HID_ANY_ID)},
2f31c525
BT
1269 {}
1270};
1271
1272MODULE_DEVICE_TABLE(hid, hidpp_devices);
1273
1274static struct hid_driver hidpp_driver = {
1275 .name = "logitech-hidpp-device",
1276 .id_table = hidpp_devices,
1277 .probe = hidpp_probe,
1278 .remove = hidpp_remove,
1279 .raw_event = hidpp_raw_event,
1280 .input_configured = hidpp_input_configured,
1281 .input_mapping = hidpp_input_mapping,
1282};
1283
1284module_hid_driver(hidpp_driver);