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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jikos/hid

Pull HID updates from Jiri Kosina:

- high resolution mode for Dell canvas support, from Benjamin Tissoires

- pen handling fixes for the Wacom driver, from Jason Gerecke

- i2c-hid: Apollo-Lake based laptops improvements, from Hans de Goede

- Input/Core: eraser tool support, from Ping Cheng

- new ALPS touchpad (T4, found currently on HP EliteBook 1000, Zbook
Stduio and HP Elite book x360) supportm from Masaki Ota

- other smaller assorted fixes

* 'for-linus' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (33 commits)
HID: cp2112: fix broken gpio_direction_input callback
HID: cp2112: fix interface specification URL
HID: Wacom: switch Dell canvas into highres mode
HID: wacom: generic: Send BTN_STYLUS3 when both barrel switches are set
HID: sony: Fix SHANWAN pad rumbling on USB
HID: i2c-hid: Add no-irq-after-reset quirk for 0911:5288 device
HID: add backlight level quirk for Asus ROG laptops
HID: cp2112: add HIDRAW dependency
HID: Add ID 044f:b605 ThrustMaster, Inc. force feedback Racing Wheel
HID: hid-logitech: remove redundant assignment to pointer value
HID: wacom: generic: Recognize WACOM_HID_WD_PEN as a type of pen collection
HID: rmi: Check that a device is a RMI device before calling RMI functions
HID: add multi-input quirk for GamepadBlock
HID: alps: add new U1 device ID
HID: alps: add support for Alps T4 Touchpad device
HID: alps: remove variables local to u1_init() from the device struct
HID: alps: properly handle max_fingers and minimum on X and Y axis
HID: alps: Separate U1 device code
HID: alps: delete unnecessary struct u1_dev devInfo
HID: usbhid: Convert timers to use timer_setup()
...

+651 -192
+2 -3
drivers/hid/Kconfig
··· 230 230 231 231 config HID_CP2112 232 232 tristate "Silicon Labs CP2112 HID USB-to-SMBus Bridge support" 233 - depends on USB_HID && I2C && GPIOLIB 233 + depends on USB_HID && HIDRAW && I2C && GPIOLIB 234 234 select GPIOLIB_IRQCHIP 235 235 ---help--- 236 236 Support for Silicon Labs CP2112 HID USB to SMBus Master Bridge. ··· 750 750 HID standard. 751 751 752 752 config HID_RETRODE 753 - tristate "Retrode" 753 + tristate "Retrode 2 USB adapter for vintage video games" 754 754 depends on USB_HID 755 755 ---help--- 756 756 Support for 757 - 758 757 * Retrode 2 cartridge and controller adapter 759 758 760 759 config HID_ROCCAT
+459 -147
drivers/hid/hid-alps.c
··· 52 52 #define ADDRESS_U1_PAD_BTN 0x00800052 53 53 #define ADDRESS_U1_SP_BTN 0x0080009F 54 54 55 + #define T4_INPUT_REPORT_LEN sizeof(struct t4_input_report) 56 + #define T4_FEATURE_REPORT_LEN T4_INPUT_REPORT_LEN 57 + #define T4_FEATURE_REPORT_ID 7 58 + #define T4_CMD_REGISTER_READ 0x08 59 + #define T4_CMD_REGISTER_WRITE 0x07 60 + 61 + #define T4_ADDRESS_BASE 0xC2C0 62 + #define PRM_SYS_CONFIG_1 (T4_ADDRESS_BASE + 0x0002) 63 + #define T4_PRM_FEED_CONFIG_1 (T4_ADDRESS_BASE + 0x0004) 64 + #define T4_PRM_FEED_CONFIG_4 (T4_ADDRESS_BASE + 0x001A) 65 + #define T4_PRM_ID_CONFIG_3 (T4_ADDRESS_BASE + 0x00B0) 66 + 67 + 68 + #define T4_FEEDCFG4_ADVANCED_ABS_ENABLE 0x01 69 + #define T4_I2C_ABS 0x78 70 + 71 + #define T4_COUNT_PER_ELECTRODE 256 55 72 #define MAX_TOUCHES 5 56 73 74 + enum dev_num { 75 + U1, 76 + T4, 77 + UNKNOWN, 78 + }; 57 79 /** 58 80 * struct u1_data 59 81 * ··· 83 61 * @input2: pointer to the kernel input2 device 84 62 * @hdev: pointer to the struct hid_device 85 63 * 86 - * @dev_ctrl: device control parameter 87 64 * @dev_type: device type 88 - * @sen_line_num_x: number of sensor line of X 89 - * @sen_line_num_y: number of sensor line of Y 90 - * @pitch_x: sensor pitch of X 91 - * @pitch_y: sensor pitch of Y 92 - * @resolution: resolution 93 - * @btn_info: button information 65 + * @max_fingers: total number of fingers 66 + * @has_sp: boolean of sp existense 67 + * @sp_btn_info: button information 94 68 * @x_active_len_mm: active area length of X (mm) 95 69 * @y_active_len_mm: active area length of Y (mm) 96 70 * @x_max: maximum x coordinate value 97 71 * @y_max: maximum y coordinate value 72 + * @x_min: minimum x coordinate value 73 + * @y_min: minimum y coordinate value 98 74 * @btn_cnt: number of buttons 99 75 * @sp_btn_cnt: number of stick buttons 100 76 */ 101 - struct u1_dev { 77 + struct alps_dev { 102 78 struct input_dev *input; 103 79 struct input_dev *input2; 104 80 struct hid_device *hdev; 105 81 106 - u8 dev_ctrl; 107 - u8 dev_type; 108 - u8 sen_line_num_x; 109 - u8 sen_line_num_y; 110 - u8 pitch_x; 111 - u8 pitch_y; 112 - u8 resolution; 113 - u8 btn_info; 82 + enum dev_num dev_type; 83 + u8 max_fingers; 84 + u8 has_sp; 114 85 u8 sp_btn_info; 115 86 u32 x_active_len_mm; 116 87 u32 y_active_len_mm; 117 88 u32 x_max; 118 89 u32 y_max; 90 + u32 x_min; 91 + u32 y_min; 119 92 u32 btn_cnt; 120 93 u32 sp_btn_cnt; 121 94 }; 95 + 96 + struct t4_contact_data { 97 + u8 palm; 98 + u8 x_lo; 99 + u8 x_hi; 100 + u8 y_lo; 101 + u8 y_hi; 102 + }; 103 + 104 + struct t4_input_report { 105 + u8 reportID; 106 + u8 numContacts; 107 + struct t4_contact_data contact[5]; 108 + u8 button; 109 + u8 track[5]; 110 + u8 zx[5], zy[5]; 111 + u8 palmTime[5]; 112 + u8 kilroy; 113 + u16 timeStamp; 114 + }; 115 + 116 + static u16 t4_calc_check_sum(u8 *buffer, 117 + unsigned long offset, unsigned long length) 118 + { 119 + u16 sum1 = 0xFF, sum2 = 0xFF; 120 + unsigned long i = 0; 121 + 122 + if (offset + length >= 50) 123 + return 0; 124 + 125 + while (length > 0) { 126 + u32 tlen = length > 20 ? 20 : length; 127 + 128 + length -= tlen; 129 + 130 + do { 131 + sum1 += buffer[offset + i]; 132 + sum2 += sum1; 133 + i++; 134 + } while (--tlen > 0); 135 + 136 + sum1 = (sum1 & 0xFF) + (sum1 >> 8); 137 + sum2 = (sum2 & 0xFF) + (sum2 >> 8); 138 + } 139 + 140 + sum1 = (sum1 & 0xFF) + (sum1 >> 8); 141 + sum2 = (sum2 & 0xFF) + (sum2 >> 8); 142 + 143 + return(sum2 << 8 | sum1); 144 + } 145 + 146 + static int t4_read_write_register(struct hid_device *hdev, u32 address, 147 + u8 *read_val, u8 write_val, bool read_flag) 148 + { 149 + int ret; 150 + u16 check_sum; 151 + u8 *input; 152 + u8 *readbuf; 153 + 154 + input = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL); 155 + if (!input) 156 + return -ENOMEM; 157 + 158 + input[0] = T4_FEATURE_REPORT_ID; 159 + if (read_flag) { 160 + input[1] = T4_CMD_REGISTER_READ; 161 + input[8] = 0x00; 162 + } else { 163 + input[1] = T4_CMD_REGISTER_WRITE; 164 + input[8] = write_val; 165 + } 166 + put_unaligned_le32(address, input + 2); 167 + input[6] = 1; 168 + input[7] = 0; 169 + 170 + /* Calculate the checksum */ 171 + check_sum = t4_calc_check_sum(input, 1, 8); 172 + input[9] = (u8)check_sum; 173 + input[10] = (u8)(check_sum >> 8); 174 + input[11] = 0; 175 + 176 + ret = hid_hw_raw_request(hdev, T4_FEATURE_REPORT_ID, input, 177 + T4_FEATURE_REPORT_LEN, 178 + HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 179 + 180 + if (ret < 0) { 181 + dev_err(&hdev->dev, "failed to read command (%d)\n", ret); 182 + goto exit; 183 + } 184 + 185 + readbuf = kzalloc(T4_FEATURE_REPORT_LEN, GFP_KERNEL); 186 + if (read_flag) { 187 + if (!readbuf) { 188 + ret = -ENOMEM; 189 + goto exit; 190 + } 191 + 192 + ret = hid_hw_raw_request(hdev, T4_FEATURE_REPORT_ID, readbuf, 193 + T4_FEATURE_REPORT_LEN, 194 + HID_FEATURE_REPORT, HID_REQ_GET_REPORT); 195 + if (ret < 0) { 196 + dev_err(&hdev->dev, "failed read register (%d)\n", ret); 197 + goto exit_readbuf; 198 + } 199 + 200 + if (*(u32 *)&readbuf[6] != address) { 201 + dev_err(&hdev->dev, "read register address error (%x,%x)\n", 202 + *(u32 *)&readbuf[6], address); 203 + goto exit_readbuf; 204 + } 205 + 206 + if (*(u16 *)&readbuf[10] != 1) { 207 + dev_err(&hdev->dev, "read register size error (%x)\n", 208 + *(u16 *)&readbuf[10]); 209 + goto exit_readbuf; 210 + } 211 + 212 + check_sum = t4_calc_check_sum(readbuf, 6, 7); 213 + if (*(u16 *)&readbuf[13] != check_sum) { 214 + dev_err(&hdev->dev, "read register checksum error (%x,%x)\n", 215 + *(u16 *)&readbuf[13], check_sum); 216 + goto exit_readbuf; 217 + } 218 + 219 + *read_val = readbuf[12]; 220 + } 221 + 222 + ret = 0; 223 + 224 + exit_readbuf: 225 + kfree(readbuf); 226 + exit: 227 + kfree(input); 228 + return ret; 229 + } 122 230 123 231 static int u1_read_write_register(struct hid_device *hdev, u32 address, 124 232 u8 *read_val, u8 write_val, bool read_flag) ··· 317 165 return ret; 318 166 } 319 167 320 - static int alps_raw_event(struct hid_device *hdev, 321 - struct hid_report *report, u8 *data, int size) 168 + static int t4_raw_event(struct alps_dev *hdata, u8 *data, int size) 169 + { 170 + unsigned int x, y, z; 171 + int i; 172 + struct t4_input_report *p_report = (struct t4_input_report *)data; 173 + 174 + if (!data) 175 + return 0; 176 + for (i = 0; i < hdata->max_fingers; i++) { 177 + x = p_report->contact[i].x_hi << 8 | p_report->contact[i].x_lo; 178 + y = p_report->contact[i].y_hi << 8 | p_report->contact[i].y_lo; 179 + y = hdata->y_max - y + hdata->y_min; 180 + z = (p_report->contact[i].palm < 0x80 && 181 + p_report->contact[i].palm > 0) * 62; 182 + if (x == 0xffff) { 183 + x = 0; 184 + y = 0; 185 + z = 0; 186 + } 187 + input_mt_slot(hdata->input, i); 188 + 189 + input_mt_report_slot_state(hdata->input, 190 + MT_TOOL_FINGER, z != 0); 191 + 192 + if (!z) 193 + continue; 194 + 195 + input_report_abs(hdata->input, ABS_MT_POSITION_X, x); 196 + input_report_abs(hdata->input, ABS_MT_POSITION_Y, y); 197 + input_report_abs(hdata->input, ABS_MT_PRESSURE, z); 198 + } 199 + input_mt_sync_frame(hdata->input); 200 + 201 + input_report_key(hdata->input, BTN_LEFT, p_report->button); 202 + 203 + input_sync(hdata->input); 204 + return 1; 205 + } 206 + 207 + static int u1_raw_event(struct alps_dev *hdata, u8 *data, int size) 322 208 { 323 209 unsigned int x, y, z; 324 210 int i; 325 211 short sp_x, sp_y; 326 - struct u1_dev *hdata = hid_get_drvdata(hdev); 327 212 213 + if (!data) 214 + return 0; 328 215 switch (data[0]) { 329 216 case U1_MOUSE_REPORT_ID: 330 217 break; 331 218 case U1_FEATURE_REPORT_ID: 332 219 break; 333 220 case U1_ABSOLUTE_REPORT_ID: 334 - for (i = 0; i < MAX_TOUCHES; i++) { 221 + for (i = 0; i < hdata->max_fingers; i++) { 335 222 u8 *contact = &data[i * 5]; 336 223 337 224 x = get_unaligned_le16(contact + 3); ··· 432 241 return 0; 433 242 } 434 243 435 - #ifdef CONFIG_PM 436 - static int alps_post_reset(struct hid_device *hdev) 244 + static int alps_raw_event(struct hid_device *hdev, 245 + struct hid_report *report, u8 *data, int size) 437 246 { 438 - return u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 439 - NULL, U1_TP_ABS_MODE | U1_SP_ABS_MODE, false); 247 + int ret = 0; 248 + struct alps_dev *hdata = hid_get_drvdata(hdev); 249 + 250 + switch (hdev->product) { 251 + case HID_PRODUCT_ID_T4_BTNLESS: 252 + ret = t4_raw_event(hdata, data, size); 253 + break; 254 + default: 255 + ret = u1_raw_event(hdata, data, size); 256 + break; 257 + } 258 + return ret; 440 259 } 441 260 442 - static int alps_post_resume(struct hid_device *hdev) 261 + static int __maybe_unused alps_post_reset(struct hid_device *hdev) 443 262 { 444 - return u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 445 - NULL, U1_TP_ABS_MODE | U1_SP_ABS_MODE, false); 263 + int ret = -1; 264 + struct alps_dev *data = hid_get_drvdata(hdev); 265 + 266 + switch (data->dev_type) { 267 + case T4: 268 + ret = t4_read_write_register(hdev, T4_PRM_FEED_CONFIG_1, 269 + NULL, T4_I2C_ABS, false); 270 + ret = t4_read_write_register(hdev, T4_PRM_FEED_CONFIG_4, 271 + NULL, T4_FEEDCFG4_ADVANCED_ABS_ENABLE, false); 272 + break; 273 + case U1: 274 + ret = u1_read_write_register(hdev, 275 + ADDRESS_U1_DEV_CTRL_1, NULL, 276 + U1_TP_ABS_MODE | U1_SP_ABS_MODE, false); 277 + break; 278 + default: 279 + break; 280 + } 281 + return ret; 446 282 } 447 - #endif /* CONFIG_PM */ 283 + 284 + static int __maybe_unused alps_post_resume(struct hid_device *hdev) 285 + { 286 + return alps_post_reset(hdev); 287 + } 288 + 289 + static int u1_init(struct hid_device *hdev, struct alps_dev *pri_data) 290 + { 291 + int ret; 292 + u8 tmp, dev_ctrl, sen_line_num_x, sen_line_num_y; 293 + u8 pitch_x, pitch_y, resolution; 294 + 295 + /* Device initialization */ 296 + ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 297 + &dev_ctrl, 0, true); 298 + if (ret < 0) { 299 + dev_err(&hdev->dev, "failed U1_DEV_CTRL_1 (%d)\n", ret); 300 + goto exit; 301 + } 302 + 303 + dev_ctrl &= ~U1_DISABLE_DEV; 304 + dev_ctrl |= U1_TP_ABS_MODE; 305 + ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 306 + NULL, dev_ctrl, false); 307 + if (ret < 0) { 308 + dev_err(&hdev->dev, "failed to change TP mode (%d)\n", ret); 309 + goto exit; 310 + } 311 + 312 + ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_X, 313 + &sen_line_num_x, 0, true); 314 + if (ret < 0) { 315 + dev_err(&hdev->dev, "failed U1_NUM_SENS_X (%d)\n", ret); 316 + goto exit; 317 + } 318 + 319 + ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_Y, 320 + &sen_line_num_y, 0, true); 321 + if (ret < 0) { 322 + dev_err(&hdev->dev, "failed U1_NUM_SENS_Y (%d)\n", ret); 323 + goto exit; 324 + } 325 + 326 + ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_X, 327 + &pitch_x, 0, true); 328 + if (ret < 0) { 329 + dev_err(&hdev->dev, "failed U1_PITCH_SENS_X (%d)\n", ret); 330 + goto exit; 331 + } 332 + 333 + ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_Y, 334 + &pitch_y, 0, true); 335 + if (ret < 0) { 336 + dev_err(&hdev->dev, "failed U1_PITCH_SENS_Y (%d)\n", ret); 337 + goto exit; 338 + } 339 + 340 + ret = u1_read_write_register(hdev, ADDRESS_U1_RESO_DWN_ABS, 341 + &resolution, 0, true); 342 + if (ret < 0) { 343 + dev_err(&hdev->dev, "failed U1_RESO_DWN_ABS (%d)\n", ret); 344 + goto exit; 345 + } 346 + pri_data->x_active_len_mm = 347 + (pitch_x * (sen_line_num_x - 1)) / 10; 348 + pri_data->y_active_len_mm = 349 + (pitch_y * (sen_line_num_y - 1)) / 10; 350 + 351 + pri_data->x_max = 352 + (resolution << 2) * (sen_line_num_x - 1); 353 + pri_data->x_min = 1; 354 + pri_data->y_max = 355 + (resolution << 2) * (sen_line_num_y - 1); 356 + pri_data->y_min = 1; 357 + 358 + ret = u1_read_write_register(hdev, ADDRESS_U1_PAD_BTN, 359 + &tmp, 0, true); 360 + if (ret < 0) { 361 + dev_err(&hdev->dev, "failed U1_PAD_BTN (%d)\n", ret); 362 + goto exit; 363 + } 364 + if ((tmp & 0x0F) == (tmp & 0xF0) >> 4) { 365 + pri_data->btn_cnt = (tmp & 0x0F); 366 + } else { 367 + /* Button pad */ 368 + pri_data->btn_cnt = 1; 369 + } 370 + 371 + pri_data->has_sp = 0; 372 + /* Check StickPointer device */ 373 + ret = u1_read_write_register(hdev, ADDRESS_U1_DEVICE_TYP, 374 + &tmp, 0, true); 375 + if (ret < 0) { 376 + dev_err(&hdev->dev, "failed U1_DEVICE_TYP (%d)\n", ret); 377 + goto exit; 378 + } 379 + if (tmp & U1_DEVTYPE_SP_SUPPORT) { 380 + dev_ctrl |= U1_SP_ABS_MODE; 381 + ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 382 + NULL, dev_ctrl, false); 383 + if (ret < 0) { 384 + dev_err(&hdev->dev, "failed SP mode (%d)\n", ret); 385 + goto exit; 386 + } 387 + 388 + ret = u1_read_write_register(hdev, ADDRESS_U1_SP_BTN, 389 + &pri_data->sp_btn_info, 0, true); 390 + if (ret < 0) { 391 + dev_err(&hdev->dev, "failed U1_SP_BTN (%d)\n", ret); 392 + goto exit; 393 + } 394 + pri_data->has_sp = 1; 395 + } 396 + pri_data->max_fingers = 5; 397 + exit: 398 + return ret; 399 + } 400 + 401 + static int T4_init(struct hid_device *hdev, struct alps_dev *pri_data) 402 + { 403 + int ret; 404 + u8 tmp, sen_line_num_x, sen_line_num_y; 405 + 406 + ret = t4_read_write_register(hdev, T4_PRM_ID_CONFIG_3, &tmp, 0, true); 407 + if (ret < 0) { 408 + dev_err(&hdev->dev, "failed T4_PRM_ID_CONFIG_3 (%d)\n", ret); 409 + goto exit; 410 + } 411 + sen_line_num_x = 16 + ((tmp & 0x0F) | (tmp & 0x08 ? 0xF0 : 0)); 412 + sen_line_num_y = 12 + (((tmp & 0xF0) >> 4) | (tmp & 0x80 ? 0xF0 : 0)); 413 + 414 + pri_data->x_max = sen_line_num_x * T4_COUNT_PER_ELECTRODE; 415 + pri_data->x_min = T4_COUNT_PER_ELECTRODE; 416 + pri_data->y_max = sen_line_num_y * T4_COUNT_PER_ELECTRODE; 417 + pri_data->y_min = T4_COUNT_PER_ELECTRODE; 418 + pri_data->x_active_len_mm = pri_data->y_active_len_mm = 0; 419 + pri_data->btn_cnt = 1; 420 + 421 + ret = t4_read_write_register(hdev, PRM_SYS_CONFIG_1, &tmp, 0, true); 422 + if (ret < 0) { 423 + dev_err(&hdev->dev, "failed PRM_SYS_CONFIG_1 (%d)\n", ret); 424 + goto exit; 425 + } 426 + tmp |= 0x02; 427 + ret = t4_read_write_register(hdev, PRM_SYS_CONFIG_1, NULL, tmp, false); 428 + if (ret < 0) { 429 + dev_err(&hdev->dev, "failed PRM_SYS_CONFIG_1 (%d)\n", ret); 430 + goto exit; 431 + } 432 + 433 + ret = t4_read_write_register(hdev, T4_PRM_FEED_CONFIG_1, 434 + NULL, T4_I2C_ABS, false); 435 + if (ret < 0) { 436 + dev_err(&hdev->dev, "failed T4_PRM_FEED_CONFIG_1 (%d)\n", ret); 437 + goto exit; 438 + } 439 + 440 + ret = t4_read_write_register(hdev, T4_PRM_FEED_CONFIG_4, NULL, 441 + T4_FEEDCFG4_ADVANCED_ABS_ENABLE, false); 442 + if (ret < 0) { 443 + dev_err(&hdev->dev, "failed T4_PRM_FEED_CONFIG_4 (%d)\n", ret); 444 + goto exit; 445 + } 446 + pri_data->max_fingers = 5; 447 + pri_data->has_sp = 0; 448 + exit: 449 + return ret; 450 + } 448 451 449 452 static int alps_input_configured(struct hid_device *hdev, struct hid_input *hi) 450 453 { 451 - struct u1_dev *data = hid_get_drvdata(hdev); 454 + struct alps_dev *data = hid_get_drvdata(hdev); 452 455 struct input_dev *input = hi->input, *input2; 453 - struct u1_dev devInfo; 454 456 int ret; 455 457 int res_x, res_y, i; 456 458 ··· 656 272 657 273 /* Allow incoming hid reports */ 658 274 hid_device_io_start(hdev); 659 - 660 - /* Device initialization */ 661 - ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 662 - &devInfo.dev_ctrl, 0, true); 663 - if (ret < 0) { 664 - dev_err(&hdev->dev, "failed U1_DEV_CTRL_1 (%d)\n", ret); 665 - goto exit; 275 + switch (data->dev_type) { 276 + case T4: 277 + ret = T4_init(hdev, data); 278 + break; 279 + case U1: 280 + ret = u1_init(hdev, data); 281 + break; 282 + default: 283 + break; 666 284 } 667 285 668 - devInfo.dev_ctrl &= ~U1_DISABLE_DEV; 669 - devInfo.dev_ctrl |= U1_TP_ABS_MODE; 670 - ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 671 - NULL, devInfo.dev_ctrl, false); 672 - if (ret < 0) { 673 - dev_err(&hdev->dev, "failed to change TP mode (%d)\n", ret); 286 + if (ret) 674 287 goto exit; 675 - } 676 - 677 - ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_X, 678 - &devInfo.sen_line_num_x, 0, true); 679 - if (ret < 0) { 680 - dev_err(&hdev->dev, "failed U1_NUM_SENS_X (%d)\n", ret); 681 - goto exit; 682 - } 683 - 684 - ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_Y, 685 - &devInfo.sen_line_num_y, 0, true); 686 - if (ret < 0) { 687 - dev_err(&hdev->dev, "failed U1_NUM_SENS_Y (%d)\n", ret); 688 - goto exit; 689 - } 690 - 691 - ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_X, 692 - &devInfo.pitch_x, 0, true); 693 - if (ret < 0) { 694 - dev_err(&hdev->dev, "failed U1_PITCH_SENS_X (%d)\n", ret); 695 - goto exit; 696 - } 697 - 698 - ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_Y, 699 - &devInfo.pitch_y, 0, true); 700 - if (ret < 0) { 701 - dev_err(&hdev->dev, "failed U1_PITCH_SENS_Y (%d)\n", ret); 702 - goto exit; 703 - } 704 - 705 - ret = u1_read_write_register(hdev, ADDRESS_U1_RESO_DWN_ABS, 706 - &devInfo.resolution, 0, true); 707 - if (ret < 0) { 708 - dev_err(&hdev->dev, "failed U1_RESO_DWN_ABS (%d)\n", ret); 709 - goto exit; 710 - } 711 - 712 - ret = u1_read_write_register(hdev, ADDRESS_U1_PAD_BTN, 713 - &devInfo.btn_info, 0, true); 714 - if (ret < 0) { 715 - dev_err(&hdev->dev, "failed U1_PAD_BTN (%d)\n", ret); 716 - goto exit; 717 - } 718 - 719 - /* Check StickPointer device */ 720 - ret = u1_read_write_register(hdev, ADDRESS_U1_DEVICE_TYP, 721 - &devInfo.dev_type, 0, true); 722 - if (ret < 0) { 723 - dev_err(&hdev->dev, "failed U1_DEVICE_TYP (%d)\n", ret); 724 - goto exit; 725 - } 726 - 727 - devInfo.x_active_len_mm = 728 - (devInfo.pitch_x * (devInfo.sen_line_num_x - 1)) / 10; 729 - devInfo.y_active_len_mm = 730 - (devInfo.pitch_y * (devInfo.sen_line_num_y - 1)) / 10; 731 - 732 - devInfo.x_max = 733 - (devInfo.resolution << 2) * (devInfo.sen_line_num_x - 1); 734 - devInfo.y_max = 735 - (devInfo.resolution << 2) * (devInfo.sen_line_num_y - 1); 736 288 737 289 __set_bit(EV_ABS, input->evbit); 738 - input_set_abs_params(input, ABS_MT_POSITION_X, 1, devInfo.x_max, 0, 0); 739 - input_set_abs_params(input, ABS_MT_POSITION_Y, 1, devInfo.y_max, 0, 0); 290 + input_set_abs_params(input, ABS_MT_POSITION_X, 291 + data->x_min, data->x_max, 0, 0); 292 + input_set_abs_params(input, ABS_MT_POSITION_Y, 293 + data->y_min, data->y_max, 0, 0); 740 294 741 - if (devInfo.x_active_len_mm && devInfo.y_active_len_mm) { 742 - res_x = (devInfo.x_max - 1) / devInfo.x_active_len_mm; 743 - res_y = (devInfo.y_max - 1) / devInfo.y_active_len_mm; 295 + if (data->x_active_len_mm && data->y_active_len_mm) { 296 + res_x = (data->x_max - 1) / data->x_active_len_mm; 297 + res_y = (data->y_max - 1) / data->y_active_len_mm; 744 298 745 299 input_abs_set_res(input, ABS_MT_POSITION_X, res_x); 746 300 input_abs_set_res(input, ABS_MT_POSITION_Y, res_y); ··· 686 364 687 365 input_set_abs_params(input, ABS_MT_PRESSURE, 0, 64, 0, 0); 688 366 689 - input_mt_init_slots(input, MAX_TOUCHES, INPUT_MT_POINTER); 367 + input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER); 690 368 691 369 __set_bit(EV_KEY, input->evbit); 692 - if ((devInfo.btn_info & 0x0F) == (devInfo.btn_info & 0xF0) >> 4) { 693 - devInfo.btn_cnt = (devInfo.btn_info & 0x0F); 694 - } else { 695 - /* Button pad */ 696 - devInfo.btn_cnt = 1; 697 - __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 698 - } 699 370 700 - for (i = 0; i < devInfo.btn_cnt; i++) 371 + if (data->btn_cnt == 1) 372 + __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 373 + 374 + for (i = 0; i < data->btn_cnt; i++) 701 375 __set_bit(BTN_LEFT + i, input->keybit); 702 376 703 - 704 377 /* Stick device initialization */ 705 - if (devInfo.dev_type & U1_DEVTYPE_SP_SUPPORT) { 706 - 378 + if (data->has_sp) { 707 379 input2 = input_allocate_device(); 708 380 if (!input2) { 709 - ret = -ENOMEM; 381 + input_free_device(input2); 710 382 goto exit; 711 383 } 712 384 713 385 data->input2 = input2; 714 - 715 - devInfo.dev_ctrl |= U1_SP_ABS_MODE; 716 - ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, 717 - NULL, devInfo.dev_ctrl, false); 718 - if (ret < 0) { 719 - dev_err(&hdev->dev, "failed SP mode (%d)\n", ret); 720 - input_free_device(input2); 721 - goto exit; 722 - } 723 - 724 - ret = u1_read_write_register(hdev, ADDRESS_U1_SP_BTN, 725 - &devInfo.sp_btn_info, 0, true); 726 - if (ret < 0) { 727 - dev_err(&hdev->dev, "failed U1_SP_BTN (%d)\n", ret); 728 - input_free_device(input2); 729 - goto exit; 730 - } 731 - 732 386 input2->phys = input->phys; 733 387 input2->name = "DualPoint Stick"; 734 388 input2->id.bustype = BUS_I2C; ··· 714 416 input2->dev.parent = input->dev.parent; 715 417 716 418 __set_bit(EV_KEY, input2->evbit); 717 - devInfo.sp_btn_cnt = (devInfo.sp_btn_info & 0x0F); 718 - for (i = 0; i < devInfo.sp_btn_cnt; i++) 419 + data->sp_btn_cnt = (data->sp_btn_info & 0x0F); 420 + for (i = 0; i < data->sp_btn_cnt; i++) 719 421 __set_bit(BTN_LEFT + i, input2->keybit); 720 422 721 423 __set_bit(EV_REL, input2->evbit); ··· 724 426 __set_bit(INPUT_PROP_POINTER, input2->propbit); 725 427 __set_bit(INPUT_PROP_POINTING_STICK, input2->propbit); 726 428 727 - ret = input_register_device(data->input2); 728 - if (ret) { 429 + if (input_register_device(data->input2)) { 729 430 input_free_device(input2); 730 431 goto exit; 731 432 } ··· 745 448 746 449 static int alps_probe(struct hid_device *hdev, const struct hid_device_id *id) 747 450 { 748 - struct u1_dev *data = NULL; 451 + struct alps_dev *data = NULL; 749 452 int ret; 750 - 751 - data = devm_kzalloc(&hdev->dev, sizeof(struct u1_dev), GFP_KERNEL); 453 + data = devm_kzalloc(&hdev->dev, sizeof(struct alps_dev), GFP_KERNEL); 752 454 if (!data) 753 455 return -ENOMEM; 754 456 ··· 760 464 if (ret) { 761 465 hid_err(hdev, "parse failed\n"); 762 466 return ret; 467 + } 468 + 469 + switch (hdev->product) { 470 + case HID_DEVICE_ID_ALPS_T4_BTNLESS: 471 + data->dev_type = T4; 472 + break; 473 + case HID_DEVICE_ID_ALPS_U1_DUAL: 474 + case HID_DEVICE_ID_ALPS_U1: 475 + data->dev_type = U1; 476 + break; 477 + default: 478 + data->dev_type = UNKNOWN; 763 479 } 764 480 765 481 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); ··· 791 483 static const struct hid_device_id alps_id[] = { 792 484 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, 793 485 USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) }, 486 + { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, 487 + USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1) }, 488 + { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, 489 + USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_T4_BTNLESS) }, 794 490 { } 795 491 }; 796 492 MODULE_DEVICE_TABLE(hid, alps_id);
+30 -1
drivers/hid/hid-asus.c
··· 67 67 #define QUIRK_USE_KBD_BACKLIGHT BIT(5) 68 68 #define QUIRK_T100_KEYBOARD BIT(6) 69 69 #define QUIRK_T100CHI BIT(7) 70 + #define QUIRK_G752_KEYBOARD BIT(8) 70 71 71 72 #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ 72 73 QUIRK_NO_INIT_REPORTS | \ ··· 671 670 hid_hw_stop(hdev); 672 671 } 673 672 673 + static const __u8 asus_g752_fixed_rdesc[] = { 674 + 0x19, 0x00, /* Usage Minimum (0x00) */ 675 + 0x2A, 0xFF, 0x00, /* Usage Maximum (0xFF) */ 676 + }; 677 + 674 678 static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, 675 679 unsigned int *rsize) 676 680 { ··· 714 708 rdesc[391] = 0xff; 715 709 rdesc[402] = 0x00; 716 710 } 711 + if (drvdata->quirks & QUIRK_G752_KEYBOARD && 712 + *rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) { 713 + /* report is missing usage mninum and maximum */ 714 + __u8 *new_rdesc; 715 + size_t new_size = *rsize + sizeof(asus_g752_fixed_rdesc); 716 + 717 + new_rdesc = devm_kzalloc(&hdev->dev, new_size, GFP_KERNEL); 718 + if (new_rdesc == NULL) 719 + return rdesc; 720 + 721 + hid_info(hdev, "Fixing up Asus G752 keyb report descriptor\n"); 722 + /* copy the valid part */ 723 + memcpy(new_rdesc, rdesc, 61); 724 + /* insert missing part */ 725 + memcpy(new_rdesc + 61, asus_g752_fixed_rdesc, sizeof(asus_g752_fixed_rdesc)); 726 + /* copy remaining data */ 727 + memcpy(new_rdesc + 61 + sizeof(asus_g752_fixed_rdesc), rdesc + 61, *rsize - 61); 728 + 729 + *rsize = new_size; 730 + rdesc = new_rdesc; 731 + } 717 732 718 733 return rdesc; 719 734 } ··· 745 718 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, 746 719 USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD), I2C_TOUCHPAD_QUIRKS }, 747 720 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, 748 - USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1) }, 721 + USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1), QUIRK_USE_KBD_BACKLIGHT }, 749 722 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, 750 723 USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2), QUIRK_USE_KBD_BACKLIGHT }, 724 + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, 725 + USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3), QUIRK_G752_KEYBOARD }, 751 726 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, 752 727 USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD), 753 728 QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
+6 -2
drivers/hid/hid-core.c
··· 1662 1662 .size = HID_MAX_DESCRIPTOR_SIZE, 1663 1663 }; 1664 1664 1665 - static struct device_attribute dev_attr_country = { 1665 + static const struct device_attribute dev_attr_country = { 1666 1666 .attr = { .name = "country", .mode = 0444 }, 1667 1667 .show = show_country, 1668 1668 }; ··· 1889 1889 #endif 1890 1890 #if IS_ENABLED(CONFIG_HID_ALPS) 1891 1891 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) }, 1892 + { HID_I2C_DEVICE(USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) }, 1893 + { HID_I2C_DEVICE(USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1) }, 1894 + { HID_I2C_DEVICE(USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_T4_BTNLESS) }, 1892 1895 #endif 1893 1896 #if IS_ENABLED(CONFIG_HID_APPLE) 1894 1897 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE) }, ··· 1982 1979 { HID_I2C_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD) }, 1983 1980 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1) }, 1984 1981 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2) }, 1982 + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3) }, 1985 1983 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_T100_KEYBOARD) }, 1986 1984 { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_ASUS_MD_5112) }, 1987 1985 { HID_USB_DEVICE(USB_VENDOR_ID_TURBOX, USB_DEVICE_ID_ASUS_MD_5110) }, ··· 2333 2329 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, 2334 2330 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb323) }, 2335 2331 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324) }, 2332 + { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb605) }, 2336 2333 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651) }, 2337 2334 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653) }, 2338 2335 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb654) }, ··· 3126 3121 MODULE_AUTHOR("Vojtech Pavlik"); 3127 3122 MODULE_AUTHOR("Jiri Kosina"); 3128 3123 MODULE_LICENSE("GPL"); 3129 -
+7 -3
drivers/hid/hid-cp2112.c
··· 21 21 * Data Sheet: 22 22 * http://www.silabs.com/Support%20Documents/TechnicalDocs/CP2112.pdf 23 23 * Programming Interface Specification: 24 - * http://www.silabs.com/Support%20Documents/TechnicalDocs/AN495.pdf 24 + * https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf 25 25 */ 26 26 27 27 #include <linux/gpio.h> ··· 196 196 HID_REQ_GET_REPORT); 197 197 if (ret != CP2112_GPIO_CONFIG_LENGTH) { 198 198 hid_err(hdev, "error requesting GPIO config: %d\n", ret); 199 + if (ret >= 0) 200 + ret = -EIO; 199 201 goto exit; 200 202 } 201 203 ··· 207 205 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, 208 206 CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT, 209 207 HID_REQ_SET_REPORT); 210 - if (ret < 0) { 208 + if (ret != CP2112_GPIO_CONFIG_LENGTH) { 211 209 hid_err(hdev, "error setting GPIO config: %d\n", ret); 210 + if (ret >= 0) 211 + ret = -EIO; 212 212 goto exit; 213 213 } 214 214 ··· 218 214 219 215 exit: 220 216 mutex_unlock(&dev->lock); 221 - return ret < 0 ? ret : -EIO; 217 + return ret; 222 218 } 223 219 224 220 static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
+1 -1
drivers/hid/hid-hyperv.c
··· 313 313 314 314 break; 315 315 default: 316 - pr_err("unsupported hid msg type - type %d len %d", 316 + pr_err("unsupported hid msg type - type %d len %d\n", 317 317 hid_msg->header.type, hid_msg->header.size); 318 318 break; 319 319 }
+10
drivers/hid/hid-ids.h
··· 77 77 #define HID_DEVICE_ID_ALPS_U1_DUAL 0x120B 78 78 #define HID_DEVICE_ID_ALPS_U1_DUAL_PTP 0x121F 79 79 #define HID_DEVICE_ID_ALPS_U1_DUAL_3BTN_PTP 0x1220 80 + #define HID_DEVICE_ID_ALPS_U1 0x1215 81 + #define HID_DEVICE_ID_ALPS_T4_BTNLESS 0x120C 82 + 80 83 81 84 #define USB_VENDOR_ID_AMI 0x046b 82 85 #define USB_DEVICE_ID_AMI_VIRT_KEYBOARD_AND_MOUSE 0xff10 ··· 185 182 #define USB_DEVICE_ID_ASUSTEK_I2C_TOUCHPAD 0x0101 186 183 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD1 0x1854 187 184 #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD2 0x1837 185 + #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3 0x1822 188 186 189 187 #define USB_VENDOR_ID_ATEN 0x0557 190 188 #define USB_DEVICE_ID_ATEN_UC100KM 0x2004 ··· 513 509 #define USB_DEVICE_ID_GYRATION_REMOTE_2 0x0003 514 510 #define USB_DEVICE_ID_GYRATION_REMOTE_3 0x0008 515 511 512 + #define I2C_VENDOR_ID_HANTICK 0x0911 513 + #define I2C_PRODUCT_ID_HANTICK_5288 0x5288 514 + 516 515 #define USB_VENDOR_ID_HANWANG 0x0b57 517 516 #define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000 518 517 #define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff ··· 735 728 #define USB_VENDOR_ID_MCC 0x09db 736 729 #define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 737 730 #define USB_DEVICE_ID_MCC_PMD1208LS 0x007a 731 + 732 + #define USB_VENDOR_ID_MCS 0x16d0 733 + #define USB_DEVICE_ID_MCS_GAMEPADBLOCK 0x0bcc 738 734 739 735 #define USB_VENDOR_ID_MGE 0x0463 740 736 #define USB_DEVICE_ID_MGE_UPS 0xffff
+9
drivers/hid/hid-input.c
··· 797 797 map_key_clear(BTN_STYLUS); 798 798 break; 799 799 800 + case 0x45: /* ERASER */ 801 + /* 802 + * This event is reported when eraser tip touches the surface. 803 + * Actual eraser (BTN_TOOL_RUBBER) is set by Invert usage when 804 + * tool gets in proximity. 805 + */ 806 + map_key_clear(BTN_TOUCH); 807 + break; 808 + 800 809 case 0x46: /* TabletPick */ 801 810 case 0x5a: /* SecondaryBarrelSwitch */ 802 811 map_key_clear(BTN_STYLUS2);
+3 -1
drivers/hid/hid-lg.c
··· 756 756 757 757 /* Setup wireless link with Logitech Wii wheel */ 758 758 if (hdev->product == USB_DEVICE_ID_LOGITECH_WII_WHEEL) { 759 - const unsigned char cbuf[] = { 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 759 + static const unsigned char cbuf[] = { 760 + 0x00, 0xAF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 761 + }; 760 762 u8 *buf = kmemdup(cbuf, sizeof(cbuf), GFP_KERNEL); 761 763 762 764 if (!buf) {
+1 -3
drivers/hid/hid-lg4ff.c
··· 474 474 static void lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude) 475 475 { 476 476 struct hid_device *hid = input_get_drvdata(dev); 477 - struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; 478 - struct hid_report *report = list_entry(report_list->next, struct hid_report, list); 479 - s32 *value = report->field[0]->value; 477 + s32 *value; 480 478 u32 expand_a, expand_b; 481 479 struct lg4ff_device_entry *entry; 482 480 struct lg_drv_data *drv_data;
+48 -4
drivers/hid/hid-multitouch.c
··· 43 43 #include <linux/module.h> 44 44 #include <linux/slab.h> 45 45 #include <linux/input/mt.h> 46 + #include <linux/jiffies.h> 46 47 #include <linux/string.h> 47 48 #include <linux/timer.h> 48 49 ··· 113 112 struct mt_slot curdata; /* placeholder of incoming data */ 114 113 struct mt_class mtclass; /* our mt device class */ 115 114 struct timer_list release_timer; /* to release sticky fingers */ 115 + struct hid_device *hdev; /* hid_device we're attached to */ 116 116 struct mt_fields *fields; /* temporary placeholder for storing the 117 117 multitouch fields */ 118 118 unsigned long mt_io_flags; /* mt flags (MT_IO_FLAGS_*) */ ··· 138 136 bool serial_maybe; /* need to check for serial protocol */ 139 137 bool curvalid; /* is the current contact valid? */ 140 138 unsigned mt_flags; /* flags to pass to input-mt */ 139 + __s32 dev_time; /* the scan time provided by the device */ 140 + unsigned long jiffies; /* the frame's jiffies */ 141 + int timestamp; /* the timestamp to be sent */ 141 142 }; 142 143 143 144 static void mt_post_parse_default_settings(struct mt_device *td); ··· 181 176 182 177 #define MT_DEFAULT_MAXCONTACT 10 183 178 #define MT_MAX_MAXCONTACT 250 179 + 180 + /* 181 + * Resync device and local timestamps after that many microseconds without 182 + * receiving data. 183 + */ 184 + #define MAX_TIMESTAMP_INTERVAL 1000000 184 185 185 186 #define MT_USB_DEVICE(v, p) HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH, v, p) 186 187 #define MT_BT_DEVICE(v, p) HID_DEVICE(BUS_BLUETOOTH, HID_GROUP_MULTITOUCH, v, p) ··· 594 583 cls->sn_pressure); 595 584 mt_store_field(usage, td, hi); 596 585 return 1; 586 + case HID_DG_SCANTIME: 587 + hid_map_usage(hi, usage, bit, max, 588 + EV_MSC, MSC_TIMESTAMP); 589 + input_set_capability(hi->input, EV_MSC, MSC_TIMESTAMP); 590 + mt_store_field(usage, td, hi); 591 + return 1; 597 592 case HID_DG_CONTACTCOUNT: 598 593 /* Ignore if indexes are out of bounds. */ 599 594 if (field->index >= field->report->maxfield || ··· 735 718 static void mt_sync_frame(struct mt_device *td, struct input_dev *input) 736 719 { 737 720 input_mt_sync_frame(input); 721 + input_event(input, EV_MSC, MSC_TIMESTAMP, td->timestamp); 738 722 input_sync(input); 739 723 td->num_received = 0; 740 724 if (test_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags)) ··· 743 725 else 744 726 clear_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags); 745 727 clear_bit(MT_IO_FLAGS_ACTIVE_SLOTS, &td->mt_io_flags); 728 + } 729 + 730 + static int mt_compute_timestamp(struct mt_device *td, struct hid_field *field, 731 + __s32 value) 732 + { 733 + long delta = value - td->dev_time; 734 + unsigned long jdelta = jiffies_to_usecs(jiffies - td->jiffies); 735 + 736 + td->jiffies = jiffies; 737 + td->dev_time = value; 738 + 739 + if (delta < 0) 740 + delta += field->logical_maximum; 741 + 742 + /* HID_DG_SCANTIME is expressed in 100us, we want it in us. */ 743 + delta *= 100; 744 + 745 + if (jdelta > MAX_TIMESTAMP_INTERVAL) 746 + /* No data received for a while, resync the timestamp. */ 747 + return 0; 748 + else 749 + return td->timestamp + delta; 746 750 } 747 751 748 752 static int mt_touch_event(struct hid_device *hid, struct hid_field *field, ··· 826 786 break; 827 787 case HID_DG_HEIGHT: 828 788 td->curdata.h = value; 789 + break; 790 + case HID_DG_SCANTIME: 791 + td->timestamp = mt_compute_timestamp(td, field, value); 829 792 break; 830 793 case HID_DG_CONTACTCOUNT: 831 794 break; ··· 1289 1246 td->num_received = 0; 1290 1247 } 1291 1248 1292 - static void mt_expired_timeout(unsigned long arg) 1249 + static void mt_expired_timeout(struct timer_list *t) 1293 1250 { 1294 - struct hid_device *hdev = (void *)arg; 1295 - struct mt_device *td = hid_get_drvdata(hdev); 1251 + struct mt_device *td = from_timer(td, t, release_timer); 1252 + struct hid_device *hdev = td->hdev; 1296 1253 1297 1254 /* 1298 1255 * An input report came in just before we release the sticky fingers, ··· 1323 1280 dev_err(&hdev->dev, "cannot allocate multitouch data\n"); 1324 1281 return -ENOMEM; 1325 1282 } 1283 + td->hdev = hdev; 1326 1284 td->mtclass = *mtclass; 1327 1285 td->inputmode = -1; 1328 1286 td->maxcontact_report_id = -1; ··· 1375 1331 */ 1376 1332 hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; 1377 1333 1378 - setup_timer(&td->release_timer, mt_expired_timeout, (long)hdev); 1334 + timer_setup(&td->release_timer, mt_expired_timeout, 0); 1379 1335 1380 1336 ret = hid_parse(hdev); 1381 1337 if (ret != 0)
+10 -3
drivers/hid/hid-rmi.c
··· 368 368 static int rmi_raw_event(struct hid_device *hdev, 369 369 struct hid_report *report, u8 *data, int size) 370 370 { 371 + struct rmi_data *hdata = hid_get_drvdata(hdev); 372 + 373 + if (!(hdata->device_flags & RMI_DEVICE)) 374 + return 0; 375 + 371 376 size = rmi_check_sanity(hdev, data, size); 372 377 if (size < 2) 373 378 return 0; ··· 718 713 { 719 714 struct rmi_data *hdata = hid_get_drvdata(hdev); 720 715 721 - clear_bit(RMI_STARTED, &hdata->flags); 722 - cancel_work_sync(&hdata->reset_work); 723 - rmi_unregister_transport_device(&hdata->xport); 716 + if (hdata->device_flags & RMI_DEVICE) { 717 + clear_bit(RMI_STARTED, &hdata->flags); 718 + cancel_work_sync(&hdata->reset_work); 719 + rmi_unregister_transport_device(&hdata->xport); 720 + } 724 721 725 722 hid_hw_stop(hdev); 726 723 }
+10 -4
drivers/hid/hid-sony.c
··· 1439 1439 goto out; 1440 1440 } 1441 1441 1442 - ret = hid_hw_output_report(hdev, buf, 1); 1443 - if (ret < 0) { 1444 - hid_info(hdev, "can't set operational mode: step 3, ignoring\n"); 1445 - ret = 0; 1442 + /* 1443 + * But the USB interrupt would cause SHANWAN controllers to 1444 + * start rumbling non-stop. 1445 + */ 1446 + if (strcmp(hdev->name, "SHANWAN PS3 GamePad")) { 1447 + ret = hid_hw_output_report(hdev, buf, 1); 1448 + if (ret < 0) { 1449 + hid_info(hdev, "can't set operational mode: step 3, ignoring\n"); 1450 + ret = 0; 1451 + } 1446 1452 } 1447 1453 1448 1454 out:
+2
drivers/hid/hid-tmff.c
··· 242 242 .driver_data = (unsigned long)ff_rumble }, 243 243 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb324), /* Dual Trigger 3-in-1 (PS3 Mode) */ 244 244 .driver_data = (unsigned long)ff_rumble }, 245 + { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb605), /* NASCAR PRO FF2 Wheel */ 246 + .driver_data = (unsigned long)ff_joystick }, 245 247 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb651), /* FGT Rumble Force Wheel */ 246 248 .driver_data = (unsigned long)ff_rumble }, 247 249 { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb653), /* RGT Force Feedback CLUTCH Raging Wheel */
+6 -1
drivers/hid/i2c-hid/i2c-hid.c
··· 46 46 47 47 /* quirks to control the device */ 48 48 #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) 49 + #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET BIT(1) 49 50 50 51 /* flags */ 51 52 #define I2C_HID_STARTED 0 ··· 169 168 I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, 170 169 { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8755, 171 170 I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, 171 + { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, 172 + I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, 172 173 { 0, 0 } 173 174 }; 174 175 ··· 255 252 256 253 ret = 0; 257 254 258 - if (wait) { 255 + if (wait && (ihid->quirks & I2C_HID_QUIRK_NO_IRQ_AFTER_RESET)) { 256 + msleep(100); 257 + } else if (wait) { 259 258 i2c_hid_dbg(ihid, "%s: waiting...\n", __func__); 260 259 if (!wait_event_timeout(ihid->wait, 261 260 !test_bit(I2C_HID_RESET_PENDING, &ihid->flags),
+4 -4
drivers/hid/usbhid/hid-core.c
··· 101 101 } 102 102 103 103 /* I/O retry timer routine */ 104 - static void hid_retry_timeout(unsigned long _hid) 104 + static void hid_retry_timeout(struct timer_list *t) 105 105 { 106 - struct hid_device *hid = (struct hid_device *) _hid; 107 - struct usbhid_device *usbhid = hid->driver_data; 106 + struct usbhid_device *usbhid = from_timer(usbhid, t, io_retry); 107 + struct hid_device *hid = usbhid->hid; 108 108 109 109 dev_dbg(&usbhid->intf->dev, "retrying intr urb\n"); 110 110 if (hid_start_in(hid)) ··· 1373 1373 1374 1374 init_waitqueue_head(&usbhid->wait); 1375 1375 INIT_WORK(&usbhid->reset_work, hid_reset); 1376 - setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); 1376 + timer_setup(&usbhid->io_retry, hid_retry_timeout, 0); 1377 1377 spin_lock_init(&usbhid->lock); 1378 1378 1379 1379 ret = hid_add_device(hid);
+1
drivers/hid/usbhid/hid-quirks.c
··· 170 170 { USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_2NES2SNES, HID_QUIRK_MULTI_INPUT }, 171 171 { USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_4NES4SNES, HID_QUIRK_MULTI_INPUT }, 172 172 { USB_VENDOR_ID_INNOMEDIA, USB_DEVICE_ID_INNEX_GENESIS_ATARI, HID_QUIRK_MULTI_INPUT }, 173 + { USB_VENDOR_ID_MCS, USB_DEVICE_ID_MCS_GAMEPADBLOCK, HID_QUIRK_MULTI_INPUT }, 173 174 174 175 { 0, 0 } 175 176 };
+7
drivers/hid/wacom_sys.c
··· 196 196 kfree(data); 197 197 break; 198 198 } 199 + 200 + if (hdev->vendor == USB_VENDOR_ID_WACOM && 201 + hdev->product == 0x4200 /* Dell Canvas 27 */ && 202 + field->application == HID_UP_MSVENDOR) { 203 + wacom->wacom_wac.mode_report = field->report->id; 204 + wacom->wacom_wac.mode_value = 2; 205 + } 199 206 } 200 207 201 208 /*
+29 -15
drivers/hid/wacom_wac.c
··· 2140 2140 case HID_DG_TIPSWITCH: 2141 2141 wacom_wac->hid_data.tipswitch |= value; 2142 2142 return; 2143 + case HID_DG_BARRELSWITCH: 2144 + wacom_wac->hid_data.barrelswitch = value; 2145 + return; 2146 + case HID_DG_BARRELSWITCH2: 2147 + wacom_wac->hid_data.barrelswitch2 = value; 2148 + return; 2143 2149 case HID_DG_TOOLSERIALNUMBER: 2144 2150 if (value) { 2145 2151 wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL); ··· 2223 2217 if (!usage->type || delay_pen_events(wacom_wac)) 2224 2218 return; 2225 2219 2226 - /* send pen events only when the pen is in/entering/leaving proximity */ 2227 - if (!wacom_wac->hid_data.inrange_state && !wacom_wac->tool[0]) 2228 - return; 2229 - 2230 - input_event(input, usage->type, usage->code, value); 2220 + /* send pen events only when the pen is in range */ 2221 + if (wacom_wac->hid_data.inrange_state) 2222 + input_event(input, usage->type, usage->code, value); 2223 + else if (wacom_wac->shared->stylus_in_proximity && !wacom_wac->hid_data.sense_state) 2224 + input_event(input, usage->type, usage->code, 0); 2231 2225 } 2232 2226 2233 2227 static void wacom_wac_pen_pre_report(struct hid_device *hdev, ··· 2242 2236 struct wacom *wacom = hid_get_drvdata(hdev); 2243 2237 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 2244 2238 struct input_dev *input = wacom_wac->pen_input; 2245 - bool prox = wacom_wac->hid_data.inrange_state; 2246 - bool range = wacom_wac->hid_data.sense_state; 2239 + bool range = wacom_wac->hid_data.inrange_state; 2240 + bool sense = wacom_wac->hid_data.sense_state; 2247 2241 2248 - if (!wacom_wac->tool[0] && prox) { /* first in prox */ 2249 - /* Going into proximity select tool */ 2242 + if (!wacom_wac->tool[0] && range) { /* first in range */ 2243 + /* Going into range select tool */ 2250 2244 if (wacom_wac->hid_data.invert_state) 2251 2245 wacom_wac->tool[0] = BTN_TOOL_RUBBER; 2252 2246 else if (wacom_wac->id[0]) ··· 2256 2250 } 2257 2251 2258 2252 /* keep pen state for touch events */ 2259 - wacom_wac->shared->stylus_in_proximity = range; 2253 + wacom_wac->shared->stylus_in_proximity = sense; 2260 2254 2261 2255 if (!delay_pen_events(wacom_wac) && wacom_wac->tool[0]) { 2262 2256 int id = wacom_wac->id[0]; 2257 + int sw_state = wacom_wac->hid_data.barrelswitch | 2258 + (wacom_wac->hid_data.barrelswitch2 << 1); 2259 + 2260 + input_report_key(input, BTN_STYLUS, sw_state == 1); 2261 + input_report_key(input, BTN_STYLUS2, sw_state == 2); 2262 + input_report_key(input, BTN_STYLUS3, sw_state == 3); 2263 2263 2264 2264 /* 2265 2265 * Non-USI EMR tools should have their IDs mangled to ··· 2281 2269 */ 2282 2270 input_report_key(input, BTN_TOUCH, 2283 2271 wacom_wac->hid_data.tipswitch); 2284 - input_report_key(input, wacom_wac->tool[0], prox); 2272 + input_report_key(input, wacom_wac->tool[0], sense); 2285 2273 if (wacom_wac->serial[0]) { 2286 2274 input_event(input, EV_MSC, MSC_SERIAL, wacom_wac->serial[0]); 2287 - input_report_abs(input, ABS_MISC, prox ? id : 0); 2275 + input_report_abs(input, ABS_MISC, sense ? id : 0); 2288 2276 } 2289 2277 2290 2278 wacom_wac->hid_data.tipswitch = false; ··· 2292 2280 input_sync(input); 2293 2281 } 2294 2282 2295 - if (!prox) { 2283 + if (!sense) { 2296 2284 wacom_wac->tool[0] = 0; 2297 2285 wacom_wac->id[0] = 0; 2298 2286 wacom_wac->serial[0] = 0; ··· 3312 3300 else 3313 3301 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 3314 3302 3315 - if (features->type == HID_GENERIC) 3316 - /* setup has already been done */ 3303 + if (features->type == HID_GENERIC) { 3304 + /* setup has already been done; apply otherwise-undetectible quirks */ 3305 + input_set_capability(input_dev, EV_KEY, BTN_STYLUS3); 3317 3306 return 0; 3307 + } 3318 3308 3319 3309 __set_bit(BTN_TOUCH, input_dev->keybit); 3320 3310 __set_bit(ABS_MISC, input_dev->absbit);
+3
drivers/hid/wacom_wac.h
··· 166 166 ((f)->physical == HID_DG_PEN) || \ 167 167 ((f)->application == HID_DG_PEN) || \ 168 168 ((f)->application == HID_DG_DIGITIZER) || \ 169 + ((f)->application == WACOM_HID_WD_PEN) || \ 169 170 ((f)->application == WACOM_HID_WD_DIGITIZER) || \ 170 171 ((f)->application == WACOM_HID_G9_PEN) || \ 171 172 ((f)->application == WACOM_HID_G11_PEN)) ··· 292 291 bool inrange_state; 293 292 bool invert_state; 294 293 bool tipswitch; 294 + bool barrelswitch; 295 + bool barrelswitch2; 295 296 int x; 296 297 int y; 297 298 int pressure;
+2
include/linux/hid.h
··· 289 289 #define HID_DG_DEVICEINDEX 0x000d0053 290 290 #define HID_DG_CONTACTCOUNT 0x000d0054 291 291 #define HID_DG_CONTACTMAX 0x000d0055 292 + #define HID_DG_SCANTIME 0x000d0056 292 293 #define HID_DG_BUTTONTYPE 0x000d0059 293 294 #define HID_DG_BARRELSWITCH2 0x000d005a 294 295 #define HID_DG_TOOLSERIALNUMBER 0x000d005b ··· 754 753 * @stop: called on remove 755 754 * @open: called by input layer on open 756 755 * @close: called by input layer on close 756 + * @power: request underlying hardware to enter requested power mode 757 757 * @parse: this method is called only once to parse the device data, 758 758 * shouldn't allocate anything to not leak memory 759 759 * @request: send report request to device (e.g. feature report)
+1
include/uapi/linux/input-event-codes.h
··· 407 407 #define BTN_TOOL_MOUSE 0x146 408 408 #define BTN_TOOL_LENS 0x147 409 409 #define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ 410 + #define BTN_STYLUS3 0x149 410 411 #define BTN_TOUCH 0x14a 411 412 #define BTN_STYLUS 0x14b 412 413 #define BTN_STYLUS2 0x14c