linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Jiri Kosina <jkosina@suse.cz>,
	Nestor Lopez Casado <nlopezcasad@logitech.com>,
	Andrew de los Reyes <andrew-vger@gizmolabs.org>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: [PATCH 09/13] HID: logitech-dj: enable notifications on connect/disconnect
Date: Tue, 30 Sep 2014 13:18:31 -0400	[thread overview]
Message-ID: <1412097515-17241-10-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1412097515-17241-1-git-send-email-benjamin.tissoires@redhat.com>

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>
---
 drivers/hid/hid-logitech-dj.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 9bc3942..c917ab6 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -630,7 +630,9 @@ static int logi_dj_recv_query_paired_devices(struct dj_receiver_dev *djrcv_dev)
 static int logi_dj_recv_switch_to_dj_mode(struct dj_receiver_dev *djrcv_dev,
 					  unsigned timeout)
 {
+	struct hid_device *hdev = djrcv_dev->hdev;
 	struct dj_report *dj_report;
+	u8 *buf;
 	int retval;
 
 	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,
 	dj_report->report_params[CMD_SWITCH_PARAM_DEVBITFIELD] = 0x3F;
 	dj_report->report_params[CMD_SWITCH_PARAM_TIMEOUT_SECONDS] = (u8)timeout;
 	retval = logi_dj_recv_send_report(djrcv_dev, dj_report);
-	kfree(dj_report);
 
 	/*
 	 * 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,
 	 */
 	msleep(50);
 
+	/*
+	 * Magical bits to set up hidpp notifications when the dj devices
+	 * are connected/disconnected.
+	 *
+	 * We can reuse dj_report because HIDPP_REPORT_SHORT_LENGTH is smaller
+	 * than DJREPORT_SHORT_LENGTH.
+	 */
+	buf = (u8 *)dj_report;
+
+	memset(buf, 0, HIDPP_REPORT_SHORT_LENGTH);
+
+	buf[0] = REPORT_ID_HIDPP_SHORT;
+	buf[1] = 0xFF;
+	buf[2] = 0x80;
+	buf[3] = 0x00;
+	buf[4] = 0x00;
+	buf[5] = 0x09;
+	buf[6] = 0x00;
+
+	hid_hw_raw_request(hdev, REPORT_ID_HIDPP_SHORT, buf,
+			HIDPP_REPORT_SHORT_LENGTH, HID_OUTPUT_REPORT,
+			HID_REQ_SET_REPORT);
+
+	kfree(dj_report);
 	return retval;
 }
 
-- 
2.1.0

  parent reply	other threads:[~2014-09-30 17:18 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30 17:18 [PATCH 00/13] HID: add support of Logitech touchpads and special devices Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 01/13] HID: fix merge from wacom into the HID tree Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 02/13] HID: core: do not scan reports if the group is already set Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 03/13] HID: logitech-dj: rely on hid groups to separate receivers from dj devices Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 04/13] HID: logitech-dj: merge header file into the source Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 05/13] HID: Introduce hidpp, a module to handle Logitech hid++ devices Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 06/13] HID: logitech: move dj devices to the HID++ module Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 07/13] HID: logitech-dj: allow transfer of HID++ reports from/to the correct dj device Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 08/13] HID: logitech: allow the DJ device to request the unifying name Benjamin Tissoires
2014-09-30 17:18 ` Benjamin Tissoires [this message]
2014-09-30 17:18 ` [PATCH 10/13] HID: logitech-hidpp: late bind the input device on wireless connection Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 11/13] HID: logitech-hidpp: Add Wireless Touchpad T650 support Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 12/13] HID: logitech-hidpp: add support of the first Logitech Wireless Touchpad Benjamin Tissoires
2014-09-30 17:18 ` [PATCH 13/13] HID: logitech-hidpp: support combo keyboard touchpad TK820 Benjamin Tissoires
2014-10-01  8:17 ` [PATCH 00/13] HID: add support of Logitech touchpads and special devices Jiri Kosina
2014-10-01 13:10   ` Benjamin Tissoires
2014-10-02 18:19     ` Andrew de los Reyes
2014-10-03 11:09       ` Jiri Kosina
2014-10-03 14:44         ` Andrew de los Reyes
2014-10-28 20:05         ` Benjamin Tissoires
2014-10-29  9:49           ` Jiri Kosina
2014-10-29 14:41             ` Benjamin Tissoires
2014-10-29 16:14               ` Jiri Kosina
2014-10-29 18:14                 ` Benjamin Tissoires

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1412097515-17241-10-git-send-email-benjamin.tissoires@redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=andrew-vger@gizmolabs.org \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nlopezcasad@logitech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).