All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Hutterer <peter.hutterer@who-t.net>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jiri Kosina <jikos@kernel.org>, Harry Cutts <hcutts@chromium.org>,
	torvalds@linux-foundation.org,
	Nestor Lopez Casado <nlopezcasad@logitech.com>,
	linux-kernel@vger.kernel.org,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: [PATCH v3 6/8] HID: logitech: Add function to enable HID++ 1.0 "scrolling acceleration"
Date: Wed,  5 Dec 2018 10:42:26 +1000	[thread overview]
Message-ID: <20181205004228.10714-7-peter.hutterer@who-t.net> (raw)
In-Reply-To: <20181205004228.10714-1-peter.hutterer@who-t.net>

From: Harry Cutts <hcutts@chromium.org>

"Scrolling acceleration" is a bit of a misnomer: it doesn't deal with
acceleration at all. However, that's the name used in Logitech's spec,
so I used it here.

Signed-off-by: Harry Cutts <hcutts@chromium.org>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
Unchanged since v1

 drivers/hid/hid-logitech-hidpp.c | 47 +++++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 22b37a3844d1..95ba9db6e613 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -400,32 +400,53 @@ static void hidpp_prefix_name(char **name, int name_length)
 #define HIDPP_SET_LONG_REGISTER				0x82
 #define HIDPP_GET_LONG_REGISTER				0x83
 
-#define HIDPP_REG_GENERAL				0x00
-
-static int hidpp10_enable_battery_reporting(struct hidpp_device *hidpp_dev)
+/**
+ * hidpp10_set_register_bit() - Sets a single bit in a HID++ 1.0 register.
+ * @hidpp_dev: the device to set the register on.
+ * @register_address: the address of the register to modify.
+ * @byte: the byte of the register to modify. Should be less than 3.
+ * Return: 0 if successful, otherwise a negative error code.
+ */
+static int hidpp10_set_register_bit(struct hidpp_device *hidpp_dev,
+	u8 register_address, u8 byte, u8 bit)
 {
 	struct hidpp_report response;
 	int ret;
 	u8 params[3] = { 0 };
 
 	ret = hidpp_send_rap_command_sync(hidpp_dev,
-					REPORT_ID_HIDPP_SHORT,
-					HIDPP_GET_REGISTER,
-					HIDPP_REG_GENERAL,
-					NULL, 0, &response);
+					  REPORT_ID_HIDPP_SHORT,
+					  HIDPP_GET_REGISTER,
+					  register_address,
+					  NULL, 0, &response);
 	if (ret)
 		return ret;
 
 	memcpy(params, response.rap.params, 3);
 
-	/* Set the battery bit */
-	params[0] |= BIT(4);
+	params[byte] |= BIT(bit);
 
 	return hidpp_send_rap_command_sync(hidpp_dev,
-					REPORT_ID_HIDPP_SHORT,
-					HIDPP_SET_REGISTER,
-					HIDPP_REG_GENERAL,
-					params, 3, &response);
+					   REPORT_ID_HIDPP_SHORT,
+					   HIDPP_SET_REGISTER,
+					   register_address,
+					   params, 3, &response);
+}
+
+
+#define HIDPP_REG_GENERAL				0x00
+
+static int hidpp10_enable_battery_reporting(struct hidpp_device *hidpp_dev)
+{
+	return hidpp10_set_register_bit(hidpp_dev, HIDPP_REG_GENERAL, 0, 4);
+}
+
+#define HIDPP_REG_FEATURES				0x01
+
+/* On HID++ 1.0 devices, high-res scroll was called "scrolling acceleration". */
+static int hidpp10_enable_scrolling_acceleration(struct hidpp_device *hidpp_dev)
+{
+	return hidpp10_set_register_bit(hidpp_dev, HIDPP_REG_FEATURES, 0, 6);
 }
 
 #define HIDPP_REG_BATTERY_STATUS			0x07
-- 
2.19.2


  parent reply	other threads:[~2018-12-05  0:43 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05  0:42 [PATCH v3 0/8] HID: MS and Logitech high-resolution scroll wheel support Peter Hutterer
2018-12-05  0:42 ` [PATCH v3 1/8] Input: add `REL_WHEEL_HI_RES` and `REL_HWHEEL_HI_RES` Peter Hutterer
2018-12-06 22:56   ` Dmitry Torokhov
2018-12-05  0:42 ` [PATCH v3 2/8] HID: core: store the collections as a basic tree Peter Hutterer
2018-12-05  0:42 ` [PATCH v3 3/8] HID: core: process the Resolution Multiplier Peter Hutterer
2018-12-05  0:42 ` [PATCH v3 4/8] HID: input: use the Resolution Multiplier for high-resolution scrolling Peter Hutterer
2018-12-05  0:42 ` [PATCH v3 5/8] HID: logitech-hidpp: fix typo, hiddpp to hidpp Peter Hutterer
2018-12-05  0:42 ` Peter Hutterer [this message]
2018-12-05  0:42 ` [PATCH v3 7/8] HID: logitech: Enable high-resolution scrolling on Logitech mice Peter Hutterer
2018-12-05 21:52   ` Harry Cutts
2018-12-14 13:46   ` Clément VUCHENER
2018-12-14 18:37     ` Harry Cutts
2018-12-15 14:45       ` Clément VUCHENER
2018-12-19 10:57         ` Clément VUCHENER
2018-12-19 20:34           ` Benjamin Tissoires
2019-04-24 15:34             ` Clément VUCHENER
2019-04-25  7:40               ` Benjamin Tissoires
2019-04-25  8:24                 ` Clément VUCHENER
2019-04-25  8:45                   ` Benjamin Tissoires
2019-04-25  9:28                     ` Clément VUCHENER
2019-04-25  9:35                       ` Benjamin Tissoires
2019-04-25 12:35                         ` Clément VUCHENER
2018-12-05  0:42 ` [PATCH v3 8/8] HID: logitech: Use LDJ_DEVICE macro for existing " Peter Hutterer
2018-12-05 21:56 ` [PATCH v3 0/8] HID: MS and Logitech high-resolution scroll wheel support Harry Cutts
2018-12-07 16:18   ` 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=20181205004228.10714-7-peter.hutterer@who-t.net \
    --to=peter.hutterer@who-t.net \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hcutts@chromium.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nlopezcasad@logitech.com \
    --cc=torvalds@linux-foundation.org \
    /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.