Commit 6a9ddc8978835deae0b2d918df74fc83588a4104
Committed by
Jiri Kosina
1 parent
33797820af
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
HID: logitech-dj: enable notifications on connect/disconnect
The receiver can send HID++ notifications to the DJ devices when the physical devices are connected/disconnected. Enable this feature by default. This command uses a HID++ command instead of a DJ one, so use a direct call to usbhid instead of using logi_dj_recv_send_report() Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Tested-by: Andrew de los Reyes <adlr@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Showing 1 changed file with 26 additions and 1 deletions Side-by-side Diff
drivers/hid/hid-logitech-dj.c
... | ... | @@ -630,7 +630,9 @@ |
630 | 630 | static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev, |
631 | 631 | unsigned timeout) |
632 | 632 | { |
633 | + struct hid_device *hdev = djrcv_dev->hdev; | |
633 | 634 | struct dj_report *dj_report; |
635 | + u8 *buf; | |
634 | 636 | int retval; |
635 | 637 | |
636 | 638 | dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL); |
... | ... | @@ -642,7 +644,6 @@ |
642 | 644 | dj_report->report_params[CMD_SWITCH_PARAM_DEVBITFIELD] = 0x3F; |
643 | 645 | dj_report->report_params[CMD_SWITCH_PARAM_TIMEOUT_SECONDS] = (u8)timeout; |
644 | 646 | retval = logi_dj_recv_send_report(djrcv_dev, dj_report); |
645 | - kfree(dj_report); | |
646 | 647 | |
647 | 648 | /* |
648 | 649 | * Ugly sleep to work around a USB 3.0 bug when the receiver is still |
... | ... | @@ -651,6 +652,30 @@ |
651 | 652 | */ |
652 | 653 | msleep(50); |
653 | 654 | |
655 | + /* | |
656 | + * Magical bits to set up hidpp notifications when the dj devices | |
657 | + * are connected/disconnected. | |
658 | + * | |
659 | + * We can reuse dj_report because HIDPP_REPORT_SHORT_LENGTH is smaller | |
660 | + * than DJREPORT_SHORT_LENGTH. | |
661 | + */ | |
662 | + buf = (u8 *)dj_report; | |
663 | + | |
664 | + memset(buf, 0, HIDPP_REPORT_SHORT_LENGTH); | |
665 | + | |
666 | + buf[0] = REPORT_ID_HIDPP_SHORT; | |
667 | + buf[1] = 0xFF; | |
668 | + buf[2] = 0x80; | |
669 | + buf[3] = 0x00; | |
670 | + buf[4] = 0x00; | |
671 | + buf[5] = 0x09; | |
672 | + buf[6] = 0x00; | |
673 | + | |
674 | + hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf, | |
675 | + HIDPP_REPORT_SHORT_LENGTH, HID_OUTPUT_REPORT, | |
676 | + HID_REQ_SET_REPORT); | |
677 | + | |
678 | + kfree(dj_report); | |
654 | 679 | return retval; |
655 | 680 | } |
656 | 681 |