Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branches 'for-3.19/hid-report-len', 'for-3.19/i2c-hid', 'for-3.19/lenovo', 'for-3.19/logitech', 'for-3.19/microsoft', 'for-3.19/plantronics', 'for-3.19/rmi', 'for-3.19/sony' and 'for-3.19/wacom' into for-linus

+2086 -391
+19
drivers/hid/Kconfig
··· 371 371 tristate "Logitech Unifying receivers full support" 372 372 depends on HIDRAW 373 373 depends on HID_LOGITECH 374 + select HID_LOGITECH_HIDPP 374 375 ---help--- 375 376 Say Y if you want support for Logitech Unifying receivers and devices. 376 377 Unifying receivers are capable of pairing up to 6 Logitech compliant 377 378 devices to the same receiver. Without this driver it will be handled by 378 379 generic USB_HID driver and all incoming events will be multiplexed 379 380 into a single mouse and a single keyboard device. 381 + 382 + config HID_LOGITECH_HIDPP 383 + tristate "Logitech HID++ devices support" 384 + depends on HID_LOGITECH 385 + ---help--- 386 + Support for Logitech devices relyingon the HID++ Logitech specification 387 + 388 + Say Y if you want support for Logitech devices relying on the HID++ 389 + specification. Such devices are the various Logitech Touchpads (T650, 390 + T651, TK820), some mice (Zone Touch mouse), or even keyboards (Solar 391 + Keayboard). 380 392 381 393 config LOGITECH_FF 382 394 bool "Logitech force feedback support" ··· 624 612 depends on HID_PICOLCD=RC_CORE || RC_CORE=y 625 613 ---help--- 626 614 Provide access to PicoLCD's CIR interface via remote control (LIRC). 615 + 616 + config HID_PLANTRONICS 617 + tristate "Plantronics USB HID Driver" 618 + default !EXPERT 619 + depends on HID 620 + ---help--- 621 + Provides HID support for Plantronics telephony devices. 627 622 628 623 config HID_PRIMAX 629 624 tristate "Primax non-fully HID-compliant devices"
+2
drivers/hid/Makefile
··· 63 63 obj-$(CONFIG_HID_LENOVO) += hid-lenovo.o 64 64 obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o 65 65 obj-$(CONFIG_HID_LOGITECH_DJ) += hid-logitech-dj.o 66 + obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o 66 67 obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o 67 68 obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o 68 69 obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o ··· 95 94 hid-picolcd-y += hid-picolcd_debugfs.o 96 95 endif 97 96 97 + obj-$(CONFIG_HID_PLANTRONICS) += hid-plantronics.o 98 98 obj-$(CONFIG_HID_PRIMAX) += hid-primax.o 99 99 obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ 100 100 hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \
+9 -6
drivers/hid/hid-core.c
··· 702 702 if (((parser->global.usage_page << 16) == HID_UP_SENSOR) && 703 703 type == HID_COLLECTION_PHYSICAL) 704 704 hid->group = HID_GROUP_SENSOR_HUB; 705 + 706 + if (hid->vendor == USB_VENDOR_ID_MICROSOFT && 707 + hid->product == USB_DEVICE_ID_MS_TYPE_COVER_3 && 708 + hid->group == HID_GROUP_MULTITOUCH) 709 + hid->group = HID_GROUP_GENERIC; 705 710 } 706 711 707 712 static int hid_scan_main(struct hid_parser *parser, struct hid_item *item) ··· 1282 1277 } 1283 1278 EXPORT_SYMBOL_GPL(hid_output_report); 1284 1279 1285 - static int hid_report_len(struct hid_report *report) 1286 - { 1287 - /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ 1288 - return ((report->size - 1) >> 3) + 1 + (report->id > 0); 1289 - } 1290 - 1291 1280 /* 1292 1281 * Allocator for buffer that is going to be passed to hid_output_report() 1293 1282 */ ··· 1818 1819 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2) }, 1819 1820 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER) }, 1820 1821 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) }, 1822 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_T651) }, 1821 1823 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_DESKTOP) }, 1822 1824 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_EDGE) }, 1823 1825 { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_DINOVO_MINI) }, ··· 1859 1859 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 1860 1860 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) }, 1861 1861 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) }, 1862 + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3) }, 1862 1863 { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) }, 1863 1864 { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) }, 1864 1865 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) }, ··· 1885 1884 { HID_USB_DEVICE(USB_VENDOR_ID_ORTEK, USB_DEVICE_ID_ORTEK_WKB2000) }, 1886 1885 { HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_6000) }, 1887 1886 { HID_USB_DEVICE(USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE) }, 1887 + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) }, 1888 1888 { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_KEYBOARD) }, 1889 1889 #if IS_ENABLED(CONFIG_HID_ROCCAT) 1890 1890 { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_ARVO) }, ··· 1914 1912 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, 1915 1913 { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, 1916 1914 { HID_USB_DEVICE(USB_VENDOR_ID_SKYCABLE, USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER) }, 1915 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE) }, 1917 1916 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_BUZZ_CONTROLLER) }, 1918 1917 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER) }, 1919 1918 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) },
+10
drivers/hid/hid-ids.h
··· 579 579 580 580 #define USB_VENDOR_ID_LOGITECH 0x046d 581 581 #define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e 582 + #define USB_DEVICE_ID_LOGITECH_T651 0xb00c 582 583 #define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 583 584 #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110 584 585 #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f ··· 652 651 #define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 653 652 #define USB_DEVICE_ID_MS_TOUCH_COVER_2 0x07a7 654 653 #define USB_DEVICE_ID_MS_TYPE_COVER_2 0x07a9 654 + #define USB_DEVICE_ID_MS_TYPE_COVER_3 0x07dc 655 655 656 656 #define USB_VENDOR_ID_MOJO 0x8282 657 657 #define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 ··· 719 717 #define USB_VENDOR_ID_ORTEK 0x05a4 720 718 #define USB_DEVICE_ID_ORTEK_PKB1700 0x1700 721 719 #define USB_DEVICE_ID_ORTEK_WKB2000 0x2000 720 + 721 + #define USB_VENDOR_ID_PLANTRONICS 0x047f 722 722 723 723 #define USB_VENDOR_ID_PANASONIC 0x04da 724 724 #define USB_DEVICE_ID_PANABOARD_UBT780 0x1044 ··· 818 814 819 815 #define USB_VENDOR_ID_SKYCABLE 0x1223 820 816 #define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07 817 + 818 + #define USB_VENDOR_ID_SMK 0x0609 819 + #define USB_DEVICE_ID_SMK_PS3_BDREMOTE 0x0306 821 820 822 821 #define USB_VENDOR_ID_SONY 0x054c 823 822 #define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b ··· 939 932 #define USB_DEVICE_ID_VERNIER_SKIP 0x0003 940 933 #define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 941 934 #define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 935 + 936 + #define USB_VENDOR_ID_VTL 0x0306 937 + #define USB_DEVICE_ID_VTL_MULTITOUCH_FF3F 0xff3f 942 938 943 939 #define USB_VENDOR_ID_WACOM 0x056a 944 940 #define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81
+1 -1
drivers/hid/hid-input.c
··· 1215 1215 return hid->ll_driver->request(hid, report, HID_REQ_SET_REPORT); 1216 1216 1217 1217 /* fall back to generic raw-output-report */ 1218 - len = ((report->size - 1) >> 3) + 1 + (report->id > 0); 1218 + len = hid_report_len(report); 1219 1219 buf = hid_alloc_report_buf(report, GFP_KERNEL); 1220 1220 if (!buf) 1221 1221 return;
+6 -7
drivers/hid/hid-lenovo.c
··· 62 62 /* HID_UP_LNVENDOR = USB, HID_UP_MSVENDOR = BT */ 63 63 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR || 64 64 (usage->hid & HID_USAGE_PAGE) == HID_UP_LNVENDOR) { 65 - set_bit(EV_REP, hi->input->evbit); 66 65 switch (usage->hid & HID_USAGE) { 67 66 case 0x00f1: /* Fn-F4: Mic mute */ 68 67 map_key_clear(KEY_MICMUTE); ··· 84 85 case 0x00f8: /* Fn-F11: View open applications (3 boxes) */ 85 86 map_key_clear(KEY_SCALE); 86 87 return 1; 87 - case 0x00fa: /* Fn-Esc: Fn-lock toggle */ 88 - map_key_clear(KEY_FN_ESC); 89 - return 1; 90 - case 0x00fb: /* Fn-F12: Open My computer (6 boxes) USB-only */ 88 + case 0x00f9: /* Fn-F12: Open My computer (6 boxes) USB-only */ 91 89 /* NB: This mapping is invented in raw_event below */ 92 90 map_key_clear(KEY_FILE); 91 + return 1; 92 + case 0x00fa: /* Fn-Esc: Fn-lock toggle */ 93 + map_key_clear(KEY_FN_ESC); 93 94 return 1; 94 95 } 95 96 } ··· 206 207 && data[0] == 0x15 207 208 && data[1] == 0x94 208 209 && data[2] == 0x01)) { 209 - data[1] = 0x0; 210 - data[2] = 0x4; 210 + data[1] = 0x00; 211 + data[2] = 0x01; 211 212 } 212 213 213 214 return 0;
+300 -97
drivers/hid/hid-logitech-dj.c
··· 26 26 #include <linux/hid.h> 27 27 #include <linux/module.h> 28 28 #include <linux/usb.h> 29 + #include <linux/kfifo.h> 29 30 #include <asm/unaligned.h> 30 31 #include "hid-ids.h" 31 - #include "hid-logitech-dj.h" 32 + 33 + #define DJ_MAX_PAIRED_DEVICES 6 34 + #define DJ_MAX_NUMBER_NOTIFICATIONS 8 35 + #define DJ_RECEIVER_INDEX 0 36 + #define DJ_DEVICE_INDEX_MIN 1 37 + #define DJ_DEVICE_INDEX_MAX 6 38 + 39 + #define DJREPORT_SHORT_LENGTH 15 40 + #define DJREPORT_LONG_LENGTH 32 41 + 42 + #define REPORT_ID_DJ_SHORT 0x20 43 + #define REPORT_ID_DJ_LONG 0x21 44 + 45 + #define REPORT_ID_HIDPP_SHORT 0x10 46 + #define REPORT_ID_HIDPP_LONG 0x11 47 + 48 + #define HIDPP_REPORT_SHORT_LENGTH 7 49 + #define HIDPP_REPORT_LONG_LENGTH 20 50 + 51 + #define HIDPP_RECEIVER_INDEX 0xff 52 + 53 + #define REPORT_TYPE_RFREPORT_FIRST 0x01 54 + #define REPORT_TYPE_RFREPORT_LAST 0x1F 55 + 56 + /* Command Switch to DJ mode */ 57 + #define REPORT_TYPE_CMD_SWITCH 0x80 58 + #define CMD_SWITCH_PARAM_DEVBITFIELD 0x00 59 + #define CMD_SWITCH_PARAM_TIMEOUT_SECONDS 0x01 60 + #define TIMEOUT_NO_KEEPALIVE 0x00 61 + 62 + /* Command to Get the list of Paired devices */ 63 + #define REPORT_TYPE_CMD_GET_PAIRED_DEVICES 0x81 64 + 65 + /* Device Paired Notification */ 66 + #define REPORT_TYPE_NOTIF_DEVICE_PAIRED 0x41 67 + #define SPFUNCTION_MORE_NOTIF_EXPECTED 0x01 68 + #define SPFUNCTION_DEVICE_LIST_EMPTY 0x02 69 + #define DEVICE_PAIRED_PARAM_SPFUNCTION 0x00 70 + #define DEVICE_PAIRED_PARAM_EQUAD_ID_LSB 0x01 71 + #define DEVICE_PAIRED_PARAM_EQUAD_ID_MSB 0x02 72 + #define DEVICE_PAIRED_RF_REPORT_TYPE 0x03 73 + 74 + /* Device Un-Paired Notification */ 75 + #define REPORT_TYPE_NOTIF_DEVICE_UNPAIRED 0x40 76 + 77 + 78 + /* Connection Status Notification */ 79 + #define REPORT_TYPE_NOTIF_CONNECTION_STATUS 0x42 80 + #define CONNECTION_STATUS_PARAM_STATUS 0x00 81 + #define STATUS_LINKLOSS 0x01 82 + 83 + /* Error Notification */ 84 + #define REPORT_TYPE_NOTIF_ERROR 0x7F 85 + #define NOTIF_ERROR_PARAM_ETYPE 0x00 86 + #define ETYPE_KEEPALIVE_TIMEOUT 0x01 87 + 88 + /* supported DJ HID && RF report types */ 89 + #define REPORT_TYPE_KEYBOARD 0x01 90 + #define REPORT_TYPE_MOUSE 0x02 91 + #define REPORT_TYPE_CONSUMER_CONTROL 0x03 92 + #define REPORT_TYPE_SYSTEM_CONTROL 0x04 93 + #define REPORT_TYPE_MEDIA_CENTER 0x08 94 + #define REPORT_TYPE_LEDS 0x0E 95 + 96 + /* RF Report types bitfield */ 97 + #define STD_KEYBOARD 0x00000002 98 + #define STD_MOUSE 0x00000004 99 + #define MULTIMEDIA 0x00000008 100 + #define POWER_KEYS 0x00000010 101 + #define MEDIA_CENTER 0x00000100 102 + #define KBD_LEDS 0x00004000 103 + 104 + struct dj_report { 105 + u8 report_id; 106 + u8 device_index; 107 + u8 report_type; 108 + u8 report_params[DJREPORT_SHORT_LENGTH - 3]; 109 + }; 110 + 111 + struct dj_receiver_dev { 112 + struct hid_device *hdev; 113 + struct dj_device *paired_dj_devices[DJ_MAX_PAIRED_DEVICES + 114 + DJ_DEVICE_INDEX_MIN]; 115 + struct work_struct work; 116 + struct kfifo notif_fifo; 117 + spinlock_t lock; 118 + bool querying_devices; 119 + }; 120 + 121 + struct dj_device { 122 + struct hid_device *hdev; 123 + struct dj_receiver_dev *dj_receiver_dev; 124 + u32 reports_supported; 125 + u8 device_index; 126 + }; 32 127 33 128 /* Keyboard descriptor (1) */ 34 129 static const char kbd_descriptor[] = { ··· 251 156 0xc0, /* EndCollection */ 252 157 }; /* */ 253 158 159 + /* HIDPP descriptor */ 160 + static const char hidpp_descriptor[] = { 161 + 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */ 162 + 0x09, 0x01, /* Usage (Vendor Usage 1) */ 163 + 0xa1, 0x01, /* Collection (Application) */ 164 + 0x85, 0x10, /* Report ID (16) */ 165 + 0x75, 0x08, /* Report Size (8) */ 166 + 0x95, 0x06, /* Report Count (6) */ 167 + 0x15, 0x00, /* Logical Minimum (0) */ 168 + 0x26, 0xff, 0x00, /* Logical Maximum (255) */ 169 + 0x09, 0x01, /* Usage (Vendor Usage 1) */ 170 + 0x81, 0x00, /* Input (Data,Arr,Abs) */ 171 + 0x09, 0x01, /* Usage (Vendor Usage 1) */ 172 + 0x91, 0x00, /* Output (Data,Arr,Abs) */ 173 + 0xc0, /* End Collection */ 174 + 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */ 175 + 0x09, 0x02, /* Usage (Vendor Usage 2) */ 176 + 0xa1, 0x01, /* Collection (Application) */ 177 + 0x85, 0x11, /* Report ID (17) */ 178 + 0x75, 0x08, /* Report Size (8) */ 179 + 0x95, 0x13, /* Report Count (19) */ 180 + 0x15, 0x00, /* Logical Minimum (0) */ 181 + 0x26, 0xff, 0x00, /* Logical Maximum (255) */ 182 + 0x09, 0x02, /* Usage (Vendor Usage 2) */ 183 + 0x81, 0x00, /* Input (Data,Arr,Abs) */ 184 + 0x09, 0x02, /* Usage (Vendor Usage 2) */ 185 + 0x91, 0x00, /* Output (Data,Arr,Abs) */ 186 + 0xc0, /* End Collection */ 187 + 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */ 188 + 0x09, 0x04, /* Usage (Vendor Usage 0x04) */ 189 + 0xa1, 0x01, /* Collection (Application) */ 190 + 0x85, 0x20, /* Report ID (32) */ 191 + 0x75, 0x08, /* Report Size (8) */ 192 + 0x95, 0x0e, /* Report Count (14) */ 193 + 0x15, 0x00, /* Logical Minimum (0) */ 194 + 0x26, 0xff, 0x00, /* Logical Maximum (255) */ 195 + 0x09, 0x41, /* Usage (Vendor Usage 0x41) */ 196 + 0x81, 0x00, /* Input (Data,Arr,Abs) */ 197 + 0x09, 0x41, /* Usage (Vendor Usage 0x41) */ 198 + 0x91, 0x00, /* Output (Data,Arr,Abs) */ 199 + 0x85, 0x21, /* Report ID (33) */ 200 + 0x95, 0x1f, /* Report Count (31) */ 201 + 0x15, 0x00, /* Logical Minimum (0) */ 202 + 0x26, 0xff, 0x00, /* Logical Maximum (255) */ 203 + 0x09, 0x42, /* Usage (Vendor Usage 0x42) */ 204 + 0x81, 0x00, /* Input (Data,Arr,Abs) */ 205 + 0x09, 0x42, /* Usage (Vendor Usage 0x42) */ 206 + 0x91, 0x00, /* Output (Data,Arr,Abs) */ 207 + 0xc0, /* End Collection */ 208 + }; 209 + 254 210 /* Maximum size of all defined hid reports in bytes (including report id) */ 255 211 #define MAX_REPORT_SIZE 8 256 212 ··· 311 165 sizeof(mse_descriptor) + \ 312 166 sizeof(consumer_descriptor) + \ 313 167 sizeof(syscontrol_descriptor) + \ 314 - sizeof(media_descriptor)) 168 + sizeof(media_descriptor) + \ 169 + sizeof(hidpp_descriptor)) 315 170 316 171 /* Number of possible hid report types that can be created by this driver. 317 172 * ··· 403 256 dj_hiddev->dev.parent = &djrcv_hdev->dev; 404 257 dj_hiddev->bus = BUS_USB; 405 258 dj_hiddev->vendor = le16_to_cpu(usbdev->descriptor.idVendor); 406 - dj_hiddev->product = le16_to_cpu(usbdev->descriptor.idProduct); 259 + dj_hiddev->product = 260 + (dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_MSB] 261 + << 8) | 262 + dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_LSB]; 407 263 snprintf(dj_hiddev->name, sizeof(dj_hiddev->name), 408 - "Logitech Unifying Device. Wireless PID:%02x%02x", 409 - dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_MSB], 410 - dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_LSB]); 264 + "Logitech Unifying Device. Wireless PID:%04x", 265 + dj_hiddev->product); 266 + 267 + dj_hiddev->group = HID_GROUP_LOGITECH_DJ_DEVICE; 411 268 412 269 usb_make_path(usbdev, dj_hiddev->phys, sizeof(dj_hiddev->phys)); 413 270 snprintf(tmpstr, sizeof(tmpstr), ":%d", dj_report->device_index); ··· 573 422 } 574 423 } 575 424 425 + static void logi_dj_recv_forward_hidpp(struct dj_device *dj_dev, u8 *data, 426 + int size) 427 + { 428 + /* We are called from atomic context (tasklet && djrcv->lock held) */ 429 + if (hid_input_report(dj_dev->hdev, HID_INPUT_REPORT, data, size, 1)) 430 + dbg_hid("hid_input_report error\n"); 431 + } 576 432 577 433 static int logi_dj_recv_send_report(struct dj_receiver_dev *djrcv_dev, 578 434 struct dj_report *dj_report) ··· 630 472 static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, 631 473 unsigned timeout) 632 474 { 475 + struct hid_device *hdev = djrcv_dev->hdev; 633 476 struct dj_report *dj_report; 477 + u8 *buf; 634 478 int retval; 635 479 636 480 dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); ··· 644 484 dj_report->report_params[CMD_SWITCH_PARAM_DEVBITFIELD] = 0x3F; 645 485 dj_report->report_params[CMD_SWITCH_PARAM_TIMEOUT_SECONDS] = (u8)timeout; 646 486 retval = logi_dj_recv_send_report(djrcv_dev, dj_report); 647 - kfree(dj_report); 648 487 649 488 /* 650 489 * Ugly sleep to work around a USB 3.0 bug when the receiver is still ··· 652 493 */ 653 494 msleep(50); 654 495 496 + /* 497 + * Magical bits to set up hidpp notifications when the dj devices 498 + * are connected/disconnected. 499 + * 500 + * We can reuse dj_report because HIDPP_REPORT_SHORT_LENGTH is smaller 501 + * than DJREPORT_SHORT_LENGTH. 502 + */ 503 + buf = (u8 *)dj_report; 504 + 505 + memset(buf, 0, HIDPP_REPORT_SHORT_LENGTH); 506 + 507 + buf[0] = REPORT_ID_HIDPP_SHORT; 508 + buf[1] = 0xFF; 509 + buf[2] = 0x80; 510 + buf[3] = 0x00; 511 + buf[4] = 0x00; 512 + buf[5] = 0x09; 513 + buf[6] = 0x00; 514 + 515 + hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf, 516 + HIDPP_REPORT_SHORT_LENGTH, HID_OUTPUT_REPORT, 517 + HID_REQ_SET_REPORT); 518 + 519 + kfree(dj_report); 655 520 return retval; 656 521 } 657 522 ··· 692 509 dbg_hid("%s:%s\n", __func__, hid->phys); 693 510 } 694 511 512 + static u8 unifying_name_query[] = {0x10, 0xff, 0x83, 0xb5, 0x40, 0x00, 0x00}; 513 + static u8 unifying_name_answer[] = {0x11, 0xff, 0x83, 0xb5}; 514 + 695 515 static int logi_dj_ll_raw_request(struct hid_device *hid, 696 516 unsigned char reportnum, __u8 *buf, 697 517 size_t count, unsigned char report_type, ··· 704 518 struct dj_receiver_dev *djrcv_dev = djdev->dj_receiver_dev; 705 519 u8 *out_buf; 706 520 int ret; 521 + 522 + if ((buf[0] == REPORT_ID_HIDPP_SHORT) || 523 + (buf[0] == REPORT_ID_HIDPP_LONG)) { 524 + if (count < 2) 525 + return -EINVAL; 526 + 527 + /* special case where we should not overwrite 528 + * the device_index */ 529 + if (count == 7 && !memcmp(buf, unifying_name_query, 530 + sizeof(unifying_name_query))) 531 + buf[4] |= djdev->device_index - 1; 532 + else 533 + buf[1] = djdev->device_index; 534 + return hid_hw_raw_request(djrcv_dev->hdev, reportnum, buf, 535 + count, report_type, reqtype); 536 + } 707 537 708 538 if (buf[0] != REPORT_TYPE_LEDS) 709 539 return -EINVAL; ··· 799 597 __func__, djdev->reports_supported); 800 598 } 801 599 600 + rdcat(rdesc, &rsize, hidpp_descriptor, sizeof(hidpp_descriptor)); 601 + 802 602 retval = hid_parse_report(hid, rdesc, rsize); 803 603 kfree(rdesc); 804 604 ··· 828 624 .raw_request = logi_dj_ll_raw_request, 829 625 }; 830 626 831 - 832 - static int logi_dj_raw_event(struct hid_device *hdev, 627 + static int logi_dj_dj_event(struct hid_device *hdev, 833 628 struct hid_report *report, u8 *data, 834 629 int size) 835 630 { ··· 836 633 struct dj_report *dj_report = (struct dj_report *) data; 837 634 unsigned long flags; 838 635 839 - dbg_hid("%s, size:%d\n", __func__, size); 840 - 841 - /* Here we receive all data coming from iface 2, there are 4 cases: 636 + /* 637 + * Here we receive all data coming from iface 2, there are 3 cases: 842 638 * 843 - * 1) Data should continue its normal processing i.e. data does not 844 - * come from the DJ collection, in which case we do nothing and 845 - * return 0, so hid-core can continue normal processing (will forward 846 - * to associated hidraw device) 639 + * 1) Data is intended for this driver i. e. data contains arrival, 640 + * departure, etc notifications, in which case we queue them for delayed 641 + * processing by the work queue. We return 1 to hid-core as no further 642 + * processing is required from it. 847 643 * 848 - * 2) Data is from DJ collection, and is intended for this driver i. e. 849 - * data contains arrival, departure, etc notifications, in which case 850 - * we queue them for delayed processing by the work queue. We return 1 851 - * to hid-core as no further processing is required from it. 644 + * 2) Data informs a connection change, if the change means rf link 645 + * loss, then we must send a null report to the upper layer to discard 646 + * potentially pressed keys that may be repeated forever by the input 647 + * layer. Return 1 to hid-core as no further processing is required. 852 648 * 853 - * 3) Data is from DJ collection, and informs a connection change, 854 - * if the change means rf link loss, then we must send a null report 855 - * to the upper layer to discard potentially pressed keys that may be 856 - * repeated forever by the input layer. Return 1 to hid-core as no 857 - * further processing is required. 858 - * 859 - * 4) Data is from DJ collection and is an actual input event from 860 - * a paired DJ device in which case we forward it to the correct hid 861 - * device (via hid_input_report() ) and return 1 so hid-core does not do 862 - * anything else with it. 649 + * 3) Data is an actual input event from a paired DJ device in which 650 + * case we forward it to the correct hid device (via hid_input_report() 651 + * ) and return 1 so hid-core does not anything else with it. 863 652 */ 864 - 865 - /* case 1) */ 866 - if (data[0] != REPORT_ID_DJ_SHORT) 867 - return false; 868 653 869 654 if ((dj_report->device_index < DJ_DEVICE_INDEX_MIN) || 870 655 (dj_report->device_index > DJ_DEVICE_INDEX_MAX)) { ··· 898 707 return true; 899 708 } 900 709 710 + static int logi_dj_hidpp_event(struct hid_device *hdev, 711 + struct hid_report *report, u8 *data, 712 + int size) 713 + { 714 + struct dj_receiver_dev *djrcv_dev = hid_get_drvdata(hdev); 715 + struct dj_report *dj_report = (struct dj_report *) data; 716 + unsigned long flags; 717 + u8 device_index = dj_report->device_index; 718 + 719 + if (device_index == HIDPP_RECEIVER_INDEX) { 720 + /* special case were the device wants to know its unifying 721 + * name */ 722 + if (size == HIDPP_REPORT_LONG_LENGTH && 723 + !memcmp(data, unifying_name_answer, 724 + sizeof(unifying_name_answer)) && 725 + ((data[4] & 0xF0) == 0x40)) 726 + device_index = (data[4] & 0x0F) + 1; 727 + else 728 + return false; 729 + } 730 + 731 + /* 732 + * Data is from the HID++ collection, in this case, we forward the 733 + * data to the corresponding child dj device and return 0 to hid-core 734 + * so he data also goes to the hidraw device of the receiver. This 735 + * allows a user space application to implement the full HID++ routing 736 + * via the receiver. 737 + */ 738 + 739 + if ((device_index < DJ_DEVICE_INDEX_MIN) || 740 + (device_index > DJ_DEVICE_INDEX_MAX)) { 741 + /* 742 + * Device index is wrong, bail out. 743 + * This driver can ignore safely the receiver notifications, 744 + * so ignore those reports too. 745 + */ 746 + dev_err(&hdev->dev, "%s: invalid device index:%d\n", 747 + __func__, dj_report->device_index); 748 + return false; 749 + } 750 + 751 + spin_lock_irqsave(&djrcv_dev->lock, flags); 752 + 753 + if (!djrcv_dev->paired_dj_devices[device_index]) 754 + /* received an event for an unknown device, bail out */ 755 + goto out; 756 + 757 + logi_dj_recv_forward_hidpp(djrcv_dev->paired_dj_devices[device_index], 758 + data, size); 759 + 760 + out: 761 + spin_unlock_irqrestore(&djrcv_dev->lock, flags); 762 + 763 + return false; 764 + } 765 + 766 + static int logi_dj_raw_event(struct hid_device *hdev, 767 + struct hid_report *report, u8 *data, 768 + int size) 769 + { 770 + dbg_hid("%s, size:%d\n", __func__, size); 771 + 772 + switch (data[0]) { 773 + case REPORT_ID_DJ_SHORT: 774 + return logi_dj_dj_event(hdev, report, data, size); 775 + case REPORT_ID_HIDPP_SHORT: 776 + /* intentional fallthrough */ 777 + case REPORT_ID_HIDPP_LONG: 778 + return logi_dj_hidpp_event(hdev, report, data, size); 779 + } 780 + 781 + return false; 782 + } 783 + 901 784 static int logi_dj_probe(struct hid_device *hdev, 902 785 const struct hid_device_id *id) 903 786 { 904 787 struct usb_interface *intf = to_usb_interface(hdev->dev.parent); 905 788 struct dj_receiver_dev *djrcv_dev; 906 789 int retval; 907 - 908 - if (is_dj_device((struct dj_device *)hdev->driver_data)) 909 - return -ENODEV; 910 790 911 791 dbg_hid("%s called for ifnum %d\n", __func__, 912 792 intf->cur_altsetting->desc.bInterfaceNumber); ··· 1131 869 hid_set_drvdata(hdev, NULL); 1132 870 } 1133 871 1134 - static int logi_djdevice_probe(struct hid_device *hdev, 1135 - const struct hid_device_id *id) 1136 - { 1137 - int ret; 1138 - struct dj_device *dj_dev = hdev->driver_data; 1139 - 1140 - if (!is_dj_device(dj_dev)) 1141 - return -ENODEV; 1142 - 1143 - ret = hid_parse(hdev); 1144 - if (!ret) 1145 - ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 1146 - 1147 - return ret; 1148 - } 1149 - 1150 872 static const struct hid_device_id logi_dj_receivers[] = { 1151 873 {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 1152 874 USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER)}, ··· 1152 906 #endif 1153 907 }; 1154 908 909 + module_hid_driver(logi_djreceiver_driver); 1155 910 1156 - static const struct hid_device_id logi_dj_devices[] = { 1157 - {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 1158 - USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER)}, 1159 - {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 1160 - USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2)}, 1161 - {} 1162 - }; 1163 - 1164 - static struct hid_driver logi_djdevice_driver = { 1165 - .name = "logitech-djdevice", 1166 - .id_table = logi_dj_devices, 1167 - .probe = logi_djdevice_probe, 1168 - }; 1169 - 1170 - 1171 - static int __init logi_dj_init(void) 1172 - { 1173 - int retval; 1174 - 1175 - dbg_hid("Logitech-DJ:%s\n", __func__); 1176 - 1177 - retval = hid_register_driver(&logi_djreceiver_driver); 1178 - if (retval) 1179 - return retval; 1180 - 1181 - retval = hid_register_driver(&logi_djdevice_driver); 1182 - if (retval) 1183 - hid_unregister_driver(&logi_djreceiver_driver); 1184 - 1185 - return retval; 1186 - 1187 - } 1188 - 1189 - static void __exit logi_dj_exit(void) 1190 - { 1191 - dbg_hid("Logitech-DJ:%s\n", __func__); 1192 - 1193 - hid_unregister_driver(&logi_djdevice_driver); 1194 - hid_unregister_driver(&logi_djreceiver_driver); 1195 - 1196 - } 1197 - 1198 - module_init(logi_dj_init); 1199 - module_exit(logi_dj_exit); 1200 911 MODULE_LICENSE("GPL"); 1201 912 MODULE_AUTHOR("Logitech"); 1202 913 MODULE_AUTHOR("Nestor Lopez Casado");
-125
drivers/hid/hid-logitech-dj.h
··· 1 - #ifndef __HID_LOGITECH_DJ_H 2 - #define __HID_LOGITECH_DJ_H 3 - 4 - /* 5 - * HID driver for Logitech Unifying receivers 6 - * 7 - * Copyright (c) 2011 Logitech 8 - */ 9 - 10 - /* 11 - * This program is free software; you can redistribute it and/or modify 12 - * it under the terms of the GNU General Public License version 2 as 13 - * published by the Free Software Foundation. 14 - * 15 - * This program is distributed in the hope that it will be useful, 16 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 - * GNU General Public License for more details. 19 - * 20 - * You should have received a copy of the GNU General Public License 21 - * along with this program; if not, write to the Free Software 22 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 - * 24 - */ 25 - 26 - #include <linux/kfifo.h> 27 - 28 - #define DJ_MAX_PAIRED_DEVICES 6 29 - #define DJ_MAX_NUMBER_NOTIFICATIONS 8 30 - #define DJ_RECEIVER_INDEX 0 31 - #define DJ_DEVICE_INDEX_MIN 1 32 - #define DJ_DEVICE_INDEX_MAX 6 33 - 34 - #define DJREPORT_SHORT_LENGTH 15 35 - #define DJREPORT_LONG_LENGTH 32 36 - 37 - #define REPORT_ID_DJ_SHORT 0x20 38 - #define REPORT_ID_DJ_LONG 0x21 39 - 40 - #define REPORT_TYPE_RFREPORT_FIRST 0x01 41 - #define REPORT_TYPE_RFREPORT_LAST 0x1F 42 - 43 - /* Command Switch to DJ mode */ 44 - #define REPORT_TYPE_CMD_SWITCH 0x80 45 - #define CMD_SWITCH_PARAM_DEVBITFIELD 0x00 46 - #define CMD_SWITCH_PARAM_TIMEOUT_SECONDS 0x01 47 - #define TIMEOUT_NO_KEEPALIVE 0x00 48 - 49 - /* Command to Get the list of Paired devices */ 50 - #define REPORT_TYPE_CMD_GET_PAIRED_DEVICES 0x81 51 - 52 - /* Device Paired Notification */ 53 - #define REPORT_TYPE_NOTIF_DEVICE_PAIRED 0x41 54 - #define SPFUNCTION_MORE_NOTIF_EXPECTED 0x01 55 - #define SPFUNCTION_DEVICE_LIST_EMPTY 0x02 56 - #define DEVICE_PAIRED_PARAM_SPFUNCTION 0x00 57 - #define DEVICE_PAIRED_PARAM_EQUAD_ID_LSB 0x01 58 - #define DEVICE_PAIRED_PARAM_EQUAD_ID_MSB 0x02 59 - #define DEVICE_PAIRED_RF_REPORT_TYPE 0x03 60 - 61 - /* Device Un-Paired Notification */ 62 - #define REPORT_TYPE_NOTIF_DEVICE_UNPAIRED 0x40 63 - 64 - 65 - /* Connection Status Notification */ 66 - #define REPORT_TYPE_NOTIF_CONNECTION_STATUS 0x42 67 - #define CONNECTION_STATUS_PARAM_STATUS 0x00 68 - #define STATUS_LINKLOSS 0x01 69 - 70 - /* Error Notification */ 71 - #define REPORT_TYPE_NOTIF_ERROR 0x7F 72 - #define NOTIF_ERROR_PARAM_ETYPE 0x00 73 - #define ETYPE_KEEPALIVE_TIMEOUT 0x01 74 - 75 - /* supported DJ HID && RF report types */ 76 - #define REPORT_TYPE_KEYBOARD 0x01 77 - #define REPORT_TYPE_MOUSE 0x02 78 - #define REPORT_TYPE_CONSUMER_CONTROL 0x03 79 - #define REPORT_TYPE_SYSTEM_CONTROL 0x04 80 - #define REPORT_TYPE_MEDIA_CENTER 0x08 81 - #define REPORT_TYPE_LEDS 0x0E 82 - 83 - /* RF Report types bitfield */ 84 - #define STD_KEYBOARD 0x00000002 85 - #define STD_MOUSE 0x00000004 86 - #define MULTIMEDIA 0x00000008 87 - #define POWER_KEYS 0x00000010 88 - #define MEDIA_CENTER 0x00000100 89 - #define KBD_LEDS 0x00004000 90 - 91 - struct dj_report { 92 - u8 report_id; 93 - u8 device_index; 94 - u8 report_type; 95 - u8 report_params[DJREPORT_SHORT_LENGTH - 3]; 96 - }; 97 - 98 - struct dj_receiver_dev { 99 - struct hid_device *hdev; 100 - struct dj_device *paired_dj_devices[DJ_MAX_PAIRED_DEVICES + 101 - DJ_DEVICE_INDEX_MIN]; 102 - struct work_struct work; 103 - struct kfifo notif_fifo; 104 - spinlock_t lock; 105 - bool querying_devices; 106 - }; 107 - 108 - struct dj_device { 109 - struct hid_device *hdev; 110 - struct dj_receiver_dev *dj_receiver_dev; 111 - u32 reports_supported; 112 - u8 device_index; 113 - }; 114 - 115 - /** 116 - * is_dj_device - know if the given dj_device is not the receiver. 117 - * @dj_dev: the dj device to test 118 - * 119 - * This macro tests if a struct dj_device pointer is a device created 120 - * by the bus enumarator. 121 - */ 122 - #define is_dj_device(dj_dev) \ 123 - (&(dj_dev)->dj_receiver_dev->hdev->dev == (dj_dev)->hdev->dev.parent) 124 - 125 - #endif
+1241
drivers/hid/hid-logitech-hidpp.c
··· 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 + 27 + MODULE_LICENSE("GPL"); 28 + MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); 29 + MODULE_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 + 39 + /* bits 1..20 are reserved for classes */ 40 + #define HIDPP_QUIRK_DELAYED_INIT BIT(21) 41 + #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22) 42 + #define HIDPP_QUIRK_MULTI_INPUT BIT(23) 43 + 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 + 66 + struct fap { 67 + u8 feature_index; 68 + u8 funcindex_clientid; 69 + u8 params[HIDPP_REPORT_LONG_LENGTH - 4U]; 70 + }; 71 + 72 + struct rap { 73 + u8 sub_id; 74 + u8 reg_address; 75 + u8 params[HIDPP_REPORT_LONG_LENGTH - 4U]; 76 + }; 77 + 78 + struct 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 + 88 + struct 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 + 99 + struct work_struct work; 100 + struct kfifo delayed_work_fifo; 101 + atomic_t connected; 102 + struct input_dev *delayed_input; 103 + 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 + 123 + static void hidpp_connect_event(struct hidpp_device *hidpp_dev); 124 + 125 + static 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 + 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 + */ 162 + static 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 + 201 + exit: 202 + mutex_unlock(&hidpp->send_mutex); 203 + return ret; 204 + 205 + } 206 + 207 + static 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 + { 211 + struct hidpp_report *message; 212 + int ret; 213 + 214 + if (param_count > sizeof(message->fap.params)) 215 + return -EINVAL; 216 + 217 + message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL); 218 + if (!message) 219 + return -ENOMEM; 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 + 230 + static 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 + { 234 + struct hidpp_report *message; 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 + 244 + message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL); 245 + if (!message) 246 + return -ENOMEM; 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 + 257 + static 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 + 264 + static 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 + 271 + static 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 + 279 + static 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 + 285 + /* -------------------------------------------------------------------------- */ 286 + /* HIDP++ 1.0 commands */ 287 + /* -------------------------------------------------------------------------- */ 288 + 289 + #define HIDPP_SET_REGISTER 0x80 290 + #define HIDPP_GET_REGISTER 0x81 291 + #define HIDPP_SET_LONG_REGISTER 0x82 292 + #define HIDPP_GET_LONG_REGISTER 0x83 293 + 294 + #define HIDPP_REG_PAIRING_INFORMATION 0xB5 295 + #define DEVICE_NAME 0x40 296 + 297 + static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev) 298 + { 299 + struct hidpp_report response; 300 + int ret; 301 + /* hid-logitech-dj is in charge of setting the right device index */ 302 + u8 params[1] = { DEVICE_NAME }; 303 + char *name; 304 + int len; 305 + 306 + ret = hidpp_send_rap_command_sync(hidpp_dev, 307 + REPORT_ID_HIDPP_SHORT, 308 + HIDPP_GET_LONG_REGISTER, 309 + HIDPP_REG_PAIRING_INFORMATION, 310 + params, 1, &response); 311 + if (ret) 312 + return NULL; 313 + 314 + len = response.rap.params[1]; 315 + 316 + if (2 + len > sizeof(response.rap.params)) 317 + return NULL; 318 + 319 + name = kzalloc(len + 1, GFP_KERNEL); 320 + if (!name) 321 + return NULL; 322 + 323 + memcpy(name, &response.rap.params[2], len); 324 + return name; 325 + } 326 + 327 + /* -------------------------------------------------------------------------- */ 328 + /* 0x0000: Root */ 329 + /* -------------------------------------------------------------------------- */ 330 + 331 + #define HIDPP_PAGE_ROOT 0x0000 332 + #define HIDPP_PAGE_ROOT_IDX 0x00 333 + 334 + #define CMD_ROOT_GET_FEATURE 0x01 335 + #define CMD_ROOT_GET_PROTOCOL_VERSION 0x11 336 + 337 + static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature, 338 + u8 *feature_index, u8 *feature_type) 339 + { 340 + struct hidpp_report response; 341 + int ret; 342 + u8 params[2] = { feature >> 8, feature & 0x00FF }; 343 + 344 + ret = hidpp_send_fap_command_sync(hidpp, 345 + HIDPP_PAGE_ROOT_IDX, 346 + CMD_ROOT_GET_FEATURE, 347 + params, 2, &response); 348 + if (ret) 349 + return ret; 350 + 351 + *feature_index = response.fap.params[0]; 352 + *feature_type = response.fap.params[1]; 353 + 354 + return ret; 355 + } 356 + 357 + static int hidpp_root_get_protocol_version(struct hidpp_device *hidpp) 358 + { 359 + struct hidpp_report response; 360 + int ret; 361 + 362 + ret = hidpp_send_fap_command_sync(hidpp, 363 + HIDPP_PAGE_ROOT_IDX, 364 + CMD_ROOT_GET_PROTOCOL_VERSION, 365 + NULL, 0, &response); 366 + 367 + if (ret == HIDPP_ERROR_INVALID_SUBID) { 368 + hidpp->protocol_major = 1; 369 + hidpp->protocol_minor = 0; 370 + return 0; 371 + } 372 + 373 + /* the device might not be connected */ 374 + if (ret == HIDPP_ERROR_RESOURCE_ERROR) 375 + return -EIO; 376 + 377 + if (ret > 0) { 378 + hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", 379 + __func__, ret); 380 + return -EPROTO; 381 + } 382 + if (ret) 383 + return ret; 384 + 385 + hidpp->protocol_major = response.fap.params[0]; 386 + hidpp->protocol_minor = response.fap.params[1]; 387 + 388 + return ret; 389 + } 390 + 391 + static bool hidpp_is_connected(struct hidpp_device *hidpp) 392 + { 393 + int ret; 394 + 395 + ret = hidpp_root_get_protocol_version(hidpp); 396 + if (!ret) 397 + hid_dbg(hidpp->hid_dev, "HID++ %u.%u device connected.\n", 398 + hidpp->protocol_major, hidpp->protocol_minor); 399 + return ret == 0; 400 + } 401 + 402 + /* -------------------------------------------------------------------------- */ 403 + /* 0x0005: GetDeviceNameType */ 404 + /* -------------------------------------------------------------------------- */ 405 + 406 + #define HIDPP_PAGE_GET_DEVICE_NAME_TYPE 0x0005 407 + 408 + #define CMD_GET_DEVICE_NAME_TYPE_GET_COUNT 0x01 409 + #define CMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME 0x11 410 + #define CMD_GET_DEVICE_NAME_TYPE_GET_TYPE 0x21 411 + 412 + static int hidpp_devicenametype_get_count(struct hidpp_device *hidpp, 413 + u8 feature_index, u8 *nameLength) 414 + { 415 + struct hidpp_report response; 416 + int ret; 417 + 418 + ret = hidpp_send_fap_command_sync(hidpp, feature_index, 419 + CMD_GET_DEVICE_NAME_TYPE_GET_COUNT, NULL, 0, &response); 420 + 421 + if (ret > 0) { 422 + hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", 423 + __func__, ret); 424 + return -EPROTO; 425 + } 426 + if (ret) 427 + return ret; 428 + 429 + *nameLength = response.fap.params[0]; 430 + 431 + return ret; 432 + } 433 + 434 + static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp, 435 + u8 feature_index, u8 char_index, char *device_name, int len_buf) 436 + { 437 + struct hidpp_report response; 438 + int ret, i; 439 + int count; 440 + 441 + ret = hidpp_send_fap_command_sync(hidpp, feature_index, 442 + CMD_GET_DEVICE_NAME_TYPE_GET_DEVICE_NAME, &char_index, 1, 443 + &response); 444 + 445 + if (ret > 0) { 446 + hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", 447 + __func__, ret); 448 + return -EPROTO; 449 + } 450 + if (ret) 451 + return ret; 452 + 453 + if (response.report_id == REPORT_ID_HIDPP_LONG) 454 + count = HIDPP_REPORT_LONG_LENGTH - 4; 455 + else 456 + count = HIDPP_REPORT_SHORT_LENGTH - 4; 457 + 458 + if (len_buf < count) 459 + count = len_buf; 460 + 461 + for (i = 0; i < count; i++) 462 + device_name[i] = response.fap.params[i]; 463 + 464 + return count; 465 + } 466 + 467 + static char *hidpp_get_device_name(struct hidpp_device *hidpp) 468 + { 469 + u8 feature_type; 470 + u8 feature_index; 471 + u8 __name_length; 472 + char *name; 473 + unsigned index = 0; 474 + int ret; 475 + 476 + ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_GET_DEVICE_NAME_TYPE, 477 + &feature_index, &feature_type); 478 + if (ret) 479 + return NULL; 480 + 481 + ret = hidpp_devicenametype_get_count(hidpp, feature_index, 482 + &__name_length); 483 + if (ret) 484 + return NULL; 485 + 486 + name = kzalloc(__name_length + 1, GFP_KERNEL); 487 + if (!name) 488 + return NULL; 489 + 490 + while (index < __name_length) { 491 + ret = hidpp_devicenametype_get_device_name(hidpp, 492 + feature_index, index, name + index, 493 + __name_length - index); 494 + if (ret <= 0) { 495 + kfree(name); 496 + return NULL; 497 + } 498 + index += ret; 499 + } 500 + 501 + return name; 502 + } 503 + 504 + /* -------------------------------------------------------------------------- */ 505 + /* 0x6100: TouchPadRawXY */ 506 + /* -------------------------------------------------------------------------- */ 507 + 508 + #define HIDPP_PAGE_TOUCHPAD_RAW_XY 0x6100 509 + 510 + #define CMD_TOUCHPAD_GET_RAW_INFO 0x01 511 + #define CMD_TOUCHPAD_SET_RAW_REPORT_STATE 0x21 512 + 513 + #define EVENT_TOUCHPAD_RAW_XY 0x00 514 + 515 + #define TOUCHPAD_RAW_XY_ORIGIN_LOWER_LEFT 0x01 516 + #define TOUCHPAD_RAW_XY_ORIGIN_UPPER_LEFT 0x03 517 + 518 + struct hidpp_touchpad_raw_info { 519 + u16 x_size; 520 + u16 y_size; 521 + u8 z_range; 522 + u8 area_range; 523 + u8 timestamp_unit; 524 + u8 maxcontacts; 525 + u8 origin; 526 + u16 res; 527 + }; 528 + 529 + struct hidpp_touchpad_raw_xy_finger { 530 + u8 contact_type; 531 + u8 contact_status; 532 + u16 x; 533 + u16 y; 534 + u8 z; 535 + u8 area; 536 + u8 finger_id; 537 + }; 538 + 539 + struct hidpp_touchpad_raw_xy { 540 + u16 timestamp; 541 + struct hidpp_touchpad_raw_xy_finger fingers[2]; 542 + u8 spurious_flag; 543 + u8 end_of_frame; 544 + u8 finger_count; 545 + u8 button; 546 + }; 547 + 548 + static int hidpp_touchpad_get_raw_info(struct hidpp_device *hidpp, 549 + u8 feature_index, struct hidpp_touchpad_raw_info *raw_info) 550 + { 551 + struct hidpp_report response; 552 + int ret; 553 + u8 *params = (u8 *)response.fap.params; 554 + 555 + ret = hidpp_send_fap_command_sync(hidpp, feature_index, 556 + CMD_TOUCHPAD_GET_RAW_INFO, NULL, 0, &response); 557 + 558 + if (ret > 0) { 559 + hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", 560 + __func__, ret); 561 + return -EPROTO; 562 + } 563 + if (ret) 564 + return ret; 565 + 566 + raw_info->x_size = get_unaligned_be16(&params[0]); 567 + raw_info->y_size = get_unaligned_be16(&params[2]); 568 + raw_info->z_range = params[4]; 569 + raw_info->area_range = params[5]; 570 + raw_info->maxcontacts = params[7]; 571 + raw_info->origin = params[8]; 572 + /* res is given in unit per inch */ 573 + raw_info->res = get_unaligned_be16(&params[13]) * 2 / 51; 574 + 575 + return ret; 576 + } 577 + 578 + static int hidpp_touchpad_set_raw_report_state(struct hidpp_device *hidpp_dev, 579 + u8 feature_index, bool send_raw_reports, 580 + bool sensor_enhanced_settings) 581 + { 582 + struct hidpp_report response; 583 + 584 + /* 585 + * Params: 586 + * bit 0 - enable raw 587 + * bit 1 - 16bit Z, no area 588 + * bit 2 - enhanced sensitivity 589 + * bit 3 - width, height (4 bits each) instead of area 590 + * bit 4 - send raw + gestures (degrades smoothness) 591 + * remaining bits - reserved 592 + */ 593 + u8 params = send_raw_reports | (sensor_enhanced_settings << 2); 594 + 595 + return hidpp_send_fap_command_sync(hidpp_dev, feature_index, 596 + CMD_TOUCHPAD_SET_RAW_REPORT_STATE, &params, 1, &response); 597 + } 598 + 599 + static void hidpp_touchpad_touch_event(u8 *data, 600 + struct hidpp_touchpad_raw_xy_finger *finger) 601 + { 602 + u8 x_m = data[0] << 2; 603 + u8 y_m = data[2] << 2; 604 + 605 + finger->x = x_m << 6 | data[1]; 606 + finger->y = y_m << 6 | data[3]; 607 + 608 + finger->contact_type = data[0] >> 6; 609 + finger->contact_status = data[2] >> 6; 610 + 611 + finger->z = data[4]; 612 + finger->area = data[5]; 613 + finger->finger_id = data[6] >> 4; 614 + } 615 + 616 + static void hidpp_touchpad_raw_xy_event(struct hidpp_device *hidpp_dev, 617 + u8 *data, struct hidpp_touchpad_raw_xy *raw_xy) 618 + { 619 + memset(raw_xy, 0, sizeof(struct hidpp_touchpad_raw_xy)); 620 + raw_xy->end_of_frame = data[8] & 0x01; 621 + raw_xy->spurious_flag = (data[8] >> 1) & 0x01; 622 + raw_xy->finger_count = data[15] & 0x0f; 623 + raw_xy->button = (data[8] >> 2) & 0x01; 624 + 625 + if (raw_xy->finger_count) { 626 + hidpp_touchpad_touch_event(&data[2], &raw_xy->fingers[0]); 627 + hidpp_touchpad_touch_event(&data[9], &raw_xy->fingers[1]); 628 + } 629 + } 630 + 631 + /* ************************************************************************** */ 632 + /* */ 633 + /* Device Support */ 634 + /* */ 635 + /* ************************************************************************** */ 636 + 637 + /* -------------------------------------------------------------------------- */ 638 + /* Touchpad HID++ devices */ 639 + /* -------------------------------------------------------------------------- */ 640 + 641 + #define WTP_MANUAL_RESOLUTION 39 642 + 643 + struct wtp_data { 644 + struct input_dev *input; 645 + u16 x_size, y_size; 646 + u8 finger_count; 647 + u8 mt_feature_index; 648 + u8 button_feature_index; 649 + u8 maxcontacts; 650 + bool flip_y; 651 + unsigned int resolution; 652 + }; 653 + 654 + static int wtp_input_mapping(struct hid_device *hdev, struct hid_input *hi, 655 + struct hid_field *field, struct hid_usage *usage, 656 + unsigned long **bit, int *max) 657 + { 658 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 659 + 660 + if ((hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) && 661 + (field->application == HID_GD_KEYBOARD)) 662 + return 0; 663 + 664 + return -1; 665 + } 666 + 667 + static void wtp_populate_input(struct hidpp_device *hidpp, 668 + struct input_dev *input_dev, bool origin_is_hid_core) 669 + { 670 + struct wtp_data *wd = hidpp->private_data; 671 + 672 + if ((hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) && origin_is_hid_core) 673 + /* this is the generic hid-input call */ 674 + return; 675 + 676 + __set_bit(EV_ABS, input_dev->evbit); 677 + __set_bit(EV_KEY, input_dev->evbit); 678 + __clear_bit(EV_REL, input_dev->evbit); 679 + __clear_bit(EV_LED, input_dev->evbit); 680 + 681 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, wd->x_size, 0, 0); 682 + input_abs_set_res(input_dev, ABS_MT_POSITION_X, wd->resolution); 683 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, wd->y_size, 0, 0); 684 + input_abs_set_res(input_dev, ABS_MT_POSITION_Y, wd->resolution); 685 + 686 + /* Max pressure is not given by the devices, pick one */ 687 + input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, 50, 0, 0); 688 + 689 + input_set_capability(input_dev, EV_KEY, BTN_LEFT); 690 + 691 + if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) 692 + input_set_capability(input_dev, EV_KEY, BTN_RIGHT); 693 + else 694 + __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit); 695 + 696 + input_mt_init_slots(input_dev, wd->maxcontacts, INPUT_MT_POINTER | 697 + INPUT_MT_DROP_UNUSED); 698 + 699 + wd->input = input_dev; 700 + } 701 + 702 + static void wtp_touch_event(struct wtp_data *wd, 703 + struct hidpp_touchpad_raw_xy_finger *touch_report) 704 + { 705 + int slot; 706 + 707 + if (!touch_report->finger_id || touch_report->contact_type) 708 + /* no actual data */ 709 + return; 710 + 711 + slot = input_mt_get_slot_by_key(wd->input, touch_report->finger_id); 712 + 713 + input_mt_slot(wd->input, slot); 714 + input_mt_report_slot_state(wd->input, MT_TOOL_FINGER, 715 + touch_report->contact_status); 716 + if (touch_report->contact_status) { 717 + input_event(wd->input, EV_ABS, ABS_MT_POSITION_X, 718 + touch_report->x); 719 + input_event(wd->input, EV_ABS, ABS_MT_POSITION_Y, 720 + wd->flip_y ? wd->y_size - touch_report->y : 721 + touch_report->y); 722 + input_event(wd->input, EV_ABS, ABS_MT_PRESSURE, 723 + touch_report->area); 724 + } 725 + } 726 + 727 + static void wtp_send_raw_xy_event(struct hidpp_device *hidpp, 728 + struct hidpp_touchpad_raw_xy *raw) 729 + { 730 + struct wtp_data *wd = hidpp->private_data; 731 + int i; 732 + 733 + for (i = 0; i < 2; i++) 734 + wtp_touch_event(wd, &(raw->fingers[i])); 735 + 736 + if (raw->end_of_frame && 737 + !(hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS)) 738 + input_event(wd->input, EV_KEY, BTN_LEFT, raw->button); 739 + 740 + if (raw->end_of_frame || raw->finger_count <= 2) { 741 + input_mt_sync_frame(wd->input); 742 + input_sync(wd->input); 743 + } 744 + } 745 + 746 + static int wtp_mouse_raw_xy_event(struct hidpp_device *hidpp, u8 *data) 747 + { 748 + struct wtp_data *wd = hidpp->private_data; 749 + u8 c1_area = ((data[7] & 0xf) * (data[7] & 0xf) + 750 + (data[7] >> 4) * (data[7] >> 4)) / 2; 751 + u8 c2_area = ((data[13] & 0xf) * (data[13] & 0xf) + 752 + (data[13] >> 4) * (data[13] >> 4)) / 2; 753 + struct hidpp_touchpad_raw_xy raw = { 754 + .timestamp = data[1], 755 + .fingers = { 756 + { 757 + .contact_type = 0, 758 + .contact_status = !!data[7], 759 + .x = get_unaligned_le16(&data[3]), 760 + .y = get_unaligned_le16(&data[5]), 761 + .z = c1_area, 762 + .area = c1_area, 763 + .finger_id = data[2], 764 + }, { 765 + .contact_type = 0, 766 + .contact_status = !!data[13], 767 + .x = get_unaligned_le16(&data[9]), 768 + .y = get_unaligned_le16(&data[11]), 769 + .z = c2_area, 770 + .area = c2_area, 771 + .finger_id = data[8], 772 + } 773 + }, 774 + .finger_count = wd->maxcontacts, 775 + .spurious_flag = 0, 776 + .end_of_frame = (data[0] >> 7) == 0, 777 + .button = data[0] & 0x01, 778 + }; 779 + 780 + wtp_send_raw_xy_event(hidpp, &raw); 781 + 782 + return 1; 783 + } 784 + 785 + static int wtp_raw_event(struct hid_device *hdev, u8 *data, int size) 786 + { 787 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 788 + struct wtp_data *wd = hidpp->private_data; 789 + struct hidpp_report *report = (struct hidpp_report *)data; 790 + struct hidpp_touchpad_raw_xy raw; 791 + 792 + if (!wd || !wd->input) 793 + return 1; 794 + 795 + switch (data[0]) { 796 + case 0x02: 797 + if (hidpp->quirks & HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS) { 798 + input_event(wd->input, EV_KEY, BTN_LEFT, 799 + !!(data[1] & 0x01)); 800 + input_event(wd->input, EV_KEY, BTN_RIGHT, 801 + !!(data[1] & 0x02)); 802 + input_sync(wd->input); 803 + } else { 804 + if (size < 21) 805 + return 1; 806 + return wtp_mouse_raw_xy_event(hidpp, &data[7]); 807 + } 808 + case REPORT_ID_HIDPP_LONG: 809 + if ((report->fap.feature_index != wd->mt_feature_index) || 810 + (report->fap.funcindex_clientid != EVENT_TOUCHPAD_RAW_XY)) 811 + return 1; 812 + hidpp_touchpad_raw_xy_event(hidpp, data + 4, &raw); 813 + 814 + wtp_send_raw_xy_event(hidpp, &raw); 815 + return 0; 816 + } 817 + 818 + return 0; 819 + } 820 + 821 + static int wtp_get_config(struct hidpp_device *hidpp) 822 + { 823 + struct wtp_data *wd = hidpp->private_data; 824 + struct hidpp_touchpad_raw_info raw_info = {0}; 825 + u8 feature_type; 826 + int ret; 827 + 828 + ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_TOUCHPAD_RAW_XY, 829 + &wd->mt_feature_index, &feature_type); 830 + if (ret) 831 + /* means that the device is not powered up */ 832 + return ret; 833 + 834 + ret = hidpp_touchpad_get_raw_info(hidpp, wd->mt_feature_index, 835 + &raw_info); 836 + if (ret) 837 + return ret; 838 + 839 + wd->x_size = raw_info.x_size; 840 + wd->y_size = raw_info.y_size; 841 + wd->maxcontacts = raw_info.maxcontacts; 842 + wd->flip_y = raw_info.origin == TOUCHPAD_RAW_XY_ORIGIN_LOWER_LEFT; 843 + wd->resolution = raw_info.res; 844 + if (!wd->resolution) 845 + wd->resolution = WTP_MANUAL_RESOLUTION; 846 + 847 + return 0; 848 + } 849 + 850 + static int wtp_allocate(struct hid_device *hdev, const struct hid_device_id *id) 851 + { 852 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 853 + struct wtp_data *wd; 854 + 855 + wd = devm_kzalloc(&hdev->dev, sizeof(struct wtp_data), 856 + GFP_KERNEL); 857 + if (!wd) 858 + return -ENOMEM; 859 + 860 + hidpp->private_data = wd; 861 + 862 + return 0; 863 + }; 864 + 865 + static void wtp_connect(struct hid_device *hdev, bool connected) 866 + { 867 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 868 + struct wtp_data *wd = hidpp->private_data; 869 + int ret; 870 + 871 + if (!connected) 872 + return; 873 + 874 + if (!wd->x_size) { 875 + ret = wtp_get_config(hidpp); 876 + if (ret) { 877 + hid_err(hdev, "Can not get wtp config: %d\n", ret); 878 + return; 879 + } 880 + } 881 + 882 + hidpp_touchpad_set_raw_report_state(hidpp, wd->mt_feature_index, 883 + true, true); 884 + } 885 + 886 + /* -------------------------------------------------------------------------- */ 887 + /* Generic HID++ devices */ 888 + /* -------------------------------------------------------------------------- */ 889 + 890 + static int hidpp_input_mapping(struct hid_device *hdev, struct hid_input *hi, 891 + struct hid_field *field, struct hid_usage *usage, 892 + unsigned long **bit, int *max) 893 + { 894 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 895 + 896 + if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 897 + return wtp_input_mapping(hdev, hi, field, usage, bit, max); 898 + 899 + return 0; 900 + } 901 + 902 + static void hidpp_populate_input(struct hidpp_device *hidpp, 903 + struct input_dev *input, bool origin_is_hid_core) 904 + { 905 + if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 906 + wtp_populate_input(hidpp, input, origin_is_hid_core); 907 + } 908 + 909 + static void hidpp_input_configured(struct hid_device *hdev, 910 + struct hid_input *hidinput) 911 + { 912 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 913 + struct input_dev *input = hidinput->input; 914 + 915 + hidpp_populate_input(hidpp, input, true); 916 + } 917 + 918 + static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data, 919 + int size) 920 + { 921 + struct hidpp_report *question = hidpp->send_receive_buf; 922 + struct hidpp_report *answer = hidpp->send_receive_buf; 923 + struct hidpp_report *report = (struct hidpp_report *)data; 924 + 925 + /* 926 + * If the mutex is locked then we have a pending answer from a 927 + * previoulsly sent command 928 + */ 929 + if (unlikely(mutex_is_locked(&hidpp->send_mutex))) { 930 + /* 931 + * Check for a correct hidpp20 answer or the corresponding 932 + * error 933 + */ 934 + if (hidpp_match_answer(question, report) || 935 + hidpp_match_error(question, report)) { 936 + *answer = *report; 937 + hidpp->answer_available = true; 938 + wake_up(&hidpp->wait); 939 + /* 940 + * This was an answer to a command that this driver sent 941 + * We return 1 to hid-core to avoid forwarding the 942 + * command upstream as it has been treated by the driver 943 + */ 944 + 945 + return 1; 946 + } 947 + } 948 + 949 + if (unlikely(hidpp_report_is_connect_event(report))) { 950 + atomic_set(&hidpp->connected, 951 + !(report->rap.params[0] & (1 << 6))); 952 + if ((hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) && 953 + (schedule_work(&hidpp->work) == 0)) 954 + dbg_hid("%s: connect event already queued\n", __func__); 955 + return 1; 956 + } 957 + 958 + if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 959 + return wtp_raw_event(hidpp->hid_dev, data, size); 960 + 961 + return 0; 962 + } 963 + 964 + static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report, 965 + u8 *data, int size) 966 + { 967 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 968 + 969 + switch (data[0]) { 970 + case REPORT_ID_HIDPP_LONG: 971 + if (size != HIDPP_REPORT_LONG_LENGTH) { 972 + hid_err(hdev, "received hid++ report of bad size (%d)", 973 + size); 974 + return 1; 975 + } 976 + return hidpp_raw_hidpp_event(hidpp, data, size); 977 + case REPORT_ID_HIDPP_SHORT: 978 + if (size != HIDPP_REPORT_SHORT_LENGTH) { 979 + hid_err(hdev, "received hid++ report of bad size (%d)", 980 + size); 981 + return 1; 982 + } 983 + return hidpp_raw_hidpp_event(hidpp, data, size); 984 + } 985 + 986 + if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 987 + return wtp_raw_event(hdev, data, size); 988 + 989 + return 0; 990 + } 991 + 992 + static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying) 993 + { 994 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 995 + char *name; 996 + 997 + if (use_unifying) 998 + /* 999 + * the device is connected through an Unifying receiver, and 1000 + * might not be already connected. 1001 + * Ask the receiver for its name. 1002 + */ 1003 + name = hidpp_get_unifying_name(hidpp); 1004 + else 1005 + name = hidpp_get_device_name(hidpp); 1006 + 1007 + if (!name) 1008 + hid_err(hdev, "unable to retrieve the name of the device"); 1009 + else 1010 + snprintf(hdev->name, sizeof(hdev->name), "%s", name); 1011 + 1012 + kfree(name); 1013 + } 1014 + 1015 + static int hidpp_input_open(struct input_dev *dev) 1016 + { 1017 + struct hid_device *hid = input_get_drvdata(dev); 1018 + 1019 + return hid_hw_open(hid); 1020 + } 1021 + 1022 + static void hidpp_input_close(struct input_dev *dev) 1023 + { 1024 + struct hid_device *hid = input_get_drvdata(dev); 1025 + 1026 + hid_hw_close(hid); 1027 + } 1028 + 1029 + static struct input_dev *hidpp_allocate_input(struct hid_device *hdev) 1030 + { 1031 + struct input_dev *input_dev = devm_input_allocate_device(&hdev->dev); 1032 + 1033 + if (!input_dev) 1034 + return NULL; 1035 + 1036 + input_set_drvdata(input_dev, hdev); 1037 + input_dev->open = hidpp_input_open; 1038 + input_dev->close = hidpp_input_close; 1039 + 1040 + input_dev->name = hdev->name; 1041 + input_dev->phys = hdev->phys; 1042 + input_dev->uniq = hdev->uniq; 1043 + input_dev->id.bustype = hdev->bus; 1044 + input_dev->id.vendor = hdev->vendor; 1045 + input_dev->id.product = hdev->product; 1046 + input_dev->id.version = hdev->version; 1047 + input_dev->dev.parent = &hdev->dev; 1048 + 1049 + return input_dev; 1050 + } 1051 + 1052 + static void hidpp_connect_event(struct hidpp_device *hidpp) 1053 + { 1054 + struct hid_device *hdev = hidpp->hid_dev; 1055 + int ret = 0; 1056 + bool connected = atomic_read(&hidpp->connected); 1057 + struct input_dev *input; 1058 + char *name, *devm_name; 1059 + 1060 + if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) 1061 + wtp_connect(hdev, connected); 1062 + 1063 + if (!connected || hidpp->delayed_input) 1064 + return; 1065 + 1066 + if (!hidpp->protocol_major) { 1067 + ret = !hidpp_is_connected(hidpp); 1068 + if (ret) { 1069 + hid_err(hdev, "Can not get the protocol version.\n"); 1070 + return; 1071 + } 1072 + } 1073 + 1074 + /* the device is already connected, we can ask for its name and 1075 + * protocol */ 1076 + hid_info(hdev, "HID++ %u.%u device connected.\n", 1077 + hidpp->protocol_major, hidpp->protocol_minor); 1078 + 1079 + input = hidpp_allocate_input(hdev); 1080 + if (!input) { 1081 + hid_err(hdev, "cannot allocate new input device: %d\n", ret); 1082 + return; 1083 + } 1084 + 1085 + name = hidpp_get_device_name(hidpp); 1086 + if (!name) { 1087 + hid_err(hdev, "unable to retrieve the name of the device"); 1088 + } else { 1089 + devm_name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "%s", name); 1090 + if (devm_name) 1091 + input->name = devm_name; 1092 + kfree(name); 1093 + } 1094 + 1095 + hidpp_populate_input(hidpp, input, false); 1096 + 1097 + ret = input_register_device(input); 1098 + if (ret) 1099 + input_free_device(input); 1100 + 1101 + hidpp->delayed_input = input; 1102 + } 1103 + 1104 + static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) 1105 + { 1106 + struct hidpp_device *hidpp; 1107 + int ret; 1108 + bool connected; 1109 + unsigned int connect_mask = HID_CONNECT_DEFAULT; 1110 + 1111 + hidpp = devm_kzalloc(&hdev->dev, sizeof(struct hidpp_device), 1112 + GFP_KERNEL); 1113 + if (!hidpp) 1114 + return -ENOMEM; 1115 + 1116 + hidpp->hid_dev = hdev; 1117 + hid_set_drvdata(hdev, hidpp); 1118 + 1119 + hidpp->quirks = id->driver_data; 1120 + 1121 + if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) { 1122 + ret = wtp_allocate(hdev, id); 1123 + if (ret) 1124 + goto wtp_allocate_fail; 1125 + } 1126 + 1127 + INIT_WORK(&hidpp->work, delayed_work_cb); 1128 + mutex_init(&hidpp->send_mutex); 1129 + init_waitqueue_head(&hidpp->wait); 1130 + 1131 + ret = hid_parse(hdev); 1132 + if (ret) { 1133 + hid_err(hdev, "%s:parse failed\n", __func__); 1134 + goto hid_parse_fail; 1135 + } 1136 + 1137 + /* Allow incoming packets */ 1138 + hid_device_io_start(hdev); 1139 + 1140 + connected = hidpp_is_connected(hidpp); 1141 + if (id->group != HID_GROUP_LOGITECH_DJ_DEVICE) { 1142 + if (!connected) { 1143 + hid_err(hdev, "Device not connected"); 1144 + hid_device_io_stop(hdev); 1145 + goto hid_parse_fail; 1146 + } 1147 + 1148 + hid_info(hdev, "HID++ %u.%u device connected.\n", 1149 + hidpp->protocol_major, hidpp->protocol_minor); 1150 + } 1151 + 1152 + hidpp_overwrite_name(hdev, id->group == HID_GROUP_LOGITECH_DJ_DEVICE); 1153 + atomic_set(&hidpp->connected, connected); 1154 + 1155 + if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) { 1156 + ret = wtp_get_config(hidpp); 1157 + if (ret) 1158 + goto hid_parse_fail; 1159 + } 1160 + 1161 + /* Block incoming packets */ 1162 + hid_device_io_stop(hdev); 1163 + 1164 + if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) 1165 + connect_mask &= ~HID_CONNECT_HIDINPUT; 1166 + 1167 + /* Re-enable hidinput for multi-input devices */ 1168 + if (hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) 1169 + connect_mask |= HID_CONNECT_HIDINPUT; 1170 + 1171 + ret = hid_hw_start(hdev, connect_mask); 1172 + if (ret) { 1173 + hid_err(hdev, "%s:hid_hw_start returned error\n", __func__); 1174 + goto hid_hw_start_fail; 1175 + } 1176 + 1177 + if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) { 1178 + /* Allow incoming packets */ 1179 + hid_device_io_start(hdev); 1180 + 1181 + hidpp_connect_event(hidpp); 1182 + } 1183 + 1184 + return ret; 1185 + 1186 + hid_hw_start_fail: 1187 + hid_parse_fail: 1188 + cancel_work_sync(&hidpp->work); 1189 + mutex_destroy(&hidpp->send_mutex); 1190 + wtp_allocate_fail: 1191 + hid_set_drvdata(hdev, NULL); 1192 + return ret; 1193 + } 1194 + 1195 + static void hidpp_remove(struct hid_device *hdev) 1196 + { 1197 + struct hidpp_device *hidpp = hid_get_drvdata(hdev); 1198 + 1199 + cancel_work_sync(&hidpp->work); 1200 + mutex_destroy(&hidpp->send_mutex); 1201 + hid_hw_stop(hdev); 1202 + } 1203 + 1204 + static const struct hid_device_id hidpp_devices[] = { 1205 + { /* wireless touchpad */ 1206 + HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, 1207 + USB_VENDOR_ID_LOGITECH, 0x4011), 1208 + .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT | 1209 + HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS }, 1210 + { /* wireless touchpad T650 */ 1211 + HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, 1212 + USB_VENDOR_ID_LOGITECH, 0x4101), 1213 + .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT }, 1214 + { /* wireless touchpad T651 */ 1215 + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 1216 + USB_DEVICE_ID_LOGITECH_T651), 1217 + .driver_data = HIDPP_QUIRK_CLASS_WTP }, 1218 + { /* Keyboard TK820 */ 1219 + HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, 1220 + USB_VENDOR_ID_LOGITECH, 0x4102), 1221 + .driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_MULTI_INPUT | 1222 + HIDPP_QUIRK_CLASS_WTP }, 1223 + 1224 + { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, 1225 + USB_VENDOR_ID_LOGITECH, HID_ANY_ID)}, 1226 + {} 1227 + }; 1228 + 1229 + MODULE_DEVICE_TABLE(hid, hidpp_devices); 1230 + 1231 + static struct hid_driver hidpp_driver = { 1232 + .name = "logitech-hidpp-device", 1233 + .id_table = hidpp_devices, 1234 + .probe = hidpp_probe, 1235 + .remove = hidpp_remove, 1236 + .raw_event = hidpp_raw_event, 1237 + .input_configured = hidpp_input_configured, 1238 + .input_mapping = hidpp_input_mapping, 1239 + }; 1240 + 1241 + module_hid_driver(hidpp_driver);
+2
drivers/hid/hid-microsoft.c
··· 274 274 .driver_data = MS_NOGET }, 275 275 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500), 276 276 .driver_data = MS_DUPLICATE_USAGES }, 277 + { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3), 278 + .driver_data = MS_HIDINPUT }, 277 279 278 280 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT), 279 281 .driver_data = MS_PRESENTER },
+27
drivers/hid/hid-multitouch.c
··· 67 67 #define MT_QUIRK_IGNORE_DUPLICATES (1 << 10) 68 68 #define MT_QUIRK_HOVERING (1 << 11) 69 69 #define MT_QUIRK_CONTACT_CNT_ACCURATE (1 << 12) 70 + #define MT_QUIRK_FORCE_GET_FEATURE (1 << 13) 70 71 71 72 #define MT_INPUTMODE_TOUCHSCREEN 0x02 72 73 #define MT_INPUTMODE_TOUCHPAD 0x03 ··· 151 150 #define MT_CLS_FLATFROG 0x0107 152 151 #define MT_CLS_GENERALTOUCH_TWOFINGERS 0x0108 153 152 #define MT_CLS_GENERALTOUCH_PWT_TENFINGERS 0x0109 153 + #define MT_CLS_VTL 0x0110 154 154 155 155 #define MT_DEFAULT_MAXCONTACT 10 156 156 #define MT_MAX_MAXCONTACT 250 ··· 256 254 MT_QUIRK_NO_AREA, 257 255 .sn_move = 2048, 258 256 .maxcontacts = 40, 257 + }, 258 + { .name = MT_CLS_VTL, 259 + .quirks = MT_QUIRK_ALWAYS_VALID | 260 + MT_QUIRK_CONTACT_CNT_ACCURATE | 261 + MT_QUIRK_FORCE_GET_FEATURE, 259 262 }, 260 263 { } 261 264 }; ··· 816 809 struct mt_device *td = hid_get_drvdata(hdev); 817 810 struct hid_report *r; 818 811 struct hid_report_enum *re; 812 + struct mt_class *cls = &td->mtclass; 813 + char *buf; 814 + int report_len; 819 815 820 816 if (td->inputmode < 0) 821 817 return; ··· 826 816 re = &(hdev->report_enum[HID_FEATURE_REPORT]); 827 817 r = re->report_id_hash[td->inputmode]; 828 818 if (r) { 819 + if (cls->quirks & MT_QUIRK_FORCE_GET_FEATURE) { 820 + report_len = hid_report_len(r); 821 + buf = hid_alloc_report_buf(r, GFP_KERNEL); 822 + if (!buf) { 823 + hid_err(hdev, "failed to allocate buffer for report\n"); 824 + return; 825 + } 826 + hid_hw_raw_request(hdev, r->id, buf, report_len, 827 + HID_FEATURE_REPORT, 828 + HID_REQ_GET_REPORT); 829 + kfree(buf); 830 + } 829 831 r->field[0]->value[td->inputmode_index] = td->inputmode_value; 830 832 hid_hw_request(hdev, r, HID_REQ_SET_REPORT); 831 833 } ··· 1302 1280 { .driver_data = MT_CLS_NSMU, 1303 1281 MT_USB_DEVICE(USB_VENDOR_ID_UNITEC, 1304 1282 USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19) }, 1283 + 1284 + /* VTL panels */ 1285 + { .driver_data = MT_CLS_VTL, 1286 + MT_USB_DEVICE(USB_VENDOR_ID_VTL, 1287 + USB_DEVICE_ID_VTL_MULTITOUCH_FF3F) }, 1305 1288 1306 1289 /* Wistron panels */ 1307 1290 { .driver_data = MT_CLS_NSMU,
+55
drivers/hid/hid-plantronics.c
··· 1 + /* 2 + * Plantronics USB HID Driver 3 + * 4 + * Copyright (c) 2014 JD Cole <jd.cole@plantronics.com> 5 + * Copyright (c) 2014 Terry Junge <terry.junge@plantronics.com> 6 + */ 7 + 8 + /* 9 + * This program is free software; you can redistribute it and/or modify it 10 + * under the terms of the GNU General Public License as published by the Free 11 + * Software Foundation; either version 2 of the License, or (at your option) 12 + * any later version. 13 + */ 14 + 15 + #include "hid-ids.h" 16 + 17 + #include <linux/hid.h> 18 + #include <linux/module.h> 19 + 20 + static int plantronics_input_mapping(struct hid_device *hdev, 21 + struct hid_input *hi, 22 + struct hid_field *field, 23 + struct hid_usage *usage, 24 + unsigned long **bit, int *max) 25 + { 26 + if (field->application == HID_CP_CONSUMERCONTROL 27 + && (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) { 28 + hid_dbg(hdev, "usage: %08x (appl: %08x) - defaulted\n", 29 + usage->hid, field->application); 30 + return 0; 31 + } 32 + 33 + hid_dbg(hdev, "usage: %08x (appl: %08x) - ignored\n", 34 + usage->hid, field->application); 35 + 36 + return -1; 37 + } 38 + 39 + static const struct hid_device_id plantronics_devices[] = { 40 + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) }, 41 + { } 42 + }; 43 + MODULE_DEVICE_TABLE(hid, plantronics_devices); 44 + 45 + static struct hid_driver plantronics_driver = { 46 + .name = "plantronics", 47 + .id_table = plantronics_devices, 48 + .input_mapping = plantronics_input_mapping, 49 + }; 50 + module_hid_driver(plantronics_driver); 51 + 52 + MODULE_AUTHOR("JD Cole <jd.cole@plantronics.com>"); 53 + MODULE_AUTHOR("Terry Junge <terry.junge@plantronics.com>"); 54 + MODULE_DESCRIPTION("Plantronics USB HID Driver"); 55 + MODULE_LICENSE("GPL");
+63 -20
drivers/hid/hid-rmi.c
··· 584 584 bool has_query10 = false; 585 585 bool has_query11; 586 586 bool has_query12; 587 + bool has_query27; 588 + bool has_query28; 589 + bool has_query36 = false; 587 590 bool has_physical_props; 588 591 bool has_gestures; 589 592 bool has_rel; 593 + bool has_data40 = false; 590 594 unsigned x_size, y_size; 591 - u16 query12_offset; 595 + u16 query_offset; 592 596 593 597 if (!data->f11.query_base_addr) { 594 598 hid_err(hdev, "No 2D sensor found, giving up.\n"); ··· 608 604 has_query9 = !!(buf[0] & BIT(3)); 609 605 has_query11 = !!(buf[0] & BIT(4)); 610 606 has_query12 = !!(buf[0] & BIT(5)); 607 + has_query27 = !!(buf[0] & BIT(6)); 608 + has_query28 = !!(buf[0] & BIT(7)); 611 609 612 610 /* query 1 to get the max number of fingers */ 613 611 ret = rmi_read(hdev, data->f11.query_base_addr + 1, buf); ··· 632 626 has_rel = !!(buf[0] & BIT(3)); 633 627 has_gestures = !!(buf[0] & BIT(5)); 634 628 629 + /* 630 + * At least 4 queries are guaranteed to be present in F11 631 + * +1 for query 5 which is present since absolute events are 632 + * reported and +1 for query 12. 633 + */ 634 + query_offset = 6; 635 + 636 + if (has_rel) 637 + ++query_offset; /* query 6 is present */ 638 + 635 639 if (has_gestures) { 636 640 /* query 8 to find out if query 10 exists */ 637 - ret = rmi_read(hdev, data->f11.query_base_addr + 8, buf); 641 + ret = rmi_read(hdev, 642 + data->f11.query_base_addr + query_offset + 1, buf); 638 643 if (ret) { 639 644 hid_err(hdev, "can not read gesture information: %d.\n", 640 645 ret); 641 646 return ret; 642 647 } 643 648 has_query10 = !!(buf[0] & BIT(2)); 649 + 650 + query_offset += 2; /* query 7 and 8 are present */ 644 651 } 645 652 646 - /* 647 - * At least 4 queries are guaranteed to be present in F11 648 - * +1 for query 5 which is present since absolute events are 649 - * reported and +1 for query 12. 650 - */ 651 - query12_offset = 6; 652 - 653 - if (has_rel) 654 - ++query12_offset; /* query 6 is present */ 655 - 656 - if (has_gestures) 657 - query12_offset += 2; /* query 7 and 8 are present */ 658 - 659 653 if (has_query9) 660 - ++query12_offset; 654 + ++query_offset; 661 655 662 656 if (has_query10) 663 - ++query12_offset; 657 + ++query_offset; 664 658 665 659 if (has_query11) 666 - ++query12_offset; 660 + ++query_offset; 667 661 668 662 /* query 12 to know if the physical properties are reported */ 669 663 if (has_query12) { 670 664 ret = rmi_read(hdev, data->f11.query_base_addr 671 - + query12_offset, buf); 665 + + query_offset, buf); 672 666 if (ret) { 673 667 hid_err(hdev, "can not get query 12: %d.\n", ret); 674 668 return ret; ··· 676 670 has_physical_props = !!(buf[0] & BIT(5)); 677 671 678 672 if (has_physical_props) { 673 + query_offset += 1; 679 674 ret = rmi_read_block(hdev, 680 675 data->f11.query_base_addr 681 - + query12_offset + 1, buf, 4); 676 + + query_offset, buf, 4); 682 677 if (ret) { 683 678 hid_err(hdev, "can not read query 15-18: %d.\n", 684 679 ret); ··· 694 687 695 688 hid_info(hdev, "%s: size in mm: %d x %d\n", 696 689 __func__, data->x_size_mm, data->y_size_mm); 690 + 691 + /* 692 + * query 15 - 18 contain the size of the sensor 693 + * and query 19 - 26 contain bezel dimensions 694 + */ 695 + query_offset += 12; 697 696 } 698 697 } 698 + 699 + if (has_query27) 700 + ++query_offset; 701 + 702 + if (has_query28) { 703 + ret = rmi_read(hdev, data->f11.query_base_addr 704 + + query_offset, buf); 705 + if (ret) { 706 + hid_err(hdev, "can not get query 28: %d.\n", ret); 707 + return ret; 708 + } 709 + 710 + has_query36 = !!(buf[0] & BIT(6)); 711 + } 712 + 713 + if (has_query36) { 714 + query_offset += 2; 715 + ret = rmi_read(hdev, data->f11.query_base_addr 716 + + query_offset, buf); 717 + if (ret) { 718 + hid_err(hdev, "can not get query 36: %d.\n", ret); 719 + return ret; 720 + } 721 + 722 + has_data40 = !!(buf[0] & BIT(5)); 723 + } 724 + 725 + 726 + if (has_data40) 727 + data->f11.report_size += data->max_fingers * 2; 699 728 700 729 /* 701 730 * retrieve the ctrl registers
+116 -34
drivers/hid/hid-sony.c
··· 798 798 __u8 buf[36]; 799 799 }; 800 800 801 + #define DS4_REPORT_0x02_SIZE 37 802 + #define DS4_REPORT_0x05_SIZE 32 803 + #define DS4_REPORT_0x11_SIZE 78 804 + #define DS4_REPORT_0x81_SIZE 7 805 + #define SIXAXIS_REPORT_0xF2_SIZE 18 806 + 801 807 static spinlock_t sony_dev_list_lock; 802 808 static LIST_HEAD(sony_device_list); 803 809 static DEFINE_IDA(sony_device_id_allocator); ··· 817 811 struct work_struct state_worker; 818 812 struct power_supply battery; 819 813 int device_id; 814 + __u8 *output_report_dmabuf; 820 815 821 816 #ifdef CONFIG_SONY_FF 822 817 __u8 left; ··· 1149 1142 1150 1143 static int sixaxis_set_operational_bt(struct hid_device *hdev) 1151 1144 { 1152 - unsigned char buf[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 }; 1153 - return hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf), 1145 + static const __u8 report[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 }; 1146 + __u8 *buf; 1147 + int ret; 1148 + 1149 + buf = kmemdup(report, sizeof(report), GFP_KERNEL); 1150 + if (!buf) 1151 + return -ENOMEM; 1152 + 1153 + ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(report), 1154 1154 HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 1155 + 1156 + kfree(buf); 1157 + 1158 + return ret; 1155 1159 } 1156 1160 1157 1161 /* ··· 1171 1153 */ 1172 1154 static int dualshock4_set_operational_bt(struct hid_device *hdev) 1173 1155 { 1174 - __u8 buf[37] = { 0 }; 1156 + __u8 *buf; 1157 + int ret; 1175 1158 1176 - return hid_hw_raw_request(hdev, 0x02, buf, sizeof(buf), 1159 + buf = kmalloc(DS4_REPORT_0x02_SIZE, GFP_KERNEL); 1160 + if (!buf) 1161 + return -ENOMEM; 1162 + 1163 + ret = hid_hw_raw_request(hdev, 0x02, buf, DS4_REPORT_0x02_SIZE, 1177 1164 HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 1165 + 1166 + kfree(buf); 1167 + 1168 + return ret; 1178 1169 } 1179 1170 1180 1171 static void sixaxis_set_leds_from_id(int id, __u8 values[MAX_LEDS]) ··· 1498 1471 1499 1472 static void sixaxis_state_worker(struct work_struct *work) 1500 1473 { 1501 - struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); 1502 - int n; 1503 - union sixaxis_output_report_01 report = { 1474 + static const union sixaxis_output_report_01 default_report = { 1504 1475 .buf = { 1505 1476 0x01, 1506 1477 0x00, 0xff, 0x00, 0xff, 0x00, ··· 1510 1485 0x00, 0x00, 0x00, 0x00, 0x00 1511 1486 } 1512 1487 }; 1488 + struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); 1489 + struct sixaxis_output_report *report = 1490 + (struct sixaxis_output_report *)sc->output_report_dmabuf; 1491 + int n; 1492 + 1493 + /* Initialize the report with default values */ 1494 + memcpy(report, &default_report, sizeof(struct sixaxis_output_report)); 1513 1495 1514 1496 #ifdef CONFIG_SONY_FF 1515 - report.data.rumble.right_motor_on = sc->right ? 1 : 0; 1516 - report.data.rumble.left_motor_force = sc->left; 1497 + report->rumble.right_motor_on = sc->right ? 1 : 0; 1498 + report->rumble.left_motor_force = sc->left; 1517 1499 #endif 1518 1500 1519 - report.data.leds_bitmap |= sc->led_state[0] << 1; 1520 - report.data.leds_bitmap |= sc->led_state[1] << 2; 1521 - report.data.leds_bitmap |= sc->led_state[2] << 3; 1522 - report.data.leds_bitmap |= sc->led_state[3] << 4; 1501 + report->leds_bitmap |= sc->led_state[0] << 1; 1502 + report->leds_bitmap |= sc->led_state[1] << 2; 1503 + report->leds_bitmap |= sc->led_state[2] << 3; 1504 + report->leds_bitmap |= sc->led_state[3] << 4; 1523 1505 1524 1506 /* Set flag for all leds off, required for 3rd party INTEC controller */ 1525 - if ((report.data.leds_bitmap & 0x1E) == 0) 1526 - report.data.leds_bitmap |= 0x20; 1507 + if ((report->leds_bitmap & 0x1E) == 0) 1508 + report->leds_bitmap |= 0x20; 1527 1509 1528 1510 /* 1529 1511 * The LEDs in the report are indexed in reverse order to their ··· 1543 1511 */ 1544 1512 for (n = 0; n < 4; n++) { 1545 1513 if (sc->led_delay_on[n] || sc->led_delay_off[n]) { 1546 - report.data.led[3 - n].duty_off = sc->led_delay_off[n]; 1547 - report.data.led[3 - n].duty_on = sc->led_delay_on[n]; 1514 + report->led[3 - n].duty_off = sc->led_delay_off[n]; 1515 + report->led[3 - n].duty_on = sc->led_delay_on[n]; 1548 1516 } 1549 1517 } 1550 1518 1551 - hid_hw_raw_request(sc->hdev, report.data.report_id, report.buf, 1552 - sizeof(report), HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); 1519 + hid_hw_raw_request(sc->hdev, report->report_id, (__u8 *)report, 1520 + sizeof(struct sixaxis_output_report), 1521 + HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); 1553 1522 } 1554 1523 1555 1524 static void dualshock4_state_worker(struct work_struct *work) 1556 1525 { 1557 1526 struct sony_sc *sc = container_of(work, struct sony_sc, state_worker); 1558 1527 struct hid_device *hdev = sc->hdev; 1528 + __u8 *buf = sc->output_report_dmabuf; 1559 1529 int offset; 1560 1530 1561 - __u8 buf[78] = { 0 }; 1562 - 1563 1531 if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) { 1532 + memset(buf, 0, DS4_REPORT_0x05_SIZE); 1564 1533 buf[0] = 0x05; 1565 1534 buf[1] = 0xFF; 1566 1535 offset = 4; 1567 1536 } else { 1537 + memset(buf, 0, DS4_REPORT_0x11_SIZE); 1568 1538 buf[0] = 0x11; 1569 1539 buf[1] = 0xB0; 1570 1540 buf[3] = 0x0F; ··· 1594 1560 buf[offset++] = sc->led_delay_off[3]; 1595 1561 1596 1562 if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) 1597 - hid_hw_output_report(hdev, buf, 32); 1563 + hid_hw_output_report(hdev, buf, DS4_REPORT_0x05_SIZE); 1598 1564 else 1599 - hid_hw_raw_request(hdev, 0x11, buf, 78, 1565 + hid_hw_raw_request(hdev, 0x11, buf, DS4_REPORT_0x11_SIZE, 1600 1566 HID_OUTPUT_REPORT, HID_REQ_SET_REPORT); 1567 + } 1568 + 1569 + static int sony_allocate_output_report(struct sony_sc *sc) 1570 + { 1571 + if (sc->quirks & SIXAXIS_CONTROLLER) 1572 + sc->output_report_dmabuf = 1573 + kmalloc(sizeof(union sixaxis_output_report_01), 1574 + GFP_KERNEL); 1575 + else if (sc->quirks & DUALSHOCK4_CONTROLLER_BT) 1576 + sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x11_SIZE, 1577 + GFP_KERNEL); 1578 + else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) 1579 + sc->output_report_dmabuf = kmalloc(DS4_REPORT_0x05_SIZE, 1580 + GFP_KERNEL); 1581 + else 1582 + return 0; 1583 + 1584 + if (!sc->output_report_dmabuf) 1585 + return -ENOMEM; 1586 + 1587 + return 0; 1601 1588 } 1602 1589 1603 1590 #ifdef CONFIG_SONY_FF ··· 1809 1754 1810 1755 static int sony_check_add(struct sony_sc *sc) 1811 1756 { 1757 + __u8 *buf = NULL; 1812 1758 int n, ret; 1813 1759 1814 1760 if ((sc->quirks & DUALSHOCK4_CONTROLLER_BT) || ··· 1825 1769 return 0; 1826 1770 } 1827 1771 } else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) { 1828 - __u8 buf[7]; 1772 + buf = kmalloc(DS4_REPORT_0x81_SIZE, GFP_KERNEL); 1773 + if (!buf) 1774 + return -ENOMEM; 1829 1775 1830 1776 /* 1831 1777 * The MAC address of a DS4 controller connected via USB can be 1832 1778 * retrieved with feature report 0x81. The address begins at 1833 1779 * offset 1. 1834 1780 */ 1835 - ret = hid_hw_raw_request(sc->hdev, 0x81, buf, sizeof(buf), 1836 - HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 1781 + ret = hid_hw_raw_request(sc->hdev, 0x81, buf, 1782 + DS4_REPORT_0x81_SIZE, HID_FEATURE_REPORT, 1783 + HID_REQ_GET_REPORT); 1837 1784 1838 - if (ret != 7) { 1785 + if (ret != DS4_REPORT_0x81_SIZE) { 1839 1786 hid_err(sc->hdev, "failed to retrieve feature report 0x81 with the DualShock 4 MAC address\n"); 1840 - return ret < 0 ? ret : -EINVAL; 1787 + ret = ret < 0 ? ret : -EINVAL; 1788 + goto out_free; 1841 1789 } 1842 1790 1843 1791 memcpy(sc->mac_address, &buf[1], sizeof(sc->mac_address)); 1844 1792 } else if (sc->quirks & SIXAXIS_CONTROLLER_USB) { 1845 - __u8 buf[18]; 1793 + buf = kmalloc(SIXAXIS_REPORT_0xF2_SIZE, GFP_KERNEL); 1794 + if (!buf) 1795 + return -ENOMEM; 1846 1796 1847 1797 /* 1848 1798 * The MAC address of a Sixaxis controller connected via USB can 1849 1799 * be retrieved with feature report 0xf2. The address begins at 1850 1800 * offset 4. 1851 1801 */ 1852 - ret = hid_hw_raw_request(sc->hdev, 0xf2, buf, sizeof(buf), 1853 - HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 1802 + ret = hid_hw_raw_request(sc->hdev, 0xf2, buf, 1803 + SIXAXIS_REPORT_0xF2_SIZE, HID_FEATURE_REPORT, 1804 + HID_REQ_GET_REPORT); 1854 1805 1855 - if (ret != 18) { 1806 + if (ret != SIXAXIS_REPORT_0xF2_SIZE) { 1856 1807 hid_err(sc->hdev, "failed to retrieve feature report 0xf2 with the Sixaxis MAC address\n"); 1857 - return ret < 0 ? ret : -EINVAL; 1808 + ret = ret < 0 ? ret : -EINVAL; 1809 + goto out_free; 1858 1810 } 1859 1811 1860 1812 /* ··· 1875 1811 return 0; 1876 1812 } 1877 1813 1878 - return sony_check_add_dev_list(sc); 1814 + ret = sony_check_add_dev_list(sc); 1815 + 1816 + out_free: 1817 + 1818 + kfree(buf); 1819 + 1820 + return ret; 1879 1821 } 1880 1822 1881 1823 static int sony_set_device_id(struct sony_sc *sc) ··· 1963 1893 if (ret) { 1964 1894 hid_err(hdev, "hw start failed\n"); 1965 1895 return ret; 1896 + } 1897 + 1898 + ret = sony_allocate_output_report(sc); 1899 + if (ret < 0) { 1900 + hid_err(hdev, "failed to allocate the output report buffer\n"); 1901 + goto err_stop; 1966 1902 } 1967 1903 1968 1904 ret = sony_set_device_id(sc); ··· 2060 1984 if (sc->quirks & SONY_BATTERY_SUPPORT) 2061 1985 sony_battery_remove(sc); 2062 1986 sony_cancel_work_sync(sc); 1987 + kfree(sc->output_report_dmabuf); 2063 1988 sony_remove_dev_list(sc); 2064 1989 sony_release_device_id(sc); 2065 1990 hid_hw_stop(hdev); ··· 2080 2003 } 2081 2004 2082 2005 sony_cancel_work_sync(sc); 2006 + 2007 + kfree(sc->output_report_dmabuf); 2083 2008 2084 2009 sony_remove_dev_list(sc); 2085 2010 ··· 2112 2033 .driver_data = PS3REMOTE }, 2113 2034 /* Logitech Harmony Adapter for PS3 */ 2114 2035 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3), 2036 + .driver_data = PS3REMOTE }, 2037 + /* SMK-Link PS3 BD Remote Control */ 2038 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SMK, USB_DEVICE_ID_SMK_PS3_BDREMOTE), 2115 2039 .driver_data = PS3REMOTE }, 2116 2040 /* Sony Dualshock 4 controllers for PS4 */ 2117 2041 { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
+9 -5
drivers/hid/i2c-hid/i2c-hid.c
··· 137 137 * descriptor. */ 138 138 unsigned int bufsize; /* i2c buffer size */ 139 139 char *inbuf; /* Input buffer */ 140 + char *rawbuf; /* Raw Input buffer */ 140 141 char *cmdbuf; /* Command buffer */ 141 142 char *argsbuf; /* Command arguments buffer */ 142 143 ··· 438 437 report->id, buffer, size)) 439 438 return; 440 439 441 - i2c_hid_dbg(ihid, "report (len=%d): %*ph\n", size, size, ihid->inbuf); 440 + i2c_hid_dbg(ihid, "report (len=%d): %*ph\n", size, size, buffer); 442 441 443 442 ret_size = buffer[0] | (buffer[1] << 8); 444 443 ··· 505 504 static void i2c_hid_free_buffers(struct i2c_hid *ihid) 506 505 { 507 506 kfree(ihid->inbuf); 507 + kfree(ihid->rawbuf); 508 508 kfree(ihid->argsbuf); 509 509 kfree(ihid->cmdbuf); 510 510 ihid->inbuf = NULL; 511 + ihid->rawbuf = NULL; 511 512 ihid->cmdbuf = NULL; 512 513 ihid->argsbuf = NULL; 513 514 ihid->bufsize = 0; ··· 525 522 report_size; /* report */ 526 523 527 524 ihid->inbuf = kzalloc(report_size, GFP_KERNEL); 525 + ihid->rawbuf = kzalloc(report_size, GFP_KERNEL); 528 526 ihid->argsbuf = kzalloc(args_len, GFP_KERNEL); 529 527 ihid->cmdbuf = kzalloc(sizeof(union command) + args_len, GFP_KERNEL); 530 528 531 - if (!ihid->inbuf || !ihid->argsbuf || !ihid->cmdbuf) { 529 + if (!ihid->inbuf || !ihid->rawbuf || !ihid->argsbuf || !ihid->cmdbuf) { 532 530 i2c_hid_free_buffers(ihid); 533 531 return -ENOMEM; 534 532 } ··· 556 552 557 553 ret = i2c_hid_get_report(client, 558 554 report_type == HID_FEATURE_REPORT ? 0x03 : 0x01, 559 - report_number, ihid->inbuf, ask_count); 555 + report_number, ihid->rawbuf, ask_count); 560 556 561 557 if (ret < 0) 562 558 return ret; 563 559 564 - ret_count = ihid->inbuf[0] | (ihid->inbuf[1] << 8); 560 + ret_count = ihid->rawbuf[0] | (ihid->rawbuf[1] << 8); 565 561 566 562 if (ret_count <= 2) 567 563 return 0; ··· 570 566 571 567 /* The query buffer contains the size, dropping it in the reply */ 572 568 count = min(count, ret_count - 2); 573 - memcpy(buf, ihid->inbuf + 2, count); 569 + memcpy(buf, ihid->rawbuf + 2, count); 574 570 575 571 return count; 576 572 }
+1 -2
drivers/hid/usbhid/hid-core.c
··· 340 340 report = usbhid->out[usbhid->outtail].report; 341 341 raw_report = usbhid->out[usbhid->outtail].raw_report; 342 342 343 - usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 344 - 1 + (report->id > 0); 343 + usbhid->urbout->transfer_buffer_length = hid_report_len(report); 345 344 usbhid->urbout->dev = hid_to_usb_dev(hid); 346 345 if (raw_report) { 347 346 memcpy(usbhid->outbuf, raw_report,
+1
drivers/hid/usbhid/hid-quirks.c
··· 79 79 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS }, 80 80 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET }, 81 81 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_NOGET }, 82 + { USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_3, HID_QUIRK_NO_INIT_REPORTS }, 82 83 { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, 83 84 { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS }, 84 85 { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS },
+1 -1
drivers/hid/wacom.h
··· 140 140 141 141 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len); 142 142 void wacom_setup_device_quirks(struct wacom_features *features); 143 - int wacom_setup_input_capabilities(struct input_dev *input_dev, 143 + int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, 144 144 struct wacom_wac *wacom_wac); 145 145 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev, 146 146 struct wacom_wac *wacom_wac);
+39 -20
drivers/hid/wacom_sys.c
··· 13 13 14 14 #include "wacom_wac.h" 15 15 #include "wacom.h" 16 + #include <linux/input/mt.h> 16 17 17 18 #define WAC_MSG_RETRIES 5 18 19 ··· 186 185 if (!pen && !finger) 187 186 return; 188 187 189 - if (finger && !features->touch_max) 190 - /* touch device at least supports one touch point */ 191 - features->touch_max = 1; 188 + /* 189 + * Bamboo models do not support HID_DG_CONTACTMAX. 190 + * And, Bamboo Pen only descriptor contains touch. 191 + */ 192 + if (features->type != BAMBOO_PT) { 193 + /* ISDv4 touch devices at least supports one touch point */ 194 + if (finger && !features->touch_max) 195 + features->touch_max = 1; 196 + } 192 197 193 198 switch (usage->hid) { 194 199 case HID_GD_X: ··· 228 221 229 222 if (features->type == HID_GENERIC) 230 223 wacom_wac_usage_mapping(hdev, field, usage); 224 + } 225 + 226 + static void wacom_post_parse_hid(struct hid_device *hdev, 227 + struct wacom_features *features) 228 + { 229 + struct wacom *wacom = hid_get_drvdata(hdev); 230 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 231 + 232 + if (features->type == HID_GENERIC) { 233 + /* Any last-minute generic device setup */ 234 + if (features->touch_max > 1) { 235 + input_mt_init_slots(wacom_wac->input, wacom_wac->features.touch_max, 236 + INPUT_MT_DIRECT); 237 + } 238 + } 231 239 } 232 240 233 241 static void wacom_parse_hid(struct hid_device *hdev, ··· 279 257 wacom_usage_mapping(hdev, hreport->field[i], 280 258 hreport->field[i]->usage + j); 281 259 } 260 + 261 + wacom_post_parse_hid(hdev, features); 282 262 } 283 263 284 264 static int wacom_hid_set_device_mode(struct hid_device *hdev) ··· 1146 1122 input_free_device(wacom->wacom_wac.input); 1147 1123 } 1148 1124 if (wacom->wacom_wac.pad_input) { 1149 - if (wacom->wacom_wac.input_registered) 1125 + if (wacom->wacom_wac.pad_registered) 1150 1126 input_unregister_device(wacom->wacom_wac.pad_input); 1151 1127 else 1152 1128 input_free_device(wacom->wacom_wac.pad_input); ··· 1168 1144 if (!input_dev || !pad_input_dev) 1169 1145 return -EINVAL; 1170 1146 1171 - error = wacom_setup_input_capabilities(input_dev, wacom_wac); 1172 - if (error) 1173 - return error; 1174 - 1175 - error = input_register_device(input_dev); 1176 - if (error) 1177 - return error; 1147 + error = wacom_setup_pentouch_input_capabilities(input_dev, wacom_wac); 1148 + if (!error) { 1149 + error = input_register_device(input_dev); 1150 + if (error) 1151 + return error; 1152 + wacom_wac->input_registered = true; 1153 + } 1178 1154 1179 1155 error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); 1180 1156 if (error) { ··· 1186 1162 error = input_register_device(pad_input_dev); 1187 1163 if (error) 1188 1164 goto fail_register_pad_input; 1165 + wacom_wac->pad_registered = true; 1189 1166 1190 1167 error = wacom_initialize_leds(wacom); 1191 1168 if (error) 1192 1169 goto fail_leds; 1193 1170 } 1194 1171 1195 - wacom_wac->input_registered = true; 1196 - 1197 1172 return 0; 1198 1173 1199 1174 fail_leds: 1200 1175 input_unregister_device(pad_input_dev); 1201 1176 pad_input_dev = NULL; 1177 + wacom_wac->pad_registered = false; 1202 1178 fail_register_pad_input: 1203 1179 input_unregister_device(input_dev); 1204 1180 wacom_wac->input = NULL; 1181 + wacom_wac->input_registered = false; 1205 1182 return error; 1206 1183 } 1207 1184 ··· 1339 1314 features->unitExpo); 1340 1315 } 1341 1316 1342 - static int wacom_hid_report_len(struct hid_report *report) 1343 - { 1344 - /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ 1345 - return ((report->size - 1) >> 3) + 1 + (report->id > 0); 1346 - } 1347 - 1348 1317 static size_t wacom_compute_pktlen(struct hid_device *hdev) 1349 1318 { 1350 1319 struct hid_report_enum *report_enum; ··· 1348 1329 report_enum = hdev->report_enum + HID_INPUT_REPORT; 1349 1330 1350 1331 list_for_each_entry(report, &report_enum->report_list, list) { 1351 - size_t report_size = wacom_hid_report_len(report); 1332 + size_t report_size = hid_report_len(report); 1352 1333 if (report_size > size) 1353 1334 size = report_size; 1354 1335 }
+142 -73
drivers/hid/wacom_wac.c
··· 25 25 #define WACOM_INTUOS_RES 100 26 26 #define WACOM_INTUOS3_RES 200 27 27 28 + /* Newer Cintiq and DTU have an offset between tablet and screen areas */ 29 + #define WACOM_DTU_OFFSET 200 30 + #define WACOM_CINTIQ_OFFSET 400 31 + 28 32 /* 29 33 * Scale factor relating reported contact size to logical contact area. 30 34 * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo ··· 604 600 } 605 601 input_report_abs(input, ABS_PRESSURE, t); 606 602 input_report_abs(input, ABS_TILT_X, 607 - ((data[7] << 1) & 0x7e) | (data[8] >> 7)); 608 - input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f); 603 + (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); 604 + input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); 609 605 input_report_key(input, BTN_STYLUS, data[1] & 2); 610 606 input_report_key(input, BTN_STYLUS2, data[1] & 4); 611 607 input_report_key(input, BTN_TOUCH, t > 10); ··· 616 612 input_report_abs(input, ABS_WHEEL, 617 613 (data[6] << 2) | ((data[7] >> 6) & 3)); 618 614 input_report_abs(input, ABS_TILT_X, 619 - ((data[7] << 1) & 0x7e) | (data[8] >> 7)); 620 - input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f); 615 + (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); 616 + input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); 621 617 } 622 618 } 623 619 ··· 919 915 input_report_key(input, BTN_EXTRA, data[6] & 0x10); 920 916 921 917 input_report_abs(input, ABS_TILT_X, 922 - ((data[7] << 1) & 0x7e) | (data[8] >> 7)); 923 - input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f); 918 + (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64); 919 + input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64); 924 920 } else { 925 921 /* 2D mouse packet */ 926 922 input_report_key(input, BTN_LEFT, data[8] & 0x04); ··· 1381 1377 { 1382 1378 struct wacom *wacom = hid_get_drvdata(hdev); 1383 1379 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1384 - struct input_dev *input = wacom_wac->input; 1380 + struct wacom_features *features = &wacom_wac->features; 1385 1381 unsigned touch_max = wacom_wac->features.touch_max; 1386 1382 1387 1383 switch (usage->hid) { 1388 1384 case HID_GD_X: 1385 + features->last_slot_field = usage->hid; 1389 1386 if (touch_max == 1) 1390 1387 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4); 1391 1388 else ··· 1394 1389 ABS_MT_POSITION_X, 4); 1395 1390 break; 1396 1391 case HID_GD_Y: 1392 + features->last_slot_field = usage->hid; 1397 1393 if (touch_max == 1) 1398 1394 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4); 1399 1395 else ··· 1402 1396 ABS_MT_POSITION_Y, 4); 1403 1397 break; 1404 1398 case HID_DG_CONTACTID: 1405 - input_mt_init_slots(input, wacom_wac->features.touch_max, 1406 - INPUT_MT_DIRECT); 1399 + features->last_slot_field = usage->hid; 1407 1400 break; 1408 1401 case HID_DG_INRANGE: 1402 + features->last_slot_field = usage->hid; 1409 1403 break; 1410 1404 case HID_DG_INVERT: 1405 + features->last_slot_field = usage->hid; 1411 1406 break; 1412 1407 case HID_DG_TIPSWITCH: 1408 + features->last_slot_field = usage->hid; 1413 1409 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0); 1414 1410 break; 1411 + } 1412 + } 1413 + 1414 + static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac, 1415 + struct input_dev *input) 1416 + { 1417 + struct hid_data *hid_data = &wacom_wac->hid_data; 1418 + bool mt = wacom_wac->features.touch_max > 1; 1419 + bool prox = hid_data->tipswitch && 1420 + !wacom_wac->shared->stylus_in_proximity; 1421 + 1422 + if (mt) { 1423 + int slot; 1424 + 1425 + slot = input_mt_get_slot_by_key(input, hid_data->id); 1426 + input_mt_slot(input, slot); 1427 + input_mt_report_slot_state(input, MT_TOOL_FINGER, prox); 1428 + } 1429 + else { 1430 + input_report_key(input, BTN_TOUCH, prox); 1431 + } 1432 + 1433 + if (prox) { 1434 + input_report_abs(input, mt ? ABS_MT_POSITION_X : ABS_X, 1435 + hid_data->x); 1436 + input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y, 1437 + hid_data->y); 1415 1438 } 1416 1439 } 1417 1440 ··· 1466 1431 } 1467 1432 1468 1433 1434 + if (usage->usage_index + 1 == field->report_count) { 1435 + if (usage->hid == wacom_wac->features.last_slot_field) 1436 + wacom_wac_finger_slot(wacom_wac, wacom_wac->input); 1437 + } 1438 + 1469 1439 return 0; 1470 1440 } 1471 1441 1472 - static void wacom_wac_finger_mt_report(struct wacom_wac *wacom_wac, 1473 - struct input_dev *input, bool touch) 1442 + static int wacom_wac_finger_count_touches(struct hid_device *hdev) 1474 1443 { 1475 - int slot; 1476 - struct hid_data *hid_data = &wacom_wac->hid_data; 1444 + struct wacom *wacom = hid_get_drvdata(hdev); 1445 + struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1446 + struct input_dev *input = wacom_wac->input; 1447 + unsigned touch_max = wacom_wac->features.touch_max; 1448 + int count = 0; 1449 + int i; 1477 1450 1478 - slot = input_mt_get_slot_by_key(input, hid_data->id); 1451 + if (touch_max == 1) 1452 + return wacom_wac->hid_data.tipswitch && 1453 + !wacom_wac->shared->stylus_in_proximity; 1479 1454 1480 - input_mt_slot(input, slot); 1481 - input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); 1482 - if (touch) { 1483 - input_report_abs(input, ABS_MT_POSITION_X, hid_data->x); 1484 - input_report_abs(input, ABS_MT_POSITION_Y, hid_data->y); 1455 + for (i = 0; i < input->mt->num_slots; i++) { 1456 + struct input_mt_slot *ps = &input->mt->slots[i]; 1457 + int id = input_mt_get_value(ps, ABS_MT_TRACKING_ID); 1458 + if (id >= 0) 1459 + count++; 1485 1460 } 1486 - input_mt_sync_frame(input); 1487 - } 1488 1461 1489 - static void wacom_wac_finger_single_touch_report(struct wacom_wac *wacom_wac, 1490 - struct input_dev *input, bool touch) 1491 - { 1492 - struct hid_data *hid_data = &wacom_wac->hid_data; 1493 - 1494 - if (touch) { 1495 - input_report_abs(input, ABS_X, hid_data->x); 1496 - input_report_abs(input, ABS_Y, hid_data->y); 1497 - } 1498 - input_report_key(input, BTN_TOUCH, touch); 1462 + return count; 1499 1463 } 1500 1464 1501 1465 static void wacom_wac_finger_report(struct hid_device *hdev, ··· 1503 1469 struct wacom *wacom = hid_get_drvdata(hdev); 1504 1470 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1505 1471 struct input_dev *input = wacom_wac->input; 1506 - bool touch = wacom_wac->hid_data.tipswitch && 1507 - !wacom_wac->shared->stylus_in_proximity; 1508 1472 unsigned touch_max = wacom_wac->features.touch_max; 1509 1473 1510 1474 if (touch_max > 1) 1511 - wacom_wac_finger_mt_report(wacom_wac, input, touch); 1512 - else 1513 - wacom_wac_finger_single_touch_report(wacom_wac, input, touch); 1475 + input_mt_sync_frame(input); 1476 + 1514 1477 input_sync(input); 1515 1478 1516 1479 /* keep touch state for pen event */ 1517 - wacom_wac->shared->touch_down = touch; 1480 + wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(hdev); 1518 1481 } 1519 1482 1520 1483 #define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \ 1521 - ((f)->physical == HID_DG_STYLUS)) 1484 + ((f)->physical == HID_DG_STYLUS) || \ 1485 + ((f)->application == HID_DG_PEN)) 1522 1486 #define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \ 1523 - ((f)->physical == HID_DG_FINGER)) 1487 + ((f)->physical == HID_DG_FINGER) || \ 1488 + ((f)->application == HID_DG_TOUCHSCREEN)) 1524 1489 1525 1490 void wacom_wac_usage_mapping(struct hid_device *hdev, 1526 1491 struct hid_field *field, struct hid_usage *usage) ··· 1714 1681 return 0; 1715 1682 1716 1683 if (data[0] == WACOM_REPORT_USB) { 1717 - if (features->type == INTUOSHT && features->touch_max) { 1684 + if (features->type == INTUOSHT && 1685 + wacom->shared->touch_input && 1686 + features->touch_max) { 1718 1687 input_report_switch(wacom->shared->touch_input, 1719 1688 SW_MUTE_DEVICE, data[8] & 0x40); 1720 1689 input_sync(wacom->shared->touch_input); ··· 1809 1774 int pid, battery, ps_connected; 1810 1775 1811 1776 if ((wacom->shared->type == INTUOSHT) && 1812 - wacom->shared->touch_max) { 1777 + wacom->shared->touch_input && 1778 + wacom->shared->touch_max) { 1813 1779 input_report_switch(wacom->shared->touch_input, 1814 1780 SW_MUTE_DEVICE, data[5] & 0x40); 1815 1781 input_sync(wacom->shared->touch_input); ··· 1874 1838 break; 1875 1839 1876 1840 case DTUS: 1841 + case DTUSX: 1877 1842 sync = wacom_dtus_irq(wacom_wac); 1878 1843 break; 1879 1844 ··· 1963 1926 input_set_abs_params(input_dev, ABS_DISTANCE, 1964 1927 0, wacom_wac->features.distance_max, 0, 0); 1965 1928 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); 1966 - input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); 1967 - input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); 1929 + input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, 0, 0); 1930 + input_abs_set_res(input_dev, ABS_TILT_X, 57); 1931 + input_set_abs_params(input_dev, ABS_TILT_Y, -64, 63, 0, 0); 1932 + input_abs_set_res(input_dev, ABS_TILT_Y, 57); 1968 1933 } 1969 1934 1970 1935 static void wacom_setup_intuos(struct wacom_wac *wacom_wac) ··· 1986 1947 __set_bit(BTN_TOOL_LENS, input_dev->keybit); 1987 1948 1988 1949 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); 1950 + input_abs_set_res(input_dev, ABS_RZ, 287); 1989 1951 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); 1990 1952 } 1991 1953 ··· 2069 2029 } 2070 2030 } 2071 2031 2072 - int wacom_setup_input_capabilities(struct input_dev *input_dev, 2032 + int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev, 2073 2033 struct wacom_wac *wacom_wac) 2074 2034 { 2075 2035 struct wacom_features *features = &wacom_wac->features; ··· 2087 2047 2088 2048 switch (features->type) { 2089 2049 case WACOM_MO: 2090 - input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0); 2091 - /* fall through */ 2092 - 2093 2050 case WACOM_G4: 2094 2051 /* fall through */ 2095 2052 ··· 2129 2092 2130 2093 case WACOM_24HD: 2131 2094 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2095 + input_abs_set_res(input_dev, ABS_Z, 287); 2132 2096 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); 2133 2097 /* fall through */ 2134 2098 ··· 2144 2106 case WACOM_BEE: 2145 2107 case CINTIQ: 2146 2108 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2109 + input_abs_set_res(input_dev, ABS_Z, 287); 2147 2110 2148 2111 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 2149 2112 ··· 2153 2114 2154 2115 case WACOM_13HD: 2155 2116 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2117 + input_abs_set_res(input_dev, ABS_Z, 287); 2156 2118 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 2157 2119 wacom_setup_cintiq(wacom_wac); 2158 2120 break; ··· 2162 2122 case INTUOS3L: 2163 2123 case INTUOS3S: 2164 2124 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2125 + input_abs_set_res(input_dev, ABS_Z, 287); 2165 2126 /* fall through */ 2166 2127 2167 2128 case INTUOS: ··· 2185 2144 0, 0); 2186 2145 2187 2146 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2147 + input_abs_set_res(input_dev, ABS_Z, 287); 2188 2148 2189 2149 wacom_setup_intuos(wacom_wac); 2190 2150 } else if (features->device_type == BTN_TOOL_FINGER) { ··· 2204 2162 case INTUOS4L: 2205 2163 case INTUOS4S: 2206 2164 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2165 + input_abs_set_res(input_dev, ABS_Z, 287); 2207 2166 wacom_setup_intuos(wacom_wac); 2208 2167 2209 2168 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); ··· 2239 2196 /* fall through */ 2240 2197 2241 2198 case DTUS: 2199 + case DTUSX: 2242 2200 case PL: 2243 2201 case DTU: 2244 2202 __set_bit(BTN_TOOL_PEN, input_dev->keybit); ··· 2290 2246 __clear_bit(ABS_X, input_dev->absbit); 2291 2247 __clear_bit(ABS_Y, input_dev->absbit); 2292 2248 __clear_bit(BTN_TOUCH, input_dev->keybit); 2249 + 2250 + /* PAD is setup by wacom_setup_pad_input_capabilities later */ 2251 + return 1; 2293 2252 } 2294 2253 } else if (features->device_type == BTN_TOOL_PEN) { 2295 2254 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); ··· 2308 2261 2309 2262 case CINTIQ_HYBRID: 2310 2263 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 2264 + input_abs_set_res(input_dev, ABS_Z, 287); 2311 2265 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); 2312 2266 2313 2267 wacom_setup_cintiq(wacom_wac); ··· 2351 2303 2352 2304 case WACOM_G4: 2353 2305 __set_bit(BTN_BACK, input_dev->keybit); 2354 - __set_bit(BTN_LEFT, input_dev->keybit); 2355 2306 __set_bit(BTN_FORWARD, input_dev->keybit); 2356 - __set_bit(BTN_RIGHT, input_dev->keybit); 2357 2307 input_set_capability(input_dev, EV_REL, REL_WHEEL); 2358 2308 break; 2359 2309 ··· 2448 2402 case INTUOSPS: 2449 2403 /* touch interface does not have the pad device */ 2450 2404 if (features->device_type != BTN_TOOL_PEN) 2451 - return 1; 2405 + return -ENODEV; 2452 2406 2453 2407 for (i = 0; i < 7; i++) 2454 2408 __set_bit(BTN_0 + i, input_dev->keybit); ··· 2492 2446 case INTUOSHT: 2493 2447 case BAMBOO_PT: 2494 2448 /* pad device is on the touch interface */ 2495 - if (features->device_type != BTN_TOOL_FINGER) 2496 - return 1; 2449 + if ((features->device_type != BTN_TOOL_FINGER) || 2450 + /* Bamboo Pen only tablet does not have pad */ 2451 + ((features->type == BAMBOO_PT) && !features->touch_max)) 2452 + return -ENODEV; 2497 2453 2498 2454 __clear_bit(ABS_MISC, input_dev->absbit); 2499 2455 ··· 2508 2460 2509 2461 default: 2510 2462 /* no pad supported */ 2511 - return 1; 2463 + return -ENODEV; 2512 2464 } 2513 2465 return 0; 2514 2466 } ··· 2712 2664 INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16, 2713 2665 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2714 2666 static const struct wacom_features wacom_features_0xF4 = 2715 - { "Wacom Cintiq 24HD", 104280, 65400, 2047, 63, 2716 - WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2667 + { "Wacom Cintiq 24HD", 104080, 65200, 2047, 63, 2668 + WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2669 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; 2717 2670 static const struct wacom_features wacom_features_0xF8 = 2718 - { "Wacom Cintiq 24HD touch", 104280, 65400, 2047, 63, /* Pen */ 2719 - WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2671 + { "Wacom Cintiq 24HD touch", 104080, 65200, 2047, 63, /* Pen */ 2672 + WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2673 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, 2720 2674 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 }; 2721 2675 static const struct wacom_features wacom_features_0xF6 = 2722 2676 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */ ··· 2734 2684 { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63, 2735 2685 WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2736 2686 static const struct wacom_features wacom_features_0x304 = 2737 - { "Wacom Cintiq 13HD", 59352, 33648, 1023, 63, 2738 - WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2687 + { "Wacom Cintiq 13HD", 59152, 33448, 1023, 63, 2688 + WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2689 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; 2739 2690 static const struct wacom_features wacom_features_0xC7 = 2740 2691 { "Wacom DTU1931", 37832, 30305, 511, 0, 2741 2692 PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; ··· 2748 2697 { "Wacom DTU1631", 34623, 19553, 511, 0, 2749 2698 DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2750 2699 static const struct wacom_features wacom_features_0xFB = 2751 - { "Wacom DTU1031", 22096, 13960, 511, 0, 2752 - DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2700 + { "Wacom DTU1031", 21896, 13760, 511, 0, 2701 + DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2702 + WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; 2703 + static const struct wacom_features wacom_features_0x32F = 2704 + { "Wacom DTU1031X", 22472, 12728, 511, 0, 2705 + DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2706 + WACOM_DTU_OFFSET, WACOM_DTU_OFFSET }; 2753 2707 static const struct wacom_features wacom_features_0x57 = 2754 2708 { "Wacom DTK2241", 95640, 54060, 2047, 63, 2755 - DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2709 + DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2710 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; 2756 2711 static const struct wacom_features wacom_features_0x59 = /* Pen */ 2757 2712 { "Wacom DTH2242", 95640, 54060, 2047, 63, 2758 - DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2713 + DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2714 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, 2759 2715 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D }; 2760 2716 static const struct wacom_features wacom_features_0x5D = /* Touch */ 2761 2717 { "Wacom DTH2242", .type = WACOM_24HDT, 2762 2718 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10, 2763 2719 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2764 2720 static const struct wacom_features wacom_features_0xCC = 2765 - { "Wacom Cintiq 21UX2", 87000, 65400, 2047, 63, 2766 - WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2721 + { "Wacom Cintiq 21UX2", 86800, 65200, 2047, 63, 2722 + WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2723 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; 2767 2724 static const struct wacom_features wacom_features_0xFA = 2768 - { "Wacom Cintiq 22HD", 95640, 54060, 2047, 63, 2769 - WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 }; 2725 + { "Wacom Cintiq 22HD", 95440, 53860, 2047, 63, 2726 + WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2727 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET }; 2770 2728 static const struct wacom_features wacom_features_0x5B = 2771 - { "Wacom Cintiq 22HDT", 95640, 54060, 2047, 63, 2772 - WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2729 + { "Wacom Cintiq 22HDT", 95440, 53860, 2047, 63, 2730 + WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2731 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, 2773 2732 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e }; 2774 2733 static const struct wacom_features wacom_features_0x5E = 2775 2734 { "Wacom Cintiq 22HDT", .type = WACOM_24HDT, ··· 2924 2863 { "ISD-V4", 12800, 8000, 255, 0, 2925 2864 TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 2926 2865 static const struct wacom_features wacom_features_0x307 = 2927 - { "Wacom ISDv5 307", 59352, 33648, 2047, 63, 2928 - CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2866 + { "Wacom ISDv5 307", 59152, 33448, 2047, 63, 2867 + CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2868 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, 2929 2869 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 }; 2930 2870 static const struct wacom_features wacom_features_0x309 = 2931 2871 { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */ 2932 2872 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10, 2933 2873 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2934 2874 static const struct wacom_features wacom_features_0x30A = 2935 - { "Wacom ISDv5 30A", 59352, 33648, 2047, 63, 2936 - CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200, 2875 + { "Wacom ISDv5 30A", 59152, 33448, 2047, 63, 2876 + CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2877 + WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET, 2937 2878 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C }; 2938 2879 static const struct wacom_features wacom_features_0x30C = 2939 2880 { "Wacom ISDv5 30C", .type = WACOM_24HDT, /* Touch */ 2940 2881 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30A, .touch_max = 10, 2882 + .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2883 + static const struct wacom_features wacom_features_0x323 = 2884 + { "Wacom Intuos P M", 21600, 13500, 1023, 31, 2885 + INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 2941 2886 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2942 2887 2943 2888 static const struct wacom_features wacom_features_HID_ANY_ID = ··· 3089 3022 { USB_DEVICE_WACOM(0x314) }, 3090 3023 { USB_DEVICE_WACOM(0x315) }, 3091 3024 { USB_DEVICE_WACOM(0x317) }, 3025 + { USB_DEVICE_WACOM(0x323) }, 3026 + { USB_DEVICE_WACOM(0x32F) }, 3092 3027 { USB_DEVICE_WACOM(0x4001) }, 3093 3028 { USB_DEVICE_WACOM(0x4004) }, 3094 3029 { USB_DEVICE_WACOM(0x5000) },
+3
drivers/hid/wacom_wac.h
··· 80 80 PL, 81 81 DTU, 82 82 DTUS, 83 + DTUSX, 83 84 INTUOS, 84 85 INTUOS3S, 85 86 INTUOS3, ··· 145 144 int pktlen; 146 145 bool check_for_hid_type; 147 146 int hid_type; 147 + int last_slot_field; 148 148 }; 149 149 150 150 struct wacom_shared { ··· 185 183 struct input_dev *input; 186 184 struct input_dev *pad_input; 187 185 bool input_registered; 186 + bool pad_registered; 188 187 int pid; 189 188 int battery_capacity; 190 189 int num_contacts_left;
+39
include/linux/hid.h
··· 234 234 #define HID_DG_BARRELSWITCH 0x000d0044 235 235 #define HID_DG_ERASER 0x000d0045 236 236 #define HID_DG_TABLETPICK 0x000d0046 237 + 238 + #define HID_CP_CONSUMERCONTROL 0x000c0001 239 + #define HID_CP_NUMERICKEYPAD 0x000c0002 240 + #define HID_CP_PROGRAMMABLEBUTTONS 0x000c0003 241 + #define HID_CP_MICROPHONE 0x000c0004 242 + #define HID_CP_HEADPHONE 0x000c0005 243 + #define HID_CP_GRAPHICEQUALIZER 0x000c0006 244 + #define HID_CP_FUNCTIONBUTTONS 0x000c0036 245 + #define HID_CP_SELECTION 0x000c0080 246 + #define HID_CP_MEDIASELECTION 0x000c0087 247 + #define HID_CP_SELECTDISC 0x000c00ba 248 + #define HID_CP_PLAYBACKSPEED 0x000c00f1 249 + #define HID_CP_PROXIMITY 0x000c0109 250 + #define HID_CP_SPEAKERSYSTEM 0x000c0160 251 + #define HID_CP_CHANNELLEFT 0x000c0161 252 + #define HID_CP_CHANNELRIGHT 0x000c0162 253 + #define HID_CP_CHANNELCENTER 0x000c0163 254 + #define HID_CP_CHANNELFRONT 0x000c0164 255 + #define HID_CP_CHANNELCENTERFRONT 0x000c0165 256 + #define HID_CP_CHANNELSIDE 0x000c0166 257 + #define HID_CP_CHANNELSURROUND 0x000c0167 258 + #define HID_CP_CHANNELLOWFREQUENCYENHANCEMENT 0x000c0168 259 + #define HID_CP_CHANNELTOP 0x000c0169 260 + #define HID_CP_CHANNELUNKNOWN 0x000c016a 261 + #define HID_CP_APPLICATIONLAUNCHBUTTONS 0x000c0180 262 + #define HID_CP_GENERICGUIAPPLICATIONCONTROLS 0x000c0200 263 + 237 264 #define HID_DG_CONFIDENCE 0x000d0047 238 265 #define HID_DG_WIDTH 0x000d0048 239 266 #define HID_DG_HEIGHT 0x000d0049 ··· 340 313 */ 341 314 #define HID_GROUP_RMI 0x0100 342 315 #define HID_GROUP_WACOM 0x0101 316 + #define HID_GROUP_LOGITECH_DJ_DEVICE 0x0102 343 317 344 318 /* 345 319 * This is the global environment of the parser. This information is ··· 1085 1057 { 1086 1058 if (hdev->ll_driver->wait) 1087 1059 hdev->ll_driver->wait(hdev); 1060 + } 1061 + 1062 + /** 1063 + * hid_report_len - calculate the report length 1064 + * 1065 + * @report: the report we want to know the length 1066 + */ 1067 + static inline int hid_report_len(struct hid_report *report) 1068 + { 1069 + /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ 1070 + return ((report->size - 1) >> 3) + 1 + (report->id > 0); 1088 1071 } 1089 1072 1090 1073 int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,