From patchwork Thu Aug 30 21:56:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Cutts X-Patchwork-Id: 10582941 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 B49E95A4 for ; Thu, 30 Aug 2018 21:56:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A48E32BE32 for ; Thu, 30 Aug 2018 21:56:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98DEC2C24B; Thu, 30 Aug 2018 21:56:56 +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 438202BE32 for ; Thu, 30 Aug 2018 21:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbeHaCAp (ORCPT ); Thu, 30 Aug 2018 22:00:45 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36480 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727981AbeHaCAo (ORCPT ); Thu, 30 Aug 2018 22:00:44 -0400 Received: by mail-pg1-f196.google.com with SMTP id d1-v6so4484256pgo.3 for ; Thu, 30 Aug 2018 14:56:29 -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=bNkXjyd/TJwjJQq5sEuLkOphZyxbub4Zs7WyVtO+UM0=; b=OO2p7d+CZgD4xu58qnmC/I+WtDMVinCv2sRX+QxYmOggLJ6HEFrSO5eq3Xwd8yOO3I 2YD0a33Qp016oqh0a0lciOhz2xY9q7NxcgvCrMbbaVJJineVysS91WrHY84ZLuoZyNMd okn84jvHPZ4wzARZvMvhFwOwkyIgsDQHf/sKs= 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=bNkXjyd/TJwjJQq5sEuLkOphZyxbub4Zs7WyVtO+UM0=; b=L2a8Amp5oDM7fYstAx6qPz4BhohMs/pwggQelgakRGbuTAhFTNZUv6VvUgZrpxDIYD 02EGZ8PFuUKznxIaMRYLhd4VFzqAvJOk2cOZf8Fh53Wo/nngJ7WG7G6X+mIuGEQyhLMm 88mbN2+73WpSr8d1J+1hJYYcF+5BbFgTN0A/KGjL2XJSpDpMttdFwFXh2J7lI8BGwGNy Lu18IbVXaZM5B9KJnEiuRwJz0fT/2jAr9I0WLEr9UtcjRRk/7VmyMmELPeB0DqTj+LHn tdDYBbAjCGMrBodMie31mPKUW+tzAv/fu0TOPFbjmXDqPuAziOqkwNuEtmWyvfHCEg/6 u8AA== X-Gm-Message-State: APzg51AEWgMlBuRyVKc2OZWiH653VF5Y7SxNDb8wcugL/UbD8GMsWWb4 46IDw0UHAni/z/wp76AePlC2+FWrYuI= X-Google-Smtp-Source: ANB0VdbNkl8lbvHPMvyngVgpXh3ZSQLD2vCCYre8H6NFVp07Ua62TVik9DMEPfWU76DNHJGykuMSzA== X-Received: by 2002:a63:f501:: with SMTP id w1-v6mr6830908pgh.446.1535666188590; Thu, 30 Aug 2018 14:56:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 14:56:28 -0700 (PDT) From: Harry Cutts To: linux-input , LKML Cc: Jiri Kosina , Dmitry Torokhov , Benjamin Tissoires , Harry Cutts , linux-doc@vger.kernel.org, Jonathan Corbet Subject: [PATCH v2 1/5] Add the `REL_WHEEL_HI_RES` event code Date: Thu, 30 Aug 2018 14:56:18 -0700 Message-Id: <20180830215622.47550-2-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 This event code represents scroll reports from high-resolution wheels, and will be used by future patches in this series. See the linux-input "Reporting high-resolution scroll events" thread [0] for more details. [0]: https://www.spinics.net/lists/linux-input/msg57380.html Signed-off-by: Harry Cutts Acked-by: Dmitry Torokhov --- Changes in v2: None Documentation/input/event-codes.rst | 11 ++++++++++- include/uapi/linux/input-event-codes.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/input/event-codes.rst b/Documentation/input/event-codes.rst index a8c0873beb95..cef220c176a4 100644 --- a/Documentation/input/event-codes.rst +++ b/Documentation/input/event-codes.rst @@ -190,7 +190,16 @@ A few EV_REL codes have special meanings: * REL_WHEEL, REL_HWHEEL: - These codes are used for vertical and horizontal scroll wheels, - respectively. + respectively. The value is the number of "notches" moved on the wheel, the + physical size of which varies by device. For high-resolution wheels (which + report multiple events for each notch of movement, or do not have notches) + this may be an approximation based on the high-resolution scroll events. + +* REL_WHEEL_HI_RES: + + - If a vertical scroll wheel supports high-resolution scrolling, this code + will be emitted in addition to REL_WHEEL. The value is the (approximate) + distance travelled by the user's finger, in microns. EV_ABS ------ diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h index 53fbae27b280..dad8d3890a3a 100644 --- a/include/uapi/linux/input-event-codes.h +++ b/include/uapi/linux/input-event-codes.h @@ -708,6 +708,7 @@ #define REL_DIAL 0x07 #define REL_WHEEL 0x08 #define REL_MISC 0x09 +#define REL_WHEEL_HI_RES 0x0a #define REL_MAX 0x0f #define REL_CNT (REL_MAX+1) From patchwork Thu Aug 30 21:56:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Cutts X-Patchwork-Id: 10582939 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 7AFA85A4 for ; Thu, 30 Aug 2018 21:56:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A86D2BE32 for ; Thu, 30 Aug 2018 21:56:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D9462C24B; Thu, 30 Aug 2018 21:56:52 +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 E319B2BE32 for ; Thu, 30 Aug 2018 21:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728006AbeHaCAq (ORCPT ); Thu, 30 Aug 2018 22:00:46 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40886 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727983AbeHaCAp (ORCPT ); Thu, 30 Aug 2018 22:00:45 -0400 Received: by mail-pg1-f196.google.com with SMTP id a13-v6so1788203pgt.7 for ; Thu, 30 Aug 2018 14:56:29 -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=QcFL356MAhLkKLgvLnv14Bj/GWDN0Ja5s+Ff/8fRGs0=; b=c/TM2kd09Qd2nmUC/nZ+uotwMWVKab1wh7r2/tBJSLUPxyY4fRvkXE5ZOCLR2/HuGI pbEMjhOySYnYwFY91c+uGCZ4+Q+jPcHttZ+aK/9ynmkL92L0qYaJGvpUhAJi0rOdQ4Si dWVwaqcfDH9Y9Jae9LTQUlKsE8DOrqzXEbpGs= 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=QcFL356MAhLkKLgvLnv14Bj/GWDN0Ja5s+Ff/8fRGs0=; b=AfxEIHhYtXiR7oSbYKDXGX9A80eAtP/G3VfShkRqBoh5RTsxq/AOc5Ipr0ylfK9/yn qhedTpRQS/oN1F1/iWZlZQMxkURX2LBDtrdGIpeFGe4ZVlOZU4clKPUyXSqS0FhVT8Px E8aKoWOrMLBXiGW65PBNYK5vMIV/NJiFCEvXAHPp74p6etwsVgjvCBKZG+QId2CXvZol dn+q/y6tTcmmc3FSlLH37fnyWLIyJs44C8xxyw2AraLN5BDhdxuCBgJg+SlmbAqflIb1 0JntJ5fYU8u80mVijvju/6pzLG7F+LNjRnIdE8DF90XhgNvwKsqbT+E1NcfZdzBC5WV4 KXlw== X-Gm-Message-State: APzg51BYeW8IQWKcLRe1xD02MhIixOq2nAkof9R4/bheJGUe/2yTidso lo+nQR/mlYhLkxfeSOF9t9MjyxJbquQ= X-Google-Smtp-Source: ANB0VdYr2ABZM9jTf/bsUPFpY/IvZnkUmrVnpJO8BC0JtuOf6RzZaHwPZjGfLw2FsZZN0AybaeU35g== X-Received: by 2002:a63:5c10:: with SMTP id q16-v6mr11342336pgb.452.1535666189427; Thu, 30 Aug 2018 14:56:29 -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.28 (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 2/5] Create a utility class for counting scroll events Date: Thu, 30 Aug 2018 14:56:19 -0700 Message-Id: <20180830215622.47550-3-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 To avoid code duplication, this class counts high-resolution scroll movements and emits the legacy low-resolution events when appropriate. Drivers should be able to create one instance for each scroll wheel that they need to handle. Signed-off-by: Harry Cutts --- Changes in v2: None drivers/hid/hid-input.c | 45 +++++++++++++++++++++++++++++++++++++++++ include/linux/hid.h | 28 +++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 4e94ea3e280a..6e84e7b9afcb 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1826,3 +1826,48 @@ void hidinput_disconnect(struct hid_device *hid) } EXPORT_SYMBOL_GPL(hidinput_disconnect); +/** + * hid_scroll_counter_handle_scroll() - Send high- and low-resolution scroll + * events given a high-resolution wheel + * movement. + * @counter: a hid_scroll_counter struct describing the wheel. + * @hi_res_value: the movement of the wheel, in the mouse's high-resolution + * units. + * + * Given a high-resolution movement, this function converts the movement into + * microns and emits high-resolution scroll events for the input device. It also + * uses the multiplier from &struct hid_scroll_counter to emit low-resolution + * scroll events when appropriate for backwards-compatibility with userspace + * input libraries. + */ +void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter, + int hi_res_value) +{ + int low_res_scroll_amount; + /* Some wheels will rest 7/8ths of a notch from the previous notch + * after slow movement, so we want the threshold for low-res events to + * be in the middle of the notches (e.g. after 4/8ths) as opposed to on + * the notches themselves (8/8ths). + */ + int threshold = counter->resolution_multiplier / 2; + + input_report_rel(counter->dev, REL_WHEEL_HI_RES, + hi_res_value * counter->microns_per_hi_res_unit); + + counter->remainder += hi_res_value; + if (abs(counter->remainder) >= threshold) { + /* Add (or subtract) 1 because we want to trigger when the wheel + * is half-way to the next notch (i.e. scroll 1 notch after a + * 1/2 notch movement, 2 notches after a 1 1/2 notch movement, + * etc.). + */ + low_res_scroll_amount = + counter->remainder / counter->resolution_multiplier + + (hi_res_value > 0 ? 1 : -1); + input_report_rel(counter->dev, REL_WHEEL, + low_res_scroll_amount); + counter->remainder -= + low_res_scroll_amount * counter->resolution_multiplier; + } +} +EXPORT_SYMBOL_GPL(hid_scroll_counter_handle_scroll); diff --git a/include/linux/hid.h b/include/linux/hid.h index 834e6461a690..037e37b0b0e6 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -1138,6 +1138,34 @@ static inline u32 hid_report_len(struct hid_report *report) int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, int interrupt); + +/** + * struct hid_scroll_counter - Utility class for processing high-resolution + * scroll events. + * @dev: the input device for which events should be reported. + * @microns_per_hi_res_unit: the amount moved by the user's finger for each + * high-resolution unit reported by the mouse, in + * microns. + * @resolution_multiplier: the wheel's resolution in high-resolution mode as a + * multiple of its lower resolution. For example, if + * moving the wheel by one "notch" would result in a + * value of 1 in low-resolution mode but 8 in + * high-resolution, the multiplier is 8. + * @remainder: counts the number of high-resolution units moved since the last + * low-resolution event (REL_WHEEL or REL_HWHEEL) was sent. Should + * only be used by class methods. + */ +struct hid_scroll_counter { + struct input_dev *dev; + int microns_per_hi_res_unit; + int resolution_multiplier; + + int remainder; +}; + +void hid_scroll_counter_handle_scroll(struct hid_scroll_counter *counter, + int hi_res_value); + /* HID quirks API */ unsigned long hid_lookup_quirk(const struct hid_device *hdev); int hid_quirks_init(char **quirks_param, __u16 bus, int count); 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 From patchwork Thu Aug 30 21:56:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Cutts X-Patchwork-Id: 10582935 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 2429513AC for ; Thu, 30 Aug 2018 21:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 121652BE32 for ; Thu, 30 Aug 2018 21:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0674E2C24B; Thu, 30 Aug 2018 21:56:41 +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 23F052C24A for ; Thu, 30 Aug 2018 21:56:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727618AbeHaCAt (ORCPT ); Thu, 30 Aug 2018 22:00:49 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38759 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbeHaCAs (ORCPT ); Thu, 30 Aug 2018 22:00:48 -0400 Received: by mail-pg1-f195.google.com with SMTP id e2-v6so4484621pgv.5 for ; Thu, 30 Aug 2018 14:56:31 -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=e3F4JxuBsYJ7mDxbuPeY7E4CxS5RryIVJNUkGSnhOpE=; b=X2dqUIwkvTQ+y1DfmJNfG+F+tyfhiOKDCK6pUlLauzmYHEBvSjEkdwFCCuMHL4RcHv UidlWoXqrmGR0VyVpkUfb7kBIGUHTSPEgW6bYxoSKX6HQZeomFsdhEKgmgMiPNA0ZPSF +9b4OjU09JD3A6Lc7tK7pb0FGd7+YxfBFVipw= 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=e3F4JxuBsYJ7mDxbuPeY7E4CxS5RryIVJNUkGSnhOpE=; b=NXaFprkZJx2qvQhUxZ+KUwZr4JNDZpbvLJoGfCGmmVrzhpX3upYAj0PrHRIQoyNPh0 cP2pP3beyxwi4tDvopvVQPB0nsapgjvJnUmJB8n54ayoBjBVr6w16F7lLF8U6ATvnjaI gPZE+mlFncFYWv88yUoLUexQZhQfNpygJO14/txM0YjZR2Ym5l9bFX0YIP6cY5Crx5Me UDscLCBlnmKjhkb9PrWykbfZ1/6vH3Dk63CccVPxNhIdtDz8BJMBD46CQnShXWD2mcRD g78MGN/kh0rzP24zcvyba2qduLsZQL8NoiGyZ6AxpPMKFuFvMuqBzBXazElgBOhYVcrE VH1Q== X-Gm-Message-State: APzg51ClZnyRKN7y3gGOV3xw13TgZb5QRqxXcRPo/qMX2EKgQPofnWn/ D41NdObDrO87ENHz/qao46dVzf/vraY= X-Google-Smtp-Source: ANB0VdZ64C2fOnsnytGs3urtOxfDGK59PTKyJYBFYVqeclcexrHtqLlCdopzVseRMpumwmdOt+VsCg== X-Received: by 2002:a65:6413:: with SMTP id a19-v6mr4405075pgv.359.1535666191331; Thu, 30 Aug 2018 14:56:31 -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.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 14:56:30 -0700 (PDT) From: Harry Cutts To: linux-input , LKML Cc: Jiri Kosina , Dmitry Torokhov , Benjamin Tissoires , Harry Cutts , Jiri Kosina Subject: [PATCH v2 4/5] Enable high-resolution scrolling on Logitech mice Date: Thu, 30 Aug 2018 14:56:21 -0700 Message-Id: <20180830215622.47550-5-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 There are three features used by various Logitech mice for high-resolution scrolling: the scrolling acceleration bit in HID++ 1.0, and the x2120 and x2121 features in HID++ 2.0 and above. This patch supports all three, and uses the multiplier reported by the mouse for the HID++ 2.0+ features. The full list of product IDs of mice which support high-resolution scrolling was provided by Logitech, but the patch was tested using the following mice (using the Unifying receiver): * HID++ 1.0: Anywhere MX, Performance MX * x2120: M560 * x2121: MX Anywhere 2, MX Master 2S Signed-off-by: Harry Cutts --- Changes in v2: None drivers/hid/hid-logitech-hidpp.c | 249 ++++++++++++++++++++++++++++++- 1 file changed, 245 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 7f8218f6ff56..fd6a8c325fa0 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -64,6 +64,14 @@ MODULE_PARM_DESC(disable_tap_to_click, #define HIDPP_QUIRK_NO_HIDINPUT BIT(23) #define HIDPP_QUIRK_FORCE_OUTPUT_REPORTS BIT(24) #define HIDPP_QUIRK_UNIFYING BIT(25) +#define HIDPP_QUIRK_HI_RES_SCROLL_1P0 BIT(26) +#define HIDPP_QUIRK_HI_RES_SCROLL_X2120 BIT(27) +#define HIDPP_QUIRK_HI_RES_SCROLL_X2121 BIT(28) + +/* Convenience constant to check for any high-res support. */ +#define HIDPP_QUIRK_HI_RES_SCROLL (HIDPP_QUIRK_HI_RES_SCROLL_1P0 | \ + HIDPP_QUIRK_HI_RES_SCROLL_X2120 | \ + HIDPP_QUIRK_HI_RES_SCROLL_X2121) #define HIDPP_QUIRK_DELAYED_INIT HIDPP_QUIRK_NO_HIDINPUT @@ -149,6 +157,7 @@ struct hidpp_device { unsigned long capabilities; struct hidpp_battery battery; + struct hid_scroll_counter vertical_wheel_counter; }; /* HID++ 1.0 error codes */ @@ -1157,6 +1166,101 @@ static int hidpp_battery_get_property(struct power_supply *psy, return ret; } +/* -------------------------------------------------------------------------- */ +/* 0x2120: Hi-resolution scrolling */ +/* -------------------------------------------------------------------------- */ + +#define HIDPP_PAGE_HI_RESOLUTION_SCROLLING 0x2120 + +#define CMD_HI_RESOLUTION_SCROLLING_SET_HIGHRES_SCROLLING_MODE 0x10 + +static int hidpp_hrs_set_highres_scrolling_mode(struct hidpp_device *hidpp, + bool enabled, u8 *multiplier) +{ + u8 feature_index; + u8 feature_type; + int ret; + u8 params[1]; + struct hidpp_report response; + + ret = hidpp_root_get_feature(hidpp, + HIDPP_PAGE_HI_RESOLUTION_SCROLLING, + &feature_index, + &feature_type); + if (ret) + return ret; + + params[0] = enabled ? BIT(0) : 0; + ret = hidpp_send_fap_command_sync(hidpp, feature_index, + CMD_HI_RESOLUTION_SCROLLING_SET_HIGHRES_SCROLLING_MODE, + params, sizeof(params), &response); + if (ret) + return ret; + *multiplier = response.fap.params[1]; + return 0; +} + +/* -------------------------------------------------------------------------- */ +/* 0x2121: HiRes Wheel */ +/* -------------------------------------------------------------------------- */ + +#define HIDPP_PAGE_HIRES_WHEEL 0x2121 + +#define CMD_HIRES_WHEEL_GET_WHEEL_CAPABILITY 0x00 +#define CMD_HIRES_WHEEL_SET_WHEEL_MODE 0x20 + +static int hidpp_hrw_get_wheel_capability(struct hidpp_device *hidpp, + u8 *multiplier) +{ + u8 feature_index; + u8 feature_type; + int ret; + struct hidpp_report response; + + ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, + &feature_index, &feature_type); + if (ret) + goto return_default; + + ret = hidpp_send_fap_command_sync(hidpp, feature_index, + CMD_HIRES_WHEEL_GET_WHEEL_CAPABILITY, + NULL, 0, &response); + if (ret) + goto return_default; + + *multiplier = response.fap.params[0]; + return 0; +return_default: + *multiplier = 8; + hid_warn(hidpp->hid_dev, + "Couldn't get wheel multiplier (error %d), assuming %d.\n", + ret, *multiplier); + return ret; +} + +static int hidpp_hrw_set_wheel_mode(struct hidpp_device *hidpp, bool invert, + bool high_resolution, bool use_hidpp) +{ + u8 feature_index; + u8 feature_type; + int ret; + u8 params[1]; + struct hidpp_report response; + + ret = hidpp_root_get_feature(hidpp, HIDPP_PAGE_HIRES_WHEEL, + &feature_index, &feature_type); + if (ret) + return ret; + + params[0] = (invert ? BIT(2) : 0) | + (high_resolution ? BIT(1) : 0) | + (use_hidpp ? BIT(0) : 0); + + return hidpp_send_fap_command_sync(hidpp, feature_index, + CMD_HIRES_WHEEL_SET_WHEEL_MODE, + params, sizeof(params), &response); +} + /* -------------------------------------------------------------------------- */ /* 0x4301: Solar Keyboard */ /* -------------------------------------------------------------------------- */ @@ -2420,7 +2524,8 @@ static int m560_raw_event(struct hid_device *hdev, u8 *data, int size) input_report_rel(mydata->input, REL_Y, v); v = hid_snto32(data[6], 8); - input_report_rel(mydata->input, REL_WHEEL, v); + hid_scroll_counter_handle_scroll( + &hidpp->vertical_wheel_counter, v); input_sync(mydata->input); } @@ -2548,6 +2653,73 @@ static int g920_get_config(struct hidpp_device *hidpp) return 0; } +/* -------------------------------------------------------------------------- */ +/* High-resolution scroll wheels */ +/* -------------------------------------------------------------------------- */ + +/** + * struct hi_res_scroll_info - Stores info on a device's high-res scroll wheel. + * @product_id: the HID product ID of the device being described. + * @microns_per_hi_res_unit: the distance moved by the user's finger for each + * high-resolution unit reported by the device, in + * 256ths of a millimetre. + */ +struct hi_res_scroll_info { + __u32 product_id; + int microns_per_hi_res_unit; +}; + +static struct hi_res_scroll_info hi_res_scroll_devices[] = { + { /* Anywhere MX */ + .product_id = 0x1017, .microns_per_hi_res_unit = 445 }, + { /* Performance MX */ + .product_id = 0x101a, .microns_per_hi_res_unit = 406 }, + { /* M560 */ + .product_id = 0x402d, .microns_per_hi_res_unit = 435 }, + { /* MX Master 2S */ + .product_id = 0x4069, .microns_per_hi_res_unit = 406 }, +}; + +static int hi_res_scroll_look_up_microns(__u32 product_id) +{ + int i; + int num_devices = sizeof(hi_res_scroll_devices) + / sizeof(hi_res_scroll_devices[0]); + for (i = 0; i < num_devices; i++) { + if (hi_res_scroll_devices[i].product_id == product_id) + return hi_res_scroll_devices[i].microns_per_hi_res_unit; + } + /* We don't have a value for this device, so use a sensible default. */ + return 406; +} + +static int hi_res_scroll_enable(struct hidpp_device *hidpp) +{ + int ret; + u8 multiplier; + + if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) { + ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); + hidpp_hrw_get_wheel_capability(hidpp, &multiplier); + } else if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2120) { + ret = hidpp_hrs_set_highres_scrolling_mode(hidpp, true, + &multiplier); + } else /* if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_1P0) */ { + ret = hidpp10_enable_scrolling_acceleration(hidpp); + multiplier = 8; + } + if (ret) + return ret; + + hidpp->vertical_wheel_counter.resolution_multiplier = multiplier; + hidpp->vertical_wheel_counter.microns_per_hi_res_unit = + hi_res_scroll_look_up_microns(hidpp->hid_dev->product); + hid_info(hidpp->hid_dev, "multiplier = %d, microns = %d\n", + multiplier, + hidpp->vertical_wheel_counter.microns_per_hi_res_unit); + return 0; +} + /* -------------------------------------------------------------------------- */ /* Generic HID++ devices */ /* -------------------------------------------------------------------------- */ @@ -2593,6 +2765,11 @@ static void hidpp_populate_input(struct hidpp_device *hidpp, wtp_populate_input(hidpp, input, origin_is_hid_core); else if (hidpp->quirks & HIDPP_QUIRK_CLASS_M560) m560_populate_input(hidpp, input, origin_is_hid_core); + + if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) { + input_set_capability(input, EV_REL, REL_WHEEL_HI_RES); + hidpp->vertical_wheel_counter.dev = input; + } } static int hidpp_input_configured(struct hid_device *hdev, @@ -2711,6 +2888,27 @@ static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report, return 0; } +static int hidpp_event(struct hid_device *hdev, struct hid_field *field, + struct hid_usage *usage, __s32 value) +{ + /* This function will only be called for scroll events, due to the + * restriction imposed in hidpp_usages. + */ + struct hidpp_device *hidpp = hid_get_drvdata(hdev); + struct hid_scroll_counter *counter = &hidpp->vertical_wheel_counter; + /* A scroll event may occur before the multiplier has been retrieved or + * the input device set, or high-res scroll enabling may fail. In such + * cases we must return early (falling back to default behaviour) to + * avoid a crash in hid_scroll_counter_handle_scroll. + */ + if (!(hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) || value == 0 + || counter->dev == NULL || counter->resolution_multiplier == 0) + return 0; + + hid_scroll_counter_handle_scroll(counter, value); + return 1; +} + static int hidpp_initialize_battery(struct hidpp_device *hidpp) { static atomic_t battery_no = ATOMIC_INIT(0); @@ -2922,6 +3120,9 @@ static void hidpp_connect_event(struct hidpp_device *hidpp) if (hidpp->battery.ps) power_supply_changed(hidpp->battery.ps); + if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL) + hi_res_scroll_enable(hidpp); + if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input) /* if the input nodes are already created, we can stop now */ return; @@ -3107,6 +3308,10 @@ static void hidpp_remove(struct hid_device *hdev) mutex_destroy(&hidpp->send_mutex); } +#define LDJ_DEVICE(product) \ + HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, \ + USB_VENDOR_ID_LOGITECH, (product)) + static const struct hid_device_id hidpp_devices[] = { { /* wireless touchpad */ HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, @@ -3121,10 +3326,39 @@ static const struct hid_device_id hidpp_devices[] = { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_T651), .driver_data = HIDPP_QUIRK_CLASS_WTP }, + { /* Mouse Logitech Anywhere MX */ + LDJ_DEVICE(0x1017), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 }, + { /* Mouse Logitech Cube */ + LDJ_DEVICE(0x4010), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2120 }, + { /* Mouse Logitech M335 */ + LDJ_DEVICE(0x4050), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* Mouse Logitech M515 */ + LDJ_DEVICE(0x4007), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2120 }, { /* Mouse logitech M560 */ - HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, - USB_VENDOR_ID_LOGITECH, 0x402d), - .driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_CLASS_M560 }, + LDJ_DEVICE(0x402d), + .driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_CLASS_M560 + | HIDPP_QUIRK_HI_RES_SCROLL_X2120 }, + { /* Mouse Logitech M705 (firmware RQM17) */ + LDJ_DEVICE(0x101b), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 }, + { /* Mouse Logitech M705 (firmware RQM67) */ + LDJ_DEVICE(0x406d), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* Mouse Logitech M720 */ + LDJ_DEVICE(0x405e), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* Mouse Logitech MX Anywhere 2 */ + LDJ_DEVICE(0x404a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { LDJ_DEVICE(0xb013), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { LDJ_DEVICE(0xb018), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { LDJ_DEVICE(0xb01f), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* Mouse Logitech MX Anywhere 2S */ + LDJ_DEVICE(0x406a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* Mouse Logitech MX Master */ + LDJ_DEVICE(0x4041), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { LDJ_DEVICE(0x4060), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { LDJ_DEVICE(0x4071), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* Mouse Logitech MX Master 2S */ + LDJ_DEVICE(0x4069), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 }, + { /* Mouse Logitech Performance MX */ + LDJ_DEVICE(0x101a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 }, { /* Keyboard logitech K400 */ HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, USB_VENDOR_ID_LOGITECH, 0x4024), @@ -3144,12 +3378,19 @@ static const struct hid_device_id hidpp_devices[] = { MODULE_DEVICE_TABLE(hid, hidpp_devices); +static const struct hid_usage_id hidpp_usages[] = { + { HID_GD_WHEEL, EV_REL, REL_WHEEL }, + { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1} +}; + static struct hid_driver hidpp_driver = { .name = "logitech-hidpp-device", .id_table = hidpp_devices, .probe = hidpp_probe, .remove = hidpp_remove, .raw_event = hidpp_raw_event, + .usage_table = hidpp_usages, + .event = hidpp_event, .input_configured = hidpp_input_configured, .input_mapping = hidpp_input_mapping, .input_mapped = hidpp_input_mapped, From patchwork Thu Aug 30 21:56:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Cutts X-Patchwork-Id: 10582933 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 74A0C5A4 for ; Thu, 30 Aug 2018 21:56:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 632212BE32 for ; Thu, 30 Aug 2018 21:56:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 577142C24B; Thu, 30 Aug 2018 21:56:35 +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 008592BE32 for ; Thu, 30 Aug 2018 21:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728049AbeHaCAt (ORCPT ); Thu, 30 Aug 2018 22:00:49 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44028 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727980AbeHaCAs (ORCPT ); Thu, 30 Aug 2018 22:00:48 -0400 Received: by mail-pf1-f194.google.com with SMTP id j26-v6so4480397pfi.10 for ; Thu, 30 Aug 2018 14:56:32 -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=Rfg9rzUuVH60O1UxfmaDA50ly54WqIEeTGdSH0qZedo=; b=jBDSFIdsNFgf07jX7/BSm57CebfNJqzTKc8JtFNuVGTaHfsIzBXelTqIqkJAdjNsD6 BD60X6IGBOpLUt3uCJDkM+O0kugzwToXPijABaCXgOxo3loFgycmoPY8QtSPa1LNuWWz 7B4HyHJf9+/4770rN4D8RFPbsraMBTDtZxqWM= 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=Rfg9rzUuVH60O1UxfmaDA50ly54WqIEeTGdSH0qZedo=; b=PpsPQQ8QaGrUhHroTChNt1hGyBVo61eWnxTQSymE4fH+jcvwbEMsGS5nPbrk0mUgtn Ur5fwNedXLdRe4YWkWNNj6qoMMHavjLVmFrep/eam0DlIeP9VjmGYvrS3+jLwf7jhFN6 wgkOUb0xE6nkDKBwrSWovcT46qbJlX0oIo+YDzUqGneUMze956NI3m4awW91ZPcfhzge F6eViIh++RqMmGb9eaZJ64wYZ+AumDtJWHX5tHq4/jkrxd6uBShdvngQ+xzJQsmX17W0 FsGbMrjgVsVIWFfHfolBC9a1aN1IEnPrD6Ct2AEkG2mxeMroDhRM/SPsiazFmVlst9BF HthA== X-Gm-Message-State: APzg51C8OeS0TaxZ5Vr2hGBGSRM85XoTDxQbgW7aBfy9qC5ThOW+Qax6 y2TpEzpAq/XBV/eew/jTMevuhlDtpb4= X-Google-Smtp-Source: ANB0VdZ1AnKQkcVAqlSIPxYIYysZ/EtSTB1QT71LfcuX81JVI7olzs7qouw5xrQNdcvB0RUDVrbeVA== X-Received: by 2002:a62:2285:: with SMTP id p5-v6mr12472726pfj.53.1535666192116; Thu, 30 Aug 2018 14:56:32 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 14:56:31 -0700 (PDT) From: Harry Cutts To: linux-input , LKML Cc: Jiri Kosina , Dmitry Torokhov , Benjamin Tissoires , Harry Cutts , Jiri Kosina Subject: [PATCH v2 5/5] Use LDJ_DEVICE macro for existing Logitech mice Date: Thu, 30 Aug 2018 14:56:22 -0700 Message-Id: <20180830215622.47550-6-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 Signed-off-by: Harry Cutts --- Changes in v2: * Changed the REL_WHEEL_HI_RES code to use micrometres (a.k.a. microns) as its units, instead of 256ths of a millimetre. * Removed support for mice connecting over Bluetooth, due to a bug where the mouse's high-res mode and the driver's settings get out of sync when the mouse is power cycled. * Moved the creation of the HID++ 1.0 function and the refactor to use the LDJ_DEVICE macro into separate patches. * Added a couple of explanatory comments to the Logitech driver. drivers/hid/hid-logitech-hidpp.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index fd6a8c325fa0..5f0c080059c6 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -3314,13 +3314,11 @@ static void hidpp_remove(struct hid_device *hdev) static const struct hid_device_id hidpp_devices[] = { { /* wireless touchpad */ - HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, - USB_VENDOR_ID_LOGITECH, 0x4011), + LDJ_DEVICE(0x4011), .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS }, { /* wireless touchpad T650 */ - HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, - USB_VENDOR_ID_LOGITECH, 0x4101), + LDJ_DEVICE(0x4101), .driver_data = HIDPP_QUIRK_CLASS_WTP | HIDPP_QUIRK_DELAYED_INIT }, { /* wireless touchpad T651 */ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, @@ -3360,16 +3358,13 @@ static const struct hid_device_id hidpp_devices[] = { { /* Mouse Logitech Performance MX */ LDJ_DEVICE(0x101a), .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_1P0 }, { /* Keyboard logitech K400 */ - HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, - USB_VENDOR_ID_LOGITECH, 0x4024), + LDJ_DEVICE(0x4024), .driver_data = HIDPP_QUIRK_CLASS_K400 }, { /* Solar Keyboard Logitech K750 */ - HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, - USB_VENDOR_ID_LOGITECH, 0x4002), + LDJ_DEVICE(0x4002), .driver_data = HIDPP_QUIRK_CLASS_K750 }, - { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, - USB_VENDOR_ID_LOGITECH, HID_ANY_ID)}, + { LDJ_DEVICE(HID_ANY_ID) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL), .driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS},