From patchwork Thu May 27 13:41:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erica Taylor X-Patchwork-Id: 12284273 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3908DC4707F for ; Thu, 27 May 2021 13:41:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17BD46128D for ; Thu, 27 May 2021 13:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236555AbhE0NnI (ORCPT ); Thu, 27 May 2021 09:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236552AbhE0NnH (ORCPT ); Thu, 27 May 2021 09:43:07 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C6C9C061574; Thu, 27 May 2021 06:41:32 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id g17so4574048wrs.13; Thu, 27 May 2021 06:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/0EAjIXy5/pf3Kvar6GSKhBiyXllv5FEc76NqStVIVE=; b=BbgkqQNyMneZFGrPWjeirOP+g4GcdcqgjtH7MfHC5b2XqBN3qXSOpQ/wUpYcNl20EB 3zbWkCbbP5OFyk2kG6hno2qaVxVRn23wUgVxkvFbQwRKdP7MsPFPHi0as0m4qR93Vt9F VzxcD5bOrxgDqIsBEO9VHRtsejsF50fjWvEugEH+3Q7UPiR83kASHFB6OyklJqXDF/Xr De8doBaujHWeARpVeqvH5dMMjiQX3IqFuVtSrWhLVWbP340B+z5sifvqOikREklFJw5L j3fS3ucR4FlS2cbJ3wFazVW76vvnPjSo97pUAifNpu69MnEy3lUUCft85HUpX8NOSRoQ J2Cg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=/0EAjIXy5/pf3Kvar6GSKhBiyXllv5FEc76NqStVIVE=; b=nU8a3d9ZOR3TczszcyJlUuch2Oq3vfjCRDbqxbA+y08JF49VCNRyoUUmB4PD91dKPt 3UZqZEl2QmtuxiZX2MeSrXPVtxgZqMWskca4vZMYvXwRM0k3IYJn4SeUkxnk7l02DV1O lfP/gErMClJSfPmw9+FGI09N89fYSMNE7RnZiHBvNPm9u/MljNTbtRW1Ixqz5TMoKmRn lfFbbWwS+sPB3qWUUHog1J0ymEDp0fMKc6e74gLkskKJVKZ6LBGlGyBLZ2Eqb0CCtRYs UNV3OLqmF7POQMKapb11T/XYd78lxi+6dQNp+l3HoMT1xaBZfuxYcHifc37btAhZ/Prf HXtg== X-Gm-Message-State: AOAM531CHYwqwTLalnNI9D4hCD/IknLG4v1GeLBYltXxJB4owe5Iv29O nY3rcKky1juC/wr1vm1Jxjw9Ri4xgvKDBNjO X-Google-Smtp-Source: ABdhPJy02CGCEoyeDa73+Y/TLDtK6K3OWbHjOnWHY3dbO968oT0SZK7vQMoCT7zCb8akSpOqErViOQ== X-Received: by 2002:adf:f907:: with SMTP id b7mr3441881wrr.357.1622122890388; Thu, 27 May 2021 06:41:30 -0700 (PDT) Received: from caroline.lan (233.119.189.80.dyn.plus.net. [80.189.119.233]) by smtp.gmail.com with ESMTPSA id b10sm3741284wrr.27.2021.05.27.06.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 06:41:30 -0700 (PDT) From: Erica Taylor To: linux-input@vger.kernel.org Cc: Erica Taylor , Jiri Kosina , Benjamin Tissoires , Dmitry Torokhov , Lee Jones , Benjamin Valentin , Matt Reynolds , Andrzej Pietrasiewicz , Sanjay Govind , linux-kernel@vger.kernel.org, Simon Wood , Greg Kroah-Hartman Subject: [PATCH 1/2] HID: logitech-hidpp: add G923 Date: Thu, 27 May 2021 14:41:03 +0100 Message-Id: <20210527134104.217865-2-rickytaylor26@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210527134104.217865-1-rickytaylor26@gmail.com> References: <20210527134104.217865-1-rickytaylor26@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This patch adds the Xbox variant of the Logitech G923 to the supported devices. NOTE: By default the G923 boots in 'Xbox mode' (compatible with the xpad driver) but Logitech uses 'PC mode' when on Windows. PC mode seems to support more features and works well with this driver. This patch does not add code to load the device into PC mode. This code can be exercised by using USB passthru with a VM, or manually issuing USB commands. There is a following patch which adds support for the protocol change to the xpad driver. Signed-off-by: Erica Taylor --- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-logitech-hidpp.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 84b8da3e7d09..41d7f1495727 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -789,6 +789,7 @@ #define USB_DEVICE_ID_LOGITECH_G510_USB_AUDIO 0xc22e #define USB_DEVICE_ID_LOGITECH_G29_WHEEL 0xc24f #define USB_DEVICE_ID_LOGITECH_G920_WHEEL 0xc262 +#define USB_DEVICE_ID_LOGITECH_G923_XBOX_WHEEL 0xc26e #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 diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index d598094dadd0..936dfea2ed27 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -4269,6 +4269,9 @@ static const struct hid_device_id hidpp_devices[] = { { /* Logitech G920 Wheel over USB */ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G920_WHEEL), .driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS}, + { /* Logitech G923 Wheel (Xbox version) over USB */ + HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G923_XBOX_WHEEL), + .driver_data = HIDPP_QUIRK_CLASS_G920 | HIDPP_QUIRK_FORCE_OUTPUT_REPORTS }, { /* Logitech G Pro Gaming Mouse over USB */ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC088) }, From patchwork Thu May 27 13:41:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erica Taylor X-Patchwork-Id: 12284275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E85B5C47089 for ; Thu, 27 May 2021 13:41:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C90C26128D for ; Thu, 27 May 2021 13:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236550AbhE0NnK (ORCPT ); Thu, 27 May 2021 09:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236553AbhE0NnH (ORCPT ); Thu, 27 May 2021 09:43:07 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8204C061760; Thu, 27 May 2021 06:41:33 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id f11so1417287wrq.1; Thu, 27 May 2021 06:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=42av6mzVPz1UHZ76BiA/La0SCJcbWprbyJjdY5KanPk=; b=kUjVgGokmyR/Ib90dM14WzCWpEV7Zx3c0rTZxucvYgXc7QLwkioEsIbmMBGrPVVwVy lVWyKi1fiwEdpjq2kxoKKg15iH0rw2I6pB4HuEWTMItOdYVmt+268OUmAx0TllC56648 UCiuaHM8o62B8Ws3uns3P6u5KQ4Szb206fH65cwQLObDG7KGYpVnJFoNGkBq70uyKsje wWuQyXSkOzuPec+SVVJjs90oc9/f7+1A6CLCjr2nNVSoUpUor358gnvDZVl/b9LKVc1m FC1qGUsnNLYGOCGqa5HCaDKjcEpz8gnT0fuBln9BXV3WT9J9QsZhDl2M1qSHS1lEeB0M JMWQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=42av6mzVPz1UHZ76BiA/La0SCJcbWprbyJjdY5KanPk=; b=oE6NMiCrRpdamc7cZT9WgGhR7MZ7hSycc4fskO8m1afUFEZkP1UhdE4x8U9lhR4fUg buMxFlPufb+TOXtp5bDQQ5VrN6jgXWebuC1e5Jn3ehL1SGddI3bweHBlziaBZwxP3xum 4Qi3olYdhXyZmZB3r7tllyeRXx/0yMXIE4NuxWzKRvka04WjSvWu7qqcqid9xDWP6qvT lJoEzYUbT62S7cdCgAUdxMjV5cJbgM5Luko7cw7zlg9L9mBk2hvDGplhO2tEvdsaWuWi ostnFUJEcwy6mRw1XZ9wqHdEFt0ccsjo2VGJJSq6otsJkRNn0zvIU44Z73wOYXwO+o+K mAAw== X-Gm-Message-State: AOAM533jlD1hmfUq8tkj+eLVpzObPmLqVfv+FWcHY+oMkVNcFLh4XblI NxfqebUL2z6K4bKO4cQWbR4Fjo+EYnuHR372 X-Google-Smtp-Source: ABdhPJy556o6tWC0YcIsFt1xTFX6RlPMfpeadDdwGVTqn8HRR1EecOx0zbvwHmzoyMzG22pdOLYu5Q== X-Received: by 2002:adf:dc88:: with SMTP id r8mr3425987wrj.277.1622122892175; Thu, 27 May 2021 06:41:32 -0700 (PDT) Received: from caroline.lan (233.119.189.80.dyn.plus.net. [80.189.119.233]) by smtp.gmail.com with ESMTPSA id b10sm3741284wrr.27.2021.05.27.06.41.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 06:41:31 -0700 (PDT) From: Erica Taylor To: linux-input@vger.kernel.org Cc: Erica Taylor , Jiri Kosina , Benjamin Tissoires , Dmitry Torokhov , Lee Jones , Benjamin Valentin , Matt Reynolds , Andrzej Pietrasiewicz , Sanjay Govind , linux-kernel@vger.kernel.org, Simon Wood , Greg Kroah-Hartman Subject: [PATCH 2/2] Input: xpad - add Logitech G923 Xbox variant Date: Thu, 27 May 2021 14:41:04 +0100 Message-Id: <20210527134104.217865-3-rickytaylor26@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210527134104.217865-1-rickytaylor26@gmail.com> References: <20210527134104.217865-1-rickytaylor26@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This includes device information for the G923 as well as code to perform a protocol change to HID++. Many features do not work as-is with the xpad driver. Almost everything apart from TrueForce works under the logitech-hidpp driver. What works: - Face buttons, D-pad, Xbox button, LB, RB, switch and menu - Paddle shifters - One pedal axis What does not work: - Force feedback - TrueForce - Shifter positions - Dial and centre button - +/- buttons - Steering wheel rotation - The other two pedal axes Signed-off-by: Erica Taylor Signed-off-by: Erica Taylor Reported-by: kernel test robot Reported-by: kernel test robot --- drivers/input/joystick/xpad.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index d69d7657ab12..930283433615 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -79,6 +79,7 @@ #define MAP_DPAD_TO_BUTTONS (1 << 0) #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) #define MAP_STICKS_TO_NULL (1 << 2) +#define HIDPP_CAPABLE BIT(3) #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \ MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL) @@ -104,6 +105,10 @@ static bool auto_poweroff = true; module_param(auto_poweroff, bool, S_IWUSR | S_IRUGO); MODULE_PARM_DESC(auto_poweroff, "Power off wireless controllers on suspend"); +static bool switch_to_hidpp = true; +module_param(switch_to_hidpp, bool, 0444); +MODULE_PARM_DESC(switch_to_hidpp, "Switch appropriate devices over to the HID++ protocol"); + static const struct xpad_device { u16 idVendor; u16 idProduct; @@ -333,6 +338,8 @@ static const struct xpad_device { { 0x24c6, 0x5d04, "Razer Sabertooth", 0, XTYPE_XBOX360 }, { 0x24c6, 0xfafe, "Rock Candy Gamepad for Xbox 360", 0, XTYPE_XBOX360 }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, + { 0x046d, 0xc262, "Logitech G920 Wheel (Xbox Mode)", HIDPP_CAPABLE, XTYPE_XBOXONE }, + { 0x046d, 0xc26d, "Logitech G923 Wheel (Xbox Mode)", HIDPP_CAPABLE, XTYPE_XBOXONE }, { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } }; @@ -420,6 +427,7 @@ static const struct usb_device_id xpad_table[] = { XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */ XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */ XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */ + XPAD_XBOXONE_VENDOR(0x046d), /* Logitech X-Box One style controllers */ XPAD_XBOX360_VENDOR(0x056e), /* Elecom JC-U3613M */ XPAD_XBOX360_VENDOR(0x06a3), /* Saitek P3600 */ XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */ @@ -558,6 +566,17 @@ static const struct xboxone_init_packet xboxone_init_packets[] = { XBOXONE_INIT_PKT(0x24c6, 0x543a, xboxone_rumbleend_init), }; +/* + * A magic packet sent to Logitech devices to tell them to change to the HID++ + * protocol. This is preferred when in use on a PC. + * + * After receiving this packet, the device will disconnect and reappear with + * a different productId, which will be picked up by the Logitech HID++ driver. + */ +static const u8 switch_to_hidpp_cmd[] = { + 0x0f, 0x00, 0x01, 0x01, 0x42 +}; + struct xpad_output_packet { u8 data[XPAD_PKT_LEN]; u8 len; @@ -998,6 +1017,14 @@ static bool xpad_prepare_next_init_packet(struct usb_xpad *xpad) return true; } + if (switch_to_hidpp && xpad->mapping & HIDPP_CAPABLE) { + dev_dbg(&xpad->intf->dev, "%s - switching to HID++", __func__); + memcpy(xpad->odata, g923_hidpp_init, ARRAY_SIZE(g923_hidpp_init)); + xpad->irq_out->transfer_buffer_length = ARRAY_SIZE(g923_hidpp_init); + xpad->odata[2] = xpad->odata_serial++; + return true; + } + return false; }