From patchwork Thu Aug 30 21:56:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Cutts X-Patchwork-Id: 10582937 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 B874213AC for ; Thu, 30 Aug 2018 21:56:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A87832BE32 for ; Thu, 30 Aug 2018 21:56:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C0A32C24B; Thu, 30 Aug 2018 21:56:49 +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 426182BE32 for ; Thu, 30 Aug 2018 21:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbeHaCBD (ORCPT ); Thu, 30 Aug 2018 22:01:03 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:45934 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728003AbeHaCAq (ORCPT ); Thu, 30 Aug 2018 22:00:46 -0400 Received: by mail-pg1-f196.google.com with SMTP id m4-v6so4471307pgv.12 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=K+BrIFtgNzrowdUUXugUbHBiB8BY72+r7B0TupBEvMyEwH+u2zppmZGfFZmIpNP6Q1 wUzABf/ztL7vsZxNwSkLhBur6r+I6JvJcNsd+oZacSxldrGLyEb6c8opSrnV/Qgh8zNn ss4d2AWRyOzOxywbhdqC8rngDiQg3mWf+XDZpPiATzNwzqqiVEkEw/XiVyzRy60iyMge 56YPjiLM+5eOV3IqG4D0F1ZDI8rac4dBJqApt8FSJKxC7+WWkgQU0RITGQsx2a3tRt7S C3mTgvAEjstBXsVWMpteO4GeMMdcb4HBbwl0PUv+eXliX2AVy4L8tQZDyRS9xPHK/kl3 cM/Q== X-Gm-Message-State: APzg51CZN828WLVpXR69wG+Y05d/wPQw8KOqzcbyBYHoYSw/DfK5uSJF u9Qxbxl3cLjNFvJe9iVpVkg5XnU0Iac= X-Google-Smtp-Source: ANB0VdZzZ/3YCj9OmeIh8VBlM+TsByTe2zlPdoJEFqYelQq8BG9V2hZad7PLvR0o62q0Ckl19kiiPA== 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 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 "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