1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright (c) 2013 Andrew Duggan <aduggan@synaptics.com> 4 * Copyright (c) 2013 Synaptics Incorporated 5 * Copyright (c) 2014 Benjamin Tissoires <benjamin.tissoires@gmail.com> 6 * Copyright (c) 2014 Red Hat, Inc 7 */ 8 9 #include <linux/kernel.h> 10 #include <linux/hid.h> 11 #include <linux/input.h> 12 #include <linux/input/mt.h> 13 #include <linux/irq.h> 14 #include <linux/irqdomain.h> 15 #include <linux/module.h> 16 #include <linux/pm.h> 17 #include <linux/slab.h> 18 #include <linux/wait.h> 19 #include <linux/sched.h> 20 #include <linux/rmi.h> 21 #include "hid-ids.h" 22 23 #define RMI_MOUSE_REPORT_ID 0x01 /* Mouse emulation Report */ 24 #define RMI_WRITE_REPORT_ID 0x09 /* Output Report */ 25 #define RMI_READ_ADDR_REPORT_ID 0x0a /* Output Report */ 26 #define RMI_READ_DATA_REPORT_ID 0x0b /* Input Report */ 27 #define RMI_ATTN_REPORT_ID 0x0c /* Input Report */ 28 #define RMI_SET_RMI_MODE_REPORT_ID 0x0f /* Feature Report */ 29 30 /* flags */ 31 #define RMI_READ_REQUEST_PENDING 0 32 #define RMI_READ_DATA_PENDING 1 33 #define RMI_STARTED 2 34 35 /* device flags */ 36 #define RMI_DEVICE BIT(0) 37 #define RMI_DEVICE_HAS_PHYS_BUTTONS BIT(1) 38 39 /* 40 * retrieve the ctrl registers 41 * the ctrl register has a size of 20 but a fw bug split it into 16 + 4, 42 * and there is no way to know if the first 20 bytes are here or not. 43 * We use only the first 12 bytes, so get only them. 44 */ 45 #define RMI_F11_CTRL_REG_COUNT 12 46 47 enum rmi_mode_type { 48 RMI_MODE_OFF = 0, 49 RMI_MODE_ATTN_REPORTS = 1, 50 RMI_MODE_NO_PACKED_ATTN_REPORTS = 2, 51 }; 52 53 /** 54 * struct rmi_data - stores information for hid communication 55 * 56 * @page_mutex: Locks current page to avoid changing pages in unexpected ways. 57 * @page: Keeps track of the current virtual page 58 * @xport: transport device to be registered with the RMI4 core. 59 * 60 * @wait: Used for waiting for read data 61 * 62 * @writeReport: output buffer when writing RMI registers 63 * @readReport: input buffer when reading RMI registers 64 * 65 * @input_report_size: size of an input report (advertised by HID) 66 * @output_report_size: size of an output report (advertised by HID) 67 * 68 * @flags: flags for the current device (started, reading, etc...) 69 * 70 * @reset_work: worker which will be called in case of a mouse report 71 * @hdev: pointer to the struct hid_device 72 * 73 * @device_flags: flags which describe the device 74 * 75 * @domain: the IRQ domain allocated for this RMI4 device 76 * @rmi_irq: the irq that will be used to generate events to rmi-core 77 */ 78 struct rmi_data { 79 struct mutex page_mutex; 80 int page; 81 struct rmi_transport_dev xport; 82 83 wait_queue_head_t wait; 84 85 u8 *writeReport; 86 u8 *readReport; 87 88 u32 input_report_size; 89 u32 output_report_size; 90 91 unsigned long flags; 92 93 struct work_struct reset_work; 94 struct hid_device *hdev; 95 96 unsigned long device_flags; 97 98 struct irq_domain *domain; 99 int rmi_irq; 100 }; 101 102 #define RMI_PAGE(addr) (((addr) >> 8) & 0xff) 103 104 static int rmi_write_report(struct hid_device *hdev, u8 *report, int len); 105 106 /** 107 * rmi_set_page - Set RMI page 108 * @hdev: The pointer to the hid_device struct 109 * @page: The new page address. 110 * 111 * RMI devices have 16-bit addressing, but some of the physical 112 * implementations (like SMBus) only have 8-bit addressing. So RMI implements 113 * a page address at 0xff of every page so we can reliable page addresses 114 * every 256 registers. 115 * 116 * The page_mutex lock must be held when this function is entered. 117 * 118 * Returns zero on success, non-zero on failure. 119 */ 120 static int rmi_set_page(struct hid_device *hdev, u8 page) 121 { 122 struct rmi_data *data = hid_get_drvdata(hdev); 123 int retval; 124 125 data->writeReport[0] = RMI_WRITE_REPORT_ID; 126 data->writeReport[1] = 1; 127 data->writeReport[2] = 0xFF; 128 data->writeReport[4] = page; 129 130 retval = rmi_write_report(hdev, data->writeReport, 131 data->output_report_size); 132 if (retval != data->output_report_size) { 133 dev_err(&hdev->dev, 134 "%s: set page failed: %d.", __func__, retval); 135 return retval; 136 } 137 138 data->page = page; 139 return 0; 140 } 141 142 static int rmi_set_mode(struct hid_device *hdev, u8 mode) 143 { 144 int ret; 145 const u8 txbuf[2] = {RMI_SET_RMI_MODE_REPORT_ID, mode}; 146 u8 *buf; 147 148 buf = kmemdup(txbuf, sizeof(txbuf), GFP_KERNEL); 149 if (!buf) 150 return -ENOMEM; 151 152 ret = hid_hw_raw_request(hdev, RMI_SET_RMI_MODE_REPORT_ID, buf, 153 sizeof(txbuf), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); 154 kfree(buf); 155 if (ret < 0) { 156 dev_err(&hdev->dev, "unable to set rmi mode to %d (%d)\n", mode, 157 ret); 158 return ret; 159 } 160 161 return 0; 162 } 163 164 static int rmi_write_report(struct hid_device *hdev, u8 *report, int len) 165 { 166 int ret; 167 168 ret = hid_hw_output_report(hdev, (void *)report, len); 169 if (ret < 0) { 170 dev_err(&hdev->dev, "failed to write hid report (%d)\n", ret); 171 return ret; 172 } 173 174 return ret; 175 } 176 177 static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr, 178 void *buf, size_t len) 179 { 180 struct rmi_data *data = container_of(xport, struct rmi_data, xport); 181 struct hid_device *hdev = data->hdev; 182 int ret; 183 int bytes_read; 184 int bytes_needed; 185 int retries; 186 int read_input_count; 187 188 mutex_lock(&data->page_mutex); 189 190 if (RMI_PAGE(addr) != data->page) { 191 ret = rmi_set_page(hdev, RMI_PAGE(addr)); 192 if (ret < 0) 193 goto exit; 194 } 195 196 for (retries = 5; retries > 0; retries--) { 197 data->writeReport[0] = RMI_READ_ADDR_REPORT_ID; 198 data->writeReport[1] = 0; /* old 1 byte read count */ 199 data->writeReport[2] = addr & 0xFF; 200 data->writeReport[3] = (addr >> 8) & 0xFF; 201 data->writeReport[4] = len & 0xFF; 202 data->writeReport[5] = (len >> 8) & 0xFF; 203 204 set_bit(RMI_READ_REQUEST_PENDING, &data->flags); 205 206 ret = rmi_write_report(hdev, data->writeReport, 207 data->output_report_size); 208 if (ret != data->output_report_size) { 209 clear_bit(RMI_READ_REQUEST_PENDING, &data->flags); 210 dev_err(&hdev->dev, 211 "failed to write request output report (%d)\n", 212 ret); 213 goto exit; 214 } 215 216 bytes_read = 0; 217 bytes_needed = len; 218 while (bytes_read < len) { 219 if (!wait_event_timeout(data->wait, 220 test_bit(RMI_READ_DATA_PENDING, &data->flags), 221 msecs_to_jiffies(1000))) { 222 hid_warn(hdev, "%s: timeout elapsed\n", 223 __func__); 224 ret = -EAGAIN; 225 break; 226 } 227 228 read_input_count = data->readReport[1]; 229 memcpy(buf + bytes_read, &data->readReport[2], 230 read_input_count < bytes_needed ? 231 read_input_count : bytes_needed); 232 233 bytes_read += read_input_count; 234 bytes_needed -= read_input_count; 235 clear_bit(RMI_READ_DATA_PENDING, &data->flags); 236 } 237 238 if (ret >= 0) { 239 ret = 0; 240 break; 241 } 242 } 243 244 exit: 245 clear_bit(RMI_READ_REQUEST_PENDING, &data->flags); 246 mutex_unlock(&data->page_mutex); 247 return ret; 248 } 249 250 static int rmi_hid_write_block(struct rmi_transport_dev *xport, u16 addr, 251 const void *buf, size_t len) 252 { 253 struct rmi_data *data = container_of(xport, struct rmi_data, xport); 254 struct hid_device *hdev = data->hdev; 255 int ret; 256 257 mutex_lock(&data->page_mutex); 258 259 if (RMI_PAGE(addr) != data->page) { 260 ret = rmi_set_page(hdev, RMI_PAGE(addr)); 261 if (ret < 0) 262 goto exit; 263 } 264 265 data->writeReport[0] = RMI_WRITE_REPORT_ID; 266 data->writeReport[1] = len; 267 data->writeReport[2] = addr & 0xFF; 268 data->writeReport[3] = (addr >> 8) & 0xFF; 269 memcpy(&data->writeReport[4], buf, len); 270 271 ret = rmi_write_report(hdev, data->writeReport, 272 data->output_report_size); 273 if (ret < 0) { 274 dev_err(&hdev->dev, 275 "failed to write request output report (%d)\n", 276 ret); 277 goto exit; 278 } 279 ret = 0; 280 281 exit: 282 mutex_unlock(&data->page_mutex); 283 return ret; 284 } 285 286 static int rmi_reset_attn_mode(struct hid_device *hdev) 287 { 288 struct rmi_data *data = hid_get_drvdata(hdev); 289 struct rmi_device *rmi_dev = data->xport.rmi_dev; 290 int ret; 291 292 ret = rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); 293 if (ret) 294 return ret; 295 296 if (test_bit(RMI_STARTED, &data->flags)) 297 ret = rmi_dev->driver->reset_handler(rmi_dev); 298 299 return ret; 300 } 301 302 static void rmi_reset_work(struct work_struct *work) 303 { 304 struct rmi_data *hdata = container_of(work, struct rmi_data, 305 reset_work); 306 307 /* switch the device to RMI if we receive a generic mouse report */ 308 rmi_reset_attn_mode(hdata->hdev); 309 } 310 311 static int rmi_input_event(struct hid_device *hdev, u8 *data, int size) 312 { 313 struct rmi_data *hdata = hid_get_drvdata(hdev); 314 struct rmi_device *rmi_dev = hdata->xport.rmi_dev; 315 unsigned long flags; 316 317 if (!(test_bit(RMI_STARTED, &hdata->flags))) 318 return 0; 319 320 local_irq_save(flags); 321 322 rmi_set_attn_data(rmi_dev, data[1], &data[2], size - 2); 323 324 generic_handle_irq(hdata->rmi_irq); 325 326 local_irq_restore(flags); 327 328 return 1; 329 } 330 331 static int rmi_read_data_event(struct hid_device *hdev, u8 *data, int size) 332 { 333 struct rmi_data *hdata = hid_get_drvdata(hdev); 334 335 if (!test_bit(RMI_READ_REQUEST_PENDING, &hdata->flags)) { 336 hid_dbg(hdev, "no read request pending\n"); 337 return 0; 338 } 339 340 memcpy(hdata->readReport, data, size < hdata->input_report_size ? 341 size : hdata->input_report_size); 342 set_bit(RMI_READ_DATA_PENDING, &hdata->flags); 343 wake_up(&hdata->wait); 344 345 return 1; 346 } 347 348 static int rmi_check_sanity(struct hid_device *hdev, u8 *data, int size) 349 { 350 int valid_size = size; 351 /* 352 * On the Dell XPS 13 9333, the bus sometimes get confused and fills 353 * the report with a sentinel value "ff". Synaptics told us that such 354 * behavior does not comes from the touchpad itself, so we filter out 355 * such reports here. 356 */ 357 358 while ((data[valid_size - 1] == 0xff) && valid_size > 0) 359 valid_size--; 360 361 return valid_size; 362 } 363 364 static int rmi_raw_event(struct hid_device *hdev, 365 struct hid_report *report, u8 *data, int size) 366 { 367 struct rmi_data *hdata = hid_get_drvdata(hdev); 368 369 if (!(hdata->device_flags & RMI_DEVICE)) 370 return 0; 371 372 size = rmi_check_sanity(hdev, data, size); 373 if (size < 2) 374 return 0; 375 376 switch (data[0]) { 377 case RMI_READ_DATA_REPORT_ID: 378 return rmi_read_data_event(hdev, data, size); 379 case RMI_ATTN_REPORT_ID: 380 return rmi_input_event(hdev, data, size); 381 default: 382 return 1; 383 } 384 385 return 0; 386 } 387 388 static int rmi_event(struct hid_device *hdev, struct hid_field *field, 389 struct hid_usage *usage, __s32 value) 390 { 391 struct rmi_data *data = hid_get_drvdata(hdev); 392 393 if ((data->device_flags & RMI_DEVICE) && 394 (field->application == HID_GD_POINTER || 395 field->application == HID_GD_MOUSE)) { 396 if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) { 397 if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) 398 return 0; 399 400 if ((usage->hid == HID_GD_X || usage->hid == HID_GD_Y) 401 && !value) 402 return 1; 403 } 404 405 schedule_work(&data->reset_work); 406 return 1; 407 } 408 409 return 0; 410 } 411 412 static void rmi_report(struct hid_device *hid, struct hid_report *report) 413 { 414 struct hid_field *field = report->field[0]; 415 416 if (!(hid->claimed & HID_CLAIMED_INPUT)) 417 return; 418 419 switch (report->id) { 420 case RMI_READ_DATA_REPORT_ID: 421 /* fall-through */ 422 case RMI_ATTN_REPORT_ID: 423 return; 424 } 425 426 if (field && field->hidinput && field->hidinput->input) 427 input_sync(field->hidinput->input); 428 } 429 430 #ifdef CONFIG_PM 431 static int rmi_suspend(struct hid_device *hdev, pm_message_t message) 432 { 433 struct rmi_data *data = hid_get_drvdata(hdev); 434 struct rmi_device *rmi_dev = data->xport.rmi_dev; 435 int ret; 436 437 if (!(data->device_flags & RMI_DEVICE)) 438 return 0; 439 440 ret = rmi_driver_suspend(rmi_dev, false); 441 if (ret) { 442 hid_warn(hdev, "Failed to suspend device: %d\n", ret); 443 return ret; 444 } 445 446 return 0; 447 } 448 449 static int rmi_post_resume(struct hid_device *hdev) 450 { 451 struct rmi_data *data = hid_get_drvdata(hdev); 452 struct rmi_device *rmi_dev = data->xport.rmi_dev; 453 int ret; 454 455 if (!(data->device_flags & RMI_DEVICE)) 456 return 0; 457 458 /* Make sure the HID device is ready to receive events */ 459 ret = hid_hw_open(hdev); 460 if (ret) 461 return ret; 462 463 ret = rmi_reset_attn_mode(hdev); 464 if (ret) 465 goto out; 466 467 ret = rmi_driver_resume(rmi_dev, false); 468 if (ret) { 469 hid_warn(hdev, "Failed to resume device: %d\n", ret); 470 goto out; 471 } 472 473 out: 474 hid_hw_close(hdev); 475 return ret; 476 } 477 #endif /* CONFIG_PM */ 478 479 static int rmi_hid_reset(struct rmi_transport_dev *xport, u16 reset_addr) 480 { 481 struct rmi_data *data = container_of(xport, struct rmi_data, xport); 482 struct hid_device *hdev = data->hdev; 483 484 return rmi_reset_attn_mode(hdev); 485 } 486 487 static int rmi_input_configured(struct hid_device *hdev, struct hid_input *hi) 488 { 489 struct rmi_data *data = hid_get_drvdata(hdev); 490 struct input_dev *input = hi->input; 491 int ret = 0; 492 493 if (!(data->device_flags & RMI_DEVICE)) 494 return 0; 495 496 data->xport.input = input; 497 498 hid_dbg(hdev, "Opening low level driver\n"); 499 ret = hid_hw_open(hdev); 500 if (ret) 501 return ret; 502 503 /* Allow incoming hid reports */ 504 hid_device_io_start(hdev); 505 506 ret = rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); 507 if (ret < 0) { 508 dev_err(&hdev->dev, "failed to set rmi mode\n"); 509 goto exit; 510 } 511 512 ret = rmi_set_page(hdev, 0); 513 if (ret < 0) { 514 dev_err(&hdev->dev, "failed to set page select to 0.\n"); 515 goto exit; 516 } 517 518 ret = rmi_register_transport_device(&data->xport); 519 if (ret < 0) { 520 dev_err(&hdev->dev, "failed to register transport driver\n"); 521 goto exit; 522 } 523 524 set_bit(RMI_STARTED, &data->flags); 525 526 exit: 527 hid_device_io_stop(hdev); 528 hid_hw_close(hdev); 529 return ret; 530 } 531 532 static int rmi_input_mapping(struct hid_device *hdev, 533 struct hid_input *hi, struct hid_field *field, 534 struct hid_usage *usage, unsigned long **bit, int *max) 535 { 536 struct rmi_data *data = hid_get_drvdata(hdev); 537 538 /* 539 * we want to make HID ignore the advertised HID collection 540 * for RMI deivces 541 */ 542 if (data->device_flags & RMI_DEVICE) { 543 if ((data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) && 544 ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON)) 545 return 0; 546 547 return -1; 548 } 549 550 return 0; 551 } 552 553 static int rmi_check_valid_report_id(struct hid_device *hdev, unsigned type, 554 unsigned id, struct hid_report **report) 555 { 556 int i; 557 558 *report = hdev->report_enum[type].report_id_hash[id]; 559 if (*report) { 560 for (i = 0; i < (*report)->maxfield; i++) { 561 unsigned app = (*report)->field[i]->application; 562 if ((app & HID_USAGE_PAGE) >= HID_UP_MSVENDOR) 563 return 1; 564 } 565 } 566 567 return 0; 568 } 569 570 static struct rmi_device_platform_data rmi_hid_pdata = { 571 .sensor_pdata = { 572 .sensor_type = rmi_sensor_touchpad, 573 .axis_align.flip_y = true, 574 .dribble = RMI_REG_STATE_ON, 575 .palm_detect = RMI_REG_STATE_OFF, 576 }, 577 }; 578 579 static const struct rmi_transport_ops hid_rmi_ops = { 580 .write_block = rmi_hid_write_block, 581 .read_block = rmi_hid_read_block, 582 .reset = rmi_hid_reset, 583 }; 584 585 static void rmi_irq_teardown(void *data) 586 { 587 struct rmi_data *hdata = data; 588 struct irq_domain *domain = hdata->domain; 589 590 if (!domain) 591 return; 592 593 irq_dispose_mapping(irq_find_mapping(domain, 0)); 594 595 irq_domain_remove(domain); 596 hdata->domain = NULL; 597 hdata->rmi_irq = 0; 598 } 599 600 static int rmi_irq_map(struct irq_domain *h, unsigned int virq, 601 irq_hw_number_t hw_irq_num) 602 { 603 irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq); 604 605 return 0; 606 } 607 608 static const struct irq_domain_ops rmi_irq_ops = { 609 .map = rmi_irq_map, 610 }; 611 612 static int rmi_setup_irq_domain(struct hid_device *hdev) 613 { 614 struct rmi_data *hdata = hid_get_drvdata(hdev); 615 int ret; 616 617 hdata->domain = irq_domain_create_linear(hdev->dev.fwnode, 1, 618 &rmi_irq_ops, hdata); 619 if (!hdata->domain) 620 return -ENOMEM; 621 622 ret = devm_add_action_or_reset(&hdev->dev, &rmi_irq_teardown, hdata); 623 if (ret) 624 return ret; 625 626 hdata->rmi_irq = irq_create_mapping(hdata->domain, 0); 627 if (hdata->rmi_irq <= 0) { 628 hid_err(hdev, "Can't allocate an IRQ\n"); 629 return hdata->rmi_irq < 0 ? hdata->rmi_irq : -ENXIO; 630 } 631 632 return 0; 633 } 634 635 static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) 636 { 637 struct rmi_data *data = NULL; 638 int ret; 639 size_t alloc_size; 640 struct hid_report *input_report; 641 struct hid_report *output_report; 642 struct hid_report *feature_report; 643 644 data = devm_kzalloc(&hdev->dev, sizeof(struct rmi_data), GFP_KERNEL); 645 if (!data) 646 return -ENOMEM; 647 648 INIT_WORK(&data->reset_work, rmi_reset_work); 649 data->hdev = hdev; 650 651 hid_set_drvdata(hdev, data); 652 653 hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; 654 hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC; 655 656 ret = hid_parse(hdev); 657 if (ret) { 658 hid_err(hdev, "parse failed\n"); 659 return ret; 660 } 661 662 if (id->driver_data) 663 data->device_flags = id->driver_data; 664 665 /* 666 * Check for the RMI specific report ids. If they are misisng 667 * simply return and let the events be processed by hid-input 668 */ 669 if (!rmi_check_valid_report_id(hdev, HID_FEATURE_REPORT, 670 RMI_SET_RMI_MODE_REPORT_ID, &feature_report)) { 671 hid_dbg(hdev, "device does not have set mode feature report\n"); 672 goto start; 673 } 674 675 if (!rmi_check_valid_report_id(hdev, HID_INPUT_REPORT, 676 RMI_ATTN_REPORT_ID, &input_report)) { 677 hid_dbg(hdev, "device does not have attention input report\n"); 678 goto start; 679 } 680 681 data->input_report_size = hid_report_len(input_report); 682 683 if (!rmi_check_valid_report_id(hdev, HID_OUTPUT_REPORT, 684 RMI_WRITE_REPORT_ID, &output_report)) { 685 hid_dbg(hdev, 686 "device does not have rmi write output report\n"); 687 goto start; 688 } 689 690 data->output_report_size = hid_report_len(output_report); 691 692 data->device_flags |= RMI_DEVICE; 693 alloc_size = data->output_report_size + data->input_report_size; 694 695 data->writeReport = devm_kzalloc(&hdev->dev, alloc_size, GFP_KERNEL); 696 if (!data->writeReport) { 697 hid_err(hdev, "failed to allocate buffer for HID reports\n"); 698 return -ENOMEM; 699 } 700 701 data->readReport = data->writeReport + data->output_report_size; 702 703 init_waitqueue_head(&data->wait); 704 705 mutex_init(&data->page_mutex); 706 707 ret = rmi_setup_irq_domain(hdev); 708 if (ret) { 709 hid_err(hdev, "failed to allocate IRQ domain\n"); 710 return ret; 711 } 712 713 if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) 714 rmi_hid_pdata.f30_data.disable = true; 715 716 data->xport.dev = hdev->dev.parent; 717 data->xport.pdata = rmi_hid_pdata; 718 data->xport.pdata.irq = data->rmi_irq; 719 data->xport.proto_name = "hid"; 720 data->xport.ops = &hid_rmi_ops; 721 722 start: 723 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); 724 if (ret) { 725 hid_err(hdev, "hw start failed\n"); 726 return ret; 727 } 728 729 return 0; 730 } 731 732 static void rmi_remove(struct hid_device *hdev) 733 { 734 struct rmi_data *hdata = hid_get_drvdata(hdev); 735 736 if (hdata->device_flags & RMI_DEVICE) { 737 clear_bit(RMI_STARTED, &hdata->flags); 738 cancel_work_sync(&hdata->reset_work); 739 rmi_unregister_transport_device(&hdata->xport); 740 } 741 742 hid_hw_stop(hdev); 743 } 744 745 static const struct hid_device_id rmi_id[] = { 746 { HID_USB_DEVICE(USB_VENDOR_ID_RAZER, USB_DEVICE_ID_RAZER_BLADE_14), 747 .driver_data = RMI_DEVICE_HAS_PHYS_BUTTONS }, 748 { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_X1_COVER) }, 749 { HID_USB_DEVICE(USB_VENDOR_ID_PRIMAX, USB_DEVICE_ID_PRIMAX_REZEL) }, 750 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_RMI, HID_ANY_ID, HID_ANY_ID) }, 751 { } 752 }; 753 MODULE_DEVICE_TABLE(hid, rmi_id); 754 755 static struct hid_driver rmi_driver = { 756 .name = "hid-rmi", 757 .id_table = rmi_id, 758 .probe = rmi_probe, 759 .remove = rmi_remove, 760 .event = rmi_event, 761 .raw_event = rmi_raw_event, 762 .report = rmi_report, 763 .input_mapping = rmi_input_mapping, 764 .input_configured = rmi_input_configured, 765 #ifdef CONFIG_PM 766 .suspend = rmi_suspend, 767 .resume = rmi_post_resume, 768 .reset_resume = rmi_post_resume, 769 #endif 770 }; 771 772 module_hid_driver(rmi_driver); 773 774 MODULE_AUTHOR("Andrew Duggan <aduggan@synaptics.com>"); 775 MODULE_DESCRIPTION("RMI HID driver"); 776 MODULE_LICENSE("GPL"); 777