From patchwork Tue Apr 11 13:29:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 9675293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3158760382 for ; Tue, 11 Apr 2017 13:30:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24CE82787C for ; Tue, 11 Apr 2017 13:30:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19A4828554; Tue, 11 Apr 2017 13:30:13 +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=-6.9 required=2.0 tests=BAYES_00,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 7C9D22787C for ; Tue, 11 Apr 2017 13:30:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752052AbdDKNaL (ORCPT ); Tue, 11 Apr 2017 09:30:11 -0400 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:59413 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751390AbdDKNaK (ORCPT ); Tue, 11 Apr 2017 09:30:10 -0400 Received: from localhost (localhost [127.0.0.1]) by osg.samsung.com (Postfix) with ESMTP id 95A4AA05F6; Tue, 11 Apr 2017 13:30:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osg.samsung.com X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from osg.samsung.com ([127.0.0.1]) by localhost (s-opensource.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5I44ww0o3uFM; Tue, 11 Apr 2017 13:30:34 +0000 (UTC) Received: from smtp.s-opensource.com (201.47.150.171.dynamic.adsl.gvt.net.br [201.47.150.171]) by osg.samsung.com (Postfix) with ESMTPSA id C594CA05F1; Tue, 11 Apr 2017 13:30:33 +0000 (UTC) Received: from mchehab by smtp.s-opensource.com with local (Exim 4.87) (envelope-from ) id 1cxvrb-00025n-PG; Tue, 11 Apr 2017 10:29:43 -0300 From: Mauro Carvalho Chehab To: linux-input@vger.kernel.org, Dmitry Torokhov , Benjamin Tissoires , Jiri Kosina Cc: Mauro Carvalho Chehab , Jiri Kosina Subject: [PATCH v4 5/5] hid-logitech-hidpp: add support for ratchet switch Date: Tue, 11 Apr 2017 10:29:42 -0300 Message-Id: <42d4c04d292c6788695036b77d8c0e3517e816ec.1491917052.git.mchehab@s-opensource.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: <34b4f3e6baedde818516ceb1d009f6568b953345.1491917052.git.mchehab@s-opensource.com> <5656f59d7fb0590dd139c5e6b597bd56e823bd94.1491917052.git.mchehab@s-opensource.com> In-Reply-To: References: 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 Logitech Anywhere MX2 and MX master produce events for the wheel ratchet/free wheel button. Add support for it. Signed-off-by: Mauro Carvalho Chehab --- drivers/hid/hid-logitech-hidpp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 20ced3f519ae..fa5a28cc77ca 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -2031,6 +2031,19 @@ static int hidpp_mouse_set_wheel_mode(struct hidpp_device *hidpp, return ret; } + ret = hidpp_send_fap_command_sync(hidpp, hrd->feature_index, + CMD_MOUSE_GET_WHEEL_RATCHET, + params, 0, &response); + if (ret > 0) { + hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n", + __func__, ret); + return -EPROTO; + } + if (ret) + return ret; + + hrd->ratchet = response.fap.params[0] & 0x01; + params[0] = (invert ? BIT(2) : 0) | (high_res ? BIT(1) : 0) | (hidpp_mode ? BIT(0) : 0); @@ -2564,10 +2577,11 @@ static int high_res_raw_event(struct hid_device *hdev, u8 *data, int size) input_report_rel(hrd->input, REL_HIRES_WHEEL, delta); else input_report_rel(hrd->input, REL_WHEEL, delta); + } else if (data[3] == 0x10) { + hrd->ratchet = data[4] & 0x01; + input_report_switch(hrd->input, SW_RATCHET, hrd->ratchet); } - /* FIXME: also report ratchet events to userspace */ - return 1; } @@ -2580,6 +2594,11 @@ static void high_res_populate_input(struct hidpp_device *hidpp, __set_bit(REL_WHEEL, hrd->input->relbit); __set_bit(REL_HIRES_WHEEL, hrd->input->relbit); + __set_bit(EV_SW, hrd->input->evbit); + __set_bit(SW_RATCHET, hrd->input->swbit); + + /* Report current state of the ratchet switch */ + input_report_switch(hrd->input, SW_RATCHET, hrd->ratchet); }