Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4504114ybi; Tue, 11 Jun 2019 07:43:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/efTVWyDZ9sRpIdCBZYzAG3Gn0xDAsUX+hyBvxWSVnuQcgJHn6VMNuH5gsdI7YfacniHE X-Received: by 2002:a62:3447:: with SMTP id b68mr24241200pfa.67.1560264233532; Tue, 11 Jun 2019 07:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560264233; cv=none; d=google.com; s=arc-20160816; b=Wk9m1UDcd0c3hZCdeKDq9RmpIdpg+L35rNoVyKnHc8ZTeOjC+G3lMhlW6kY6iOFezr k231+IY2JUq9gu0h39QH4yp7JeMhjlotUmpQwUzYje41khdajbOfJXLIJKkVVhioRdVR ucFMR8kWePR2cI+6Cfw75ChXStoWLYCkoRRyE/NhtoW37OrnhhD5ZNuNJmLMS5tcNrr+ uOh+kNCRla6ZCag110NEJTVTf0gMJL5l9aWztkZ+8/JuPK5LTEdFWu9Ue7IFKcXtDl10 VTbPVmZaZCNxWHedK39F44rsDZhhr7fyzu3Jpu/ns3MrjTzlZfAYTz9UyQ4rtrlnHNkG CTrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ar4hb3yiBL9RLGyl8brQ12ttcv1qOaVZT7c8EOl9hRY=; b=uZu7JZ7oKtr5DrFvKmYiVTQr20wEnqSrbV2InM2s8ofpTAmgC3WztFGUXu2TNfveae f+0/8I2Qa8R9ix7A6T/2+cm1XhRpW7E4YPwi5qnx+C3949oEAyspdG2wbWpdIPewkKr4 IRXriWB0htJDvfOH8WEwxK3xg682F3ib6VsukLv09Ehm7P2huOrZKFoC2A0fQYOisDP5 SsBCmAnT91iCwBrRNng9t3QHPyODFfQ3XlkARwEURknGHJeZBZ0TZHGtzp4AjRECkX2G 5avvZv0L31M+WzUFxHuJbMZSaruYLc8KNu7nN9MdYckMB2YxTNc2bqmSAPWU5UxP6xKn yQqA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si2475632pjk.55.2019.06.11.07.43.37; Tue, 11 Jun 2019 07:43:53 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403965AbfFKOmv (ORCPT + 99 others); Tue, 11 Jun 2019 10:42:51 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:45519 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403895AbfFKOmu (ORCPT ); Tue, 11 Jun 2019 10:42:50 -0400 Received: by mail-qt1-f196.google.com with SMTP id j19so14778300qtr.12 for ; Tue, 11 Jun 2019 07:42:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ar4hb3yiBL9RLGyl8brQ12ttcv1qOaVZT7c8EOl9hRY=; b=ndhqUAmJ4wQW6J4UKZWlxUoH+v3q48Im1bTV9uuLHEiwf+/VPGMLyLohWTOmNRu+HE QcJXQdLtlQeoY5sWWOPSc7A1A18IMnWBL+mwtmjv5Mct46+tzpl1HEGzLyWKHfYrChfd MwUxHdx2VoCSw3naFNqQHUhO+7QfPmi3EeQuiQkf26ltaw/D/iuDrV4fYxDbSElfHIev WFmLhzmQQMK8hxezFLH9vbQnworZpwlMYe2U9h7FkTpFmuRd8KfxnpbAvV9aoFNeospH VPDPxcyepKEypgCaHa4i3qv0rlBAD1itT1mm5Yg1qQsp+1TCVdy0ZC7/8HqdCBBexlV+ rJRQ== X-Gm-Message-State: APjAAAXStvJsKTOAnIPMBy4JgWcKOlq0mI0c0rva+m1QVz10KGD96quM Y61HHmDyWSuCvI30SQdVhBiiWl75pvOUarUsOPjLRg== X-Received: by 2002:ac8:2998:: with SMTP id 24mr62504198qts.31.1560264169050; Tue, 11 Jun 2019 07:42:49 -0700 (PDT) MIME-Version: 1.0 References: <20190611121320.30267-1-nsaenzjulienne@suse.de> In-Reply-To: <20190611121320.30267-1-nsaenzjulienne@suse.de> From: Benjamin Tissoires Date: Tue, 11 Jun 2019 16:42:37 +0200 Message-ID: Subject: Re: [PATCH v2] HID: input: fix a4tech horizontal wheel custom usage To: Nicolas Saenz Julienne Cc: Jiri Kosina , Dmitry Torokhov , wbauer@tmo.at, "open list:HID CORE LAYER" , lkml Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 11, 2019 at 2:13 PM Nicolas Saenz Julienne wrote: > > 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 > --- Yep, I like this one much better. > > NOTE: I CC'd Wolfgang as he's the one who can test this. I'll wait for Wolfram to confirm that the patch works before pushing then. > > Changes since v1: > - new approach, moved fix into hid-a4tech > > 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 98bf694626f7..3a8c4a5971f7 100644 > --- a/drivers/hid/hid-a4tech.c > +++ b/drivers/hid/hid-a4tech.c > @@ -23,12 +23,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; You seem to be extra precocious here. This is basically what the current hid-input.c mapping does. But I think it is for the best, given that this time you are locking the behavior of this reserved usage. Cheers, Benjamin > + } > + > + 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) > @@ -52,8 +76,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; > @@ -64,7 +87,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); > input_event(input, EV_REL, value ? REL_HWHEEL_HI_RES : > @@ -131,6 +154,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.21.0 >