From patchwork Sat Mar 25 22:49: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: 9644901 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 BA968601E9 for ; Sat, 25 Mar 2017 22:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A297127165 for ; Sat, 25 Mar 2017 22:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9764A27FA8; Sat, 25 Mar 2017 22:50:30 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 4B3E527165 for ; Sat, 25 Mar 2017 22:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751230AbdCYWua (ORCPT ); Sat, 25 Mar 2017 18:50:30 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:34850 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751205AbdCYWu3 (ORCPT ); Sat, 25 Mar 2017 18:50:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Sender:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=j6Dk5bQPdIp+AWehxMxq60vWolndmASD4sHTcmWN1jE=; b=Od4PXm8cNWBt/Yo29NhdUCBdS bLe75yB89Y/cmoPA8lvayTVrl5nG/aMf7tqIEdGZA7HxeNNQSHBCmEXOSZaNy4n02SEdjiDPkda62 L3a5HeQNVBAQ8L2ENYCnWpiduVGFKMXN3uNzb1kvUcbl3dqK5oZr+zxtRjCga+uo/dgexX3R+Tyyq /DZxXsYFgzD0IhqYuHsAMGCxETODljsSXsHtsHxQS6X2Y0RzHkESEiu+1xDGKcHnbyWuCRG7t72Pg auZg2sCL1cj60N/Umk1+g11tIh8cP2Xauuu8hPxb1SXxEE0ZheMI1iRan8ifJM/I4Slm2+oi88guV SItZzlnhg==; Received: from 177.205.100.127.dynamic.adsl.gvt.net.br ([177.205.100.127] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cruVG-0007Jl-Q7; Sat, 25 Mar 2017 22:49:47 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.87) (envelope-from ) id 1cruVD-0000li-Bb; Sat, 25 Mar 2017 19:49:43 -0300 From: Mauro Carvalho Chehab To: linux-input@vger.kernel.org Cc: Mauro Carvalho Chehab , Dmitry Torokhov , Peter Hutterer , Benjamin Tissoires , Jiri Kosina Subject: [PATCH RFC 4/4] hid-logitech-hidpp: add support for ratchet switch Date: Sat, 25 Mar 2017 19:49:42 -0300 Message-Id: <9c21f1c0527613a64edc2b3e0b7a8d8861f6e0fb.1490481944.git.mchehab@s-opensource.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: <2529a55b0477cc638f1104a423cb67de1628a96d.1490481944.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 ee3f544bda4f..72f80869633f 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -1406,6 +1406,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, 16, &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 ? 0x4 : 0 | high_res ? 0x2 : 0 | hidpp_mode ? 0x1 : 0; @@ -1945,10 +1958,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; } @@ -1961,6 +1975,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); }