From patchwork Mon Sep 26 02:58:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adi Ratiu X-Patchwork-Id: 9350127 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 556E4601C2 for ; Mon, 26 Sep 2016 02:59:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A25428B28 for ; Mon, 26 Sep 2016 02:59:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E78528BD2; Mon, 26 Sep 2016 02:59:20 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 B992528B28 for ; Mon, 26 Sep 2016 02:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034924AbcIZC7B (ORCPT ); Sun, 25 Sep 2016 22:59:01 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33828 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941262AbcIZC6s (ORCPT ); Sun, 25 Sep 2016 22:58:48 -0400 Received: by mail-wm0-f65.google.com with SMTP id l132so11931347wmf.1 for ; Sun, 25 Sep 2016 19:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adirat-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SVHKcAUel8ST6043a4QEM9D3rYmpRwP3dO7cjs2WZSA=; b=rzLSvjUwuKb8RDHvnlUBK9uTTQ9cGyzpLlkB5ku3bUV/0bitwUHO4mogemeuzsQA7Q dStwl10NcLbPIKZGQ0BMSpZJ/hrVR5dL14StiqE9RVHNWG7+wVACgowbozrDBXWo7RC0 fg5HIpD9XJPJekKPdAjujww/BMcFeBczDfOBM4Rx0BhYWW+FT+xjr4LR153xUWQDbI9u VIJauAgF6WvqclGjtITwssC0zxX0FmDs3zL5kmDQJr6cG4bFysx1pk8/+ZJHEJ/V+us/ EgMapA5ktIl5EoS6JC/nPcrLo+lrpibLbAO7HRzDxgvFZx3HqmoCDnB5uZm9drycRGu/ zU0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SVHKcAUel8ST6043a4QEM9D3rYmpRwP3dO7cjs2WZSA=; b=fztF7OyaZi76zE2S+jSWhA9Mwouu89pwKoIftubyuydi82WBSHcXj58Wg9oWmuSWVe WqFjZQo9U6hEF8v0eET8/8Y0xIP6YbDrwB5Bxcyq9FpT05BKMMLJam/pSTwt2hNbHz4T 7piUksSDsw9McDw0lfeX/5eb/jtdAfosHKLhaVajTmgfJSgF5+07ECevVwltAeTVBvQB yZ1zzb94H1RnGTlS6N9xMzvb7g8iIBfYgF0Se5Z+wmAbtIX+Frv3t1naA5AwEUE+bTvP FsYfoVIfH1YFNPEyFQL80HyRh7+8wnJCTDsPthbIWwjOsTDiUyEVCawvfkaXHnB8nr91 jHpQ== X-Gm-Message-State: AA6/9RkU5+UKT42UolW8tGq4Yg9FxbnTOhtP4l/sTiFZpDk4RHARPx3ODuyFTBCZRU7fWQ== X-Received: by 10.194.114.100 with SMTP id jf4mr15641322wjb.87.1474858726800; Sun, 25 Sep 2016 19:58:46 -0700 (PDT) Received: from adiPC.lan ([188.24.78.211]) by smtp.gmail.com with ESMTPSA id t202sm8636949wmt.22.2016.09.25.19.58.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Sep 2016 19:58:46 -0700 (PDT) From: Ioan-Adrian Ratiu To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] hid: input: add HID_QUIRK_REUSE_AXES and fix dragonrise Date: Mon, 26 Sep 2016 05:58:39 +0300 Message-Id: <20160926025839.2790-2-adi@adirat.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160926025839.2790-1-adi@adirat.com> References: <20160926025839.2790-1-adi@adirat.com> 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 Commit 79346d620e9d ("HID: input: force generic axis to be mapped to their user space axis") made mapping generic axes to their userspace equivalents mandatory and some lower end gamepads which were depending on the previous behaviour suffered severe regressions because they were reusing axes and expecting hid-input to multiplex their map to the respective userspace axis by always searching for and using the next available axis. Now the result is that different device axes appear on a single axis in userspace, which is clearly a regression in the hid-input driver because it needs to continue to handle this hardware as expected before the forcing to provide the same interface to userspace. Since these lower-end gamepads like 0079:0006 are definitely the exception, create a quirk to fix them. Signed-off-by: Ioan-Adrian Ratiu --- drivers/hid/hid-dr.c | 2 ++ drivers/hid/hid-input.c | 16 +++++++++++----- include/linux/hid.h | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-dr.c b/drivers/hid/hid-dr.c index 2523f8a..27fc826 100644 --- a/drivers/hid/hid-dr.c +++ b/drivers/hid/hid-dr.c @@ -274,6 +274,8 @@ static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id) hid_hw_stop(hdev); goto err; } + /* has only 5 axes and reuses X, Y */ + hdev->quirks |= HID_QUIRK_REUSE_AXES; break; } diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index fb9ace1..1cc6fe4 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -633,11 +633,17 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel /* These usage IDs map directly to the usage codes. */ case HID_GD_X: case HID_GD_Y: case HID_GD_Z: case HID_GD_RX: case HID_GD_RY: case HID_GD_RZ: - if (field->flags & HID_MAIN_ITEM_RELATIVE) - map_rel(usage->hid & 0xf); - else - map_abs_clear(usage->hid & 0xf); - break; + + /* if quirk is active don't force the userspace mapping, + * instead search and use the next available axis. + */ + if (!(device->quirks & HID_QUIRK_REUSE_AXES)) { + if (field->flags & HID_MAIN_ITEM_RELATIVE) + map_rel(usage->hid & 0xf); + else + map_abs_clear(usage->hid & 0xf); + break; + } case HID_GD_SLIDER: case HID_GD_DIAL: case HID_GD_WHEEL: if (field->flags & HID_MAIN_ITEM_RELATIVE) diff --git a/include/linux/hid.h b/include/linux/hid.h index 75b66ec..0979920 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -320,6 +320,7 @@ struct hid_item { #define HID_QUIRK_NO_EMPTY_INPUT 0x00000100 #define HID_QUIRK_NO_INIT_INPUT_REPORTS 0x00000200 #define HID_QUIRK_ALWAYS_POLL 0x00000400 +#define HID_QUIRK_REUSE_AXES 0x00000800 #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID 0x00020000 #define HID_QUIRK_NO_OUTPUT_REPORTS_ON_INTR_EP 0x00040000