All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Wood <simon@mungewell.org>
To: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, "Jiri Kosina" <jkosina@suse.cz>,
	Edwin <Edwin@Velds.nl>,
	"Michal Malý" <madcatxster@devoid-pointer.net>,
	"elias vanderstuyft" <elias.vds@gmail.com>,
	"Benjamin Tissoires" <benjamin.tissoires@redhat.com>,
	"Simon Wood" <simon@mungewell.org>
Subject: [Patch-V2 2/6] HID: hid-logitech-hidpp: Add support for very long packets
Date: Thu, 12 Nov 2015 09:25:31 -0700	[thread overview]
Message-ID: <1447345535-2912-3-git-send-email-simon@mungewell.org> (raw)
In-Reply-To: <1447345535-2912-1-git-send-email-simon@mungewell.org>

Patch add support for the 'very long' HID++ packets, which are
64 bytes in length.

Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/hid/hid-logitech-hidpp.c | 59 ++++++++++++++++++++++++++++++++--------
 1 file changed, 48 insertions(+), 11 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 5fd9786..0f53dc8 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -40,9 +40,11 @@ MODULE_PARM_DESC(disable_tap_to_click,
 
 #define REPORT_ID_HIDPP_SHORT			0x10
 #define REPORT_ID_HIDPP_LONG			0x11
+#define REPORT_ID_HIDPP_VERY_LONG		0x12
 
 #define HIDPP_REPORT_SHORT_LENGTH		7
 #define HIDPP_REPORT_LONG_LENGTH		20
+#define HIDPP_REPORT_VERY_LONG_LENGTH		64
 
 #define HIDPP_QUIRK_CLASS_WTP			BIT(0)
 #define HIDPP_QUIRK_CLASS_M560			BIT(1)
@@ -81,13 +83,13 @@ MODULE_PARM_DESC(disable_tap_to_click,
 struct fap {
 	u8 feature_index;
 	u8 funcindex_clientid;
-	u8 params[HIDPP_REPORT_LONG_LENGTH - 4U];
+	u8 params[HIDPP_REPORT_VERY_LONG_LENGTH - 4U];
 };
 
 struct rap {
 	u8 sub_id;
 	u8 reg_address;
-	u8 params[HIDPP_REPORT_LONG_LENGTH - 4U];
+	u8 params[HIDPP_REPORT_VERY_LONG_LENGTH - 4U];
 };
 
 struct hidpp_report {
@@ -153,6 +155,9 @@ static int __hidpp_send_report(struct hid_device *hdev,
 	case REPORT_ID_HIDPP_LONG:
 		fields_count = HIDPP_REPORT_LONG_LENGTH;
 		break;
+	case REPORT_ID_HIDPP_VERY_LONG:
+		fields_count = HIDPP_REPORT_VERY_LONG_LENGTH;
+		break;
 	default:
 		return -ENODEV;
 	}
@@ -217,8 +222,9 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
 		goto exit;
 	}
 
-	if (response->report_id == REPORT_ID_HIDPP_LONG &&
-	    response->fap.feature_index == HIDPP20_ERROR) {
+	if ((response->report_id == REPORT_ID_HIDPP_LONG ||
+			response->report_id == REPORT_ID_HIDPP_VERY_LONG) &&
+			response->fap.feature_index == HIDPP20_ERROR) {
 		ret = response->fap.params[1];
 		dbg_hid("%s:got hidpp 2.0 error %02X\n", __func__, ret);
 		goto exit;
@@ -243,7 +249,11 @@ static int hidpp_send_fap_command_sync(struct hidpp_device *hidpp,
 	message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL);
 	if (!message)
 		return -ENOMEM;
-	message->report_id = REPORT_ID_HIDPP_LONG;
+
+	if (param_count > (HIDPP_REPORT_LONG_LENGTH - 4))
+		message->report_id = REPORT_ID_HIDPP_VERY_LONG;
+	else
+		message->report_id = REPORT_ID_HIDPP_LONG;
 	message->fap.feature_index = feat_index;
 	message->fap.funcindex_clientid = funcindex_clientid;
 	memcpy(&message->fap.params, params, param_count);
@@ -258,13 +268,23 @@ static int hidpp_send_rap_command_sync(struct hidpp_device *hidpp_dev,
 	struct hidpp_report *response)
 {
 	struct hidpp_report *message;
-	int ret;
+	int ret, max_count;
 
-	if ((report_id != REPORT_ID_HIDPP_SHORT) &&
-	    (report_id != REPORT_ID_HIDPP_LONG))
+	switch (report_id) {
+	case REPORT_ID_HIDPP_SHORT:
+		max_count = HIDPP_REPORT_SHORT_LENGTH - 4;
+		break;
+	case REPORT_ID_HIDPP_LONG:
+		max_count = HIDPP_REPORT_LONG_LENGTH - 4;
+		break;
+	case REPORT_ID_HIDPP_VERY_LONG:
+		max_count = HIDPP_REPORT_VERY_LONG_LENGTH - 4;
+		break;
+	default:
 		return -EINVAL;
+	}
 
-	if (param_count > sizeof(message->rap.params))
+	if (param_count > max_count)
 		return -EINVAL;
 
 	message = kzalloc(sizeof(struct hidpp_report), GFP_KERNEL);
@@ -508,10 +528,19 @@ static int hidpp_devicenametype_get_device_name(struct hidpp_device *hidpp,
 	if (ret)
 		return ret;
 
-	if (response.report_id == REPORT_ID_HIDPP_LONG)
+	switch (response.report_id) {
+	case REPORT_ID_HIDPP_VERY_LONG:
+		count = HIDPP_REPORT_VERY_LONG_LENGTH - 4;
+		break;
+	case REPORT_ID_HIDPP_LONG:
 		count = HIDPP_REPORT_LONG_LENGTH - 4;
-	else
+		break;
+	case REPORT_ID_HIDPP_SHORT:
 		count = HIDPP_REPORT_SHORT_LENGTH - 4;
+		break;
+	default:
+		return -EPROTO;
+	}
 
 	if (len_buf < count)
 		count = len_buf;
@@ -1347,6 +1376,14 @@ static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report,
 
 	/* Generic HID++ processing. */
 	switch (data[0]) {
+	case REPORT_ID_HIDPP_VERY_LONG:
+		if (size != HIDPP_REPORT_VERY_LONG_LENGTH) {
+			hid_err(hdev, "received hid++ report of bad size (%d)",
+				size);
+			return 1;
+		}
+		ret = hidpp_raw_hidpp_event(hidpp, data, size);
+		break;
 	case REPORT_ID_HIDPP_LONG:
 		if (size != HIDPP_REPORT_LONG_LENGTH) {
 			hid_err(hdev, "received hid++ report of bad size (%d)",
-- 
2.1.4


  parent reply	other threads:[~2015-11-12 16:25 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 16:25 [Patch-V2 0/6] HID: Support for the Logitech G920 Wheel Simon Wood
2015-11-12 16:25 ` [Patch-V2 1/6] INPUT: xpad: Add minimal support for " Simon Wood
2015-11-19 13:50   ` Jiri Kosina
2015-11-19 18:31     ` Dmitry Torokhov
2015-11-19 18:35       ` Simon Wood
2015-11-19 23:19         ` Edwin
2015-12-10  1:23       ` Dmitry Torokhov
2015-12-10  1:39         ` Dmitry Torokhov
2015-12-10 17:08           ` Benjamin Tissoires
2015-12-10 18:40             ` Dmitry Torokhov
2016-01-04  9:55               ` Benjamin Tissoires
2016-01-04 12:43                 ` madcatxster
2016-01-04 12:43                   ` madcatxster
     [not found]                 ` <568ad0ae.ea3d320a.6acab.2b84SMTPIN_ADDED_MISSING@mx.google.com>
2016-01-05  1:01                   ` Dmitry Torokhov
2016-01-06 14:36                 ` Jiri Kosina
2016-01-07  1:47                   ` Dmitry Torokhov
2016-01-07  4:25                     ` Simon Wood
2016-01-07 22:50                     ` Michal Malý
2016-01-07 22:53                       ` Dmitry Torokhov
2016-01-07 22:53                         ` Dmitry Torokhov
2016-01-07 23:05                         ` Michal Malý
2016-01-07 23:05                           ` Michal Malý
2016-01-08  9:11                     ` Jiri Kosina
2015-12-13 12:50             ` Elias Vanderstuyft
2015-11-12 16:25 ` Simon Wood [this message]
2015-11-12 16:25 ` [Patch-V2 3/6] HID: hid-logitech-hidpp: Add basic support for Logitech G920 Simon Wood
2015-11-19 11:18   ` Benjamin Tissoires
2015-11-12 16:25 ` [Patch-V2 4/6] HID: hid-logitech-hidpp: Add range sysfs " Simon Wood
2015-11-12 16:25 ` [Patch-V2 5/6] HID: Add vendor specific usage pages " Simon Wood
2015-11-12 16:25 ` [Patch-V2 6/6] HID: hid-logitech-hidpp: G920 remove deadzones Simon Wood
2015-11-12 16:32 ` [Patch-V2 0/6] HID: Support for the Logitech G920 Wheel Simon Wood
2015-11-19 10:04 ` Jiri Kosina
2015-11-19 11:23   ` 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=1447345535-2912-3-git-send-email-simon@mungewell.org \
    --to=simon@mungewell.org \
    --cc=Edwin@Velds.nl \
    --cc=benjamin.tissoires@redhat.com \
    --cc=elias.vds@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madcatxster@devoid-pointer.net \
    --subject='Re: [Patch-V2 2/6] HID: hid-logitech-hidpp: Add support for very long packets' \
    /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

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.