Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8902923imu; Tue, 4 Dec 2018 16:44:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/WnnCeN4bV5pgK2JM3VI8hmGP6iHIzh2NLwg+cbm2XZndzG7RkjlRrsysKA+tVnVB1aJwLG X-Received: by 2002:a17:902:7896:: with SMTP id q22mr22416902pll.280.1543970655546; Tue, 04 Dec 2018 16:44:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543970655; cv=none; d=google.com; s=arc-20160816; b=AIxWfIzuYeWifptApBCk4Q/qGVAQXkldlv1J3Fpjm4lp6BXWMClw8A8+Bu1iWFE/wZ gIzLY7FdSZ7/7NopkmhtqTgYZYs5SWABgrxKAmx0a+eCqcTovliLDfqtNOh/yBZcJkTV x9XxU07krlFmhAavoAyCntM/M3TFmnILM7N3H1HGHfZo4UDYPgKYEw+yVaI1yu4vKXZH xw9MnAfiU8+8/Yu4faC0YGN8u5a5bOiFcwwp01PZuVYC11oLr2UoCAJmQh7+HewZDC/0 oQGLmo7I9B1Gfchc+RALJLdcCpSe0J+isDXyG3R7KpmV31RMGwvlzGyR0Zc08BR/j5Rg JMYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=k0wpaOF+B4pJSqXa2tG5vClg3F+LRFCjDb4ghPCqbbY=; b=MAKGdFiUSjTDiMUZpRwP6dkeVzBlinrkEB6Djn6LQQ0o9J9aSjRelaRRFO/eSZhjhL Mqq30QBG2Heb/Jf6NCzO6VHYSCRkhKcOOxQ6Wu6X/c/f4HyF1Ylqau6afDDnIC5dLc+5 u02QNU/sDlfD9FdaFbSZyf0+fkuZ7lBocnCdXBtc1kLHU5SGKDpOFefGK4+w0kS9K+cq MCxGNkNJTeXD7aSYcZoL+ZTAcqXNx+sP3wPnjuKo2iM5LTQKqN8dszONBbfZS4RFAgV4 anG/I95Otmjn9eNVpJTUp2V0cG4rviAXtaw72/DIG7Q68/NcdqlmMzM5W1N4njJEIrGA F6Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@who-t.net header.s=fm1 header.b=gn5eGRno; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=UvPqHrpm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si19564179pfm.37.2018.12.04.16.44.00; Tue, 04 Dec 2018 16:44:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@who-t.net header.s=fm1 header.b=gn5eGRno; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=UvPqHrpm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726850AbeLEAnN (ORCPT + 99 others); Tue, 4 Dec 2018 19:43:13 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:60697 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbeLEAnL (ORCPT ); Tue, 4 Dec 2018 19:43:11 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id EFE7EEF3; Tue, 4 Dec 2018 19:43:09 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 04 Dec 2018 19:43:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=who-t.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=k0wpaOF+B4pJS qXa2tG5vClg3F+LRFCjDb4ghPCqbbY=; b=gn5eGRnoSGNLJ57Ek4X53SfBDtGku qf5Omy7o6wyJOZTvBce8Tt0Sm9Hylbj5/XCSFQwQZwbNNajuqIYfmmjB2fhDiRSC fSOnrWAfmFRpwobPVQYdbzh215RXl4tPTRHpD+iC5RSii/6BwL8kFlkJ1e7tso3w 1BSa880POVHiF1ewRzgn20gJukFtd7ka7sAw80oR3ZhPNOTIDOPG8eB4s/lURRXz HKlgOQHkXEYo4iqH3OK69JZk3vm3XTvAxUs72XzmMvs5kbRtKTVY2vewXOIzglbR vQw7aYHRC9sGT4/+EuYNni9eRCWYNyUkN1G09TJXbl8p9Ic2n/650BZsQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=k0wpaOF+B4pJSqXa2tG5vClg3F+LRFCjDb4ghPCqbbY=; b=UvPqHrpm rv5W2RO1CoWUY+Q4x0wPg3JUR9hsEMAdQ488bFJlPUKgXEPkg85lZJoPlStksU0D Ya7dkKWOMurO3iPGMrU+pLr2iHHyulcKdvclX3Q0VPrSeBMU58DFcpZMfjm1ixuL L3dqOJnvu7g8dcXRoVb7Yfw0pl9rXWgYjyQB6xKd+0GxMVl8UMkbYi6LqH9XinGb jGITQc5/a8IzICpMB1hZIc1sEJjKMFgt5c+bNVY7Pg7nPeFpjpjE6u2igccph7gV BX1xCLg7XwDmAsuHESUA1IQcHWIzBWY7MpnRmDq8AxawRNiQJBAMU0yUDsPTDDu/ TwUbdQXzcjFYSw== X-ME-Sender: X-ME-Proxy: Received: from jelly.home.gateway (167-179-166-29.a7b3a6.bne.nbn.aussiebb.net [167.179.166.29]) by mail.messagingengine.com (Postfix) with ESMTPA id 8EC8AE49CB; Tue, 4 Dec 2018 19:43:06 -0500 (EST) From: Peter Hutterer To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Jiri Kosina , Harry Cutts , torvalds@linux-foundation.org, Nestor Lopez Casado , linux-kernel@vger.kernel.org, Benjamin Tissoires 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 Message-Id: <20181205004228.10714-7-peter.hutterer@who-t.net> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205004228.10714-1-peter.hutterer@who-t.net> References: <20181205004228.10714-1-peter.hutterer@who-t.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Harry Cutts "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 Reviewed-by: Benjamin Tissoires Signed-off-by: Peter Hutterer --- 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