Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5237219ybl; Tue, 27 Aug 2019 01:19:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwoQCqx4PfEPe/q1mb3Y/e0XsESVovRvHvp326y8HPM9Z4Ex9mSwrKMQcapfUHDfVqfXZ8A X-Received: by 2002:a63:4e05:: with SMTP id c5mr19694048pgb.396.1566893950964; Tue, 27 Aug 2019 01:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893950; cv=none; d=google.com; s=arc-20160816; b=WYV87zN6gcjY8OwnGOhqjT+aiVwfAo4uQO7rhx1EIULZNpJRxArKEVK1QJrHA4lBnM ZLNYmw62xKpvnZP3SEmAIlOoAufiGmlt97lHC7LTcyna7SGzYkSf46zqltYIYmdMbmwk RJh79xCh31dGPuuCfEmx98MEZVKz520uYzcMIt0mybJtO71xJP7R+mi+hCoTt1fMDv0A NTMEhPCz8kx+TyYqm0sdP8Fu/KMJIsfjJfmTBNwR1UI3xKGdEO6MAm1dAEs81ETbCOxL 1PTxIeypjFOKVT4GajYy6A2UM8uhoosS2SYV7BE9ZkS6HEPlY5oAOl7I+GRtC0hDaw8C 8hnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V8d5D+6kPjN88/Y+YEXqbR5PF4zXkc0umGvuw8fR2g4=; b=0dly3JDoAN2xH+lAb/j5qJhJ5/qrmPPXEXCQo/MfTlAq6F4dUxkoT4yfDDycJIWWaW guPQilUTKB8/h9vgCPYmuL7fByDmbTKQ7jEo2HfQegp7J5mspkTDONcswfehpCRgPyOq tA4ixojVFlnGuFQnLDwBOtQcBtBPHd82dzTqwmulx6gmt4r3AgIYwNJtJF/TVhXgrU9d 7mKNMaWFC6J5vyZ75xiK2cOvhoFDHbWEnzh2Mcp/ERblc4jTW8sL9JbKaWSa4Q7H3bnb w+8JLUTVYvHu62Hb1dQan56tPUPNoXLYE4RxvPiHsbuBxBocGA//PqRN8jP9lagKss93 z7Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C9bG9Wee; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f23si748400plj.241.2019.08.27.01.18.55; Tue, 27 Aug 2019 01:19:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C9bG9Wee; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729414AbfH0HwX (ORCPT + 99 others); Tue, 27 Aug 2019 03:52:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:43644 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729388AbfH0HwU (ORCPT ); Tue, 27 Aug 2019 03:52:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B74562173E; Tue, 27 Aug 2019 07:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892339; bh=szNqJgC9d5Ndna8YoKeMJQN4lU7/tFfd7KS/NIiUoh4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C9bG9Weekn2JPMLyjIHFJMiGRih1/Z6lLSg1QjGFigSSq7fvOlgZwx1F1hJasoQLc IiPaONcLgnVWwKd6OQuCbPFKT0ChmPAtkNVxvhNr0uRYmTCOwL04wt7yDbSfzdl0R3 NMmziUEyjn38Io78f+o/WeeoBXxnZ3hmTeCgkjsE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Saenz Julienne , Jiri Kosina , Sasha Levin Subject: [PATCH 4.14 22/62] HID: input: fix a4tech horizontal wheel custom usage Date: Tue, 27 Aug 2019 09:50:27 +0200 Message-Id: <20190827072701.664140123@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072659.803647352@linuxfoundation.org> References: <20190827072659.803647352@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1c703b53e5bfb5c2205c30f0fb157ce271fd42fb ] Some a4tech mice use the 'GenericDesktop.00b8' usage to inform whether the previous wheel report was horizontal or vertical. Before c01908a14bf73 ("HID: input: add mapping for "Toggle Display" key") this usage was being mapped to 'Relative.Misc'. After the patch it's simply ignored (usage->type == 0 & usage->code == 0). Which ultimately makes hid-a4tech ignore the WHEEL/HWHEEL selection event, as it has no usage->type. We shouldn't rely on a mapping for that usage as it's nonstandard and doesn't really map to an input event. So we bypass the mapping and make sure the custom event handling properly handles both reports. Fixes: c01908a14bf73 ("HID: input: add mapping for "Toggle Display" key") Signed-off-by: Nicolas Saenz Julienne Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-a4tech.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c index 9428ea7cdf8a0..c52bd163abb3e 100644 --- a/drivers/hid/hid-a4tech.c +++ b/drivers/hid/hid-a4tech.c @@ -26,12 +26,36 @@ #define A4_2WHEEL_MOUSE_HACK_7 0x01 #define A4_2WHEEL_MOUSE_HACK_B8 0x02 +#define A4_WHEEL_ORIENTATION (HID_UP_GENDESK | 0x000000b8) + struct a4tech_sc { unsigned long quirks; unsigned int hw_wheel; __s32 delayed_value; }; +static int a4_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + struct a4tech_sc *a4 = hid_get_drvdata(hdev); + + if (a4->quirks & A4_2WHEEL_MOUSE_HACK_B8 && + usage->hid == A4_WHEEL_ORIENTATION) { + /* + * We do not want to have this usage mapped to anything as it's + * nonstandard and doesn't really behave like an HID report. + * It's only selecting the orientation (vertical/horizontal) of + * the previous mouse wheel report. The input_events will be + * generated once both reports are recorded in a4_event(). + */ + return -1; + } + + return 0; + +} + static int a4_input_mapped(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) @@ -53,8 +77,7 @@ static int a4_event(struct hid_device *hdev, struct hid_field *field, struct a4tech_sc *a4 = hid_get_drvdata(hdev); struct input_dev *input; - if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || - !usage->type) + if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput) return 0; input = field->hidinput->input; @@ -65,7 +88,7 @@ static int a4_event(struct hid_device *hdev, struct hid_field *field, return 1; } - if (usage->hid == 0x000100b8) { + if (usage->hid == A4_WHEEL_ORIENTATION) { input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, a4->delayed_value); return 1; @@ -129,6 +152,7 @@ MODULE_DEVICE_TABLE(hid, a4_devices); static struct hid_driver a4_driver = { .name = "a4tech", .id_table = a4_devices, + .input_mapping = a4_input_mapping, .input_mapped = a4_input_mapped, .event = a4_event, .probe = a4_probe, -- 2.20.1