All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Benjamin Tissoires <benjamin.tissoires@gmail.com>,
	Jiri Kosina <jkosina@suse.cz>,
	Nestor Lopez Casado <nlopezcasad@logitech.com>,
	Andrew de los Reyes <adlr@chromium.org>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/5] HID: logitech-dj: add .request callback
Date: Wed,  8 Jan 2014 17:18:49 -0500	[thread overview]
Message-ID: <1389219529-29671-6-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1389219529-29671-1-git-send-email-benjamin.tissoires@redhat.com>

From: Benjamin Tisssoires <benjamin.tissoires@redhat.com>

The .request callback allows to send data from the dj device driver to the
device. Because of the DJ protocol, we only authorize HID++ communication
through this request.

The device index has to be overwritten by the receiver. All communication pass
through it, and the receiver is the only one to know which dj device has which
device index.
Furthermore, this allows to use the same calls from the driver point of view:
if a device is connected through a DJ interface, the receiver will overwrite
the device index, if it is connected through another bus (like bluetooth),
then the transport layer will not change the report, and it will be correctly
forwarded to the device.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/hid-logitech-dj.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 3444feb..4335d21 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -624,6 +624,22 @@ static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf,
 	return 0;
 }
 
+static void logi_dj_ll_request(struct hid_device *hid, struct hid_report *rep,
+		int reqtype)
+{
+	struct dj_device *djdev = hid->driver_data;
+	struct dj_receiver_dev *djrcv_dev = djdev->dj_receiver_dev;
+
+	if ((rep->id != REPORT_ID_HIDPP_LONG) &&
+	    (rep->id != REPORT_ID_HIDPP_SHORT))
+		/* prevent forwarding of non acceptable reports */
+		return;
+
+	hid_set_field(rep->field[0], 0, djdev->device_index);
+
+	hid_hw_request(djrcv_dev->hdev, rep, reqtype);
+}
+
 static void rdcat(char *rdesc, unsigned int *rsize, const char *data, unsigned int size)
 {
 	memcpy(rdesc + *rsize, data, size);
@@ -759,6 +775,7 @@ static struct hid_ll_driver logi_dj_ll_driver = {
 	.stop = logi_dj_ll_stop,
 	.open = logi_dj_ll_open,
 	.close = logi_dj_ll_close,
+	.request = logi_dj_ll_request,
 	.hidinput_input_event = logi_dj_ll_input_event,
 };
 
-- 
1.8.4.2


  parent reply	other threads:[~2014-01-08 22:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08 22:18 [PATCH 0/5] HID logitech DJ fixes and preps for enabling extended features Benjamin Tissoires
2014-01-08 22:18 ` [PATCH 1/5] HID: logitech-dj: Fix USB 3.0 issue Benjamin Tissoires
2014-01-16 21:50   ` Jiri Kosina
2014-01-17  8:48     ` Nestor Lopez Casado
     [not found]       ` <CAE7qMrpEnF3y-dVP14190y33YNidCdjtJeO9PcMVcBBJDJsYuw@mail.gmail.com>
2014-02-14 13:35         ` Nestor Lopez Casado
2014-01-08 22:18 ` [PATCH 2/5] HID: core: do not scan reports if the group is already set Benjamin Tissoires
2014-01-08 22:18 ` [PATCH 3/5] HID: logitech-dj: rely on hid groups to separate receivers from dj devices Benjamin Tissoires
2014-01-08 22:18 ` [PATCH 4/5] HID: logitech-dj: forward incoming HID++ reports to the correct dj device Benjamin Tissoires
2014-01-08 22:18 ` Benjamin Tissoires [this message]
2014-01-09 21:08 ` [PATCH 0/5] HID logitech DJ fixes and preps for enabling extended features Andrew de los Reyes
2014-01-09 21:22   ` Benjamin Tissoires
2014-01-29 18:21     ` Andrew de los Reyes
2014-01-29 18:42       ` 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=1389219529-29671-6-git-send-email-benjamin.tissoires@redhat.com \
    --to=benjamin.tissoires@redhat.com \
    --cc=adlr@chromium.org \
    --cc=benjamin.tissoires@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.