From patchwork Wed Dec 5 00:42:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Hutterer X-Patchwork-Id: 10712847 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B57E71731 for ; Wed, 5 Dec 2018 00:43:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A412C2CA49 for ; Wed, 5 Dec 2018 00:43:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 985CF2CA62; Wed, 5 Dec 2018 00:43:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 283022CA49 for ; Wed, 5 Dec 2018 00:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbeLEAnM (ORCPT ); Tue, 4 Dec 2018 19:43:12 -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 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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