From patchwork Mon Apr 3 19:35:32 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: 9660447 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 D55186032D for ; Mon, 3 Apr 2017 19:35:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC819284C9 for ; Mon, 3 Apr 2017 19:35:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E63A284D1; Mon, 3 Apr 2017 19:35: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=-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 22668284C9 for ; Mon, 3 Apr 2017 19:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752378AbdDCTfy (ORCPT ); Mon, 3 Apr 2017 15:35:54 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:54449 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751990AbdDCTfy (ORCPT ); Mon, 3 Apr 2017 15:35:54 -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=PodgXhhjK2S3n45kj+aPMMHUV2UyJ3S41BhrHpGGU2k=; b=ErjLq/dYoAd3K7gHDNni/qph4 6eq3RD8Gqb8PykP1+fyD8zbIQBVTvd1oejlDK9SfeQ1kTdpZs7iXp5+PgxjPh5wJGERz+dNvNlbeP t88MKv8mUAA42qlQkajhqiAlArC7mNBplbP4nUXqjp9OUGfxgwoAQlxfhq7Rf5tCremxdZHX+00mK k7pBqAsy4Hm0GH9wzqXHwZgh2uKPRHUttYKZHIZ6L29MQLVeYHR6VpdaO4J7/TFJVUUFYkZGqYZAl uWv59hVXvxW7AvcsiAugR/u8vcsoZIfGKxRnnZWy91puANfucDHM61YTRHm1K3FB9x3U4OiEBM83f qwf3OWviA==; Received: from 177.17.134.102.dynamic.adsl.gvt.net.br ([177.17.134.102] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cv7lY-0002nx-2U; Mon, 03 Apr 2017 19:35:52 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.87) (envelope-from ) id 1cv7lJ-0001op-Dy; Mon, 03 Apr 2017 16:35:37 -0300 From: Mauro Carvalho Chehab Cc: Mauro Carvalho Chehab , Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org Subject: [PATCH 4/4] hid-logitech-hidpp: add support for ratchet switch Date: Mon, 3 Apr 2017 16:35:32 -0300 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: <61af20504c6b06adfb523ae4d734cbda6b6ff545.1491247515.git.mchehab@s-opensource.com> In-Reply-To: References: To: unlisted-recipients:; (no To-header on input) 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 c208a5107511..6177087ffaca 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); }