Skip to content

Commit 6a9ddc8

Browse files
bentissJiri Kosina
authored andcommitted
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 <[email protected]> Tested-by: Andrew de los Reyes <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 3379782 commit 6a9ddc8

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/hid/hid-logitech-dj.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,9 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
630630
static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
631631
unsigned timeout)
632632
{
633+
struct hid_device *hdev = djrcv_dev->hdev;
633634
struct dj_report *dj_report;
635+
u8 *buf;
634636
int retval;
635637

636638
dj_report = kzalloc(sizeof(struct dj_report), GFP_KERNEL);
@@ -642,7 +644,6 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
642644
dj_report->report_params[CMD_SWITCH_PARAM_DEVBITFIELD] = 0x3F;
643645
dj_report->report_params[CMD_SWITCH_PARAM_TIMEOUT_SECONDS] = (u8)timeout;
644646
retval = logi_dj_recv_send_report(djrcv_dev, dj_report);
645-
kfree(dj_report);
646647

647648
/*
648649
* Ugly sleep to work around a USB 3.0 bug when the receiver is still
@@ -651,6 +652,30 @@ static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
651652
*/
652653
msleep(50);
653654

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);
654679
return retval;
655680
}
656681

0 commit comments

Comments
 (0)