Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp33720imm; Thu, 30 Aug 2018 14:58:39 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbb+Zqz4RalGZF6QpCnq/wzZlx+7qgt83QvkDyLvKQHtOhg47ySrP6I+3nZbQO5aAEAgzqw X-Received: by 2002:a63:4e25:: with SMTP id c37-v6mr11442775pgb.6.1535666319482; Thu, 30 Aug 2018 14:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535666319; cv=none; d=google.com; s=arc-20160816; b=NU/i9VPfTeooPAQsfu6IOL0BysewD1kosoa6+OFyPHT/sUaE8gJRj7B8ATZNK+ByuG BihEC9sc5Txvbmvca65vRW8Nv6U+bythirN2K9z2QFWPwYbjdrN2aAFqAmocQs1wZAUr 7hcmotDMW2+0HwA5YTHzutufjhag7BmR1U3fHarrR4v8iSVL0/K0BR4x7ylA7cBRUcou FHidtg6s5oBRh855Z6/MuJtYTWVv75hPRv/Q/SfMntaFPpuTI+nqttZ+9KGDkXW2RLQu RlGXzdrxaiJ+QhouiYA2BQADv7ZI6Rx572LRB/ME4ynL+o2qIAxh77qeKvGih5+40/KA 0vzg== 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:arc-authentication-results; bh=tK2RoHy+bNp5WpzedluyMhr/Pjp/ubfWGOtvCPwzdM8=; b=zz5u/aNHaDJidyPHw43aw9FhyR5+xwS1DdH4YamS82oibstZ+ZR8GoT3satcX4Vams ay22iRVV/ZtpX8N3qkUViQY30irK817NCIhx6PIvPhf51zVFDkFoO21X7EY35JxvLtR+ 0BmiHrvKiqBvs1lIQ0nPx5rnO+nZrrQuIQoy5g2V6cuGmchdA+5tku7PsI7JrYXoj/4s WDxPbRBg1sxa0YULQmPa2VDXSw0F9whLONC6r/Jo4p1IdA/EvpoNhdPGhjsyQzcZMDlT TmwRh/oPq40a/46q2Epp89S+OAVm/nSAV1eqL17G77Le1xZSoyU7MJo/E7AkLJbc1M6M yCJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JaMcNExf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9-v6si7575275pgg.622.2018.08.30.14.58.25; Thu, 30 Aug 2018 14:58:39 -0700 (PDT) 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=@chromium.org header.s=google header.b=JaMcNExf; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbeHaCAr (ORCPT + 99 others); Thu, 30 Aug 2018 22:00:47 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40884 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727980AbeHaCAq (ORCPT ); Thu, 30 Aug 2018 22:00:46 -0400 Received: by mail-pg1-f193.google.com with SMTP id a13-v6so1788210pgt.7 for ; Thu, 30 Aug 2018 14:56:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tK2RoHy+bNp5WpzedluyMhr/Pjp/ubfWGOtvCPwzdM8=; b=JaMcNExfzR3a3B5/j6veY2KNZfQQzGlsQC+edr+oSGklZafSKaQDbcH/Q2d1hBFpai YThbyNgIgqkSTh5f6gtNkePh7l8Z5nlZ20niM49ZWgBiINgaYyXvsi8SNNs9wgdbR6zQ bKHdl5g77z67mynTFoTdxPug0m6Y/8TbrpmQA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tK2RoHy+bNp5WpzedluyMhr/Pjp/ubfWGOtvCPwzdM8=; b=ICNEUWfZX7dWanhs2ihZjJz+UR3ClIl7aln3ph6hf/b/9tMRTxKqM/0/FbbcsiNvzU dnaHTIKIoaJt0l5f73hYHG3ImkIZd0VpupPnNtQOT1A2ma9o7Od0h3aBROiuOAybmkuU HmyoeLP793VtE283AbDczddCIiGD5r86+iXjLoehKSLmcg9EHm4r82mfICIzxS3KMWHA BN/jA36BtIdKRSsjLPKr/S2Fm8nDNQ1mDHkbfUxzWLA/G5zan0Td8311ij6rqJf5O2m1 eiINZVadco7QOYehdrOUxN/XmHUI/LDNTyTPOlhzBjiDyKO07WpOOZ2NdKzNMe/7dysr 0zOQ== X-Gm-Message-State: APzg51AEYmU5ZogFnB/H7zNRipI4Il5a1M+B30IOOkWxzDi/YdAF++MT yZFZaDVaTE6R0iC/p9BB+xjkCQ== X-Received: by 2002:a62:4e56:: with SMTP id c83-v6mr12618749pfb.240.1535666190411; Thu, 30 Aug 2018 14:56:30 -0700 (PDT) Received: from kolhar.mtv.corp.google.com ([2620:15c:202:201:356a:9de2:526a:5bc]) by smtp.gmail.com with ESMTPSA id h132-v6sm13516828pfc.100.2018.08.30.14.56.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 14:56:29 -0700 (PDT) From: Harry Cutts To: linux-input , LKML Cc: Jiri Kosina , Dmitry Torokhov , Benjamin Tissoires , Harry Cutts , Jiri Kosina Subject: [PATCH v2 3/5] Add function to enable HID++ 1.0 "scrolling acceleration" Date: Thu, 30 Aug 2018 14:56:20 -0700 Message-Id: <20180830215622.47550-4-hcutts@chromium.org> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: <20180830215622.47550-1-hcutts@chromium.org> References: <20180830215622.47550-1-hcutts@chromium.org> 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 "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 --- Changes in v2: None 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 19cc980eebce..7f8218f6ff56 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.0.rc0.228.g281dcd1b4d0-goog