From patchwork Thu Jan 24 11:40:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarrad Whitaker X-Patchwork-Id: 10778789 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76FD013BF for ; Thu, 24 Jan 2019 11:41:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 659B72E909 for ; Thu, 24 Jan 2019 11:41:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5970D2E911; Thu, 24 Jan 2019 11:41:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 B60FB2E909 for ; Thu, 24 Jan 2019 11:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727513AbfAXLlR (ORCPT ); Thu, 24 Jan 2019 06:41:17 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42131 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbfAXLlQ (ORCPT ); Thu, 24 Jan 2019 06:41:16 -0500 Received: by mail-pg1-f194.google.com with SMTP id d72so2535135pga.9 for ; Thu, 24 Jan 2019 03:41:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CWD9FUp0OZlstTzkhjL1uji3T7D2vhQxbAEJ0DRNZ3Q=; b=ErzIs+jGIu/3Spi+HokGlIk+JPxg3jy6cAWOicRtNbjr6x8QJOkgfbBdodS1W3TF/h t2bOxQYuJh5Ky3uyBTm+HKhT+uCheZPBQJNSlsCUZczWZx13PpQkSyUv3SJhi65Gj/uR mRUmBkfH3ryLNK7xCRArF06odz2k/wly3CMi816yYs08rhKJHsRHpOvs0wQe6CC7Lnw+ uJ1mRrV49G8n2GkIcV68uK6jlu2O0VnOd6In4XInPnIOC82NPSS3h+lbBqv+MzhP/+Lv 9fY/bosiV2C8nLxXxiSw8td7IKgieJzRGZ6lqndP9GARNuXVo7RVmpEcOMe6S02pNagZ Nt4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CWD9FUp0OZlstTzkhjL1uji3T7D2vhQxbAEJ0DRNZ3Q=; b=jWXQ3dbJgW9mtmKzxbxCGY1jzbxkvsoIBAqa1id0gzQWxquBkKviFPh6rEDXtUFtdd 9m/OYUjc8VKAgUAxorQ+61R54M2+q4LgFBqB/JU8+KzqU7WTTvTFUyUOiAPVPtkb5UPQ awungv1ecOvIWiHQcOcubJVJY+DtvFlrKGXFNhHdeYkXZlfmPM/3G04D52Tz6KwNVweW moTrDXLPXVtg4CuD9QaDgAVzudIQ7lXHGHggBMPtQ5c6/MS5QPGznXabPRJhJY3q8oTk BwnbkIy3bqt4hif1NO3H/4ml33EYjJAKvussPsOCwZmYP5uaVal1a6M32sZehBPql7my yZBw== X-Gm-Message-State: AJcUukeGPtyWLKYI5J3Q15jnc78nlWknUqQZ/nhFwmM6TRGN+yyzOTE3 eBOtj/4C0J/lnnlS6Ow0PXv5OliAmaY= X-Google-Smtp-Source: ALg8bN6VTxZlpY3h/BsujtEN21cr5GmeOKHxS3kheB5vvfvuWU+o4lu7AWK8nCai26VrIpABjOZfAg== X-Received: by 2002:a62:8a51:: with SMTP id y78mr6061941pfd.35.1548330075468; Thu, 24 Jan 2019 03:41:15 -0800 (PST) Received: from localhost.localdomain (110-174-103-123.static.tpgi.com.au. [110.174.103.123]) by smtp.googlemail.com with ESMTPSA id h8sm24119755pgv.27.2019.01.24.03.41.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 03:41:14 -0800 (PST) From: Jarrad Whitaker To: linux-input@vger.kernel.org Cc: Benjamin Tissoires , Jiri Kosina , Jarrad Whitaker Subject: [PATCH] hid: fix Logitech WingMan Formula GP joined axes Date: Thu, 24 Jan 2019 22:40:50 +1100 Message-Id: <20190124114050.14143-1-jarrad.whitaker@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 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 The Logitech WingMan Formula GP by default presents a combined accelerate/brake axis, so this patch assigns it to hid-logitech in order to benefit from the axis-splitting logic in lg4ff. There is also a fixed report descriptor for the resulting report. Signed-off-by: Jarrad Whitaker --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-lg.c | 60 ++++++++++++++++++++++++++++++++++++++++ drivers/hid/hid-lg4ff.c | 6 ++++ drivers/hid/hid-quirks.c | 1 + 4 files changed, 68 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 24f846d67478..c43fe0a0fc36 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -744,6 +744,7 @@ #define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283 #define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286 #define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940 0xc287 +#define USB_DEVICE_ID_LOGITECH_WINGMAN_FG 0xc20e #define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG 0xc293 #define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 #define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295 diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c index 596227ddb6e0..5d419a95b6c2 100644 --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c @@ -50,6 +50,7 @@ #define MOMO_RDESC_ORIG_SIZE 87 #define MOMO2_RDESC_ORIG_SIZE 87 #define FFG_RDESC_ORIG_SIZE 85 +#define FG_RDESC_ORIG_SIZE 82 /* Fixed report descriptors for Logitech Driving Force (and Pro) * wheel controllers @@ -381,6 +382,49 @@ static __u8 ffg_rdesc_fixed[] = { 0xC0 /* End Collection */ }; +static __u8 fg_rdesc_fixed[] = { +0x05, 0x01, /* Usage Page (Desktop), */ +0x09, 0x04, /* Usage (Joystik), */ +0xA1, 0x01, /* Collection (Application), */ +0xA1, 0x02, /* Collection (Logical), */ +0x15, 0x00, /* Logical Minimum (0), */ +0x26, 0xFF, 0x00, /* Logical Maximum (255), */ +0x35, 0x00, /* Physical Minimum (0), */ +0x46, 0xFF, 0x00, /* Physical Maximum (255), */ +0x75, 0x08, /* Report Size (8), */ +0x95, 0x01, /* Report Count (1), */ +0x09, 0x30, /* Usage (X), */ +0x81, 0x02, /* Input (Variable), */ +0xA4, /* Push, */ +0x25, 0x01, /* Logical Maximum (1), */ +0x45, 0x01, /* Physical Maximum (1), */ +0x75, 0x01, /* Report Size (1), */ +0x95, 0x02, /* Report Count (2), */ +0x81, 0x01, /* Input (Constant), */ +0x95, 0x06, /* Report Count (6), */ +0x05, 0x09, /* Usage Page (Button), */ +0x19, 0x01, /* Usage Minimum (01h), */ +0x29, 0x06, /* Usage Maximum (06h), */ +0x81, 0x02, /* Input (Variable), */ +0x05, 0x01, /* Usage Page (Desktop), */ +0xB4, /* Pop, */ +0x81, 0x02, /* Input (Constant), */ +0x09, 0x31, /* Usage (Y), */ +0x81, 0x02, /* Input (Variable), */ +0x09, 0x32, /* Usage (Z), */ +0x81, 0x02, /* Input (Variable), */ +0xC0, /* End Collection, */ +0xA1, 0x02, /* Collection (Logical), */ +0x26, 0xFF, 0x00, /* Logical Maximum (255), */ +0x46, 0xFF, 0x00, /* Physical Maximum (255), */ +0x75, 0x08, /* Report Size (8), */ +0x95, 0x04, /* Report Count (4), */ +0x09, 0x02, /* Usage (02h), */ +0xB1, 0x02, /* Feature (Variable), */ +0xC0, /* End Collection, */ +0xC0 /* End Collection, */ +}; + /* * Certain Logitech keyboards send in report #3 keys which are far * above the logical maximum described in descriptor. This extends @@ -408,6 +452,19 @@ static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc, switch (hdev->product) { + case USB_DEVICE_ID_LOGITECH_WINGMAN_FG: + if (*rsize == FG_RDESC_ORIG_SIZE) { + hid_info(hdev, + "fixing up Logitech Wingman Formula GP report descriptor\n"); + rdesc = fg_rdesc_fixed; + *rsize = sizeof(fg_rdesc_fixed); + } else { + hid_info(hdev, + "rdesc size test failed for formula gp\n"); + } + break; + + case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG: if (*rsize == FFG_RDESC_ORIG_SIZE) { hid_info(hdev, @@ -664,6 +721,7 @@ static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi, usage->code == ABS_RZ)) { switch (hdev->product) { case USB_DEVICE_ID_LOGITECH_G29_WHEEL: + case USB_DEVICE_ID_LOGITECH_WINGMAN_FG: case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG: case USB_DEVICE_ID_LOGITECH_WHEEL: case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL: @@ -871,6 +929,8 @@ static const struct hid_device_id lg_devices[] = { .driver_data = LG_NOGET | LG_FF4 }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL), .driver_data = LG_FF4 }, + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FG), + .driver_data = LG_NOGET }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG), .driver_data = LG_NOGET | LG_FF4 }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2), diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 512d67e1aae3..a299c9d1605f 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c @@ -103,6 +103,10 @@ static const signed short lg4ff_wheel_effects[] = { -1 }; +static const signed short no_wheel_effects[] = { + -1 +}; + struct lg4ff_wheel { const u32 product_id; const signed short *ff_effects; @@ -137,6 +141,7 @@ struct lg4ff_alternate_mode { }; static const struct lg4ff_wheel lg4ff_devices[] = { + {USB_DEVICE_ID_LOGITECH_WINGMAN_FG, no_wheel_effects, 40, 180, NULL}, {USB_DEVICE_ID_LOGITECH_WINGMAN_FFG, lg4ff_wheel_effects, 40, 180, NULL}, {USB_DEVICE_ID_LOGITECH_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}, {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL, lg4ff_wheel_effects, 40, 270, NULL}, @@ -346,6 +351,7 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report, rd[5] = rd[3]; rd[6] = 0x7F; return 1; + case USB_DEVICE_ID_LOGITECH_WINGMAN_FG: case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG: case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL: case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2: diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c index 94088c0ed68a..4c063d8b2e13 100644 --- a/drivers/hid/hid-quirks.c +++ b/drivers/hid/hid-quirks.c @@ -451,6 +451,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_WHEEL) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FG) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) }, { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) },